Commit c45b2291 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[modules] Propogate scheduled exception on ToString failure

Also, add a couple of macros to handle error cases.

R=adamk@chromium.org

Bug: chromium:744292
Change-Id: I5dcb19ce67ec1aa4318d68d973d304cb07a65b80
Reviewed-on: https://chromium-review.googlesource.com/575394
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46722}
parent fbc681d3
...@@ -3331,18 +3331,14 @@ namespace { ...@@ -3331,18 +3331,14 @@ namespace {
MaybeHandle<JSPromise> NewRejectedPromise(Isolate* isolate, MaybeHandle<JSPromise> NewRejectedPromise(Isolate* isolate,
v8::Local<v8::Context> api_context, v8::Local<v8::Context> api_context,
Handle<Object> exception) { Handle<Object> exception) {
v8::MaybeLocal<v8::Promise::Resolver> maybe_resolver =
v8::Promise::Resolver::New(api_context);
v8::Local<v8::Promise::Resolver> resolver; v8::Local<v8::Promise::Resolver> resolver;
// TODO(gsathya): Add test that checks this failure ASSIGN_RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
if (!maybe_resolver.ToLocal(&resolver)) { isolate, resolver, v8::Promise::Resolver::New(api_context),
return MaybeHandle<JSPromise>(); MaybeHandle<JSPromise>());
}
if (resolver->Reject(api_context, v8::Utils::ToLocal(exception)) RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
.IsNothing()) { isolate, resolver->Reject(api_context, v8::Utils::ToLocal(exception)),
return MaybeHandle<JSPromise>(); MaybeHandle<JSPromise>());
}
v8::Local<v8::Promise> promise = resolver->GetPromise(); v8::Local<v8::Promise> promise = resolver->GetPromise();
return v8::Utils::OpenHandle(*promise); return v8::Utils::OpenHandle(*promise);
...@@ -3370,12 +3366,13 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback( ...@@ -3370,12 +3366,13 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
} }
DCHECK(!has_pending_exception()); DCHECK(!has_pending_exception());
v8::MaybeLocal<v8::Promise> maybe_promise = v8::Local<v8::Promise> promise;
ASSIGN_RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
this, promise,
host_import_module_dynamically_callback_( host_import_module_dynamically_callback_(
api_context, v8::Utils::ToLocal(source_url), api_context, v8::Utils::ToLocal(source_url),
v8::Utils::ToLocal(specifier_str)); v8::Utils::ToLocal(specifier_str)),
RETURN_VALUE_IF_SCHEDULED_EXCEPTION(this, MaybeHandle<JSPromise>()); MaybeHandle<JSPromise>());
v8::Local<v8::Promise> promise = maybe_promise.ToLocalChecked();
return v8::Utils::OpenHandle(*promise); return v8::Utils::OpenHandle(*promise);
} }
......
...@@ -132,6 +132,26 @@ class CompilationManager; ...@@ -132,6 +132,26 @@ class CompilationManager;
#define RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, T) \ #define RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, T) \
RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, MaybeHandle<T>()) RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, MaybeHandle<T>())
#define ASSIGN_RETURN_ON_SCHEDULED_EXCEPTION_VALUE(isolate, dst, call, value) \
do { \
Isolate* __isolate__ = (isolate); \
if (!(call).ToLocal(&dst)) { \
DCHECK(__isolate__->has_scheduled_exception()); \
__isolate__->PromoteScheduledException(); \
return value; \
} \
} while (false)
#define RETURN_ON_SCHEDULED_EXCEPTION_VALUE(isolate, call, value) \
do { \
Isolate* __isolate__ = (isolate); \
if ((call).IsNothing()) { \
DCHECK(__isolate__->has_scheduled_exception()); \
__isolate__->PromoteScheduledException(); \
return value; \
} \
} while (false)
#define RETURN_RESULT_OR_FAILURE(isolate, call) \ #define RETURN_RESULT_OR_FAILURE(isolate, call) \
do { \ do { \
Handle<Object> __result__; \ Handle<Object> __result__; \
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --harmony-dynamic-import
__v_1 = {
};
function __f_8() {
try {
__f_8();
} catch(e) {
import(__v_1);
}
}
__f_8();
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