[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/+/2327752
Reviewed-by: Marja Hölttä <marja@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69148}
This commit is contained in:
Shu-yu Guo 2020-07-29 18:25:37 -07:00 committed by Commit Bot
parent e2d1278855
commit a03d0483bb
4 changed files with 5 additions and 5 deletions

View File

@ -3024,6 +3024,7 @@ class AstNodeFactory final {
const ScopedPtrList<Expression>& arguments, int pos,
Call::PossiblyEval possibly_eval = Call::NOT_EVAL,
bool optional_chain = false) {
DCHECK_IMPLIES(possibly_eval == Call::IS_POSSIBLY_EVAL, !optional_chain);
return zone_->New<Call>(zone_, expression, arguments, pos, possibly_eval,
optional_chain);
}

View File

@ -1403,8 +1403,9 @@ class ParserBase {
// optimizations. This checks if expression is an eval call, and if yes,
// forwards the information to scope.
Call::PossiblyEval CheckPossibleEvalCall(ExpressionT expression,
bool is_optional_call,
Scope* scope) {
if (impl()->IsIdentifier(expression) &&
if (!is_optional_call && impl()->IsIdentifier(expression) &&
impl()->IsEval(impl()->AsIdentifier(expression))) {
function_state_->RecordFunctionOrEvalCall();
scope->RecordEvalCall();
@ -3358,7 +3359,7 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) {
// These calls are marked as potentially direct eval calls. Whether
// they are actually direct calls to eval is determined at run time.
Call::PossiblyEval is_possibly_eval =
CheckPossibleEvalCall(result, scope());
CheckPossibleEvalCall(result, is_optional, scope());
if (has_spread) {
result = impl()->SpreadCall(result, args, pos, is_possibly_eval,

View File

@ -649,6 +649,7 @@ class PreParserFactory {
bool optional_chain = false) {
if (possibly_eval == Call::IS_POSSIBLY_EVAL) {
DCHECK(expression.IsIdentifier() && expression.AsIdentifier().IsEval());
DCHECK(!optional_chain);
return PreParserExpression::CallEval();
}
return PreParserExpression::Call();

View File

@ -558,9 +558,6 @@
'built-ins/Atomics/xor/bigint/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 ###########################
# https://bugs.chromium.org/p/v8/issues/detail?id=7833