Commit graph

68626 commits

Author SHA1 Message Date
Shannon Booth
e7ad9a9bad LibURL/Pattern: URL parse correct value in opaque path canonicalization 2025-04-06 08:24:54 -04:00
Shannon Booth
e54504ad93 LibURL/Pattern: Implement 'compute protocol matches a special scheme' 2025-04-06 08:24:54 -04:00
Shannon Booth
6b1fa3ecd0 LibURL/Pattern: Implement matching a URLPattern 2025-04-06 08:24:54 -04:00
Shannon Booth
2a44420e52 LibURL/Pattern: Implement generating a component match result 2025-04-06 08:24:54 -04:00
Shannon Booth
e35555f00e LibURL/Pattern: Complete the implementation of the constructor 2025-04-06 08:24:54 -04:00
Shannon Booth
c9e6ad562c LibURL/Pattern: Implement ability to compile a component
This provides the infrastructure for taking a part list from the
pattern parser and generating the actual regexp object which is
used for matching against URLs from the pattern.
2025-04-06 08:24:54 -04:00
Shannon Booth
934f1ec30d LibURL/Pattern: Implement the URLPattern Pattern Parser 2025-04-06 08:24:54 -04:00
Shannon Booth
45d852d14b LibURL: Add helper for getting array of the special schemes
This is useful for iterating over all of the special schemes, as
needed in the URLPattern implementation.
2025-04-06 08:24:54 -04:00
Shannon Booth
e3ef6d3aee LibURL/Pattern: Implement ability to generate a pattern string
Compiling a URLPattern component will generate a 'parts list' which
is used for generating the regular expression that is used for
matching against URLs.

This parts list is also used to generate (through this function) a
pattern string. The pattern string of a URL component is what is
exposed on the USVString getters of the URLPattern class itself.

As an example, the following:

```
let pattern = new URLPattern({ "pathname": "/foo/(.*)*" });
console.log(pattern.pathname);
```

Will log the pattern string of: '/foo/**'.
2025-04-06 08:24:54 -04:00
Shannon Booth
f3679184cb LibURL/Pattern: Add representation of a URL Pattern 'options' struct
These control how a pattern string is generated, which can vary for
different components and is also impacted by the 'ignoreCase' option
that can be provided in the URLPattern constructor.
2025-04-06 08:24:54 -04:00
Shannon Booth
88bea4a717 LibURL/Pattern: Add a URL Pattern 'Part' representation 2025-04-06 08:24:54 -04:00
Shannon Booth
8a33c57c1e LibWeb/LibURL: Use an IgnoreCase enum for URLPatternOptions
This is to save a future name conflict that will appear between
the options IDL dictionary and the options struct that are both
present in the spec.

It is also a nicer interface for now given there is only a single
option at the moment.
2025-04-06 08:24:54 -04:00
Shannon Booth
f80e7d6816 LibURL/Pattern: Implement processing a URL Pattern Init
This gets us to the point just before the point of parsing the
pattern strings for each URL component to produce a regular
expression.
2025-04-06 08:24:54 -04:00
Shannon Booth
3f73cd30a2 LibURL: Rename 'cannot have a base URL' to 'has an opaque path'
This follows a rename made in the URL specification.
2025-04-06 08:24:54 -04:00
Shannon Booth
6b85748f53 LibURL/Pattern: Implement helper for escaping a URL Pattern String 2025-04-06 08:24:54 -04:00
Andreas Kling
c7bba505ea LibJS: Only use bitfields in Bytecode::Operand on aarch64
It seems both aarch64 and x86_64 are extremely sensitive to the use of
bitfields here. Unfortunately, aarch64 gains a huge speedup from them
while x86_64 sees a very noticeable slowdown.

Since we're talking about 5%+ swings in both directions here, let's go
for the best of both worlds and use ifdefs in the Operand memory layout.
2025-04-06 14:14:34 +02:00
Timothy Flynn
2810071a9c LibWebView: Support custom search engines
This allows the user to store custom search engines via about:settings.
Custom engines will be displayed below the builtin engines in the drop-
down to select the default engine.

A couple of edge cases here:

1. We currently reject a custom engine if one with the same name already
   exists. In the future, we should allow editing custom engines.

2. If a custom engine which was the default engine is removed, we will
   disable search rather than falling back to any other engine.
2025-04-06 13:45:10 +02:00
Timothy Flynn
dbf4b189a4 LibWebView: Do not use AK::format to format search engine URLs
This is to prepare for custom search engines. If we use AK::format, it
would be trivial for a user (or bad actor) to come up with a template
search engine URL that ultimately crashes the browser due to internal
assertions in AK::format. For example:

    https://example.com/crash={1}

