Commit graph

28640 commits

Author SHA1 Message Date
kleines Filmröllchen 614ff9c46e Maps: Load tiles starting from center
The information the user is most interested in is usually in the center,
so we should start loading tiles from the center and move outwards.
Since tiles are loaded in draw order, simply drawing them in this order
achieves the desired effect. The current center-outwards loading
algorithm is a basic spiral algorithm, but others may be evaluated
later.
2023-09-30 11:11:05 +02:00
Andreas Kling a54e283901 LibJS: Fix two bugs in the GC fast rejection of possible pointers
- Convert to FlatPtr instead of doing pointer arithmetic on a too-large
  pointer type in find_min_and_max_block_addresses(). This makes the
  range more accurate.

- Untag possible cell pointers in add_possible_value() before doing the
  rejection. Otherwise we end up rejecting most pointers since the tags
  sit in the highest bits!

This fixes a crash when running the Speedometer benchmark.
2023-09-30 09:50:55 +02:00
Andreas Kling f388d2362a LibJS: Pad the capacity of BasicBlock while growing it
Just using Vector::resize() meant that we allocated exact capacity
instead of leaving padding at the end. This patch adds a call to
grow_capacity() before resize(), which ensures that we grow with the
usual extra padding.
2023-09-30 09:33:11 +02:00
Aliaksandr Kalenik e79d4f3462 LibJS: Early reject pointers outside of allocated blocks range in GC
This change adds a check to discard pointers that are lower than the
minimum address of all allocated blocks or higher than the maximum
address of all blocks. By doing this we avoid executing plenty of set()
operations on the HashMap in the add_possible_value().

With this change gather_conservative_roots() run 10x times faster in
Speedometer React-Redux-TodoMVC test.
2023-09-30 08:07:12 +02:00
Sam Atkins a3a5af3fd1 LibWeb: Implement length and item() for ResolvedCSSStyleDeclaration 2023-09-29 20:20:55 +02:00
Sam Atkins 08cf35cf9a LibWeb: Allow indexing into CSSStyleDeclaration by number
The `item(unsigned long index)` method is marked as a getter in IDL, so
let's treat it as such.
2023-09-29 20:20:55 +02:00
Sam Atkins 33e4a35d2d LibWeb: Resolve style for box-shadow and text-shadow 2023-09-29 15:12:09 +01:00
Sam Atkins 44836cd8ed LibWeb: Resolve style for logical-side length properties
For now, we just hard-code the logical sides to physical ones, but at
least the hard-coding is all in one place. :^)
2023-09-29 15:12:09 +01:00
Sam Atkins 2fa1df2ec4 LibWeb: Implement resolved style for line-height 2023-09-29 15:12:09 +01:00
Sam Atkins 30e31d83b6 LibWeb: Construct resolved shorthands from resolved longhands
Recursively call `style_value_for_property()` for the longhands, instead
of duplicating the logic to construct them.
2023-09-29 15:12:09 +01:00
Sam Atkins 737cccec70 LibWeb: Remove manual construction of resolved sided-border values
The automatic shorthand code will handle these just fine.
2023-09-29 15:12:09 +01:00
Sam Atkins 77fb85d27a LibWeb: Add spec comments to style_value_for_property()
Also, re-order things to match. No behaviour changes.

