Commit graph

61030 commits

Author SHA1 Message Date
Nico Weber
3435770c23 Meta: Use -std=c++2b on mac hosts in the GN build
Xcode clang doesn't understand the -std=c++23 spelling yet, and this
is what CMake's `set(CMAKE_CXX_STANDARD 23)` translates to too.

Unbreaks building with Xcode clang on macOS.
2024-05-07 11:41:40 -04:00
Nico Weber
2f81a3610d Meta: Port recent changes to the GN build
3a73eb99ac
2024-05-07 11:41:40 -04:00
Jamie Mansfield
8c4dc9476b LibWeb: Precision when using background-size: contain
This ensures that precision is maintained when calculating the image
size when using `background-size: contain`.
2024-05-07 11:15:04 -04:00
Jamie Mansfield
e48cb80a66 LibWeb: Precision when using background-size: cover
This ensures that precision is maintained when calculating the image
size when using `background-size: cover`.
2024-05-07 11:15:04 -04:00
Nico Weber
dad4843ee4 TestImageWriter: Add a JPEG roundtrip test 2024-05-07 11:14:41 -04:00
Nico Weber
9384f118d2 TestImageWriter: Add a QOI roundtrip test 2024-05-07 11:14:41 -04:00
Nico Weber
83bdc9c831 TestImageWriter: Add a BMP roundtrip test 2024-05-07 11:14:41 -04:00
Nico Weber
0a26831a10 TestImageWriter: Add a PNG roundtrip test 2024-05-07 11:14:41 -04:00
Nico Weber
aefab64984 TestImageWriter: Use double parens instead of temporary err
Explicit template arguments must be wrapped in parens,
else they confuse the preprocessor.

Add the parens instead of avoiding the use of explicit template
arguments.

No behavior change.
2024-05-07 11:14:41 -04:00
Nico Weber
51fc51d0b5 LibGfx/WebPWriter: Use one-element huffman tree for opaque images
That way, we can write 0 instead of 8 bits for every alpha byte.
Reduces the size of sunset-retro.png when saved as a webp file
from 3 MiB to 2.25 MiB, without affecting encode speed.

Once we use CanonicalCodes we'll get this for free for all channels,
but opaque images are common enough that it feels worth it to do this
before then.
2024-05-07 11:13:01 -04:00
Nico Weber
7d93f7fc99 LibGfx/WebPWriter: Correctly fill in alpha_is_used hint 2024-05-07 11:13:01 -04:00
Nico Weber
0e2e7cd1be LibGfx/WebPWriter: Rename alpha_hint to alpha_is_used_hint
No behavior change.
2024-05-07 11:13:01 -04:00
Nico Weber
5b335d51e1 LibGfx/WebPWriter: Implement ICC color profile data writing
Most of this code (VP8X chunk writing) will be used for writing
animated webp files too.
2024-05-07 11:11:41 -04:00
Nico Weber
c174adc6b1 LibGfx/WebPLossless: Remove a useless non-spec comment
There's already a spec comment saying the same thing a few lines
further down, just move that up.

No behavior change.
2024-05-07 11:10:06 -04:00
Nico Weber
7b3cc2e055 LibGfx/WebPLossless: Add spec ref about color indexing modifying width
No behavior change. This got clarified here:
https://chromium-review.googlesource.com/c/webm/libwebp/+/4688320
2024-05-07 11:10:06 -04:00
Nico Weber
26b3e31f2e LibGfx/WebPLossless: Make width_bits reading look more like in the spec
No behavior change.
2024-05-07 11:10:06 -04:00
Nico Weber
c1b289c144 LibGfx/WebPLossless: Add spec note about combining predicted values
No behavior change. This got clarified in the spec in
https://chromium-review.googlesource.com/c/webm/libwebp/+/4638649
2024-05-07 11:10:06 -04:00
Nico Weber
3662eea0ac LibGfx/WebPLossless: Update spec comments for reading max_symbol
This used to be misleading in the spec, but that was fixed in
https://chromium-review.googlesource.com/c/webm/libwebp/+/4674031

Update the comments to match.

Also, a check we already had got added to the spec in
https://chromium-review.googlesource.com/c/webm/libwebp/+/4674032
so add a citation for that.

