Andreas Kling
c2aad0f573
LibJS/Bytecode: Move PutByValue impl to CommonImplementations
2023-10-27 19:07:22 +02:00
Andreas Kling
9c93d100d1
LibJS/JIT: Compile the NewFunction bytecode instruction
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
a913ac5799
LibJS/JIT: Compile the NewArray bytecode instruction
2023-10-27 19:07:22 +02:00
Andreas Kling
6a16783c66
LibJS/JIT: Compile the SetVariable bytecode instruction
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
e946440ed3
LibJS/JIT: Compile the TypeofVariable bytecode instruction
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
c65aecd878
LibJS/JIT: Compile all the unary bytecode instructions
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
d866780235
LibJS/JIT: Compile the NewObject bytecode instruction
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
10bf25999c
LibJS/JIT: Move VM pointers from R8,R9,R10 to R13,R14,R15
...
This way they don't clash with the SysV ABI function argument registers.
2023-10-27 19:07:22 +02:00
Andreas Kling
decc221109
LibJS/JIT: Save and restore callee-saved registers in jitted code
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
966b6f78a6
LibJS/JIT: Compile the GetByValue 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
1c0efbec6b
LibJS/JIT: Compile the ResolveThisBinding bytecode instruction
2023-10-27 19:07:22 +02:00
Andreas Kling
b2602a4bae
LibJS/JIT: Compile the ToNumeric bytecode instruction
2023-10-27 19:07:22 +02:00
Andreas Kling
0f735b3502
LibJS/JIT: Log both success and failure from the JIT compiler
...
These logs will eventually go away, once the JIT compiler can always
compile everything. :^)
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
6a6ef6670c
LibJS/JIT: Support the GetById bytecode op
...
We can now do basic property (get) access in jitted code! :^)
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
b923ca392d
LibJS/JIT: Support all the binary bytecode ops :^)
...
(And use the X macro to avoid repeating ourselves!)
2023-10-27 19:07:22 +02:00
Andreas Kling
c2fe7af095
LibJS/JIT: Support the NewString bytecode op
...
This necessitated making the JIT::Compiler aware of the current
Bytecode::Executable, since that's where all the string literals are
held, but that seems like a good thing.
2023-10-27 19:07:22 +02:00
Andreas Kling
efe58ebf2f
LibJS/JIT: Support the Return bytecode op
2023-10-27 19:07:22 +02:00
Andreas Kling
45be2a8f72
LibJS/JIT: Add support for Add/Sub/Mul/Div bytecode ops
2023-10-27 19:07:22 +02:00
Geo25rey
891b071654
LibJS/JIT: Add support for "throw" keyword
2023-10-27 19:07:22 +02:00
Andreas Kling
ed0d2bce83
LibJS/JIT: Handle exceptions in LessThan :^)
2023-10-27 19:07:22 +02:00
Andreas Kling
9dd5be0186
LibJS/JIT: Compile the EnterUnwindContext and LeaveUnwindContext ops
...
These push a "valid" unwind context on the stack and check_exception()
now knows how to jump to the (catch) handler if present.
(finally) finalizers will require some more work, but with this change,
we now have basic support for try...catch. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling
9d35016284
LibJS/JIT: Add Assembler::jump(Operand) and verify_not_reached()
...
Yet another jump() overload, and also a way to crash if we end up
somewhere we shouldn't be while in jitted code.
2023-10-27 19:07:22 +02:00
Andreas Kling
e3560c2545
LibJS/JIT: Propagate exceptions in the simplest case :^)
...
We now establish a stack of "unwind contexts" similar to what the
bytecode interpreter does, but here, it's a stack of structs with
addresses to the catch and finally blocks.
Unwind contexts also have a "valid" flag, and the root unwind context
(always present, pushed on JIT code entry) has valid=false, which we
interpret in check_exception() as "return and let our caller deal with
the exception".
Anything in Compiler that may generate an exception should now also
call check_exception() ASAP to emit the code for handling this.
2023-10-27 19:07:22 +02:00
Andreas Kling
3523f9f722
LibJS/JIT: Add patchable absolute references to basic blocks
2023-10-27 19:07:22 +02:00
Andreas Kling
2e6c02f088
LibJS/JIT: Support Imm32 operands in Assembler::push()
2023-10-27 19:07:22 +02:00
Andreas Kling
71e41418f6
LibJS/JIT: Do "enter & leave" sequence in x86_64 machine code
...
This ensures that the stack pointer is restored before we return from
the jitted code.
2023-10-27 19:07:22 +02:00
Andreas Kling
814b07a9c2
LibJS/JIT: Add Assembler::jump_if_equal()
...
And also factor out cmp() so we don't have to repeat it.
2023-10-27 19:07:22 +02:00
Andreas Kling
a7bad26b63
LibJS/JIT: Add missing unistd.h include (fixes Clang build)
2023-10-27 19:07:22 +02:00
Andreas Kling
c21978ead6
LibJS/JIT: Remove unused functions from Assembler
2023-10-27 19:07:22 +02:00
Andreas Kling
1e8c6d3b06
LibJS/JIT: Use mov() helper in Assembler::native_call()
2023-10-27 19:07:22 +02:00
Andreas Kling
e7ce3d271a
LibJS/JIT: Add Assembler::add() and sub() helpers
2023-10-27 19:07:22 +02:00
Andreas Kling
10dcb4d53a
LibJS/JIT: Add Assembler::push() and pop() helpers
2023-10-27 19:07:22 +02:00
Andreas Kling
acece9057e
LibJS/JIT: Make Assembler::Reg represent X86 registers
...
And move the generic register aliases to JIT::Compiler.
2023-10-27 19:07:22 +02:00
Andreas Kling
f9041c7b31
LibJS/JIT: Fast path for boolean JS::Value in compile_to_boolean()
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
Jesús (gsus) Lapastora
2086b8df9c
LibJS/Date: Ensure YearFromTime(t)
holds invariant after approximation
...
As of https://tc39.es/ecma262/#sec-yearfromtime , YearFromTime(t) should
return `y` such that `TimeFromYear(YearFromTime(t)) <= t`. This wasn't
held, since the approximation contained decimal digits that would nudge
the final value in the wrong direction.
Adapted from Kiesel:
6548a85743
Co-authored-by: Linus Groh <mail@linusgroh.de>
2023-10-23 09:26:55 -04:00
Jelle Raaijmakers
c58193bafa
LibJS: Support large number of decimals in Number.prototype.toFixed
...
The spec asks us to perform some calculations that quickly exceed an
`u64`, but instead of jumping through hoops we can rely on our AK
implementation of floating point formatting to come up with the
correctly rounded result.
Note that most other JS engines seem to diverge from the spec as well
and fall back to a generic dtoa path.
2023-10-18 19:39:30 -04:00