Commit bd39edcd authored by jochen's avatar jochen Committed by Commit bot

[api] Move slow-path work behind fast path in InstantiateObject

BUG=
R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1743543002

Cr-Commit-Position: refs/heads/master@{#34326}
parent 6a7e8661
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment