Andreas Kling
cfdb8a2756
LibJS/JIT: Update "unwind context" stack in JIT code
...
Until now, the unwind context stack has not been maintained by jitted
code, which meant we were unable to support the `with` statement.
This is a first step towards supporting that by making jitted code
call out to C++ to update the unwind context stack when entering/leaving
unwind contexts.
We also introduce a new "Catch" bytecode instruction that moves the
current exception into the accumulator. It's always emitted at the start
of a "catch" block.
2023-11-12 14:21:41 +01:00
Andreas Kling
b6435ca280
LibJS: Unify bytecode instruction names with their helper names
2023-11-12 14:21:41 +01:00
Idan Horowitz
e58209e5cf
LibJS: Skip an always-false branch in the JIT to_boolean slow case
2023-11-11 08:55:18 +01:00
Andreas Kling
2520c46224
LibJS/JIT: Resolve the GetCalleeAndThisFromEnvironment cache at JIT time
2023-11-10 14:49:25 +01:00
Simon Wanner
a3399fa13a
LibJS/JIT: Expand Mul
fast path to double & i32 combinations
...
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
Simon Wanner
867b8146cf
LibJS/JIT: Expand Sub
fast path to double & i32 combinations
...
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
Simon Wanner
5edab2679c
LibJS/JIT: Expand Add
fast path to double & i32 combinations
...
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
Simon Wanner
d91b376393
LibJS/JIT: Add helper for generating combined i32 & double fastpaths
...
Co-authored-by: Stephan Vedder <vedder@mbits.info>
2023-11-10 11:01:59 +01:00
iliadsh
94b47ff03b
LibJS: Add GetByValue fast path for simple array access
2023-11-10 08:22:44 +01:00
Andreas Kling
ac23ab42b3
LibJS/JIT: Add fast path for cached GetById
2023-11-09 16:02:14 +01:00
Andreas Kling
55e467c359
LibJS/JIT: Add fast path for cached PutById
2023-11-09 16:02:14 +01:00
Andreas Kling
b1b2ca1485
LibJS: Add basic monomorphic caching for PutById property access
...
This patch makes it possible for JS::Object::internal_set() to populate
a CacheablePropertyMetadata, and uses this to implement a basic
monomorphic cache for the most common form of property write access.
2023-11-09 16:02:14 +01:00
Stephan Vedder
13726fd3b7
LibJS/JIT: Add fast path for decrement
...
Generate jitted code for the decrement opcode.
2023-11-08 21:09:44 +01:00
Stephan Vedder
0e69f744df
LibJS/JIT: Add increment instruction
...
Instead of using `Add` with an immediate of 1 use the `Inc` instruction
2023-11-08 21:09:44 +01:00
Sebastian Bernauer
8eb9c2dc54
LibJS/JIT: Add fast path for number comparisons
...
So far only less_than was using a fast path. This commits uses the same
path for less_than_equals, greater_than and greater_than_equals.
2023-11-08 14:11:51 +01:00
iliadsh
aef654592f
LibJS/JIT: Bail in UnsignedRightShift fast path if result is negative
2023-11-07 21:59:03 +01:00
Simon Wanner
8eeb4e0aff
LibJS/JIT: Use mov8/mov32 for loads in compile_get_variable
2023-11-07 14:39:13 +01:00
Andreas Kling
1d8ec677a3
LibJS/JIT: Add fast path for cached GetVariable accesses
...
We can now stay in machine code for environment variable read accesses
as long as they are cached and initialized.
20% speed-up on Octane/zlib.js :^)
2023-11-07 11:33:04 +01:00
Andreas Kling
e1e7e696ac
LibJS/JIT: Store the running ExecutionContext& in a dedicated register
2023-11-07 11:33:04 +01:00
iliadsh
24d5070520
LibJS/JIT: Add fast path for UnsignedRightShift
2023-11-07 10:17:04 +01:00
iliadsh
c956316c98
LibJS/JIT: Add fast path for RightShift
2023-11-07 10:17:04 +01:00
iliadsh
1244e91481
LibJS/JIT: Add fast path for LeftShift
2023-11-07 10:17:04 +01:00
Andreas Kling
536b9c29e4
LibJS/JIT: Resolve the EnvironmentVariableCache pointers at JIT time
2023-11-06 13:06:10 +01:00
Andreas Kling
a616a682fe
LibJS/JIT: Resolve the GlobalVariableCache pointers at JIT time
2023-11-06 13:06:10 +01:00
Andreas Kling
f03d4a1ffe
LibJS/JIT: Resolve the PropertyLookupCache pointers at JIT time
...
We know where the lookup cache is by the time we're jitting code, so
let's put the pointer directly into the instruction stream.
2023-11-06 13:06:10 +01:00
Andreas Kling
3b6b9b9f25
LibJS: Take VM instead of Interpreter in more common implementations
2023-11-06 13:06:10 +01:00
Andreas Kling
234ed2d466
LibJS/JIT: Resolve the GetGlobal identifier at JIT time
2023-11-06 13:06:10 +01:00
Andreas Kling
c92954db36
LibJS/JIT: Resolve the GetById property name at JIT time
...
We can resolve the IdentifierTableIndex to a DeprecatedFlyString& once
when jitting the code, instead of every time GetById executes.
2023-11-06 13:06:10 +01:00
Nikodem Rabuliński
bacbd830fe
LibJIT: Make X86_64Assembler::native_call take u64 instead of void*
...
Now that x86-specific Assembler will be compiled on every architecture
we can't rely on void* being the right width.
It also fixes compilation on targets which have void*
be different length from u64 (WASM in particular).
2023-11-06 10:05:42 +01:00
Nikodem Rabuliński
8aa35f4fab
LibJIT+LibJS: Rename Assembler to X86_64Assembler
...
This is in preparation for making LibJIT support multiple architectures.
Assembler will now be typedefed to the specific assembler
for a particular architecture.
Additionally, there's now JIT_ARCH_SUPPORTED which is defined on
architectures which LibJIT supports.
2023-11-06 10:05:42 +01:00
Nikodem Rabuliński
9f5450527f
LibJS+LibJIT: Make Assembler::native_call accept preserved_registers
...
This makes JS::JIT::Compiler less architecture-specific
and unifies aligning the stack into a single operation,
where previously we were doing it separately for preserved registers
and for stack arguments.
2023-11-06 10:05:42 +01:00
Idan Horowitz
58e2fe895c
LibJS: Stash thrown exception in a register before executing finalizer
...
This kills 2 birds with one stone:
1. It makes sure generated check_exception() calls in the finalizer
don't mis-read the pending exception as caused by their matching
operation.
2. It implicitly ensures that terminated finally blocks (by a return
statement) overwrite any pending exceptions, since they will never
execute the ContinuePendingUnwind operation that restores the
stashed exception.
This additional logic is required in the JIT (as opposed to the
interpreter), since the JIT uses the exception register to store and
check the possibly-exceptional results from each individual operation,
while the interpreter only modifies it when an operation has thrown an
exception.
2023-11-03 20:27:45 +01:00
Idan Horowitz
aaa81cd3b9
Revert "LibJS/JIT: Clear exception before executing finalizer"
...
This reverts commit 0daebef727
.
Finally blocks do not unconditionally swallow pending exceptions.
This resolves #21759 and fixes the 2 remaining failing test-js tests.
2023-11-03 20:27:45 +01:00
Andreas Kling
24fb009cf5
LibJS+LibJIT: Add fast path for Int32 * Int32
2023-11-03 10:48:02 +01:00
Andreas Kling
0aeb83b03f
LibJS+LibJIT: Add fast path for Int32 ^ Int32
2023-11-03 10:48:02 +01:00
Andreas Kling
3a5c177025
LibJS/JIT: Add fast path for Int32 | Int32
2023-11-03 10:48:02 +01:00
Andreas Kling
82635083dc
LibJS/JIT: Add fast path for Int32 & Int32
2023-11-03 10:48:02 +01:00
Andreas Kling
17ae6edd8e
LibJS+LibJIT: Add fast path for Int32 - Int32
2023-11-03 10:48:02 +01:00
Simon Wanner
c810d4784e
LibJS/JIT: Compile the Await instruction
2023-11-03 07:31:11 +01:00
Simon Wanner
4671520c0a
LibJS/JIT: Compile the Yield instruction
2023-11-03 07:31:11 +01:00
Simon Wanner
e400682fb1
LibJS/JIT: Support alternative entry point blocks
...
If Interpreter::run_and_return_frame is called with a specific entry
point we now map that to a native instruction address, which the JIT
code jumps to after the function prologue.
2023-11-03 07:31:11 +01:00
Idan Horowitz
38f3b78a1d
LibJS: Store the bytecode accumulator in a dedicated physical register
...
We now use a dedicated physical register to store the bytecode
accumulator, instead of loading and storing it to the memory everytime.
2023-11-02 22:35:35 +01:00
Simon Wanner
112eadc863
LibJS/JIT: Annotate disassembly with bytecode information
2023-10-31 07:07:17 +01:00
Simon Wanner
9f78e56823
LibJS/JIT: Record machine code location to bytecode location mapping
2023-10-31 07:07:17 +01:00
Simon Wanner
0daebef727
LibJS/JIT: Clear exception before executing finalizer
...
language/statements/try/S12.14_A13_T2.js ❌ -> ✅
language/statements/try/S12.14_A15.js ❌ -> ✅
language/statements/try/S12.14_A7_T1.js ❌ -> ✅
language/statements/try/S12.14_A7_T2.js ❌ -> ✅
language/statements/try/S12.14_A7_T3.js ❌ -> ✅
language/statements/try/completion-values-fn-finally-abrupt.js ❌ -> ✅
language/statements/try/completion-values-fn-finally-return.js ❌ -> ✅
2023-10-30 15:05:26 +01:00
Simon Wanner
bd62c4763c
LibJS/JIT: Flip saved_return_value condition in ContinuePendingUnwind
...
This did not match the `if (saved_return_value) return else resume`
in Interpreter.
test/built-ins/Promise/all/resolve-poisoned-then.js ❌ -> ✅
test/built-ins/Promise/all/resolve-thenable.js ❌ -> ✅
test/built-ins/Promise/allSettled/resolve-poisoned-then.js ❌ -> ✅
test/built-ins/Promise/allSettled/resolve-thenable.js ❌ -> ✅
test/built-ins/Promise/race/resolve-self.js ❌ -> ✅
test/language/statements/try/S12.14_A7_T1.js ✅ -> ❌
test/language/statements/try/S12.14_A7_T2.js ✅ -> ❌
test/language/statements/try/S12.14_A7_T3.js ✅ -> ❌
2023-10-30 15:05:26 +01:00
Simon Wanner
82c057391e
LibJS/JIT: Handle uninitialized bindings in GetLocal
...
test262: +78 ✅ -72 ❌ -4 💥 ️
2023-10-30 15:05:26 +01:00
Simon Wanner
5b2c0dfec0
LibJS/JIT: Return result of SuperCallWithArgumentArray
...
test/language/expressions/optional-chaining/call-expression.js 💥 ️ -> ✅
test/language/expressions/super/call-expr-value.js 💥 ️ -> ✅
2023-10-30 15:05:26 +01:00
Evgeniy Baskov
da45bd3fde
LibJS/JIT: Implement static exception handling
2023-10-30 13:10:08 +01:00
Andreas Kling
0c6d094a7e
LibJS/JIT: Stop logging JIT success by default (but still log failure)
2023-10-30 07:11:43 +01:00