Commit graph

794 commits

Author SHA1 Message Date
Timothy Flynn
97f7cb805f LibJS: Remove errant invocation to FormatNumericUnits
This is an editorial change in the Intl.DurationFormat proposal. See:
cdef892
2025-02-06 10:46:04 -05:00
Timothy Flynn
eef9d07088 LibJS: Add an explicit check for a valid ISO date in ToTemporalYearMonth
This is an editorial change in the Temporal proposal. See:
a1c5d61
2025-02-06 07:59:09 -05:00
Timothy Flynn
97b384db74 LibJS: Move call to CreateISODateRecord lower in ToTemporalYearMonth
This is an editorial change in the Temporal proposal. See:
58fd7de
2025-02-06 07:59:09 -05:00
jg99
51434c2ed0 LibJS: Parse dates like "1 Jan 2001 00:00:00 GMT" 2025-02-05 15:06:54 -07:00
Timothy Flynn
911b915763 LibJS: Handle call stack limit exceptions in NewPromiseReactionJob
The promise job's fulfillment / rejection handlers may push an execution
context onto the VM, which will throw an internal error if our ad-hoc
call stack size limit has been reached. Thus, we cannot blindly VERIFY
that the result of invoking these handlers is non-abrupt.

This patch will propagate any internal error forward, and retains the
condition that any other error type is not thrown.
2025-02-05 08:05:01 -05:00
Timothy Flynn
b91a0f5403 LibJS: Repurpose MUST_OR_THROW_OOM to propagate general internal errors
There are now no users of the MUST_OR_THROW_OOM macro. Let's rename this
macro to indicate it may be used to propagate any internal error (such
as the call stack limit error) in places that would otherwise crash due
to a MUST/VERIFY invocation.

Note there's no actual functional change here, as we weren't able to
ensure the internal error was an OOM error previously.
2025-02-05 08:05:01 -05:00
Timothy Flynn
4c51602437 LibJS: Remove OOM handling from TypedArrayGetElement 2025-02-05 08:05:01 -05:00
Timothy Flynn
49f1ef52ad LibJS: Remove OOM handling from JS intrinsics initialization 2025-02-05 08:05:01 -05:00
Timothy Flynn
0fe9bbad2e LibJS: Add missing include to Intrinsics.h
This was preventing clangd in my environment from processing the
Intrinsics class.
2025-02-05 08:05:01 -05:00
Shannon Booth
b58ba2e1bd LibJS: Localize popping of execution context in AsyncFunctionDriver
Instead of adding a flag for the two callers that need a pop of the
execution context stack when invoking continue_async_execution inline
the pop of the execution context.

This makes the management of these stacks and surrounding VERIFY calls
much more obvious.
2025-01-30 13:57:29 -07:00
Shannon Booth
d1f9e3be90 LibJS: Only run queued promise jobs if there is no embedder
This has no functional difference as run_queued_promise jobs does
nothing when LibWeb is used as it has a different implementation of
enqueuing and running promise jobs. But this change makes it more
obvious that run_queued_promise jobs does nothing when there is an
embedder, and adjusts the comment to reflect what the code is
actually achieving.
2025-01-30 13:57:29 -07:00
Timothy Flynn
5372d07c5c LibJS: Simplify ParseTemporalCalendarString
This is an editorial change in the Temporal proposal. See:
1b1fd9f
2025-01-28 11:25:42 +00:00
Andreas Kling
d465e2aa2b LibJS: Cache the Intl.Collator in String.prototype.localeCompare()
In the very common case that no special constructor options are provided
for the Intl.Collator when calling localeCompare() on a string, we can
cache and reuse a default-constructed Intl.Collator, saving lots of time
and space.

This shaves a fair bit of load time off of https://wpt.fyi/ where they
use Array.prototype.sort() and localeCompare() to sort a big JSON thing.

Time spent in sort():
- Before: 1656 ms
- After: 135 ms
2025-01-23 21:38:19 +01:00
Andreas Kling
51a91771b8 LibJS+LibGC: Run FinalizationRegistry cleanup host hook *after* GC
Before this change, it was possible for a second GC to get triggered
in the middle of a first GC, due to allocations happening in the
FinalizationRegistry cleanup host hook. To avoid this causing problems,
we add a "post-GC task" mechanism and use that to invoke the host hook
once all other GC activity is finished, and we've unset the "collecting
garbage" flag.

Note that the test included here only fails reliably when running with
the -g flag (collect garbage after each allocation).

