Commit graph

29519 commits

Author SHA1 Message Date
Nico Weber d24289eef4 LibPDF: Always log unhandled type 1 and type 2 font program opcodes
This would've made it easy to see that we were missing flex opcodes for
https://developer.apple.com/library/archive/documentation/mac/pdf/Text.pdf
2023-11-01 11:40:16 -04:00
Nico Weber e1a743f286 LibPDF: Implement type 2 flex, hflex, hflex1, flex1 operators
This is the type 2 equivalent to type2 othersubr, from what I can tell.

See "4.1 Path Construction Operators" in 5177.Type2.pdf,
"The Type 2 Charstring Format".

Makes text show up alright on
https://developer.apple.com/library/archive/documentation/mac/pdf/Text.pdf
2023-11-01 11:40:16 -04:00
Nico Weber 3e707efdfa LibPDF: Move type1 subr 0 handling into othersubr handler
https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf,
8.4 First Four Subrs Entries:

"""If Flex or hint replacement is used in a Type 1 font program, the
first four entries in the Subrs array in the Private dictionary must be
assigned charstrings that correspond to the following code sequences. If
neither Flex nor hint replacement is used in the font program, then this
requirement is removed, and the first Subrs entry may be a normal
charstring subroutine sequence. The first four Subrs entries contain:

Subrs entry number 0:
3 0 callothersubr pop pop setcurrentpoint return
"""

othersubr handler 0 gets three arguments:
* The flex height (the distance after which the bezier splines
  are replaced with just straight lines)
* The current position after the flex

It pushes that position on the postscript stack, where predefined subr
handler number 0 then pops it from. It then passes it to
setcurrentpoint.

In theory, we now correctly do that setcurrentpoint call, which we
previously weren't.

In practice, that setcurrentpoint call always receives the last point of
the flex -- and our path api apparently gets confused when move_to() is
called on it when the current point is already at that same location.

So tweak the SetCurrentPoint handler to not set the current point on
the path if it's already the path's current point, with a FIXME to
figure out what exactly is happening in Gfx::Path.

No big behavior change if flex is used, but this is more correct if it
isn't.

(This only works because our `return` handler is empty, else we would
have to make the callothersubr handler start a call frame.)
2023-11-01 11:38:41 -04:00
Nico Weber 0bb8249780 LibPDF: Move type1 subr 1 and 2 handling into othersubr handler
https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf,
8.4 First Four Subrs Entries:

"""If Flex or hint replacement is used in a Type 1 font program, the
first four entries in the Subrs array in the Private dictionary must be
assigned charstrings that correspond to the following code sequences. If
neither Flex nor hint replacement is used in the font program, then this
requirement is removed, and the first Subrs entry may be a normal
charstring subroutine sequence. The first four Subrs entries contain:

[...]

Subrs entry number 1:
0 1 callothersubr return

Subrs entry number 2:
0 2 callothersubr return
"""

So subr entry numbers 1 and 2 just call othersubr 1 and and 2, which
means we can just move the handling code over.

No behavior change if flex is used, but more correct if it isn't.

(This only works because our `return` handler is empty, else we would
have to make the callothersubr handler start a call frame.)
2023-11-01 11:38:41 -04:00
david072 53d73b95ce HackStudio: Also ask about unsaved changes when running
HackStudio now also asks about unsaved changes when trying to run,
instead of only on build.
2023-11-01 12:05:57 +00:00
david072 02cc2e0f8f HackStudio: Don't crash when saving is denied on build
When running build while having unsaved changes in HackStudio, it asks
whether you want to save the unsaved files with a separate dialog. When
you click "Yes" to saving the files, but deny the save-file dialog,
HackStudio would crash, since we were expecting there to be a file
to save to. Now, we check whether a file was picked, and if not, we
abort the build.
2023-11-01 12:05:57 +00:00
0GreenClover0 88cc019275 FlappyBug: Unify the way of getting the final score
Previously we would display the score rounded to the nearest integer,
but save the high score by using a static_cast<u32>, which would
always round the score down. This could lead to the final score being
higher than the new high score, when they should be equal.
Now we always round the score to the nearest integer.
2023-11-01 10:43:55 +01:00
Aliaksandr Kalenik 4676b288a2 LibWeb: Set table width to GRIDMAX if calculated value is max-content
If the width of the table container is specified as max-content, then
it seems sensible to resolve it as the sum of the maximum widths of the
columns.
2023-10-31 18:13:14 +01:00
networkException ff6d7cf3e4 LibJS+LibWeb: Bring script fetching closer to the spec
This patch updates various parts of the script fetching implementation
to match the current specification.

Notably, the implementation of changes to the import assertions /
attributes proposal are not part of this patch(series).
2023-10-31 18:09:14 +01:00
networkException 5b1d0d4d1b LibWeb: Add FetchContext as HostDefined JS::GraphLoadingState field
This patch adds FetchContext as the type to be used in the HostDefined
slot of JS::GraphLoadingState in web script fetching.
2023-10-31 18:09:14 +01:00
networkException c3b02ae65a LibJS: Add GraphLoadingState Record
This patch adds the GraphLoadingState Record with a struct HostDefined
for use in the HostDefined field.
2023-10-31 18:09:14 +01:00
networkException dd90ed11b3 LibWeb: Add helper to create default classic script fetch options 2023-10-31 18:09:14 +01:00
networkException d1c1218d42 LibWeb/Fetch: Implement changes to priority
This patch updates the priority member of fetch requests to be
an enum. The implementation defined struct previously named Priority
has been renamed to InternalPriority in line with the spec.
2023-10-31 18:09:14 +01:00
networkException 5aa7c51956 LibWeb: Pass around JS::HeapFunctions when fetching scripts
This patch replaces the use of JS::SafeFunction for the
OnFetchScriptComplete in various script fetching functions with
JS::HeapFunction. The same applies for callbacks in ModuleMap.

