Commit graph

75 commits

Author SHA1 Message Date
Linus Groh
5db38d7ba1 LibJS: Replace standalone js_bigint() with BigInt::create()
Three standalone Cell creation functions remain in the JS namespace:

- js_bigint()
- js_string()
- js_symbol()

All of them are leftovers from early iterations when LibJS still took
inspiration from JSC, which itself has jsString(). Nowadays, we pretty
much exclusively use static create() functions to construct types
allocated on the JS heap, and there's no reason to not do the same for
these.
Also change the return type from BigInt* to NonnullGCPtr<BigInt> while
we're here.

This is patch 1/3, replacement of js_string() and js_symbol() follow.
2022-12-07 16:43:06 +00:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Andreas Kling
71067cbc6c LibJS+LibWeb: Make Runtime/AbstractOperations.h not include AST.h
This led to considerable fallout and many files had to be patched with
now-missing include statements.
2022-11-23 16:05:59 +00:00
Luke Wilde
b26b18a0bc LibJS: Add timeZoneName: "critical" option to ZonedDateTime.toString()
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d84937f
2022-11-03 19:15:50 +00:00
Moustafa Raafat
939374a037 LibJS: Use the UnsignedBigInteger compare_to_double algorithm
This also avoids an unnecessary copy
2022-11-02 22:04:34 -06:00
Moustafa Raafat
54b8a2b094 LibCrypto: Add a way to compare UnsignedBigInteger with double
This patch also make SignedBigInteger::compare_to_double make use
of the new function.
2022-11-02 22:04:34 -06:00
Moustafa Raafat
5edd4bd512 LibJS: Require NanosecondsToDays remainder less than dayLength
This is an normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/ac69b63
2022-10-22 19:14:14 +02:00
Moustafa Raafat
b1c8029c2b LibJS: Require that NanosecondsToDays doesn't flip sign
This is an normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/e13c52d
2022-10-22 19:14:14 +02:00
Linus Groh
57162ad510 LibJS: Rename IsValidTimeZoneName to IsAvailableTimeZoneName
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/873313b
2022-10-17 12:56:05 +02:00
Timothy Flynn
443ffab9dc LibJS: Use infallible ParseTimeZoneOffsetString
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/654e300
2022-10-15 18:05:02 +02:00
Timothy Flynn
1a84dbcb07 LibJS: Replace GetEpochFromISOParts with GetUTCEpochNanoseconds
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/1b051cc

Note that since Date's implementation of this AO uses Crypto bigints
rather than allocating JS bigints, this change has the fallout of
removing some unused VM parameters and adding an overload of the
IsValidEpochNanoseconds AO for use without a JS::BigInt.
2022-10-15 18:05:02 +02:00
Timothy Flynn
4fbec2e8b3 LibJS: Replace RoundTowardsZero with truncate
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/409ab66
2022-10-15 18:05:02 +02:00
snooze6214
1fde3737f4 LibJS: Move time zone annotation parsing into ParseISODateTime
This is an editorial change in the Temporal spec.

See: tc39/proposal-temporal@c410e25e47
2022-10-15 05:09:09 +00:00
Linus Groh
50428ea8d2 LibJS: Move intrinsics to the realm
Intrinsics, i.e. mostly constructor and prototype objects, but also
things like empty and new object shape now live on a new heap-allocated
JS::Intrinsics object, thus completing the long journey of taking all
the magic away from the global object.
This represents the Realm's [[Intrinsics]] slot in the spec and matches
its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of
architecture.

In the majority of cases it should now be possibly to fully allocate a
regular object without the global object existing, and in fact that's
what we do now - the realm is allocated before the global object, and
the intrinsics between both :^)
2022-08-27 11:29:10 +01:00
davidot
6989f304bc LibJS: Remove now unnecessary i32 casts when constructing BigIntegers 2022-08-26 19:18:26 +01:00
davidot
791855deab LibCrypto+LibJS: Remove the create_from methods from BigInteger
Instead we just use a specific constructor. With this set of
constructors using curly braces for constructing is highly recommended.
As then it will not do too many implicit conversions which could lead to
unexpected loss of data or calling the much slower double constructor.