Rather than coming up with a complicated pre-format validator, let's
just not use AK::format. Custom URLs will signify their template query
parameters with "%s". So we can do the same with our built-in engines.
When it comes time to format the URL, we will do a simple string
replacement.
2025-04-06 13:45:10 +02:00
Timothy Flynn
cbee476dac LibWebView: Store search engine names/URLs as String
In order to support custom search engines, we will need to store the
engine properties as String to hold user-provided data.

This also caused a compile error trying to assign Optional<SearchEngine>
to Optional<SearchEngine const&>, so there's a bit of extra churn here.
2025-04-06 13:45:10 +02:00
Timothy Flynn
7f37a8f60f AK: Add an AK::find helper to return a reference to the found value
This is often more convenient than dealing with iterators.

This commit includes a couple conversions to find_value as examples.
2025-04-06 13:45:10 +02:00
Timothy Flynn
9cab5dc0c9 Base: Consolidate a couple of about:settings container classes 2025-04-06 13:45:10 +02:00
Andreas Kling
d138474e0d LibJS: Avoid unnecessary shifts in Value empty/null/undefined checks
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
We know that the payload is always 0 for these three Value types, and so
we can implement checking for them as full 64-bit compares against
constant values instead of checking just the tag.

This avoids shifting the tag 48 bits to the right before comparing it.
Since these are used all over the place, it actually leads to a nice
code size reduction.
2025-04-06 04:47:01 +02:00
Andreas Kling
c8865458da LibJS: Mark exception-handling paths with [[unlikely]] in interpreter
This appears actually helpful and consistently makes all benchmarks
slightly faster on my machine.
2025-04-06 04:47:01 +02:00
Andreas Kling
aec7dd5778 LibJS: Mark Interpreter::handle_exception() as NEVER_INLINE
Before this change, we were inlining this function after every
handler for instructions that could throw.

Forcing it out-of-line shrinks the main bytecode interpreter by 15%
and yields a decent 2.5% speedup on JetStream/gcc-loops.cpp.js
2025-04-06 04:47:01 +02:00
Aliaksandr Kalenik
d5edd62e57 LibWeb: Limit usage of getElementById() cache to connected roots
Fixes bug when we always return null from getElementById() on
unconnected roots because id to element cache is only maintained for
connected roots.

Fixes broken Perf-Dashboard suite in Speedometer 3.
2025-04-06 04:14:29 +02:00
Andreas Kling
3c2a2bb39f LibJS: Shrink JS::Bytecode::Operand from 8 bytes to 4 bytes
This packs the bytecode much better and gives us a decent performance
boost on throughput-focused benchmarks.

Measured on my M3 MacBook Pro:
- 4.7% speedup on Kraken
- 2.3% speedup on Octane
- 2.7% speedup on JetStream1
2025-04-06 02:05:27 +02:00
Andreas Kling
70411a117b LibJS: Use u32 instead of size_t for bytecode instruction array sizes
Instructions that have an embedded tail array are not going to have
more than 2^32 elements in any remotely sane situation.
2025-04-06 02:05:27 +02:00
Andreas Kling
42cc481091 LibJS: Make Optional<StringTableIndex> use less space
We can use the index's invalid state to signal an empty optional.
This makes Optional<StringTableIndex> 4 bytes instead of 8,
shrinking every bytecode instruction that uses these.
2025-04-06 02:05:27 +02:00
Andreas Kling
f1a54ef281 LibJS: Use u32 for RegexTableIndex
Same as we already do for StringTableIndex and IdentifierTableIndex.
2025-04-06 02:05:27 +02:00
rmg-x
37998895d8 AK+Meta+LibCore+Tests: Remove unused SipHash implementation
This is a homegrown implementation that wasn't actually used in
dependent classes. If this is needed in the future, using OpenSSL would
probably be a better option.
2025-04-06 01:47:50 +02:00
Timothy Flynn
f1f7f68f36 LibWebView: Highlight about: and data: URL schemes 2025-04-06 00:32:14 +02:00
Aliaksandr Kalenik
c3121c9d8a LibIPC+Meta: Keep message buffer alive until acknowledged by peer
This change ensures that instead of immediately deallocating the message
buffer after sending, we retain it in an acknowledgement wait queue
until an acknowledgement is received from the peer. This is necessary
to handle a behavior of the macOS kernel, which may prematurely
garbage-collect file descriptors contained within the message buffer
before the peer receives them.

The acknowledgement mechanism assumes messages are received in the same
order they were sent so, each acknowledgement message simply indicates
the count of successfully received messages, specifying how many entries
can safely be removed from the acknowledgement wait queue.
2025-04-05 23:14:32 +02:00
Andreas Kling
15e2c78e9a LibJS: Shrink ThrowCompletionOr<void>
Some checks failed
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled
By specializing this template and using the special empty JS::Value as a
marker for the `void` state, we shrink this very common class from 16
bytes to 8 bytes.

This allows bytecode instruction handlers to return their result in a
single 64-bit register, allowing tighter code generation.
2025-04-05 21:34:13 +02:00
Andreas Kling
c5a239b8c4 LibJS: Add missing visit for CyclicModule::m_evaluation_error 2025-04-05 21:34:13 +02:00
Lukas Scheller
852e8ff12f LibWeb: Fix grid placement with named lines 2025-04-05 21:30:37 +02:00
devgianlu
6fc9de7aab LibJS: Remove invalid call to realm() on bytecode generator error
There is no realm when that call happens, use the same logic as the
lines above to create an error from the VM alone.
2025-04-05 20:55:21 +02:00
rmg-x
27c19c02d2 RequestServer: Remove check for square brackets in host before resolving
This is no longer needed since `IPv6Address::from_string` supports
square brackets. After the update to curl, `CURLOPT_RESOLVE` now
supports replacing IPv6 hosts as well.
2025-04-05 14:26:09 -04:00
rmg-x
6480e1a3fe AK+Tests: Add support for URI syntax in IPv6Address::from_string
This supports IPv6 strings that start with `[` and end with `]` in
accordance with RFC3986 which states:

A host identified by an Internet Protocol literal address, version 6
[RFC3513] or later, is distinguished by enclosing the IP literal
within square brackets ("[" and "]").  This is the only place where
square bracket characters are allowed in the URI syntax.
2025-04-05 14:26:09 -04:00
rmg-x
20e6de9340 Meta: Update curl to 8.13.0 2025-04-05 14:26:09 -04:00
devgianlu
08cfd5ff1b LibJS: Set empty function parameters on ClassStaticInit scope
This prevents the variables declared inside a class static initializer
to escape to the nearest containing function causing all sorts of memory
corruptions.
2025-04-05 18:20:36 +01:00
devgianlu
6aea459e00 LibJS: Wrap static_init_block_scope call in its own scope 2025-04-05 18:20:36 +01:00
Ali Mohammad Pur
396f35c41d Meta: Don't require LTO to build in release mode
check_ipo_supported() will by default fail the generation if IPO is not
available; this commit makes it so we continue the build just without
LTO.
2025-04-05 19:09:59 +02:00
Andreas Kling
fe1962d7fa LibJS: Make SetCompletionType bytecode instruction actually set type
This recovers 38 tests in test262 that regressed in a0bb31f7a0.
2025-04-05 15:00:05 +02:00
Tim Ledbetter
026bc91d6c LibWeb/CSS: Extract border width values directly
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
There's no need to keep a copy of a `BorderData` object in this case.
This makes the variable names used a bit less confusing.
2025-04-05 12:54:22 +02:00
Tim Ledbetter
32812f5db0 LibWeb: Return absolutized computed value for outline width property 2025-04-05 12:54:22 +02:00
Andreas Kling
b05b9378ed LibJS: Demote VERIFYs in Completion() to ASSERT
These were *extremely* hot in profiles (noticed when looking at
disassembly).

Now that we've made the special empty JS::Value much harder to create
accidentally, we can feel better about turning these into ASSERT and
catching them in debug builds.
2025-04-05 11:20:26 +02:00
Andreas Kling
3cf50539ec LibJS: Make Value() default-construct the undefined value
The special empty value (that we use for array holes, Optional<Value>
when empty and a few other other placeholder/sentinel tasks) still
exists, but you now create one via JS::js_special_empty_value() and
check for it with Value::is_special_empty_value().

The main idea here is to make it very unlikely to accidentally create an
unexpected special empty value.
2025-04-05 11:20:26 +02:00
Andreas Kling
0d91363742 LibJS: Remove weird fallback behavior in VM::argument/argument_count
If there's no running execution context, let's just error out in there
instead of returning a weird empty value.
2025-04-05 11:20:26 +02:00
Andreas Kling
ceddc8d660 LibJS: Make a bunch of functions in Environment pure virtual 2025-04-05 11:20:26 +02:00
Andreas Kling
de424d6879 LibJS: Make Completion.[[Value]] non-optional
Instead, just use js_undefined() whenever the [[Value]] field is unused.
This avoids a whole bunch of presence checks.
2025-04-05 11:20:26 +02:00