Index: src/api-natives.cc |
diff --git a/src/api-natives.cc b/src/api-natives.cc |
index d97dfae0a08d064ef55ec82aac65ca32c1c64d66..c7de4fd07bf28ec23140c4275e05b0a415cfb177 100644 |
--- a/src/api-natives.cc |
+++ b/src/api-natives.cc |
@@ -16,8 +16,8 @@ namespace internal { |
namespace { |
MaybeHandle<JSObject> InstantiateObject(Isolate* isolate, |
- Handle<ObjectTemplateInfo> data); |
- |
+ Handle<ObjectTemplateInfo> data, |
+ bool is_hidden_prototype); |
MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate, |
Handle<FunctionTemplateInfo> data, |
@@ -30,32 +30,36 @@ MaybeHandle<Object> Instantiate(Isolate* isolate, Handle<Object> data, |
return InstantiateFunction(isolate, |
Handle<FunctionTemplateInfo>::cast(data), name); |
} else if (data->IsObjectTemplateInfo()) { |
- return InstantiateObject(isolate, Handle<ObjectTemplateInfo>::cast(data)); |
+ return InstantiateObject(isolate, Handle<ObjectTemplateInfo>::cast(data), |
+ false); |
} else { |
return data; |
} |
} |
- |
-MaybeHandle<Object> DefineAccessorProperty(Isolate* isolate, |
- Handle<JSObject> object, |
- Handle<Name> name, |
- Handle<Object> getter, |
- Handle<Object> setter, |
- PropertyAttributes attributes) { |
- if (!getter->IsUndefined()) { |
- ASSIGN_RETURN_ON_EXCEPTION( |
- isolate, getter, |
- InstantiateFunction(isolate, |
- Handle<FunctionTemplateInfo>::cast(getter)), |
- Object); |
- } |
- if (!setter->IsUndefined()) { |
- ASSIGN_RETURN_ON_EXCEPTION( |
- isolate, setter, |
- InstantiateFunction(isolate, |
- Handle<FunctionTemplateInfo>::cast(setter)), |
- Object); |
+MaybeHandle<Object> DefineAccessorProperty( |
+ Isolate* isolate, Handle<JSObject> object, Handle<Name> name, |
+ Handle<Object> getter, Handle<Object> setter, PropertyAttributes attributes, |
+ bool force_instantiate) { |
+ DCHECK(!getter->IsFunctionTemplateInfo() || |
+ !FunctionTemplateInfo::cast(*getter)->do_not_cache()); |
+ DCHECK(!setter->IsFunctionTemplateInfo() || |
+ !FunctionTemplateInfo::cast(*setter)->do_not_cache()); |
+ if (force_instantiate) { |
+ if (getter->IsFunctionTemplateInfo()) { |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, getter, |
+ InstantiateFunction(isolate, |
+ Handle<FunctionTemplateInfo>::cast(getter)), |
+ Object); |
+ } |
+ if (setter->IsFunctionTemplateInfo()) { |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, setter, |
+ InstantiateFunction(isolate, |
+ Handle<FunctionTemplateInfo>::cast(setter)), |
+ Object); |
+ } |
} |
RETURN_ON_EXCEPTION(isolate, JSObject::DefineAccessor(object, name, getter, |
setter, attributes), |
@@ -170,7 +174,8 @@ ObjectTemplateInfo* GetParent(ObjectTemplateInfo* data) { |
template <typename TemplateInfoT> |
MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj, |
- Handle<TemplateInfoT> data) { |
+ Handle<TemplateInfoT> data, |
+ bool is_hidden_prototype) { |
HandleScope scope(isolate); |
// Disable access checks while instantiating the object. |
AccessCheckDisableScope access_check_scope(isolate, obj); |
@@ -237,10 +242,10 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj, |
} else { |
auto getter = handle(properties.get(i++), isolate); |
auto setter = handle(properties.get(i++), isolate); |
- RETURN_ON_EXCEPTION(isolate, |
- DefineAccessorProperty(isolate, obj, name, getter, |
- setter, attributes), |
- JSObject); |
+ RETURN_ON_EXCEPTION( |
+ isolate, DefineAccessorProperty(isolate, obj, name, getter, setter, |
+ attributes, is_hidden_prototype), |
+ JSObject); |
} |
} else { |
// Intrinsic data property --- Get appropriate value from the current |
@@ -277,7 +282,8 @@ void UncacheTemplateInstantiation(Isolate* isolate, Handle<Smi> serial_number) { |
} |
MaybeHandle<JSObject> InstantiateObject(Isolate* isolate, |
- Handle<ObjectTemplateInfo> info) { |
+ Handle<ObjectTemplateInfo> info, |
+ bool is_hidden_prototype) { |
// Enter a new scope. Recursion could otherwise create a lot of handles. |
HandleScope scope(isolate); |
// Fast path. |
@@ -305,7 +311,9 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate, |
} |
auto object = isolate->factory()->NewJSObject(cons); |
ASSIGN_RETURN_ON_EXCEPTION( |
- isolate, result, ConfigureInstance(isolate, object, info), JSFunction); |
+ isolate, result, |
+ ConfigureInstance(isolate, object, info, is_hidden_prototype), |
+ JSFunction); |
// TODO(dcarney): is this necessary? |
JSObject::MigrateSlowToFast(result, 0, "ApiNatives::InstantiateObject"); |
@@ -341,7 +349,8 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate, |
ASSIGN_RETURN_ON_EXCEPTION( |
isolate, prototype, |
InstantiateObject(isolate, |
- Handle<ObjectTemplateInfo>::cast(prototype_templ)), |
+ Handle<ObjectTemplateInfo>::cast(prototype_templ), |
+ data->hidden_prototype()), |
JSFunction); |
} |
auto parent = handle(data->parent_template(), isolate); |
@@ -373,7 +382,8 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate, |
// Cache the function. |
CacheTemplateInstantiation(isolate, serial_number, function); |
} |
- auto result = ConfigureInstance(isolate, function, data); |
+ auto result = |
+ ConfigureInstance(isolate, function, data, data->hidden_prototype()); |
if (result.is_null()) { |
// Uncache on error. |
if (serial_number->value()) { |
@@ -437,7 +447,7 @@ MaybeHandle<JSObject> ApiNatives::InstantiateObject( |
Handle<ObjectTemplateInfo> data) { |
Isolate* isolate = data->GetIsolate(); |
InvokeScope invoke_scope(isolate); |
- return ::v8::internal::InstantiateObject(isolate, data); |
+ return ::v8::internal::InstantiateObject(isolate, data, false); |
} |