Commit graph

24579 commits

Author SHA1 Message Date
Shannon Booth ec381c122e LibWeb: Implement "Resolve a Blob URL"
Which performs a lookup to find a blob (if any) corresponding to the
given blob URL.
2024-05-12 15:46:29 -06:00
Shannon Booth c071720430 LibWeb: Handle blob URLs in Document::parse_url
Implement this function to the spec, and use the full blown URL parser
that handles blob URLs, instead of the basic-url-parser.

Also clean up a FIXME that does not seem relevant any more.
2024-05-12 15:46:29 -06:00
Timothy Flynn 95c6fdf401 LibWebView: Escape HTML entities in the Task Manager process titles 2024-05-12 15:38:18 -06:00
Shannon Booth 5e7678d1c6 LibWeb: Implement AudioBuffer.copyFromChannel 2024-05-12 19:11:37 +02:00
Aliaksandr Kalenik 8bcaf68023 LibJS: Remove VM::execute_ast_node() 2024-05-12 19:10:25 +02:00
Aliaksandr Kalenik 6fb1d9e516 LibJS: Stop using execute_ast_node() for class property evaluation
Instead, generate bytecode to execute their AST nodes and save the
resulting operands inside the NewClass instruction.

Moving property expression evaluation to happen before NewClass
execution also moves along creation of new private environment and
its population with private members (private members should be visible
during property evaluation).

Before:
- NewClass

After:
- CreatePrivateEnvironment
- AddPrivateName
- ...
- AddPrivateName
- NewClass
- LeavePrivateEnvironment
2024-05-12 19:10:25 +02:00
Aliaksandr Kalenik b46fc47bf7 LibJS: Remove execute_ast_node() usage for ClassMethod function creation
Call ECMAScriptFunctionObject constructor directly instead of using
execute_ast_node() to emit NewFunction instruction.
2024-05-12 19:10:25 +02:00
Shannon Booth 2e1316507f LibWeb: Fix missing initialization of delta_z in WheelEvent 2024-05-12 14:24:18 +00:00
Shannon Booth 42e3ba409e LibWeb: Add constructor for WheelEvent
This makes https://profiler.firefox.com/ progress much further in
loading :^)
2024-05-12 14:24:18 +00:00
Shannon Booth 0c799b23cb LibWeb: Use WebIDL::UnsignedLong for deltaMode in WheelEvent
This matches the IDL definition. Without this we experience a compile
time error when adding the WheelEvent constructor due to a mimatched
type between the enum class and UnsignedLong that the prototype is
passing through to the event init struct for the constructor.
2024-05-12 14:24:18 +00:00
Shannon Booth e5206f5529 LibWeb: Only use lowercase attributes on toggle for HTML documents 2024-05-12 07:28:09 +01:00
Shannon Booth 89a536b57a LibWeb: Remove resolved FIXME about putting HTMLALlCollection in HTML NS
This was an unfortunate artifact from development. I originally added
this class in the DOM namespace alongside HTMLCollection until I
realized it was defined by the HTML spec instead. To remind myself to
move it over to the HTML namespace, I left this comment. It was moved
to the correct namespace before upstreaming to the main repo, but I
forgot to remove this comment!
2024-05-12 07:28:09 +01:00
Shannon Booth 97c1722ebd LibWeb: Remove resolved FIXME about implementing more methods in Range
We are not missing a whole bunch of IDL methods any more :^)
2024-05-12 07:28:09 +01:00
Shannon Booth dadc610e4a LibWeb: Pass a FlyString to getElementsByTagNameNS 2024-05-12 07:28:09 +01:00
Nico Weber f506818052 LibGfx/WebPWriter: Support animations with transparent pixels
Once we see a frame with transparent pixels, we now toggle the
"has alpha" bit in the header.

To not require a SeekableStream opened for reading, we now pass the
unmodified original flag bit to WebPAnimationWriter.
2024-05-11 15:43:02 -04:00
Nico Weber 3a4e0c2804 LibGfx+Utilities: Add animation utility, make it write animated webps
The high-level design is that we have a static method on WebPWriter that
returns an AnimationWriter object. AnimationWriter has a virtual method
for writing individual frames. This allows streaming animations to disk,
without having to buffer up the entire animation in memory first.
The semantics of this function, add_frame(), are that data is flushed
to disk every time the function is called, so that no explicit `close()`
method is needed.

For some formats that store animation length at the start of the file,
including WebP, this means that this needs to write to a SeekableStream,
so that add_frame() can seek to the start and update the size when a
frame is written.

