Commit graph

1456 commits

Author SHA1 Message Date
Timothy Flynn
313c050a61 LibJS: Do not override the timeZoneName option in Intl.DateTimeFormat
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/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
0b2c80e503 LibJS: Adjust FIXME for an incorrect assertion in GetModuleNamespace
It turns out that the FIXME which we had left unimplemented is actually
a spec bug.
2025-01-02 11:30:30 +01:00
Shannon Booth
1031f424e9 LibJS: Remove inaccurate comment about use of on_call_stack_emptied
This is no longer done. One of the comments is also innacurate for a
second reason - the call stack is never empty in that case, and is
verified as such only a few lines above.
2025-01-02 11:30:04 +01:00
Shannon Booth
1586d77b76 LibJS: Adopt editorial fix of return types of algorithms returning empty
See: https://github.com/tc39/ecma262/commit/35af90949
2025-01-02 11:30:04 +01:00
Shannon Booth
8beb567088 LibJS: Remove redundant completion type check in ScriptEvaluation
See editorial change to the ECMA-262 spec of:

https://github.com/tc39/ecma262/commit/bc5b7fda5
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
ada36e5c0a LibJS: Allow async functions named "async" as function properties
For example, https://locals.com/site/discover has a script with an
object of the form:

    var f = {
        parser: {
            sync() {},
            async async() {},
        }
    };

We were previously throwing a syntax error on the async function, as we
specifically did not allow using "async" as a function name here.
2024-12-26 17:23:10 +01:00
Timothy Flynn
a5455ac121 LibJS: Ensure a function follows an async identifier in objects 2024-12-26 17:23:10 +01:00
Timothy Flynn
5947c37637 LibJS: Return the allocated dst register from deleting super properties
Even though calling delete on a super property will ultimately throw a
ReferenceError, we must return the allocated register for the result of
the delete operation (which would normally be a boolean). If the delete
operation is used in a return statement, the bytecode generator for the
return statement must be able to assume the statement had some output.
2024-12-14 12:08:50 -08: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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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
R-Goc
18132a0be1 LibJS: Remove compile flag for Windows 2024-12-08 17:37:26 -07:00
Timothy Flynn
234f218803 LibJS: Ensure GetDateTimeFormat returns nonnull for the best format
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/7aef51e
https://github.com/tc39/proposal-temporal/commit/35cc12d
https://github.com/tc39/proposal-temporal/commit/2637ba5
https://github.com/tc39/proposal-temporal/commit/76dc52f
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/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:
https://github.com/tc39/proposal-temporal/commit/38233ae
2024-12-05 15:29:08 -05:00
Timothy Flynn
5c0c1e507c LibJS: Reverse date comparison in DifferenceISODateTime
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/4a8cdb5
2024-12-05 15:29:08 -05:00
Timothy Flynn
16aebef4f4 LibJS: Make DifferenceISODateTime infallible
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/df74f7f
2024-12-05 15:29:08 -05:00
Timothy Flynn
25c361bb96 LibJS: Remove errant period from ZonedDateTime.prototype.toPlainDate
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/5e25315
2024-12-05 15:29:08 -05:00
Timothy Flynn
fe4995b69a LibJS: Replace invalid reference to an [[Offset]] internal slot
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/f1569ef

Here, we also update the struct member name to match the correct slot
name.
2024-12-05 15:29:08 -05:00
Timothy Flynn
db87f173fb LibJS: Implement the RegExp.escape proposal
https://tc39.es/proposal-regex-escaping/
2024-12-05 13:56:21 +01:00
Timothy Flynn
bd1009f3c1 LibJS: Extract some JS lexer helpers to free functions
We will need these in an upcoming proposal.
2024-12-05 13:56:21 +01:00
Timothy Flynn
5e534f4d83 LibJS+LibUnicode: Designate a sort order for Intl.PluralRules categories
This is a normative change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/62fe5db
2024-12-05 09:49:55 +01:00
Timothy Flynn
e5ec8441c9 LibJS: Remove the Intl.PluralRules GetOperands AO
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/c7bca3a
2024-12-05 09:49:55 +01:00
Jonne Ransijn
d5fbf7323a AK+LibJS: Allow {TRY,MUST}{,_OR_THROW_OOM} on list-initializers
List initializers may contain commas without surrounding parenthesis,
causing them to be passed as multiple macro arguments.
2024-12-04 16:45:58 +00:00
Shannon Booth
bd2f794873 LibJS: Make output_debug_message accept a StringView 2024-12-04 16:34:13 +00:00
Timothy Flynn
3c64e4595a LibJS: Use exact mathematical values for Intl.DurationFormat
We can't use doubles due to precision loss for extremely large values.
2024-12-04 08:01:35 -05:00
Timothy Flynn
5cfd50224c LibJS: Use enums instead of strings in Intl.DurationFormat AOs 2024-12-04 08:01:35 -05:00
Timothy Flynn
37fc9b6511 LibJS: Apply editorial updates to Intl.DurationFormat
To help prepare for its stage 4 promotion, this applies the editorial
updates made to Intl.DurationFormat over the last few months.
2024-12-04 08:01:35 -05:00
Jonne Ransijn
d7596a0a61 AK: Don't implicitly convert Optional<T&> to Optional<T>
C++ will jovially select the implicit conversion operator, even if it's
complete bogus, such as for unknown-size types or non-destructible
types. Therefore, all such conversions (which incur a copy) must
(unfortunately) be explicit so that non-copyable types continue to work.

NOTE: We make an exception for trivially copyable types, since they
are, well, trivially copyable.

Co-authored-by: kleines Filmröllchen <filmroellchen@serenityos.org>
2024-12-04 01:58:22 +01:00
Jonne Ransijn
edb3b10d11 LibJS: Align AsyncBlockStart with the latest drafts
`AsyncBlockStart` was still doing a `DisposeResources` call as
specified in older drafts of the `explicit-resource-management`
proposal, but the latest draft no longer does this, and it is
causing crashes when combined with the `array-from-async` proposal.
2024-12-02 18:20:56 -05:00
Jonne Ransijn
1b3f8e1e9a LibJS: Cache source code positions more often
The source code position cache was moved from a line based approach
to a "chunk"-based approach to improve performance on large, minified
JavaScript files with few lines, but this has had an adverse effect
on _multi-line_ source files.

Reintroduce some of the old behaviour by caching lines again, with
some added sanity limits to avoid caching empty/overly small lines.

Source code positions in files with few lines will still be cached
less often, since minified JavaScript files can be assumed to be
unusually large, and since stack traces for minified JavaScript
are less useful as well.

On WPT tests with large JavaScript dependencies like
`css/css-masking/animations/clip-interpolation.html` this reduces the
amount of time spent in `SourceCode::range_from_offsets` by as much as
99.98%, for the small small price of 80KB extra memory usage.
2024-12-02 11:42:11 +01:00
Shannon Booth
1a15e2cec6 LibJS: Allow comparing module records by equality 2024-12-01 11:56:18 +01:00