Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 927ff012f7740e4afd3a4c3e6f837f2fb4e68787..0ec03484a64f3c0398bd36d76268c7e91e192422 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -151,6 +151,10 @@ namespace v8 { |
PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ |
false, i::HandleScope, false) |
+#define ENTER_V8_FOR_NEW_CONTEXT(isolate) \ |
+ i::VMState<v8::OTHER> __state__((isolate)); \ |
+ i::DisallowExceptions __no_exceptions__((isolate)) |
+ |
#define EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, value) \ |
do { \ |
if (has_pending_exception) { \ |
@@ -6203,12 +6207,15 @@ static i::Handle<ObjectType> CreateEnvironment( |
v8::DeserializeInternalFieldsCallback internal_fields_deserializer) { |
i::Handle<ObjectType> result; |
- // Enter V8 via an ENTER_V8 scope. |
{ |
- ENTER_V8(isolate); |
+ ENTER_V8_FOR_NEW_CONTEXT(isolate); |
Yang
2017/01/17 09:54:23
What about stack overflow, which trigger RangeErro
jochen (gone - plz use gerrit)
2017/01/17 10:24:01
we'd just swallow the exception and return an empt
|
v8::Local<ObjectTemplate> proxy_template; |
i::Handle<i::FunctionTemplateInfo> proxy_constructor; |
i::Handle<i::FunctionTemplateInfo> global_constructor; |
+ i::Handle<i::Object> named_interceptor( |
+ isolate->factory()->undefined_value()); |
+ i::Handle<i::Object> indexed_interceptor( |
+ isolate->factory()->undefined_value()); |
if (!maybe_global_template.IsEmpty()) { |
v8::Local<v8::ObjectTemplate> global_template = |
@@ -6241,6 +6248,25 @@ static i::Handle<ObjectType> CreateEnvironment( |
global_constructor->set_access_check_info( |
isolate->heap()->undefined_value()); |
} |
+ |
+ // Same for other interceptors. |
+ if (!global_constructor->named_property_handler()->IsUndefined(isolate)) { |
+ named_interceptor = |
+ handle(global_constructor->named_property_handler(), isolate); |
+ auto obj = CreateInterceptorInfo( |
+ isolate, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
+ nullptr, Local<Value>(), PropertyHandlerFlags::kNone); |
Yang
2017/01/17 09:54:22
Do we want a canonical no-op interceptor info, cre
jochen (gone - plz use gerrit)
2017/01/17 10:24:01
done
|
+ global_constructor->set_named_property_handler(*obj); |
+ } |
+ if (!global_constructor->indexed_property_handler()->IsUndefined( |
+ isolate)) { |
+ indexed_interceptor = |
+ handle(global_constructor->indexed_property_handler(), isolate); |
+ auto obj = CreateInterceptorInfo( |
+ isolate, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
+ nullptr, Local<Value>(), PropertyHandlerFlags::kNone); |
+ global_constructor->set_indexed_property_handler(*obj); |
+ } |
} |
i::MaybeHandle<i::JSGlobalProxy> maybe_proxy; |
@@ -6254,7 +6280,7 @@ static i::Handle<ObjectType> CreateEnvironment( |
invoke.Invoke(isolate, maybe_proxy, proxy_template, extensions, |
context_snapshot_index, internal_fields_deserializer); |
- // Restore the access check info on the global template. |
+ // Restore the access check info and interceptors on the global template. |
if (!maybe_global_template.IsEmpty()) { |
DCHECK(!global_constructor.is_null()); |
DCHECK(!proxy_constructor.is_null()); |
@@ -6262,6 +6288,8 @@ static i::Handle<ObjectType> CreateEnvironment( |
proxy_constructor->access_check_info()); |
global_constructor->set_needs_access_check( |
proxy_constructor->needs_access_check()); |
+ global_constructor->set_named_property_handler(*named_interceptor); |
+ global_constructor->set_indexed_property_handler(*indexed_interceptor); |
} |
} |
// Leave V8. |