Andreas Kling
1dc60b028f
LibJS: Add BytecodeGenerator helpers for reference get/put
...
This allows code sharing between all AST nodes that want to get and/or
put through a reference.
2021-10-25 15:16:22 +02:00
Andreas Kling
b63d17e2f8
LibJS: Add fast paths for <, >, <=, and >= with Int32 on both sides
...
This gives us a ~5% speed-up on Kraken's ai-astar.js
2021-10-25 14:35:23 +02:00
Andreas Kling
d203a86900
LibJS: Always inline the bytecode instruction iterator's operator++
2021-10-25 13:37:02 +02:00
Andreas Kling
a97d75bb63
LibJS: Add default constructor for PrivateName
...
This avoids a round-trip through FlyString("") for every Reference.
2021-10-25 13:29:44 +02:00
Andreas Kling
3618ca2420
LibJS: Propagate exceptions across bytecode executable boundaries
...
To support situations like this:
function foo() { throw 1; }
try {
foo();
} catch (e) {
}
Each unwind context now keeps track of its origin executable.
When an exception is thrown, we return from run() immediately if the
nearest unwind context isn't in the current executable.
This causes a natural unwind to the point where we find the
catch/finally block(s) to jump into.
2021-10-25 12:57:21 +02:00
Andreas Kling
5a099b98cd
LibJS: Make eval() code run in the bytecode VM
...
If we have an active bytecode interpreter, let's make eval() use it.
2021-10-25 12:57:21 +02:00
Andreas Kling
049b755123
LibJS: Make bytecode interpreter leave unwind context immediately
...
We were missing some "break" statements, causing us to actually finish
executing everything within "try" blocks before actually jumping to the
"catch" and/or "finally" blocks.
2021-10-25 12:57:21 +02:00
Andreas Kling
a831cd9cc7
LibJS: Make bytecode VM throw TypeError on attempt to call non-callable
...
This isn't perfect, but allows us to progress instead of crashing in
the TODO().
2021-10-25 12:57:21 +02:00
Andreas Kling
6fc3c14b7a
LibJS: Fix bogus bytecode codegen for "catch" parameters
...
Add a missing '!' so that catch clauses with a named parameter actually
generate a SetVariable opcode.
2021-10-25 12:57:21 +02:00
Andreas Kling
b138b4c83f
LibJS: Optimize Value::to_property_key() for numeric property names
...
If the Value is a non-negative Int32, create a numeric PropertyKey
instead of making a string key.
This makes "ai-astar" test from the Kraken benchmark run in 30 seconds,
down from 42 seconds. :^)
2021-10-24 17:18:09 +02:00
Andreas Kling
65a7296b8f
LibJS: Make Value::to_property_key() return a JS::PropertyKey
...
Instead of returning JS::StringOrSymbol, which is a space-optimized type
used in Shape property tables, this now returns JS::PropertyKey which is
*not* space-optimized, but has other niceties like optimized storage of
numeric ("indexed") properties.
2021-10-24 17:18:09 +02:00
Andreas Kling
7ccb8c8609
LibJS: Provide default hash traits for JS::PropertyKey
...
Let's not require people to use PropertyNameTraits everywhere when we
can just specialize AK::Traits<JS::PropertyKey> instead. :^)
2021-10-24 17:18:09 +02:00
Andreas Kling
c02e992de2
LibJS: Use PropertyKey in MemberExpression::to_reference()
2021-10-24 17:18:09 +02:00
Andreas Kling
75f2510de9
LibJS: Make make_super_property_reference() take a PropertyKey
...
Let's get rid of StringOrSymbol usage outside of Shape.
2021-10-24 17:18:08 +02:00
Andreas Kling
398c181c79
LibJS: Rename PropertyName to PropertyKey
...
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Andreas Kling
715e7fada8
LibJS: Add the "fast non-local access" optimization to the bytecode VM
...
The GetVariable bytecode op now caches environment coordinates for fast
cross-scope variable lookup.
2021-10-24 17:18:07 +02:00
Andreas Kling
da98212001
LibJS: Add a separate "identifier table" to bytecode executables
...
This is a specialized string table for storing identifiers only.
Identifiers are always FlyStrings, which makes many common operations
faster by allowing O(1) comparison.
2021-10-24 17:18:07 +02:00
Andreas Kling
13f04e37e5
LibJS: Use String and move semantics in Bytecode::StringTable
...
Avoid creating new AK::String objects when we already have one.
2021-10-24 17:18:07 +02:00
Andreas Kling
3117182c2e
LibJS: Implement 'this' in the bytecode VM
...
ThisExpression now emits a "ResolveThisBinding" bytecode op, which
simply loads the VM's current 'this' binding into the accumulator.
2021-10-24 17:18:06 +02:00
Andreas Kling
7c7bc4f44a
LibJS: Alphabetize the bytecode opcode list
2021-10-24 17:18:06 +02:00
Andreas Kling
f75d78f56a
LibJS: Include executable name in bytecode dumps
2021-10-24 17:18:06 +02:00
Andreas Kling
c95dde971b
LibJS: Move global "should dump bytecode" flag into LibJS
...
This will allow us to trigger bytecode executable dumps when generating
bytecode inside LibJS as well, not just in clients like js and test-js.
2021-10-24 17:18:06 +02:00
Andreas Kling
da77e2aa4f
LibJS: Add Bytecode::Executable::dump()
...
Let's have a helper for producing a consistent executable dump instead
of repeating the logic in multiple places.
2021-10-24 17:18:05 +02:00
davidot
9c9aaf4d4f
LibJS: Don't VERIFY that a function is Regular when executing in AST
...
By replacing this VERIFY with a thrown Error we no longer crash when
calling a generator function in the AST interpreter. This allows us to
more gracefully handle situation which have not been implemented yet.
In particular this helps the libjs-test262-runner since it can now
continue on to the next tests instead of having the entire process end.
2021-10-24 08:38:02 +01:00
Timothy Flynn
e503b60bdc
LibJS: Convert a few TRYs to MUST in RegExp.prototype
...
These are marked with ! in the spec. This also adds assertions above
a couple of these operations to be extra sure (the spec also indicates
we should make these assertions).
2021-10-23 19:22:34 +01:00
Timothy Flynn
20f73d2abc
LibJS: Convert Atomics functions to ThrowCompletionOr
2021-10-23 19:16:03 +01:00
Timothy Flynn
3edf86462b
LibJS: Convert typed_array_from to ThrowCompletionOr
2021-10-23 19:16:03 +01:00
Idan Horowitz
2ab089fa21
LibJS: Convert RegExpStringIteratorPrototype to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
063ce946b7
LibJS: Convert RegExpPrototype functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
9b3c91aa65
LibJS: Convert the RegExpExec AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
a89d9d2c6f
LibJS: Convert the RegExpBuiltinExec AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
a2fbf6a3d5
LibJS: Convert the MakeIndicesArray AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
e3181a7ded
LibJS: Convert RegExpConstructor functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
844be7a0a5
LibJS: Convert the RegExpCreate AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
d9f5e2d461
LibJS: Convert the RegExpInitialize AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
35faf50941
LibJS: Convert PromisePrototype functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
5af8f72d54
LibJS: Convert PromiseConstructor functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
81bdb20c61
LibJS: Convert the PromiseResolve AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
0d602c5ec5
LibJS: Convert the NewPromiseCapability AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
2b87f77578
LibJS: Convert DatePrototype functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
ba39a54bb8
LibJS: Convert DateConstructor functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
306c25f3c2
LibJS: Convert the NumberToBigInt AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
f7bafea661
LibJS: Convert TypedArrayConstructor functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
92b25cacd1
LibJS: Convert TypedArrayPrototype functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
94be1f772a
LibJS: Convert typed_array_merge_sort to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
86aa8a14ea
LibJS: Convert the TypedArraySpeciesCreate AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
18c2d537c7
LibJS: Convert StringPrototype functions to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
38c4693c70
LibJS: Convert the CreateHTML AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
0948bd8c1e
LibJS: Convert the PadString AO to ThrowCompletionOr
2021-10-23 18:01:51 +02:00
Idan Horowitz
70a35f9600
LibJS: Convert resolve_best_locale to ThrowCompletionOr
2021-10-23 18:01:51 +02:00