Commit graph

61140 commits

Author SHA1 Message Date
Andreas Kling
7bdc207d81 LibJS/Bytecode: Make execute_impl() return void for non-throwing ops
This way we can't accidentally ignore exceptions.
2024-05-10 19:53:15 +02:00
Andreas Kling
76df5ae030 Meta: Update Clang version requirement to 17+ 2024-05-10 19:53:15 +02:00
Andreas Kling
01ec56f1ed LibJS/Bytecode: Fix register being freed too early in delete codegen
It wasn't actually possible for it to get reused incorrectly here, but
let's fix the bug anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling
353e635535 LibJS/Bytecode: Grab at ThrowCompletionOr errors directly
The interpreter can now grab at the error value directly instead of
instantiating a temporary Completion to hold it.
2024-05-10 15:03:24 +00:00
Andreas Kling
f5efc47905 LibJS: Make ThrowCompletionOr<T> smaller
Instead of storing a full JS::Completion for the "throw completion"
case, we now store a simple JS::Value (wrapped in ErrorValue for the
type system).

This shrinks TCO<void> and TCO<Value> (the most common TCOs) by 8 bytes,
which has a non-trivial impact on performance.
2024-05-10 15:03:24 +00:00
Andreas Kling
6b2b90d2b0 AK: Remove AK_HAS_CONDITIONALLY_TRIVIAL
Code behind this appears to compile nicely with Clang 17 and later.
2024-05-10 15:03:24 +00:00
Andreas Kling
ae11a4de1c LibJS: Remove unused target field from Completion
This shrinks Completion by 16 bytes, which has non-trivial impact
on performance.
2024-05-10 15:03:24 +00:00
Andreas Kling
a77c6e15f4 LibJS/Bytecode: Streamline return/yield flow a bit in the interpreter 2024-05-10 15:03:24 +00:00
Andreas Kling
3e1a6fca91 LibJS/Bytecode: Remove exception checks from Return/Await/Yield
These instructions can't throw anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling
8eccfdb98c LibJS/Bytecode: Cache a base pointer to executable constants
Instead of fetching it from the current executable whenever we fetch a
constant, just keep a base pointer to the constants array handy.
2024-05-10 15:03:24 +00:00
Andreas Kling
810a297626 LibJS/Bytecode: Remove Instruction::execute()
Just make sure everyone calls the instruction-specific execute_impl()
instead. :^)
2024-05-10 15:03:24 +00:00
Andreas Kling
601e10d50c LibJS/Bytecode: Make StringTableIndex be a 32-bit index
This makes a bunch of instructions smaller.
2024-05-10 15:03:24 +00:00
Andreas Kling
b99f0a7e22 LibJS/Bytecode: Reorder Call instruction members to make it smaller 2024-05-10 15:03:24 +00:00
Andreas Kling
96511a7d19 LibJS/Bytecode: Avoid unnecessary copy of call expression callee
If the callee is already a temporary register, we don't need to copy it
to *another* temporary before evaluating arguments. None of the
arguments will clobber the existing temporary anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling
56a3ccde1a LibJS/Bytecode: Turn UnaryMinus(NumericLiteral) into a constant 2024-05-10 15:03:24 +00:00
Andreas Kling
e37feaa196 LibJS/Bytecode: Skip unnecessary exception checks in interpreter
Many opcodes cannot ever throw an exception, so we can just avoid
checking it after executing them.
2024-05-10 15:03:24 +00:00
Andreas Kling
34f287087e LibJS/Bytecode: Only copy call/array expression arguments when needed
We only need to make copies of locals here, in case the locals are
modified by something like increment/decrement expressions.

Registers and constants can slip right through, without being Mov'ed
into a temporary first.
2024-05-10 15:03:24 +00:00
Andreas Kling
caf2e675bf LibJS/Bytecode: Don't emit GetGlobal undefined
We know that `undefined` in the global scope is always the proper
undefined value. This commit takes advantage of that by simply emitting
a constant undefined value instead.

