perf(test262): +2.4% pass rate via Function .name/.length and ArrayLike support

- Array indexOf/includes/lastIndexOf: ArrayLike receiver + fromIndex + SameValueZero
- Function.prototype methods: add .length property via bind_method_static
- Error objects: add .name property via create_kind_error
- Constructor functions: add .name via make_pair + .length via bind_constructor!
- test262: 8497→9009 pass (+512), 38.3%→40.7% rate

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit af61949e6cab1b149a13e571e29bacc4267d5690)
This commit is contained in:
爱特每羊队
2026-06-28 18:23:08 +08:00
parent db013bd4f6
commit 05f1056cde
4 changed files with 161 additions and 38 deletions
+15 -5
View File
@@ -39,14 +39,24 @@ pub fn create_kind_error<H: VmHost>(host: &mut H, kind: &str, msg: &str) -> JsVa
let obj = host
.epoch()
.alloc(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(proto_ptr)));
let sf = Arc::clone(host.kernel_core().perm_interner());
let sh = Arc::clone(host.kernel_core().shape_forge());
// 设置 .name = kind (ES spec: Error.prototype.name)
{
let si_name = sf.intern("name").0;
let shape = sh.make_shape(EMPTY_SHAPE_ID, si_name);
let name_val = host.new_string(kind);
unsafe {
(*obj).set_shape_id(shape);
(*obj).push_prop(name_val);
}
}
if !msg.is_empty() {
let sf = Arc::clone(host.kernel_core().perm_interner());
let sh = Arc::clone(host.kernel_core().shape_forge());
let si = sf.intern("message").0;
let new_shape = sh.make_shape(EMPTY_SHAPE_ID, si);
let si_msg = sf.intern("message").0;
let shape = sh.make_shape(unsafe { (*obj).shape_id() }, si_msg);
let msg_val = host.new_string(msg);
unsafe {
(*obj).set_shape_id(new_shape);
(*obj).set_shape_id(shape);
(*obj).push_prop(msg_val);
}
}