Commit graph

24747 commits

Author SHA1 Message Date
Andrew Kaster a68222f654 LibWeb: Enable callbacks in chunk steps for ReadableStreamDefaultTee
We enqueue a microtask for this readable stream AO, and the methods that
we call from the chunk steps manipulate promises. As such, we need to
enable callbacks for the entire microtask's temporary execution
context.
2024-05-23 11:22:44 +02:00
Andrew Kaster bab546472e LibWeb: Mark FontFaceSet as a setlike IDL interface
And implement more of the constructor logic.
2024-05-23 10:57:34 +02:00
Andrew Kaster 7077e4d002 LibIDL+LibWeb: Add support for WebIDL setlike declarations on interfaces 2024-05-23 10:57:34 +02:00
Aliaksandr Kalenik f29ac8517e LibJS: Skip ordinary_call_bind_this() when possible
If during parsing it was found that function won't use `this` then
there is no need to initialise `this_value` during call.
2024-05-23 09:53:31 +02:00
Aliaksandr Kalenik e934132442 LibJS+LibWeb: Pass function metadata collected in parsing using a struct
By using separate struct we can avoid updating AST node and
ECMAScriptFunctionObject constructors every time there is a need to
add or remove some additional information colllected during parsing.
2024-05-23 09:53:31 +02:00
Ali Mohammad Pur 8b1341c77e LibWeb: Make exported Wasm functions keep the module instance alive
As it's not uncommon for users to drop the module instance on the floor
after having grabbed the few exports they need to hold on to.
Fixes a few UAFs that show up as "invalid" accesses to
memory/tables/etc.
2024-05-23 00:55:56 -06:00
Matthew Olsson a98ad191c7 Userland: Add ESCAPING annotations to a bunch of places
This isn't comprehensive; just a result of a simple grep search.
2024-05-22 21:55:34 -06:00
Matthew Olsson a5f4c9a632 AK+Userland: Remove NOESCAPE
See the next commit for an explanation
2024-05-22 21:55:34 -06:00
Andreas Kling 899c38d342 LibWeb: Mark IDBFactory.open() with FIXME extended attribute in IDL
The stub implementation broke x.com and probably other sites as well,
but let's at least mark it FIXME so we get some debug logging about it.
2024-05-22 21:46:08 +02:00
Andreas Kling 79870bc603 Revert "LibWeb: Add stub for IDBFactory.open"
This reverts commit f7beea1397.

This broke loading https://x.com/
2024-05-22 21:40:52 +02:00
Lucas CHOLLET 07446bbea1 LibGfx/GIF: Use the correct reference to seek before the trailer
This was working with files, but with pre-allocated buffers, the end
is not the same position as last written byte.
2024-05-22 13:29:05 -04:00
Lucas CHOLLET 3c4b8749f0 LibGfx/GIF: Write a Graphic Control Extension block
This allows us to write the duration of each frame.
2024-05-22 13:29:05 -04:00
Lucas CHOLLET bee8dd76ee LibGfx/GIF: Write the netscape extension block
This allows us to encode the required number of loops in the file.
2024-05-22 13:29:05 -04:00
Aliaksandr Kalenik ebb3d8025c LibJS: Get this from execution context for non-arrow functions
Allows to skip function environment allocation for non-arrow functions
if the only reason it is needed is to hold `this` binding.

The parser is changed to do following:
- If a function is an arrow function and uses `this` then all functions
  in a scope chain are marked to allocate function environment for
  `this` binding.
- If a function uses `new.target` then all functions in a scope chain
  are marked to allocate function environment.

`ordinary_call_bind_this()` is changed to put `this` value in execution
context when function environment allocation is skipped.

35% improvement in Octane/typescript.js
50% improvement in Octane/deltablue.js
19% improvement in Octane/raytrace.js
2024-05-22 18:30:13 +02:00
Dan Klishch 7ae990d2e5 LibCrypto: Don't compute 2*N remainders in Adler32
Otherwise Zlib decompression spends half of the time computing the
checksum.
2024-05-22 14:25:21 +02:00
Nico Weber b7b51d01c3 LibGfx/AnimationWriter: Survive animations with two identical frames
Creating a completely empty bitmap fails. Just write a 1x1 bitmap
if the bitmap ends up empty for now.
2024-05-22 06:41:47 -04:00
Nico Weber 51617929dc LibGfx/GIFLoader: Add more debug logging output 2024-05-22 06:41:47 -04:00
Dan Klishch 5a85067b49 Revert "LibCore: Add Core::deferred_invoke_if(F, Condition)"
This reverts commit a362c37c8b.

