The engine built Boolean.prototype but defined no global Boolean, so
Boolean(x), new Boolean(x), x instanceof Boolean and filter(Boolean)
threw a ReferenceError. Boolean now converts a value when called and
makes a Boolean object with new (ECMA-262 5.1 sections 15.6.1 and
15.6.2), with Boolean.prototype as its prototype.
test262 no longer skips tests that name Boolean, so more of them run;
docs/target-app-parity.md has the new counts.
- Spreading an array checks the room in the result as each element is
read, so a getter that shrinks an array of length 4294967295 gives the
elements it reads. An array no getter reads, and any other object, is
still checked against its length when spread begins.
- Spread counts each element's index name, and each character of a
string, against the heap as it reads them.
- A function with default or rest parameters checks the heap again before
its body's environment and declarations are made, since the parameters'
values may have used the room the call reserved.
- Without the ES2015 option, a function that eval code declares on the
global object closes over the global scope, so it sees the scripts'
`let` and `const` names, as functions of global code do.
- With the ES2015 option, a global `var` whose name the global object
only inherits gets its own property.
- The test262 ES2015 subset runs a test whose source does not tokenize,
so the error counts as a failure instead of a skip.
A realm made with Options::es2015 reads function* declarations and
expressions, *name() methods in object literals, yield and yield*, as
ECMA-262 11th edition sections 14.4 and 25.4 define them. A suspended
generator keeps its frame in its object; next, return and throw on
%GeneratorPrototype% push it back on the interpreter's frame stack, so
a resumption takes fuel and counts against the frame limit, and return
runs the finally blocks around the yield. Resuming a running generator
throws a TypeError. yield* passes next, throw and return on to its
iterator and closes one without throw before throwing a TypeError.
%GeneratorFunction% is reached through a generator function's
constructor. Outside generators, sloppy code still reads yield as a
name, and a realm without the option reads function* as a syntax error.
An engine that #targetengine kept from a .jsx run has no generator
built-ins, so a generator function called there throws a TypeError.
cargo xtask test262 runs the generator folders: 509 of 549 runs pass
(94 of 96 before). Docs: docs/mcp.md, docs/target-app-parity.md.
- A promise resolved with itself roots its TypeError before the queue
reserves room, so a collection there no longer frees the reason.
- A sliced run whose last job ends a slice reports Done in that slice
instead of Paused, and a pause asked for in a run's last step no longer
pauses the next run.
- The job queue is replaced at run end, which frees its buffer.
- A reaction job runs a finally callback as its own call, so a slice can
pause inside it; the callback no longer runs to its end within the
unbroken-fuel allowance.
- all, allSettled and race read an array to its current length at each
step, and a string input is flattened through the charged path and
shared instead of copied.
- The test262 runner checks the expected exception of an async test with
a runtime negative.
With Options::es2015, vectorcraft-js reads and runs two ECMAScript 2020
forms: optional chains (a?.b, a?.[key], f?.(args) and the accesses and
calls after them) and ??.
- An optional step that finds undefined or null ends the whole chain
with undefined, without evaluating its other keys and arguments.
Parentheses end a chain. a?.b() and a.b?.() call with a as this,
(a?.b)() does too, eval?.(code) is an indirect eval, and delete a?.b
is true when a is undefined or null.
- ?? keeps any left side other than undefined and null.
- ?. before a digit still reads as ? and a number (a?.5:1).
- Mixing ?? with && or || without parentheses, assigning to or updating
an optional chain, a tagged template after one and new a?.b() are
syntax errors.
Two new jump instructions test for undefined and null, and the verifier
checks both of their paths. A chain of any length compiles with a loop.
.jsx files and source strings stay ES5.1, where ?. and ?? are syntax
errors.
The test262 ES2015 subset now also reads expressions/optional-chaining
and expressions/coalesce: 426 of 426 negative parse runs and 591 of 615
other runs pass with the option. The 24 failing runs are the same as
before this change.
With Options::es2015 set, a vectorcraft-js realm has Symbol (ECMA-262
11th edition, section 19.4): Symbol(description), which new refuses,
the description getter, toString, valueOf, and Symbol.for and
Symbol.keyFor over a registry that lasts as long as the realm. typeof
gives "symbol". Symbols are property keys: Object.getOwnPropertySymbols
lists them in the order they were added, defineProperty,
getOwnPropertyDescriptor, freeze, seal, in, delete and hasOwnProperty
take them, and for-in, Object.keys, getOwnPropertyNames and
JSON.stringify leave them out. String(symbol) and symbol.toString()
give Symbol(description); any other conversion of a Symbol to a string
or a number throws a TypeError.
Symbol.iterator, asyncIterator, hasInstance, toPrimitive and
toStringTag are defined. Conversion to a primitive calls @@toPrimitive,
instanceof calls @@hasInstance, and Object.prototype.toString writes a
string @@toStringTag. Array.prototype.values (also @@iterator), keys
and entries, String.prototype[@@iterator] (by code point) and every
arguments object's @@iterator return iterators with next(). An Array
Iterator's next keeps its object reachable while a length getter or
valueOf runs script.
Each iterator step takes fuel, and each Symbol and registry entry
counts against the heap limit. An error about a Symbol-keyed property
names the Symbol by at most 256 units of its description, built only
when the error is thrown. String(symbol), symbol.toString() and the
[object tag] of Object.prototype.toString charge their copies to the
heap and fuel first. Realms without the option, including the one the
app runs scripts in, are unchanged. for-of, spread and destructuring
are not part of this change.
cargo xtask test262 runs the suite's Symbol, ArrayIteratorPrototype,
StringIteratorPrototype, getOwnPropertySymbols, Array.prototype
values/keys/entries/Symbol.iterator and String.prototype[Symbol.iterator]
tests in such a realm: 164 of 216 runs pass (6 before). The 52 others
expect a configurable function length and a function name property.
A script run from a .js file now has Promise as ECMA-262 11th edition
section 25.6 defines it: the constructor, then, catch, finally, and
Promise.resolve, reject, all, allSettled and race. .jsx scripts and
scripts given as source keep the ES5.1 built-ins; a named engine gets
Promise at the first .js run that names it and keeps it.
- The callbacks run as jobs from one FIFO queue after the script's own
code ends and before the run ends, sliced like the script, with no
native recursion along a then chain. Each job takes 1 unit of fuel, so
an endless chain stops at the fuel limit.
- More than 1,048,576 waiting jobs end the run with a Jobs limit error.
A run that fails, hits a limit or is stopped drops its waiting jobs
and rolls back as before.
- A promise still rejected with no handler when the run ends goes to
the report's unhandledRejections (first 20) and unhandledRejectionCount,
and to the Script Console with its file, line and column.
- Until the language has iterators, all, allSettled and race take
arrays, objects with a whole-number length and strings, and the
statics always build plain Promise objects. Promise.any is not provided.
cargo xtask test262 now runs the suite's built-ins/Promise tests that
need only the built-ins present: 402 of 538 runs pass.
Docs: docs/mcp.md, docs/target-app-parity.md.
vectorcraft-js gains Options::es2015, which reads and runs these
ECMAScript 2015 forms: let and const with block scope and their
temporal dead zone, a new let binding for each loop iteration,
function declarations scoped to their block (with the Annex B.3.3
variable outside strict mode code), arrow functions, template
literals and tagged templates, default and rest parameters, and
spread in array literals, calls and new. Spread reads arrays,
strings by code point and objects with a length, by index, and
throws a TypeError for anything else until iterators are added.
Eval code outside strict mode code cannot declare a var that clashes
with a let or const around it, or with a parameter inside a default
value. Spread, template objects and the new scopes take fuel and
count against the heap limit, and nested arrows and templates count
against the depth limit.
script.run sets the option for a .js file; eval, Function, #include
files, $.evalFile and a kept #targetengine read code the way the
running script does. A .jsx file and a source string stay ES5.1.
The test262 runner gains an ES2015 subset run, read without and with
the option. docs/mcp.md and docs/target-app-parity.md describe the
new forms.
A suite with test/annexB but no test/annexB/language skipped the Annex B
parse test and the language group of annex_b_runs. Both now skip only
when test/annexB is absent, and fail when it is present without its
language folder. The Annex B built-ins folders still skip one by one.
annex_b_runs counted skipped tests toward its check that a folder has
tests to run, so a folder where every test needs a missing built-in or
is asynchronous passed without running anything. It now requires at
least one test to run, as the ES5 groups do.
The Annex B runners checked their folders with Path::exists, which returns
false when the metadata cannot be read, so a folder that could not be
searched skipped the tests as if it were absent. They now use try_exists:
only an absent folder skips, and a metadata error fails the test.
The parity doc now says that an interpreter panic fails annex_b_runs and
makes cargo xtask test262 exit non-zero, while conformance failures do not.
The test262 runner read only test/language and a few built-ins folders,
so the Annex B tests were never counted, among them the for-in variable
with an initializer that must parse in sloppy code and give a
SyntaxError in strict code.
- annex_b_parse_subset parses every test under test/annexB/language
without a feature tag, of any edition, in the modes its flags give,
and writes annexb-parse-failures.txt.
- annex_b_runs runs those tests and the test/annexB/built-ins tests for
String, Date, RegExp and Function through the interpreter and writes
annexb-language-failures.txt and annexb-builtins-failures.txt. The
escape and unescape folders still run once, with the ES5 built-ins.
- A suite without test/annexB skips both; a folder there with nothing
to parse or run fails them. Conformance failures stay in the reports.
- The runner reads only regular files inside the suite: it does not
follow symbolic links, refuses an includes: name that leaves harness/,
refuses a file over 8 MiB before reading it, and fails on a folder it
cannot read instead of skipping it.
Docs: docs/target-app-parity.md, the xtask test262 module comment.
The interpreter runs skipped every test with a missing built-in's name
anywhere in a string literal, so a test that only mentions Boolean in
a message or in text data was never run. A string now counts when it
is the name alone (a property key such as this["Map"]), or when the
test or an included harness file can run strings as code (eval,
Function or a constructor property, by name or by string key).
Identifiers and property names count as before, and a source that does
not tokenize as ES5 is still skipped.
At tc39/test262 d53ebc8b, language/types/string/S8.4_A6.1.js and
S8.4_A6.2.js now run and pass: the language run goes from 2,459 tests
(205 skipped) to 2,461 (203 skipped), and the failure lists are
unchanged.
The text a non-string argument converts to stays rooted while the parse runs, so a
collection still counts it. A property name read from the text is charged to the heap
until its property is defined. Boolean.prototype.toString and valueOf are added, so a
Boolean object writes `true` or `false`. The json2 sample no longer includes U+2028:
the polyfill escapes it and section 15.12.3 does not.
run_tests read an unreadable harness, include or test file as an empty
string, so a broken suite checkout passed with every run counted as a
failure. It now stops with the file's path. The language run checks
that test/language exists, and the language and built-ins runs check
that at least one ES5 test ran.
Installing the built-ins is not bounded by the heap limit: Math and JSON
no longer reserve heap while they install, so a realm made with a tiny
heap_bytes gets every built-in and runs once the limit is raised. If
installing fails, the realm keeps the reason and every run ends with an
internal error instead of running against missing built-ins.
The json2.js test skips only when the built-in check returns false, and
fails on any other result. The parser's progress line says the app does
not run scripts yet.
A realm now has String, Number, RegExp and Date as ECMAScript 5.1
sections 15.5, 15.7, 15.9 and 15.10 define them, with Annex B's substr,
getYear, setYear and toGMTString.
- String: every ES5 prototype method; split, replace, match and search
take strings and RegExps. Each new string's length is checked against
the heap limit before it is built, and scans take fuel.
- Number: toString(radix), toFixed, toExponential and toPrecision
format from the number's exact decimal value.
- RegExp: a backtracking matcher keeps its choice points and capture
state on the heap, within the heap room left, and takes fuel for every
step, so a catastrophic pattern stops at the fuel limit. Patterns
nested past Options::max_depth give a SyntaxError. Flags g, i and m,
lastIndex, exec, test and toString.
- Date: chrono converts days to calendar dates, shifting by whole
400-year cycles past its years. Realm::set_clock and
Realm::set_time_zone set the clock and local time (UTC by default).
Without a hint, a Date converts to a primitive as a string.
cargo xtask test262 also runs the suite's built-ins tests for the four
and prints their counts.
vectorcraft-js now provides the ECMAScript 5.1 built-ins: the Object
property-descriptor functions, create, keys, seal and freeze (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). Prototype methods are writable and configurable.
The array methods work on array-like objects and visit only the indices
that exist, so a sparse array of length 2^32-1 costs as much as its
elements, and they see indices a callback adds. join writes a cycle back
to an array as an empty string; JSON.stringify throws a TypeError on a
cycle. JSON parsing, writing and the reviver walk use no native
recursion. Every loop takes fuel and every result is checked against
the heap limit, so new Array(4294967295).join("x") ends with the heap
limit and a huge sort or stringify ends with a limit.
cargo xtask test262 also runs the suite's ES5 built-in tests and fetches
json2.js at a pinned commit, checked against its SHA-256, to compare its
output with the built-in JSON once Date, String.prototype.replace and
RegExp exist.
The harness's assert.js formats failure messages with the global String, which the interpreter does not provide yet, so the four failing runs reported "ReferenceError: String is not defined". The runner now defines a stand-in that converts with +, and the failures name the assertion (the completion value tests expect undefined where ECMA-262 5.1 section 12.6.3 gives 4).
vectorcraft-js gains a Realm that runs ECMAScript 5.1 scripts. The parsed
script compiles to stack-machine bytecode, a verifier checks every jump
target, handler, constant index and stack depth before the code runs, and
the interpreter keeps JavaScript calls on its own frame stack. Closures,
this, arguments, with, direct and indirect eval, new Function,
try/catch/finally, labeled break and continue, and for-in in insertion
order follow sections 10 to 14 of ECMA-262 5.1. Variable references are
resolved before the right-hand side of an assignment runs (11.13).
Objects and environments live in an arena with a mark-and-sweep
collector and index handles. Built-ins are limited to Object and
Object.prototype's basic methods, Function with call and apply, eval
and the error constructors.
Every run is bounded by fuel, heap bytes, frames, nested host calls and
an interrupt flag another thread can set, with smaller defaults in the
wasm build. A run that reaches a limit ends with a limit error that a
script's try cannot catch. Source passed to eval and Function counts
against Options::max_source_units.
cargo xtask test262 also runs the suite's ES5 test/language tests that
need only these built-ins and prints their counts apart from the parse
counts. Nothing in the app calls the interpreter yet.
New crate vectorcraft-js reads ECMAScript 5.1 source into a syntax tree
with source positions: a UTF-16 lexer (line and column tracking, automatic
semicolon insertion, the regexp and division goals), preprocessor lines
read as directive tokens, a recursive-descent parser to an arena tree, and
the ES5 early errors, strict mode included. Nesting deeper than
Options::max_depth (200 by default) gives a SyntaxError with its line and
column rather than overflowing the stack. Nothing runs scripts yet.
cargo xtask test262 downloads test262 at a pinned commit, checks its
SHA-256, unpacks it into the gitignored corpus/ folder and runs the ES5
syntax tests. A differential test in the engine compares the lexer with
scriptcheck on line counts, directives and unterminated literals.