diff options
author | Maya Lekova <mslekova@chromium.org> | 2020-07-23 11:24:41 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2020-10-18 21:18:00 +0300 |
commit | 6cfba9f7f6a54c539f10966e87dff70ba80ab6c6 (patch) | |
tree | 617ea4b86802538203621686e2121f9097112456 /src/node_process_methods.cc | |
parent | b65e5aeaa7bd68a9a02530af3ec40616c468b2fd (diff) |
process: update v8 fast api calls usage
This commit removes the WrapperTraits specialization for FastHrtime
according to recent changes in the V8 API.
Refs: https://github.com/nodejs/node/issues/33374
PR-URL: https://github.com/nodejs/node/pull/35415
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'src/node_process_methods.cc')
-rw-r--r-- | src/node_process_methods.cc | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index e708fe7f090..6e7b1c92946 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -457,6 +457,12 @@ class FastHrtime : public BaseObject { SET_MEMORY_INFO_NAME(FastHrtime) SET_SELF_SIZE(FastHrtime) + static FastHrtime* FromV8ApiObject(v8::ApiObject api_object) { + v8::Object* v8_object = reinterpret_cast<v8::Object*>(&api_object); + return static_cast<FastHrtime*>( + v8_object->GetAlignedPointerFromInternalField(BaseObject::kSlot)); + } + // This is the legacy version of hrtime before BigInt was introduced in // JavaScript. // The value returned by uv_hrtime() is a 64-bit int representing nanoseconds, @@ -466,7 +472,7 @@ class FastHrtime : public BaseObject { // broken into the upper/lower 32 bits to be converted back in JS, // because there is no Uint64Array in JS. // The third entry contains the remaining nanosecond part of the value. - static void FastNumber(FastHrtime* receiver) { + static void NumberImpl(FastHrtime* receiver) { uint64_t t = uv_hrtime(); uint32_t* fields = static_cast<uint32_t*>(receiver->backing_store_->Data()); fields[0] = (t / NANOS_PER_SEC) >> 32; @@ -474,18 +480,26 @@ class FastHrtime : public BaseObject { fields[2] = t % NANOS_PER_SEC; } + static void FastNumber(v8::ApiObject receiver) { + NumberImpl(FromV8ApiObject(receiver)); + } + static void SlowNumber(const FunctionCallbackInfo<Value>& args) { - FastNumber(FromJSObject<FastHrtime>(args.Holder())); + NumberImpl(FromJSObject<FastHrtime>(args.Holder())); } - static void FastBigInt(FastHrtime* receiver) { + static void BigIntImpl(FastHrtime* receiver) { uint64_t t = uv_hrtime(); uint64_t* fields = static_cast<uint64_t*>(receiver->backing_store_->Data()); fields[0] = t; } + static void FastBigInt(v8::ApiObject receiver) { + BigIntImpl(FromV8ApiObject(receiver)); + } + static void SlowBigInt(const FunctionCallbackInfo<Value>& args) { - FastBigInt(FromJSObject<FastHrtime>(args.Holder())); + BigIntImpl(FromJSObject<FastHrtime>(args.Holder())); } v8::Global<ArrayBuffer> array_buffer_; @@ -563,17 +577,6 @@ void RegisterProcessMethodsExternalReferences( } // namespace node -namespace v8 { -template <> -class WrapperTraits<node::FastHrtime> { - public: - static const void* GetTypeInfo() { - static const int tag = 0; - return reinterpret_cast<const void*>(&tag); - } -}; -} // namespace v8 - NODE_MODULE_CONTEXT_AWARE_INTERNAL(process_methods, node::InitializeProcessMethods) NODE_MODULE_EXTERNAL_REFERENCE(process_methods, |