Commit graph

149 commits

Author SHA1 Message Date
Simon Wanner
dd466ec83a LibJS/Bytecode: Remove the PushDeclarativeEnvironment 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
68f4d21de2 LibJS: Lazily collect stack trace information
The previous implementation was calling `backtrace()` for every
function call, which is quite slow.

Instead, this implementation provides VM::stack_trace() which unwinds
the native stack, maps it through NativeExecutable::get_source_range
and combines it with source ranges from interpreted call frames.
2023-11-02 07:37:41 +01:00
Simon Wanner
fb7b4b9c59 LibJS/JIT: Provide source location information for JIT code
This works by walking a backtrace until the currently executing
native executable is found, and then mapping the native address
to its bytecode instruction.
2023-10-31 07:07:17 +01:00
Hendiadyoin1
1341f4438d LibJS: Save scheduled jumps when entering unwind contexts
These are then restored upon `ContinuePendingUnwind`.
This stops us from forgetting where we needed to jump when we do extra
try-catches in finally blocks.

Co-Authored-By: Jesús "gsus" Lapastora <cyber.gsuscode@gmail.com>
2023-10-30 13:10:08 +01:00
Hendiadyoin1
4da5b8ec67 LibJS: Reset scheduled-jump flag when throwing an exception
Otherwise we might attempt to follow the scheduled jump later
2023-10-30 13:10:08 +01:00
Hendiadyoin1
f5645e3c9c LibJS: Use static unwind mappings for unwind related functions 2023-10-30 13:10:08 +01:00
Simon Wanner
ad81bf47bb LibJS: Move GetObjectPropertyIterator impl to CommonImplementations 2023-10-29 22:57:19 +01:00
Jakub Berkop
6a7b9b85a4 LibJS/JIT: Compile the DeleteByValueWithThis instruction 2023-10-29 21:51:46 +01:00
Jakub Berkop
0776404e03 LibJS/JIT: Compile the DeleteByValue instruction 2023-10-29 21:51:46 +01:00
Jakub Berkop
f5fcd4596c LibJS/JIT: Compile the DeleteById instruction 2023-10-29 21:51:46 +01:00
Simon Wanner
516bb01082 LibJS/Bytecode: Move Append impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
5179ff5fc9 LibJS/Bytecode: Move IteratorToArray impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
661dbbc83d LibJS/Bytecode: Move object_to_iterator to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
d416cef9bb LibJS/Bytecode: Move iterator_to_object to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
1eee110575 LibJS: Move SuperCallWithArgumentArray impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner
f9fbb8cff2 LibJS/Bytecode: Move NewClass impl to CommonImplementations 2023-10-29 07:44:11 +01:00
Simon Wanner
54f1f7a51b LibJS/Bytecode: Move CreateVariable impl to CommonImplementations 2023-10-29 07:44:11 +01:00
Idan Horowitz
b2d8d0c270 LibJS: Compile the CallWithArgumentArray bytecode instruction 2023-10-28 20:27:16 +02:00
Andreas Kling
c1551a64dc LibJS/JIT: Compile the NewRegExp bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
935d67cfcf LibJS/JIT: Compile the GetCalleeAndThisFromEnvironment instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
dabaaabfc0 LibJS/JIT: Support the GetVariable bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
bcf7cdb679 LibJS/Bytecode: Un-templatize throw_if_needed_for_call() 2023-10-27 19:07:22 +02:00
Andreas Kling
c2aad0f573 LibJS/Bytecode: Move PutByValue impl to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling
9f61cda27e LibJS/Bytecode: Move NewFunction impl into CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling
393d90abe1 LibJS/Bytecode: Move SetVariable implementation to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling
d368dc5d25 LibJS/Bytecode: Move TypeofVariable impl to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling
640455b1d2 LibJS/JIT: Compile the Call bytecode instruction
I've left a FIXME about dealing with some throwsy cases.
2023-10-27 19:07:22 +02:00
Andreas Kling
7fc35fde09 LibJS/Bytecode: Move throw_if_needed_for_call to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling
b56ecc7e34 LibJS/Bytecode: Move perform_call helper to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling
580249d650 LibJS/JIT: Compile the PutById bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
3974ce2069 LibJS/JIT: Compile the GetGlobal bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
12898f5aef LibJS/JIT: Compile the Decrement bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
e8190105db LibJS/Bytecode: Move GetByValue implementation to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling
310bcd4717 LibJS/JIT: Don't keep trying to JIT unsupported bytecode executables
We now only try jitting each Bytecode::Executable once, and then cache
the resulting NativeExecutable.
2023-10-27 19:07:22 +02:00
Andreas Kling
8905682a16 LibJS/Bytecode: Begin moving shareable (JIT+Interpreter) stuff somewhere
There are a lot of native C++ functions that will be used by both the
bytecode interpreter and jitted code. Let's put them in their own file
instead of having them in Interpreter.cpp.
2023-10-27 19:07:22 +02:00
Andreas Kling
babdc0a25b LibJS: Work-in-progress JIT compiler :^) 2023-10-27 19:07:22 +02:00
Andreas Kling
2e23f00a2f LibJS/Bytecode: Move environment coordinate caches to Executable
Moving them out of the respective instructions allows the bytecode
stream to be immutable.
2023-10-27 07:26:37 +02:00
Andreas Kling
6a3f27509f LibJS: Avoid IdentifierTable lookup in cached GetGlobal op
When we hit the cache in GetGlobal, we don't need the identifier string
at all, so let's defer fetching it until after the cache miss.