Also to ensure we don't feed (Un)SignedBigInteger infinities we throw
RangeError earlier for Durations.
2022-08-26 19:18:26 +01:00
Luke Wilde
54bb6bf2c0 LibJS: Avoid calling ToString on calendar when calendarName is "never"
This is a normative change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/6122f4e
- https://github.com/tc39/proposal-temporal/commit/cf586bc
2022-08-25 21:11:23 +01:00
Linus Groh
b345a0acca LibJS+LibWeb: Reduce use of GlobalObject as an intermediary
- Prefer VM::current_realm() over GlobalObject::associated_realm()
- Prefer VM::heap() over GlobalObject::heap()
- Prefer Cell::vm() over Cell::global_object()
- Prefer Wrapper::vm() over Wrapper::global_object()
- Inline Realm::global_object() calls used to access intrinsics as they
  will later perform a direct lookup without going through the global
  object
2022-08-23 13:58:30 +01:00
Linus Groh
25849f8a6d LibJS: Replace GlobalObject with VM in common AOs [Part 18/19] 2022-08-23 13:58:30 +01:00
Linus Groh
a022e548b8 LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]
This is where the fun begins. :^)
2022-08-23 13:58:30 +01:00
Linus Groh
694f66b5ca LibJS: Replace GlobalObject with VM in Temporal AOs [Part 2/19] 2022-08-23 13:58:30 +01:00
Linus Groh
f3117d46dc LibJS: Remove GlobalObject from VM::throw_completion()
This is a continuation of the previous five commits.

A first big step into the direction of no longer having to pass a realm
(or currently, a global object) trough layers upon layers of AOs!
Unlike the create() APIs we can safely assume that this is only ever
called when a running execution context and therefore current realm
exists. If not, you can always manually allocate the Error and put it in
a Completion :^)

In the spec, throw exceptions implicitly use the current realm's
intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-08-23 13:58:30 +01:00
Linus Groh
b99cc7d050 LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits.

