summaryrefslogtreecommitdiff
path: root/deps/v8/include
diff options
context:
space:
mode:
authorGus Caplan <me@gus.host>2018-07-03 17:42:16 -0500
committerGus Caplan <me@gus.host>2018-07-05 16:58:59 -0500
commite7a18c5bf132ff0e3f9ccb702ff7628eaf214865 (patch)
tree1d094f519dc28e52c44cd001e89ad39847f0938c /deps/v8/include
parent8476053c132fd9613aab547aba165190f8064254 (diff)
downloadandroid-node-v8-e7a18c5bf132ff0e3f9ccb702ff7628eaf214865.tar.gz
android-node-v8-e7a18c5bf132ff0e3f9ccb702ff7628eaf214865.tar.bz2
android-node-v8-e7a18c5bf132ff0e3f9ccb702ff7628eaf214865.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/include')
-rw-r--r--deps/v8/include/v8.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h
index ab77238a77..fe8f5a3839 100644
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -3048,6 +3048,48 @@ class V8_EXPORT Uint32 : public Integer {
class V8_EXPORT BigInt : public Primitive {
public:
static Local<BigInt> New(Isolate* isolate, int64_t value);
+ static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
+ /**
+ * Creates a new BigInt object using a specified sign bit and a
+ * specified list of digits/words.
+ * The resulting number is calculated as:
+ *
+ * (-1)^sign_bit * (words[0] * (2^64)^0 + words[1] * (2^64)^1 + ...)
+ */
+ static MaybeLocal<BigInt> NewFromWords(Local<Context> context, int sign_bit,
+ int word_count, const uint64_t* words);
+
+ /**
+ * Returns the value of this BigInt as an unsigned 64-bit integer.
+ * If `lossless` is provided, it will reflect whether the return value was
+ * truncated or wrapped around. In particular, it is set to `false` if this
+ * BigInt is negative.
+ */
+ uint64_t Uint64Value(bool* lossless = nullptr) const;
+
+ /**
+ * Returns the value of this BigInt as a signed 64-bit integer.
+ * If `lossless` is provided, it will reflect whether this BigInt was
+ * truncated or not.
+ */
+ int64_t Int64Value(bool* lossless = nullptr) const;
+
+ /**
+ * Returns the number of 64-bit words needed to store the result of
+ * ToWordsArray().
+ */
+ int WordCount() const;
+
+ /**
+ * Writes the contents of this BigInt to a specified memory location.
+ * `sign_bit` must be provided and will be set to 1 if this BigInt is
+ * negative.
+ * `*word_count` has to be initialized to the length of the `words` array.
+ * Upon return, it will be set to the actual number of words that would
+ * be needed to store this BigInt (i.e. the return value of `WordCount()`).
+ */
+ void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
+
V8_INLINE static BigInt* Cast(v8::Value* obj);
private: