Lines Matching defs:isolate

24 #include "src/execution/isolate-inl.h"
56 IsolateT* isolate, int length,
58 static Handle<BigInt> NewFromInt(Isolate* isolate, int value);
59 static Handle<BigInt> NewFromDouble(Isolate* isolate, double value);
61 static Handle<MutableBigInt> Copy(Isolate* isolate,
65 IsolateT* isolate, AllocationType allocation = AllocationType::kYoung) {
68 New(isolate, 0, allocation).ToHandleChecked());
85 Isolate* isolate, Handle<BigIntBase> x, bool sign,
87 static Handle<MutableBigInt> AbsoluteSubOne(Isolate* isolate,
91 static MaybeHandle<BigInt> LeftShiftByAbsolute(Isolate* isolate,
94 static Handle<BigInt> RightShiftByAbsolute(Isolate* isolate,
97 static Handle<BigInt> RightShiftByMaximum(Isolate* isolate, bool sign);
173 MaybeHandle<T> ThrowBigIntTooBig(Isolate* isolate) {
183 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kBigIntTooBig), T);
187 MaybeHandle<MutableBigInt> MutableBigInt::New(IsolateT* isolate, int length,
190 return ThrowBigIntTooBig<MutableBigInt>(isolate);
193 Cast(isolate->factory()->NewBigInt(length, allocation));
201 Handle<BigInt> MutableBigInt::NewFromInt(Isolate* isolate, int value) {
202 if (value == 0) return Zero(isolate);
203 Handle<MutableBigInt> result = Cast(isolate->factory()->NewBigInt(1));
219 Handle<BigInt> MutableBigInt::NewFromDouble(Isolate* isolate, double value) {
221 if (value == 0) return Zero(isolate);
232 Handle<MutableBigInt> result = Cast(isolate->factory()->NewBigInt(digits));
287 Handle<MutableBigInt> MutableBigInt::Copy(Isolate* isolate,
291 Handle<MutableBigInt> result = New(isolate, length).ToHandleChecked();
345 Handle<BigInt> BigInt::Zero(IsolateT* isolate, AllocationType allocation) {
346 return MutableBigInt::Zero(isolate, allocation);
348 template Handle<BigInt> BigInt::Zero(Isolate* isolate,
350 template Handle<BigInt> BigInt::Zero(LocalIsolate* isolate,
353 Handle<BigInt> BigInt::UnaryMinus(Isolate* isolate, Handle<BigInt> x) {
358 Handle<MutableBigInt> result = MutableBigInt::Copy(isolate, x);
363 MaybeHandle<BigInt> BigInt::BitwiseNot(Isolate* isolate, Handle<BigInt> x) {
367 result = MutableBigInt::AbsoluteSubOne(isolate, x);
370 result = MutableBigInt::AbsoluteAddOne(isolate, x, true);
375 MaybeHandle<BigInt> BigInt::Exponentiate(Isolate* isolate, Handle<BigInt> base,
379 THROW_NEW_ERROR(isolate,
385 return MutableBigInt::NewFromInt(isolate, 1);
393 return UnaryMinus(isolate, base);
402 return ThrowBigIntTooBig<BigInt>(isolate);
407 return ThrowBigIntTooBig<BigInt>(isolate);
415 if (!MutableBigInt::New(isolate, needed_digits).ToHandle(&result)) {
433 Multiply(isolate, running_square, running_square);
439 maybe_result = Multiply(isolate, result, running_square);
447 MaybeHandle<BigInt> BigInt::Multiply(Isolate* isolate, Handle<BigInt> x,
453 if (!MutableBigInt::New(isolate, result_length).ToHandle(&result)) {
457 bigint::Status status = isolate->bigint_processor()->Multiply(
461 isolate->TerminateExecution();
468 MaybeHandle<BigInt> BigInt::Divide(Isolate* isolate, Handle<BigInt> x,
472 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kBigIntDivZero),
479 return Zero(isolate);
483 return result_sign == x->sign() ? x : UnaryMinus(isolate, x);
487 if (!MutableBigInt::New(isolate, result_length).ToHandle(&quotient)) {
491 bigint::Status status = isolate->bigint_processor()->Divide(
495 isolate->TerminateExecution();
502 MaybeHandle<BigInt> BigInt::Remainder(Isolate* isolate, Handle<BigInt> x,
506 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kBigIntDivZero),
512 if (y->length() == 1 && y->digit(0) == 1) return Zero(isolate);
515 if (!MutableBigInt::New(isolate, result_length).ToHandle(&remainder)) {
519 bigint::Status status = isolate->bigint_processor()->Modulo(
523 isolate->TerminateExecution();
530 MaybeHandle<BigInt> BigInt::Add(Isolate* isolate, Handle<BigInt> x,
539 if (!MutableBigInt::New(isolate, result_length).ToHandle(&result)) {
550 MaybeHandle<BigInt> BigInt::Subtract(Isolate* isolate, Handle<BigInt> x,
553 if (x->is_zero()) return UnaryMinus(isolate, y);
559 if (!MutableBigInt::New(isolate, result_length).ToHandle(&result)) {
570 MaybeHandle<BigInt> BigInt::LeftShift(Isolate* isolate, Handle<BigInt> x,
573 if (y->sign()) return MutableBigInt::RightShiftByAbsolute(isolate, x, y);
574 return MutableBigInt::LeftShiftByAbsolute(isolate, x, y);
577 MaybeHandle<BigInt> BigInt::SignedRightShift(Isolate* isolate, Handle<BigInt> x,
580 if (y->sign()) return MutableBigInt::LeftShiftByAbsolute(isolate, x, y);
581 return MutableBigInt::RightShiftByAbsolute(isolate, x, y);
584 MaybeHandle<BigInt> BigInt::UnsignedRightShift(Isolate* isolate,
587 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kBigIntShr), BigInt);
632 MaybeHandle<BigInt> BigInt::BitwiseAnd(Isolate* isolate, Handle<BigInt> x,
640 result = MutableBigInt::New(isolate, result_length).ToHandleChecked();
646 if (!MutableBigInt::New(isolate, result_length).ToHandle(&result)) {
654 result = MutableBigInt::New(isolate, result_length).ToHandleChecked();
661 MaybeHandle<BigInt> BigInt::BitwiseXor(Isolate* isolate, Handle<BigInt> x,
669 result = MutableBigInt::New(isolate, result_length).ToHandleChecked();
675 result = MutableBigInt::New(isolate, result_length).ToHandleChecked();
682 if (!MutableBigInt::New(isolate, result_length).ToHandle(&result)) {
691 MaybeHandle<BigInt> BigInt::BitwiseOr(Isolate* isolate, Handle<BigInt> x,
697 MutableBigInt::New(isolate, result_length).ToHandleChecked();
712 MaybeHandle<BigInt> BigInt::Increment(Isolate* isolate, Handle<BigInt> x) {
714 Handle<MutableBigInt> result = MutableBigInt::AbsoluteSubOne(isolate, x);
719 MutableBigInt::AbsoluteAddOne(isolate, x, false));
723 MaybeHandle<BigInt> BigInt::Decrement(Isolate* isolate, Handle<BigInt> x) {
726 result = MutableBigInt::AbsoluteAddOne(isolate, x, true);
729 return MutableBigInt::NewFromInt(isolate, -1);
731 result = MutableBigInt::AbsoluteSubOne(isolate, x);
736 Maybe<ComparisonResult> BigInt::CompareToString(Isolate* isolate,
740 MaybeHandle<BigInt> maybe_ny = StringToBigInt(isolate, y);
744 if (isolate->has_pending_exception()) {
754 Maybe<bool> BigInt::EqualToString(Isolate* isolate, Handle<BigInt> x,
757 MaybeHandle<BigInt> maybe_n = StringToBigInt(isolate, y);
761 if (isolate->has_pending_exception()) {
924 MaybeHandle<String> BigInt::ToString(Isolate* isolate, Handle<BigInt> bigint,
927 return isolate->factory()->zero_string();
945 result = isolate->factory()
974 THROW_NEW_ERROR(isolate, NewInvalidStringLengthError(), String);
979 result = isolate->factory()
985 bigint::Status status = isolate->bigint_processor()->ToString(
989 isolate->TerminateExecution();
1000 if (needed_size < string_size && !isolate->heap()->IsLargeObject(*result)) {
1002 isolate->heap()->CreateFillerObjectAt(
1018 MaybeHandle<BigInt> BigInt::FromNumber(Isolate* isolate,
1022 return MutableBigInt::NewFromInt(isolate, Smi::ToInt(*number));
1026 THROW_NEW_ERROR(isolate,
1030 return MutableBigInt::NewFromDouble(isolate, value);
1033 MaybeHandle<BigInt> BigInt::FromObject(Isolate* isolate, Handle<Object> obj) {
1036 isolate, obj,
1037 JSReceiver::ToPrimitive(isolate, Handle<JSReceiver>::cast(obj),
1043 return MutableBigInt::NewFromInt(isolate, obj->BooleanValue(isolate));
1050 if (!StringToBigInt(isolate, Handle<String>::cast(obj)).ToHandle(&n)) {
1051 if (isolate->has_pending_exception()) {
1057 Factory* factory = isolate->factory();
1065 THROW_NEW_ERROR(isolate,
1074 isolate, NewTypeError(MessageTemplate::kBigIntFromObject, obj), BigInt);
1077 Handle<Object> BigInt::ToNumber(Isolate* isolate, Handle<BigInt> x) {
1078 if (x->is_zero()) return Handle<Smi>(Smi::zero(), isolate);
1082 return Handle<Smi>(Smi::FromInt(value), isolate);
1085 return isolate->factory()->NewHeapNumber(result);
1196 Isolate* isolate, Handle<BigIntBase> x, bool sign,
1209 Handle<MutableBigInt> result(result_storage, isolate);
1211 if (!New(isolate, result_length).ToHandle(&result)) {
1229 Handle<MutableBigInt> MutableBigInt::AbsoluteSubOne(Isolate* isolate,
1233 Handle<MutableBigInt> result = New(isolate, length).ToHandleChecked();
1242 MaybeHandle<BigInt> MutableBigInt::LeftShiftByAbsolute(Isolate* isolate,
1247 return ThrowBigIntTooBig<BigInt>(isolate);
1253 return ThrowBigIntTooBig<BigInt>(isolate);
1256 if (!New(isolate, result_length).ToHandle(&result)) {
1264 Handle<BigInt> MutableBigInt::RightShiftByAbsolute(Isolate* isolate,
1270 return RightShiftByMaximum(isolate, sign);
1278 return RightShiftByMaximum(isolate, sign);
1280 Handle<MutableBigInt> result = New(isolate, result_length).ToHandleChecked();
1286 Handle<BigInt> MutableBigInt::RightShiftByMaximum(Isolate* isolate, bool sign) {
1289 return NewFromInt(isolate, -1);
1291 return Zero(isolate);
1305 void Terminate(Isolate* isolate) { isolate->TerminateExecution(); }
1307 void Terminate(LocalIsolate* isolate) { UNREACHABLE(); }
1310 MaybeHandle<BigInt> BigInt::Allocate(IsolateT* isolate,
1316 MutableBigInt::New(isolate, digits, allocation).ToHandleChecked();
1318 isolate->bigint_processor()->FromString(GetRWDigits(result), accumulator);
1320 Terminate(isolate);
1370 Isolate* isolate, uint32_t bitfield,
1377 MutableBigInt::Cast(isolate->factory()->NewBigInt(length));
1411 Handle<BigInt> BigInt::AsIntN(Isolate* isolate, uint64_t n, Handle<BigInt> x) {
1413 if (n == 0) return MutableBigInt::Zero(isolate);
1418 MutableBigInt::New(isolate, needed_length).ToHandleChecked();
1425 MaybeHandle<BigInt> BigInt::AsUintN(Isolate* isolate, uint64_t n,
1428 if (n == 0) return MutableBigInt::Zero(isolate);
1432 return ThrowBigIntTooBig<BigInt>(isolate);
1435 result = MutableBigInt::New(isolate, result_length).ToHandleChecked();
1442 result = MutableBigInt::New(isolate, result_length).ToHandleChecked();
1449 Handle<BigInt> BigInt::FromInt64(Isolate* isolate, int64_t n) {
1450 if (n == 0) return MutableBigInt::Zero(isolate);
1454 MutableBigInt::Cast(isolate->factory()->NewBigInt(length));
1471 Handle<BigInt> BigInt::FromUint64(Isolate* isolate, uint64_t n) {
1472 if (n == 0) return MutableBigInt::Zero(isolate);
1476 MutableBigInt::Cast(isolate->factory()->NewBigInt(length));
1482 MaybeHandle<BigInt> BigInt::FromWords64(Isolate* isolate, int sign_bit,
1486 return ThrowBigIntTooBig<BigInt>(isolate);
1488 if (words64_count == 0) return MutableBigInt::Zero(isolate);
1495 if (!MutableBigInt::New(isolate, length).ToHandle(&result)) {