Commit graph

4235 commits

Author SHA1 Message Date
Linus Groh
d4eaaf905c LibJS: Port create_iterator_result_object() to NonnullGCPtr 2023-04-15 16:26:42 +02:00
Linus Groh
aff1ec6014 LibJS: Port iterator_step() to GCPtr 2023-04-15 16:23:03 +02:00
Linus Groh
e54536421a LibJS: Port iterator_next() to NonnullGCPtr 2023-04-15 16:22:57 +02:00
Linus Groh
b110258848 LibJS: Port this_symbol_value() to NonnullGCPtr 2023-04-15 16:06:52 +02:00
Linus Groh
dd91f1a5a5 LibJS: Port this_string_value() to NonnullGCPtr 2023-04-15 16:06:18 +02:00
Linus Groh
9c6eba771a LibJS: Port this_bigint_value() to NonnullGCPtr 2023-04-15 16:06:02 +02:00
Linus Groh
d8ee4c0e7d LibJS: Add remaining missing spec comments to StringPrototype
The changes from ac2f109 were from an old branch, which either had a
rebase accident or was simply incomplete. Should be complete now :^)
2023-04-15 16:00:59 +02:00
Linus Groh
ac2f1098f7 LibJS: Add spec comments to StringPrototype 2023-04-15 14:07:28 +02:00
Linus Groh
16197af60d LibJS: Add spec comments to StringObject 2023-04-15 14:07:28 +02:00
Linus Groh
9cf1a244f8 LibJS: Add spec comments to ProxyConstructor 2023-04-15 14:07:28 +02:00
Linus Groh
b1ea436093 LibJS: Add spec comments to ObjectPrototype 2023-04-15 14:07:28 +02:00
Linus Groh
50cb4f08a1 LibJS: Add spec comments to ObjectConstructor 2023-04-15 14:07:28 +02:00
Linus Groh
f0dd425492 LibJS: Add spec comments to Object 2023-04-15 14:07:28 +02:00
Linus Groh
63624a3a67 LibJS: Add spec comments to NumberConstructor 2023-04-15 14:07:28 +02:00
Linus Groh
23d9096541 LibJS: Add spec comments to MathObject 2023-04-15 14:07:28 +02:00
Linus Groh
f3f78642f4 LibJS: Add spec comments to MapPrototype 2023-04-15 14:07:28 +02:00
Linus Groh
2140200a19 LibJS: Add spec comments to GlobalObject 2023-04-15 14:07:28 +02:00
Linus Groh
89503a0cfe LibJS: Port PrototypeObject::typed_this_value() to NonnullGCPtr 2023-04-14 09:59:29 +02:00
Linus Groh
a23dd88f61 LibJS: Port PrototypeObject::typed_this_object() to NonnullGCPtr 2023-04-14 09:59:29 +02:00
Linus Groh
15360e50d3 LibJS: Port PrototypeObject::this_object() to NonnullGCPtr 2023-04-14 09:59:29 +02:00
Linus Groh
b33b0d60e6 LibJS: Port Value::get_method() to GCPtr 2023-04-14 09:59:29 +02:00
Linus Groh
9279b0780d LibJS: Port Value::to_bigint() to NonnullGCPtr 2023-04-14 09:59:29 +02:00
Linus Groh
f345f72b55 LibJS: Port Value::to_object() to NonnullGCPtr 2023-04-14 09:59:29 +02:00
Linus Groh
e79f5b6e85 LibJS: Port Value::to_primitive_string() to NonnullGCPtr 2023-04-14 09:59:29 +02:00
Linus Groh
2555d7a36a LibJS: Make well-known symbol getters return NonnullGCPtr
None of these are ever null after the VM has been initialized, as proved
by virtually every caller immediately dereferencing the raw pointer.
2023-04-13 14:29:42 +02:00
Linus Groh
b84f8fb55b LibJS: Make intrinsics getters return NonnullGCPtr
Some of these are allocated upon initialization of the intrinsics, and
some lazily, but in neither case the getters actually return a nullptr.

This saves us a whole bunch of pointer dereferences (as NonnullGCPtr has
an `operator T&()`), and also has the interesting side effect of forcing
us to explicitly use the FunctionObject& overload of call(), as passing
a NonnullGCPtr is ambigous - it could implicitly be turned into a Value
_or_ a FunctionObject& (so we have to dereference manually).
2023-04-13 14:29:42 +02:00
Linus Groh
ed9e2366da LibJS: Add spec comments to WeakSetPrototype 2023-04-13 13:04:44 +02:00
Linus Groh
bccffed7e9 LibJS: Add spec comments to WeakSetConstructor 2023-04-13 13:04:44 +02:00
Linus Groh
77fc05afd6 LibJS: Add spec comments to WeakRefPrototype 2023-04-13 13:04:44 +02:00
Linus Groh
7c9f1dcced LibJS: Add spec comments to WeakRefConstructor 2023-04-13 13:04:44 +02:00
Linus Groh
7bf92b5c3b LibJS: Add spec comments to WeakMapPrototype 2023-04-13 13:04:44 +02:00
Linus Groh
627dc1b88b LibJS: Add spec comments to WeakMapConstructor 2023-04-13 13:04:44 +02:00
Linus Groh
89bcc05a0d LibJS: Add spec comments to TypedArrayPrototype 2023-04-13 13:04:44 +02:00
Linus Groh
aefa053473 LibJS: Add spec comments to TypedArrayConstructor 2023-04-13 13:04:44 +02:00
Linus Groh
81c6ad047a LibJS: Add spec comments to SymbolPrototype 2023-04-13 13:04:44 +02:00
Linus Groh
0ae511edae LibJS: Add spec comments to SymbolConstructor 2023-04-13 13:04:44 +02:00
Linus Groh
066133d97b LibJS: Add spec comments to StringConstructor 2023-04-13 13:04:44 +02:00
Linus Groh
1b3c3f9777 LibJS: Add spec comments to SetPrototype 2023-04-13 13:04:44 +02:00
Linus Groh
58566d2a3f LibJS: Add spec comments to SetConstructor 2023-04-13 13:04:44 +02:00
Timothy Flynn
f816a24b86 LibJS: Update spec numbers for the Intl NumberFormat v3 proposal
This proposal has been merged into the main ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/4257160

