Commit graph

1219 commits

Author SHA1 Message Date
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
Jonne Ransijn
58631e9eef LibJS: Add missing CommonPropertyNamess and StringMayBeNumber::Nos 2024-12-01 10:42:49 +01:00
Jonne Ransijn
cfb00ba494 LibJS: Stop lazily coercing numeric PropertyKeys
Lazily coercing might have made sense in the past, but since hashing
and comparing requires the `PropertyKey` to be coerced, and since a
`PropertyKey` will be used to index into a hashmap 99% of the time,
which will hash the `PropertyKey` and use it in comparisons, the
extra complexity and branching produced by lazily coercing has
become more trouble than it is worth.

Remove the lazy coercions, which then also neatly allows us to
switch to a `Variant`-based implementation.
2024-12-01 10:42:49 +01:00
Timothy Flynn
53a507303c LibJS: Prevent extensions of TypedArray exotic objects
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/c1040ff
2024-11-30 11:18:26 +01:00
Timothy Flynn
0468463e2e LibJS: Implement the ECMA-402 ZonedDateTime.prototype.toLocaleString.js 2024-11-29 09:52:12 +01:00
Timothy Flynn
c96f6c396f LibJS: Implement the ECMA-402 PlainDateTime.prototype.toLocaleString.js 2024-11-29 09:52:12 +01:00
Timothy Flynn
224304cd56 LibJS: Implement the ECMA-402 PlainTime.prototype.toLocaleString.js 2024-11-29 09:52:12 +01:00
Timothy Flynn
ac0292b18f LibJS: Implement the ECMA-402 PlainYearMonth.prototype.toLocaleString.js 2024-11-29 09:52:12 +01:00
Timothy Flynn
bca70584b9 LibJS: Implement the ECMA-402 PlainMonthDay.prototype.toLocaleString.js 2024-11-29 09:52:12 +01:00
Timothy Flynn
697e68e68f LibJS: Implement the ECMA-402 PlainDate.prototype.toLocaleString.js 2024-11-29 09:52:12 +01:00
Timothy Flynn
964f41bb53 LibJS: Implement the ECMA-402 Instant.prototype.toLocaleString.js 2024-11-29 09:52:12 +01:00
Timothy Flynn
ea503a4f68 LibJS+LibUnicode: Integrate Temporal into Intl.DateTimeFormat
The gist is that we need to construct an ICU date-time formatter for
each possible Temporal type. This is of course going to be expensive.
So instead, we construct the configurations needed for the ICU objects
in the Intl.DateTimeFormat constructor, and defer creating the actual
ICU objects until they are needed.

Each formatting prototype can also now accept either a number (as they
already did), or any of the supported Temporal objects. These types may
not be mixed, and their properties (namely, their calendar) must align
with the Intl.DateTimeFormat object.
2024-11-29 09:52:12 +01:00
Timothy Flynn
0d635100c4 LibJS: Port Date.parse string arguments to String 2024-11-26 15:02:07 -05:00
Timothy Flynn
fc6155cf2c LibJS: Differentiate between failed ISO8601 parsing and invalid values
If we were able to parse an ISO8601 Date string, but the parse results
in an invalid date (e.g. out of the min/max range), we should abort
parsing immediately.
2024-11-26 15:02:07 -05:00
Timothy Flynn
511029807a LibJS: Implement Date.prototype.toTemporalInstant 2024-11-26 15:02:07 -05:00
Timothy Flynn
8e8c133db5 LibJS: Use Temporal for the Date constructor and Date.now() 2024-11-26 15:02:07 -05:00
Timothy Flynn
7aee254708 LibJS: Use correct epoch offset in InterpretISODateTimeOffset 2024-11-26 15:02:00 -05:00
Timothy Flynn
a93d32a306 LibJS: Alphabetically sort property keys and error types
And make ErrorType definitions use a better hanging-indent style, to
make it easier to maintain going forward.

