diff options
author | Gus Caplan <me@gus.host> | 2018-07-03 17:42:16 -0500 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2018-07-26 08:34:24 +0200 |
commit | a921aff334e4d8d1df012608ec1e8fef9a4a0968 (patch) | |
tree | 8ecd9370b9c1f4c8b089facaf897df9dc08940b0 /deps/v8/src/api.cc | |
parent | eea5aeea475afc0c97f8ce0af1675cfcea027d39 (diff) | |
download | android-node-v8-a921aff334e4d8d1df012608ec1e8fef9a4a0968.tar.gz android-node-v8-a921aff334e4d8d1df012608ec1e8fef9a4a0968.tar.bz2 android-node-v8-a921aff334e4d8d1df012608ec1e8fef9a4a0968.zip |
deps: cherry-pick 477df06 from upstream v8
Original commit message:
[API] Expand BigInt API
Provide a more complete BigInt API.
Bug: v8:7712
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Ic8562d616f3125deabdf8b52c7019b191bef0e07
Reviewed-on: chromium-review.googlesource.com/1101198
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54122}
PR-URL: https://github.com/nodejs/node/pull/21644
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'deps/v8/src/api.cc')
-rw-r--r-- | deps/v8/src/api.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 34b4773c2f..66ca4bb96a 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -8000,6 +8000,49 @@ Local<BigInt> v8::BigInt::New(Isolate* isolate, int64_t value) { return Utils::ToLocal(result); } +Local<BigInt> v8::BigInt::NewFromUnsigned(Isolate* isolate, uint64_t value) { + CHECK(i::FLAG_harmony_bigint); + i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(internal_isolate); + i::Handle<i::BigInt> result = i::BigInt::FromUint64(internal_isolate, value); + return Utils::ToLocal(result); +} + +MaybeLocal<BigInt> v8::BigInt::NewFromWords(Local<Context> context, + int sign_bit, int word_count, + const uint64_t* words) { + CHECK(i::FLAG_harmony_bigint); + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); + ENTER_V8_NO_SCRIPT(isolate, context, BigInt, NewFromWords, + MaybeLocal<BigInt>(), InternalEscapableScope); + i::MaybeHandle<i::BigInt> result = + i::BigInt::FromWords64(isolate, sign_bit, word_count, words); + has_pending_exception = result.is_null(); + RETURN_ON_FAILED_EXECUTION(BigInt); + RETURN_ESCAPED(Utils::ToLocal(result.ToHandleChecked())); +} + +uint64_t v8::BigInt::Uint64Value(bool* lossless) const { + i::Handle<i::BigInt> handle = Utils::OpenHandle(this); + return handle->AsUint64(lossless); +} + +int64_t v8::BigInt::Int64Value(bool* lossless) const { + i::Handle<i::BigInt> handle = Utils::OpenHandle(this); + return handle->AsInt64(lossless); +} + +int BigInt::WordCount() const { + i::Handle<i::BigInt> handle = Utils::OpenHandle(this); + return handle->Words64Count(); +} + +void BigInt::ToWordsArray(int* sign_bit, int* word_count, + uint64_t* words) const { + i::Handle<i::BigInt> handle = Utils::OpenHandle(this); + return handle->ToWordsArray64(sign_bit, word_count, words); +} + void Isolate::ReportExternalAllocationLimitReached() { i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); if (heap->gc_state() != i::Heap::NOT_IN_GC) return; |