The commit tried to add an unused function that continued our tradition
of not properly waiting for things but instead flooding event loop with
condition checks that delay firing of the event. I think this is a
fundamentally flawed approach. See also checks for
`fire_when_not_visible` in LibCore/EventLoopImplementationUnix.cpp.
2024-05-21 23:32:54 +02:00
Tim Ledbetter c0e504fbdd LibWeb: Add some missing [FIXME] IDL attributes 2024-05-21 19:29:04 +02:00
Tim Ledbetter 58bb5e1f7a LibWeb: Use [Reflect] to implement HTMLPreElement.width 2024-05-21 19:28:43 +02:00
Tim Ledbetter 2a7cf1c588 LibWeb: Implement the width and height attributes where missing
This change adds the `width` and `height` properties to
`HTMLVideoElement` and `HTMLSourceElement`. These properties reflect
their respective content attribute values.
2024-05-21 19:28:43 +02:00
Tim Ledbetter 9f9aa62128 LibWeb: Implement the hspace and vspace attributes
These properties reflect their respective content attributes.
2024-05-21 19:28:43 +02:00
Aliaksandr Kalenik 4d37b9e715 LibJS: Do not count arguments as env binding when local variable is used
This is a follow up for 210a5d77dc that
actually allows to skip function environment allocation.
2024-05-21 15:49:29 +00:00
Dan Klishch 38b51b791e AK+Kernel+LibVideo: Include workarounds for missing P0960 only in Xcode
With this change, ".*make.*" function family now does error checking
earlier, which improves experience while using clangd. Note that the
change also make them instantiate classes a bit more eagerly, so in
LibVideo/PlaybackManager, we have to first define SeekingStateHandler
and only then make() it.

Co-Authored-By: stelar7 <dudedbz@gmail.com>
2024-05-21 14:24:59 +02:00
Aliaksandr Kalenik 210a5d77dc LibJS: Use a local variable for arguments object when possible
This allows us to skip allocating a function environment in cases where
it was previously impossible because the arguments object needed a
binding.

This change does not bring visible improvement in Kraken or Octane
benchmarks but seems useful to have anyway.
2024-05-21 11:24:50 +02:00
Lucas CHOLLET 777e84b09b LibGfx+animation: Support writing animated GIF files 2024-05-21 09:47:46 +02:00
Lucas CHOLLET 6a5f8b5163 LibGfx/GIF: Make write_logical_descriptor() take an IntSize
The bitmap was only needed for its size.
2024-05-21 09:47:46 +02:00
Kenneth Myhra 29112f7365 LibWeb: Integrate Streams in XHR::send() 2024-05-20 16:57:52 -04:00
Kenneth Myhra 76418f3ffa LibWeb: Implement the concept incrementally read a body 2024-05-20 16:57:52 -04:00
Kenneth Myhra 34ecc59508 LibWeb: Implement read a chunk concept for ReadableStreamDefaultReader 2024-05-20 16:57:52 -04:00
Kenneth Myhra 50f454fdd5 LibWeb: Enqueue body chunks in Fetch::extract_body()
Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2024-05-20 16:57:52 -04:00
Kenneth Myhra f119ac1a9d LibWeb: Integrate TransformStream into fetch_response_handover() 2024-05-20 16:57:52 -04:00
Kenneth Myhra 5a3e603b3d LibWeb: Implement AO transform_stream_set_up() 2024-05-20 16:57:52 -04:00
Kenneth Myhra f3ecdb22d5 LibWeb: Implement ReadableStream::close() 2024-05-20 16:57:52 -04:00
Kenneth Myhra e2c4019bfc LibWeb: Close acquired writer in AO readable_stream_pipe_to()
Also adds a test to prove that the WritableStream's close callback is
called.
2024-05-20 16:57:52 -04:00
Kenneth Myhra 15b677385c LibWeb: Provide an UInt8Array to AO writable_stream_default_writer_write
ReadLoopReadRequest::on_chunk expects an UInt8Array, so make sure we
convert the passed in ByteBuffer to an UInt8Array before passing it to
the AO writable_stream_default_writer_write.

Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2024-05-20 16:57:52 -04:00
Timothy Flynn b5ba60f1d1 LibWeb: Change Fetch's ProcessBodyError to accept a plain JS value
This callback is meant to be triggered by streams, which does not always
provide a WebIDL::DOMException. Pass a plain value instead. Of all the
users of this callback, only one actually uses the value, and already
converts the DOMException to a plain value.
2024-05-20 16:57:52 -04:00
Timothy Flynn fb9c8324d9 LibThreading: Remove extra spammy log message upon starting a thread 2024-05-20 11:28:34 -06:00
Lucas CHOLLET a8bac0adc1 LibGfx/WebP: Use default initializer for CanonicalCode::m_code
No behavior change.
2024-05-20 13:17:34 -04:00
Nico Weber d294f150ed LibGfx+LibCompress: WebPWriter performance regression reduction
This moves both Gfx::CanonicalCode::write_symbol() and
Compress::CanonicalCode::write_symbol() inline.

