From 5db38d7ba1a8caa5138dd65cc06be0c0e5a568e4 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 6 Dec 2022 22:03:52 +0000 Subject: [PATCH] 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 while we're here. This is patch 1/3, replacement of js_string() and js_symbol() follow. --- Tests/LibWasm/test-wasm.cpp | 4 +-- Userland/Libraries/LibJS/AST.cpp | 13 +++---- Userland/Libraries/LibJS/Bytecode/Op.cpp | 7 ++-- .../Libraries/LibJS/Runtime/ArrayBuffer.h | 4 +-- Userland/Libraries/LibJS/Runtime/BigInt.cpp | 17 ++++----- Userland/Libraries/LibJS/Runtime/BigInt.h | 4 +-- .../LibJS/Runtime/BigIntConstructor.cpp | 8 ++--- .../Libraries/LibJS/Runtime/DatePrototype.cpp | 2 +- .../LibJS/Runtime/Intl/MathematicalValue.cpp | 2 +- .../LibJS/Runtime/Temporal/Duration.cpp | 2 +- .../LibJS/Runtime/Temporal/Instant.cpp | 10 +++--- .../Runtime/Temporal/InstantConstructor.cpp | 20 +++++------ .../Runtime/Temporal/InstantPrototype.cpp | 2 +- .../Libraries/LibJS/Runtime/Temporal/Now.cpp | 2 +- .../LibJS/Runtime/Temporal/TimeZone.cpp | 14 ++++---- .../Runtime/Temporal/TimeZonePrototype.cpp | 4 +-- .../LibJS/Runtime/Temporal/ZonedDateTime.cpp | 16 ++++----- .../Temporal/ZonedDateTimePrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Value.cpp | 36 +++++++++---------- 19 files changed, 83 insertions(+), 86 deletions(-) diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index 22b510c1e1b..c339c70726f 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -174,7 +174,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export) return m_machine.store().get(*v)->value().value().visit( [&](auto const& value) -> JS::Value { return JS::Value(static_cast(value)); }, [&](i32 value) { return JS::Value(static_cast(value)); }, - [&](i64 value) -> JS::Value { return JS::js_bigint(vm, Crypto::SignedBigInteger { value }); }, + [&](i64 value) -> JS::Value { return JS::BigInt::create(vm, Crypto::SignedBigInteger { value }); }, [&](Wasm::Reference const& reference) -> JS::Value { return reference.ref().visit( [&](const Wasm::Reference::Null&) -> JS::Value { return JS::js_null(); }, @@ -253,7 +253,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke) result.values().first().value().visit( [&](auto const& value) { return_value = JS::Value(static_cast(value)); }, [&](i32 value) { return_value = JS::Value(static_cast(value)); }, - [&](i64 value) { return_value = JS::Value(JS::js_bigint(vm, Crypto::SignedBigInteger { value })); }, + [&](i64 value) { return_value = JS::Value(JS::BigInt::create(vm, Crypto::SignedBigInteger { value })); }, [&](Wasm::Reference const& reference) { reference.ref().visit( [&](const Wasm::Reference::Null&) { return_value = JS::js_null(); }, diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 46c75331af3..c0f8364304a 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -2817,7 +2817,7 @@ Completion UpdateExpression::execute(Interpreter& interpreter) const else { // a. Assert: Type(oldValue) is BigInt. // b. Let newValue be BigInt::add(oldValue, 1ℤ). - new_value = js_bigint(interpreter.heap(), old_value.as_bigint().big_integer().plus(Crypto::SignedBigInteger { 1 })); + new_value = BigInt::create(vm, old_value.as_bigint().big_integer().plus(Crypto::SignedBigInteger { 1 })); } break; case UpdateOp::Decrement: @@ -2830,7 +2830,7 @@ Completion UpdateExpression::execute(Interpreter& interpreter) const else { // a. Assert: Type(oldValue) is BigInt. // b. Let newValue be BigInt::subtract(oldValue, 1ℤ). - new_value = js_bigint(interpreter.heap(), old_value.as_bigint().big_integer().minus(Crypto::SignedBigInteger { 1 })); + new_value = BigInt::create(vm, old_value.as_bigint().big_integer().minus(Crypto::SignedBigInteger { 1 })); } break; default: @@ -3483,19 +3483,20 @@ Completion NumericLiteral::execute(Interpreter& interpreter) const Completion BigIntLiteral::execute(Interpreter& interpreter) const { InterpreterNodeScope node_scope { interpreter, *this }; + auto& vm = interpreter.vm(); // 1. Return the NumericValue of NumericLiteral as defined in 12.8.3. Crypto::SignedBigInteger integer; if (m_value[0] == '0' && m_value.length() >= 3) { if (m_value[1] == 'x' || m_value[1] == 'X') { - return Value { js_bigint(interpreter.heap(), Crypto::SignedBigInteger::from_base(16, m_value.substring(2, m_value.length() - 3))) }; + return Value { BigInt::create(vm, Crypto::SignedBigInteger::from_base(16, m_value.substring(2, m_value.length() - 3))) }; } else if (m_value[1] == 'o' || m_value[1] == 'O') { - return Value { js_bigint(interpreter.heap(), Crypto::SignedBigInteger::from_base(8, m_value.substring(2, m_value.length() - 3))) }; + return Value { BigInt::create(vm, Crypto::SignedBigInteger::from_base(8, m_value.substring(2, m_value.length() - 3))) }; } else if (m_value[1] == 'b' || m_value[1] == 'B') { - return Value { js_bigint(interpreter.heap(), Crypto::SignedBigInteger::from_base(2, m_value.substring(2, m_value.length() - 3))) }; + return Value { BigInt::create(vm, Crypto::SignedBigInteger::from_base(2, m_value.substring(2, m_value.length() - 3))) }; } } - return Value { js_bigint(interpreter.heap(), Crypto::SignedBigInteger::from_base(10, m_value.substring(0, m_value.length() - 1))) }; + return Value { BigInt::create(vm, Crypto::SignedBigInteger::from_base(10, m_value.substring(0, m_value.length() - 1))) }; } // 13.2.3.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-literals-runtime-semantics-evaluation diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 5866a4dcc2d..a500b297eb3 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -169,7 +169,8 @@ JS_ENUMERATE_COMMON_UNARY_OPS(JS_DEFINE_COMMON_UNARY_OP) ThrowCompletionOr NewBigInt::execute_impl(Bytecode::Interpreter& interpreter) const { - interpreter.accumulator() = js_bigint(interpreter.vm().heap(), m_bigint); + auto& vm = interpreter.vm(); + interpreter.accumulator() = BigInt::create(vm, m_bigint); return {}; } @@ -706,7 +707,7 @@ ThrowCompletionOr Increment::execute_impl(Bytecode::Interpreter& interpret if (old_value.is_number()) interpreter.accumulator() = Value(old_value.as_double() + 1); else - interpreter.accumulator() = js_bigint(vm, old_value.as_bigint().big_integer().plus(Crypto::SignedBigInteger { 1 })); + interpreter.accumulator() = BigInt::create(vm, old_value.as_bigint().big_integer().plus(Crypto::SignedBigInteger { 1 })); return {}; } @@ -718,7 +719,7 @@ ThrowCompletionOr Decrement::execute_impl(Bytecode::Interpreter& interpret if (old_value.is_number()) interpreter.accumulator() = Value(old_value.as_double() - 1); else - interpreter.accumulator() = js_bigint(vm, old_value.as_bigint().big_integer().minus(Crypto::SignedBigInteger { 1 })); + interpreter.accumulator() = BigInt::create(vm, old_value.as_bigint().big_integer().minus(Crypto::SignedBigInteger { 1 })); return {}; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h index 34f4655654a..09fc8739474 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h @@ -111,10 +111,10 @@ static Value raw_bytes_to_numeric(VM& vm, ByteBuffer raw_value, bool is_little_e if constexpr (sizeof(UnderlyingBufferDataType) == 8) { if constexpr (IsSigned) { static_assert(IsSame); - return js_bigint(vm, Crypto::SignedBigInteger { int_value }); + return BigInt::create(vm, Crypto::SignedBigInteger { int_value }); } else { static_assert(IsOneOf); - return js_bigint(vm, Crypto::SignedBigInteger { Crypto::UnsignedBigInteger { int_value } }); + return BigInt::create(vm, Crypto::SignedBigInteger { Crypto::UnsignedBigInteger { int_value } }); } } else { return Value(int_value); diff --git a/Userland/Libraries/LibJS/Runtime/BigInt.cpp b/Userland/Libraries/LibJS/Runtime/BigInt.cpp index acddf5e9e9a..86691727e2c 100644 --- a/Userland/Libraries/LibJS/Runtime/BigInt.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigInt.cpp @@ -11,22 +11,17 @@ namespace JS { +NonnullGCPtr BigInt::create(VM& vm, Crypto::SignedBigInteger big_integer) +{ + return *vm.heap().allocate_without_realm(move(big_integer)); +} + BigInt::BigInt(Crypto::SignedBigInteger big_integer) : m_big_integer(move(big_integer)) { VERIFY(!m_big_integer.is_invalid()); } -BigInt* js_bigint(Heap& heap, Crypto::SignedBigInteger big_integer) -{ - return heap.allocate_without_realm(move(big_integer)); -} - -BigInt* js_bigint(VM& vm, Crypto::SignedBigInteger big_integer) -{ - return js_bigint(vm.heap(), move(big_integer)); -} - // 21.2.1.1.1 NumberToBigInt ( number ), https://tc39.es/ecma262/#sec-numbertobigint ThrowCompletionOr number_to_bigint(VM& vm, Value number) { @@ -37,7 +32,7 @@ ThrowCompletionOr number_to_bigint(VM& vm, Value number) return vm.throw_completion(ErrorType::BigIntFromNonIntegral); // 2. Return the BigInt value that represents ℝ(number). - return js_bigint(vm, Crypto::SignedBigInteger { number.as_double() }); + return BigInt::create(vm, Crypto::SignedBigInteger { number.as_double() }).ptr(); } } diff --git a/Userland/Libraries/LibJS/Runtime/BigInt.h b/Userland/Libraries/LibJS/Runtime/BigInt.h index 8c58a58df67..8a853933faa 100644 --- a/Userland/Libraries/LibJS/Runtime/BigInt.h +++ b/Userland/Libraries/LibJS/Runtime/BigInt.h @@ -16,6 +16,8 @@ class BigInt final : public Cell { JS_CELL(BigInt, Cell); public: + [[nodiscard]] static NonnullGCPtr create(VM&, Crypto::SignedBigInteger); + virtual ~BigInt() override = default; Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; } @@ -27,8 +29,6 @@ private: Crypto::SignedBigInteger m_big_integer; }; -BigInt* js_bigint(Heap&, Crypto::SignedBigInteger); -BigInt* js_bigint(VM&, Crypto::SignedBigInteger); ThrowCompletionOr number_to_bigint(VM&, Value); } diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp index 3142f41fd72..c8bf3c2ead4 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -80,11 +80,11 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntConstructor::as_int_n) // NOTE: Some of the below conditionals are non-standard, but are to protect SignedBigInteger from // allocating an absurd amount of memory if `bits - 1` overflows to NumericLimits::max. if ((bits == 0) && (mod >= BIGINT_ONE)) - return js_bigint(vm, mod.minus(bits_shift_left)); + return BigInt::create(vm, mod.minus(bits_shift_left)); if ((bits > 0) && (mod >= BIGINT_ONE.shift_left(bits - 1))) - return js_bigint(vm, mod.minus(bits_shift_left)); + return BigInt::create(vm, mod.minus(bits_shift_left)); - return js_bigint(vm, mod); + return BigInt::create(vm, mod); } // 21.2.2.2 BigInt.asUintN ( bits, bigint ), https://tc39.es/ecma262/#sec-bigint.asuintn @@ -99,7 +99,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntConstructor::as_uint_n) // 3. Return the BigInt value that represents ℝ(bigint) modulo 2bits. // FIXME: For large values of `bits`, this can likely be improved with a SignedBigInteger API to // drop the most significant bits. - return js_bigint(vm, modulo(bigint->big_integer(), BIGINT_ONE.shift_left(bits))); + return BigInt::create(vm, modulo(bigint->big_integer(), BIGINT_ONE.shift_left(bits))); } } diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 627454334eb..5d5decc61dc 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -1194,7 +1194,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_temporal_instant) // 2. Let ns be ? NumberToBigInt(t) × ℤ(10^6). auto* ns = TRY(number_to_bigint(vm, Value(t))); - ns = js_bigint(vm, ns->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000 })); + ns = BigInt::create(vm, ns->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000 })); // 3. Return ! CreateTemporalInstant(ns). return MUST(Temporal::create_temporal_instant(vm, *ns)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.cpp b/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.cpp index 8cfc51906c3..ca4705baa87 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.cpp @@ -308,7 +308,7 @@ Value MathematicalValue::to_value(VM& vm) const return Value(value); }, [&](Crypto::SignedBigInteger const& value) { - return Value(js_bigint(vm, value)); + return Value(BigInt::create(vm, value)); }, [](auto symbol) { switch (symbol) { diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index a67171b5a90..ad9be9e7aba 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -1642,7 +1642,7 @@ ThrowCompletionOr adjust_rounded_duration_days(VM& vm, double ye } // 10. Set timeRemainderNs to ! RoundTemporalInstant(ℤ(timeRemainderNs - dayLengthNs), increment, unit, roundingMode). - time_remainder_ns = round_temporal_instant(vm, *js_bigint(vm, time_remainder_ns.minus(day_length_ns)), increment, unit, rounding_mode)->big_integer(); + time_remainder_ns = round_temporal_instant(vm, BigInt::create(vm, time_remainder_ns.minus(day_length_ns)), increment, unit, rounding_mode)->big_integer(); // 11. Let adjustedDateDuration be ? AddDuration(years, months, weeks, days, 0, 0, 0, 0, 0, 0, 0, 0, 0, direction, 0, 0, 0, 0, 0, 0, relativeTo). auto adjusted_date_duration = TRY(add_duration(vm, years, months, weeks, days, 0, 0, 0, 0, 0, 0, 0, 0, 0, direction, 0, 0, 0, 0, 0, 0, &relative_to)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp index 4215d9ca6a1..534a8c84d1c 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp @@ -143,7 +143,7 @@ ThrowCompletionOr parse_temporal_instant(VM& vm, DeprecatedString const } // 9. Return result. - return js_bigint(vm, move(result_ns)); + return BigInt::create(vm, move(result_ns)).ptr(); } // 8.5.5 CompareEpochNanoseconds ( epochNanosecondsOne, epochNanosecondsTwo ), https://tc39.es/proposal-temporal/#sec-temporal-compareepochnanoseconds @@ -167,7 +167,7 @@ ThrowCompletionOr add_instant(VM& vm, BigInt const& epoch_nanoseconds, VERIFY(hours == trunc(hours) && minutes == trunc(minutes) && seconds == trunc(seconds) && milliseconds == trunc(milliseconds) && microseconds == trunc(microseconds) && nanoseconds == trunc(nanoseconds)); // 1. Let result be epochNanoseconds + ℤ(nanoseconds) + ℤ(microseconds) × 1000ℤ + ℤ(milliseconds) × 10^6ℤ + ℤ(seconds) × 10^9ℤ + ℤ(minutes) × 60ℤ × 10^9ℤ + ℤ(hours) × 3600ℤ × 10^9ℤ. - auto* result = js_bigint(vm, + auto result = BigInt::create(vm, epoch_nanoseconds.big_integer() .plus(Crypto::SignedBigInteger { nanoseconds }) .plus(Crypto::SignedBigInteger { microseconds }.multiplied_by(Crypto::SignedBigInteger { 1'000 })) @@ -181,7 +181,7 @@ ThrowCompletionOr add_instant(VM& vm, BigInt const& epoch_nanoseconds, return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // 3. Return result. - return result; + return result.ptr(); } // 8.5.7 DifferenceInstant ( ns1, ns2, roundingIncrement, smallestUnit, roundingMode ), https://tc39.es/proposal-temporal/#sec-temporal-differenceinstant @@ -191,7 +191,7 @@ BigInt* difference_instant(VM& vm, BigInt const& nanoseconds1, BigInt const& nan // 2. Assert: Type(ns2) is BigInt. // 3. Return ! RoundTemporalInstant(ns2 - ns1, roundingIncrement, smallestUnit, roundingMode). - return round_temporal_instant(vm, *js_bigint(vm, nanoseconds2.big_integer().minus(nanoseconds1.big_integer())), rounding_increment, smallest_unit, rounding_mode); + return round_temporal_instant(vm, BigInt::create(vm, nanoseconds2.big_integer().minus(nanoseconds1.big_integer())), rounding_increment, smallest_unit, rounding_mode); } // 8.5.8 RoundTemporalInstant ( ns, increment, unit, roundingMode ), https://tc39.es/proposal-temporal/#sec-temporal-roundtemporalinstant @@ -235,7 +235,7 @@ BigInt* round_temporal_instant(VM& vm, BigInt const& nanoseconds, u64 increment, } // 8. Return RoundNumberToIncrementAsIfPositive(ℝ(ns), incrementNs, roundingMode). - return js_bigint(vm, round_number_to_increment_as_if_positive(nanoseconds.big_integer(), increment_nanoseconds, rounding_mode)); + return BigInt::create(vm, round_number_to_increment_as_if_positive(nanoseconds.big_integer(), increment_nanoseconds, rounding_mode)); } // 8.5.9 TemporalInstantToString ( instant, timeZone, precision ), https://tc39.es/proposal-temporal/#sec-temporal-temporalinstanttostring diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp index 9f2b34e6170..ab97a62de18 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp @@ -72,7 +72,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from) // 1. If Type(item) is Object and item has an [[InitializedTemporalInstant]] internal slot, then if (item.is_object() && is(item.as_object())) { // a. Return ! CreateTemporalInstant(item.[[Nanoseconds]]). - return MUST(create_temporal_instant(vm, *js_bigint(vm, static_cast(item.as_object()).nanoseconds().big_integer()))); + return MUST(create_temporal_instant(vm, BigInt::create(vm, static_cast(item.as_object()).nanoseconds().big_integer()))); } // 2. Return ? ToTemporalInstant(item). @@ -89,14 +89,14 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_seconds) auto* epoch_seconds = TRY(number_to_bigint(vm, epoch_seconds_value)); // 3. Let epochNanoseconds be epochSeconds × 10^9ℤ. - auto* epoch_nanoseconds = js_bigint(vm, epoch_seconds->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000'000 })); + auto epoch_nanoseconds = BigInt::create(vm, epoch_seconds->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000'000 })); // 4. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception. - if (!is_valid_epoch_nanoseconds(*epoch_nanoseconds)) + if (!is_valid_epoch_nanoseconds(epoch_nanoseconds)) return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // 5. Return ! CreateTemporalInstant(epochNanoseconds). - return MUST(create_temporal_instant(vm, *epoch_nanoseconds)); + return MUST(create_temporal_instant(vm, epoch_nanoseconds)); } // 8.2.4 Temporal.Instant.fromEpochMilliseconds ( epochMilliseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochmilliseconds @@ -109,14 +109,14 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_milliseconds) auto* epoch_milliseconds = TRY(number_to_bigint(vm, epoch_milliseconds_value)); // 3. Let epochNanoseconds be epochMilliseconds × 10^6ℤ. - auto* epoch_nanoseconds = js_bigint(vm, epoch_milliseconds->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000 })); + auto epoch_nanoseconds = BigInt::create(vm, epoch_milliseconds->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000 })); // 4. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception. - if (!is_valid_epoch_nanoseconds(*epoch_nanoseconds)) + if (!is_valid_epoch_nanoseconds(epoch_nanoseconds)) return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // 5. Return ! CreateTemporalInstant(epochNanoseconds). - return MUST(create_temporal_instant(vm, *epoch_nanoseconds)); + return MUST(create_temporal_instant(vm, epoch_nanoseconds)); } // 8.2.5 Temporal.Instant.fromEpochMicroseconds ( epochMicroseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochmicroseconds @@ -126,14 +126,14 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_microseconds) auto* epoch_microseconds = TRY(vm.argument(0).to_bigint(vm)); // 2. Let epochNanoseconds be epochMicroseconds × 1000ℤ. - auto* epoch_nanoseconds = js_bigint(vm, epoch_microseconds->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000 })); + auto epoch_nanoseconds = BigInt::create(vm, epoch_microseconds->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000 })); // 3. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception. - if (!is_valid_epoch_nanoseconds(*epoch_nanoseconds)) + if (!is_valid_epoch_nanoseconds(epoch_nanoseconds)) return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // 4. Return ! CreateTemporalInstant(epochNanoseconds). - return MUST(create_temporal_instant(vm, *epoch_nanoseconds)); + return MUST(create_temporal_instant(vm, epoch_nanoseconds)); } // 8.2.6 Temporal.Instant.fromEpochNanoseconds ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochnanoseconds diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 5d530b3aaac..37d40bd3690 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -101,7 +101,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_microseconds_getter) auto [us, _] = ns.big_integer().divided_by(Crypto::UnsignedBigInteger { 1'000 }); // 5. Return ℤ(µs). - return js_bigint(vm, move(us)); + return BigInt::create(vm, move(us)); } // 8.3.6 get Temporal.Instant.prototype.epochNanoseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.instant.prototype.epochnanoseconds diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp index 786d15c8956..2b27e1be6ea 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp @@ -170,7 +170,7 @@ BigInt* system_utc_epoch_nanoseconds(VM& vm) // if an overflow occurs during seconds -> nanoseconds conversion. // 3. Return ℤ(ns). - return js_bigint(vm, move(ns)); + return BigInt::create(vm, move(ns)); } // 2.3.3 SystemInstant ( ), https://tc39.es/proposal-temporal/#sec-temporal-systeminstant diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp index 4b57afa5c0c..cfc480264b7 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp @@ -99,7 +99,7 @@ ThrowCompletionOr create_temporal_time_zone(VM& vm, DeprecatedString ISODateTime get_iso_parts_from_epoch(VM& vm, Crypto::SignedBigInteger const& epoch_nanoseconds) { // 1. Assert: ! IsValidEpochNanoseconds(ℤ(epochNanoseconds)) is true. - VERIFY(is_valid_epoch_nanoseconds(*js_bigint(vm, epoch_nanoseconds))); + VERIFY(is_valid_epoch_nanoseconds(BigInt::create(vm, epoch_nanoseconds))); // 2. Let remainderNs be epochNanoseconds modulo 10^6. auto remainder_ns_bigint = modulo(epoch_nanoseconds, Crypto::UnsignedBigInteger { 1'000'000 }); @@ -480,24 +480,24 @@ ThrowCompletionOr disambiguate_possible_instants(VM& vm, MarkedVector< auto epoch_nanoseconds = get_utc_epoch_nanoseconds(date_time.iso_year(), date_time.iso_month(), date_time.iso_day(), date_time.iso_hour(), date_time.iso_minute(), date_time.iso_second(), date_time.iso_millisecond(), date_time.iso_microsecond(), date_time.iso_nanosecond()); // 8. Let dayBeforeNs be epochNanoseconds - ℤ(nsPerDay). - auto* day_before_ns = js_bigint(vm, epoch_nanoseconds.minus(ns_per_day_bigint)); + auto day_before_ns = BigInt::create(vm, epoch_nanoseconds.minus(ns_per_day_bigint)); // 9. If ! IsValidEpochNanoseconds(dayBeforeNs) is false, throw a RangeError exception. - if (!is_valid_epoch_nanoseconds(*day_before_ns)) + if (!is_valid_epoch_nanoseconds(day_before_ns)) return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // 10. Let dayBefore be ! CreateTemporalInstant(dayBeforeNs). - auto* day_before = MUST(create_temporal_instant(vm, *day_before_ns)); + auto* day_before = MUST(create_temporal_instant(vm, day_before_ns)); // 11. Let dayAfterNs be epochNanoseconds + ℤ(nsPerDay). - auto* day_after_ns = js_bigint(vm, epoch_nanoseconds.plus(ns_per_day_bigint)); + auto day_after_ns = BigInt::create(vm, epoch_nanoseconds.plus(ns_per_day_bigint)); // 12. If ! IsValidEpochNanoseconds(dayAfterNs) is false, throw a RangeError exception. - if (!is_valid_epoch_nanoseconds(*day_after_ns)) + if (!is_valid_epoch_nanoseconds(day_after_ns)) return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // 13. Let dayAfter be ! CreateTemporalInstant(dayAfterNs). - auto* day_after = MUST(create_temporal_instant(vm, *day_after_ns)); + auto* day_after = MUST(create_temporal_instant(vm, day_after_ns)); // 14. Let offsetBefore be ? GetOffsetNanosecondsFor(timeZone, dayBefore). auto offset_before = TRY(get_offset_nanoseconds_for(vm, time_zone, *day_before)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp index 2a3c1fce575..289d8116678 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp @@ -164,8 +164,8 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_possible_instants_for) return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // b. Let instant be ! CreateTemporalInstant(epochNanoseconds). - auto* epoch_nanoseconds_bigint = js_bigint(vm, move(epoch_nanoseconds)); - auto* instant = MUST(create_temporal_instant(vm, *epoch_nanoseconds_bigint)); + auto epoch_nanoseconds_bigint = BigInt::create(vm, move(epoch_nanoseconds)); + auto* instant = MUST(create_temporal_instant(vm, epoch_nanoseconds_bigint)); // c. Append instant to possibleInstants. possible_instants.append(instant); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index d50f8e4465a..da2514b6555 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -69,7 +69,7 @@ ThrowCompletionOr interpret_iso_date_time_offset(VM& vm, i32 year return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // d. Return epochNanoseconds. - return js_bigint(vm, move(epoch_nanoseconds)); + return BigInt::create(vm, move(epoch_nanoseconds)).ptr(); } // 5. Assert: offsetBehaviour is option. @@ -471,7 +471,7 @@ ThrowCompletionOr nanoseconds_to_days(VM& vm, Crypto::S auto& start_ns = relative_to.nanoseconds().big_integer(); // 6. Let startInstant be ! CreateTemporalInstant(ℤ(startNs)). - auto* start_instant = MUST(create_temporal_instant(vm, *js_bigint(vm, start_ns))); + auto* start_instant = MUST(create_temporal_instant(vm, BigInt::create(vm, start_ns))); // 7. Let startDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(relativeTo.[[TimeZone]], startInstant, relativeTo.[[Calendar]]). auto* start_date_time = TRY(builtin_time_zone_get_plain_date_time_for(vm, &relative_to.time_zone(), *start_instant, relative_to.calendar())); @@ -479,14 +479,14 @@ ThrowCompletionOr nanoseconds_to_days(VM& vm, Crypto::S // 8. Let endNs be startNs + nanoseconds. auto end_ns = start_ns.plus(nanoseconds); - auto* end_ns_bigint = js_bigint(vm, end_ns); + auto end_ns_bigint = BigInt::create(vm, end_ns); // 9. If ! IsValidEpochNanoseconds(ℤ(endNs)) is false, throw a RangeError exception. - if (!is_valid_epoch_nanoseconds(*end_ns_bigint)) + if (!is_valid_epoch_nanoseconds(end_ns_bigint)) return vm.throw_completion(ErrorType::TemporalInvalidEpochNanoseconds); // 10. Let endInstant be ! CreateTemporalInstant(ℤ(endNs)). - auto* end_instant = MUST(create_temporal_instant(vm, *end_ns_bigint)); + auto* end_instant = MUST(create_temporal_instant(vm, end_ns_bigint)); // 11. Let endDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(relativeTo.[[TimeZone]], endInstant, relativeTo.[[Calendar]]). auto* end_date_time = TRY(builtin_time_zone_get_plain_date_time_for(vm, &relative_to.time_zone(), *end_instant, relative_to.calendar())); @@ -498,7 +498,7 @@ ThrowCompletionOr nanoseconds_to_days(VM& vm, Crypto::S auto days = date_difference.days; // 14. Let intermediateNs be ℝ(? AddZonedDateTime(ℤ(startNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, days, 0, 0, 0, 0, 0, 0)). - auto intermediate_ns = TRY(add_zoned_date_time(vm, *js_bigint(vm, start_ns), &relative_to.time_zone(), relative_to.calendar(), 0, 0, 0, days, 0, 0, 0, 0, 0, 0))->big_integer(); + auto intermediate_ns = TRY(add_zoned_date_time(vm, BigInt::create(vm, start_ns), &relative_to.time_zone(), relative_to.calendar(), 0, 0, 0, days, 0, 0, 0, 0, 0, 0))->big_integer(); // 15. If sign is 1, then if (sign == 1) { @@ -508,7 +508,7 @@ ThrowCompletionOr nanoseconds_to_days(VM& vm, Crypto::S days--; // ii. Set intermediateNs to ℝ(? AddZonedDateTime(ℤ(startNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, days, 0, 0, 0, 0, 0, 0)). - intermediate_ns = TRY(add_zoned_date_time(vm, *js_bigint(vm, start_ns), &relative_to.time_zone(), relative_to.calendar(), 0, 0, 0, days, 0, 0, 0, 0, 0, 0))->big_integer(); + intermediate_ns = TRY(add_zoned_date_time(vm, BigInt::create(vm, start_ns), &relative_to.time_zone(), relative_to.calendar(), 0, 0, 0, days, 0, 0, 0, 0, 0, 0))->big_integer(); } } @@ -519,7 +519,7 @@ ThrowCompletionOr nanoseconds_to_days(VM& vm, Crypto::S // 18. Repeat, while done is false, while (true) { // a. Let oneDayFartherNs be ℝ(? AddZonedDateTime(ℤ(intermediateNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, sign, 0, 0, 0, 0, 0, 0)). - auto one_day_farther_ns = TRY(add_zoned_date_time(vm, *js_bigint(vm, intermediate_ns), &relative_to.time_zone(), relative_to.calendar(), 0, 0, 0, sign, 0, 0, 0, 0, 0, 0))->big_integer(); + auto one_day_farther_ns = TRY(add_zoned_date_time(vm, BigInt::create(vm, intermediate_ns), &relative_to.time_zone(), relative_to.calendar(), 0, 0, 0, sign, 0, 0, 0, 0, 0, 0))->big_integer(); // b. Set dayLengthNs to oneDayFartherNs - intermediateNs. day_length_ns = one_day_farther_ns.minus(intermediate_ns); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index 5b4fa31ec41..71a6f65127f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -391,7 +391,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_microseconds_getter) auto us = ns.big_integer().divided_by(Crypto::UnsignedBigInteger { 1'000 }).quotient; // 5. Return ℤ(µs). - return js_bigint(vm, move(us)); + return BigInt::create(vm, move(us)); } // 6.3.18 get Temporal.ZonedDateTime.prototype.epochNanoseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochnanoseconds diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index cd00c14e06d..6513492394b 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -608,7 +608,7 @@ ThrowCompletionOr Value::to_bigint(VM& vm) const return vm.throw_completion(ErrorType::Convert, "null", "BigInt"); case BOOLEAN_TAG: { auto value = primitive.as_bool() ? 1 : 0; - return js_bigint(vm, Crypto::SignedBigInteger { value }); + return BigInt::create(vm, Crypto::SignedBigInteger { value }).ptr(); } case BIGINT_TAG: return &primitive.as_bigint(); @@ -695,7 +695,7 @@ static Optional string_to_bigint(VM& vm, StringView string) bigint.negate(); // 6. Return ℤ(mv). - return js_bigint(vm, move(bigint)); + return BigInt::create(vm, move(bigint)); } // 7.1.15 ToBigInt64 ( argument ), https://tc39.es/ecma262/#sec-tobigint64 @@ -1012,7 +1012,7 @@ ThrowCompletionOr bitwise_and(VM& vm, Value lhs, Value rhs) return Value(TRY(lhs_numeric.to_i32(vm)) & TRY(rhs_numeric.to_i32(vm))); } if (both_bigint(lhs_numeric, rhs_numeric)) - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().bitwise_and(rhs_numeric.as_bigint().big_integer()))); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().bitwise_and(rhs_numeric.as_bigint().big_integer())); return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "bitwise AND"); } @@ -1031,7 +1031,7 @@ ThrowCompletionOr bitwise_or(VM& vm, Value lhs, Value rhs) return Value(TRY(lhs_numeric.to_i32(vm)) | TRY(rhs_numeric.to_i32(vm))); } if (both_bigint(lhs_numeric, rhs_numeric)) - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().bitwise_or(rhs_numeric.as_bigint().big_integer()))); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().bitwise_or(rhs_numeric.as_bigint().big_integer())); return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "bitwise OR"); } @@ -1050,7 +1050,7 @@ ThrowCompletionOr bitwise_xor(VM& vm, Value lhs, Value rhs) return Value(TRY(lhs_numeric.to_i32(vm)) ^ TRY(rhs_numeric.to_i32(vm))); } if (both_bigint(lhs_numeric, rhs_numeric)) - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().bitwise_xor(rhs_numeric.as_bigint().big_integer()))); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().bitwise_xor(rhs_numeric.as_bigint().big_integer())); return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "bitwise XOR"); } @@ -1060,7 +1060,7 @@ ThrowCompletionOr bitwise_not(VM& vm, Value lhs) auto lhs_numeric = TRY(lhs.to_numeric(vm)); if (lhs_numeric.is_number()) return Value(~TRY(lhs_numeric.to_i32(vm))); - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().bitwise_not())); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().bitwise_not()); } // 13.5.4 Unary + Operator, https://tc39.es/ecma262/#sec-unary-plus-operator @@ -1079,10 +1079,10 @@ ThrowCompletionOr unary_minus(VM& vm, Value lhs) return Value(-lhs_numeric.as_double()); } if (lhs_numeric.as_bigint().big_integer() == BIGINT_ZERO) - return Value(js_bigint(vm, BIGINT_ZERO)); + return BigInt::create(vm, BIGINT_ZERO); auto big_integer_negated = lhs_numeric.as_bigint().big_integer(); big_integer_negated.negate(); - return Value(js_bigint(vm, big_integer_negated)); + return BigInt::create(vm, big_integer_negated); } // 13.9.1 The Left Shift Operator ( << ), https://tc39.es/ecma262/#sec-left-shift-operator @@ -1113,12 +1113,12 @@ ThrowCompletionOr left_shift(VM& vm, Value lhs, Value rhs) // For positive initial values and no remainder just return quotient if (division_result.remainder.is_zero() || !big_integer.is_negative()) - return js_bigint(vm, division_result.quotient); + return BigInt::create(vm, division_result.quotient); // For negative round "down" to the next negative number - return js_bigint(vm, division_result.quotient.minus(Crypto::SignedBigInteger { 1 })); + return BigInt::create(vm, division_result.quotient.minus(Crypto::SignedBigInteger { 1 })); } // 2. Return the BigInt value that represents ℝ(x) × 2^y. - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().multiplied_by(multiplier_divisor))); + return Value(BigInt::create(vm, lhs_numeric.as_bigint().big_integer().multiplied_by(multiplier_divisor))); } return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "left-shift"); } @@ -1140,7 +1140,7 @@ ThrowCompletionOr right_shift(VM& vm, Value lhs, Value rhs) if (both_bigint(lhs_numeric, rhs_numeric)) { auto rhs_negated = rhs_numeric.as_bigint().big_integer(); rhs_negated.negate(); - return left_shift(vm, lhs, js_bigint(vm, rhs_negated)); + return left_shift(vm, lhs, BigInt::create(vm, rhs_negated)); } return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "right-shift"); } @@ -1190,7 +1190,7 @@ ThrowCompletionOr add(VM& vm, Value lhs, Value rhs) if (both_number(lhs_numeric, rhs_numeric)) return Value(lhs_numeric.as_double() + rhs_numeric.as_double()); if (both_bigint(lhs_numeric, rhs_numeric)) - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().plus(rhs_numeric.as_bigint().big_integer()))); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().plus(rhs_numeric.as_bigint().big_integer())); return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "addition"); } @@ -1206,7 +1206,7 @@ ThrowCompletionOr sub(VM& vm, Value lhs, Value rhs) return Value(interm); } if (both_bigint(lhs_numeric, rhs_numeric)) - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().minus(rhs_numeric.as_bigint().big_integer()))); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().minus(rhs_numeric.as_bigint().big_integer())); return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "subtraction"); } @@ -1218,7 +1218,7 @@ ThrowCompletionOr mul(VM& vm, Value lhs, Value rhs) if (both_number(lhs_numeric, rhs_numeric)) return Value(lhs_numeric.as_double() * rhs_numeric.as_double()); if (both_bigint(lhs_numeric, rhs_numeric)) - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().multiplied_by(rhs_numeric.as_bigint().big_integer()))); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().multiplied_by(rhs_numeric.as_bigint().big_integer())); return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "multiplication"); } @@ -1232,7 +1232,7 @@ ThrowCompletionOr div(VM& vm, Value lhs, Value rhs) if (both_bigint(lhs_numeric, rhs_numeric)) { if (rhs_numeric.as_bigint().big_integer() == BIGINT_ZERO) return vm.throw_completion(ErrorType::DivisionByZero); - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).quotient)); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).quotient); } return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "division"); } @@ -1253,7 +1253,7 @@ ThrowCompletionOr mod(VM& vm, Value lhs, Value rhs) if (both_bigint(lhs_numeric, rhs_numeric)) { if (rhs_numeric.as_bigint().big_integer() == BIGINT_ZERO) return vm.throw_completion(ErrorType::DivisionByZero); - return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).remainder)); + return BigInt::create(vm, lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).remainder); } return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "modulo"); } @@ -1320,7 +1320,7 @@ ThrowCompletionOr exp(VM& vm, Value lhs, Value rhs) if (both_bigint(lhs_numeric, rhs_numeric)) { if (rhs_numeric.as_bigint().big_integer().is_negative()) return vm.throw_completion(ErrorType::NegativeExponent); - return Value(js_bigint(vm, Crypto::NumberTheory::Power(lhs_numeric.as_bigint().big_integer(), rhs_numeric.as_bigint().big_integer()))); + return BigInt::create(vm, Crypto::NumberTheory::Power(lhs_numeric.as_bigint().big_integer(), rhs_numeric.as_bigint().big_integer())); } return vm.throw_completion(ErrorType::BigIntBadOperatorOtherType, "exponentiation"); }