diff --git a/doc/api/addons.md b/doc/api/addons.md index 08172a9ae9..446a63b1a2 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -923,7 +923,7 @@ void MyObject::New(const FunctionCallbackInfo& args) { void MyObject::PlusOne(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); - MyObject* obj = ObjectWrap::Unwrap(args.Holder()); + MyObject* obj = ObjectWrap::Unwrap(args.This()); obj->value_ += 1; args.GetReturnValue().Set(Number::New(isolate, obj->value_)); @@ -1138,7 +1138,7 @@ void MyObject::NewInstance(const FunctionCallbackInfo& args) { void MyObject::PlusOne(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); - MyObject* obj = ObjectWrap::Unwrap(args.Holder()); + MyObject* obj = ObjectWrap::Unwrap(args.This()); obj->value_ += 1; args.GetReturnValue().Set(Number::New(isolate, obj->value_)); diff --git a/src/README.md b/src/README.md index 5853e1efa2..01d6d5fd4b 100644 --- a/src/README.md +++ b/src/README.md @@ -418,8 +418,6 @@ Node.js source code.) `args[n]` is a `Local` that represents the n-th argument passed to the function. `args.This()` is the `this` value inside this function call. -`args.Holder()` is equivalent to `args.This()` in all use cases inside of -Node.js. `args.GetReturnValue()` is a placeholder for the return value of the function, and provides a `.Set()` method that can be called with a boolean, integer, @@ -829,7 +827,7 @@ The JavaScript object can be accessed as a `v8::Local` by using `self->object()`, given a `BaseObject` named `self`. Accessing a `BaseObject` from a `v8::Local` (frequently that is -`args.This()` or `args.Holder()` in a [binding function][]) can be done using +`args.This()` in a [binding function][]) can be done using the `Unwrap(obj)` function, where `T` is a subclass of `BaseObject`. A helper for this is the `ASSIGN_OR_RETURN_UNWRAP` macro that returns from the current function if unwrapping fails (typically that means that the `BaseObject` @@ -838,7 +836,7 @@ has been deleted earlier). ```cpp void Http2Session::Request(const FunctionCallbackInfo& args) { Http2Session* session; - ASSIGN_OR_RETURN_UNWRAP(&session, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&session, args.This()); Environment* env = session->env(); Local context = env->context(); Isolate* isolate = env->isolate(); diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 137e70b356..7bf2811730 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -257,7 +257,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo& args) { void AsyncWrap::GetAsyncId(const FunctionCallbackInfo& args) { AsyncWrap* wrap; args.GetReturnValue().Set(kInvalidAsyncId); - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); args.GetReturnValue().Set(wrap->get_async_id()); } @@ -299,7 +299,7 @@ void AsyncWrap::AsyncReset(const FunctionCallbackInfo& args) { CHECK(args[0]->IsObject()); AsyncWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); Local resource = args[0].As(); double execution_async_id = @@ -311,7 +311,7 @@ void AsyncWrap::AsyncReset(const FunctionCallbackInfo& args) { void AsyncWrap::GetProviderType(const FunctionCallbackInfo& args) { AsyncWrap* wrap; args.GetReturnValue().Set(AsyncWrap::PROVIDER_NONE); - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); args.GetReturnValue().Set(wrap->provider_type()); } diff --git a/src/base_object-inl.h b/src/base_object-inl.h index 518b22dabe..61f30b3cfb 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -132,19 +132,18 @@ v8::EmbedderGraph::Node::Detachedness BaseObject::GetDetachedness() const { template void BaseObject::InternalFieldGet( - v8::Local property, - const v8::PropertyCallbackInfo& info) { - info.GetReturnValue().Set( - info.This()->GetInternalField(Field).As()); + const v8::FunctionCallbackInfo& args) { + args.GetReturnValue().Set( + args.This()->GetInternalField(Field).As()); } template -void BaseObject::InternalFieldSet(v8::Local property, - v8::Local value, - const v8::PropertyCallbackInfo& info) { +void BaseObject::InternalFieldSet( + const v8::FunctionCallbackInfo& args) { + v8::Local value = args[0]; // This could be e.g. value->IsFunction(). CHECK(((*value)->*typecheck)()); - info.This()->SetInternalField(Field, value); + args.This()->SetInternalField(Field, value); } bool BaseObject::has_pointer_data() const { diff --git a/src/base_object.h b/src/base_object.h index fd6d62a99c..546d968e5c 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -111,12 +111,9 @@ class BaseObject : public MemoryRetainer { // Setter/Getter pair for internal fields that can be passed to SetAccessor. template - static void InternalFieldGet(v8::Local property, - const v8::PropertyCallbackInfo& info); + static void InternalFieldGet(const v8::FunctionCallbackInfo& args); template - static void InternalFieldSet(v8::Local property, - v8::Local value, - const v8::PropertyCallbackInfo& info); + static void InternalFieldSet(const v8::FunctionCallbackInfo& args); // This is a bit of a hack. See the override in async_wrap.cc for details. virtual bool IsDoneInitializing() const; diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index e129cc57b5..2998022387 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -1404,7 +1404,7 @@ template static void Query(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ChannelWrap* channel; - ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&channel, args.This()); CHECK_EQ(false, args.IsConstructCall()); CHECK(args[0]->IsObject()); @@ -1664,7 +1664,7 @@ void GetNameInfo(const FunctionCallbackInfo& args) { void GetServers(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ChannelWrap* channel; - ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&channel, args.This()); Local server_array = Array::New(env->isolate()); @@ -1702,7 +1702,7 @@ void GetServers(const FunctionCallbackInfo& args) { void SetServers(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ChannelWrap* channel; - ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&channel, args.This()); if (channel->active_query_count()) { return args.GetReturnValue().Set(DNS_ESETSRVPENDING); @@ -1783,7 +1783,7 @@ void SetServers(const FunctionCallbackInfo& args) { void SetLocalAddress(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ChannelWrap* channel; - ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&channel, args.This()); CHECK_EQ(args.Length(), 2); CHECK(args[0]->IsString()); @@ -1846,7 +1846,7 @@ void SetLocalAddress(const FunctionCallbackInfo& args) { void Cancel(const FunctionCallbackInfo& args) { ChannelWrap* channel; - ASSIGN_OR_RETURN_UNWRAP(&channel, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&channel, args.This()); TRACE_EVENT_INSTANT0(TRACING_CATEGORY_NODE2(dns, native), "cancel", TRACE_EVENT_SCOPE_THREAD); diff --git a/src/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc index 94e2957cad..f7ff786d65 100644 --- a/src/crypto/crypto_cipher.cc +++ b/src/crypto/crypto_cipher.cc @@ -438,7 +438,7 @@ void CipherBase::Init(const char* cipher_type, void CipherBase::Init(const FunctionCallbackInfo& args) { CipherBase* cipher; - ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This()); Environment* env = Environment::GetCurrent(args); CHECK_GE(args.Length(), 3); @@ -510,7 +510,7 @@ void CipherBase::InitIv(const char* cipher_type, void CipherBase::InitIv(const FunctionCallbackInfo& args) { CipherBase* cipher; - ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This()); Environment* env = cipher->env(); CHECK_GE(args.Length(), 4); @@ -645,7 +645,7 @@ bool CipherBase::IsAuthenticatedMode() const { void CipherBase::GetAuthTag(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CipherBase* cipher; - ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This()); // Only callable after Final and if encrypting. if (cipher->ctx_ || @@ -661,7 +661,7 @@ void CipherBase::GetAuthTag(const FunctionCallbackInfo& args) { void CipherBase::SetAuthTag(const FunctionCallbackInfo& args) { CipherBase* cipher; - ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This()); Environment* env = Environment::GetCurrent(args); if (!cipher->ctx_ || @@ -774,7 +774,7 @@ bool CipherBase::SetAAD( void CipherBase::SetAAD(const FunctionCallbackInfo& args) { CipherBase* cipher; - ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This()); Environment* env = Environment::GetCurrent(args); CHECK_EQ(args.Length(), 2); @@ -887,7 +887,7 @@ bool CipherBase::SetAutoPadding(bool auto_padding) { void CipherBase::SetAutoPadding(const FunctionCallbackInfo& args) { CipherBase* cipher; - ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This()); bool b = cipher->SetAutoPadding(args.Length() < 1 || args[0]->IsTrue()); args.GetReturnValue().Set(b); // Possibly report invalid state failure @@ -962,7 +962,7 @@ void CipherBase::Final(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CipherBase* cipher; - ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cipher, args.This()); if (cipher->ctx_ == nullptr) return THROW_ERR_CRYPTO_INVALID_STATE(env); diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc index 17b99177d6..a5b38fde51 100644 --- a/src/crypto/crypto_context.cc +++ b/src/crypto/crypto_context.cc @@ -422,7 +422,7 @@ void SecureContext::New(const FunctionCallbackInfo& args) { void SecureContext::Init(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); Environment* env = sc->env(); CHECK_EQ(args.Length(), 3); @@ -595,7 +595,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_GE(args.Length(), 1); // Private key argument is mandatory @@ -626,7 +626,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo& args) { void SecureContext::SetSigalgs(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); Environment* env = sc->env(); ClearErrorOnReturn clear_error_on_return; @@ -644,7 +644,7 @@ void SecureContext::SetEngineKey(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_EQ(args.Length(), 2); @@ -707,7 +707,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_GE(args.Length(), 1); // Certificate argument is mandatory @@ -734,7 +734,7 @@ void SecureContext::AddCACert(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_GE(args.Length(), 1); // CA certificate argument is mandatory @@ -771,7 +771,7 @@ void SecureContext::AddCRL(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_GE(args.Length(), 1); // CRL argument is mandatory @@ -790,7 +790,7 @@ void SecureContext::SetRootCerts() { void SecureContext::AddRootCerts(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); sc->SetRootCerts(); } @@ -798,7 +798,7 @@ void SecureContext::SetCipherSuites(const FunctionCallbackInfo& args) { // BoringSSL doesn't allow API config of TLS1.3 cipher suites. #ifndef OPENSSL_IS_BORINGSSL SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); Environment* env = sc->env(); ClearErrorOnReturn clear_error_on_return; @@ -813,7 +813,7 @@ void SecureContext::SetCipherSuites(const FunctionCallbackInfo& args) { void SecureContext::SetCiphers(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); Environment* env = sc->env(); ClearErrorOnReturn clear_error_on_return; @@ -837,7 +837,7 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo& args) { void SecureContext::SetECDHCurve(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); Environment* env = sc->env(); CHECK_GE(args.Length(), 1); // ECDH curve name argument is mandatory @@ -899,7 +899,7 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo& args) { void SecureContext::SetMinProto(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_EQ(args.Length(), 1); CHECK(args[0]->IsInt32()); @@ -911,7 +911,7 @@ void SecureContext::SetMinProto(const FunctionCallbackInfo& args) { void SecureContext::SetMaxProto(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_EQ(args.Length(), 1); CHECK(args[0]->IsInt32()); @@ -923,7 +923,7 @@ void SecureContext::SetMaxProto(const FunctionCallbackInfo& args) { void SecureContext::GetMinProto(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_EQ(args.Length(), 0); @@ -934,7 +934,7 @@ void SecureContext::GetMinProto(const FunctionCallbackInfo& args) { void SecureContext::GetMaxProto(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_EQ(args.Length(), 0); @@ -946,7 +946,7 @@ void SecureContext::GetMaxProto(const FunctionCallbackInfo& args) { void SecureContext::SetOptions(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_GE(args.Length(), 1); CHECK(args[0]->IsNumber()); @@ -960,7 +960,7 @@ void SecureContext::SetOptions(const FunctionCallbackInfo& args) { void SecureContext::SetSessionIdContext( const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); Environment* env = sc->env(); CHECK_GE(args.Length(), 1); @@ -992,7 +992,7 @@ void SecureContext::SetSessionIdContext( void SecureContext::SetSessionTimeout(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); CHECK_GE(args.Length(), 1); CHECK(args[0]->IsInt32()); @@ -1003,7 +1003,7 @@ void SecureContext::SetSessionTimeout(const FunctionCallbackInfo& args) { void SecureContext::Close(const FunctionCallbackInfo& args) { SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); sc->Reset(); } @@ -1015,7 +1015,7 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo& args) { bool ret = false; SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); ClearErrorOnReturn clear_error_on_return; if (args.Length() < 1) { @@ -1124,7 +1124,7 @@ void SecureContext::SetClientCertEngine( CHECK(args[0]->IsString()); SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sc, args.This()); MarkPopErrorOnReturn mark_pop_error_on_return; @@ -1161,7 +1161,7 @@ void SecureContext::SetClientCertEngine( void SecureContext::GetTicketKeys(const FunctionCallbackInfo& args) { SecureContext* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); Local buff; if (!Buffer::New(wrap->env(), 48).ToLocal(&buff)) @@ -1176,7 +1176,7 @@ void SecureContext::GetTicketKeys(const FunctionCallbackInfo& args) { void SecureContext::SetTicketKeys(const FunctionCallbackInfo& args) { SecureContext* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK_GE(args.Length(), 1); // Ticket keys argument is mandatory CHECK(args[0]->IsArrayBufferView()); @@ -1196,7 +1196,7 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo& args) { void SecureContext::EnableTicketKeyCallback( const FunctionCallbackInfo& args) { SecureContext* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); SSL_CTX_set_tlsext_ticket_key_cb(wrap->ctx_.get(), TicketKeyCallback); } @@ -1350,7 +1350,7 @@ void SecureContext::CtxGetter(const FunctionCallbackInfo& info) { template void SecureContext::GetCertificate(const FunctionCallbackInfo& args) { SecureContext* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); Environment* env = wrap->env(); X509* cert; diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc index b4447102a8..dac37f52b9 100644 --- a/src/crypto/crypto_dh.cc +++ b/src/crypto/crypto_dh.cc @@ -292,7 +292,7 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman; - ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.This()); if (!DH_generate_key(diffieHellman->dh_.get())) { return ThrowCryptoError(env, ERR_get_error(), "Key generation failed"); @@ -327,7 +327,7 @@ void DiffieHellman::GetField(const FunctionCallbackInfo& args, Environment* env = Environment::GetCurrent(args); DiffieHellman* dh; - ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&dh, args.This()); const BIGNUM* num = get_field(dh->dh_.get()); if (num == nullptr) @@ -388,7 +388,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman; - ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.This()); ClearErrorOnReturn clear_error_on_return; @@ -447,7 +447,7 @@ void DiffieHellman::SetKey(const FunctionCallbackInfo& args, int (*set_field)(DH*, BIGNUM*), const char* what) { Environment* env = Environment::GetCurrent(args); DiffieHellman* dh; - ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&dh, args.This()); CHECK_EQ(args.Length(), 1); ArrayBufferOrViewContents buf(args[0]); if (UNLIKELY(!buf.CheckSizeInt32())) @@ -473,7 +473,7 @@ void DiffieHellman::VerifyErrorGetter(const FunctionCallbackInfo& args) { HandleScope scope(args.GetIsolate()); DiffieHellman* diffieHellman; - ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.This()); args.GetReturnValue().Set(diffieHellman->verifyError_); } diff --git a/src/crypto/crypto_ec.cc b/src/crypto/crypto_ec.cc index 860d5048db..9c50f26ba5 100644 --- a/src/crypto/crypto_ec.cc +++ b/src/crypto/crypto_ec.cc @@ -155,7 +155,7 @@ void ECDH::GenerateKeys(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ECDH* ecdh; - ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.This()); if (!EC_KEY_generate_key(ecdh->key_.get())) return THROW_ERR_CRYPTO_OPERATION_FAILED(env, "Failed to generate key"); @@ -196,7 +196,7 @@ void ECDH::ComputeSecret(const FunctionCallbackInfo& args) { CHECK(IsAnyBufferSource(args[0])); ECDH* ecdh; - ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.This()); MarkPopErrorOnReturn mark_pop_error_on_return; @@ -240,7 +240,7 @@ void ECDH::GetPublicKey(const FunctionCallbackInfo& args) { CHECK_EQ(args.Length(), 1); ECDH* ecdh; - ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.This()); const EC_GROUP* group = EC_KEY_get0_group(ecdh->key_.get()); const EC_POINT* pub = EC_KEY_get0_public_key(ecdh->key_.get()); @@ -263,7 +263,7 @@ void ECDH::GetPrivateKey(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ECDH* ecdh; - ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.This()); const BIGNUM* b = EC_KEY_get0_private_key(ecdh->key_.get()); if (b == nullptr) @@ -289,7 +289,7 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ECDH* ecdh; - ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.This()); ArrayBufferOrViewContents priv_buffer(args[0]); if (UNLIKELY(!priv_buffer.CheckSizeInt32())) @@ -345,7 +345,7 @@ void ECDH::SetPublicKey(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ECDH* ecdh; - ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&ecdh, args.This()); CHECK(IsAnyBufferSource(args[0])); diff --git a/src/crypto/crypto_hash.cc b/src/crypto/crypto_hash.cc index 46086018b6..09ed200299 100644 --- a/src/crypto/crypto_hash.cc +++ b/src/crypto/crypto_hash.cc @@ -378,7 +378,7 @@ void Hash::HashDigest(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Hash* hash; - ASSIGN_OR_RETURN_UNWRAP(&hash, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&hash, args.This()); enum encoding encoding = BUFFER; if (args.Length() >= 1) { diff --git a/src/crypto/crypto_hmac.cc b/src/crypto/crypto_hmac.cc index b101d5c7b0..86315374fd 100644 --- a/src/crypto/crypto_hmac.cc +++ b/src/crypto/crypto_hmac.cc @@ -85,7 +85,7 @@ void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) { void Hmac::HmacInit(const FunctionCallbackInfo& args) { Hmac* hmac; - ASSIGN_OR_RETURN_UNWRAP(&hmac, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&hmac, args.This()); Environment* env = hmac->env(); const node::Utf8Value hash_type(env->isolate(), args[0]); @@ -114,7 +114,7 @@ void Hmac::HmacDigest(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Hmac* hmac; - ASSIGN_OR_RETURN_UNWRAP(&hmac, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&hmac, args.This()); enum encoding encoding = BUFFER; if (args.Length() >= 1) { diff --git a/src/crypto/crypto_keys.cc b/src/crypto/crypto_keys.cc index c5dd2fb8fc..12654ecceb 100644 --- a/src/crypto/crypto_keys.cc +++ b/src/crypto/crypto_keys.cc @@ -971,7 +971,7 @@ KeyObjectHandle::KeyObjectHandle(Environment* env, void KeyObjectHandle::Init(const FunctionCallbackInfo& args) { KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); MarkPopErrorOnReturn mark_pop_error_on_return; CHECK(args[0]->IsInt32()); @@ -1015,7 +1015,7 @@ void KeyObjectHandle::Init(const FunctionCallbackInfo& args) { void KeyObjectHandle::InitJWK(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); MarkPopErrorOnReturn mark_pop_error_on_return; // The argument must be a JavaScript object that we will inspect @@ -1054,7 +1054,7 @@ void KeyObjectHandle::InitJWK(const FunctionCallbackInfo& args) { void KeyObjectHandle::InitECRaw(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); CHECK(args[0]->IsString()); Utf8Value name(env->isolate(), args[0]); @@ -1092,7 +1092,7 @@ void KeyObjectHandle::InitECRaw(const FunctionCallbackInfo& args) { void KeyObjectHandle::InitEDRaw(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); CHECK(args[0]->IsString()); Utf8Value name(env->isolate(), args[0]); @@ -1134,7 +1134,7 @@ void KeyObjectHandle::InitEDRaw(const FunctionCallbackInfo& args) { void KeyObjectHandle::Equals(const FunctionCallbackInfo& args) { KeyObjectHandle* self_handle; KeyObjectHandle* arg_handle; - ASSIGN_OR_RETURN_UNWRAP(&self_handle, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&self_handle, args.This()); ASSIGN_OR_RETURN_UNWRAP(&arg_handle, args[0].As()); std::shared_ptr key = self_handle->Data(); std::shared_ptr key2 = arg_handle->Data(); @@ -1182,7 +1182,7 @@ void KeyObjectHandle::Equals(const FunctionCallbackInfo& args) { void KeyObjectHandle::GetKeyDetail(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); CHECK(args[0]->IsObject()); @@ -1235,7 +1235,7 @@ Local KeyObjectHandle::GetAsymmetricKeyType() const { void KeyObjectHandle::GetAsymmetricKeyType( const FunctionCallbackInfo& args) { KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); args.GetReturnValue().Set(key->GetAsymmetricKeyType()); } @@ -1263,7 +1263,7 @@ bool KeyObjectHandle::CheckEcKeyData() const { void KeyObjectHandle::CheckEcKeyData(const FunctionCallbackInfo& args) { KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); args.GetReturnValue().Set(key->CheckEcKeyData()); } @@ -1271,14 +1271,14 @@ void KeyObjectHandle::CheckEcKeyData(const FunctionCallbackInfo& args) { void KeyObjectHandle::GetSymmetricKeySize( const FunctionCallbackInfo& args) { KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); args.GetReturnValue().Set( static_cast(key->Data()->GetSymmetricKeySize())); } void KeyObjectHandle::Export(const FunctionCallbackInfo& args) { KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); KeyType type = key->Data()->GetKeyType(); @@ -1328,7 +1328,7 @@ void KeyObjectHandle::ExportJWK( const v8::FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); KeyObjectHandle* key; - ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); CHECK(args[0]->IsObject()); CHECK(args[1]->IsBoolean()); diff --git a/src/crypto/crypto_sig.cc b/src/crypto/crypto_sig.cc index ab020efbae..3441d7e771 100644 --- a/src/crypto/crypto_sig.cc +++ b/src/crypto/crypto_sig.cc @@ -371,7 +371,7 @@ void Sign::New(const FunctionCallbackInfo& args) { void Sign::SignInit(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Sign* sign; - ASSIGN_OR_RETURN_UNWRAP(&sign, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sign, args.This()); const node::Utf8Value sign_type(args.GetIsolate(), args[0]); crypto::CheckThrow(env, sign->Init(*sign_type)); @@ -414,7 +414,7 @@ Sign::SignResult Sign::SignFinal( void Sign::SignFinal(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Sign* sign; - ASSIGN_OR_RETURN_UNWRAP(&sign, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&sign, args.This()); ClearErrorOnReturn clear_error_on_return; @@ -492,7 +492,7 @@ void Verify::New(const FunctionCallbackInfo& args) { void Verify::VerifyInit(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Verify* verify; - ASSIGN_OR_RETURN_UNWRAP(&verify, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&verify, args.This()); const node::Utf8Value verify_type(args.GetIsolate(), args[0]); crypto::CheckThrow(env, verify->Init(*verify_type)); @@ -545,7 +545,7 @@ void Verify::VerifyFinal(const FunctionCallbackInfo& args) { ClearErrorOnReturn clear_error_on_return; Verify* verify; - ASSIGN_OR_RETURN_UNWRAP(&verify, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&verify, args.This()); unsigned int offset = 0; ManagedEVPPKey pkey = diff --git a/src/crypto/crypto_tls.cc b/src/crypto/crypto_tls.cc index 5e1a1f2fbf..34382af902 100644 --- a/src/crypto/crypto_tls.cc +++ b/src/crypto/crypto_tls.cc @@ -506,7 +506,7 @@ void TLSWrap::Wrap(const FunctionCallbackInfo& args) { void TLSWrap::Receive(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); ArrayBufferViewContents buffer(args[0]); const char* data = buffer.data(); @@ -528,7 +528,7 @@ void TLSWrap::Receive(const FunctionCallbackInfo& args) { void TLSWrap::Start(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK(!wrap->started_); wrap->started_ = true; @@ -1155,7 +1155,7 @@ int TLSWrap::DoShutdown(ShutdownWrap* req_wrap) { void TLSWrap::SetVerifyMode(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK_EQ(args.Length(), 2); CHECK(args[0]->IsBoolean()); @@ -1187,7 +1187,7 @@ void TLSWrap::SetVerifyMode(const FunctionCallbackInfo& args) { void TLSWrap::EnableSessionCallbacks(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK_NOT_NULL(wrap->ssl_); wrap->enable_session_callbacks(); @@ -1203,7 +1203,7 @@ void TLSWrap::EnableSessionCallbacks(const FunctionCallbackInfo& args) { void TLSWrap::EnableKeylogCallback(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK(wrap->sc_); wrap->sc_->SetKeylogCallback(KeylogCallback); } @@ -1220,7 +1220,7 @@ void TLSWrap::EnableKeylogCallback(const FunctionCallbackInfo& args) { void TLSWrap::EnableTrace(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); #if HAVE_SSL_TRACE if (wrap->ssl_) { @@ -1243,7 +1243,7 @@ void TLSWrap::EnableTrace(const FunctionCallbackInfo& args) { void TLSWrap::DestroySSL(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); wrap->Destroy(); Debug(wrap, "DestroySSL() finished"); } @@ -1272,7 +1272,7 @@ void TLSWrap::Destroy() { void TLSWrap::EnableCertCb(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); wrap->WaitForCertCb(OnClientHelloParseEnd, wrap); } @@ -1289,7 +1289,7 @@ void TLSWrap::OnClientHelloParseEnd(void* arg) { void TLSWrap::EnableALPNCb(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); wrap->alpn_callback_enabled_ = true; SSL* ssl = wrap->ssl_.get(); @@ -1301,7 +1301,7 @@ void TLSWrap::GetServername(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK_NOT_NULL(wrap->ssl_); @@ -1317,7 +1317,7 @@ void TLSWrap::SetServername(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK_EQ(args.Length(), 1); CHECK(args[0]->IsString()); @@ -1382,7 +1382,7 @@ int TLSWrap::SetCACerts(SecureContext* sc) { void TLSWrap::SetPskIdentityHint(const FunctionCallbackInfo& args) { TLSWrap* p; - ASSIGN_OR_RETURN_UNWRAP(&p, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&p, args.This()); CHECK_NOT_NULL(p->ssl_); Environment* env = p->env(); @@ -1399,7 +1399,7 @@ void TLSWrap::SetPskIdentityHint(const FunctionCallbackInfo& args) { void TLSWrap::EnablePskCallback(const FunctionCallbackInfo& args) { TLSWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK_NOT_NULL(wrap->ssl_); SSL_set_psk_server_callback(wrap->ssl_.get(), PskServerCallback); @@ -1533,7 +1533,7 @@ void TLSWrap::MemoryInfo(MemoryTracker* tracker) const { void TLSWrap::CertCbDone(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); CHECK(w->is_waiting_cert_cb() && w->cert_cb_running_); @@ -1578,7 +1578,7 @@ void TLSWrap::CertCbDone(const FunctionCallbackInfo& args) { void TLSWrap::SetALPNProtocols(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Environment* env = w->env(); if (args.Length() < 1 || !Buffer::HasInstance(args[0])) return env->ThrowTypeError("Must give a Buffer as first argument"); @@ -1597,7 +1597,7 @@ void TLSWrap::SetALPNProtocols(const FunctionCallbackInfo& args) { void TLSWrap::GetPeerCertificate(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Environment* env = w->env(); bool abbreviated = args.Length() < 1 || !args[0]->IsTrue(); @@ -1613,7 +1613,7 @@ void TLSWrap::GetPeerCertificate(const FunctionCallbackInfo& args) { void TLSWrap::GetPeerX509Certificate(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Environment* env = w->env(); X509Certificate::GetPeerCertificateFlag flag = w->is_server() @@ -1627,7 +1627,7 @@ void TLSWrap::GetPeerX509Certificate(const FunctionCallbackInfo& args) { void TLSWrap::GetCertificate(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Environment* env = w->env(); Local ret; @@ -1637,7 +1637,7 @@ void TLSWrap::GetCertificate(const FunctionCallbackInfo& args) { void TLSWrap::GetX509Certificate(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Environment* env = w->env(); Local ret; if (X509Certificate::GetCert(env, w->ssl_).ToLocal(&ret)) @@ -1648,7 +1648,7 @@ void TLSWrap::GetFinished(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); // We cannot just pass nullptr to SSL_get_finished() // because it would further be propagated to memcpy(), @@ -1679,7 +1679,7 @@ void TLSWrap::GetPeerFinished(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); // We cannot just pass nullptr to SSL_get_peer_finished() // because it would further be propagated to memcpy(), @@ -1710,7 +1710,7 @@ void TLSWrap::GetSession(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); SSL_SESSION* sess = SSL_get_session(w->ssl_.get()); if (sess == nullptr) @@ -1739,7 +1739,7 @@ void TLSWrap::SetSession(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); if (args.Length() < 1) return THROW_ERR_MISSING_ARGS(env, "Session argument is mandatory"); @@ -1756,7 +1756,7 @@ void TLSWrap::SetSession(const FunctionCallbackInfo& args) { void TLSWrap::IsSessionReused(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); bool yes = SSL_session_reused(w->ssl_.get()); args.GetReturnValue().Set(yes); } @@ -1764,7 +1764,7 @@ void TLSWrap::IsSessionReused(const FunctionCallbackInfo& args) { void TLSWrap::VerifyError(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); // XXX(bnoordhuis) The UNABLE_TO_GET_ISSUER_CERT error when there is no // peer certificate is questionable but it's compatible with what was @@ -1792,14 +1792,14 @@ void TLSWrap::VerifyError(const FunctionCallbackInfo& args) { void TLSWrap::GetCipher(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); args.GetReturnValue().Set( GetCipherInfo(env, w->ssl_).FromMaybe(Local())); } void TLSWrap::LoadSession(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); // TODO(@sam-github) check arg length and types in js, and CHECK in c++ if (args.Length() >= 1 && Buffer::HasInstance(args[0])) { @@ -1816,7 +1816,7 @@ void TLSWrap::LoadSession(const FunctionCallbackInfo& args) { void TLSWrap::GetSharedSigalgs(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); SSL* ssl = w->ssl_.get(); int nsig = SSL_get_shared_sigalgs(ssl, 0, nullptr, nullptr, nullptr, nullptr, @@ -1898,7 +1898,7 @@ void TLSWrap::ExportKeyingMaterial(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); uint32_t olen = args[0].As()->Value(); Utf8Value label(env->isolate(), args[1]); @@ -1937,13 +1937,13 @@ void TLSWrap::ExportKeyingMaterial(const FunctionCallbackInfo& args) { void TLSWrap::EndParser(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); w->hello_parser_.End(); } void TLSWrap::Renegotiate(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); ClearErrorOnReturn clear_error_on_return; if (SSL_renegotiate(w->ssl_.get()) != 1) return ThrowCryptoError(w->env(), ERR_get_error()); @@ -1951,7 +1951,7 @@ void TLSWrap::Renegotiate(const FunctionCallbackInfo& args) { void TLSWrap::GetTLSTicket(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Environment* env = w->env(); SSL_SESSION* sess = SSL_get_session(w->ssl_.get()); @@ -1971,14 +1971,14 @@ void TLSWrap::GetTLSTicket(const FunctionCallbackInfo& args) { void TLSWrap::NewSessionDone(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); w->awaiting_new_session_ = false; w->NewSessionDoneCb(); } void TLSWrap::SetOCSPResponse(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Environment* env = w->env(); if (args.Length() < 1) @@ -1991,14 +1991,14 @@ void TLSWrap::SetOCSPResponse(const FunctionCallbackInfo& args) { void TLSWrap::RequestOCSP(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); SSL_set_tlsext_status_type(w->ssl_.get(), TLSEXT_STATUSTYPE_ocsp); } void TLSWrap::GetEphemeralKeyInfo(const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Environment* env = Environment::GetCurrent(args); CHECK(w->ssl_); @@ -2017,7 +2017,7 @@ void TLSWrap::GetEphemeralKeyInfo(const FunctionCallbackInfo& args) { void TLSWrap::GetProtocol(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); args.GetReturnValue().Set( OneByteString(env->isolate(), SSL_get_version(w->ssl_.get()))); } @@ -2025,7 +2025,7 @@ void TLSWrap::GetProtocol(const FunctionCallbackInfo& args) { void TLSWrap::GetALPNNegotiatedProto(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); const unsigned char* alpn_proto; unsigned int alpn_proto_len; @@ -2051,7 +2051,7 @@ void TLSWrap::GetALPNNegotiatedProto(const FunctionCallbackInfo& args) { void TLSWrap::WritesIssuedByPrevListenerDone( const FunctionCallbackInfo& args) { TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); Debug(w, "WritesIssuedByPrevListenerDone is called"); w->has_active_write_issued_by_prev_listener_ = false; @@ -2076,7 +2076,7 @@ void TLSWrap::SetMaxSendFragment(const FunctionCallbackInfo& args) { CHECK(args.Length() >= 1 && args[0]->IsNumber()); Environment* env = Environment::GetCurrent(args); TLSWrap* w; - ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&w, args.This()); int rv = SSL_set_max_send_fragment( w->ssl_.get(), args[0]->Int32Value(env->context()).FromJust()); diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h index 0ae2946e5e..6367776662 100644 --- a/src/crypto/crypto_util.h +++ b/src/crypto/crypto_util.h @@ -136,7 +136,7 @@ void Decode(const v8::FunctionCallbackInfo& args, void (*callback)(T*, const v8::FunctionCallbackInfo&, const char*, size_t)) { T* ctx; - ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&ctx, args.This()); if (args[0]->IsString()) { StringBytes::InlineDecoder decoder; @@ -412,7 +412,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork { Environment* env = Environment::GetCurrent(args); CryptoJob* job; - ASSIGN_OR_RETURN_UNWRAP(&job, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&job, args.This()); if (job->mode() == kCryptoJobAsync) return job->ScheduleWork(); diff --git a/src/crypto/crypto_x509.cc b/src/crypto/crypto_x509.cc index 3ce4d26be8..a5d40e1bf1 100644 --- a/src/crypto/crypto_x509.cc +++ b/src/crypto/crypto_x509.cc @@ -56,7 +56,7 @@ template void Fingerprint(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); Local ret; if (GetFingerprintDigest(env, algo(), cert->get()).ToLocal(&ret)) args.GetReturnValue().Set(ret); @@ -208,7 +208,7 @@ template Property( static void ReturnPropertyThroughBIO(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); BIOPointer bio(BIO_new(BIO_s_mem())); CHECK(bio); Local ret; @@ -244,7 +244,7 @@ template Property(Environment* env, X509* cert)> static void ReturnProperty(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); Local ret; if (Property(env, cert->get()).ToLocal(&ret)) args.GetReturnValue().Set(ret); } @@ -264,7 +264,7 @@ void X509Certificate::Raw(const FunctionCallbackInfo& args) { void X509Certificate::PublicKey(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); // TODO(tniessen): consider checking X509_get_pubkey() when the // X509Certificate object is being created. @@ -283,7 +283,7 @@ void X509Certificate::PublicKey(const FunctionCallbackInfo& args) { void X509Certificate::Pem(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); BIOPointer bio(BIO_new(BIO_s_mem())); CHECK(bio); if (PEM_write_bio_X509(bio.get(), cert->get())) @@ -293,14 +293,14 @@ void X509Certificate::Pem(const FunctionCallbackInfo& args) { void X509Certificate::CheckCA(const FunctionCallbackInfo& args) { X509Certificate* cert; ClearErrorOnReturn clear_error_on_return; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); args.GetReturnValue().Set(X509_check_ca(cert->get()) == 1); } void X509Certificate::CheckHost(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); CHECK(args[0]->IsString()); // name CHECK(args[1]->IsUint32()); // flags @@ -335,7 +335,7 @@ void X509Certificate::CheckHost(const FunctionCallbackInfo& args) { void X509Certificate::CheckEmail(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); CHECK(args[0]->IsString()); // name CHECK(args[1]->IsUint32()); // flags @@ -362,7 +362,7 @@ void X509Certificate::CheckEmail(const FunctionCallbackInfo& args) { void X509Certificate::CheckIP(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); CHECK(args[0]->IsString()); // IP CHECK(args[1]->IsUint32()); // flags @@ -385,7 +385,7 @@ void X509Certificate::CheckIP(const FunctionCallbackInfo& args) { void X509Certificate::CheckIssued(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); CHECK(args[0]->IsObject()); CHECK(X509Certificate::HasInstance(env, args[0].As())); @@ -401,7 +401,7 @@ void X509Certificate::CheckIssued(const FunctionCallbackInfo& args) { void X509Certificate::CheckPrivateKey(const FunctionCallbackInfo& args) { X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); CHECK(args[0]->IsObject()); KeyObjectHandle* key; @@ -418,7 +418,7 @@ void X509Certificate::CheckPrivateKey(const FunctionCallbackInfo& args) { void X509Certificate::Verify(const FunctionCallbackInfo& args) { X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); CHECK(args[0]->IsObject()); KeyObjectHandle* key; @@ -436,7 +436,7 @@ void X509Certificate::Verify(const FunctionCallbackInfo& args) { void X509Certificate::ToLegacy(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); ClearErrorOnReturn clear_error_on_return; Local ret; if (X509ToObject(env, cert->get()).ToLocal(&ret)) @@ -445,7 +445,7 @@ void X509Certificate::ToLegacy(const FunctionCallbackInfo& args) { void X509Certificate::GetIssuerCert(const FunctionCallbackInfo& args) { X509Certificate* cert; - ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&cert, args.This()); if (cert->issuer_cert_) args.GetReturnValue().Set(cert->issuer_cert_->object()); } diff --git a/src/env-inl.h b/src/env-inl.h index 3cd7b6fb31..7f1bf04073 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -62,31 +62,6 @@ inline uv_loop_t* IsolateData::event_loop() const { return event_loop_; } -inline void IsolateData::SetCppgcReference(v8::Isolate* isolate, - v8::Local object, - void* wrappable) { - v8::CppHeap* heap = isolate->GetCppHeap(); - CHECK_NOT_NULL(heap); - v8::WrapperDescriptor descriptor = heap->wrapper_descriptor(); - uint16_t required_size = std::max(descriptor.wrappable_instance_index, - descriptor.wrappable_type_index); - CHECK_GT(object->InternalFieldCount(), required_size); - - uint16_t* id_ptr = nullptr; - { - Mutex::ScopedLock lock(isolate_data_mutex_); - auto it = - wrapper_data_map_.find(descriptor.embedder_id_for_garbage_collected); - CHECK_NE(it, wrapper_data_map_.end()); - id_ptr = &(it->second->cppgc_id); - } - - object->SetAlignedPointerInInternalField(descriptor.wrappable_type_index, - id_ptr); - object->SetAlignedPointerInInternalField(descriptor.wrappable_instance_index, - wrappable); -} - inline uint16_t* IsolateData::embedder_id_for_cppgc() const { return &(wrapper_data_->cppgc_id); } diff --git a/src/env.cc b/src/env.cc index d0dd5501ce..4f8d4197cd 100644 --- a/src/env.cc +++ b/src/env.cc @@ -23,6 +23,7 @@ #include "util-inl.h" #include "v8-cppgc.h" #include "v8-profiler.h" +#include "v8-sandbox.h" // v8::Object::Wrap(), v8::Object::Unwrap() #include #include @@ -70,7 +71,6 @@ using v8::TryCatch; using v8::Uint32; using v8::Undefined; using v8::Value; -using v8::WrapperDescriptor; using worker::Worker; extern bool node_is_nwjs; @@ -543,36 +543,17 @@ IsolateData::IsolateData(Isolate* isolate, v8::CppHeap* cpp_heap = isolate->GetCppHeap(); uint16_t cppgc_id = kDefaultCppGCEmebdderID; - if (cpp_heap != nullptr) { - // The general convention of the wrappable layout for cppgc in the - // ecosystem is: - // [ 0 ] -> embedder id - // [ 1 ] -> wrappable instance - // If the Isolate includes a CppHeap attached by another embedder, - // And if they also use the field 0 for the ID, we DCHECK that - // the layout matches our layout, and record the embedder ID for cppgc - // to avoid accidentally enabling cppgc on non-cppgc-managed wrappers . - v8::WrapperDescriptor descriptor = cpp_heap->wrapper_descriptor(); - if (descriptor.wrappable_type_index == BaseObject::kEmbedderType) { - cppgc_id = descriptor.embedder_id_for_garbage_collected; - DCHECK_EQ(descriptor.wrappable_instance_index, BaseObject::kSlot); - } - // If the CppHeap uses the slot we use to put non-cppgc-traced BaseObject - // for embedder ID, V8 could accidentally enable cppgc on them. So - // safe guard against this. - DCHECK_NE(descriptor.wrappable_type_index, BaseObject::kSlot); - } else { - cpp_heap_ = CppHeap::Create( - platform, - CppHeapCreateParams{ - {}, - WrapperDescriptor( - BaseObject::kEmbedderType, BaseObject::kSlot, cppgc_id)}); - isolate->AttachCppHeap(cpp_heap_.get()); - } + // We do not care about overflow since we just want this to be different // from the cppgc id. uint16_t non_cppgc_id = cppgc_id + 1; + if (cpp_heap == nullptr) { + cpp_heap_ = CppHeap::Create(platform, v8::CppHeapCreateParams{{}}); + // TODO(joyeecheung): pass it into v8::Isolate::CreateParams and let V8 + // own it when we can keep the isolate registered/task runner discoverable + // during isolate disposal. + isolate->AttachCppHeap(cpp_heap_.get()); + } { // GC could still be run after the IsolateData is destroyed, so we store @@ -604,11 +585,12 @@ IsolateData::~IsolateData() { } } -// Public API +// Deprecated API, embedders should use v8::Object::Wrap() directly instead. void SetCppgcReference(Isolate* isolate, Local object, void* wrappable) { - IsolateData::SetCppgcReference(isolate, object, wrappable); + v8::Object::Wrap( + isolate, object, wrappable); } void IsolateData::MemoryInfo(MemoryTracker* tracker) const { diff --git a/src/env.h b/src/env.h index c0d659c204..8e89f4d5f8 100644 --- a/src/env.h +++ b/src/env.h @@ -165,10 +165,6 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer { uint16_t* embedder_id_for_cppgc() const; uint16_t* embedder_id_for_non_cppgc() const; - static inline void SetCppgcReference(v8::Isolate* isolate, - v8::Local object, - void* wrappable); - inline uv_loop_t* event_loop() const; inline MultiIsolatePlatform* platform() const; inline const SnapshotData* snapshot_data() const; diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index 1fbe0178c7..27289ab7ee 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -39,7 +39,7 @@ using v8::Value; void HandleWrap::Ref(const FunctionCallbackInfo& args) { HandleWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); if (IsAlive(wrap)) uv_ref(wrap->GetHandle()); @@ -48,7 +48,7 @@ void HandleWrap::Ref(const FunctionCallbackInfo& args) { void HandleWrap::Unref(const FunctionCallbackInfo& args) { HandleWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); if (IsAlive(wrap)) uv_unref(wrap->GetHandle()); @@ -57,14 +57,14 @@ void HandleWrap::Unref(const FunctionCallbackInfo& args) { void HandleWrap::HasRef(const FunctionCallbackInfo& args) { HandleWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); args.GetReturnValue().Set(HasRef(wrap)); } void HandleWrap::Close(const FunctionCallbackInfo& args) { HandleWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); wrap->Close(args[0]); } diff --git a/src/histogram.cc b/src/histogram.cc index 4f58359fe5..4dbdea9be5 100644 --- a/src/histogram.cc +++ b/src/histogram.cc @@ -165,7 +165,7 @@ void HistogramBase::MemoryInfo(MemoryTracker* tracker) const { void HistogramBase::RecordDelta(const FunctionCallbackInfo& args) { HistogramBase* histogram; - ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.This()); (*histogram)->RecordDelta(); } @@ -185,7 +185,7 @@ void HistogramBase::Record(const FunctionCallbackInfo& args) { if (!lossless || value < 1) return THROW_ERR_OUT_OF_RANGE(env, "value is out of range"); HistogramBase* histogram; - ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.This()); (*histogram)->Record(value); } @@ -204,7 +204,7 @@ void HistogramBase::FastRecord(Local receiver, void HistogramBase::Add(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); HistogramBase* histogram; - ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.This()); CHECK(GetConstructorTemplate(env->isolate_data())->HasInstance(args[0])); HistogramBase* other; @@ -432,7 +432,7 @@ void IntervalHistogram::OnStop() { void IntervalHistogram::Start(const FunctionCallbackInfo& args) { IntervalHistogram* histogram; - ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.This()); histogram->OnStart(args[0]->IsTrue() ? StartFlags::RESET : StartFlags::NONE); } @@ -444,7 +444,7 @@ void IntervalHistogram::FastStart(Local receiver, bool reset) { void IntervalHistogram::Stop(const FunctionCallbackInfo& args) { IntervalHistogram* histogram; - ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.This()); histogram->OnStop(); } @@ -455,67 +455,67 @@ void IntervalHistogram::FastStop(Local receiver) { } void HistogramImpl::GetCount(const FunctionCallbackInfo& args) { - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); double value = static_cast((*histogram)->Count()); args.GetReturnValue().Set(value); } void HistogramImpl::GetCountBigInt(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); args.GetReturnValue().Set( BigInt::NewFromUnsigned(env->isolate(), (*histogram)->Count())); } void HistogramImpl::GetMin(const FunctionCallbackInfo& args) { - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); double value = static_cast((*histogram)->Min()); args.GetReturnValue().Set(value); } void HistogramImpl::GetMinBigInt(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); args.GetReturnValue().Set(BigInt::New(env->isolate(), (*histogram)->Min())); } void HistogramImpl::GetMax(const FunctionCallbackInfo& args) { - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); double value = static_cast((*histogram)->Max()); args.GetReturnValue().Set(value); } void HistogramImpl::GetMaxBigInt(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); args.GetReturnValue().Set(BigInt::New(env->isolate(), (*histogram)->Max())); } void HistogramImpl::GetMean(const FunctionCallbackInfo& args) { - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); args.GetReturnValue().Set((*histogram)->Mean()); } void HistogramImpl::GetExceeds(const FunctionCallbackInfo& args) { - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); double value = static_cast((*histogram)->Exceeds()); args.GetReturnValue().Set(value); } void HistogramImpl::GetExceedsBigInt(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); args.GetReturnValue().Set( BigInt::New(env->isolate(), (*histogram)->Exceeds())); } void HistogramImpl::GetStddev(const FunctionCallbackInfo& args) { - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); args.GetReturnValue().Set((*histogram)->Stddev()); } void HistogramImpl::GetPercentile(const FunctionCallbackInfo& args) { - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); CHECK(args[0]->IsNumber()); double percentile = args[0].As()->Value(); double value = static_cast((*histogram)->Percentile(percentile)); @@ -525,7 +525,7 @@ void HistogramImpl::GetPercentile(const FunctionCallbackInfo& args) { void HistogramImpl::GetPercentileBigInt( const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); CHECK(args[0]->IsNumber()); double percentile = args[0].As()->Value(); int64_t value = (*histogram)->Percentile(percentile); @@ -534,7 +534,7 @@ void HistogramImpl::GetPercentileBigInt( void HistogramImpl::GetPercentiles(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); CHECK(args[0]->IsMap()); Local map = args[0].As(); (*histogram)->Percentiles([map, env](double key, int64_t value) { @@ -548,7 +548,7 @@ void HistogramImpl::GetPercentiles(const FunctionCallbackInfo& args) { void HistogramImpl::GetPercentilesBigInt( const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); CHECK(args[0]->IsMap()); Local map = args[0].As(); (*histogram)->Percentiles([map, env](double key, int64_t value) { @@ -560,7 +560,7 @@ void HistogramImpl::GetPercentilesBigInt( } void HistogramImpl::DoReset(const FunctionCallbackInfo& args) { - HistogramImpl* histogram = HistogramImpl::FromJSObject(args.Holder()); + HistogramImpl* histogram = HistogramImpl::FromJSObject(args.This()); (*histogram)->Reset(); } diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 41ae0e43b0..75e08a7ec4 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -132,14 +132,14 @@ class JSBindingsConnection : public BaseObject { static void Disconnect(const FunctionCallbackInfo& info) { JSBindingsConnection* session; - ASSIGN_OR_RETURN_UNWRAP(&session, info.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&session, info.This()); session->Disconnect(); } static void Dispatch(const FunctionCallbackInfo& info) { Environment* env = Environment::GetCurrent(info); JSBindingsConnection* session; - ASSIGN_OR_RETURN_UNWRAP(&session, info.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&session, info.This()); CHECK(info[0]->IsString()); if (session->session_) { @@ -205,11 +205,8 @@ void InspectorConsoleCall(const FunctionCallbackInfo& info) { CHECK(inspector_method->IsFunction()); if (!env->is_in_inspector_console_call()) { env->set_is_in_inspector_console_call(true); - MaybeLocal ret = - inspector_method.As()->Call(context, - info.Holder(), - call_args.length(), - call_args.out()); + MaybeLocal ret = inspector_method.As()->Call( + context, info.This(), call_args.length(), call_args.out()); env->set_is_in_inspector_console_call(false); if (ret.IsEmpty()) return; @@ -218,10 +215,8 @@ void InspectorConsoleCall(const FunctionCallbackInfo& info) { Local node_method = info[1]; CHECK(node_method->IsFunction()); - USE(node_method.As()->Call(context, - info.Holder(), - call_args.length(), - call_args.out())); + USE(node_method.As()->Call( + context, info.This(), call_args.length(), call_args.out())); } static void* GetAsyncTask(int64_t asyncId) { diff --git a/src/js_stream.cc b/src/js_stream.cc index 68f6915eb6..55cbdf5bf2 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -164,7 +164,7 @@ void JSStream::Finish(const FunctionCallbackInfo& args) { void JSStream::ReadBuffer(const FunctionCallbackInfo& args) { JSStream* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); ArrayBufferViewContents buffer(args[0]); const char* data = buffer.data(); @@ -194,7 +194,7 @@ void JSStream::ReadBuffer(const FunctionCallbackInfo& args) { void JSStream::EmitEOF(const FunctionCallbackInfo& args) { JSStream* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); wrap->EmitRead(UV_EOF); } diff --git a/src/js_udp_wrap.cc b/src/js_udp_wrap.cc index ed2238a3b5..a4f183025d 100644 --- a/src/js_udp_wrap.cc +++ b/src/js_udp_wrap.cc @@ -137,12 +137,12 @@ SocketAddress JSUDPWrap::GetSockName() { void JSUDPWrap::New(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK(args.IsConstructCall()); - new JSUDPWrap(env, args.Holder()); + new JSUDPWrap(env, args.This()); } void JSUDPWrap::EmitReceived(const FunctionCallbackInfo& args) { JSUDPWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); Environment* env = wrap->env(); ArrayBufferViewContents buffer(args[0]); @@ -176,7 +176,7 @@ void JSUDPWrap::EmitReceived(const FunctionCallbackInfo& args) { void JSUDPWrap::OnSendDone(const FunctionCallbackInfo& args) { JSUDPWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK(args[0]->IsObject()); CHECK(args[1]->IsInt32()); @@ -189,7 +189,7 @@ void JSUDPWrap::OnSendDone(const FunctionCallbackInfo& args) { void JSUDPWrap::OnAfterBind(const FunctionCallbackInfo& args) { JSUDPWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); wrap->listener()->OnAfterBind(); } diff --git a/src/node.h b/src/node.h index dc5196c36f..a7c6ff7b52 100644 --- a/src/node.h +++ b/src/node.h @@ -1560,24 +1560,14 @@ void RegisterSignalHandler(int signal, bool reset_handler = false); #endif // _WIN32 -// Configure the layout of the JavaScript object with a cppgc::GarbageCollected -// instance so that when the JavaScript object is reachable, the garbage -// collected instance would have its Trace() method invoked per the cppgc -// contract. To make it work, the process must have called -// cppgc::InitializeProcess() before, which is usually the case for addons -// loaded by the stand-alone Node.js executable. Embedders of Node.js can use -// either need to call it themselves or make sure that -// ProcessInitializationFlags::kNoInitializeCppgc is *not* set for cppgc to -// work. -// If the CppHeap is owned by Node.js, which is usually the case for addon, -// the object must be created with at least two internal fields available, -// and the first two internal fields would be configured by Node.js. -// This may be superseded by a V8 API in the future, see -// https://bugs.chromium.org/p/v8/issues/detail?id=13960. Until then this -// serves as a helper for Node.js isolates. -NODE_EXTERN void SetCppgcReference(v8::Isolate* isolate, - v8::Local object, - void* wrappable); +// This is kept as a compatibility layer for addons to wrap cppgc-managed +// objects on Node.js versions without v8::Object::Wrap(). Addons created to +// work with only Node.js versions with v8::Object::Wrap() should use that +// instead. +NODE_DEPRECATED("Use v8::Object::Wrap()", + NODE_EXTERN void SetCppgcReference(v8::Isolate* isolate, + v8::Local object, + void* wrappable)); } // namespace node diff --git a/src/node_blob.cc b/src/node_blob.cc index 1fe6237e73..aade8bfa21 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -247,7 +247,7 @@ void Blob::New(const FunctionCallbackInfo& args) { void Blob::GetReader(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Blob* blob; - ASSIGN_OR_RETURN_UNWRAP(&blob, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&blob, args.This()); BaseObjectPtr reader = Blob::Reader::Create(env, BaseObjectPtr(blob)); @@ -257,7 +257,7 @@ void Blob::GetReader(const FunctionCallbackInfo& args) { void Blob::ToSlice(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Blob* blob; - ASSIGN_OR_RETURN_UNWRAP(&blob, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&blob, args.This()); CHECK(args[0]->IsUint32()); CHECK(args[1]->IsUint32()); size_t start = args[0].As()->Value(); @@ -326,7 +326,7 @@ BaseObjectPtr Blob::Reader::Create(Environment* env, void Blob::Reader::Pull(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Blob::Reader* reader; - ASSIGN_OR_RETURN_UNWRAP(&reader, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&reader, args.This()); CHECK(args[0]->IsFunction()); Local fn = args[0].As(); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 02dfbb3838..69e99d3ffd 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1036,7 +1036,7 @@ void ContextifyScript::CreateCachedData( const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ContextifyScript* wrapped_script; - ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.This()); Local unbound_script = PersistentToLocal::Default(env->isolate(), wrapped_script->script_); std::unique_ptr cached_data( @@ -1056,7 +1056,7 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); ContextifyScript* wrapped_script; - ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.Holder()); + ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.This()); CHECK_EQ(args.Length(), 5); CHECK(args[0]->IsObject() || args[0]->IsNull()); @@ -1117,7 +1117,7 @@ bool ContextifyScript::EvalMachine(Local context, if (!env->can_call_into_js()) return false; - if (!ContextifyScript::InstanceOf(env, args.Holder())) { + if (!ContextifyScript::InstanceOf(env, args.This())) { THROW_ERR_INVALID_THIS( env, "Script methods can only be called on script instances."); @@ -1126,7 +1126,7 @@ bool ContextifyScript::EvalMachine(Local context, TryCatchScope try_catch(env); ContextifyScript* wrapped_script; - ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.Holder(), false); + ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.This(), false); Local unbound_script = PersistentToLocal::Default(env->isolate(), wrapped_script->script_); Local