This also removes DescendantFetchingContext, which stashed the
on complete function in fetch_descendants_of_a_module_script
for multiple calls to fetch_internal_module_script_graph
previously.
2023-10-31 18:09:14 +01:00
networkException 33b40eaeed LibJS: Add LoadedModules to Script and CyclicModule 2023-10-31 18:09:14 +01:00
networkException d60e8c9df5 LibJS: Add ModuleWithSpecifier for LoadedModules
This patch adds ModuleWithSpecifier as the record type to be used in
the LoadedModules field of Realm, Script and Cyclic Module Records.
2023-10-31 18:09:14 +01:00
networkException 7c7ca7f230 LibWeb: Add New as a possible enum variant of ModuleStatus 2023-10-31 18:09:14 +01:00
networkException 89ea444967 LibWeb: Use proper helper for appending to scripts to run after parsing
Instead of appending manually to the
scripts_to_execute_when_parsing_has_finished list, lets use the proper,
currently unused function for this.
2023-10-31 18:09:14 +01:00
Timothy Flynn 99216b2a87 ClockSettings: Use a Vector as the time zone model's container type
The time zones were stored as a static Span until commit 0bc401a1d6, and
are now stored in a Vector. By continuing to tell the ItemListModel that
the container is a Span, we create a temporary Span in its constructor,
which the model tries to hold a constant reference to. Use the default
Vector container type now instead to prevent creating such temporaries.
2023-10-31 15:21:34 +01:00
Tim Ledbetter a6f9ad6012 LibGfx/OpenType: Ensure offsets are strictly less than the file size
Previously, an offset that was equal to the size of the file would
cause a crash.
2023-10-31 14:15:24 +01:00
Andrew Kaster 49d21619d4 CMake: Use a helper file to find GL and EGL in a platform agnostic way
Also add a flag to turn off accelerated graphics entirely.
2023-10-31 02:32:58 -06:00
Aliaksandr Kalenik 141f56accc LibWeb: Position abspos items inside grid relative to their grid area
Since grid item's containing block is not grid container but
corresponding grid area, it affect positioning of abspos items.
2023-10-31 08:46:17 +01:00
Aliaksandr Kalenik 44001d2178 LibWeb: Separate grid item's area rect calculation in a function in GFC
We would also have to find grid area rect while abspos items layout so
it makes sense to have this code in a separate function.
2023-10-31 08:46:17 +01:00
Uku Loskit 98ad5a7141 LibHTTP: Fix issues with HTTP POST request and requests with a body
The previous implementation created invalid HTTP requests in cases
where the request method was POST or when the request contained a
body. There were two bugs for these cases:

1) the 'Content-Type' header was sent twice
2) a stray CRLF was appended to the request
2023-10-31 07:09:26 +01:00
Aliaksandr Kalenik 549dee4db1 LibWeb: Call prepare_for_replaced_layout() on replaced boxes in GFC
We need to call prepare_for_replaced_layout() on grid items to populate
their natural sizes and aspect ration.
2023-10-31 07:08:30 +01:00
stelar7 a559dca816 LibTLS: Fix supported signature algorithms typo
The ED curve is INTRINSIC/ED25519, not INTRINSIC/ECDSA
2023-10-31 07:07:53 +01:00
Simon Wanner fb7b4b9c59 LibJS/JIT: Provide source location information for JIT code
This works by walking a backtrace until the currently executing
native executable is found, and then mapping the native address
to its bytecode instruction.
2023-10-31 07:07:17 +01:00
Simon Wanner 112eadc863 LibJS/JIT: Annotate disassembly with bytecode information 2023-10-31 07:07:17 +01:00
Simon Wanner 9f78e56823 LibJS/JIT: Record machine code location to bytecode location mapping 2023-10-31 07:07:17 +01:00
Timothy Flynn cf93e56833 headless-browser: Use LibWebView to sanitize input URLs
Remove the ad-hoc sanitization in favor of LibWebView. This was missed
after commit 191e20d639.
2023-10-31 07:03:15 +01:00
Tobias Christiansen e60253d64c LibWeb: Respect offsets always when painting with object-position
Previously we didn't always set the bitmap_intersect correctly when
applying an object-position. This lead to images not correctly being
centered when the axis that it should move along was not the specified
axis.
2023-10-31 07:03:05 +01:00
Tobias Christiansen 6f71b8be1b LibWeb: Use local 'offset' variable in ImagePaintable
We created the local and then did not use it everywhere we could.
2023-10-31 07:03:05 +01:00
Tobias Christiansen 3a4d30dddc LibWeb: Avoid truncation of aspect-ratio-computation in ImagePaintable
The value of the aspect ratio of the bitmap got truncated and this
lead to funky rendering problems when using object-fit and
object-position.
2023-10-31 07:03:05 +01:00
Ali Mohammad Pur 78c04cb8b2 AK+LibPDF: Make Format print floats in a roundtrip-safe way by default
Previously we assumed a default precision of 6, which made the printed
values quite odd in some cases.
This commit changes that default to print them with just enough
precision to produce the exact same float when roundtripped.

This commit adds some new tests that assert exact format outputs, which
have to be modified if we decide to change the default behaviour.
2023-10-31 09:12:35 +03:30
Andrew Kaster baa26d10a8 LibTLS: Retry sending in TLSv12::flush() on EAGAIN or EINTR
Crashing here is not very helpful.
2023-10-31 00:36:51 +03:30
MacDue c93d367d95 LibWeb: Layout SVG <text> elements during layout (not while painting)
Previously, all SVG <text> elements were zero-sized boxes, that were
only actually positioned and sized during painting. This led to a number
of problems, the most visible of which being that text could not be
scaled based on the viewBox.

Which this patch, <text> elements get a correctly sized layout box,
that can be hit-tested and respects the SVG viewBox.

To share code with SVGGeometryElement's the PathData (from the prior
commit) has been split into a computed path and computed transforms.
The computed path is specific to geometry elements, but the computed
transforms are shared between all SVG graphics elements.
2023-10-30 19:44:54 +01:00
MacDue dc9cb449b1 LibWeb: Store computed SVG path data/transforms in LayoutState
This removes the awkward hack to recompute the layout transform at paint
time, and makes it possible for path sizes to be computed during layout.

For example, it's possible to use relative units in SVG shapes (e.g.
<rect>), which can be resolved during layout, but would be hard to
resolve again during painting.
2023-10-30 19:44:54 +01:00
Timothy Flynn 19313945f2 LibWeb: Implement loading a favicon in absence of a <link> icon element
For example, serenityos.org does not contain a <link rel="icon"> element
to indicate its favicon. Before navigables, we implemented attempting to
load a fallback favicon in a rather ad-hoc manner. This implements the
full spec steps to do so after the HTML document is parsed.
2023-10-30 18:31:15 +01:00
Timothy Flynn b1274a885b LibWeb: Return success when a <link> element decodes a valid favicon 2023-10-30 18:31:15 +01:00
Timothy Flynn 1504469c50 js: Implement the exit builtin without calling the native exit function
If we invoke the exit native function from within the exit builtin, the
native call will then invoke global destructors. This ultimately ends up
deleting the JS::NativeFunction that defines the exit builtin, thus we
try to delete the AK::Function held inside the NativeFunction while that
AK::Function is executing. This is explicitly forbidden by AK::Function.

Instead, simply set a flag to exit the REPL after the builtin executes.
2023-10-30 18:12:17 +01:00
Andrew Kaster f9386737a6 LibTLS: Add certificate verification for ECDSA with SECP256r1 curves 2023-10-30 10:17:39 -06:00
Michiel Visser c548dca174 LibTLS: Add ECDSA support with the secp256r1 curve 2023-10-30 10:17:39 -06:00
Michiel Visser caf533bddf LibCrypto: Add ECDSA signature checking with secp256r1 2023-10-30 10:17:39 -06:00
Simon Wanner 0daebef727 LibJS/JIT: Clear exception before executing finalizer
language/statements/try/S12.14_A13_T2.js                        -> 
language/statements/try/S12.14_A15.js                           -> 
language/statements/try/S12.14_A7_T1.js                         -> 
language/statements/try/S12.14_A7_T2.js                         -> 
language/statements/try/S12.14_A7_T3.js                         -> 
language/statements/try/completion-values-fn-finally-abrupt.js  -> 
language/statements/try/completion-values-fn-finally-return.js  -> 
2023-10-30 15:05:26 +01:00
Simon Wanner bd62c4763c LibJS/JIT: Flip saved_return_value condition in ContinuePendingUnwind
This did not match the `if (saved_return_value) return else resume`
in Interpreter.

