stage2 提供近乎完整的功能但出现严重性能问题 添加stage0的原生性能记录 stage1添加更多内置函数 nob重构代码使其更加健壮

This commit is contained in:
zzy committed 2026-09-19 18:08:43 +08:00
1 parent b5a7a811b3
commit e02b0c633a
35 files changed
+14018 -216

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
// Expect retcode = 0
// 时间/参考量接口(原生 vm_timestamp,case 探测风格,不假设一定可用)。
// available() -> 1 = 时间可用;0 = 不可用(其余 time 相关返回值恒为 0)
// sec() -> 当前秒
// ns() -> 当前纳秒部分
// steps() -> VM 已执行指令数(参考量)
// now_ns() -> 完整纳秒时间戳(单次调用;纪元纳秒 < 2^64,无需 i128)
#extern(vm) fn vm_timestamp(kind: usize): usize;
fn available(): usize {
ret vm_timestamp(0);
}
fn sec(): usize {
ret vm_timestamp(1);
}
fn ns(): usize {
ret vm_timestamp(2);
}
fn steps(): usize {
ret vm_timestamp(3);
}
fn now_ns(): usize {
ret vm_timestamp(4);
}
fn main(): void {
var has = available();
if has != 0 {
var a = now_ns();
var b = now_ns();
@assert(b >= a, "now monotonic");
}
var s0 = steps();
var i: usize = 0;
while i < 1000 { i = i + 1; }
var s1 = steps();
@assert(s1 >= s0, "steps monotonic");
}