i.e. instead of:

    M(VeryLongErrorNameHere, "very long error "
                             "message across multiple "
                             "lines"

We now have:

    M(VeryLongErrorNameHere,
        "very long error message across multiple "
        "lines")
2024-11-26 11:35:15 -05:00
Timothy Flynn
6a9aec29d5 LibJS: Remove unused property names and error types
Held off on this during the Temporal rewrite in favor of just removing
these all in one go.
2024-11-26 11:35:15 -05:00
Timothy Flynn
ade510fe17 LibJS: Pass ISO types by value vs. const-reference more correctly
We were passing types like ISODate by reference so that they could be
used as forward-declarations. But after commit 021a5f4ded, we now have
their full definitions anywhere they're needed. So let's pass ISODate by
value everywhere consistently - it is only 8 bytes.
2024-11-26 11:35:15 -05:00
Timothy Flynn
2d9405e5d7 LibJS: Use the TimeDuration alias a bit less in Temporal
It was a bit of a semantic mistake too use this alias too eagerly.
Namely, it should not be used to refer to epoch nanoseconds. We now only
use the TimeDuration alias where the spec refers to a value as a time
duration.
2024-11-26 11:35:15 -05:00
Jelle Raaijmakers
872a214f80 LibJS: Make FunctionPrototype's name empty per the spec 2024-11-26 12:44:05 +00:00
Jelle Raaijmakers
74614a10d1 LibJS: Correct spec table number for FunctionObject 2024-11-26 12:44:05 +00:00
Timothy Flynn
58828ffd62 LibJS: Implement Temporal.ZonedDateTime.prototype.to*
Includes:

Temporal.ZonedDateTime.prototype.toInstant
Temporal.ZonedDateTime.prototype.toPlainDate
Temporal.ZonedDateTime.prototype.toPlainTime
Temporal.ZonedDateTime.prototype.toPlainDateTime
2024-11-26 11:00:56 +01:00
Timothy Flynn
b95528d7b5 LibJS: Stub out Temporal.ZonedDateTime.prototype.getTimeZoneTransition
We will have to add facilities to determine next/previous time zone
transitions. Ideally, ICU can provide this.
2024-11-26 11:00:56 +01:00
Timothy Flynn
6d78f1327e LibJS: Implement Temporal.ZonedDateTime.prototype.startOfDay 2024-11-26 11:00:56 +01:00
Timothy Flynn
3d0f384e01 LibJS: Implement Temporal.ZonedDateTime.prototype.with*
Includes:

Temporal.ZonedDateTime.prototype.with
Temporal.ZonedDateTime.prototype.withPlainTime
Temporal.ZonedDateTime.prototype.withCalendar
Temporal.ZonedDateTime.prototype.withTimeZone
2024-11-26 11:00:56 +01:00
Timothy Flynn
f2ab9e1aa9 LibJS: Implement Temporal.ZonedDateTime.prototype.round 2024-11-26 11:00:56 +01:00
Timothy Flynn
eadd0c40c9 LibJS: Implement Temporal.ZonedDateTime.prototype.since/until 2024-11-26 11:00:56 +01:00
Timothy Flynn
336efa5e3f LibJS: Implement Temporal.ZonedDateTime.prototype.add/subtract/equals 2024-11-26 11:00:56 +01:00
Timothy Flynn
4ef21614e9 LibJS: Implement stringification Temporal.ZonedDateTime prototypes 2024-11-26 11:00:56 +01:00
Timothy Flynn
c0150acc5e LibJS: Implement Temporal.*.prototype.toZonedDateTimeISO and friends 2024-11-26 11:00:56 +01:00
Timothy Flynn
18f95434bc LibJS: Implement the Temporal.Duration relative-to ZonedDateTime options 2024-11-26 11:00:56 +01:00
Timothy Flynn
3e6133cc09 LibJS: Handle ZonedDateTime in the various Temporal factories 2024-11-26 11:00:56 +01:00
Timothy Flynn
8c73cae2b8 LibJS: Implement the Temporal.ZonedDateTime constructor
And the simple Temporal.ZonedDateTime.prototype getters, so that the
constructed Temporal.ZonedDateTime may actually be validated.
2024-11-26 11:00:56 +01:00
Timothy Flynn
8ab765a3eb LibJS: Invoke CalendarDateToISO recursively correctly
Copy-paste mistake that becomes apparent in Temporal.ZonedDateTime
tests.
2024-11-26 11:00:56 +01:00
Pavel Shliak
4ae3a0dcba LibJS: Make a __JS_ENUMERATE comment more informative 2024-11-25 13:17:03 -07:00
Timothy Flynn
f2c19f96f8 LibJS: Implement Temporal.Now 2024-11-25 13:32:58 +01:00