test/built-ins/Promise/all/resolve-poisoned-then.js         -> 
test/built-ins/Promise/all/resolve-thenable.js              -> 
test/built-ins/Promise/allSettled/resolve-poisoned-then.js  -> 
test/built-ins/Promise/allSettled/resolve-thenable.js       -> 
test/built-ins/Promise/race/resolve-self.js                 -> 
test/language/statements/try/S12.14_A7_T1.js                -> 
test/language/statements/try/S12.14_A7_T2.js                -> 
test/language/statements/try/S12.14_A7_T3.js                -> 
2023-10-30 15:05:26 +01:00
Simon Wanner 82c057391e LibJS/JIT: Handle uninitialized bindings in GetLocal
test262: +78     -72     -4 💥
2023-10-30 15:05:26 +01:00
Simon Wanner 5b2c0dfec0 LibJS/JIT: Return result of SuperCallWithArgumentArray
test/language/expressions/optional-chaining/call-expression.js 💥️ -> 
test/language/expressions/super/call-expr-value.js             💥️ -> 
2023-10-30 15:05:26 +01:00
Evgeniy Baskov da45bd3fde LibJS/JIT: Implement static exception handling 2023-10-30 13:10:08 +01:00
Hendiadyoin1 1341f4438d LibJS: Save scheduled jumps when entering unwind contexts
These are then restored upon `ContinuePendingUnwind`.
This stops us from forgetting where we needed to jump when we do extra
try-catches in finally blocks.

Co-Authored-By: Jesús "gsus" Lapastora <cyber.gsuscode@gmail.com>
2023-10-30 13:10:08 +01:00
Hendiadyoin1 4da5b8ec67 LibJS: Reset scheduled-jump flag when throwing an exception
Otherwise we might attempt to follow the scheduled jump later
2023-10-30 13:10:08 +01:00
Hendiadyoin1 f5645e3c9c LibJS: Use static unwind mappings for unwind related functions 2023-10-30 13:10:08 +01:00
Hendiadyoin1 73f347b75c LibJS: Create static unwind mappings for BasicBlocks
This is currently only used in the bytecode dump to annotate to where
unwinds lead per block, but will be hooked up to the virtual machine in
the next commit.
2023-10-30 13:10:08 +01:00
Tobias Christiansen 647f0ccd3f LibWeb: Add rendering support for 'object-position'
Images now get rendered correctly according to the 'object-position'
property.
2023-10-30 10:40:30 +00:00
Tobias Christiansen d00c7e55a5 LibWeb: Add plumbing for the new 'object-position' property
Now, the 'object-position' property gets properly parsed and is
provided to the rest of the ecosystem.
In the parser we use the same parsing as for the background-position,
which is not entirely correct but almost a <position>.
2023-10-30 10:40:30 +00:00
Tobias Christiansen 7e11de272f LibWeb: Add 'object-position' property and 'position' enum
This patch adds the 'object-position' CSS property description to the
json for code generation.
Also the 'position' enum is added. The values of this enum are the
valid inputs to the object-position property from CSS Values-4.
2023-10-30 10:40:30 +00:00
Tobias Christiansen 6602b1ddb1 LibWeb: Rename "position" enum to "positioning"
The postitioning enum values are used by the position CSS property.
Unfortunately, the prior naming clashes with the CSS Values-4 type
named position, which will be implemented in a later commit.
2023-10-30 10:40:30 +00:00
Gurkirat Singh 60640fe38d Utilities: Implement slugify using AK/Slugify 2023-10-30 10:39:59 +00:00
Gurkirat Singh ab2d8c092e LibCore: Implement handler for Vector<String> positional arguments 2023-10-30 10:39:59 +00:00
Gurkirat Singh da8a3f9ff2 LibMarkdown: Render slugified anchor tag in heading
Because slugify function accepts AK::String, which can hold unicode
code_points as well, heading text is normalised to ensure with NFD
form to ensure same binary respresentation of a particular string.
2023-10-30 10:39:59 +00:00
Andreas Kling 0c6d094a7e LibJS/JIT: Stop logging JIT success by default (but still log failure) 2023-10-30 07:11:43 +01:00
Zaggy1024 dfaf645302 LibJS: Add an inline JIT fast path when ToNumeric has nothing to do
In most cases, this op will do nothing, as it is running on an the
accumulator while it already contains a number. Let's avoid doing that
native call.
2023-10-30 07:10:54 +01:00
Simon Wanner a2b0154661 LibJS/JIT: Compile the AsyncIteratorClose instruction 2023-10-30 07:10:24 +01:00
Simon Wanner ac59e982a9 LibJS/JIT: Compile the CopyObjectExcludingProperties instruction 2023-10-30 07:10:24 +01:00
Simon Wanner 9494fbe670 LibJS/JIT: Compile the PutByValueWithThis instruction 2023-10-30 07:10:24 +01:00
Simon Wanner 847889343f LibJS/JIT: Compile the New##ErrorName instructions 2023-10-30 07:10:24 +01:00
Simon Wanner fd059d4e4a LibJS/JIT: Compile the JumpUndefined instruction 2023-10-30 07:10:24 +01:00
Simon Wanner a16082c6a5 LibJS/JIT: Compile the HasPrivateId instruction 2023-10-30 07:10:24 +01:00
Simon Wanner 712c89dacf LibJS/JIT: Compile the GetNewTarget instruction 2023-10-30 07:10:24 +01:00
Simon Wanner 19045d6431 LibJS/JIT: Compile the GetMethod instruction 2023-10-30 07:10:24 +01:00
Simon Wanner 06ea4cfc4f LibJS/JIT: Compile the DeleteVariable instruction 2023-10-30 07:10:24 +01:00
Simon Wanner cd18bc9d55 LibJS/JIT: Compile the GetImportMeta instruction 2023-10-30 07:10:24 +01:00
Simon Wanner c0c40110c1 LibJS/JIT: Compile the ImportCall instruction 2023-10-30 07:10:24 +01:00
Simon Wanner ac43d3f6db LibJS/JIT: Compile the PutPrivateById instruction 2023-10-29 22:57:19 +01:00
Simon Wanner 81697549b7 LibJS/JIT: Compile the PutByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner 38d5d7979b LibJS/JIT: Compile the DeleteByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner b53277110e LibJS/JIT: Compile the GetByValueWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner 569ca57e22 LibJS/JIT: Compile the GetByIdWithThis instruction 2023-10-29 22:57:19 +01:00
Simon Wanner ad81f49b02 LibJS/JIT: Compile the ResolveSuperBase instruction 2023-10-29 22:57:19 +01:00
Simon Wanner 4e9edb8c53 LibJS/JIT: Compile the GetPrivateById instruction 2023-10-29 22:57:19 +01:00
Simon Wanner 4ce2878394 LibJS/JIT: Compile the GetObjectPropertyIterator instruction 2023-10-29 22:57:19 +01:00
Simon Wanner ad81bf47bb LibJS: Move GetObjectPropertyIterator impl to CommonImplementations 2023-10-29 22:57:19 +01:00
Tim Schumacher 25642dfe87 LibCompress: Implement correct validation of last filters 2023-10-29 22:00:59 +01:00
Tim Schumacher 786e654dfd LibCompress: Implement the XZ delta filter 2023-10-29 22:00:59 +01:00
Tim Schumacher f0b08e9dea LibCompress: Process XZ filters in reverse order
XZ writes filters in the order that they are used during compression, so
we need to process them in the reverse order while decompression.

