831 Commits

Author SHA1 Message Date
pjh123 1f2a020585 feat: Iterator helpers 基建——Symbol.dispose 注册与 %IteratorHelperPrototype% 2026-08-16 14:44:47 +08:00
pjh123 84f84402ba fix: 绑定侧解构计算键参与闭包捕获遍历防静默错值 2026-08-16 14:30:20 +08:00
pjh123 7de55b25d8 refactor: 测试断言改 assert! 2026-08-16 14:04:27 +08:00
pjh123 1a244398f1 refactor: match 可改 ? 的等价改写 2026-08-16 14:04:25 +08:00
pjh123 fd2b290927 feat: 解构计算键通用 fallback 支持任意键表达式 2026-08-16 13:49:17 +08:00
pjh123 457b1b874d fix: new 表达式 native 构造收口 call_function_sync 防 255/254 槽污染 2026-08-16 13:41:01 +08:00
pjh123 1da9c98e62 fix: for-in/for-of 头名仅 var 提升入入口初始化名单,排除 let/const 2026-08-16 13:32:25 +08:00
pjh123 8f7d0f1186 fix: 类表达式真实名 cell 按声明路径门控,不再覆盖外层同名绑定 2026-08-16 13:32:25 +08:00
pjh123 5df04a8e58 chore: 全仓 rustfmt 格式化归拢 2026-08-16 12:50:36 +08:00
pjh123 4572ecffaa feat: new.target MetaProperty emit 支持(LOAD_VAR NewTarget) 2026-08-16 12:43:50 +08:00
pjh123 2755894330 test: upvalue cell 时序判别用例(class 捕获/var 入口初始化/参数默认值链式捕获) 2026-08-16 12:34:14 +08:00
pjh123 23a5f35ae1 fix: 闭包链式捕获越界改编译错误早暴露防静默错值 2026-08-16 12:34:14 +08:00
pjh123 4911c058d8 fix: var 捕获绑定函数与程序入口统一初始化为 undefined 消除 TDZ 误报 2026-08-16 12:34:10 +08:00
pjh123 331691e8bd fix: class 声明名纳入闭包捕获,嵌套函数经 cell 读取类绑定 2026-08-16 12:34:03 +08:00
pjh123 43c7ca1fd6 feat: 私有字段复合赋值 emit 支持(GET_PRIVATE→op→SET_PRIVATE 序列) 2026-08-16 12:12:26 +08:00
pjh123 82c088ac9f fix: for-await-of 同步迭代器 return() 忽略路径补异常值槽配对 2026-08-16 12:00:59 +08:00
pjh123 75f28f6e3e fix: class 生成器方法补 is_generator 标志,修正方法形态生成器语义 2026-08-16 11:44:20 +08:00
pjh123 16793d3b36 fix: 异常值通道配对——忽略调用槽配对、unwind 接住清槽、生成器参数初始化不覆盖异常值 2026-08-16 11:29:50 +08:00
pjh123 afa79aa5fb fix: Date 多参构造年 0-99 按规范映射到 1900-1999 2026-08-16 10:58:50 +08:00
pjh123 e97473c8ad fix: Date 普通调用忽略参数并移除 RFC2822 panic 2026-08-16 10:58:12 +08:00
pjh123 d237b4b70e fix: clear_ic_caches ext 计数补登 BREAK/CONTINUE/RETURN 2026-08-16 10:43:03 +08:00
pjh123 8ac26fc01f fix: IC 快速路径 symbol 原始值走 Symbol.prototype 链 2026-08-16 10:31:34 +08:00
pjh123 a8378694be fix: for-of/for-in 提前退出时按规范顺序完成 IteratorClose
return/break/continue 逃出 for-of 时此前完全不执行 IteratorClose:
BREAK/CONTINUE/RETURN 指令现在经 ext 字携带词法逃出的迭代器层数
(for-of + for-in 各 16 位),运行时在全部 finally 穿越之后、真正
跳转/返回之前按 LIFO 关闭——与规范 §13.7.5.4(循环体完成值已含
内部 try-finally 处理,IteratorClose 在后)顺序一致。

- emit 词法:LabelCtx 增加 for-of/for-in 深度计数,loop/switch/label
  打开时快照,break/continue/return 按当前深度减目标深度计算逃出层数
  (switch 内 break 以 switch 打开点为基准,目标循环自身不计入)