7% speed-up on Kraken/imaging-gaussian-blur.js :^)
2023-10-08 11:55:27 +02:00
Andreas Kling
ae4e46a037 LibJS: Do less work in successfully cached GetByValue* ops
If we have a cached environment coordinate that hasn't been screwed
by eval(), we can get the value directly without instantiating a
Reference.

15% speed-up on Octane/zlib.js :^)
2023-10-07 20:01:52 +02:00
Andreas Kling
65717e3b75 LibJS: Inline fast case for Value::to_{boolean,number,numeric,primitive}
These functions all have a very common case that can be dealt with a
very simple inline check, often avoiding the need to call an out-of-line
function. This patch moves the common case to inline functions in a new
ValueInlines.h header (necessary due to header dependency issues..)

8% speed-up on the entire Kraken benchmark :^)
2023-10-07 07:13:52 +02:00
Andreas Kling
021a141b53 LibJS: Make array-like Put access on ordinary objects much faster
This patch adds a fast path to the PutByValue bytecode op that bypasses
a ton of things *if* a set of assumptions hold:

- The property key must be a non-negative Int32
- The base object must not interfere with indexed property access
- The base object must have simple indexed property storage
- The property key must already be present as an own property
- The existing value must not have any accessors defined

If this holds (which it should in many common cases), we can skip all
kinds of checks and poke directly at the property storage, saving time.

16% speed-up on the entire Kraken benchmark :^)
(including: 88% speed-up on Kraken/imaging-desaturate.js)
(including: 55% speed-up on Kraken/audio-fft.js)
(including: 54% speed-up on Kraken/audio-beat-detection.js)
2023-10-05 16:57:45 +02:00
Andreas Kling
27a83f7e5e LibJS: Make array-like Get access on ordinary objects much faster
This patch adds a fast path to the GetByValue bytecode op that bypasses
a ton of things *if* a set of assumptions hold:

- The property key must be a non-negative Int32
- The base object must not interfere with indexed property access
- The property key must already be present as an own property
- The existing value must not have any accessors defined

If this holds (which it should in the common case), we can poke directly
at the indexed property storage and save a boatload of time.

10% speed-up on the entire Kraken benchmark :^)
(including: 31% speed-up on Kraken/audio-dft.js)
(including: 23% speed-up on Kraken/stanford-crypto-aes.js)
2023-10-05 16:57:45 +02:00
Andreas Kling
c14db6ab12 LibJS: Make Executable ref-counted and let instruction iterator co-own it
This ensures that the instruction stream pointed at by the instruction
iterator remains valid as long as the iterator exists.
2023-10-03 08:23:33 +02:00
Andreas Kling
feedbd6a01 LibJS: Put __builtin_unreachable() in unused bytecode opcode handlers
For the opcodes that are handled directly in the interpreter loop,
we want the compiler to know that there's nothing to inline here.
2023-09-28 06:09:16 +02:00
Andreas Kling
f3606adc58 LibJS: Inline bytecode ops for direct local/register access
These can do a lot less stuff if we put them directly in the interpreter
loop and allow them to access the locals/registers arrays directly.
2023-09-28 06:09:16 +02:00
Andreas Kling
ae1ac9871b LibJS: Move all bytecode instruction implementations to Interpreter.cpp
This allows aggressive inlining without LTO.
2023-09-28 06:09:16 +02:00
Andreas Kling
e5474c384d LibJS: Inline flow control ops in the bytecode interpreter loop
Instead of calling out to helper functions for flow control (and then
checking control flags on every iteration), we now simply inline those
ops in the interpreter loop directly.
2023-09-28 06:09:16 +02:00
Andreas Kling
39cfb64269 LibJS: Return early from Interpreter on unhandled exception
If we don't have a local unwind context to handle the exception, we can
just return right away. This allows us to remove one check from the
inner loop.
2023-09-28 06:09:16 +02:00