This wasn't noticed earlier because we only supported the LZMA2 filter.
2023-10-29 22:00:59 +01:00
Jakub Berkop 6a7b9b85a4 LibJS/JIT: Compile the DeleteByValueWithThis instruction 2023-10-29 21:51:46 +01:00
Jakub Berkop 0776404e03 LibJS/JIT: Compile the DeleteByValue instruction 2023-10-29 21:51:46 +01:00
Jakub Berkop f5fcd4596c LibJS/JIT: Compile the DeleteById instruction 2023-10-29 21:51:46 +01:00
Bastiaan van der Plaat 0104225d9b LibWeb: Add TextEncoder encodeInto 2023-10-29 21:44:53 +01:00
Bastiaan van der Plaat f1ead552ce LibWeb: Add constructor options to TextDecoder 2023-10-29 21:44:53 +01:00
Tim Ledbetter 9ed8c0b183 LibGfx/JPEG: Propagate errors when creating JPEGLoadingContext
This allows the JPEG fuzzer to make progress.
2023-10-29 21:39:29 +01:00
Hendiadyoin1 a42d849ec1 LibJIT: Widen allowed argument range for add32 and use REX if necessary
The REX prefix is elided when it is not needed, so no change in code
size is to be expected
2023-10-29 20:28:04 +01:00
Hendiadyoin1 248782461c LibJIT: Introduce and use REX prefix helper
This makes the code a bit more readable and in conjunction with the
ModRM helper should prevent some operand ordering bugs.
This also includes one incidental bugfix:
`sign_extend_32_to_64_bits`, was not setting the `REX.R` bit when
appropriate,
And one size obvious optimization:
We may now elide the REX prefix on `xor eax, eax` as storing to a 32 bit
register clears the upper 32 bit of said register, which is wanted here.
2023-10-29 20:28:04 +01:00
Hendiadyoin1 540963fbe3 LibJIT: Use ModRM helpers where applicable
This also widens the argument coverage of some helpers, to allow
memory offsets, this also consolidates the displacement size choosing.
This also stops us from some out argument ordering bugs, as we now just
need to look up the correct calling convention and call the correct
function.
2023-10-29 20:28:04 +01:00
Hendiadyoin1 b46c5545f1 LibJIT: Add ModRM helpers for argument encoding 2023-10-29 20:28:04 +01:00
Andrew Kaster 86ce502ae2 LibGfx+Utilities: Add helpers to load vector fonts from Core::Resources 2023-10-29 13:12:28 -06:00
Andrew Kaster 286dc6df7f LibGfx: Remove ability to load fonts directly from a file path
Users must now either pass a Core::Resource, a resource:// URI, or
a Core::MappedFile
2023-10-29 13:12:28 -06:00
Andrew Kaster 1567332e34 Userland+Tests: Remove uses of direct file loading for BitmapFont
Route them through Core::Resource APIs instead.
2023-10-29 13:12:28 -06:00
Andrew Kaster d587bd0a04 LibGfx: Add helpers to load BitmapFont from Core::Resource 2023-10-29 13:12:28 -06:00
Andrew Kaster 897f4d05eb LibGfx: Add abstraction to load BitmapFont from a FixedMemoryStream
We'll use this to load from a Core::Resource in a later commit.
2023-10-29 13:12:28 -06:00
Andrew Kaster a4c7d9a374 LibCore: Add helper to load a possibly-relative path into a Resource 2023-10-29 13:12:28 -06:00
FalseHonesty 2285dfb80e LibWeb: Resolve block max-width percentage against containing block 2023-10-29 19:35:02 +01:00
Simon Wanner 40064d872f LibJS/JIT: Compile the Append instruction 2023-10-29 17:36:09 +01:00
Simon Wanner 516bb01082 LibJS/Bytecode: Move Append impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner 3dc5c8d28e LibJS/JIT: Compile the IteratorToArray instruction 2023-10-29 17:36:09 +01:00
Simon Wanner 5179ff5fc9 LibJS/Bytecode: Move IteratorToArray impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner c697ff61f6 LibJS/JIT: Compile the IteratorClose instruction 2023-10-29 17:36:09 +01:00
Simon Wanner 233502a10c LibJS/JIT: Compile the IteratorResultValue instruction 2023-10-29 17:36:09 +01:00
Simon Wanner e7fdf9c7e5 LibJS/JIT: Compile the ThrowIfNullish instruction 2023-10-29 17:36:09 +01:00
Simon Wanner 9e2edc3085 LibJS/JIT: Compile the ThrowIfNotObject instruction 2023-10-29 17:36:09 +01:00
Simon Wanner 39deb365d2 LibJS/JIT: Compile the IteratorResultDone instruction 2023-10-29 17:36:09 +01:00
Simon Wanner 045a1386d8 LibJS/JIT: Compile the IteratorNext instruction 2023-10-29 17:36:09 +01:00
Simon Wanner 661dbbc83d LibJS/Bytecode: Move object_to_iterator to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner 4f8f8b7792 LibJS/JIT: Compile the GetIterator instruction 2023-10-29 17:36:09 +01:00
Simon Wanner d416cef9bb LibJS/Bytecode: Move iterator_to_object to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner d247744a3e LibJS/JIT: Compile the SuperCallWithArgumentArray instruction 2023-10-29 17:36:09 +01:00
Simon Wanner 1eee110575 LibJS: Move SuperCallWithArgumentArray impl to CommonImplementations 2023-10-29 17:36:09 +01:00
Simon Wanner 09dce5f1bd LibJS/JIT: Compile the BlockDeclarationInstantiation instruction 2023-10-29 17:36:09 +01:00
Simon Wanner a28d6291ad LibJS/JIT: Generate switch cases using X macro 2023-10-29 17:36:09 +01:00
Simon Wanner f89bfb3f27 LibJS/JIT: Declare compile_* methods using X macro 2023-10-29 17:36:09 +01:00
Aliaksandr Kalenik 92461a2618 LibWeb: Use FillRect command in RecordingPainter if corners radius is 0
This change makes RecordingPainter to emit a FillRect command instead
of FillRectWithRoundedCorners if all corners have a radius = 0.