- 指令编码:brk/cont/ret 三参构造,lower 跳转路径补发 ext 字
- 运行时:dispatch_break/continue/return 读取逃出计数,无 finally 时
  直接关闭后跳转/返回,有 finally 时随 Completion 悬挂由 TRY_FINALLY_END
  在穿越完成后消费;生成器 .return()/.throw() 注入经 complete_generator_return
  全关快照栈迭代器;return() 抛错经 unwind 替代完成值并关闭剩余迭代器
- 顺带:for-in 逃出残留(无 return() 语义,仅弹栈);for-await-of 的
  异步迭代器不做同步关闭(return() promise 须 await,走异步机制)
- 新增 15 项回归测试:return/labeled break/continue/switch/while/finally
  顺序/抛错优先/生成器注入/for-in/for-await-of 嵌套
2026-08-16 09:31:39 +08:00
pjh123 b885b672b9 for-of 迭代器栈条目化:迭代器与最近 next 结果配对存放
单一 last_for_of_result 槽被嵌套迭代覆盖,CLOSE 判定本迭代器是否
自然 done 时误读他者结果,导致数组解构/spread/嵌套 for-of 提前退出
漏调或误调 return()。改为栈条目 (iterator, last_result) 配对:

- IterState.for_of_iters 元素改 ForOfEntry,删除 last_for_of_result
- INIT 压条目,DONE 写本条目,NEXT/CLOSE 读本条目结果判 done
- GC mark/rewrite、inline save/restore、挂起帧快照同步配对遍历
- for-await-of 数组解构提前 break 现正确触发 return()(任务 40 样例)
2026-08-16 04:00:06 +08:00
pjh123 19fcdd73d0 fix: Date 构造器缺省字段与溢出滚动语义符合规范
多参缺省字段固定为日=1、时分秒毫秒=0(不再取当前时刻);
月/日/时等分量越界按 MakeDay/MakeTime 滚动进位,负月同样归一;
单参字符串与 Date.parse 支持时区偏移(Z/+hh:mm/+hhmm)折算 UTC,
修复此前 NaiveDateTime 解析静默丢弃偏移的问题。
2026-08-16 03:43:42 +08:00
pjh123 1a2d8682ae fix: builtins 对象分配统一走 alloc_object 登记消除高频路径泄漏 2026-08-16 03:36:02 +08:00
pjh123 63ccb0fcf3 regalloc: 建图只遍历活集 + rewrite use 点按指令分组
graph 建边由逐指令全 node 扫描(O(insts × nodes),活集小也扫全表)
改为只遍历该指令活集中置位的 vreg(u64 位集 trailing_zeros 升序,
与 node 表升序遍历逐字节同序,确定性不漂移)。rewrite 主循环对每
指令全扫全局 uses 表(O(insts × spills) 二次方)改为按指令分组的
use 点列表,只取本指令的 use 点。

实测(debug,test262 identifiers 最大样本):plain 17.0.0
16.9s → 1.06s(-94%),class 9.0.0 7.0s → 1.61s(-77%),
均低于 2s 达标线;identifiers 子集 268/268 全 PASS(原 32 个
10s 超时全部转 PASS)。
2026-08-16 03:26:57 +08:00
pjh123 9bbe5ae67a liveness: live 集改 u64 位集 + 不动点缓冲复用
LiveInfo 四矩阵由逐位 Vec<bool>(1 字节/位,长度 = max_vreg+1)改为
u64 压缩位集(1 字 64 位,长度 ÷8),dataflow 不动点 out/input 缓冲
提为循环外复用(clear + 覆盖,免逐迭代逐块分配)。dce_precise /
graph 建图 / call_window 三处消费方同步改为字内位移查询,越界语义
与旧 Vec<bool>::get 一致(越界 = 不 live)。位集遍历(call_window
存活上界)按 trailing_zeros 只走实际置位,活集小则近 O(活集) 而非
O(254)。

