Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: src/api-natives.cc

Issue 1679683004: Revert of Do not eagerly instantiate accessors' JSFunction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/arguments.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api-natives.cc
diff --git a/src/api-natives.cc b/src/api-natives.cc
index c7de4fd07bf28ec23140c4275e05b0a415cfb177..d97dfae0a08d064ef55ec82aac65ca32c1c64d66 100644
--- a/src/api-natives.cc
+++ b/src/api-natives.cc
@@ -16,8 +16,8 @@
namespace {
MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
- Handle<ObjectTemplateInfo> data,
- bool is_hidden_prototype);
+ Handle<ObjectTemplateInfo> data);
+
MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
Handle<FunctionTemplateInfo> data,
@@ -30,36 +30,32 @@
return InstantiateFunction(isolate,
Handle<FunctionTemplateInfo>::cast(data), name);
} else if (data->IsObjectTemplateInfo()) {
- return InstantiateObject(isolate, Handle<ObjectTemplateInfo>::cast(data),
- false);
+ return InstantiateObject(isolate, Handle<ObjectTemplateInfo>::cast(data));
} else {
return data;
}
}
-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);
- }
+
+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);
}
RETURN_ON_EXCEPTION(isolate, JSObject::DefineAccessor(object, name, getter,
setter, attributes),
@@ -174,8 +170,7 @@
template <typename TemplateInfoT>
MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
- Handle<TemplateInfoT> data,
- bool is_hidden_prototype) {
+ Handle<TemplateInfoT> data) {
HandleScope scope(isolate);
// Disable access checks while instantiating the object.
AccessCheckDisableScope access_check_scope(isolate, obj);
@@ -242,10 +237,10 @@
} 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, is_hidden_prototype),
- JSObject);
+ RETURN_ON_EXCEPTION(isolate,
+ DefineAccessorProperty(isolate, obj, name, getter,
+ setter, attributes),
+ JSObject);
}
} else {
// Intrinsic data property --- Get appropriate value from the current
@@ -282,8 +277,7 @@
}
MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
- Handle<ObjectTemplateInfo> info,
- bool is_hidden_prototype) {
+ Handle<ObjectTemplateInfo> info) {
// Enter a new scope. Recursion could otherwise create a lot of handles.
HandleScope scope(isolate);
// Fast path.
@@ -311,9 +305,7 @@
}
auto object = isolate->factory()->NewJSObject(cons);
ASSIGN_RETURN_ON_EXCEPTION(
- isolate, result,
- ConfigureInstance(isolate, object, info, is_hidden_prototype),
- JSFunction);
+ isolate, result, ConfigureInstance(isolate, object, info), JSFunction);
// TODO(dcarney): is this necessary?
JSObject::MigrateSlowToFast(result, 0, "ApiNatives::InstantiateObject");
@@ -349,8 +341,7 @@
ASSIGN_RETURN_ON_EXCEPTION(
isolate, prototype,
InstantiateObject(isolate,
- Handle<ObjectTemplateInfo>::cast(prototype_templ),
- data->hidden_prototype()),
+ Handle<ObjectTemplateInfo>::cast(prototype_templ)),
JSFunction);
}
auto parent = handle(data->parent_template(), isolate);
@@ -382,8 +373,7 @@
// Cache the function.
CacheTemplateInstantiation(isolate, serial_number, function);
}
- auto result =
- ConfigureInstance(isolate, function, data, data->hidden_prototype());
+ auto result = ConfigureInstance(isolate, function, data);
if (result.is_null()) {
// Uncache on error.
if (serial_number->value()) {
@@ -447,7 +437,7 @@
Handle<ObjectTemplateInfo> data) {
Isolate* isolate = data->GetIsolate();
InvokeScope invoke_scope(isolate);
- return ::v8::internal::InstantiateObject(isolate, data, false);
+ return ::v8::internal::InstantiateObject(isolate, data);
}
« no previous file with comments | « no previous file | src/arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698