`fill_rect_with_rounded_corners()` in LibGfx already has a similar
optimization. But now when we also have LibAccelGfx, which does not
support painting rectangles with rounded corners yet, it makes sense to
emit FillRect whenever possible.
2023-10-29 17:13:23 +01:00
Aliaksandr Kalenik b6732b0234 Ladybird+WebContent: Add option to use GPU painter
Adds `--enable-gpu-painting` param to enable painting command executor
that uses LibAccelGfx.
2023-10-29 17:13:23 +01:00
Aliaksandr Kalenik 7d26cbf523 LibWeb: Add painting command executor that uses LibAccelGfx
This change introduces a command executor for RecordingPainter that
utilizes LibAccelGfx.
2023-10-29 17:13:23 +01:00
Aliaksandr Kalenik 95c154d9bd LibAccelGfx+Meta: Introduce OpenGL painting library
This change introduces a new 2D graphics library that uses OpenGL to
perform painting operations. For now, it has extremely limited
functionality and supports only rectangle painting, but we have to
start somewhere.

Since this library is intended to be used by LibWeb, where the
WebContent process does not have an associated window, painting occurs
in an offscreen buffer created using EGL.

For now it is only possible to compile this library on linux.
Offscreen context creation on SerenityOS and MacOS will have to be
implemented separately in the future.

Co-Authored-By: Andreas Kling <awesomekling@gmail.com>
2023-10-29 17:13:23 +01:00
Zaggy1024 56e8f52cb3 LibJIT/LibJS: Remove jump_if_***() in favor of jump_if()
The `jump_if()` function implements all the conditions already in use
and more, so let's avoid encouraging more wrapper functions.
2023-10-29 17:11:04 +01:00
Zaggy1024 288aff01cd LibJIT: Emit all Jcc jump instructions from one function
Since all conditional instructions use a certain number of bits to
encode the condition type (from my observation of `Jcc`, `SETcc` and
`CMOVcc`), let's abuse that to deduplicate some code!

This adds a `Condition` enum that defines the type of condition we are
jumping based on, whose underlying values are the values that must be
encoded to trigger each condition.
2023-10-29 17:11:04 +01:00
Zaggy1024 e717961000 LibJIT: Use test x, x instead of cmp x, 0 in all cases
The `test` instruction will have the same result as `cmp` when
comparing to zero, so let's always emit that code. This has no effect
until the following commit.
2023-10-29 17:11:04 +01:00
Karol Kosek bf16ddfbb0 LibWeb: Bail parsing transform-origin if the parsed value is null
Passing a value of a type different than number or length-percentage
to transform-origin returned a null pointer, and we didn't take care
of that path before.

This patch fixes a crash caused by an incorrect CSS declaration, such as
`transform-origin: "center"`.

Fixes #21609
2023-10-29 11:22:53 +01:00
Aliaksandr Kalenik d22aa851cf LibWeb: Float property should be ignored for grid items 2023-10-29 09:43:13 +01:00
Aliaksandr Kalenik 5ef94f0ba8 LibWeb/Painting: Fix translation for FIllRect command
After 4318bcf447 RecordingPainter
is suppoed to write commands in coordinate system of stacking context.

This commit adds missing translation for FillRect command.
2023-10-29 08:48:34 +01:00
Aliaksandr Kalenik f75186ec8f LibWeb: Add support for grid item's min-height and max-height in GFC 2023-10-29 08:46:51 +01:00
Lucas CHOLLET e721c74598 LibGfx: Provide an implementation for ImageDecoderPlugin::icc_data() 2023-10-29 07:21:10 +00:00
iliadsh 4f3945024a LibJS/JIT: Add fast path for Add Int32, Int32
This uses the 32-bit registers to perform the addition and bail if the
overflow flag (OF) is set.
2023-10-29 08:02:00 +01:00
Simon Wanner 4b23a7dfb4 LibJS/JIT: Compile the NewClass bytecode instruction 2023-10-29 07:44:11 +01:00
Simon Wanner f9fbb8cff2 LibJS/Bytecode: Move NewClass impl to CommonImplementations 2023-10-29 07:44:11 +01:00
Simon Wanner ddce5e03c2 LibJS/JIT: Clear unwind context handler on usage
This clears the handler pointer of the current unwind context
before jumping to it. This is necessary to not loop infinitely
when an exception is thrown from the handler.
In that case control flow should go to the finalizer instead.

This mirrors how unwind_context.handler_called is used in the
Bytecode::Interpreter.

`try { throw 1 } catch (e) { throw 2 } finally {}` now runs
without looping infinitely in the catch block.
2023-10-29 07:44:11 +01:00
Simon Wanner 224f92f6e4 LibJS/JIT: Compile the CreateVariable bytecode instruction 2023-10-29 07:44:11 +01:00
Simon Wanner 54f1f7a51b LibJS/Bytecode: Move CreateVariable impl to CommonImplementations 2023-10-29 07:44:11 +01:00
Simon Wanner 1d3062de9e LibJS/JIT: Compile the ConcatString bytecode instruction 2023-10-29 07:44:11 +01:00
implicitfield 4b60a99573 Shell: Remove '#' from the list of acceptable bareword characters
This stops the shell from always interpreting '#' as the start of a
comment in non-Posix mode.
2023-10-29 01:35:40 +03:30
Fabian Meyer 4afd782477 LibJIT: Fix Assembler::add(reg, reg) and sub(reg, reg) encoding 2023-10-28 23:13:22 +02:00
Evgeniy Baskov 9258e253ca LibJS/JIT: Fix crash in CallWithArgumentArray 2023-10-28 22:33:45 +02:00
Andreas Kling 40ecf7689b LibJS/JIT: Run clang-format on Compiler.cpp 2023-10-28 21:02:13 +02:00
Simon Wanner 2cbc9d6970 LibJS/JIT: Consolidate exception handling code
Instead of emitting the lengthy exception checking/handling routine,
we only emit code for checking the presence of an exception and jump
to a common exception handler.

This code size optimization saves 2.08MiB on Kraken/ai-astar.js
2023-10-28 20:44:49 +02:00
Simon Wanner 202a08ecc2 LibJS+LibJIT: Replace make_label() with default constructed label 2023-10-28 20:44:49 +02:00
Simon Wanner ff265d1900 LibJIT: Support jumps to already linked labels 2023-10-28 20:44:49 +02:00
Idan Horowitz b2d8d0c270 LibJS: Compile the CallWithArgumentArray bytecode instruction 2023-10-28 20:27:16 +02:00
Idan Horowitz 2b65a80ecb LibJS: Compile the NewBigInt bytecode instruction 2023-10-28 20:27:16 +02:00
Idan Horowitz d200361620 LibJS: Remove useless indirection in compile_new_{function, regexp}
The cxx_new_* functions have the exact same signature as the underlying
function they redirect to, so there's no need for them. Removing them
saves us a couple of opcodes.
2023-10-28 20:27:16 +02:00
Andreas Kling 9c0c672839 LibJS/JIT: Store the VM register array base in RBX
This allows us to use the displacement-less MOV encoding when accessing
register $0 (the accumulator).

