Commit f2741b13 authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Resolving or rejecting promises doesn't execute script

It just enqueues a microtask.

Bug: chromium:728583
Change-Id: Iecbc6f33db8a94acd10d9ae1f2173700d872ac50
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2827906Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74036}
parent 61f4b3b6
...@@ -303,6 +303,9 @@ declare_args() { ...@@ -303,6 +303,9 @@ declare_args() {
# Enable map packing & unpacking (sets -dV8_MAP_PACKING). # Enable map packing & unpacking (sets -dV8_MAP_PACKING).
v8_enable_map_packing = false v8_enable_map_packing = false
# Allow for JS promise hooks (instead of just C++).
v8_allow_javascript_in_promise_hooks = false
} }
# Derived defaults. # Derived defaults.
...@@ -821,6 +824,9 @@ config("features") { ...@@ -821,6 +824,9 @@ config("features") {
if (v8_dict_property_const_tracking) { if (v8_dict_property_const_tracking) {
defines += [ "V8_DICT_PROPERTY_CONST_TRACKING" ] defines += [ "V8_DICT_PROPERTY_CONST_TRACKING" ]
} }
if (v8_allow_javascript_in_promise_hooks) {
defines += [ "V8_ALLOW_JAVASCRIPT_IN_PROMISE_HOOKS" ]
}
} }
config("toolchain") { config("toolchain") {
......
...@@ -7268,8 +7268,13 @@ Local<Promise> Promise::Resolver::GetPromise() { ...@@ -7268,8 +7268,13 @@ Local<Promise> Promise::Resolver::GetPromise() {
Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, Maybe<bool> Promise::Resolver::Resolve(Local<Context> context,
Local<Value> value) { Local<Value> value) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
#if defined(V8_ALLOW_JAVASCRIPT_IN_PROMISE_HOOKS)
ENTER_V8(isolate, context, Promise_Resolver, Resolve, Nothing<bool>(), ENTER_V8(isolate, context, Promise_Resolver, Resolve, Nothing<bool>(),
i::HandleScope); i::HandleScope);
#else
ENTER_V8_NO_SCRIPT(isolate, context, Promise_Resolver, Resolve,
Nothing<bool>(), i::HandleScope);
#endif
auto self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
auto promise = i::Handle<i::JSPromise>::cast(self); auto promise = i::Handle<i::JSPromise>::cast(self);
...@@ -7286,8 +7291,13 @@ Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, ...@@ -7286,8 +7291,13 @@ Maybe<bool> Promise::Resolver::Resolve(Local<Context> context,
Maybe<bool> Promise::Resolver::Reject(Local<Context> context, Maybe<bool> Promise::Resolver::Reject(Local<Context> context,
Local<Value> value) { Local<Value> value) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
#if defined(V8_ALLOW_JAVASCRIPT_IN_PROMISE_HOOKS)
ENTER_V8(isolate, context, Promise_Resolver, Reject, Nothing<bool>(), ENTER_V8(isolate, context, Promise_Resolver, Reject, Nothing<bool>(),
i::HandleScope); i::HandleScope);
#else
ENTER_V8_NO_SCRIPT(isolate, context, Promise_Resolver, Reject,
Nothing<bool>(), i::HandleScope);
#endif
auto self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
auto promise = i::Handle<i::JSPromise>::cast(self); auto promise = i::Handle<i::JSPromise>::cast(self);
......
...@@ -1133,6 +1133,9 @@ TEST(TerminateExecutionTopLevelAwaitAsync) { ...@@ -1133,6 +1133,9 @@ TEST(TerminateExecutionTopLevelAwaitAsync) {
CHECK(!try_catch.HasTerminated()); CHECK(!try_catch.HasTerminated());
eval_promise->Resolve(env.local(), v8::Undefined(isolate)).ToChecked(); eval_promise->Resolve(env.local(), v8::Undefined(isolate)).ToChecked();
#if !defined(V8_ALLOW_JAVASCRIPT_IN_PROMISE_HOOKS)
isolate->PerformMicrotaskCheckpoint();
#endif
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
CHECK(try_catch.HasTerminated()); CHECK(try_catch.HasTerminated());
......
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