It also adds `__attribute__((always_inline))` on the arguments
to visit() in the latter. (ALWAYS_INLINE doesn't work on lambdas.)

Numbers with `ministat`: I ran once:

    Build/lagom/bin/image -o test.bmp Base/res/wallpapers/sunset-retro.png

and then ran to bench:

    ~/src/hack/bench.py -n 20 -o bench_foo1.txt \
        Build/lagom/bin/image -o test.webp test.bmp

...and then `ministat bench_foo1.txt bench_foo2.txt` to compare.

The previous commit increased the time for this command by 38% compared
to the before state.

With this, it's an 8.6% regression. So still a regression, but a smaller
one.

Or, in other words, this commit reduces times by 21% compared to the
previous commit.

Numbers with hyperfine are similar -- with this on top of the previous
commit, this is a 7-11% regression, instead of an almost 50% regression.

(A local branch that changes how we compute CanonicalCodes so that we
actually compress a bit is perf-neutral since the image writing code
doesn't change.)

`hyperfine 'image -o test.webp test.bmp'`:
* Before:          23.7 ms ± 0.7 ms (116 runs)
* Previous commit: 33.2 ms ± 0.8 ms (82 runs)
* This commit:     25.5 ms ± 0.7 ms (102 runs)

`hyperfine 'animation -o wow.webp giphy.gif'`:
* Before:           85.5 ms ± 2.0 ms (34 runs)
* Previous commit: 127.7 ms ± 4.4 ms (22 runs)
* This commit:      95.3 ms ± 2.1 ms (31 runs)

`hyperfine 'animation -o wow.webp 7z7c.gif'`:
* Before:          12.6 ms ± 0.6 ms (198 runs)
* Previous commit: 16.5 ms ± 0.9 ms (153 runs)
* This commit:     13.5 ms ± 0.6 ms (186 runs)
2024-05-20 13:17:34 -04:00
Nico Weber 7aa61ca49b LibGfx/WebP: Add CanonicalCode::write_symbol(), use it in writer
We still construct the code length codes manually, and now we also
construct a PrefixCodeGroup manually that assigns 8 bits to all
symbols (except for fully-opaque alpha channels, and for the
unused distance codes, like before). But now we use the CanonicalCodes
from that PrefixCodeGroup for writing.

No behavior change at all, the output is bit-for-bit identical to
before. But this is a step towards actually huffman-coding symbols.

This is however a pretty big perf regression. For
`image -o test.webp test.bmp` (where test.bmp is retro-sunset.png
re-encoded as bmp), time goes from 23.7 ms to 33.2 ms.

`animation -o wow.webp giphy.gif` goes from 85.5 ms to 127.7 ms.

`animation -o wow.webp 7z7c.gif` goes from 12.6 ms to 16.5 ms.
2024-05-20 13:17:34 -04:00
Nico Weber 1bd1b6e5e9 LibGfx/WebPWriter: Put hot loop in its own function
This makes it easier to compare the generated assembly for this function
in different scenarios.

No behavior or perf change.
2024-05-20 13:17:34 -04:00
Nico Weber ed2658d72c LibGfx/WebP: Move some to-be-shared code to WebPSharedLossless.h
No behavior change. No measurable performance different either.

(I tried `hyperfine 'Build/lagom/bin/image --no-output foo.webp'`
for a few input images before and after this change, and I didn't
see a difference. I also tried if moving both
Gfx::CanonicalCode::read_symbol() and
Compress::CanonicalCode::read_symbol() inline, and that didn't
help either.)
2024-05-20 13:17:34 -04:00
Nico Weber 86b0a56899 LibGfx/WebPWriter: Minor cleanups
Replace a comment with equivalent code, and rename a variable.

No behavior change.
2024-05-20 13:17:34 -04:00
Andreas Kling 448b7ca87b LibJS/Bytecode: Add dedicated instruction for getting length property
By doing this, we can remove all the special-case checks for `length`
from the generic GetById and GetByIdWithThis code paths, making every
other property lookup a bit faster.

Small progressions on most benchmarks, and some larger progressions:

- 12% on Octane/crypto.js
- 6% on Kraken/ai-astar.js
2024-05-20 12:51:56 +02:00
Tim Ledbetter a6d6729034 LibWeb: Implement the MouseEvent.relatedTarget attribute
This returns the secondary target of a mouse event. For `onmouseenter`
and `onmouseover` events, this is the EventTarget the mouse exited
from. For `onmouseleave` and `onmouseout` events, this is the
EventTarget the mouse entered to.
2024-05-20 08:21:41 +02:00
Ali Mohammad Pur def379ce3f LibCrypto: Move some data around earlier in GHash to make it go faster
This makes galois_multiply() about 10% faster.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur 57714fbb38 RequestServer: Handle IPC requests on multiple threads concurrently
Previously RS handled all the requests in an event loop, leading to
issues with connections being started in the middle of other connections
being started (and potentially blowing up the stack), ultimately causing
requests to be delayed because of other requests.
This commit reworks the way we handle these (specifically starting
connections) by first serialising the requests, and then performing them
in multiple threads concurrently; which yields a significant loading
performance and reliability increase.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur 4ef24e1c7c LibThreading: Add a ThreadPool 2024-05-20 08:03:35 +02:00
Ali Mohammad Pur d277fd4679 LibThreading: Expose the ProtectedType alias 2024-05-20 08:03:35 +02:00