This reduces code size by 158 KiB on Kraken/ai-astar.js :^)
2023-10-28 20:26:35 +02:00
Andreas Kling 32d3a47058 LibJIT: Generate MOV ModR/M without displacement when possible
For non-extended register bases and 0x0 offset, we can emit a ModR/M
byte without displacement.
2023-10-28 20:26:35 +02:00
Nico Weber 4cc24548f6 LibPDF: Call dbgln() for unimplemented flex upcodes 2023-10-28 13:28:05 -04:00
Nico Weber e484fae8e1 LibPDF: Don't do special subr processing for type 2 CFFs
This is a subset of #21484: Type 2 CFFs never use the special subrs,
so stop doing them for type 2 at least for now.

Fixes an assert in 0000064.pdf in 0000.zip in the pdfa dataset
(a stack underflow because a subr is supposed to push a bunch of
stuff, but instead it ran one of the built-in routines instead of
the subr from the font file).

As discussed in #21484, this isn't right for type 1 CFFs either,
but just removing the code there regresses Tests/LibPDF/type1.pdf.
A slightly more involved thing is needed there; I added a FIXME
for that here.
2023-10-28 13:28:05 -04:00
Tim Ledbetter 5c0c55d2c0 LibPDF: Ensure xref stream field widths are within expected range
Previously, an xref stream with a field with larger than 8 would
result in an undefined shift occurring. We now ensure that each field
width is a number and is less than or equal to 8.
2023-10-28 13:17:09 -04:00
Sam Atkins 596773f12f LibWeb: Stop forward-declaring NavigationParams twice 2023-10-28 13:15:51 -04:00
MacDue 3659149888 LibWeb: Fix stroke-opacity for stroked paths that use PaintStyles
Ref test included :)
2023-10-28 19:06:12 +02:00
Timothy Flynn 8dc25dffc2 LibWebView: Protect URL highlighting against partially-typed URLs
The current helpers assume that a valid URL is a full URL (i.e. contains
the "://" separator between the scheme and domain). This isn't true, as
"file:" alone is parsed as a valid URL.

We must also avoid simply searching for the parsed public suffix in the
original URL string. For example, "com" is a public suffix. If we search
for that in the URL "com.com", we will think the public suffix starts at
index 0.
2023-10-28 19:03:19 +02:00
Sönke Holz 24e64cac7e Kernel/riscv64: Add register state related headers 2023-10-28 10:36:06 -06:00
Andreas Kling 87baf140f2 LibJS/JIT: Use PUSH imm when pushing null unwind context pointer(s)
Small code size optimization, saves 252 bytes on Kraken/ai-astar.js :^)
2023-10-28 18:20:07 +02:00
Andreas Kling bbde64e0b6 LibJIT: Emit 8-bit PUSH imm when possible 2023-10-28 18:20:07 +02:00
Andreas Kling fff82c5ffe LibJS/JIT: Only preserve VM& when making native call to C++
Instead of pushing and popping every single caller-saved registers,
we can optimize code size (and speed!) by only pushing the one register
we actually care about: RDI (since it holds our VM&).

This means that native calls may clobber every other caller-saved
register, so this is something that you have to be aware of when
emitting native calls in the JIT.

This reduces code size on Kraken/ai-astar.js by 553 KiB and makes
execution time ~6% faster as well! :^)
2023-10-28 18:20:07 +02:00
Andreas Kling 926786e8d1 LibJS+LibJIT: Let users of JIT::Assembler handle caller-saved registers
Instead of JIT::Assembler making the decision for everyone and forcing
out every caller-saved register in the ABI onto the stack, we now leave
that decision to users of JIT::Assembler.
2023-10-28 18:20:07 +02:00
Andreas Kling 9afd12a8ba LibJS/JIT: Consolidate exits from the jitted code
Instead of emitting the "restore callee-saved registers and return"
sequence again and again, just emit it once at the end of the generated
code, and have everyone jump to it.

This is a code size optimization that saves 207KiB on Kraken/ai-astar.js
2023-10-28 18:20:07 +02:00
Idan Horowitz 0768bf2623 LibJS: Execute the finalizer when returning from a try block in the JIT
This fixes 1 of the 2 remaining failing test-js tests.
2023-10-28 17:11:47 +02:00
Idan Horowitz 78cac671b6 LibJS: Pass the expression string to cxx_call as a stack argument
This restores the bytecode interpreter's original call exception
throwing behaviour to the JIT.
This also fixes 8 of the 10 failing test-js tests when running with the
JIT enabled.
2023-10-28 14:44:45 +02:00
Idan Horowitz 863314ff10 LibJIT: Support passing stack arguments to native_call()s
The x86-64 SystemV ABI specifies that additional arguments after the
first 6 register-passed ones should be passed on the stack.
2023-10-28 14:44:45 +02:00
Andreas Kling e63423554f LibJIT: Keep the stack pointer aligned for making native calls
Instead of adjusting the stack pointer before/after making native calls,
just make sure we come out of enter() with the stack pointer aligned
for making calls.

This is strictly a code size reduction. :^)
2023-10-28 09:10:38 +02:00
Idan Horowitz 538a570852 LibJIT+LibJS: Consolidate sized immediate assembler operands
This replaces the existing sized immediate operands with a unified
immediate operand that leaves the size handling to the assembler,
instead of the user.

This has 2 benefits:
1. The user doesn't need to know which specific operand size the
instruction expects when using it
2. The assembler automatically chooses the minimal operand size that
fits the given value, resulting in smaller code size without any
additional effort from the user. While the change is small, it still
has a noticeable effect on performance (since it increases the I$ hit
rate), resulting in 5% speedup on kraken a-star.
2023-10-28 07:04:14 +02:00
Andrew Kaster d8ab9ed87c LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter
Move TabPosition into its own file, and using it into the global
namespace the same way we do for Gfx::Orientation. This unbreaks the gn
build, and out of tree builds.
2023-10-27 16:51:03 -06:00
Simon Wanner ec8330b647 LibJS/JIT: Dump disassembly of generated code using LibX86
This avoids the need for redirecting stdout to a file and using
ndisasm, which can lead to problems if other things are printed.
2023-10-27 21:49:55 +02:00
Simon Wanner 1d68c64b98 LibX86: Apply REX.W to B9-BF MOVs
All the MOVs in the B8-BF range can use the REX.W prefix, not just B8.
Previously instructions like `48 B9... mov rcx, imm64` were interpreted
as `mov rcx, imm32` because the REX.W prefix was only applied to
`48 B8... mov rax, imm64`.
2023-10-27 21:49:55 +02:00
Martin Janiczek 4fc1daa69f LibTest: Change #define-d constants into constexpr and a runtime flag
MAX_GENERATED_VALUES_PER_TEST is now the --randomized_runs flag:
$ ./Build/lagom/bin/TestGenerator --randomized_runs 1000