This reveals quite a few properties that are missing here, or which we
implement somewhat incorrectly.
2023-09-29 15:12:09 +01:00
Karol Kosek 9ce2682ce6 Userland: Port lists of mime types to String 2023-09-29 14:40:21 +01:00
Karol Kosek e75d694974 Userland: Compare event MIME type list with a StringView
The following commit will port MIME types to String. Traits<String>
- used in Vector::contains_slow - can't compare String type with char*,
so we need to use StringView instead.
2023-09-29 14:40:21 +01:00
Karol Kosek 2f35348104 Userland: Store MIME keys as String in Core::MimeData 2023-09-29 14:40:21 +01:00
Karol Kosek 4f638d3af2 Userland: Take StringView in MimeData::data() and has_{format,text,urls} 2023-09-29 14:40:21 +01:00
Sam Atkins dcf3bdcb9a LibWeb: Use correct realm when focusing HTMLTextAreaElement
This matches HTMLInputElement, and fixes the crash when focusing a
textarea.
2023-09-29 07:21:43 -04:00
Sam Atkins ca16a1ed08 LibWeb: Store GridSize values as a Variant
A GridSize can't hold both a LengthPercentage and a Flex at the same
time, so let's limit that.
2023-09-28 20:33:20 +01:00
Sam Atkins b66ff21379 LibWeb: Add missing check for flexible grid tracks
Previously this didn't cause issues because the default flex-factor is
0, but once we only store a flex-factor for FlexibleLength-type
GridSizes, this causes a crash.
2023-09-28 20:33:20 +01:00
Sam Atkins 127bfd64a8 LibWeb: Use Flex type in GridSize 2023-09-28 20:33:20 +01:00
Sam Atkins dfd3d9a72d LibWeb: Support flex in typed attr() 2023-09-28 20:33:20 +01:00
Sam Atkins b0317bb3a1 LibWeb: Implement Flex and FlexStyleValue types 2023-09-28 20:33:20 +01:00
Sam Atkins f1d7ea67c0 LibWeb: Add missing check for frequency values 2023-09-28 20:33:20 +01:00
Aliaksandr Kalenik 66b7da4fc7 LibJS: Remove unused make_super_property_reference()
This function is no longer used anywhere after we removed AST
interpreter.
2023-09-28 20:34:47 +02:00
Nico Weber 563bb9d20c ICC: Implement Profile::to_pcs() for grayscale colors
There's probably a nicer way of doing this where we don't need to expand
the gray value into a full Vector3, but for now this is good enough.

Makes PDFs written by macOS 13.5.2's "Save as PDF..." feature show up.
2023-09-28 16:57:31 +01:00
Nico Weber 6b4da8680d ICC: Move a lambda up a bit
No behavior change.
2023-09-28 16:57:31 +01:00
Aliaksandr Kalenik 42e9dfedc2 LibJS: Pre-calculate the number of bindings for function environments
We can use `ensure_capacity` for binding vectors if we know their sizes
in advance. This ensures that binding vectors aren't reallocated during
the `function_declaration_instantiation` execution.

With this change, `try_grow_capacity()` and `shrink_to_fit()` are no
longer visible in the `function_declaration_instantiation()` profiles
when running React-Redux-TodoMVC from Speedometer.
2023-09-28 15:33:43 +02:00
Aliaksandr Kalenik 98f479318a LibJS: Do not create environment bindings for local variables
If variable is local it is not stored in an environment so we don't
need a binding.
2023-09-28 15:33:43 +02:00
Aliaksandr Kalenik 4561469d52 LibJS: Fix BindingPattern::contains_expression() is name is expression
If any of binding pattern entry's name is expession
`contains_expression()` should return true.

For example:
```js
function evalInComputedPropertyKey(
  {[eval("var x = 'inner'")]: ignored}
) {}
```

`contains_expression()` should return true for the binding param in
this function.
2023-09-28 15:33:43 +02:00
Andreas Kling aeb8b5685f LibJS: Make Bytecode::Generator::emit() return void
There are no callers left that use the return value.
2023-09-28 14:52:03 +02:00
Andreas Kling 887183cad6 LibJS: Remove last user of Op::Jump::set_targets() and API itself
This was just a matter of instantiating a BasicBlock earlier so we
can reference it when making the jump.
2023-09-28 14:52:03 +02:00
Andreas Kling bdd21cf9db LibJS: Remove almost all uses of Op::Jump::set_targets()
We should initialize jump targets when constructing the jump instruction
instead of doing it later. This was already the case in all construction
sites but one. This first patch converts all those sites to pass final
targets to the constructor directly.
2023-09-28 14:52:03 +02:00
Andreas Kling 84850700a0 LibJS: Make BC::Generator::emit_with_extra_register_slots() return void
Nobody was using the return value.
2023-09-28 14:52:03 +02:00
Sam Atkins 9e99368694 LibWeb: Track quote-nesting level while building the layout tree
This makes multiple levels of quote actually use different quotation
marks, instead of always the first available pair of them.

Each Layout::Node remembers what the quote-nesting level was before its
content was evaluated, so that we can re-use this number in
`apply_style()`. This is a bit hacky, since we end up converting the
`content` value into a string twice.

`StyleProperties::content()` now takes an initial quote-nesting level,
and returns the final level after that content.
2023-09-28 14:49:10 +02:00
Sam Atkins 493dd5d93c LibWeb: Create ::before pseudo-element before element children
This allows any effects of `content` (eg quotes and counters) to happen
in the right order.