实测(debug,start-unicode-17.0.0.js):liveness 三趟合计
~536ms → ~118ms(-78%),矩阵内存 ÷8;graph 全 node 扫描为剩余
瓶颈,另行跟进。
2026-08-16 03:20:02 +08:00
pjh123 f899538535 regalloc: LiveInfo 维度守卫改 Cow 借用,合法路径免全量复制
alloc 与 encode_call_window 在 LiveInfo 维度匹配(正常路径)时仍全量
clone 稠密 bitset 矩阵,随后只读消费。改为 Cow::Borrowed 借用原分析
结果,维度不符才 Cow::Owned 重建。零语义变化,消除每次 alloc/编码
的无谓内存复制。
2026-08-16 03:03:55 +08:00
pjh123 0737ce3ef1 test262: supervise 模式回传失败类别,汇总可按根因拆分
子进程心跳扩展失败分类计数(类别\t计数逐行写出),supervise_window
聚合为 RunStats 而非裸三计数,父进程汇总打印 FAIL categories(与
in-process 共用 print_fail_categories)。此前子进程 stdout 被丢弃、
heartbeat 只带 pass/fail/skip,categorize_fail 在 supervise 下完全
不可用,10k+ fail 无法按 VM/parse/compile 根因拆分;现在类别基线
可数据化。超时/崩溃归入 timeout/crash 类别。
2026-08-16 02:50:29 +08:00
pjh123 2b86cd241d test262: $262 宿主对象最小绑定 + is not defined 判定白名单化
引擎侧:绑定 $262 宿主对象(evalScript/global/gc 可用,detachArrayBuffer/
createRealm/agent 抛 not supported 而非 ReferenceError),并加入编译期
已知全局表;引用 $262.* 的测试从全量 skip 转为真实执行。

runner 侧:is not defined 不再一票吞 skip——解析错误消息中的标识符名,
仅在缺失全局白名单($262/structuredClone/queueMicrotask)内才按能力
缺失跳过;其余 is not defined 按真实失败计入,修复后应转 PASS 的
测试恢复可见。
2026-08-16 02:47:02 +08:00
pjh123 1a03213390 test262: skip 判定收窄——receiver 校验等已实现语义错误转真实失败
judge_vm_error 抽出纯函数 classify_vm_error 并补充表驱动单测;
将 call stack size exceeded / not callable / ToPrimitive 缺口 / receiver
校验(called on non-Set 等)12 条错误子串移出 skip 列表:这些是引擎
行为与测试期望不符的真实失败,此前被误计为 skip,fail 数被系统性低估。
保留的 skip 仅限真正的能力未实现形态(not yet implemented / not
supported / NEW_EXPRESSION 等)。
2026-08-16 02:46:17 +08:00
pjh123 06441e09ff fix: 全局构造器与内置对象属性改非枚举与规范对齐 2026-08-16 02:29:42 +08:00
pjh123 355b0233f0 fix: NEW_OBJECT 走统一分配入口登记 epoch 对象消除属性向量泄漏 2026-08-16 02:16:34 +08:00
pjh123 5de959e2bd fix: String 方法 Symbol 参数抛 TypeError 且缺参按 undefined 查找
as_string 由兜底转换改 Result 化:Symbol 与其余转换失败抛
TypeError,对象 ToString 抛出的原生异常经 take_uncaught_value
原样传播,不再静默降级为空串/占位文本。17 处调用点统一经
try_string! 抛错。

indexOf/includes/startsWith/endsWith/lastIndexOf 删除缺参短路:
searchString 缺省按 ToString(undefined)="undefined" 参与查找,
'undefined'.indexOf() 现得 0。

类正则对象(Object.create(RegExp.prototype))默认 toString 抛
TypeError 的 replace/split 用例随异常传播行为更新断言。
2026-08-16 02:08:13 +08:00
pjh123 0c6aa7fbef fix: 构造帧 super 状态改显式标志修复多层继承与 return 语义
derived 构造器 super 状态改由 CallFrame.super_called 显式标志承载,
取代依赖 regs[254] 值判定:多层继承中间 derived 帧由 SUPER_CALL 压入
this=构造对象,值判定三重失效(未调 super 不报错 / this-before-super
失效 / 合法 super() 误判 more-than-once)。父构造器正常返回经
construct_result_reg==Some(254) 识别置位调用方帧(该 ABI 不变量仅
SUPER_CALL 压帧满足),抛错走 unwind 不置位。

do_return 检查放宽为非对象返回值(含 undefined/null/原始值)且未调
super 时抛 ReferenceError(规范 §9.2.2.2),调过 super 回退构造 this。