As allocating a JS cell already primarily involves a realm instead of a
global object, and we'll need to pass one to the allocate() function
itself eventually (it's bridged via the global object right now), the
create() functions need to receive a realm as well.
The plan is for this to be the highest-level function that actually
receives a realm and passes it around, AOs on an even higher level will
use the "current realm" concept via VM::current_realm() as that's what
the spec assumes; passing around realms (or global objects, for that
matter) on higher AO levels is pointless and unlike for allocating
individual objects, which may happen outside of regular JS execution, we
don't need control over the specific realm that is being used there.
2022-08-23 13:58:30 +01:00
Timothy Flynn
a712c7b5e1 LibJS: Replace comparisons of "0"_bigint with SignedBigInteger::is_zero
This just avoids creating UnsignedBigInteger's underlying vector.
2022-07-18 08:51:07 +01:00
Linus Groh
ee0d5d6649 LibJS: Refactor common option reading into the GetDifferenceSettings AO
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/78abbb8
2022-06-24 22:12:03 +01:00
Linus Groh
3679f671b9 LibJS: Mark some calls of CreateTemporalDate as infallible
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/30344e8
2022-06-24 22:12:03 +01:00
Linus Groh
7b5a7e7759 LibJS: Check for invalid epoch nanoseconds in NanosecondsToDays
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/f1f016e
2022-06-24 22:12:03 +01:00
Linus Groh
ddea6d451b LibJS: Check for invalid epoch nanoseconds in InterpretISODateTimeOffset
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/cdfe4a5
2022-06-24 22:12:03 +01:00
Linus Groh
2c647da0b5 LibJS: Mark AddInstant in AddZonedDateTime as fallible
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/8bc0f98
2022-06-15 17:49:20 +01:00
Linus Groh
36ef604905 LibJS: Assume options is an object in the DifferenceZonedDateTime AO
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/a6662f1
2022-06-15 17:49:20 +01:00
Linus Groh
52a4ee563d LibJS: Assume options is an object in the MergeLargestUnitOption AO
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/20a04ac
2022-06-15 17:49:20 +01:00
Linus Groh
8be4cc9653 LibJS: Make options mandatory in Difference{Zoned,ISO}DateTime
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d4c4a16
2022-06-15 17:49:20 +01:00
Linus Groh
be2c86002a LibJS: Handle absent options in DifferenceZonedDateTime
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/edc223c
2022-06-15 17:49:20 +01:00
Linus Groh
9b3602d000 LibJS: Update missing/superfluous commas in various spec comments
These are editorial changes in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/9586746
- https://github.com/tc39/proposal-temporal/commit/3c76ecc
- https://github.com/tc39/proposal-temporal/commit/96eab07
2022-06-15 17:49:20 +01:00
Linus Groh
3e6561c75f LibJS: Fold PreparePartialTemporalFields into PrepareTemporalFields
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6ed1835
2022-06-15 17:49:20 +01:00
Linus Groh
4c77575ec5 LibJS: Simplify Temporal unit AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/1b3d018
2022-06-10 12:39:11 +02:00
Linus Groh
ae1fdf299d LibJS: Use the rounding abstract operations from Intl.NumberFormat V3
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/75279e5

Co-Authored-By: Idan Horowitz <idan.horowitz@gmail.com>
2022-05-25 00:25:23 +01:00
Linus Groh
74695ce76e LibJS: Mark two Get operations in ToTemporalZonedDateTime infallible
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/fed9f16
2022-05-17 21:24:50 +01:00
Linus Groh
80048c694a LibJS: Use '2 × nsMaxInstant' in a couple of assertion comments
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/a225863
2022-05-09 20:27:20 +02:00
Linus Groh
cc8f5151d7 LibJS: Refactor Temporal since/until to common AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/85a9f57
2022-05-08 00:07:58 +02:00
Linus Groh
c6f7214a60 LibJS: Replace magic nanosecond numbers with constants
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/3fdbfda
2022-05-08 00:07:58 +02:00
Linus Groh
3729a910f6 LibJS: Refactor Temporal add/subtract to common AOs
This is an editorial change in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/2f96efc
- https://github.com/tc39/proposal-temporal/commit/fbff635
2022-05-08 00:07:58 +02:00
Linus Groh
27793bf76c LibJS: Replace U+2212 MINUS SIGN with U+002D HYPHEN-MINUS
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/bbcd37b
2022-04-29 22:40:46 +02:00
Linus Groh
76a6bd0e75 LibJS: Fix numeric type confusion in GetEpochFromISOParts return value
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/2a59eac
2022-04-29 22:40:46 +02:00
Linus Groh
70593b7448 LibJS: Update for structured headers added to various Temporal AOs
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/e6a15a5
2022-04-29 22:40:46 +02:00
Linus Groh
9a3014c91a LibJS: Drop "integral part of" language
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6ec1608
2022-04-29 22:40:46 +02:00
Luke Wilde
c32dcf7f75 LibJS: Update ZonedDateTime AO spec comments for structured headers
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/01714a5
2022-04-11 23:47:02 +01:00
Linus Groh
e109b967a1 LibJS: Make options object const in more Temporal AOs 2022-04-08 00:43:17 +01:00
Linus Groh
151eb8606d LibJS: Consistently call observable Temporal AOs with undefined options
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6fa5b9d
2022-04-07 12:58:39 +01:00
Linus Groh
ff3256792d LibJS: Change nanoseconds_to_days() argument from a JS to Crypto BigInt
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/0b1346c
2022-03-19 19:28:49 +00:00