diff --git a/deps/v8/include/v8-object.h b/deps/v8/include/v8-object.h index bad299fc42948d..49369317b72c39 100644 --- a/deps/v8/include/v8-object.h +++ b/deps/v8/include/v8-object.h @@ -20,6 +20,8 @@ class Function; class FunctionTemplate; template class PropertyCallbackInfo; +class Module; +class UnboundScript; /** * A private symbol @@ -480,6 +482,21 @@ class V8_EXPORT Object : public Value { /** Sets the value in an internal field. */ void SetInternalField(int index, Local value); + /** + * Warning: These are Node.js-specific extentions used to avoid breaking + * changes in Node.js v18.x. They do not exist in V8 upstream and will + * not exist in Node.js v21.x. Node.js embedders and addon authors should + * not use them from v18.x. + */ +#ifndef NODE_WANT_INTERNALS + V8_DEPRECATED("This extention should only be used by Node.js core") +#endif + void SetInternalFieldForNodeCore(int index, Local value); +#ifndef NODE_WANT_INTERNALS + V8_DEPRECATED("This extention should only be used by Node.js core") +#endif + void SetInternalFieldForNodeCore(int index, Local value); + /** * Gets a 2-byte-aligned native pointer from an internal field. This field * must have been set by SetAlignedPointerInInternalField, everything else diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index 8d224bea2e2261..3b1a81680b0323 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -5948,14 +5948,33 @@ Local v8::Object::SlowGetInternalField(int index) { return Utils::ToLocal(value); } -void v8::Object::SetInternalField(int index, v8::Local value) { - i::Handle obj = Utils::OpenHandle(this); +template +void SetInternalFieldImpl(v8::Object* receiver, int index, v8::Local value) { + i::Handle obj = Utils::OpenHandle(receiver); const char* location = "v8::Object::SetInternalField()"; if (!InternalFieldOK(obj, index, location)) return; i::Handle val = Utils::OpenHandle(*value); i::Handle::cast(obj)->SetEmbedderField(index, *val); } +void v8::Object::SetInternalField(int index, v8::Local value) { + SetInternalFieldImpl(this, index, value); +} + +/** + * These are Node.js-specific extentions used to avoid breaking changes in + * Node.js v20.x. + */ +void v8::Object::SetInternalFieldForNodeCore(int index, + v8::Local value) { + SetInternalFieldImpl(this, index, value); +} + +void v8::Object::SetInternalFieldForNodeCore(int index, + v8::Local value) { + SetInternalFieldImpl(this, index, value); +} + void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { i::Handle obj = Utils::OpenHandle(this); const char* location = "v8::Object::GetAlignedPointerFromInternalField()";