Skip to content

perf(vm): bypass runtime coercion for primitive operands - #13

Open
Eric-Song-Nop wants to merge 3 commits into
perf/static-property-atomsfrom
perf/primitive-coercion-fast-path
Open

perf(vm): bypass runtime coercion for primitive operands#13
Eric-Song-Nop wants to merge 3 commits into
perf/static-property-atomsfrom
perf/primitive-coercion-fast-path

Conversation

@Eric-Song-Nop

Copy link
Copy Markdown

Stacked on #12. Base: perf/static-property-atoms; head: perf/primitive-coercion-fast-path, both in pocket-stack/quickjs-oxide. Review and merge in dependency order.

Migrated from Eric-Song-Nop#3 with identical commits and preserved measurement/validation evidence.

Change / 修改

Arithmetic and comparison instructions used to send primitive operands through VmHost into Runtime::to_primitive before receiving the same value back. Add one inline VM ToPrimitive entry point: return primitives unchanged and delegate objects, with the original hint, to the existing host. Numeric preparation and unary/add/comparison instructions share that entry point; arithmetic, result tagging, string/BigInt handling and object conversion remain single implementations.

数值与比较指令此前把原始值送入 VmHost/Runtime 后再原样返回。现在通过一个共享 VM ToPrimitive 入口直接返回原始值,对象及原 hint 交给现有 host。数值准备与一元/加法/比较复用入口,计算、结果标签、字符串/BigInt 与对象转换规则保持单一实现。

Related issue / 关联 issue: #8

Validation / 验证

  • 3,002 Rust workspace tests passed; 0 failed; 1 existing ignored. Tests exercise primitive host bypass, representation/NaN-bit preservation, object hints/order/abrupt completion and mixed numeric semantics. / 3002 项通过,0 失败,1 项原有忽略。
  • Formatting, source layout, Rust-only and strict production Clippy passed in profiling/default/test262-host configurations. / 格式、布局、Rust-only 和三种配置的生产目标 strict Clippy 通过。
  • Full Test262 ran on both revisions: 102,037 outcome rows identical, zero new failures. Only the first source-fingerprint header differs; both frozen full-file receipt gates still exit 1, and no baseline was updated. / 前后完整 Test262 结果逐行一致;冻结文件校验仍因源码指纹头变化失败,没有修改基线。
  • Binary-object production boundary passed; all 690 isolation canaries rejected. / 字节码生产边界检查通过,690 个隔离 canary 全部按预期拒绝。

Measurements / 测量

Same PocketLab machine and release flags, runtime diagnostics inactive, unchanged workloads. All 80 runs passed output checks: five alternating pairs for each initial workload plus a separate ten-pair confirmation for each Richards workload, using the exact same binaries. All initial and confirmation samples are retained.

同机同 release 配置、运行时诊断关闭、工作负载未改动。首轮每负载五轮交替对照,随后对两种 Richards 分别独立复测十轮,使用哈希相同的二进制。80 次输出全部校验通过,保留两轮全部样本。

Workload / 负载 Before median ms After median ms Time reduction / 耗时下降
Integer loop ×10 million / 整数循环一千万次 1967.352 1547.222 21.36%
Property reads ×20 million / 属性读取负载两千万次 7041.108 6522.871 7.36%
Fixed Richards, initial / 固定 Richards 首轮 1496.602 1506.159 -0.64%
Original Richards, initial / 原始 Richards 首轮 6243.921 6295.843 -0.83%
Fixed Richards, confirmation / 固定 Richards 复测 1498.446 1494.523 +0.26%
Original Richards, confirmation / 原始 Richards 复测 6224.281 6230.859 -0.11%

Richards ranges overlap in both rounds; no stable Richards gain is established, and a small regression remains possible. Property-read timing includes numeric loop/accumulation work. CPU frequency/system isolation were not controlled; this is not a whole-engine speedup claim. No new CPU sampling or phase/memory probe was performed.

Richards 两轮范围均重叠,没有建立稳定收益,小幅回退仍有可能。属性读取负载包含数值循环和累加;未锁频或完全隔离系统,不把单个负载收益推广到整个引擎。本轮未重新采集 CPU 栈或阶段/内存探针。

双语报告 / Report · 全部样本及验证记录 / Samples and receipts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant