Commit graph

61422 commits

Author SHA1 Message Date
Matthew Olsson a5f4c9a632 AK+Userland: Remove NOESCAPE
See the next commit for an explanation
2024-05-22 21:55:34 -06:00
Tim Ledbetter d2b3007248 IDLGenerators: Use spec-compliant algorithm to parse integer values 2024-05-23 04:15:46 +02:00
Liav A 5b17091a4b Ports/file: Build host version to ensure we can properly cross compile
We should build file natively as well so it can be used to compile the
target build (for serenity). The Makefile doesn't do this automatically
so to ensure it will not fail due to version mismatch between the host
version and target version, we ensure we always have a native binary at
hand.
2024-05-23 01:00:39 +02:00
Liav A. 3ba5daeca9 Kernel: Actually set physical base pointer correctly in prekernel stage
I did a mistake and set the kernel_physical_base value to be just on
the actual linked kernel ELF start offset, while this value should
represent together with KERNEL_MAPPING_BASE the actual higher-half load
address.

By changing this value, we resolve a bug in which disabling KASLR
doesn't work and will cause the prekernel to hang on this statement:
```c++
VERIFY(kernel_load_base >= kernel_mapping_base + 0x200000);
```
2024-05-22 23:25:51 +02: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 c83fc59534 Tests/LibGfx: Also test animated GIFs 2024-05-22 13:29:05 -04: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
Tim Ledbetter 1bc0fcca8d IDLGenerators: Support [Reflect] on long and unsigned long 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
Ali Mohammad Pur 960a4b636c RequestServer: Account for null sockets in recreate_socket_if_needed()
A connection's socket is allowed to be null if it's being recreated
after a failed connect(), this was handled correctly in
request_did_finish but not in recreate_socket_if_needed; this commit
fixes this oversight.
2024-05-21 11:25:08 +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
Tim Ledbetter 817bfef3aa Tests/AK: Add tests for integral log2 2024-05-21 09:31:17 +02:00
Tim Ledbetter d0d81e470e AK: Fix off by one error in integral ceil_log2()
Previously, certain values of `ceil_log2(x)` would be 1 smaller than
`ceil(log2(x))`.
2024-05-21 09:31:17 +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 ddc622233f RequestServer: Serialise accesses to IPC::Connection
Most of IPC::Connection is thread-safe, but the responsiveness timer is
very much not so, this commit makes sure only one thread can send stuff
through IPC to avoid having threads racing in IPC::Connection.
This is simply less work than making sure everything IPC::Connection
uses (now and later) is thread-safe.
2024-05-20 08:03:35 +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