It's sometimes useful to try larger numbers for it instead of the
default of 100.

MAX_GEN_ATTEMPTS_PER_VALUE is now a constexpr. It's not usually needed
to tweak this value; we can recompile with a different value on the rare
occasion.
2023-10-27 12:26:06 -06:00
Martin Janiczek ed60a032a8 LibTest: Clean up an unneeded import 2023-10-27 12:26:06 -06:00
Martin Janiczek 4c068ba921 LibTest: Minimize footprint of Gen::unsigned_int, simplify code
unsigned_int(0) doesn't need to draw bits from RandomnessSource.

An expression for getting INT_MAX for u32 didn't need to be
special-cased over the general formula.

This is a follow-up on a few comments
2023-10-27 12:26:06 -06:00
Andreas Kling 230aa1404c LibJIT: Only compile Assembler on x86_64 for now 2023-10-27 19:07:22 +02:00
Andreas Kling c1551a64dc LibJS/JIT: Compile the NewRegExp bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling d6756decb9 LibJS/JIT: Compile the JumpNullish bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 17b2c7d965 LibJS/JIT: Compile the TypeofLocal bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling a645b9c6c3 LibJS/JIT: Stub out the JIT compiler on everything but ARCH(X86_64)
We don't support other architectures yet!
2023-10-27 19:07:22 +02:00
Andreas Kling d1c701f79f LibJS/JIT: Compile the Create/LeaveLexicalEnvironment instructions 2023-10-27 19:07:22 +02:00
Andreas Kling 935d67cfcf LibJS/JIT: Compile the GetCalleeAndThisFromEnvironment instruction 2023-10-27 19:07:22 +02:00
Andreas Kling dabaaabfc0 LibJS/JIT: Support the GetVariable bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 17657d012f LibJS/JIT: Consider compilation failed if mprotect(PROT_EXEC) fails 2023-10-27 19:07:22 +02:00
Andreas Kling 8c745ca223 LibJS+LibJIT: Fix GCC build 2023-10-27 19:07:22 +02:00
Andreas Kling 8eba60d015 LibJS/JIT: Only try JIT compilation when LIBJS_JIT is set in environment
Instead of adding a flag to everything everywhere, let's try using an
environment variable this time.
2023-10-27 19:07:22 +02:00
Andreas Kling ae273e8e20 LibJS/JIT: Add simple compile-time flags for logging & dumping code 2023-10-27 19:07:22 +02:00
Andreas Kling 3b239b64ff LibJS/JIT: Remove debug spam in cxx_increment() 2023-10-27 19:07:22 +02:00
Andreas Kling e2f5bfb4c4 LibJS/JIT: Always mask everything but LSB in ToBoolean
As it turns out, cxx_to_boolean() may return "bool" as other values
than just 0 or 1. This happens when the C++ compiler decides to only
update the AL portion of the RAX return value register instead of
the whole thing.
2023-10-27 19:07:22 +02:00
Andreas Kling 5b198ccf32 LibJS+LibJIT: Don't turn patchable movs into xors with self
If a mov instruction is meant to be patchable, we don't want to rewrite
it as a xor, since that removes the slot where we'd patch in the right
value later.

Also, make sure to set both size bits in the REX prefix for xoring a
register with itself.
2023-10-27 19:07:22 +02:00
Andreas Kling 8b32e98f3f LibJS/JIT: Simplify Increment Int32 fast path
When we know the value is a positive Int32 less than 0x7fffffff,
it's safe to just add 1 to it and use that as the final result.
This avoids the work of re-adding the INT32_TAG.
2023-10-27 19:07:22 +02:00
Andreas Kling b43e38112c LibJS/JIT: Use JIT::Assembler::jump_if_zero() to improve code size 2023-10-27 19:07:22 +02:00
Andreas Kling 6f0baea594 LibJIT: Add jump_if_zero() and jump_if_not_zero() to Assembler
These can use test reg,reg on x86 which gives us a shorter encoding.
2023-10-27 19:07:22 +02:00
Andreas Kling fb483f1950 LibJIT: Emit 8-bit displacement variants for mov when possible 2023-10-27 19:07:22 +02:00
Andreas Kling d09bc54586 LibJIT: Encode mov(reg, 0) as xor(reg, reg)
This uses less space for the same result. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling 5b87d26027 LibJIT+LibJS: Move JIT::Assembler into a new LibJIT library
This will allow other parts of the system to generate machine code
at runtime. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling bfb527e614 LibJS/JIT: Call throw_if_needed_for_call() in cxx_call()
This allows test-js to run to completion (although we do still have
some bugs to track down.)
2023-10-27 19:07:22 +02:00
Andreas Kling bcf7cdb679 LibJS/Bytecode: Un-templatize throw_if_needed_for_call() 2023-10-27 19:07:22 +02:00
Andreas Kling 72c31fdd01 LibJS: Remove all interactions between Assembler and BasicBlock
With this change, Assembler is now free from LibJS concepts and could
move out to its own apartment. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling 022974a43a LibJS/JIT: Let Compiler keep per-BasicBlock state internally
Compiler now has a BasicBlockData struct for each BasicBlock. The struct
contains all the stuff that we previously stored with the
Bytecode::BasicBlock.
2023-10-27 19:07:22 +02:00
Andreas Kling 8a24d00b1a LibJS/JIT: Preserve the accumulator across PutByFoo
This ensures that we don't clobber the accumulator when putting a value
to a setter.
2023-10-27 19:07:22 +02:00
Andreas Kling 5bd93f34af LibJS/JIT: Sign-extend integers before comparing in LessThan fast path 2023-10-27 19:07:22 +02:00
Andreas Kling 4b7f5f4ae7 LibJS/JIT: Allow multiple jumps to the same Assembler::Label 2023-10-27 19:07:22 +02:00
Andreas Kling 1fb95c7df9 LibJS/JIT: Add fast path for LessThan Int32 < Int32
This uses a new branch_if_both_int32() helper.

