@mica-js/simulator 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/device.d.ts +90 -1
- package/dist/index.d.ts +90 -1
- package/dist/index.js +601 -16
- package/dist/index.js.map +1 -1
- package/dist/sandbox.js +1 -1
- package/package.json +4 -4
package/dist/device.d.ts
CHANGED
|
@@ -118,11 +118,62 @@ declare interface JitDelay {
|
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/** Direct 时间准入声明;`service` 引用本实例 number 状态,`blocked` 引用安静的 pure fn 且依赖 `service`。 */
|
|
122
|
+
export declare interface JitDirectTiming {
|
|
123
|
+
/**
|
|
124
|
+
* 定时服务状态名:`elapsed` 是自同一上次结算点起的已累计量,`deadline` 是该时点的期限,
|
|
125
|
+
* 单位均为 ps;`deadline` 为 0 表示当前无定时服务。两项须在运行时为非负安全整数,
|
|
126
|
+
* 否则候选使用普通指令路径。
|
|
127
|
+
*/
|
|
128
|
+
readonly service?: {
|
|
129
|
+
/** 自同一上次结算点起的已累计时间,单位 ps。 */
|
|
130
|
+
readonly elapsed: string;
|
|
131
|
+
/** 自同一上次结算点起的期限,单位 ps;0 表示无定时服务。 */
|
|
132
|
+
readonly deadline: string;
|
|
133
|
+
};
|
|
134
|
+
/** 依赖 `service`;缺少 `service` 时注册被拒绝。同步、确定、不抛错且只读的无参 bool `pure fn`;为真时使用普通指令路径。 */
|
|
135
|
+
readonly blocked?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** 同步翻译期提供的 Direct 时间候选标记;仅本次 `translate` 回调内有效。 */
|
|
139
|
+
export declare interface JitDirectTimingInput {
|
|
140
|
+
/**
|
|
141
|
+
* 标记返回块中从 `pc` 起、共 `instructionCount`(2–8)条连续指令组成的合块:纯定长
|
|
142
|
+
* 前缀后接一条普通 GPIO/SFR 终结写。非法、重复或无法证明的标记只取消该优化。
|
|
143
|
+
*/
|
|
144
|
+
readonly markDirectSpan?: (pc: number, instructionCount: number) => void;
|
|
145
|
+
/** 标记以 `pc` 为环头的自回跳循环;非法或冲突的标记只取消该优化。 */
|
|
146
|
+
readonly markDirectLoop?: (pc: number, candidate: JitLoopCandidate) => void;
|
|
147
|
+
}
|
|
148
|
+
|
|
121
149
|
export declare interface JitHost {
|
|
122
150
|
attachJit(options: JitOptions): Disposable;
|
|
123
151
|
loadBytes(memory: string, bytes: Uint8Array, offset?: number): void;
|
|
124
152
|
}
|
|
125
153
|
|
|
154
|
+
/** 循环计数地址:常量偏移,或由选择字节按 `(selectorByte & mask) | bits` 合成的字节偏移。 */
|
|
155
|
+
export declare type JitLoopAddress = {
|
|
156
|
+
readonly kind: 'constant';
|
|
157
|
+
readonly offset: number;
|
|
158
|
+
} | {
|
|
159
|
+
readonly kind: 'maskedByte';
|
|
160
|
+
readonly memory: string;
|
|
161
|
+
readonly offset: number;
|
|
162
|
+
/** 选择字节的位掩码。 */
|
|
163
|
+
readonly mask: number;
|
|
164
|
+
/** 合成地址中置位的位。 */
|
|
165
|
+
readonly bits: number;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/** 忙等循环候选:无计数器的自跳,或每轮递减一字节并按新值非零自跳。 */
|
|
169
|
+
export declare type JitLoopCandidate = {
|
|
170
|
+
readonly kind: 'spin';
|
|
171
|
+
} | {
|
|
172
|
+
readonly kind: 'decrement8';
|
|
173
|
+
readonly memory: string;
|
|
174
|
+
readonly address: JitLoopAddress;
|
|
175
|
+
};
|
|
176
|
+
|
|
126
177
|
export declare interface JitOptions {
|
|
127
178
|
readonly entry: string;
|
|
128
179
|
readonly code: string;
|
|
@@ -144,11 +195,38 @@ export declare interface JitOptions {
|
|
|
144
195
|
readonly beforeInstruction?: InstructionHook;
|
|
145
196
|
readonly polling?: readonly JitPolling[];
|
|
146
197
|
readonly delays?: ReadonlyMap<number, JitDelay>;
|
|
198
|
+
/**
|
|
199
|
+
* Direct 时间准入:`service` 指向本实例的定时服务 number 状态,`blocked` 指向安静条件。
|
|
200
|
+
* 省略时同步翻译不提供 `markDirectSpan`/`markDirectLoop`,不做时间候选登记;普通 Direct
|
|
201
|
+
* 仍按宿主上限和其余准入条件执行。
|
|
202
|
+
*/
|
|
203
|
+
readonly directTiming?: JitDirectTiming;
|
|
147
204
|
/**
|
|
148
205
|
* 启用 Direct 指令体共享:同步翻译期间提供 `markDirectBodyShareable`,并只把通过
|
|
149
206
|
* 运行时校验的等价候选交给 Direct 会话。仅省略时为 false;关闭时所有入口独立执行。
|
|
150
207
|
*/
|
|
151
208
|
readonly shareDirectBodies?: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* 启用跨实例 Direct 编译工件共享:显式 `true` 时,同进程中的注册共享有界的指令模板与
|
|
211
|
+
* 分片工厂缓存。省略或 `false` 时,每个注册使用独立工件缓存,只在本注册内复用,
|
|
212
|
+
* 保持原生产默认。
|
|
213
|
+
*/
|
|
214
|
+
readonly shareDirectArtifacts?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* 跨实例翻译工件身份:`abi` 标识生成器与融合规则,`configuration` 标识时钟及特化配置。
|
|
217
|
+
* 省略时翻译结果只用于当前实例。
|
|
218
|
+
*/
|
|
219
|
+
readonly translationIdentity?: {
|
|
220
|
+
readonly abi: string;
|
|
221
|
+
readonly configuration: string;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* 两级 Direct 执行。省略时保持即时 Direct;设置后每个本地路由从共享通用级开始,
|
|
225
|
+
* 成功完成的真实指令达到正安全整数 `promoteAfter` 后晋升。
|
|
226
|
+
*/
|
|
227
|
+
readonly directTier?: {
|
|
228
|
+
readonly promoteAfter: number;
|
|
229
|
+
};
|
|
152
230
|
readonly translate: JitTranslate;
|
|
153
231
|
}
|
|
154
232
|
|
|
@@ -175,7 +253,7 @@ declare interface JitPolling {
|
|
|
175
253
|
|
|
176
254
|
export declare type JitTranslate = (input: JitTranslateInput, builder: JitBlockBuilder) => BlockIR;
|
|
177
255
|
|
|
178
|
-
export declare interface JitTranslateInput {
|
|
256
|
+
export declare interface JitTranslateInput extends JitDirectTimingInput {
|
|
179
257
|
readonly pc: number;
|
|
180
258
|
/** 仅在本次同步 translate 回调内有效;长度最多为本 region 的 `size`。 */
|
|
181
259
|
readonly code: BorrowedBytes;
|
|
@@ -189,6 +267,17 @@ export declare interface JitTranslateInput {
|
|
|
189
267
|
* 必须各自对应返回块中不同的指令入口。
|
|
190
268
|
*/
|
|
191
269
|
readonly markDirectBodyShareable?: (pc: number, byteLength: number) => void;
|
|
270
|
+
/**
|
|
271
|
+
* 报告影响本次翻译 IR 的借用视图物理代码区间。运行时先确认偏移与长度均为非负安全
|
|
272
|
+
* 整数且落在视图内;当前只校验,不保留借用视图。
|
|
273
|
+
*/
|
|
274
|
+
readonly markTranslationDependencies?: (ranges: readonly JitTranslationDependency[]) => void;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** 影响本次翻译 IR 的借用代码字节区间,单位为所属 region 内的偏移。 */
|
|
278
|
+
export declare interface JitTranslationDependency {
|
|
279
|
+
readonly offset: number;
|
|
280
|
+
readonly length: number;
|
|
192
281
|
}
|
|
193
282
|
|
|
194
283
|
declare interface Notification_2 {
|
package/dist/index.d.ts
CHANGED
|
@@ -287,11 +287,62 @@ export declare interface JitDelay {
|
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
/** Direct 时间准入声明;`service` 引用本实例 number 状态,`blocked` 引用安静的 pure fn 且依赖 `service`。 */
|
|
291
|
+
export declare interface JitDirectTiming {
|
|
292
|
+
/**
|
|
293
|
+
* 定时服务状态名:`elapsed` 是自同一上次结算点起的已累计量,`deadline` 是该时点的期限,
|
|
294
|
+
* 单位均为 ps;`deadline` 为 0 表示当前无定时服务。两项须在运行时为非负安全整数,
|
|
295
|
+
* 否则候选使用普通指令路径。
|
|
296
|
+
*/
|
|
297
|
+
readonly service?: {
|
|
298
|
+
/** 自同一上次结算点起的已累计时间,单位 ps。 */
|
|
299
|
+
readonly elapsed: string;
|
|
300
|
+
/** 自同一上次结算点起的期限,单位 ps;0 表示无定时服务。 */
|
|
301
|
+
readonly deadline: string;
|
|
302
|
+
};
|
|
303
|
+
/** 依赖 `service`;缺少 `service` 时注册被拒绝。同步、确定、不抛错且只读的无参 bool `pure fn`;为真时使用普通指令路径。 */
|
|
304
|
+
readonly blocked?: string;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** 同步翻译期提供的 Direct 时间候选标记;仅本次 `translate` 回调内有效。 */
|
|
308
|
+
export declare interface JitDirectTimingInput {
|
|
309
|
+
/**
|
|
310
|
+
* 标记返回块中从 `pc` 起、共 `instructionCount`(2–8)条连续指令组成的合块:纯定长
|
|
311
|
+
* 前缀后接一条普通 GPIO/SFR 终结写。非法、重复或无法证明的标记只取消该优化。
|
|
312
|
+
*/
|
|
313
|
+
readonly markDirectSpan?: (pc: number, instructionCount: number) => void;
|
|
314
|
+
/** 标记以 `pc` 为环头的自回跳循环;非法或冲突的标记只取消该优化。 */
|
|
315
|
+
readonly markDirectLoop?: (pc: number, candidate: JitLoopCandidate) => void;
|
|
316
|
+
}
|
|
317
|
+
|
|
290
318
|
export declare interface JitHost {
|
|
291
319
|
attachJit(options: JitOptions): Disposable;
|
|
292
320
|
loadBytes(memory: string, bytes: Uint8Array, offset?: number): void;
|
|
293
321
|
}
|
|
294
322
|
|
|
323
|
+
/** 循环计数地址:常量偏移,或由选择字节按 `(selectorByte & mask) | bits` 合成的字节偏移。 */
|
|
324
|
+
export declare type JitLoopAddress = {
|
|
325
|
+
readonly kind: 'constant';
|
|
326
|
+
readonly offset: number;
|
|
327
|
+
} | {
|
|
328
|
+
readonly kind: 'maskedByte';
|
|
329
|
+
readonly memory: string;
|
|
330
|
+
readonly offset: number;
|
|
331
|
+
/** 选择字节的位掩码。 */
|
|
332
|
+
readonly mask: number;
|
|
333
|
+
/** 合成地址中置位的位。 */
|
|
334
|
+
readonly bits: number;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
/** 忙等循环候选:无计数器的自跳,或每轮递减一字节并按新值非零自跳。 */
|
|
338
|
+
export declare type JitLoopCandidate = {
|
|
339
|
+
readonly kind: 'spin';
|
|
340
|
+
} | {
|
|
341
|
+
readonly kind: 'decrement8';
|
|
342
|
+
readonly memory: string;
|
|
343
|
+
readonly address: JitLoopAddress;
|
|
344
|
+
};
|
|
345
|
+
|
|
295
346
|
export declare interface JitOptions {
|
|
296
347
|
readonly entry: string;
|
|
297
348
|
readonly code: string;
|
|
@@ -313,11 +364,38 @@ export declare interface JitOptions {
|
|
|
313
364
|
readonly beforeInstruction?: InstructionHook;
|
|
314
365
|
readonly polling?: readonly JitPolling[];
|
|
315
366
|
readonly delays?: ReadonlyMap<number, JitDelay>;
|
|
367
|
+
/**
|
|
368
|
+
* Direct 时间准入:`service` 指向本实例的定时服务 number 状态,`blocked` 指向安静条件。
|
|
369
|
+
* 省略时同步翻译不提供 `markDirectSpan`/`markDirectLoop`,不做时间候选登记;普通 Direct
|
|
370
|
+
* 仍按宿主上限和其余准入条件执行。
|
|
371
|
+
*/
|
|
372
|
+
readonly directTiming?: JitDirectTiming;
|
|
316
373
|
/**
|
|
317
374
|
* 启用 Direct 指令体共享:同步翻译期间提供 `markDirectBodyShareable`,并只把通过
|
|
318
375
|
* 运行时校验的等价候选交给 Direct 会话。仅省略时为 false;关闭时所有入口独立执行。
|
|
319
376
|
*/
|
|
320
377
|
readonly shareDirectBodies?: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* 启用跨实例 Direct 编译工件共享:显式 `true` 时,同进程中的注册共享有界的指令模板与
|
|
380
|
+
* 分片工厂缓存。省略或 `false` 时,每个注册使用独立工件缓存,只在本注册内复用,
|
|
381
|
+
* 保持原生产默认。
|
|
382
|
+
*/
|
|
383
|
+
readonly shareDirectArtifacts?: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* 跨实例翻译工件身份:`abi` 标识生成器与融合规则,`configuration` 标识时钟及特化配置。
|
|
386
|
+
* 省略时翻译结果只用于当前实例。
|
|
387
|
+
*/
|
|
388
|
+
readonly translationIdentity?: {
|
|
389
|
+
readonly abi: string;
|
|
390
|
+
readonly configuration: string;
|
|
391
|
+
};
|
|
392
|
+
/**
|
|
393
|
+
* 两级 Direct 执行。省略时保持即时 Direct;设置后每个本地路由从共享通用级开始,
|
|
394
|
+
* 成功完成的真实指令达到正安全整数 `promoteAfter` 后晋升。
|
|
395
|
+
*/
|
|
396
|
+
readonly directTier?: {
|
|
397
|
+
readonly promoteAfter: number;
|
|
398
|
+
};
|
|
321
399
|
readonly translate: JitTranslate;
|
|
322
400
|
}
|
|
323
401
|
|
|
@@ -344,7 +422,7 @@ export declare interface JitPolling {
|
|
|
344
422
|
|
|
345
423
|
export declare type JitTranslate = (input: JitTranslateInput, builder: JitBlockBuilder) => BlockIR;
|
|
346
424
|
|
|
347
|
-
export declare interface JitTranslateInput {
|
|
425
|
+
export declare interface JitTranslateInput extends JitDirectTimingInput {
|
|
348
426
|
readonly pc: number;
|
|
349
427
|
/** 仅在本次同步 translate 回调内有效;长度最多为本 region 的 `size`。 */
|
|
350
428
|
readonly code: BorrowedBytes;
|
|
@@ -358,6 +436,17 @@ export declare interface JitTranslateInput {
|
|
|
358
436
|
* 必须各自对应返回块中不同的指令入口。
|
|
359
437
|
*/
|
|
360
438
|
readonly markDirectBodyShareable?: (pc: number, byteLength: number) => void;
|
|
439
|
+
/**
|
|
440
|
+
* 报告影响本次翻译 IR 的借用视图物理代码区间。运行时先确认偏移与长度均为非负安全
|
|
441
|
+
* 整数且落在视图内;当前只校验,不保留借用视图。
|
|
442
|
+
*/
|
|
443
|
+
readonly markTranslationDependencies?: (ranges: readonly JitTranslationDependency[]) => void;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/** 影响本次翻译 IR 的借用代码字节区间,单位为所属 region 内的偏移。 */
|
|
447
|
+
export declare interface JitTranslationDependency {
|
|
448
|
+
readonly offset: number;
|
|
449
|
+
readonly length: number;
|
|
361
450
|
}
|
|
362
451
|
|
|
363
452
|
declare const libraryTag: unique symbol;
|