Commit graph

33299 commits

Author SHA1 Message Date
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 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
Isaac 653f41336b SystemMonitor: Add dropped packets count to adapter table 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 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 b0b1817b06 LibELF: Make orders in which we store/call things explicit
While on it, add a few spec links and remove needless conversions
between DynamicLoader objects and their respective filesystem paths.
2024-05-08 09:53:58 -06:00
Nico Weber d988b6facc LibGfx/WebPWriter+TestImageWriter: Fix bugs writing VP8X header
Two bugs:

1. Correctly set bits in VP8X header.
   Turns out these were set in the wrong order.

2. Correctly set the `has_alpha` flag.

Also add a test for writing webp files with icc data. With the
additional checks in other commits in this PR, this test catches
the bug in WebPWriter.

Rearrange some existing functions to make it easier to write this test:

* Extract encode_bitmap() from get_roundtrip_bitmap().
  encode_bitmap() allows passing extra_args that the test uses to pass
  in ICC data.
* Extract expect_bitmaps_equal() from test_roundtrip()
2024-05-08 16:34:11 +02:00
Nico Weber 0805319d1e LibGfx/WebPLoader: Diagnose mismatch between VP8X and VP8L alpha bits
If this turns out to be too strict in practice, we can replace it with
a `dbgln("VP8X and VP8L headers disagree about alpha; ignoring VP8X");`
instead.

ALso update catdog-alert-13-alpha-used-false.webp to not trigger this.
I had manually changed the VP8L alpha flag at offset 0x2a in
da48238fbd to clear it, but I hadn't changed the VP8X flag.
This changes the byte at offset 0x14 from 0x10 (has_alpha) to 0x00
(no alpha) as well, to match.
2024-05-08 16:34:11 +02:00
Nico Weber 25e2e17218 LibGfx/WebPLoader: Diagnose ICCP flag / ICCP chunk presence mismatch
If this turns out to be too strict in practice, we can replace it with
a dbgln() with the same message, but with with ", ignoring header."
tacked on at the end.
2024-05-08 16:34:11 +02:00
Nico Weber 25be8f8ae7 LibGfx/WebPWriter: Add some debug logging 2024-05-08 16:34:11 +02:00
Andrew Kaster e10721f1b5 LibWeb: Add stub implementation of FontFaceSet and Document.fonts
This is now enough for duolingo to load and use its fallback fonts.
2024-05-08 10:39:16 +02:00
Andrew Kaster 2c31d7dddc LibWeb: Add stub implementation of CSS FontFace Web API 2024-05-08 10:39:16 +02:00
Andrew Kaster 3a5eabc43b LibWeb: Rename CSS::FontFace to CSS::ParsedFontFace
This implementation detail of CSSFontFaceRule is hogging the name of a
Web API from CSS Font Loading Module Level 3.
2024-05-08 10:39:16 +02:00
Jamie Mansfield 3f113e728f LibWeb/SVG: Stub SVGTransform.setSkewY 2024-05-07 17:33:27 -06:00
Jamie Mansfield dc6febaea6 LibWeb/SVG: Stub SVGTransform.setSkewX 2024-05-07 17:33:27 -06:00
Jamie Mansfield 0bac2d5fbd LibWeb/SVG: Stub SVGTransform.setRotate 2024-05-07 17:33:27 -06:00
Jamie Mansfield effb696eef LibWeb/SVG: Stub SVGTransform.setScale 2024-05-07 17:33:27 -06:00
Jamie Mansfield 5d5f043631 LibWeb/SVG: Stub SVGTransform.setTranslate 2024-05-07 17:33:27 -06:00
Jamie Mansfield c102630a59 LibWeb/SVG: Stub SVGTransform.angle 2024-05-07 17:33:27 -06:00
Jamie Mansfield 4406d06d26 LibWeb/SVG: Stub SVGTransform.type 2024-05-07 17:33:27 -06:00
Jamie Mansfield bc91c75481 LibWeb/SVG: Format SVGTransform.idl 2024-05-07 17:33:27 -06:00
Jamie Mansfield 74d90338b1 LibWeb/Fetch: Support setting request priority from JS 2024-05-07 17:27:37 -06:00
Jamie Mansfield 4387d12159 LibWeb/Fetch: Block ports 4190 and 6679
See:
- https://github.com/whatwg/fetch/commit/4c3750d
2024-05-07 17:27:37 -06:00
Jamie Mansfield 987198782c LibWeb/Fetch: Use "json" destination
See:
- https://github.com/SerenityOS/serenity/commit/da8d0d8
- https://github.com/whatwg/fetch/commit/49bff76
- https://github.com/whatwg/html/commit/37659e9
2024-05-07 17:27:37 -06:00
Jamie Mansfield e2f242a552 LibWeb/Fetch: Implement "fetch destination from module type" AO
See:
- https://github.com/whatwg/html/commit/37659e9
2024-05-07 17:27:37 -06:00
Jamie Mansfield 1b043d259a LibWeb: Implement ShadowRoot.onslotchange 2024-05-07 17:27:37 -06:00
Jamie Mansfield da0ca2f866 LibWeb: Implement ShadowRoot.delegatesFocus 2024-05-07 17:27:37 -06:00
Shannon Booth 71819153cb LibWeb: Implement Element::scroll(HTML::ScrollToOptions) 2024-05-07 17:21:52 -06:00
Shannon Booth 37ca32d62c LibWeb: Implement Element::scroll(x, y) closer to spec 2024-05-07 17:21:52 -06:00
Shannon Booth 31977cc0ac LibWeb: Implement Element::scroll_by(x, y) 2024-05-07 17:21:52 -06:00
Shannon Booth e640a68733 LibWeb: Implement Element::scroll_by(HTML::ScrollToOptions) 2024-05-07 17:21:52 -06:00
Shannon Booth e5d03e382e LibWeb: Add AO for "normalize non-finite values"
We had implemented this in two different ways. Add an AO to to align the
implementations.
2024-05-07 17:21:52 -06:00
Sönke Holz 116f82d21a LibDebug: Don't assume compilation unit index == line program index
Instead, use the `DW_AT_stmt_list` attribute of the compilation unit
entry to determine the corresponding line program.
2024-05-07 16:57:09 -06:00
Sönke Holz 14ae04075e LibDebug: Make LineProgram::create take DwarfInfo as a const reference
The m_dwarf_info is never mutated, so it can be const.
2024-05-07 16:57:09 -06:00
Sönke Holz bc7d067821 LibDebug: Remove m_stream member from LineProgram
The stream passed to LineProgram::create is a temporary, so rather than
keeping an (unused) dangling reference, pass this stream explicitly to
all functions used by LineProgram::create.
2024-05-07 16:57:09 -06:00