It's interesting to note that we can compare encoded Int32 values
without stripping the INT32_TAG, since it doesn't affect signedness
of values.
2023-10-27 19:07:22 +02:00
Andreas Kling 895c613400 LibJS/JIT: Fix encoding of CMP reg,reg 2023-10-27 19:07:22 +02:00
Andreas Kling ea65214c57 LibJS/JIT: Add fast path for Increment with Int32 value
This uses a new branch_if_int32() mechanism that takes a code generating
lambda whose code will run if the input register is an Int32 JS::Value.
2023-10-27 19:07:22 +02:00
Andreas Kling aeb9bd3bf1 LibJS/JIT: Fix encoding of x86_64 AND reg, reg 2023-10-27 19:07:22 +02:00
Andreas Kling e4c4fb09f9 LibJS/JIT: Add fast path for the ResolveThisBinding codegen
We now generate a fast path for cached `this` values. The first time
`this` is resolved within a function, we call out to C++, but then
all subsequent accesses will hit the cache in Register::this_value().
2023-10-27 19:07:22 +02:00
Andreas Kling 7097169967 LibJS/JIT: Compile the PutByValue bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling c2aad0f573 LibJS/Bytecode: Move PutByValue impl to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling 9c93d100d1 LibJS/JIT: Compile the NewFunction bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 9f61cda27e LibJS/Bytecode: Move NewFunction impl into CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling a913ac5799 LibJS/JIT: Compile the NewArray bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 6a16783c66 LibJS/JIT: Compile the SetVariable bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 393d90abe1 LibJS/Bytecode: Move SetVariable implementation to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling e946440ed3 LibJS/JIT: Compile the TypeofVariable bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling d368dc5d25 LibJS/Bytecode: Move TypeofVariable impl to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling c65aecd878 LibJS/JIT: Compile all the unary bytecode instructions 2023-10-27 19:07:22 +02:00
Andreas Kling 640455b1d2 LibJS/JIT: Compile the Call bytecode instruction
I've left a FIXME about dealing with some throwsy cases.
2023-10-27 19:07:22 +02:00
Andreas Kling 7fc35fde09 LibJS/Bytecode: Move throw_if_needed_for_call to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling b56ecc7e34 LibJS/Bytecode: Move perform_call helper to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling d866780235 LibJS/JIT: Compile the NewObject bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 580249d650 LibJS/JIT: Compile the PutById bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 10bf25999c LibJS/JIT: Move VM pointers from R8,R9,R10 to R13,R14,R15
This way they don't clash with the SysV ABI function argument registers.
2023-10-27 19:07:22 +02:00
Andreas Kling decc221109 LibJS/JIT: Save and restore callee-saved registers in jitted code 2023-10-27 19:07:22 +02:00
Andreas Kling 3974ce2069 LibJS/JIT: Compile the GetGlobal bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 12898f5aef LibJS/JIT: Compile the Decrement bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 966b6f78a6 LibJS/JIT: Compile the GetByValue bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling e8190105db LibJS/Bytecode: Move GetByValue implementation to CommonImplementations 2023-10-27 19:07:22 +02:00
Andreas Kling 1c0efbec6b LibJS/JIT: Compile the ResolveThisBinding bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling b2602a4bae LibJS/JIT: Compile the ToNumeric bytecode instruction 2023-10-27 19:07:22 +02:00
Andreas Kling 0f735b3502 LibJS/JIT: Log both success and failure from the JIT compiler
These logs will eventually go away, once the JIT compiler can always
compile everything. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling 310bcd4717 LibJS/JIT: Don't keep trying to JIT unsupported bytecode executables
We now only try jitting each Bytecode::Executable once, and then cache
the resulting NativeExecutable.
2023-10-27 19:07:22 +02:00
Andreas Kling 6a6ef6670c LibJS/JIT: Support the GetById bytecode op
We can now do basic property (get) access in jitted code! :^)
2023-10-27 19:07:22 +02:00
Andreas Kling 8905682a16 LibJS/Bytecode: Begin moving shareable (JIT+Interpreter) stuff somewhere
There are a lot of native C++ functions that will be used by both the
bytecode interpreter and jitted code. Let's put them in their own file
instead of having them in Interpreter.cpp.
2023-10-27 19:07:22 +02:00
Andreas Kling b923ca392d LibJS/JIT: Support all the binary bytecode ops :^)
(And use the X macro to avoid repeating ourselves!)
2023-10-27 19:07:22 +02:00
Andreas Kling c2fe7af095 LibJS/JIT: Support the NewString bytecode op
This necessitated making the JIT::Compiler aware of the current
Bytecode::Executable, since that's where all the string literals are
held, but that seems like a good thing.
2023-10-27 19:07:22 +02:00
Andreas Kling efe58ebf2f LibJS/JIT: Support the Return bytecode op 2023-10-27 19:07:22 +02:00
Andreas Kling 45be2a8f72 LibJS/JIT: Add support for Add/Sub/Mul/Div bytecode ops 2023-10-27 19:07:22 +02:00
Geo25rey 891b071654 LibJS/JIT: Add support for "throw" keyword 2023-10-27 19:07:22 +02:00
Andreas Kling ed0d2bce83 LibJS/JIT: Handle exceptions in LessThan :^) 2023-10-27 19:07:22 +02:00
Andreas Kling 9dd5be0186 LibJS/JIT: Compile the EnterUnwindContext and LeaveUnwindContext ops
These push a "valid" unwind context on the stack and check_exception()
now knows how to jump to the (catch) handler if present.

(finally) finalizers will require some more work, but with this change,
we now have basic support for try...catch. :^)
2023-10-27 19:07:22 +02:00
Andreas Kling 9d35016284 LibJS/JIT: Add Assembler::jump(Operand) and verify_not_reached()
Yet another jump() overload, and also a way to crash if we end up
somewhere we shouldn't be while in jitted code.
2023-10-27 19:07:22 +02:00
Andreas Kling e3560c2545 LibJS/JIT: Propagate exceptions in the simplest case :^)
We now establish a stack of "unwind contexts" similar to what the
bytecode interpreter does, but here, it's a stack of structs with
addresses to the catch and finally blocks.

Unwind contexts also have a "valid" flag, and the root unwind context
(always present, pushed on JIT code entry) has valid=false, which we
interpret in check_exception() as "return and let our caller deal with
the exception".

Anything in Compiler that may generate an exception should now also
call check_exception() ASAP to emit the code for handling this.
2023-10-27 19:07:22 +02:00
Andreas Kling 3523f9f722 LibJS/JIT: Add patchable absolute references to basic blocks 2023-10-27 19:07:22 +02:00
Andreas Kling 2e6c02f088 LibJS/JIT: Support Imm32 operands in Assembler::push() 2023-10-27 19:07:22 +02:00
Andreas Kling 71e41418f6 LibJS/JIT: Do "enter & leave" sequence in x86_64 machine code
This ensures that the stack pointer is restored before we return from
the jitted code.
2023-10-27 19:07:22 +02:00
Andreas Kling 814b07a9c2 LibJS/JIT: Add Assembler::jump_if_equal()
And also factor out cmp() so we don't have to repeat it.
2023-10-27 19:07:22 +02:00
Andreas Kling a7bad26b63 LibJS/JIT: Add missing unistd.h include (fixes Clang build) 2023-10-27 19:07:22 +02:00
Andreas Kling c21978ead6 LibJS/JIT: Remove unused functions from Assembler 2023-10-27 19:07:22 +02:00
Andreas Kling 1e8c6d3b06 LibJS/JIT: Use mov() helper in Assembler::native_call() 2023-10-27 19:07:22 +02:00
Andreas Kling e7ce3d271a LibJS/JIT: Add Assembler::add() and sub() helpers 2023-10-27 19:07:22 +02:00