perf: member 复合写路径接入 IC 写命中(depth 0)消除每次 DashMap 查询与回写

set_member_prop 增加 ic_set_hit_own(仅接受 depth==0 槽,跳过读侧学习的
原型条目防原型污染)命中直写槽,ext_pc 由 read_member_prop 显式带出消除
隐式 pc 契约;写新属性 miss 分支(IC_SET 分发 + member 写)统一改
CreateDataProperty 快路径(保留原型链 setter/readonly 检查),砍掉
ordinary_set 全链路的重复查询与 shape 转换开销。
This commit is contained in:
2026-08-15 08:16:49 +08:00
parent abeab6f216
commit aa4c28cdf0
7 changed files with 361 additions and 52 deletions
@@ -154,10 +154,10 @@ fn rerun_clears_polymorphic_slots() {
);
}
/// member 读侧(obj.x++)多 shape 轮换:read_member_prop 多态命中,
/// 写侧(set_member_prop)暂不接命中——本任务只验证格式同步不错位。
/// member 复合写(obj.x++)多 shape 轮换:读侧与写侧都经 4 槽缓存命中,
/// 每 shape 仅读侧学习 1 次 miss(写侧复用读侧条目直写)。
#[test]
fn member_compound_polymorphic_read_side_hits() {
fn member_compound_polymorphic_read_write_hits() {
let (r, _hits, misses) = run_once(
r#"var a = { x: 1 }, b = { x: 2, y: 3 };
for (var i = 0; i < 10000; i++) {
@@ -167,7 +167,7 @@ fn member_compound_polymorphic_read_side_hits() {
a.x + b.x"#,
);
assert_eq!(r, "10003", "两对象 x 各自增 5000 次(从 1/2 起)");
assert!(misses < 5000, "读侧 4 槽缓存使 miss 远低于迭代数(实际 {misses},写侧新属性路径不计入)");
assert_eq!(misses, 2, "两 shape 各 1 次读侧学习 miss,写侧全命中");
}
/// 非对象 receiver(字符串)经 IC primitive 分支:手动跳越全部扩展字后语义正确。