Commit graph

55757 commits

Author SHA1 Message Date
Andrew Kaster
faa8ef98c9 Meta: Port recent changes to gn BUILD
5c7e5cc738
a8f0fa5dd4
0d417cd604
5b87d26027
 (and other friends from the JIT PR)
f915aa70cd
2023-10-27 16:51:03 -06:00
Andrew Kaster
d8ab9ed87c LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter
Move TabPosition into its own file, and using it into the global
namespace the same way we do for Gfx::Orientation. This unbreaks the gn
build, and out of tree builds.
2023-10-27 16:51:03 -06:00
Idan Horowitz
702dd0ca55 AK: Use array element count instead of memory size in backtrace call
The backtrace execinfo API takes the number of addresses the result
buffer can hold instead of its size, for some reason. Previously
backtraces larger than 256 frames deep would write past the end of the
result buffer.
2023-10-27 16:06:35 -04:00
Simon Wanner
ec8330b647 LibJS/JIT: Dump disassembly of generated code using LibX86
This avoids the need for redirecting stdout to a file and using
ndisasm, which can lead to problems if other things are printed.
2023-10-27 21:49:55 +02:00
Simon Wanner
1d68c64b98 LibX86: Apply REX.W to B9-BF MOVs
All the MOVs in the B8-BF range can use the REX.W prefix, not just B8.
Previously instructions like `48 B9... mov rcx, imm64` were interpreted
as `mov rcx, imm32` because the REX.W prefix was only applied to
`48 B8... mov rax, imm64`.
2023-10-27 21:49:55 +02:00
Martin Janiczek
4fc1daa69f LibTest: Change #define-d constants into constexpr and a runtime flag
MAX_GENERATED_VALUES_PER_TEST is now the --randomized_runs flag:
$ ./Build/lagom/bin/TestGenerator --randomized_runs 1000

It's sometimes useful to try larger numbers for it instead of the
default of 100.

MAX_GEN_ATTEMPTS_PER_VALUE is now a constexpr. It's not usually needed
to tweak this value; we can recompile with a different value on the rare
occasion.
2023-10-27 12:26:06 -06:00
Martin Janiczek
ed60a032a8 LibTest: Clean up an unneeded import 2023-10-27 12:26:06 -06:00
Martin Janiczek
4c068ba921 LibTest: Minimize footprint of Gen::unsigned_int, simplify code
unsigned_int(0) doesn't need to draw bits from RandomnessSource.

An expression for getting INT_MAX for u32 didn't need to be
special-cased over the general formula.

This is a follow-up on a few comments
2023-10-27 12:26:06 -06:00
Andreas Kling
230aa1404c LibJIT: Only compile Assembler on x86_64 for now 2023-10-27 19:07:22 +02:00
Andreas Kling
c1551a64dc LibJS/JIT: Compile the NewRegExp bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
d6756decb9 LibJS/JIT: Compile the JumpNullish bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
17b2c7d965 LibJS/JIT: Compile the TypeofLocal bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling
a645b9c6c3 LibJS/JIT: Stub out the JIT compiler on everything but ARCH(X86_64)
We don't support other architectures yet!
2023-10-27 19:07:22 +02:00
Andreas Kling
d1c701f79f LibJS/JIT: Compile the Create/LeaveLexicalEnvironment instructions 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
17657d012f LibJS/JIT: Consider compilation failed if mprotect(PROT_EXEC) fails 2023-10-27 19:07:22 +02:00
Andreas Kling
8c745ca223 LibJS+LibJIT: Fix GCC build 2023-10-27 19:07:22 +02:00
Andreas Kling
8eba60d015 LibJS/JIT: Only try JIT compilation when LIBJS_JIT is set in environment
Instead of adding a flag to everything everywhere, let's try using an
environment variable this time.
2023-10-27 19:07:22 +02:00
Andreas Kling
ae273e8e20 LibJS/JIT: Add simple compile-time flags for logging & dumping code 2023-10-27 19:07:22 +02:00
Andreas Kling
3b239b64ff LibJS/JIT: Remove debug spam in cxx_increment() 2023-10-27 19:07:22 +02:00
Andreas Kling
e2f5bfb4c4 LibJS/JIT: Always mask everything but LSB in ToBoolean
As it turns out, cxx_to_boolean() may return "bool" as other values
than just 0 or 1. This happens when the C++ compiler decides to only
update the AL portion of the RAX return value register instead of
the whole thing.
2023-10-27 19:07:22 +02:00
Andreas Kling
5b198ccf32 LibJS+LibJIT: Don't turn patchable movs into xors with self
If a mov instruction is meant to be patchable, we don't want to rewrite
it as a xor, since that removes the slot where we'd patch in the right
value later.

