Commit a03d0483 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

[optional-chaining] Make eval?.() indirect

This is a spec bug in V8. Only call expressions literally of the form
'eval(...)' are considered direct.

Bug: v8:10688
Change-Id: Ia5ac9992db82cad0ad6870119bd94a0b4daee417
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2327752Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69148}
parent e2d12788
...@@ -3024,6 +3024,7 @@ class AstNodeFactory final { ...@@ -3024,6 +3024,7 @@ class AstNodeFactory final {
const ScopedPtrList<Expression>& arguments, int pos, const ScopedPtrList<Expression>& arguments, int pos,
Call::PossiblyEval possibly_eval = Call::NOT_EVAL, Call::PossiblyEval possibly_eval = Call::NOT_EVAL,
bool optional_chain = false) { bool optional_chain = false) {
DCHECK_IMPLIES(possibly_eval == Call::IS_POSSIBLY_EVAL, !optional_chain);
return zone_->New<Call>(zone_, expression, arguments, pos, possibly_eval, return zone_->New<Call>(zone_, expression, arguments, pos, possibly_eval,
optional_chain); optional_chain);
} }
......
...@@ -1403,8 +1403,9 @@ class ParserBase { ...@@ -1403,8 +1403,9 @@ class ParserBase {
// optimizations. This checks if expression is an eval call, and if yes, // optimizations. This checks if expression is an eval call, and if yes,
// forwards the information to scope. // forwards the information to scope.
Call::PossiblyEval CheckPossibleEvalCall(ExpressionT expression, Call::PossiblyEval CheckPossibleEvalCall(ExpressionT expression,
bool is_optional_call,
Scope* scope) { Scope* scope) {
if (impl()->IsIdentifier(expression) && if (!is_optional_call && impl()->IsIdentifier(expression) &&
impl()->IsEval(impl()->AsIdentifier(expression))) { impl()->IsEval(impl()->AsIdentifier(expression))) {
function_state_->RecordFunctionOrEvalCall(); function_state_->RecordFunctionOrEvalCall();
scope->RecordEvalCall(); scope->RecordEvalCall();
...@@ -3358,7 +3359,7 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) { ...@@ -3358,7 +3359,7 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) {
// These calls are marked as potentially direct eval calls. Whether // These calls are marked as potentially direct eval calls. Whether
// they are actually direct calls to eval is determined at run time. // they are actually direct calls to eval is determined at run time.
Call::PossiblyEval is_possibly_eval = Call::PossiblyEval is_possibly_eval =
CheckPossibleEvalCall(result, scope()); CheckPossibleEvalCall(result, is_optional, scope());
if (has_spread) { if (has_spread) {
result = impl()->SpreadCall(result, args, pos, is_possibly_eval, result = impl()->SpreadCall(result, args, pos, is_possibly_eval,
......
...@@ -649,6 +649,7 @@ class PreParserFactory { ...@@ -649,6 +649,7 @@ class PreParserFactory {
bool optional_chain = false) { bool optional_chain = false) {
if (possibly_eval == Call::IS_POSSIBLY_EVAL) { if (possibly_eval == Call::IS_POSSIBLY_EVAL) {
DCHECK(expression.IsIdentifier() && expression.AsIdentifier().IsEval()); DCHECK(expression.IsIdentifier() && expression.AsIdentifier().IsEval());
DCHECK(!optional_chain);
return PreParserExpression::CallEval(); return PreParserExpression::CallEval();
} }
return PreParserExpression::Call(); return PreParserExpression::Call();
......
...@@ -558,9 +558,6 @@ ...@@ -558,9 +558,6 @@
'built-ins/Atomics/xor/bigint/non-shared-bufferdata': [FAIL], 'built-ins/Atomics/xor/bigint/non-shared-bufferdata': [FAIL],
'built-ins/Atomics/xor/non-shared-bufferdata': [FAIL], 'built-ins/Atomics/xor/non-shared-bufferdata': [FAIL],
# https://crbug.com/v8/10688
'language/expressions/optional-chaining/eval-optional-call': [FAIL],
######################## NEEDS INVESTIGATION ########################### ######################## NEEDS INVESTIGATION ###########################
# https://bugs.chromium.org/p/v8/issues/detail?id=7833 # https://bugs.chromium.org/p/v8/issues/detail?id=7833
......
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