Fixes #3051
2025-01-23 12:10:21 +01:00
Luke Wilde
30507681f7 LibJS: Parse dates like "2021-04-21T15:00:00+0000"
This is used on figma.com
2025-01-21 21:36:05 +01:00
Luke Wilde
3ab4efb7ef LibJS: Parse dates like "2025-01-13 00:00:00.000"
This is used on figma.com.
2025-01-21 21:36:05 +01:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Timothy Flynn
b64a355a30 LibJS: Remove support for the "assert" keyword for import attributes
This was removed from the spec some time ago. See:
14286bb
2025-01-21 14:58:32 +01:00
Timothy Flynn
049109452e LibJS: Do not attempt to link modules which have failed to load
Linking a module has assertions about the module's state, namely that
the state is not "new". The state remains "new" if loading the module
has failed. See: https://tc39.es/ecma262/#figure-module-graph-missing

    In any case, this exception causes a loading failure, which results
    in A's [[Status]] remaining new.

So we must propagate that failure, instead of blindly moving on to the
linking steps.
2025-01-21 14:58:32 +01:00
Timothy Flynn
26c2484c2f LibJS: Implement the AsyncDisposableStack interface
This is very similar to the DisposableStack interface, except disposal
of resources is promise-based.
2025-01-17 20:46:32 +01:00
Timothy Flynn
5ea0aa5f08 LibJS: Bring the explicit resource management implementation up to date
While we don't yet have a working `using` implementation with our byte
code, we can still keep our DisposableStack implementation up to date.
The changes brought in here are all editorial, and set us up to start
an AsyncDisposableStack implementation.
2025-01-17 20:46:32 +01:00
Timothy Flynn
59162c8155 LibJS: Adjust ad-hoc clamping behavior in RegulateISODate
Instead of clamping to the limits allowed by ISOYearMonthWithinLimits,
clamp to the limits allowed by the type we are converting to (i32). This
allows some callers to then reject years outside that range.
2025-01-17 10:08:06 +01:00
Timothy Flynn
d5b26183f3 LibJS: Convert errant MUST to TRY in Temporal.PlainDateTime.with 2025-01-17 10:08:06 +01:00
Timothy Flynn
c3fc8996bf LibJS: Refer to RFC 9557 instead of ISO 8601 where appropriate
This is an editorial change in the Temporal proposal. See:
9bb84b2
2025-01-17 10:08:06 +01:00
Timothy Flynn
313c050a61 LibJS: Do not override the timeZoneName option in Intl.DateTimeFormat
This is an editorial change in the Temporal proposal. See:
d76d11b
2025-01-17 10:08:06 +01:00
Shannon Booth
5aeae5e583 LibJS: Parse dates like "Wednesday, Jan 15, 2025"
This was getting called on abc.com
2025-01-15 10:42:29 +01:00
Nicolas Ramz
423d106fd8 LibJS: Support date strings of the form "Thu, 09 Jan 2025 23:00:00" 2025-01-08 18:45:43 +01:00
Shannon Booth
c804d08d34 LibJS: Parse dates like "2025-01-02 14:00:00+0000"
This was getting spammed in the console by a website in the wild.
2025-01-03 14:43:13 -08:00
Lucas CHOLLET
d6abd44522 AK: Merge implementations of operator== for Optional
Instead of having a overload of the operator in each specialization of
Optional, use a free function as a common implementation.
2025-01-03 17:11:22 +01:00
Shannon Booth
1586d77b76 LibJS: Adopt editorial fix of return types of algorithms returning empty
See: 35af90949
2025-01-02 11:30:04 +01:00
Shannon Booth
d48a0aaa55 LibJS: Remove unneeded FIXMEs for suspending an execution context
From what I understand, the suspension steps are not required now,
or in the future for our implementation, or any other. The intent
is already implemented in the spec pushing on another execution
context to the stack and leaving the running execution context as-is.

The resume steps are a slightly different story as there is some subtle
behavior which the spec is trying to convey where some custom logic may
need to be done when one execution context changes from one to another.
It may be worth implementing those steps at a later point in time so
that this behavior is a bit easier to follow in those cases.

To make the situation more confusing - from what I can gather from the
spec, not all cases that the spec mentions resume actually means
anything normative. Resume is only _actually_ needed in a limited set
of locations.

