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

Unified Diff: src/execution.cc

Issue 1041753002: fast path for api function creation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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 | « src/builtins.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/execution.cc
diff --git a/src/execution.cc b/src/execution.cc
index 7ae67410e45790653c33d8f578abf79f8c38ec18..9f50560cf40dad27b8d5d948dda19c2ace465a33 100644
--- a/src/execution.cc
+++ b/src/execution.cc
@@ -59,14 +59,19 @@ MUST_USE_RESULT static MaybeHandle<Object> Invoke(
Isolate* isolate = function->GetIsolate();
// api callbacks can be called directly.
- if (!is_construct && function->shared()->IsApiFunction()) {
+ if (function->shared()->IsApiFunction() &&
+ (!is_construct ||
+ !function->shared()->get_api_func_data()->remove_prototype())) {
SaveContext save(isolate);
isolate->set_context(function->context());
- if (receiver->IsGlobalObject()) {
+ if (is_construct) {
+ receiver = isolate->factory()->NewJSObject(function);
+ } else if (receiver->IsGlobalObject()) {
receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy());
}
DCHECK(function->context()->global_object()->IsGlobalObject());
- auto value = Builtins::InvokeApiFunction(function, receiver, argc, args);
+ auto value = Builtins::InvokeApiFunction(function, receiver, argc, args,
+ is_construct);
bool has_exception = value.is_null();
DCHECK(has_exception == isolate->has_pending_exception());
if (has_exception) {
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698