Commit 230e4ed0 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

Mark intrinsics AsyncFunction{Enter,Reject,Resolve} as side-effect free

This fixes the DevTools console preview when using REPL mode.
AsyncFunction* intriniscs are side-effect free and marking them as such
is correct.

Bug: chromium:1043151
Change-Id: Ie0c36507b98b0c12f3d627c34102c04c27358ff2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2010106Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65876}
parent f2bd9c6c
......@@ -348,6 +348,9 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
V(NewObject) \
V(StringMaxLength) \
V(StringToArray) \
V(AsyncFunctionEnter) \
V(AsyncFunctionReject) \
V(AsyncFunctionResolve) \
/* Test */ \
V(GetOptimizationStatus) \
V(OptimizeFunctionOnNextCall) \
......@@ -357,7 +360,10 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
// Intrinsics with inline versions have to be whitelisted here a second time.
#define INLINE_INTRINSIC_WHITELIST(V) \
V(Call) \
V(IsJSReceiver)
V(IsJSReceiver) \
V(AsyncFunctionEnter) \
V(AsyncFunctionReject) \
V(AsyncFunctionResolve)
#define CASE(Name) case Runtime::k##Name:
#define INLINE_CASE(Name) case Runtime::kInline##Name:
......
......@@ -31,7 +31,6 @@ function listener(event, exec_state, event_data, data) {
fail("new Promise()");
fail("generator()");
fail("g.next()");
fail("async()");
fail("Promise.resolve()");
fail("Promise.reject()");
fail("p.then(() => {})");
......@@ -39,8 +38,15 @@ function listener(event, exec_state, event_data, data) {
fail("p.finally(() => {})");
fail("Promise.all([p, p])");
fail("Promise.race([p, p])");
fail("(async function() {})()");
fail("(async function() { await 1; })()");
// Calling (but not awaiting) non-side-effecting async functions
// should be fine.
function succeed(source) {
exec_state.frame(0).evaluate(source, true);
}
succeed("async()");
succeed("(async function() {})()");
} catch (e) {
exception = e;
print(e, e.stack);
......
Tests that Runtime.evaluate with REPL mode correctly detects side-effects.
Test "let" declaration is side-effecting
{
id : <messageId>
result : {
exceptionDetails : {
columnNumber : -1
exception : {
className : EvalError
description : EvalError: Possible side-effect in debug-evaluate
objectId : <objectId>
subtype : error
type : object
}
exceptionId : <exceptionId>
lineNumber : -1
scriptId : <scriptId>
text : Uncaught
}
result : {
className : EvalError
description : EvalError: Possible side-effect in debug-evaluate
objectId : <objectId>
subtype : error
type : object
}
}
}
Test side-effect free expressions can be eagerly evaluated
{
id : <messageId>
result : {
result : {
description : 3
type : number
value : 3
}
}
}
{
id : <messageId>
result : {
result : {
type : string
value : hello REPL
}
}
}
{
id : <messageId>
result : {
result : {
className : Promise
description : Promise
objectId : <objectId>
subtype : promise
type : object
}
}
}
// Copyright 2019 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.
let {Protocol} = InspectorTest.start(
'Tests that Runtime.evaluate with REPL mode correctly detects side-effects.');
Protocol.Runtime.enable();
(async function() {
InspectorTest.log('Test "let" declaration is side-effecting');
await evaluateRepl('let x = 21;');
InspectorTest.log('Test side-effect free expressions can be eagerly evaluated');
await evaluateRepl('1 + 2');
await evaluateRepl('"hello " + "REPL"');
await evaluateRepl('(async function foo() { return 42; })();');
InspectorTest.completeTest();
})();
async function evaluateRepl(expression) {
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: expression,
replMode: true,
throwOnSideEffect: true
}));
}
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