Note this includes some editorial and normative changes made when the
proposal was merged into the main spec, but are not in the proposal spec
itself. In particular, the following AOs were changed:

    PartitionNumberRangePattern (normative)
    SetNumberFormatDigitOptions (editorial)
2023-04-11 23:22:32 +02:00
Timothy Flynn
b411e30024 LibJS: Require a [[RoundingMode]] slot within FormatNumericToString
This was optional to work around a spec issue. That issue was fixed and
brought into LibJS in commit 5b3b14b, but this FIXME was neglected.
2023-04-11 23:22:32 +02:00
Ben Wiederhake
560133a0c6 Everywhere: Remove unused DeprecatedString includes 2023-04-09 22:00:54 +02:00
Timothy Flynn
a8fce9eec2 LibJS: Update spec numbers for the Intl Enumeration proposal
This proposal has been merged into the main ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/81856b3
2023-04-07 20:50:50 +02:00
Linus Groh
3709d11212 LibJS: Parse secondary expressions with the original forbidden token set
Instead of passing the continuously merged initial forbidden token set
(with the new additional forbidden tokens from each parsed secondary
expression) to the next call of parse_secondary_expression(), keep a
copy of the original set and use it as the base for parsing the next
secondary expression.

This bug prevented us from properly parsing the following expression:

```js
0 ?? 0 ? 0 : 0 || 0
```

...due to LogicalExpression with LogicalOp::NullishCoalescing returning
both DoubleAmpersand and DoublePipe in its forbidden token set.

The following correct AST is now generated:

Program
  (Children)
    ExpressionStatement
      ConditionalExpression
        (Test)
          LogicalExpression
            NumericLiteral 0
            ??
            NumericLiteral 0
        (Consequent)
          NumericLiteral 0
        (Alternate)
          LogicalExpression
            NumericLiteral 0
            ||
            NumericLiteral 0

An alternate solution I explored was only merging the original forbidden
token set with the one of the last parsed secondary expression which is
then passed to match_secondary_expression(); however that led to an
incorrect AST (note the alternate expression):

Program
  (Children)
    ExpressionStatement
      LogicalExpression
        ConditionalExpression
          (Test)
            LogicalExpression
              NumericLiteral 0
              ??
              NumericLiteral 0
          (Consequent)
            NumericLiteral 0
          (Alternate)
            NumericLiteral 0
        ||
        NumericLiteral 0

Truth be told, I don't know enough about the inner workings of the
parser to fully explain the difference. AFAICT this patch has no
unintended side effects in its current form though.

Fixes #18087.
2023-04-02 06:45:37 +02:00
Andreas Kling
b727f8113f LibJS: Add fast path to Value::to_u32() if Value is a positive i32
6.6% speed-up on Kraken's stanford-crypto-aes subtest. :^)
2023-03-30 19:13:35 +01:00
Hendiadyoin1
b76d3f287f LibJS: Make yy{/,-}mm{/,-}dd hh:mm test timezone independent
Otherwise this will fail in non UTC timezones.
2023-03-23 13:33:03 -04:00
Timothy Flynn
6d49eab8a6 LibJS+LibTimeZone: Explicitly canonicalize "GMT" to "UTC"
This is a normative change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/50eb413

Note that this canonicalization already occurred. As the above commit
alludes to, we parse the rearguard format of the TZDB, so GMT is already
an alias to Etc/GMT. But it doesn't hurt to be explicit here.
2023-03-23 15:30:21 +00:00
Timothy Flynn
c5c6065611 LibJS: Add missing internal slots to creation of Intl.DateTimeFormat
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/f6c0c41
2023-03-23 15:30:21 +00:00
Timothy Flynn
a13b6a3cb0 LibJS: Remove ! from AO calls that can't throw from Intl.DateTimeFormat
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/8f9080e
2023-03-23 15:30:21 +00:00
Timothy Flynn
b74786d3c3 LibJS: Explicitly provide all GetIterator arguments from Intl.ListFormat
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/13895c8
2023-03-23 15:30:21 +00:00