This design should work for GIF and APNG writing as well. We can move
AnimationWriter to a new header if we add writers for these.

Currently, `animation` can read any animated image format we can read
(apng, gif, webp) and convert it to an animated webp file.

The written animated webp file is not compressed whatsoever, so this
creates large output files at the moment.
2024-05-11 15:43:02 -04:00
Nico Weber 27cc9e7386 LibGfx/WebPWriter: Write VP8X chunk header and bytes at once
For VP8L it arguably makes sense to separate the two, but for
fixed-size chunk like VP8X it doesn't.

No behavior change.
2024-05-11 15:43:02 -04:00
Aliaksandr Kalenik 0c8e76cbd7 LibJS: Delete named_evaluation_if_anonymous_function()
This code was a leftover from AST interpreter.
2024-05-11 18:16:15 +02:00
Andreas Kling 6ad6e09be1 LibJS: Make Environment::is_declarative_environment() non-virtual
This function was moderately hot (2%) on the clusters demo, and making
it non-virtual costs us nothing.
2024-05-11 15:22:36 +02:00
Andreas Kling b5a070e8ce LibJS/Bytecode: Don't create empty lexical environments
This patch stops emitting the BlockDeclarationInstantiation instruction
when there are no locals, and no function declarations in the scope.

We were spending 20% of CPU time on https://ventrella.com/Clusters/ just
creating empty environments for no reason.
2024-05-11 15:22:36 +02:00
theonlyasdk 9e976dfeac LibWebView: Add Wikipedia to builtin search engines list 2024-05-11 07:53:04 -04:00
Andreas Kling 239b9d8662 LibJS: Manually limit the recursion depth in Proxy
Instead of relying on native stack overflows to kick us out of circular
proxy chains, we now keep track of the recursion depth and kick
ourselves out if it exceeds 10'000.

This fixes an issue where compiler tail/sibling call optimizations would
turn infinite recursion into infinite loops, and thus never hit a stack
overflow to kick itself out.

For whatever reason, we've only seen the issue on SerenityOS with UBSAN,
but it could theoretically happen on any platform.
2024-05-11 13:00:46 +02:00
Lucas CHOLLET 7a55c4af0e LibGfx/GIF: Avoid copying LZW subblocks twice
I started to write that in order to remove the manual copy of the data
but that should produce some performance gains as well.
2024-05-11 12:53:57 +02:00
Lucas CHOLLET 7aa76e6c9f LibGfx/GIF: Shorten the lifetime of lzw_encoded_bytes_expected 2024-05-11 12:53:57 +02:00
Aliaksandr Kalenik 1e361db3f3 LibJS: Remove VM::binding_initialization()
This function was used for function params initialization but no longer
used after it got replaced by emitting bytecode.
2024-05-11 11:43:05 +02:00
Aliaksandr Kalenik 3d4b13a01c LibJS: Ensure capacity for created lexical and variable environments
If the minimal amount of required bindings is known in advance, it could
be used to ensure capacity to avoid resizing the internal vector that
holds bindings.
2024-05-11 11:43:05 +02:00
Aliaksandr Kalenik a4f70986a0 LibJS: Emit bytecode for function declaration instantiation
By doing that all instructions required for instantiation are emitted
once in compilation and then reused for subsequent calls, instead of
running generic instantiation process for each call.
2024-05-11 11:43:05 +02:00
Aliaksandr Kalenik 89a007327a LibJS: Change NewFunction instruction to accept FunctionNode
Preparation for upcoming changes where NewFunction will have to be used
with FunctionDeclaration node.
2024-05-11 11:43:05 +02:00
Aliaksandr Kalenik 00018ad415 LibJS: Move BindingPattern bytecode generation into a method
Preparation for upcoming function where binding pattern will have to be
used outside of ASTCodegen.cpp
2024-05-11 11:43:05 +02:00
dgaston 739cc4b8dc LibChess: Fix crash when importing PGN
Fix the incorrect parsing in `Chess::Move::from_algebraic`
of moves with a capture and promotion (e.g. gxf8=Q) due to
the promoted piece type not being passed through to the
`Board::is_legal` method. This addresses a FIXME regarding
this issue in `ChessWidget.cpp`.
2024-05-11 07:41:57 +01:00
Andrew Kaster 2bc51f08d9 LibWeb: Implement or stub FontFace interface's attribute getters/setters
We only support parsing half of these, so the ones we don't recognize
get a friendly exception thrown.
2024-05-11 07:30:29 +01:00
Andrew Kaster de98c122d1 LibWeb: Move CSS unicode-ranges parsing code into a common helper 2024-05-11 07:30:29 +01:00
Andreas Kling 7bdc207d81 LibJS/Bytecode: Make execute_impl() return void for non-throwing ops
This way we can't accidentally ignore exceptions.
2024-05-10 19:53:15 +02:00
Andreas Kling 01ec56f1ed LibJS/Bytecode: Fix register being freed too early in delete codegen
It wasn't actually possible for it to get reused incorrectly here, but
let's fix the bug anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling 353e635535 LibJS/Bytecode: Grab at ThrowCompletionOr errors directly
The interpreter can now grab at the error value directly instead of
instantiating a temporary Completion to hold it.
2024-05-10 15:03:24 +00:00
Andreas Kling f5efc47905 LibJS: Make ThrowCompletionOr<T> smaller
Instead of storing a full JS::Completion for the "throw completion"
case, we now store a simple JS::Value (wrapped in ErrorValue for the
type system).