To make it work there are a couple of other changes needed:
- Skip nodes generated by ::before when constructing button layout.
- When in a flex parent, don't merge an inline text node into a previous
  one that is generated from a pseudo-element.
2023-09-28 14:49:10 +02:00
Sam Atkins d431aeed04 LibWeb: Repeat last available quote-type, instead of looping them all
I misunderstood this part of the spec before.
2023-09-28 14:49:10 +02:00
Shannon Booth 2d8b2328fd LibJS: Syntax error for a unary expression followed by exponentiation
This change makes LibJS correctly report a syntax error when a unary
expression is followed by exponentiation, as the spec requires.
Apparently this is due to that expression being ambiguous ordering.

Strangely this check does not seem to apply in the same way for '++' and
'--' for reasons that I don't fully understand. For example

```
let x = 5;
++x ** 2
```

Since `--5` and `++5` on it's own results in a syntax error anyway, it
seems we do not need to perform this exponentiation check in those
places.

Diff Tests:
    +6     -6 
2023-09-28 13:11:11 +02:00
Bastiaan van der Plaat 5e7a82a853 LibWeb: Create canvas bitmap when not existing in toDataURL and toBlob 2023-09-28 13:09:25 +02:00
Andreas Kling d24e07579f LibJS: Use a Vector<u8> for BasicBlock instruction storage
This reduces the minimum size of a basic block from 4 KiB to 0 bytes.
With this change, memory usage at the end of Speedometer is 1.2 GiB,
down from 1.8 GiB.
2023-09-28 11:25:19 +02:00
Aliaksandr Kalenik 32be413f4e LibWeb: Add missing visit_edges() for ImageStyleValue
ImageStyleValue has a visit_edges() method, although it is not a
GC-allocated object. This is necessary because it owns a GC-allocated
ImageRequest that we want to visit, instead of using JS::Handle, to
avoid leaks. In the future, we might want to make StyleValue be
GC-allocated.

For now, this change adds missing visit_edges() calls for objects that
own ImageStyleValue.
2023-09-28 06:11:17 +02:00
Aliaksandr Kalenik b43b3d2f8d LibWeb: Null check container while creating srcdoc navigation params
Fixes https://github.com/SerenityOS/serenity/issues/21205
Fixes https://github.com/SerenityOS/serenity/issues/21240
2023-09-28 06:09:52 +02:00
Andreas Kling feedbd6a01 LibJS: Put __builtin_unreachable() in unused bytecode opcode handlers
For the opcodes that are handled directly in the interpreter loop,
we want the compiler to know that there's nothing to inline here.
2023-09-28 06:09:16 +02:00
Andreas Kling f3606adc58 LibJS: Inline bytecode ops for direct local/register access
These can do a lot less stuff if we put them directly in the interpreter
loop and allow them to access the locals/registers arrays directly.
2023-09-28 06:09:16 +02:00
Andreas Kling ae1ac9871b LibJS: Move all bytecode instruction implementations to Interpreter.cpp
This allows aggressive inlining without LTO.
2023-09-28 06:09:16 +02:00
Andreas Kling e5474c384d LibJS: Inline flow control ops in the bytecode interpreter loop
Instead of calling out to helper functions for flow control (and then
checking control flags on every iteration), we now simply inline those
ops in the interpreter loop directly.
2023-09-28 06:09:16 +02:00
Andreas Kling 39cfb64269 LibJS: Return early from Interpreter on unhandled exception
If we don't have a local unwind context to handle the exception, we can
just return right away. This allows us to remove one check from the
inner loop.
2023-09-28 06:09:16 +02:00
Andreas Kling c9eff35b96 LibJS: Use goto instead of bool will_jump in interpreter loop
This is honestly less spaghetti-ish.
2023-09-28 06:09:16 +02:00
Andreas Kling 9fe38245b2 LibJS: Move bytecode interpreter's inner loop to its own function 2023-09-28 06:09:16 +02:00
Andreas Kling 951a85992b LibJS: Mark the exception path as [[unlikely]] in the interpreter loop 2023-09-28 06:09:16 +02:00
Andreas Kling 031ec98803 LibJS: Streamline InstructionStreamIterator
Nuke all the per-instruction bounds checking when iterating instructions
by using raw pointers instead of indexing into a ReadonlyBytes.

The interpreter loop already checks that we're in-bounds anyway.
2023-09-28 06:09:16 +02:00