[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: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#46722}
This commit is contained in:
parent
fbc681d370
commit
c45b2291a7
@ -3331,18 +3331,14 @@ namespace {
|
||||
MaybeHandle<JSPromise> NewRejectedPromise(Isolate* isolate,
|
||||
v8::Local<v8::Context> api_context,
|
||||
Handle<Object> exception) {
|
||||
v8::MaybeLocal<v8::Promise::Resolver> maybe_resolver =
|
||||
v8::Promise::Resolver::New(api_context);
|
||||
v8::Local<v8::Promise::Resolver> resolver;
|
||||
// TODO(gsathya): Add test that checks this failure
|
||||
if (!maybe_resolver.ToLocal(&resolver)) {
|
||||
return MaybeHandle<JSPromise>();
|
||||
}
|
||||
ASSIGN_RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
|
||||
isolate, resolver, v8::Promise::Resolver::New(api_context),
|
||||
MaybeHandle<JSPromise>());
|
||||
|
||||
if (resolver->Reject(api_context, v8::Utils::ToLocal(exception))
|
||||
.IsNothing()) {
|
||||
return MaybeHandle<JSPromise>();
|
||||
}
|
||||
RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
|
||||
isolate, resolver->Reject(api_context, v8::Utils::ToLocal(exception)),
|
||||
MaybeHandle<JSPromise>());
|
||||
|
||||
v8::Local<v8::Promise> promise = resolver->GetPromise();
|
||||
return v8::Utils::OpenHandle(*promise);
|
||||
@ -3370,12 +3366,13 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
|
||||
}
|
||||
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_(
|
||||
api_context, v8::Utils::ToLocal(source_url),
|
||||
v8::Utils::ToLocal(specifier_str));
|
||||
RETURN_VALUE_IF_SCHEDULED_EXCEPTION(this, MaybeHandle<JSPromise>());
|
||||
v8::Local<v8::Promise> promise = maybe_promise.ToLocalChecked();
|
||||
v8::Utils::ToLocal(specifier_str)),
|
||||
MaybeHandle<JSPromise>());
|
||||
return v8::Utils::OpenHandle(*promise);
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,26 @@ class CompilationManager;
|
||||
#define RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, 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) \
|
||||
do { \
|
||||
Handle<Object> __result__; \
|
||||
|
16
test/mjsunit/regress/regress-744292.js
Normal file
16
test/mjsunit/regress/regress-744292.js
Normal file
@ -0,0 +1,16 @@
|
||||
// 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();
|
Loading…
Reference in New Issue
Block a user