This shrinks TCO<void> and TCO<Value> (the most common TCOs) by 8 bytes,
which has a non-trivial impact on performance.
2024-05-10 15:03:24 +00:00
Andreas Kling ae11a4de1c LibJS: Remove unused target field from Completion
This shrinks Completion by 16 bytes, which has non-trivial impact
on performance.
2024-05-10 15:03:24 +00:00
Andreas Kling a77c6e15f4 LibJS/Bytecode: Streamline return/yield flow a bit in the interpreter 2024-05-10 15:03:24 +00:00
Andreas Kling 3e1a6fca91 LibJS/Bytecode: Remove exception checks from Return/Await/Yield
These instructions can't throw anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling 8eccfdb98c LibJS/Bytecode: Cache a base pointer to executable constants
Instead of fetching it from the current executable whenever we fetch a
constant, just keep a base pointer to the constants array handy.
2024-05-10 15:03:24 +00:00
Andreas Kling 810a297626 LibJS/Bytecode: Remove Instruction::execute()
Just make sure everyone calls the instruction-specific execute_impl()
instead. :^)
2024-05-10 15:03:24 +00:00
Andreas Kling 601e10d50c LibJS/Bytecode: Make StringTableIndex be a 32-bit index
This makes a bunch of instructions smaller.
2024-05-10 15:03:24 +00:00
Andreas Kling b99f0a7e22 LibJS/Bytecode: Reorder Call instruction members to make it smaller 2024-05-10 15:03:24 +00:00
Andreas Kling 96511a7d19 LibJS/Bytecode: Avoid unnecessary copy of call expression callee
If the callee is already a temporary register, we don't need to copy it
to *another* temporary before evaluating arguments. None of the
arguments will clobber the existing temporary anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling 56a3ccde1a LibJS/Bytecode: Turn UnaryMinus(NumericLiteral) into a constant 2024-05-10 15:03:24 +00:00
Andreas Kling e37feaa196 LibJS/Bytecode: Skip unnecessary exception checks in interpreter
Many opcodes cannot ever throw an exception, so we can just avoid
checking it after executing them.
2024-05-10 15:03:24 +00:00
Andreas Kling 34f287087e LibJS/Bytecode: Only copy call/array expression arguments when needed
We only need to make copies of locals here, in case the locals are
modified by something like increment/decrement expressions.

Registers and constants can slip right through, without being Mov'ed
into a temporary first.
2024-05-10 15:03:24 +00:00
Andreas Kling caf2e675bf LibJS/Bytecode: Don't emit GetGlobal undefined
We know that `undefined` in the global scope is always the proper
undefined value. This commit takes advantage of that by simply emitting
a constant undefined value instead.

Unfortunately we can't be so sure in other scopes.
2024-05-10 15:03:24 +00:00
Andreas Kling 448f837d38 LibJS/Bytecode: Round constant operands of bitwise binary expressions
This helps some of the Cloudflare Turnstile stuff run faster, since they
are deliberately screwing with JS engines by asking us to do a bunch of
bitwise operations on e.g 65535.56

By rounding such values in bytecode generation, the interpreter can stay
on the happy path while executing, and finish quite a bit faster.
2024-05-10 15:03:24 +00:00
Andreas Kling ca8dc8f61f LibJS/Bytecode: Turn JumpIf true/false into unconditional Jump 2024-05-10 15:03:24 +00:00