Unfortunately we can't be so sure in other scopes.
2024-05-10 15:03:24 +00:00
Andreas Kling
448f837d38 LibJS/Bytecode: Round constant operands of bitwise binary expressions
This helps some of the Cloudflare Turnstile stuff run faster, since they
are deliberately screwing with JS engines by asking us to do a bunch of
bitwise operations on e.g 65535.56

By rounding such values in bytecode generation, the interpreter can stay
on the happy path while executing, and finish quite a bit faster.
2024-05-10 15:03:24 +00:00
Andreas Kling
ca8dc8f61f LibJS/Bytecode: Turn JumpIf true/false into unconditional Jump 2024-05-10 15:03:24 +00:00
Andreas Kling
7654da3851 LibJS/Bytecode: Do basic compare-and-jump peephole optimization
We now fuse sequences like [LessThan, JumpIf] to JumpLessThan.
This is only allowed for temporaries (i.e VM registers) with no other
references to them.
2024-05-10 15:03:24 +00:00
Marios Prokopakis
9bcb0feb4d ping: Update the man page 2024-05-09 13:13:20 -06:00
Marios Prokopakis
eecede20ac ping: Implement waittime
Specify the time in seconds to wait for a reply for each packet sent.
Replies received out of order will not be printed as replied but they
will be considered as replied when calculating statistics. Setting it
to 0 means infinite timeout.
2024-05-09 13:13:20 -06:00
Marios Prokopakis
b3658c5706 ping: Implement flood ping mode
In flood ping mode, the time interval between each request is set
to zero to provide a rapid display of how many packets are being
dropped. For each request a period '.' is printed, while for every
reply a backspace is printed.
2024-05-09 13:13:20 -06:00
Marios Prokopakis
90f5e5139f ping: Implement adaptive ping mode
In adaptive ping mode, the interval between each ping request
adapts to the RTT.
2024-05-09 13:13:20 -06:00
Timothy Flynn
1fbf1bc4ac LibWeb: Don't try to click a form image until it has loaded
We are often trying to click the image before it has finished loading.
This results in us trying to click a 0x0 rect. Instead, wait until the
image load event.

This fixes a flake with form-image-submission.html often seen on CI.
2024-05-09 19:29:47 +02:00
Isaac
653f41336b SystemMonitor: Add dropped packets count to adapter table 2024-05-09 12:02:26 +02:00
Isaac
3d2fcf4244 Kernel/net: Add tracking of dropped packets per adapter 2024-05-09 12:02:26 +02:00
Andreas Kling
f164e18a55 LibJS/Bytecode: Bunch all tests together in switch statement codegen
Before this change, switch codegen would interleave bytecode like this:

    (test for case 1)
    (code for case 1)
    (test for case 2)
    (code for case 2)

This meant that we often had to make many large jumps while looking for
the matching case, since code for each case can be huge.

It now looks like this instead:

    (test for case 1)
    (test for case 2)
    (code for case 1)
    (code for case 2)

This way, we can just fall through the tests until we hit one that fits,
without having to make any large jumps.
2024-05-09 09:12:13 +02:00
Andreas Kling
18b8fae85c LibJS/Bytecode: Remove pointless basic block in SwitchStatement codegen 2024-05-09 09:12:13 +02:00
Andreas Kling
6873628317 LibJS/Bytecode: Make NewArray a variable-length instruction
This removes a layer of indirection in the bytecode where we had to make
sure all the initializer elements were laid out in sequential registers.

Array expressions no longer clobber registers permanently, and they can
be reused immediately afterwards.
2024-05-09 09:12:13 +02:00
Andreas Kling
cea59b6642 LibJS/Bytecode: Reuse bytecode registers
This patch adds a register freelist to Bytecode::Generator and switches
all operands inside the generator to a new ScopedOperand type that is
ref-counted and automatically frees the register when nothing uses it.

