| 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) {
|
|
|