[async-hooks] Fix Promise.resolve optimization with async hooks enabled
Promise.resolve shouldn't be optimized when the async hooks are enabled. Bug: chromium:900674 Change-Id: I225c3d9002f293395993ded37a1d475635467a94 Reviewed-on: https://chromium-review.googlesource.com/c/1335693 Commit-Queue: Maya Lekova <mslekova@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#57505}
This commit is contained in:
parent
f84919d4b8
commit
607033a9e4
@ -645,6 +645,10 @@ Reduction JSNativeContextSpecialization::ReduceJSPromiseResolve(Node* node) {
|
||||
Node* effect = NodeProperties::GetEffectInput(node);
|
||||
Node* control = NodeProperties::GetControlInput(node);
|
||||
|
||||
if (!isolate()->IsPromiseHookProtectorIntact()) {
|
||||
return NoChange();
|
||||
}
|
||||
|
||||
// Check if the {constructor} is the %Promise% function.
|
||||
HeapObjectMatcher m(constructor);
|
||||
if (!m.HasValue() ||
|
||||
@ -664,6 +668,10 @@ Reduction JSNativeContextSpecialization::ReduceJSPromiseResolve(Node* node) {
|
||||
if (value_map->IsJSPromiseMap()) return NoChange();
|
||||
}
|
||||
|
||||
// Install a code dependency on the promise hook protector cell.
|
||||
dependencies()->DependOnProtector(
|
||||
PropertyCellRef(broker(), factory()->promise_hook_protector()));
|
||||
|
||||
// Create a %Promise% instance and resolve it with {value}.
|
||||
Node* promise = effect =
|
||||
graph()->NewNode(javascript()->CreatePromise(), context, effect);
|
||||
|
12
test/mjsunit/regress/regress-crbug-900674.js
Normal file
12
test/mjsunit/regress/regress-crbug-900674.js
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright 2018 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: --allow-natives-syntax
|
||||
|
||||
function foo() {
|
||||
let val = Promise.resolve().then();
|
||||
}
|
||||
foo();
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
foo();
|
Loading…
Reference in New Issue
Block a user