Commit graph

1273 commits

Author SHA1 Message Date
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
47ba231a9b LibJS: Do not consume "with" tokens in import statements as identifiers
The "with" statement is its own token (TokenType::With), and thus would
fail to parse as an identifier. We've already asserted that the token
we are parsing is "with" or "assert", so just consume it.
2025-01-21 14:58:32 +01:00
Timothy Flynn
2c3077d929 LibJS: Implement InnerModuleLoading as a free function
It is currently implemented as a member of CyclicModule. However, as the
spec indicates, this must be invokable with non-CyclicModule modules. In
several of the call sites, we are blindly casting to a CyclicModule;
this will fail for e.g. JSON modules.
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
7d420bbd3d LibJS: Update the noted grammar for ImportDeclaration 2025-01-21 14:58:32 +01:00
Timothy Flynn
263fd9b7c6 LibJS: Add missing spec prose to FinishLoadingImportedModule 2025-01-21 14:58:32 +01:00
Timothy Flynn
6a564376fc Meta+LibUnicode+LibJS: Upgrade to ICU 76.1
This updates our local ICU overlay port to use ICU 76.1. This includes
Unicode 16 and CLDR 46.

Upstream vcpkg is not able to supply versions past 74 yet due to various
dependency issues, but we are able to use this version ourselves. The
overlay port now includes a patch to revert ICU's dependence on autoconf
2.72 for now, as this version is not yet available on all systems.

All of the test changes were cross-referenced with Firefox to ensure
correctness.
2025-01-18 17:56:40 -05:00
Timothy Flynn
0763997591 LibJS: Ensure tests using the "ar" locale use the "arab" number system
In ICU 76, the default was changed from "arab" to "latn". See:
c149724509

The whole point of these tests was to use a non-Latin numbering system.
This patch ensures that is the case to make following patches easier to
grok.
2025-01-18 17:56:40 -05: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
f82b1c5a2d LibJS: Alphabetically sort the list of well-known symbols 2025-01-17 20:46:32 +01:00
Luke Wilde
a588756105 LibJS: Use correct this value for tagged template literals with members
Required by creepjs, which does Date().split` `[3] to get the current
year.
2025-01-17 17:15:12 +01:00
Luke Wilde
5f33383a7b LibJS: Propagate direct eval presence if the current scope is screwed
Previously it only deoptimized the parent scope if the current scope
contains direct eval, which is incorrect because code ran in direct
eval mode has access to the entire scope chain it was executed in.
The fix is to also propagate direct eval's presence if the current
scope is marked as being screwed by direct eval.

This fixes Google's botguard failing to complete on Google sign in, as
it tried to access local variables outside of a direct parent function
with eval, causing it throw "unhandled" exceptions. Unhandled is in
quotes because their bytecode VM _technically_ caught it, but it was
considered an unhandled exception. This was determined by removing get
optimizations and then adding debug output for every get operation.
Using this, I noticed that for these errors, it would access the
'message' and 'stack' properties. This is because their error handler
function noticed this was not a synthesised error, which is never
expected to happen. That was determined by using Chrome Devtools 'pause
on handled exception' feature, and noticing it never threw a '[var] is
not defined' exception, but only synthesized error objects which
contained a sentinel value to let it know it was synthesized.

I added debug output to eval to print out what was being eval'd because
it makes heavy use of eval. This revealed that the exceptions only came
from eval.

I then dumped every generated executable and noticed the variables it
was trying to access were generated as local variables in the top
scope. This led to checking what makes a variable considered local or
not, which then lead to this block of code in ~ScopePusher that
propagates eval presence only to the immediate parent scope. This
variable directly controls whether to create all variables properly
with variable environments and bindings or allow them to be stored as
local registers tied to that function's executable.

Since this now lets botguard run to completion, it no longer considers
us to be an insecure/potential bot browser when signing in, now
allowing us to be able to sign in to Google.
2025-01-17 14:36:03 +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
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: 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:

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:
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
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:
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