For now, let's just remove the unneeded FIXMEs that indicate that there
is something to be done for the suspension steps, as there is not, and
leave the resume steps as is.
2025-01-02 11:30:04 +01:00
Timothy Flynn
27478ec7d4 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-19 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")
2024-12-28 05:39:32 -08:00
Andreas Kling
3bfb0534be LibGC: Rename MarkedVector => RootVector
Let's try to make it a bit more clear that this is a Vector of GC roots.
2024-12-26 19:10:44 +01:00
Timothy Flynn
962441b3cf LibJS: Avoid internal assertion accessing detached TA internal slots
This defers accessing TA internal slots until we know we have a valid,
attached TA. Our implementation has assertions that guard against this.
2024-12-13 07:09:39 -08:00
Timothy Flynn
0bc55424c8 LibJS: Fix variable reference in CreateDateTimeFormat
This is an editorial change in the Temporal proposal. See:
8acd353
2024-12-11 08:43:54 -08:00
Timothy Flynn
002b0ea7c7 LibJS: Remove dead code from ZonedDateTime.prototype.toLocaleString
This is an editorial change in the Temporal proposal. See:
065cf94
2024-12-11 08:43:54 -08:00
Timothy Flynn
b9ac4557d6 LibJS: Change variable name of parsed time zone offset
This is an editorial change in the Temporal proposal. See:
30d17d3
2024-12-11 08:43:54 -08:00
Pavel Shliak
6f81b80114 Everywhere: Include HashMap only where it's actually used 2024-12-09 12:31:16 +01:00
Timothy Flynn
234f218803 LibJS: Ensure GetDateTimeFormat returns nonnull for the best format
This is an editorial change in the Temporal proposal. See:
8a52801
2024-12-06 11:13:10 -05:00
Timothy Flynn
7104d724ee LibJS: Simplify condition in GetDateTimeFormat
This is an editorial change in the Temporal proposal. See:
23c74b6
2024-12-06 11:13:10 -05:00
Timothy Flynn
6b8acc0af5 LibJS: Ensure DifferenceISODateTime receives valid ISO date-times
This is an editorial change in the Temporal proposal. See:
b5da334
2024-12-06 11:13:10 -05:00
Timothy Flynn
6dfa6993e5 LibJS: Add workaround for invalid ISODateTimes in DifferenceISODateTime
The assertions can be hit when Temporal.Duration.prototype.round / total
are provided a PlainDate at the very limits of valid date-times. Tests
were recently added to test262 which trip these assertions, thus we are
now crashing in those tests. Let's throw a RangeError instead, as this
is the behavior expected by the tests.
2024-12-05 15:29:08 -05:00
Timothy Flynn
784e872851 LibJS: Remove errant assertion from ParseISODateTime
This is an editorial change in the Temporal proposal. See:
728beeb
2024-12-05 15:29:08 -05:00
Timothy Flynn
0e81092685 LibJS: Make CombineDateAndTimeDuration infallible
This is an editorial change in the Temporal proposal. See:
794960c
2024-12-05 15:29:08 -05:00
Timothy Flynn
e29c6d2a80 LibJS: Mark invocation to CombineDateAndTimeDuration as infallible
This is an editorial change in the Temporal proposal. See:
6860ad1
2024-12-05 15:29:08 -05:00
Timothy Flynn
46c3406008 LibJS: Swap arguments in invocation to AddTimeDurationToEpochNanoseconds
This is an editorial change in the Temporal proposal. See:
630b043

This also changes the second argument of this AO to not use the alias of
TimeDuration, as that should not be used to refer to epoch nanoseconds.
This was missed in commit 2d9405e5d7.
2024-12-05 15:29:08 -05:00
Timothy Flynn
713e86cc1d LibJS: Mark some AO invocations in the Nudge* AOs as infallible
These are editorial changes in the Temporal proposal. See:
7aef51e
35cc12d
2637ba5
76dc52f
034f756
2024-12-05 15:29:08 -05:00
Timothy Flynn
4cbb5661d0 LibJS: Make ToDateDurationRecordWithoutTime infallible
This is an editorial change in the Temporal proposal. See:
05017b9
2024-12-05 15:29:08 -05:00
Timothy Flynn
4f07cddb2d LibJS: Mark TemporalDurationFromInternal as infallible in difference AOs
This is an editorial change in the Temporal proposal. See:
76c6612
2024-12-05 15:29:08 -05:00
Timothy Flynn
81b38c66a8 LibJS: Avoid negated test in DifferenceTemporalZonedDateTime
This is an editorial change in the Temporal proposal. See:
38233ae
2024-12-05 15:29:08 -05:00