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

Unified Diff: src/builtins/builtins-api.cc

Issue 2203353002: [api] Stay in C++ when constructing an API-function (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: set the receiver to the_hole for construct calls Created 4 years, 4 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/builtins.h ('k') | src/execution.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-api.cc
diff --git a/src/builtins/builtins-api.cc b/src/builtins/builtins-api.cc
index 96ea6dc63496d1d4dd6576f78c3188938e3244c0..aed10b1288a112e5807768d98417878c90d4cf9c 100644
--- a/src/builtins/builtins-api.cc
+++ b/src/builtins/builtins-api.cc
@@ -157,16 +157,17 @@ class RelocatableArguments : public BuiltinArguments, public Relocatable {
} // namespace
MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate,
+ bool is_construct,
Handle<HeapObject> function,
Handle<Object> receiver,
- int argc,
- Handle<Object> args[]) {
+ int argc, Handle<Object> args[],
+ Handle<HeapObject> new_target) {
DCHECK(function->IsFunctionTemplateInfo() ||
(function->IsJSFunction() &&
JSFunction::cast(*function)->shared()->IsApiFunction()));
// Do proper receiver conversion for non-strict mode api functions.
- if (!receiver->IsJSReceiver()) {
+ if (!is_construct && !receiver->IsJSReceiver()) {
if (function->IsFunctionTemplateInfo() ||
is_sloppy(JSFunction::cast(*function)->shared()->language_mode())) {
ASSIGN_RETURN_ON_EXCEPTION(isolate, receiver,
@@ -180,7 +181,6 @@ MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate,
? Handle<FunctionTemplateInfo>::cast(function)
: handle(JSFunction::cast(*function)->shared()->get_api_func_data(),
isolate);
- Handle<HeapObject> new_target = isolate->factory()->undefined_value();
// Construct BuiltinArguments object:
// new target, function, arguments reversed, receiver.
const int kBufferSize = 32;
@@ -204,8 +204,13 @@ MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate,
MaybeHandle<Object> result;
{
RelocatableArguments arguments(isolate, frame_argc, &argv[frame_argc - 1]);
- result = HandleApiCallHelper<false>(isolate, function, new_target, fun_data,
- receiver, arguments);
+ if (is_construct) {
+ result = HandleApiCallHelper<true>(isolate, function, new_target,
+ fun_data, receiver, arguments);
+ } else {
+ result = HandleApiCallHelper<false>(isolate, function, new_target,
+ fun_data, receiver, arguments);
+ }
}
if (argv != small_argv) delete[] argv;
return result;
« no previous file with comments | « src/builtins/builtins.h ('k') | src/execution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698