No behavior change.
2024-05-07 11:10:06 -04:00
Nico Weber
a511f5507c LibGfx/WebPLossless: Add spec comment about transform order
This used to not be mentioned in the spec, but it got added
based on our feedback:
https://chromium-review.googlesource.com/c/webm/libwebp/+/4637757
2024-05-07 11:10:06 -04:00
Nico Weber
e69a0fa7d3 LibGfx/WebPLossless: Add a spec comment
No behavior change. Makes things flow better with the comment I'm
about to add in the next commit.
2024-05-07 11:10:06 -04:00
Nico Weber
5897e9bd29 LibGfx/WebPLossless: Move around a spec comment
That way, we don't need a comment that wasn't from the spec.
No behavior change.
2024-05-07 11:10:06 -04:00
Nico Weber
076a8e5d0b LibGfx/WebPLossless: Remove "AMENDED" in spec comments
No behavior change. This corresponds to this spec change:
https://chromium-review.googlesource.com/c/webm/libwebp/+/4567695
2024-05-07 11:10:06 -04:00
Nico Weber
05bb657b8b LibGfx/WebPLossless: Replace num_code_lengths check with VERIFY
No behavior change. This corresponds to this spec change:
https://chromium-review.googlesource.com/c/webm/libwebp/+/4779444
2024-05-07 11:10:06 -04:00
Lucas CHOLLET
ed1bdf3851 Tests/LibGfx: Add a test for bilevel images with only required tags
Bilevel images are not required to have a BitsPerSample or a
SamplesPerPixel tag, while this is unusual these images are still valid.

The test case has been generated by first making a copy of
ccitt3_1d_fill.tiff and then, using `tiffset` to remove both tags:
tiffset -u 258 ccitt3_no_tags.tiff
tiffset -u 277 ccitt3_no_tags.tiff
2024-05-07 11:06:12 -04:00
matjojo
cd1eeb3cdd LibWeb: Do not consume scroll event in PaintableBox without overflow
Specifically, without scrollable overflow.

Fixes #24009, both on brave.com and on the reduction.
2024-05-07 14:04:02 +00:00
Andreas Kling
a020a0779d LibJS/Bytecode: Do a stack check when entering run_bytecode()
If we don't have enough stack space, throw an exception while we still
can, and give the caller a chance to recover.

This particular problem will go away once we make calls non-recursive.
2024-05-07 09:15:40 +02:00
Andreas Kling
ebe6ec6069 AK: Check for u32 overflow in String::repeated()
I don't know why this was checking for size_t overflow, but it was
tripping up ASAN malloc() checks by passing a way-too-large size.
2024-05-07 09:15:40 +02:00
Andreas Kling
7b93b8cea7 LibJS/Bytecode: Flatten the interpreter main loop (Clang only)
This means inlining all the things. This yields a 40% speedup on the for
loop microbenchmark, and everything else gets faster as well. :^)

This makes compilation take foreeeever with GCC, so I'm only enabling it
for Clang in this commit. We should figure out how to make GCC compile
this without timing out CI, since the speedup is amazing.
2024-05-07 09:15:40 +02:00
Andreas Kling
f4af056aa9 LibJS/Bytecode: Thread the bytecode interpreter
This commit converts the main loop in Bytecode::Interpreter to use a
label table and computed goto for fast instruction dispatch.

This yields roughly 35% speedup on the for loop microbenchmark,
and makes everything else faster as well. :^)
2024-05-07 09:15:40 +02:00
Andreas Kling
b45f55b199 LibJS/Bytecode: Fix wonky serialization of instruction value lists 2024-05-07 09:15:40 +02:00
Andreas Kling
9cbf17f181 LibJS/Bytecode: Emit do...while body before test in codegen
This makes the code flow naturally and allows jump elision to work.
2024-05-07 09:15:40 +02:00
Andreas Kling
68507b7e55 LibJS/Bytecode: Store SetLocal's local index as a u32
Same size as local indexes everywhere else.
2024-05-07 09:15:40 +02:00
Andreas Kling
e43d96f310 LibJS/Bytecode: Remove Instruction::m_length field
Now that the interpreter is unrolled, we can advance the program counter
manually based on the current instruction type.

This makes most instructions a bit smaller. :^)
2024-05-07 09:15:40 +02:00
Andreas Kling
ce93000757 LibJS/Bytecode: Unroll the bytecode interpreter
This commit adds a HANDLE_INSTRUCTION macro that expands to everything
needed to handle a single instruction (invoking the handler function,
checking for exceptions, and advancing the program counter).

This gives a ~15% speed-up on a for loop microbenchmark, and makes
basically everything faster.
2024-05-07 09:15:40 +02:00
Andreas Kling
fae1527a18 LibJS/Bytecode: Turn JumpIf condition,@a,@next into JumpTrue/JumpFalse
If one of the jump targets is the very next block, we can convert the
jump instruction into a smaller JumpTrue or JumpFalse.
2024-05-07 09:15:40 +02:00
Andreas Kling
37d722f4a6 LibJS/Bytecode: Make IdentifierTableIndex a 32-bit index
This makes a bunch of instructions smaller.
2024-05-07 09:15:40 +02:00
Andreas Kling
95759dcc6d LibJS/Bytecode: Put end block last in for statement codegen 2024-05-07 09:15:40 +02:00
Andreas Kling
f3d57db774 LibJS/Bytecode: Stop emitting unnecessary jump at end of for statement 2024-05-07 09:15:40 +02:00
Andreas Kling
69cc64e94c LibJS/Bytecode: Emit for condition check before update statement
This allows jump elision to eliminate an unnecessary jump since things
now get laid out naturally in memory (normal execution order).
2024-05-07 09:15:40 +02:00
Andreas Kling
24d8b056c7 LibJS/Bytecode: Elide jumps that land in the very next block
Jumping to the next block is effectively a no-op, so let's save time and
space by just not emitting those jumps.
2024-05-07 09:15:40 +02:00
Andreas Kling
3a73eb99ac LibJS/Bytecode: Store labels as basic block index during compilation
Instead of storing a BasicBlock* and forcing the size of Label to be
sizeof(BasicBlock*), we now store the basic block index as a u32.

This means the final version of the bytecode is able to keep labels
at sizeof(u32), shrinking the size of many instructions. :^)
2024-05-07 09:15:40 +02:00
Andreas Kling
5a08544138 LibJS/Bytecode: Keep instruction source mappings in Executable
Instead of storing source offsets with each instruction, we now keep
them in a side table in Executable.

This shrinks each instruction by 8 bytes, further improving locality.
2024-05-07 09:15:40 +02:00
Andreas Kling
4cf4ea92a7 LibJS/Bytecode: Store Instruction length as u32
This makes every instruction 8 bytes smaller.
2024-05-07 09:15:40 +02:00
Andreas Kling
f6aee2b9e8 LibJS/Bytecode: Flatten bytecode to a contiguous representation
Instead of keeping bytecode as a set of disjoint basic blocks on the
malloc heap, bytecode is now a contiguous sequence of bytes(!)

The transformation happens at the end of Bytecode::Generator::generate()
and the only really hairy part is rerouting jump labels.

This required solving a few problems:

- The interpreter execution loop had to change quite a bit, since we
  were storing BasicBlock pointers all over the place, and control
  transfer was done by redirecting the interpreter's current block.

- Exception handlers & finalizers are now stored per-bytecode-range
  in a side table in Executable.

- The interpreter now has a plain program counter instead of a stream
  iterator. This actually makes error stack generation a bit nicer
  since we just have to deal with a number instead of reaching into
  the iterator.

This yields a 25% performance improvement on this microbenchmark:

    for (let i = 0; i < 1_000_000; ++i) { }

But basically everything gets faster. :^)
2024-05-07 09:15:40 +02:00
Andreas Kling
c2d3d9d1d4 LibJS/Bytecode: Make each Jump instruction inherit Instruction directly
Before this change, all JumpFoo instructions inherited from Jump, which
forced the unconditional Jump to have an unusued "false target" member.
Also, labels were unnecessarily wrapped in Optional<>.

By defining each jump instruction separately, they all shrink in size,
and all ambiguity is removed.
2024-05-07 09:15:40 +02:00
Timothy Flynn
464d7d5858 LibGfx+LibWeb: Allow inexact size lookups when requesting scaled fonts
For bitmap fonts, we will often not have an exact match for requested
sizes. Return the closest match instead of a nullptr.

LibWeb is currently the only user of this API. If it needs to be
configurable in the future to only allow exact matches, we can add a
parameter or another method at that time.
2024-05-06 23:26:42 +00:00
dgaston
8f784243a1 Chess: Improve PGN importing
This commit replaces the `import_pgn` implementation
with a more resiliant parser to handle various edge
cases and give helpful error messages instead of crashing.
2024-05-06 19:25:07 +01:00
Andrew Kaster
77e890b15e Meta+Documentation+Ports: Move from C++20 to C++23
Now that oss-fuzz is on a clang commit > the 17.x release candidates,
we can start looking at some shiny new features to enable.
2024-05-06 11:46:28 -06:00
MacDue
5bb37caf9e Ladybird: Add the "Debug" category back to the menubar
This was accidentally removed in 5da9af4.
2024-05-06 13:42:43 -04:00
Lucas CHOLLET
3c138b9580 LibGfx/TIFF: Support bilevel images missing baseline tags
Bilevel images are not required to have a BitsPerSample or a
SamplesPerPixel tag.
2024-05-06 17:33:25 +02:00