Also, make sure to set both size bits in the REX prefix for xoring a
register with itself.
2023-10-27 19:07:22 +02:00
Andreas Kling
8b32e98f3f LibJS/JIT: Simplify Increment Int32 fast path
When we know the value is a positive Int32 less than 0x7fffffff,
it's safe to just add 1 to it and use that as the final result.
This avoids the work of re-adding the INT32_TAG.
2023-10-27 19:07:22 +02:00
Andreas Kling
b43e38112c LibJS/JIT: Use JIT::Assembler::jump_if_zero() to improve code size 2023-10-27 19:07:22 +02:00
Andreas Kling
6f0baea594 LibJIT: Add jump_if_zero() and jump_if_not_zero() to Assembler
These can use test reg,reg on x86 which gives us a shorter encoding.
2023-10-27 19:07:22 +02:00
Andreas Kling
fb483f1950 LibJIT: Emit 8-bit displacement variants for mov when possible 2023-10-27 19:07:22 +02:00
Andreas Kling
d09bc54586 LibJIT: Encode mov(reg, 0) as xor(reg, reg)
This uses less space for the same result. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling
5b87d26027 LibJIT+LibJS: Move JIT::Assembler into a new LibJIT library
This will allow other parts of the system to generate machine code
at runtime. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling
bfb527e614 LibJS/JIT: Call throw_if_needed_for_call() in cxx_call()
This allows test-js to run to completion (although we do still have
some bugs to track down.)
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
72c31fdd01 LibJS: Remove all interactions between Assembler and BasicBlock
With this change, Assembler is now free from LibJS concepts and could
move out to its own apartment. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling
022974a43a LibJS/JIT: Let Compiler keep per-BasicBlock state internally
Compiler now has a BasicBlockData struct for each BasicBlock. The struct
contains all the stuff that we previously stored with the
Bytecode::BasicBlock.
2023-10-27 19:07:22 +02:00
Andreas Kling
8a24d00b1a LibJS/JIT: Preserve the accumulator across PutByFoo
This ensures that we don't clobber the accumulator when putting a value
to a setter.
2023-10-27 19:07:22 +02:00
Andreas Kling
5bd93f34af LibJS/JIT: Sign-extend integers before comparing in LessThan fast path 2023-10-27 19:07:22 +02:00
Andreas Kling
4b7f5f4ae7 LibJS/JIT: Allow multiple jumps to the same Assembler::Label 2023-10-27 19:07:22 +02:00
Andreas Kling
1fb95c7df9 LibJS/JIT: Add fast path for LessThan Int32 < Int32
This uses a new branch_if_both_int32() helper.

It's interesting to note that we can compare encoded Int32 values
without stripping the INT32_TAG, since it doesn't affect signedness
of values.
2023-10-27 19:07:22 +02:00
Andreas Kling
895c613400 LibJS/JIT: Fix encoding of CMP reg,reg 2023-10-27 19:07:22 +02:00
Andreas Kling
ea65214c57 LibJS/JIT: Add fast path for Increment with Int32 value
This uses a new branch_if_int32() mechanism that takes a code generating
lambda whose code will run if the input register is an Int32 JS::Value.
2023-10-27 19:07:22 +02:00
Andreas Kling
aeb9bd3bf1 LibJS/JIT: Fix encoding of x86_64 AND reg, reg 2023-10-27 19:07:22 +02:00
Andreas Kling
e4c4fb09f9 LibJS/JIT: Add fast path for the ResolveThisBinding codegen
We now generate a fast path for cached `this` values. The first time
`this` is resolved within a function, we call out to C++, but then
all subsequent accesses will hit the cache in Register::this_value().
2023-10-27 19:07:22 +02:00
Andreas Kling
7097169967 LibJS/JIT: Compile the PutByValue bytecode instruction 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
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