This dramatically reduces the size of bytecode executable register
windows, which were often in the several thousands of registers for
large functions. Most functions now use less than 100 registers.
2024-05-09 09:12:13 +02:00
Andreas Kling
f537d0b3cf LibJS/Bytecode: Allow all basic blocks to use cached this from block 0
The first block in every executable will always execute first, so if it
ends up doing a ResolveThisBinding, it's fine for all other blocks
within the same executable to use the same `this` value.
2024-05-09 09:12:13 +02:00
Andreas Kling
55a4b0a21e LibJS: Mark Value as a trivial type for AK collection purposes
It's perfectly fine to memcpy() a bunch of JS::Values around, and if
that helps Vector<Value> go faster, let's allow it.
2024-05-09 09:12:13 +02:00
Andreas Kling
161298b5d1 LibJS/Bytecode: Inline indexed property access in GetByVal better 2024-05-09 09:12:13 +02:00
Andreas Kling
3170ad2ee3 LibJS: Avoid string trimming in GlobalObject.parseInt() when possible
In the common case, parseInt() is being called with strings that don't
have leading whitespace. By checking for that first, we can avoid the
cost of trimming and multiple malloc/GC allocations.
2024-05-09 09:12:13 +02:00
Andreas Kling
0f70ff9a67 LibJS/Bytecode: Only emit ResolveThisBinding once per basic block
Once executed, this instruction will always produce the same result
in subsequent executions, so it's okay to cache it.

Unfortunately it may throw, so we can't just hoist it to the top of
every executable, since that would break observable execution order.
2024-05-09 09:12:13 +02:00
Timothy Flynn
a447b9bffd CI: Explicitly enable audio access on macOS 14
On the macOS 14 runners on GitHub actions, attempting to play audio (by
way of AudioOutputUnitStart) will open a pop-up asking for microphone
permission. This prevents any calling test to hang until they error out
with MACH_SEND_TIMED_OUT. This works around the issue by explicitly
enabling microphone access to all applications.
2024-05-08 14:46:39 -06:00
Timothy Flynn
b9210a757e CI: Move the Lagom CI to GitHub actions 2024-05-08 14:46:39 -06:00
Timothy Flynn
660e3ccb1c CI: Rename cmake.yml to serenity.yml
Just calling it "cmake" doesn't really describe what it is for, and a
future commit will add a lagom.yml. So let's call this serenity.yml to
make it clear that it tests SerenityOS itself.

This also renames the workflow, and updates some matrix orderings, to be
easier to distinguish between this job and the upcoming lagom.yml,
2024-05-08 14:46:39 -06:00
Timothy Flynn
ac8d5cce3c CI: Move the clang toolchain CI to GitHub actions 2024-05-08 14:46:39 -06:00
Timothy Flynn
c7828b0640 CI: Remove custom python setup
The only python on the CI machines is now python3. The python installed
by setup-python (which is CPython) seems to have issues running WPT.
2024-05-08 14:46:39 -06:00
Timothy Flynn
520667bda0 CI: Install the six python package
Needed for WPT.
2024-05-08 14:46:39 -06:00
Timothy Flynn
d7dc279ba8 CI: Add the extracted wabt package to the PATH
Unlike Azure, we can't just set the PATH environment variable in GitHub
Actions. We must add it using a special GITHUB_PATH file.
2024-05-08 14:46:39 -06:00
Timothy Flynn
d67b52853a CI: Use the correct value for the save-cache architecture on Lagom 2024-05-08 14:46:39 -06:00
Timothy Flynn
33cf9e68dd CI: Use the correct value for the toolchain ccache primary key 2024-05-08 14:46:39 -06:00
Timothy Flynn
323c9edbb9 LibJS: Increase the stack limit on macOS with ASAN enabled
The macOS 14 runners on GitHub Actions fail with a stack overflow
otherwise.
2024-05-08 14:46:39 -06:00
Hendiadyoin1
e1aecff2ab LibJS: Fail compilation earlier when trying to emit with wrong arguments
This makes the compilation backtraces a lot nicer, and allows clangd to
see the mistake as well.
2024-05-08 22:01:58 +02:00
Hendiadyoin1
af94e4c05d LibJS: Save and restore exceptions on yields in finalizers
Also removes a bunch of related old FIXMEs.
2024-05-08 22:01:58 +02:00
Dan Klishch
8d3eb937c8 Meta: Remove check-symbols.sh
check-symbols.sh had been dealing with libc.a which we don't provide
anymore.
2024-05-08 09:54:41 -06:00