super 构造器改取当前帧 callee 原型而非 newTarget 原型:newTarget 跨
SUPER_CALL 压帧保持为最外层类,取其原型在中间 derived 层解析回同一
父类导致无限压帧。
2026-08-16 01:23:52 +08:00
pjh123 946c96472f fix: object 家族 dirty 时重建迭代器绑定并对齐 Iterator.prototype,绑定幂等化避免重复槽 2026-08-16 00:25:30 +08:00
pjh123 d309379551 fix: 未声明标识符读取抛 ReferenceError(typeof 特判返回 undefined) 2026-08-16 00:10:08 +08:00
pjh123 e448c642a5 fix: 迭代器原型形状补全(Iterator.prototype/string 中继层/next 原型化) 2026-08-15 23:36:01 +08:00
pjh123 3358cf712e fix: 非常量键成员 **= 复合赋值 rhs 生效 2026-08-15 23:20:36 +08:00
pjh123 2a447b17fe fix: 块内函数声明预声明支持(Annex B 块级绑定) 2026-08-15 23:13:26 +08:00
pjh123 ec32e42ce5 feat: 迭代器原型基建:%IteratorPrototype% 链 + 各集合迭代器原型
新增 %IteratorPrototype%(含 @@iterator 返回自身,经原型链被全部迭代器
继承,it[Symbol.iterator]() === it 恒等)与 %ArrayIteratorPrototype%/
%MapIteratorPrototype%/%SetIteratorPrototype%/%StringIteratorPrototype%/
%RegExpStringIteratorPrototype%(链到 %IteratorPrototype%);Array/Map/Set/
TA/String/matchAll 迭代器包装统一挂对应原型;补 Array/String 的 @@iterator
别名绑定。集合迭代器原型不含 return 方法(规范集合迭代器无 return)。
2026-08-15 22:57:03 +08:00
pjh123 c230edeb57 feat: Function.prototype[Symbol.hasInstance] 绑定与 bound 函数构造语义
@@hasInstance 按 OrdinaryHasInstance 实现(非可调用 this 返回 false、
prototype 非对象抛 TypeError、bound 链递归到最内层 target);
new boundFn() 解包 [[BoundTargetFunction]] 链后转发构造:绑定实参前置、
新对象原型取 target.prototype、new.target 替换为最内层 target。
2026-08-15 22:40:45 +08:00
pjh123 d83d598221 fix: parseInt/parseFloat 对象参数按 ToString 完整转换并传播异常
对象参数走 ToPrimitive(string hint) 后取串解析(toString 结果可见),
Symbol 抛 TypeError,对象方法抛出的原始异常原样传播。
2026-08-15 22:32:14 +08:00
pjh123 9390ed6be4 fix: for-const 循环 update 段豁免 const 写检查(per-iteration 绑定合法) 2026-08-15 22:29:09 +08:00
pjh123 3e34607380 fix: Promise.prototype.then 按构造器建派生能力支持子类 2026-08-15 22:16:05 +08:00
pjh123 07ea7e6d4f fix: TDZ 写与 const 赋值检查补全(含闭包捕获路径) 2026-08-15 21:55:43 +08:00
pjh123 2669967967 fix: parseInt/parseFloat 前缀解析与 radix 语义符合规范 2026-08-15 21:40:27 +08:00
pjh123 07d6c83c6b fix: 错误对象属性枚举性、toString 标签与构造器调用语义
- message/name 属性改非枚举(CreateNonEnumerableDataPropertyOrThrow),
  Object.keys/for-in/JSON.stringify 不再泄漏错误信息
- 新增 Error 家族对象标签,Object.prototype.toString 输出 [object Error],
  含子类型与用户子类(沿原型链判定)
- Error 家族构造器补 length=1,函数调用忽略 this 一律新建对象
- JSON.stringify 序列化仅含可枚举自身属性(规范 EnumerableOwnPropertyNames)
2026-08-15 21:30:28 +08:00
pjh123 c4961fae29 feat: 二元幂运算 opcode 支持 number 与 BigInt
- 新增 EXP opcode(0x94)与 emit 层 Exponential 分支,二元 a ** b 不再 compile error
- dispatch_exp 与 dispatch_compound_exp 共享 exp_result:IEEE-754 powf 快路径 +
  BigInt 幂(负/超 u32 指数 RangeError)+ 混合 BigInt/Number TypeError
- 复合 **= 补 BigInt 语义(此前走 f64 近似),与二元 ** 行为一致
2026-08-15 21:17:49 +08:00