| Index: src/execution.cc
|
| diff --git a/src/execution.cc b/src/execution.cc
|
| index 59421c70bef54d2c0e8466fa71fc567d94cdc8d2..2d6add712ab7fb4053272e265c2e41ecc9fdbe52 100644
|
| --- a/src/execution.cc
|
| +++ b/src/execution.cc
|
| @@ -54,11 +54,14 @@ static void PrintDeserializedCodeInfo(Handle<JSFunction> function) {
|
|
|
| namespace {
|
|
|
| +enum class MessageHandling { kReport, kKeep };
|
| +
|
| MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct,
|
| Handle<Object> target,
|
| Handle<Object> receiver, int argc,
|
| Handle<Object> args[],
|
| - Handle<Object> new_target) {
|
| + Handle<Object> new_target,
|
| + MessageHandling message_handling) {
|
| DCHECK(!receiver->IsJSGlobalObject());
|
|
|
| #ifdef USE_SIMULATOR
|
| @@ -69,7 +72,9 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct,
|
| StackLimitCheck check(isolate);
|
| if (check.HasOverflowed()) {
|
| isolate->StackOverflow();
|
| - isolate->ReportPendingMessages();
|
| + if (message_handling == MessageHandling::kReport) {
|
| + isolate->ReportPendingMessages();
|
| + }
|
| return MaybeHandle<Object>();
|
| }
|
| #endif
|
| @@ -89,7 +94,9 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct,
|
| bool has_exception = value.is_null();
|
| DCHECK(has_exception == isolate->has_pending_exception());
|
| if (has_exception) {
|
| - isolate->ReportPendingMessages();
|
| + if (message_handling == MessageHandling::kReport) {
|
| + isolate->ReportPendingMessages();
|
| + }
|
| return MaybeHandle<Object>();
|
| } else {
|
| isolate->clear_pending_message();
|
| @@ -103,7 +110,9 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct,
|
| CHECK(AllowJavascriptExecution::IsAllowed(isolate));
|
| if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) {
|
| isolate->ThrowIllegalOperation();
|
| - isolate->ReportPendingMessages();
|
| + if (message_handling == MessageHandling::kReport) {
|
| + isolate->ReportPendingMessages();
|
| + }
|
| return MaybeHandle<Object>();
|
| }
|
|
|
| @@ -150,7 +159,9 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct,
|
| bool has_exception = value->IsException(isolate);
|
| DCHECK(has_exception == isolate->has_pending_exception());
|
| if (has_exception) {
|
| - isolate->ReportPendingMessages();
|
| + if (message_handling == MessageHandling::kReport) {
|
| + isolate->ReportPendingMessages();
|
| + }
|
| return MaybeHandle<Object>();
|
| } else {
|
| isolate->clear_pending_message();
|
| @@ -159,13 +170,10 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct,
|
| return Handle<Object>(value, isolate);
|
| }
|
|
|
| -} // namespace
|
| -
|
| -
|
| -// static
|
| -MaybeHandle<Object> Execution::Call(Isolate* isolate, Handle<Object> callable,
|
| - Handle<Object> receiver, int argc,
|
| - Handle<Object> argv[]) {
|
| +MaybeHandle<Object> CallInternal(Isolate* isolate, Handle<Object> callable,
|
| + Handle<Object> receiver, int argc,
|
| + Handle<Object> argv[],
|
| + MessageHandling message_handling) {
|
| // Convert calls on global objects to be calls on the global
|
| // receiver instead to avoid having a 'this' pointer which refers
|
| // directly to a global object.
|
| @@ -174,7 +182,17 @@ MaybeHandle<Object> Execution::Call(Isolate* isolate, Handle<Object> callable,
|
| handle(Handle<JSGlobalObject>::cast(receiver)->global_proxy(), isolate);
|
| }
|
| return Invoke(isolate, false, callable, receiver, argc, argv,
|
| - isolate->factory()->undefined_value());
|
| + isolate->factory()->undefined_value(), message_handling);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +// static
|
| +MaybeHandle<Object> Execution::Call(Isolate* isolate, Handle<Object> callable,
|
| + Handle<Object> receiver, int argc,
|
| + Handle<Object> argv[]) {
|
| + return CallInternal(isolate, callable, receiver, argc, argv,
|
| + MessageHandling::kReport);
|
| }
|
|
|
|
|
| @@ -190,7 +208,8 @@ MaybeHandle<Object> Execution::New(Isolate* isolate, Handle<Object> constructor,
|
| Handle<Object> new_target, int argc,
|
| Handle<Object> argv[]) {
|
| return Invoke(isolate, true, constructor,
|
| - isolate->factory()->undefined_value(), argc, argv, new_target);
|
| + isolate->factory()->undefined_value(), argc, argv, new_target,
|
| + MessageHandling::kReport);
|
| }
|
|
|
|
|
| @@ -211,24 +230,27 @@ MaybeHandle<Object> Execution::TryCall(Isolate* isolate,
|
| catcher.SetVerbose(false);
|
| catcher.SetCaptureMessage(false);
|
|
|
| - maybe_result = Call(isolate, callable, receiver, argc, args);
|
| + maybe_result =
|
| + CallInternal(isolate, callable, receiver, argc, args,
|
| + exception_out != nullptr ? MessageHandling::kReport
|
| + : MessageHandling::kKeep);
|
|
|
| if (maybe_result.is_null()) {
|
| - DCHECK(catcher.HasCaught());
|
| DCHECK(isolate->has_pending_exception());
|
| - DCHECK(isolate->external_caught_exception());
|
| if (isolate->pending_exception() ==
|
| isolate->heap()->termination_exception()) {
|
| is_termination = true;
|
| } else {
|
| - if (exception_out != NULL) {
|
| + if (exception_out != nullptr) {
|
| + DCHECK(catcher.HasCaught());
|
| + DCHECK(isolate->external_caught_exception());
|
| *exception_out = v8::Utils::OpenHandle(*catcher.Exception());
|
| }
|
| }
|
| - isolate->OptionalRescheduleException(true);
|
| + if (exception_out != nullptr) {
|
| + isolate->OptionalRescheduleException(true);
|
| + }
|
| }
|
| -
|
| - DCHECK(!isolate->has_pending_exception());
|
| }
|
|
|
| // Re-request terminate execution interrupt to trigger later.
|
|
|