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

Unified Diff: src/api-natives.cc

Issue 1743543002: [api] Move slow-path work behind fast path in InstantiateObject (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 | no next file » | 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 56ee7374e5f67cf5552957e254de6fd0c8c876dc..a81e2957b03e741be860753a5f07a0557fa736f9 100644
--- a/src/api-natives.cc
+++ b/src/api-natives.cc
@@ -289,19 +289,8 @@ void UncacheTemplateInstantiation(Isolate* isolate, Handle<Smi> serial_number) {
MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
Handle<ObjectTemplateInfo> info,
bool is_hidden_prototype) {
- // Enter a new scope. Recursion could otherwise create a lot of handles.
- HandleScope scope(isolate);
// Fast path.
Handle<JSObject> result;
- auto constructor = handle(info->constructor(), isolate);
- Handle<JSFunction> cons;
- if (constructor->IsUndefined()) {
- cons = isolate->object_function();
- } else {
- auto cons_templ = Handle<FunctionTemplateInfo>::cast(constructor);
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, cons, InstantiateFunction(isolate, cons_templ), JSFunction);
- }
auto serial_number = handle(Smi::cast(info->serial_number()), isolate);
if (serial_number->value()) {
// Probe cache.
@@ -312,9 +301,20 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
result = handle(JSObject::cast(boilerplate), isolate);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, result, JSObject::DeepCopyApiBoilerplate(result), JSObject);
- return scope.CloseAndEscape(result);
+ return result;
}
}
+ // Enter a new scope. Recursion could otherwise create a lot of handles.
+ HandleScope scope(isolate);
+ auto constructor = handle(info->constructor(), isolate);
+ Handle<JSFunction> cons;
+ if (constructor->IsUndefined()) {
+ cons = isolate->object_function();
+ } else {
+ auto cons_templ = Handle<FunctionTemplateInfo>::cast(constructor);
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, cons, InstantiateFunction(isolate, cons_templ), JSFunction);
+ }
auto object = isolate->factory()->NewJSObject(cons);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, result,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698