Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "vm,src: add property query interceptors" #53348

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 2 additions & 66 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ using v8::FunctionTemplate;
using v8::HandleScope;
using v8::IndexedPropertyHandlerConfiguration;
using v8::Int32;
using v8::Integer;
using v8::Intercepted;
using v8::Isolate;
using v8::Just;
Expand Down Expand Up @@ -177,22 +176,20 @@ void ContextifyContext::InitializeGlobalTemplates(IsolateData* isolate_data) {
NamedPropertyHandlerConfiguration config(
PropertyGetterCallback,
PropertySetterCallback,
PropertyQueryCallback,
PropertyDescriptorCallback,
PropertyDeleterCallback,
PropertyEnumeratorCallback,
PropertyDefinerCallback,
PropertyDescriptorCallback,
{},
PropertyHandlerFlags::kHasNoSideEffect);

IndexedPropertyHandlerConfiguration indexed_config(
IndexedPropertyGetterCallback,
IndexedPropertySetterCallback,
IndexedPropertyQueryCallback,
IndexedPropertyDescriptorCallback,
IndexedPropertyDeleterCallback,
PropertyEnumeratorCallback,
IndexedPropertyDefinerCallback,
IndexedPropertyDescriptorCallback,
{},
PropertyHandlerFlags::kHasNoSideEffect);

Expand Down Expand Up @@ -357,14 +354,12 @@ void ContextifyContext::RegisterExternalReferences(
ExternalReferenceRegistry* registry) {
registry->Register(MakeContext);
registry->Register(CompileFunction);
registry->Register(PropertyQueryCallback);
registry->Register(PropertyGetterCallback);
registry->Register(PropertySetterCallback);
registry->Register(PropertyDescriptorCallback);
registry->Register(PropertyDeleterCallback);
registry->Register(PropertyEnumeratorCallback);
registry->Register(PropertyDefinerCallback);
registry->Register(IndexedPropertyQueryCallback);
registry->Register(IndexedPropertyGetterCallback);
registry->Register(IndexedPropertySetterCallback);
registry->Register(IndexedPropertyDescriptorCallback);
Expand Down Expand Up @@ -463,51 +458,6 @@ bool ContextifyContext::IsStillInitializing(const ContextifyContext* ctx) {
return ctx == nullptr || ctx->context_.IsEmpty();
}

// static
Intercepted ContextifyContext::PropertyQueryCallback(
Local<Name> property, const PropertyCallbackInfo<Integer>& args) {
ContextifyContext* ctx = ContextifyContext::Get(args);

// Still initializing
if (IsStillInitializing(ctx)) {
return Intercepted::kNo;
}

Local<Context> context = ctx->context();
Local<Object> sandbox = ctx->sandbox();

PropertyAttribute attr;

Maybe<bool> maybe_has = sandbox->HasRealNamedProperty(context, property);
if (maybe_has.IsNothing()) {
return Intercepted::kNo;
} else if (maybe_has.FromJust()) {
Maybe<PropertyAttribute> maybe_attr =
sandbox->GetRealNamedPropertyAttributes(context, property);
if (!maybe_attr.To(&attr)) {
return Intercepted::kNo;
}
args.GetReturnValue().Set(attr);
return Intercepted::kYes;
} else {
maybe_has = ctx->global_proxy()->HasRealNamedProperty(context, property);
if (maybe_has.IsNothing()) {
return Intercepted::kNo;
} else if (maybe_has.FromJust()) {
Maybe<PropertyAttribute> maybe_attr =
ctx->global_proxy()->GetRealNamedPropertyAttributes(context,
property);
if (!maybe_attr.To(&attr)) {
return Intercepted::kNo;
}
args.GetReturnValue().Set(attr);
return Intercepted::kYes;
}
}

return Intercepted::kNo;
}

// static
Intercepted ContextifyContext::PropertyGetterCallback(
Local<Name> property, const PropertyCallbackInfo<Value>& args) {
Expand Down Expand Up @@ -759,20 +709,6 @@ void ContextifyContext::PropertyEnumeratorCallback(
args.GetReturnValue().Set(properties);
}

// static
Intercepted ContextifyContext::IndexedPropertyQueryCallback(
uint32_t index, const PropertyCallbackInfo<Integer>& args) {
ContextifyContext* ctx = ContextifyContext::Get(args);

// Still initializing
if (IsStillInitializing(ctx)) {
return Intercepted::kNo;
}

return ContextifyContext::PropertyQueryCallback(
Uint32ToName(ctx->context(), index), args);
}

// static
Intercepted ContextifyContext::IndexedPropertyGetterCallback(
uint32_t index, const PropertyCallbackInfo<Value>& args) {
Expand Down
8 changes: 1 addition & 7 deletions src/node_contextify.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ class ContextifyContext : public BaseObject {
bool produce_cached_data,
v8::Local<v8::Symbol> id_symbol,
const errors::TryCatchScope& try_catch);
static void WeakCallback(
const v8::WeakCallbackInfo<ContextifyContext>& data);
static v8::Intercepted PropertyQueryCallback(
v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Integer>& args);
static void WeakCallback(const v8::WeakCallbackInfo<ContextifyContext>& data);
static v8::Intercepted PropertyGetterCallback(
v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& args);
Expand All @@ -118,8 +114,6 @@ class ContextifyContext : public BaseObject {
const v8::PropertyCallbackInfo<v8::Boolean>& args);
static void PropertyEnumeratorCallback(
const v8::PropertyCallbackInfo<v8::Array>& args);
static v8::Intercepted IndexedPropertyQueryCallback(
uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& args);
static v8::Intercepted IndexedPropertyGetterCallback(
uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& args);
static v8::Intercepted IndexedPropertySetterCallback(
Expand Down
83 changes: 0 additions & 83 deletions test/parallel/test-vm-global-property-prototype.js

This file was deleted.