Commit graph

645 commits

Author SHA1 Message Date
Andreas Kling
298dfa96a4 LibJS: Remove unused members from EnterUnwindContext instruction 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
Jesús (gsus) Lapastora
1850652881 LibJS/Bytecode: Check if eval function is a function
When overriding 'eval' to a non-function value, the interpreter would
crash. Now it handles this case swiftly, throwing a TypeError.
2023-11-11 08:56:12 +01:00
Andreas Kling
2520c46224 LibJS/JIT: Resolve the GetCalleeAndThisFromEnvironment cache at JIT time 2023-11-10 14:49:25 +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
Todderod
bb9230bbcd LibJS: Remove redundant Store op
If the property for GetByValue in Generator::load_from_reference
is a calculated value this would be stored in an allocated
register and returned from the function. Not all callers want
this information however, so now only give it out when asked for.

Reduced the instruction count for Kraken/ai-astar.js function
"neighbours" from 214 to 192.
2023-11-08 22:18:28 +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
Simon Wanner
eaf8c2e398 LibJS: Improve error messages for primitive strict mode property access
Using ErrorType::ReferencePrimitiveSetProperty the errors for primitives
now look like "Cannot set property 'foo' of number '123'".

The strict-mode-errors test has been adjusted and re-enabled.
2023-11-05 18:44:48 +01:00
Simon Wanner
b9c9315bcb LibJS: Assign getter/setter function names as early as possible
In case of {get func() {}, set func() {}} we were wrongly setting the
function name to 'func' and then later trying to replace an empty name
with 'get func'/'set func' which failed.

Instead, set the name to 'get func'/'set func' right away.
The code in put_by_property_key is kept, for when that is called
by put_by_value.
2023-11-05 18:44:48 +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
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
Nick Hawke
67566e5017 LibJS: Migrate DeprecatedString to String
This changes BasicBlock's constructor and create().
2023-11-02 14:55:12 +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
Hendiadyoin1
73f347b75c LibJS: Create static unwind mappings for BasicBlocks
This is currently only used in the bytecode dump to annotate to where
unwinds lead per block, but will be hooked up to the virtual machine in
the next commit.
2023-10-30 13:10:08 +01:00
Simon Wanner
a2b0154661 LibJS/JIT: Compile the AsyncIteratorClose instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
ac59e982a9 LibJS/JIT: Compile the CopyObjectExcludingProperties instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
9494fbe670 LibJS/JIT: Compile the PutByValueWithThis instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
847889343f LibJS/JIT: Compile the New##ErrorName instructions 2023-10-30 07:10:24 +01:00
Simon Wanner
a16082c6a5 LibJS/JIT: Compile the HasPrivateId instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
19045d6431 LibJS/JIT: Compile the GetMethod instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
c0c40110c1 LibJS/JIT: Compile the ImportCall instruction 2023-10-30 07:10:24 +01:00
Simon Wanner
ac43d3f6db LibJS/JIT: Compile the PutPrivateById instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
81697549b7 LibJS/JIT: Compile the PutByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
38d5d7979b LibJS/JIT: Compile the DeleteByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
b53277110e LibJS/JIT: Compile the GetByValueWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
569ca57e22 LibJS/JIT: Compile the GetByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner
4e9edb8c53 LibJS/JIT: Compile the GetPrivateById instruction 2023-10-29 22:57:19 +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
40064d872f LibJS/JIT: Compile the Append instruction 2023-10-29 17:36:09 +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
c697ff61f6 LibJS/JIT: Compile the IteratorClose instruction 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
4f8f8b7792 LibJS/JIT: Compile the GetIterator instruction 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