Scripts: global var records, spread limits and body declarations follow ECMAScript 2015

- `delete x` through the global environment clears the global `var`
  record when it deletes the global object's own property. `delete
  this.x`, and `delete x` on a name the global object only inherits,
  keep it, so a later `let x` is still a SyntaxError (ECMA-262 2015
  sections 12.5.3.2 and 8.1.1.4.7).
- A 5.1-edition `var` on a name the global object only inherits makes no
  property and is no longer recorded as a global `var`.
- Spread allows a result of exactly 4,294,967,295 elements and throws a
  RangeError only past it. An index setter without a getter no longer
  puts off the length check, and the check takes fuel for each property
  it looks at.
- A body after default parameters checks each function declaration and
  variable against the heap just before it is made.
- Tests: the spread heap sweep fails on an unexpected setup error and
  needs one complete spread; the body sweep counts only stops after the
  default value was made and reads the heap estimate before the next
  run.
- Docs: the earlier ES2015 test262 counts are labeled as the counts
  before classes were added.
This commit is contained in:
dotCooCoo committed 2026-11-22 16:06:07 -08:00
1 parent 4eca7a5ccb
commit f1c19445f5
3 files changed
+110 -36

No files matched your search

+59 -13
View File
@@ -319,8 +319,29 @@ fn a_global_var_stops_a_later_let_even_on_a_configurable_property() {
assert!(is_thrown(&realm.run("let z;"), "SyntaxError"));
assert_eq!(realm.run("delete z"), Ok(JsValue::Bool(true)));
assert_eq!(realm.run("let z = 3; z"), Ok(JsValue::Number(3.0)));
// Deleting the property itself, not through the global environment, keeps the record
// (ECMA-262 2015 sections 12.5.3.2 and 8.1.1.4.7).
assert_eq!(realm.run("(0, eval)('var w = 1'); delete this.w"), Ok(JsValue::Bool(true)));
assert_eq!(realm.run("let w = 4; w"), Ok(JsValue::Number(4.0)));
assert!(is_thrown(&realm.run("let w = 4;"), "SyntaxError"));
assert_eq!(realm.run("(0, eval)('var u = 1'); with (this) { delete u; }"), Ok(JsValue::Bool(true)));
assert!(is_thrown(&realm.run("let u = 5;"), "SyntaxError"));
// Deleting a name the global object only inherits deletes no variable.
assert_eq!(realm.run("(0, eval)('var t = 1'); delete this.t; Object.prototype.t = 2; delete t"), Ok(JsValue::Bool(true)));
assert!(is_thrown(&realm.run("let t = 6;"), "SyntaxError"));
}
#[test]
fn a_5_1_var_on_an_inherited_name_is_not_a_global_var() {
// The 5.1 edition's `var` on a name the global object only inherits makes no property, so the
// name does not stop a later `let` once the inherited property is gone.
let mut realm = Realm::new();
assert_eq!(realm.run("Object.prototype.x = 1; Object.prototype.y = 1; this.y = 2; 0"), Ok(JsValue::Number(0.0)));
assert_eq!(realm.run("var x, y; this.hasOwnProperty('x')"), Ok(JsValue::Bool(false)));
assert_eq!(realm.run("delete Object.prototype.x"), Ok(JsValue::Bool(true)));
realm.set_es2015(true);
assert_eq!(realm.run("let x = 1; x"), Ok(JsValue::Number(1.0)));
// A `var` on an own property is still recorded.
assert!(is_thrown(&realm.run("let y = 3;"), "SyntaxError"));
}
#[test]
@@ -568,10 +589,21 @@ fn an_array_s_spread_is_checked_against_the_elements_it_reads() {
let then_more = "var a = []; a.length = 4294967295; Object.defineProperty(a, 0, { get: function () { a.length = 1; return 7; } }); \
var b = [...a, ...[1, 2]]; b.join() === '7,1,2'";
truth(then_more);
// An array no getter reads is checked when spread begins, without reading its elements.
// An array no getter reads is checked when spread begins, without reading its elements. An
// empty array has room for 4,294,967,295 elements, so only one more is too long.
let mut realm = Realm::with_options(es_options(), Limits { fuel: 10_000, ..Limits::default() });
let long = realm.run("var a = []; a.length = 4294967295; [...a]");
let long = realm.run("var a = []; a.length = 4294967295; [0, ...a]");
assert!(is_thrown(&long, "RangeError"), "{long:?}");
let fits = realm.run("[...a]").unwrap_err();
assert_eq!(fits.kind, RunErrorKind::Limit(LimitKind::Fuel), "{fits:?}");
// A setter at an index reads nothing, so it does not put off the check.
let mut realm = Realm::with_options(es_options(), Limits { fuel: 10_000, ..Limits::default() });
let set = realm.run("var a = []; a.length = 4294967295; Object.defineProperty(a, 0, { set: function (v) {} }); [0, ...a]");
assert!(is_thrown(&set, "RangeError"), "{set:?}");
// A getter that shrinks the array still puts off the check.
let most = "var a = []; a.length = 4294967295; Object.defineProperty(a, 0, { get: function () { a.length = 1; return 7; } }); \
var b = [0, ...a]; b.join() === '0,7'";
truth(most);
// An object that is not an array is still checked against the length it has when spread
// begins.
throws("[0, ...{ length: 4294967295 }];", "RangeError");
@@ -587,20 +619,27 @@ fn spread_counts_each_index_name_against_the_heap() {
assert_eq!(measure.run(setup), Ok(JsValue::Number(0.0)));
measure.interp().collect_garbage();
let base = measure.interp().heap.bytes;
for extra in (0..640usize).map(|k| k * 1024) {
let mut spread_all = 0;
for extra in (0..1280usize).map(|k| k * 2048) {
let heap_bytes = base + extra;
let mut realm = Realm::with_options(es_options(), Limits { heap_bytes, ..Limits::default() });
if realm.run(setup).is_err() {
// Only the heap limit may stop the setup.
if let Err(e) = realm.run(setup) {
assert_eq!(e.kind, RunErrorKind::Limit(LimitKind::Heap), "setup at {heap_bytes}: {e:?}");
continue;
}
match realm.run(&format!("var b = {spread}; b.length")) {
Ok(v) => assert_eq!(v, JsValue::Number(4000.0), "{spread} at {heap_bytes}"),
Ok(v) => {
assert_eq!(v, JsValue::Number(4000.0), "{spread} at {heap_bytes}");
spread_all += 1;
}
Err(e) => assert_eq!(e.kind, RunErrorKind::Limit(LimitKind::Heap), "{spread} at {heap_bytes}: {e:?}"),
}
// A collection counts what is live, without the bytes the spread held while it ran.
realm.interp().collect_garbage();
assert!(realm.interp().heap.bytes <= heap_bytes, "{spread}: {} > {heap_bytes}", realm.interp().heap.bytes);
}
assert!(spread_all > 0, "{spread}: no limit in the range fit the whole spread");
}
}
@@ -623,7 +662,7 @@ fn spread_and_templates_stay_within_the_limits() {
let e = realm.run("var s = 'x'; for (var i = 0; i < 22; i++) s += s; [...s]").unwrap_err();
assert!(matches!(e.kind, RunErrorKind::Limit(_)), "{e:?}");
throws("function f() {} f(...{ length: 100000 });", "RangeError");
throws("var a = []; a.length = 4294967294; [0, ...a];", "RangeError");
throws("var a = []; a.length = 4294967294; [0, 1, ...a];", "RangeError");
}
#[test]
@@ -664,10 +703,12 @@ fn a_rest_parameter_checks_the_heap_before_its_array_is_made() {
fn a_body_after_default_parameters_checks_the_heap_before_its_scope_is_made() {
// The default value fills the heap a little more each run, so at some count the room left
// after it is smaller than the body's long variable names need. The call then ends with the
// heap limit before the heap estimate passes it.
// heap limit before the heap estimate passes it. Only a run that stops after `fill` has
// returned counts as stopped by the body.
let vars = (0..200).map(|i| format!("v{i:0>60}")).collect::<Vec<_>>().join(", ");
let setup = format!(
"var keep = []; function fill(k) {{ for (var i = 0; i < k; i++) keep.push(i); }} function f(a = fill(count)) {{ var {vars}; return 1; }} 0"
"var keep = [], filled = false; function fill(k) {{ for (var i = 0; i < k; i++) keep.push(i); filled = true; }} \
function f(a = fill(count)) {{ var {vars}; return 1; }} 0"
);
let mut measure = Realm::with_options(es_options(), Limits::default());
assert_eq!(measure.run(&setup), Ok(JsValue::Number(0.0)));
@@ -677,16 +718,21 @@ fn a_body_after_default_parameters_checks_the_heap_before_its_scope_is_made() {
for count in (0..4000).step_by(20) {
let mut realm = Realm::with_options(es_options(), Limits { heap_bytes, ..Limits::default() });
assert_eq!(realm.run(&setup), Ok(JsValue::Number(0.0)));
match realm.run(&format!("var count = {count}; f()")) {
let result = realm.run(&format!("var count = {count}; f()"));
// The estimate is read before the next run, whose code may make the collector run.
let bytes = realm.interp().heap.bytes;
assert!(bytes <= heap_bytes, "{count}: {bytes} > {heap_bytes}");
match result {
Ok(v) => assert_eq!(v, JsValue::Number(1.0), "{count}"),
Err(e) => {
assert_eq!(e.kind, RunErrorKind::Limit(LimitKind::Heap), "{count}: {e:?}");
stopped += 1;
if realm.run("filled") == Ok(JsValue::Bool(true)) {
stopped += 1;
}
}
}
assert!(realm.interp().heap.bytes <= heap_bytes, "{count}: {} > {heap_bytes}", realm.interp().heap.bytes);
}
assert!(stopped > 0, "no count reached the heap limit");
assert!(stopped > 0, "no count reached the heap limit after the default value was made");
}
#[test]
+50 -22
View File
@@ -1410,7 +1410,18 @@ impl Interp {
}
_ => return internal("not a declarative environment"),
},
Resolved::Obj { object, .. } => self.delete(object, &name, false)?,
Resolved::Obj { object, with_this } => {
let own = self.get_own_property(object, &name)?.is_some();
let deleted = self.delete(object, &name, false)?;
// A global variable whose own property is deleted through the global environment
// no longer stops a `let` or `const` of its name (ECMA-262 2015 section 8.1.1.4.7).
// Deleting the global object's property any other way, as `delete this.x` does,
// or deleting a name it only inherits, keeps the record.
if own && deleted && !with_this && object == self.global {
self.global_vars.remove(&name);
}
deleted
}
};
self.push(Value::Bool(result))
}
@@ -1903,12 +1914,6 @@ impl Interp {
match self.get_own_property(id, k)? {
None => Ok(true),
Some(p) if p.configurable() => {
// A deleted global variable no longer stops a `let` or `const` of its name
// (ECMA-262 2015 section 8.1.1.4.7), and the names kept are never more than the
// global object's properties.
if id == self.global {
self.global_vars.remove(k);
}
let o = self.object_mut(id)?;
o.props.remove(k);
if let Class::Arguments(map) = &mut o.class
@@ -2346,8 +2351,9 @@ impl Interp {
let frame = self.frame()?;
let (code, params) = (frame.code.clone(), frame.env);
// The parameters' values may have filled the room the call reserved, so the body's
// environment and declarations are checked against the heap again.
self.reserve_heap(declaration_bytes(&code).saturating_add(ENV_BYTES))?;
// environment, its scope and each declaration are checked against the heap again, each
// just before it is made.
self.reserve_heap(ENV_BYTES)?;
// Each new environment is in the frame, where the collector finds it, before the next
// allocation.
let var_env = self.heap.alloc_env(Env::Decl { bindings: PropMap::default(), outer: Some(params) });
@@ -2357,6 +2363,7 @@ impl Interp {
for (name, fi) in &code.fun_decls {
self.use_fuel()?;
let Some(fcode) = code.functions.get(*fi as usize).cloned() else { return internal("function out of range") };
self.reserve_heap(binding_bytes(name.len()).saturating_add(closure_bytes(&fcode)))?;
let f = self.make_closure(fcode, lex)?;
self.temp_roots.push(Value::Object(f));
let r = self.env_insert(var_env, name.clone(), Binding::new(Value::Object(f), true, false));
@@ -2372,6 +2379,9 @@ impl Interp {
Some(Env::Decl { bindings, .. }) => bindings.get(v).map_or(Value::Undefined, |b| b.value.clone()),
_ => Value::Undefined,
};
// The initial value is reachable from the parameters' environment while the heap is
// checked.
self.reserve_heap(binding_bytes(v.len()))?;
self.env_insert(var_env, v.clone(), Binding::new(initial, true, false))?;
}
Ok(())
@@ -2447,7 +2457,7 @@ impl Interp {
// and the room is checked as each element is read. Any other object, and an array
// whose elements no getter reads, is checked against the length it has now.
let array = matches!(self.object(o)?.class, Class::Array { .. });
if n >= f64::from(room) && !(array && self.has_index_getter(o)?) {
if n > f64::from(room) && !(array && self.has_index_getter(o)?) {
return Err(self.throw(ErrorType::Range, "array literal too long"));
}
let n = n as u32;
@@ -2463,7 +2473,7 @@ impl Interp {
if i >= end {
return Ok(());
}
if i.saturating_add(1) >= room {
if i >= room {
return Err(self.throw(ErrorType::Range, "array literal too long"));
}
self.use_fuel()?;
@@ -2495,7 +2505,7 @@ impl Interp {
let o = self.object_mut(a)?;
let Class::Array { length, .. } = &mut o.class else { return internal("spread into something that is not an array") };
let start = *length;
let Some(end) = u32::try_from(items.len()).ok().and_then(|n| start.checked_add(n)).filter(|&e| e < u32::MAX) else {
let Some(end) = u32::try_from(items.len()).ok().and_then(|n| start.checked_add(n)) else {
return Err(self.throw(ErrorType::Range, "array literal too long"));
};
*length = end;
@@ -2507,14 +2517,26 @@ impl Interp {
}
/// Whether reading the elements of `o` by index can run code: `o` or an object it inherits
/// from has an accessor property with an index name. Each object takes a unit of fuel.
/// from has an accessor property with a getter and an index name. Each object, and each
/// property looked at, takes a unit of fuel.
fn has_index_getter(&mut self, o: ObjId) -> JsResult<bool> {
let mut cur = Some(o);
while let Some(id) = cur {
self.use_fuel()?;
let object = self.object(id)?;
if object.props.iter().any(|(k, p)| matches!(p, Prop::Accessor { .. }) && array_index(k).is_some()) {
return Ok(true);
// The fuel and the interrupt flag are checked at each property, so a long scan stops
// as soon as either ends the run.
let Some(object) = self.heap.object(id) else { return internal("object out of range") };
for (k, p) in object.props.iter() {
if self.fuel == 0 {
return Err(Abrupt::Limit(LimitKind::Fuel));
}
self.fuel -= 1;
if self.interrupt.load(Ordering::Relaxed) {
return Err(Abrupt::Limit(LimitKind::Interrupted));
}
if matches!(p, Prop::Accessor { get: Some(_), .. }) && array_index(k).is_some() {
return Ok(true);
}
}
cur = object.proto;
}
@@ -3443,16 +3465,22 @@ impl Interp {
let Some(fcode) = code.functions.get(*fi as usize).cloned() else { return internal("function out of range") };
let f = self.make_closure(fcode, scope)?;
self.declare(var_env, name, Some(Value::Object(f)), configurable)?;
if on_global {
self.global_vars.insert(name.clone());
}
self.note_global_var(on_global, name)?;
}
for v in &code.vars {
self.use_fuel()?;
self.declare(var_env, v, None, configurable)?;
if on_global {
self.global_vars.insert(v.clone());
}
self.note_global_var(on_global, v)?;
}
Ok(())
}
/// Records `name` as a global `var` or function name when `on_global` and the global object
/// has it as an own property after its declaration: a `var` the 5.1 edition declares on a
/// name the global object only inherits makes no property, and is not recorded.
fn note_global_var(&mut self, on_global: bool, name: &Key) -> JsResult<()> {
if on_global && self.get_own_property(self.global, name)?.is_some() {
self.global_vars.insert(name.clone());
}
Ok(())
}
+1 -1
View File
@@ -1079,7 +1079,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- `vectorcraft-js` parses JavaScript as ECMAScript 5.1 defines it, with the legacy octal forms, block functions and lenient regular expressions of Annex B, into a syntax tree with source spans; it reads the `#target`, `#include` and other preprocessor lines as directives without running them, and a script that breaks the grammar or an early-error rule gives a `SyntaxError` with its line and column. Nesting past the parser's depth limit (`Options::max_depth`, 200 by default) gives a `SyntaxError` instead of exhausting the stack. `cargo xtask test262` fetches the conformance suite at a pinned commit and parses its ES5 tests: 5,411 of 5,418 runs pass (the 7 others use `let` and `const`). This entry covers parsing; the next entry covers running scripts. Tests: `crates/js/src/tests.rs`, `crates/engine/tests/it/js_lexer_vs_scriptcheck.rs`.
- `vectorcraft-js` identifiers, written out or as `\uXXXX` and `\u{...}` escapes, take the characters Unicode's `ID_Start` and `ID_Continue` properties allow (https://www.unicode.org/reports/tr31/), plus `$` and, at the start, `_`, as later ECMAScript editions define them (https://tc39.es/ecma262/#sec-names-and-keywords). `Other_ID_Start` characters such as U+2118 and `Other_ID_Continue` characters such as U+00B7 and the zero width non-joiner and joiner are accepted, and no `Pattern_Syntax` or `Pattern_White_Space` character is. Letter categories come from Unicode 17.0, so U+088F starts an identifier and U+1ACF may follow its first character; characters assigned after Unicode 17.0 are not yet identifier characters. Tests: `crates/js/src/tests.rs` (`identifier_characters_are_unicode_17_id_start_and_id_continue`, which checks every code point, `identifiers_take_the_characters_unicode_17_assigned`, `identifiers_take_the_other_id_start_and_continue_characters`, `identifiers_refuse_pattern_syntax_surrogates_and_bad_escapes`, `no_pattern_syntax_or_white_space_character_is_an_identifier_character`).
- `vectorcraft-js`'s `Realm` runs ECMAScript 5.1 scripts: the parsed script compiles to verified bytecode that a non-recursive interpreter runs, with closures, `this`, `arguments`, `with`, direct and indirect `eval`, `new Function`, `try`/`catch`/`finally`, labeled `break` and `continue`, and `for`-`in` in insertion order, over a mark-and-sweep heap, with the built-ins the next two entries list. Every run is bounded by fuel, heap bytes, frames, nested host calls and an interrupt flag (smaller defaults in the wasm build), and a run that reaches a limit stops with a limit error that `try` cannot catch. `cargo xtask test262` also runs the suite's ES5 language tests that need only the built-ins present: 4,280 of 4,286 runs pass (4 of the others expect the completion values of later editions, and 2 expect a configurable function `length`). The app does not call it yet. Tests: `crates/js/src/interp_tests.rs`, `crates/js/tests/test262.rs`.
- With `Options::es2015`, `vectorcraft-js` also reads and runs these ECMAScript 2015 forms (https://262.ecma-international.org/6.0/): `let` and `const` with block scope and their temporal dead zone (a read or write before the declaration runs throws a `ReferenceError`, and a write to a `const` throws a `TypeError` in any code), a new `let` binding for each iteration of a `for` or `for`-`in` loop, function declarations scoped to their block, arrow functions with the `this` and `arguments` of the code around them and no `prototype`, template literals and tagged templates with one frozen strings object for each site, default and rest parameters with an `arguments` object that does not follow the parameters, and spread in array literals, calls and `new`. Spread reads arrays by index, reading the length again before each element, strings and `String` objects by code point, and objects with a `length` property by index, and throws a `TypeError` for any other value; that rule is VectorCraft's own until iterators are added. Spread and template objects take fuel for each element and count against the heap limit, and nested arrows and templates count against `Options::max_depth`. `script.run` sets the option for a `.js` file, and `eval`, `Function`, `#include` files and `$.evalFile` read code the way the script does; a `.jsx` file and a `source` string stay ES5.1. Destructuring, `for`-`of`, generators and modules are still syntax errors. `cargo xtask test262` reads the suite's tests of these forms without and with the option: 390 of 390 negative parse runs and 533 of 708 other runs pass with it (373 and 27 without it). Of the 175 failing runs, 151 do not parse because the tests also use forms this list leaves out (classes, method definitions, destructuring, `for`-`of`, trailing commas in parameter lists, and a later edition's rule for escapes in tagged templates), and 24 expect function `name` properties, a configurable function `length` and the `caller` and `arguments` restrictions, ECMAScript 2015 rules that `vectorcraft-js` does not implement. Tests: `crates/js/src/es2015_tests.rs`, `crates/js/tests/test262.rs`, `crates/engine/src/tests/script_run.rs`.
- With `Options::es2015`, `vectorcraft-js` also reads and runs these ECMAScript 2015 forms (https://262.ecma-international.org/6.0/): `let` and `const` with block scope and their temporal dead zone (a read or write before the declaration runs throws a `ReferenceError`, and a write to a `const` throws a `TypeError` in any code), a new `let` binding for each iteration of a `for` or `for`-`in` loop, function declarations scoped to their block, arrow functions with the `this` and `arguments` of the code around them and no `prototype`, template literals and tagged templates with one frozen strings object for each site, default and rest parameters with an `arguments` object that does not follow the parameters, and spread in array literals, calls and `new`. Spread reads arrays by index, reading the length again before each element, strings and `String` objects by code point, and objects with a `length` property by index, and throws a `TypeError` for any other value; that rule is VectorCraft's own until iterators are added. Spread and template objects take fuel for each element and count against the heap limit, and nested arrows and templates count against `Options::max_depth`. `script.run` sets the option for a `.js` file, and `eval`, `Function`, `#include` files and `$.evalFile` read code the way the script does; a `.jsx` file and a `source` string stay ES5.1. Destructuring, `for`-`of`, generators and modules are still syntax errors. Before classes were added, `cargo xtask test262` read the suite's tests of these forms without and with the option: 390 of 390 negative parse runs and 533 of 708 other runs passed with it (373 and 27 without it). Of the 175 runs that failed, 151 did not parse because the tests also use forms this list leaves out (classes, method definitions, destructuring, `for`-`of`, trailing commas in parameter lists, and a later edition's rule for escapes in tagged templates), and 24 expected function `name` properties, a configurable function `length` and the `caller` and `arguments` restrictions, ECMAScript 2015 rules that `vectorcraft-js` does not implement. The next entry gives the current counts, with the class tests included. Tests: `crates/js/src/es2015_tests.rs`, `crates/js/tests/test262.rs`, `crates/engine/src/tests/script_run.rs`.
- With `Options::es2015`, `vectorcraft-js` also reads and runs classes (https://262.ecma-international.org/6.0/#sec-class-definitions): declarations, scoped to their block like `let`, and expressions, with `extends`, `static` members, getters and setters, and computed method names; class code is strict mode code, methods are not enumerable and cannot be constructed, and calling a class without `new` throws a `TypeError`. A derived constructor's `this` is unusable until `super(…)` returns (a `ReferenceError`), and its own default constructor passes its arguments on. `super.name` and `super[key]` read, call and write through the prototype of the method's home object with `this` as the receiver, in class methods and in methods written in object literals, which are enumerable. `new.target` names the constructor `new` was applied to, in functions and the arrow functions inside them. A class can extend `null`, a function, a class, or the built-in constructors `Object`, `Function`, `Array`, `String`, `Number`, `Boolean`, `RegExp`, `Date` and the error types; a class can name another built-in constructor in `extends`, but `new` on that class throws a `TypeError` when it reaches the built-in constructor, a rule that is VectorCraft's own. Each class and method takes fuel, and deep chains of constructors stop at the frame limit. `super` and `new.target` in code given to direct `eval`, function `name` properties and computed keys outside classes are not supported yet. With the class, `super` and `new.target` tests added, `cargo xtask test262` reads 1,175 tests of these forms: with the option, all 554 negative parse runs and 1,527 of 1,731 other runs pass (537 and 43 without it). Of the 204 failing runs, 98 do not parse because the tests also use forms `vectorcraft-js` does not read (destructuring, `for`-`of`, generators, binary and octal number literals, trailing commas in parameter lists, async arrow functions, and a later edition's rule for escapes in tagged templates); of the other 106, 36 use `Object.setPrototypeOf` or `RegExp.prototype.flags`, which `vectorcraft-js` does not have, 62 expect function `name` properties, a configurable `length` or the `caller` and `arguments` restrictions, and 8 use `super` or `new.target` in direct `eval`. Tests: `crates/js/src/es2015_tests.rs`, `crates/js/tests/test262.rs`.
- `vectorcraft-js` provides the ECMAScript 5.1 built-ins `Object` with its property-descriptor functions, `create`, `keys`, `seal` and `freeze` (section 15.2), `Function.prototype.bind` (15.3.4.5), `Array` with every ES5 method (15.4), the error types (15.11), `Math` (15.8), `JSON` with revivers, replacers and indentation (15.12), and the global functions with Annex B's `escape` and `unescape` (15.1, B.2). The array methods work on array-like objects. A method visits only the indices that exist when its range is longer than 4,096 indices and more than 8 times the properties on the object and its prototypes, so `new Array(4294967295).join("")` ends at once; a shorter range is visited index by index, holes included, and each index takes fuel. `join` writes a cycle back to an array as an empty string, `JSON.stringify` throws a `TypeError` on a cycle, and deep `JSON` nesting uses no native stack. Every loop takes fuel and every result is checked against the heap limit. `cargo xtask test262` runs the suite's ES5 built-in tests that need only these built-ins: 6,798 of 6,866 runs pass (the 34 failing tests expect rules of later editions). It also fetches the `json2.js` polyfill at a pinned commit and checks that its `stringify` and `parse` agree with the built-in `JSON`. Tests: `crates/js/src/builtins_tests.rs`, `crates/js/tests/test262.rs`, `crates/js/tests/json2.rs`.
- `vectorcraft-js` has `String`, `Number`, `RegExp` and `Date` as ECMAScript 5.1 defines them (sections 15.5, 15.7, 15.9 and 15.10, https://262.ecma-international.org/5.1/), with Annex B's `substr`, `getYear`, `setYear` and `toGMTString`. `toFixed`, `toExponential` and `toPrecision` format a number from its exact decimal value, and `toString(radix)` writes any base from 2 to 36. Regular expressions (flags `g`, `i` and `m`) run on a backtracking matcher whose choice points and capture state count against the heap limit and which takes fuel for every step, so a catastrophic pattern stops at the fuel limit and 50,000 nested groups give a `SyntaxError` at the default depth limit. A string method that would build a string past the heap limit stops before it allocates. `Date` reads the clock and time zone the host sets (`Realm::set_clock`, `Realm::set_time_zone`; local time is UTC by default). `cargo xtask test262` runs the suite's `built-ins` tests for the four (https://github.com/tc39/test262): of the runs of the ES5 tests that need only the built-ins present, 1,379 of 1,411 pass for `String`, 298 of 298 for `Number`, 954 of 988 for `RegExp` and 8 of 8 for `Date`. The others expect later editions' rules (built-in functions whose `length` can be deleted, flags given with a RegExp object, a negative `lastIndex`, `RegExp.prototype` as a plain object, and `RegExp.prototype`'s `global`, `ignoreCase` and `multiline` properties that can be deleted). Tests: `crates/js/src/text_tests.rs`, `crates/js/tests/test262.rs`.