Commit 632e261a authored by ishell's avatar ishell Committed by Commit bot

[es8] Remove syntactic tail calls support.

BUG=v8:4915

Review-Url: https://codereview.chromium.org/2372513003
Cr-Commit-Position: refs/heads/master@{#39808}
parent 24e29f28
......@@ -2845,7 +2845,6 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_explicit_tailcalls)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_declarations)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_string_padding)
......@@ -3428,7 +3427,6 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
bool Genesis::InstallExperimentalNatives() {
static const char* harmony_explicit_tailcalls_natives[] = {nullptr};
static const char* harmony_tailcalls_natives[] = {nullptr};
static const char* harmony_sharedarraybuffer_natives[] = {
"native harmony-atomics.js", NULL};
......
......@@ -198,7 +198,6 @@ DEFINE_IMPLICATION(es_staging, move_object_start)
V(harmony_function_sent, "harmony function.sent") \
V(harmony_sharedarraybuffer, "harmony sharedarraybuffer") \
V(harmony_simd, "harmony simd") \
V(harmony_explicit_tailcalls, "harmony explicit tail calls") \
V(harmony_do_expressions, "harmony do-expressions") \
V(harmony_restrictive_generators, \
"harmony restrictions on generator declarations") \
......
......@@ -593,19 +593,10 @@ class ErrorUtils : public AllStatic {
T(UnexpectedEOS, "Unexpected end of input") \
T(UnexpectedFunctionSent, \
"function.sent expression is not allowed outside a generator") \
T(UnexpectedInsideTailCall, "Unexpected expression inside tail call") \
T(UnexpectedReserved, "Unexpected reserved word") \
T(UnexpectedStrictReserved, "Unexpected strict mode reserved word") \
T(UnexpectedSuper, "'super' keyword unexpected here") \
T(UnexpectedSloppyTailCall, \
"Tail call expressions are not allowed in non-strict mode") \
T(UnexpectedNewTarget, "new.target expression is not allowed here") \
T(UnexpectedTailCall, "Tail call expression is not allowed here") \
T(UnexpectedTailCallInCatchBlock, \
"Tail call expression in catch block when finally block is also present") \
T(UnexpectedTailCallInForInOf, "Tail call expression in for-in/of body") \
T(UnexpectedTailCallInTryBlock, "Tail call expression in try block") \
T(UnexpectedTailCallOfEval, "Tail call of a direct eval is not allowed") \
T(UnexpectedTemplateString, "Unexpected template string") \
T(UnexpectedToken, "Unexpected token %") \
T(UnexpectedTokenIdentifier, "Unexpected identifier") \
......
This diff is collapsed.
......@@ -3550,7 +3550,6 @@ Expression* Parser::ParseClassLiteral(const AstRawString* name,
block_state.set_start_position(scanner()->location().end_pos);
ExpressionClassifier extends_classifier(this);
extends = ParseLeftHandSideExpression(CHECK_OK);
CheckNoTailCallExpressions(CHECK_OK);
RewriteNonPattern(CHECK_OK);
impl()->AccumulateFormalParameterContainmentErrors();
} else {
......@@ -4221,12 +4220,7 @@ void Parser::MarkCollectedTailCallExpressions() {
const ZoneList<Expression*>& tail_call_expressions =
function_state_->tail_call_expressions().expressions();
for (int i = 0; i < tail_call_expressions.length(); ++i) {
Expression* expression = tail_call_expressions[i];
// If only FLAG_harmony_explicit_tailcalls is enabled then expression
// must be a Call expression.
DCHECK(FLAG_harmony_tailcalls || !FLAG_harmony_explicit_tailcalls ||
expression->IsCall());
MarkTailPosition(expression);
MarkTailPosition(tail_call_expressions[i]);
}
}
......
......@@ -278,7 +278,6 @@ PreParserExpression PreParser::ParseClassLiteral(
if (has_extends) {
ExpressionClassifier extends_classifier(this);
ParseLeftHandSideExpression(CHECK_OK);
CheckNoTailCallExpressions(CHECK_OK);
ValidateExpression(CHECK_OK);
impl()->AccumulateFormalParameterContainmentErrors();
}
......
// Copyright 2016 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: --harmony-explicit-tailcalls
function f() {
return 1;
}
function* g() {
'use strict';
return continue f();
}
*%(basename)s:13: SyntaxError: Tail call expression is not allowed here
return continue f();
^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
return continue f() - a ;
}
*%(basename)s:13: SyntaxError: Tail call expression is not allowed here
return continue f() - a ;
^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
return b + continue f() ;
}
*%(basename)s:13: SyntaxError: Tail call expression is not allowed here
return b + continue f() ;
^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
return 1, 2, 3, continue f() , 4 ;
}
*%(basename)s:13: SyntaxError: Tail call expression is not allowed here
return 1, 2, 3, continue f() , 4 ;
^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function g() {
return class A extends continue f() {};
}
*%(basename)s:9: SyntaxError: Tail call expression is not allowed here
return class A extends continue f() {};
^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
for (var v in {a:0}) {
return continue f() ;
}
}
*%(basename)s:14: SyntaxError: Tail call expression in for-in/of body
return continue f() ;
^^^^^^^^^^^^
SyntaxError: Tail call expression in for-in/of body
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
for (var v of [1, 2, 3]) {
return continue f() ;
}
}
*%(basename)s:14: SyntaxError: Tail call expression in for-in/of body
return continue f() ;
^^^^^^^^^^^^
SyntaxError: Tail call expression in for-in/of body
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
return continue f() && a ;
}
*%(basename)s:13: SyntaxError: Tail call expression is not allowed here
return continue f() && a ;
^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
return continue f() || a ;
}
*%(basename)s:13: SyntaxError: Tail call expression is not allowed here
return continue f() || a ;
^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function g() {
class A {};
class B extends A {
constructor() {
return continue f() ;
}
}
}
*%(basename)s:12: SyntaxError: Tail call expression is not allowed here
return continue f() ;
^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
try {
f();
} catch(e) {
return continue f() ;
} finally {
f();
}
}
*%(basename)s:16: SyntaxError: Tail call expression in catch block when finally block is also present
return continue f() ;
^^^^^^^^^^^^
SyntaxError: Tail call expression in catch block when finally block is also present
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
try {
try {
f();
} catch(e) {
return continue f() ;
}
} finally {
f();
}
}
*%(basename)s:17: SyntaxError: Tail call expression in try block
return continue f() ;
^^^^^^^^^^^^
SyntaxError: Tail call expression in try block
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
try {
return continue f() ;
} catch(e) {
}
}
*%(basename)s:14: SyntaxError: Tail call expression in try block
return continue f() ;
^^^^^^^^^^^^
SyntaxError: Tail call expression in try block
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
return (continue f(1)) (2) ;
}
*%(basename)s:13: SyntaxError: Tail call expression is not allowed here
return (continue f(1)) (2) ;
^^^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
// Copyright 2016 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: --harmony-explicit-tailcalls
function g() {
return continue eval ("f()") ;
}
*%(basename)s:8: SyntaxError: Tail call of a direct eval is not allowed
return continue eval ("f()") ;
^^^^^^^^^^^^^
SyntaxError: Tail call of a direct eval is not allowed
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function g(x) {
return continue x ;
}
*%(basename)s:9: SyntaxError: Unexpected expression inside tail call
return continue x ;
^
SyntaxError: Unexpected expression inside tail call
// Copyright 2016 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: --harmony-explicit-tailcalls
function f() {
return 1;
}
function g() {
return continue new f() ;
}
*%(basename)s:12: SyntaxError: Unexpected expression inside tail call
return continue new f() ;
^^^^^^^
SyntaxError: Unexpected expression inside tail call
// Copyright 2016 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: --harmony-explicit-tailcalls
function g() {
return continue f() ;
}
*%(basename)s:8: SyntaxError: Tail call expressions are not allowed in non-strict mode
return continue f() ;
^^^^^^^^^^^^^
SyntaxError: Tail call expressions are not allowed in non-strict mode
// Copyright 2016 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: --harmony-explicit-tailcalls
"use strict";
function f() {
return 1;
}
function g() {
var x = continue f() ;
}
*%(basename)s:13: SyntaxError: Tail call expression is not allowed here
var x = continue f() ;
^^^^^^^^^^^^^
SyntaxError: Tail call expression is not allowed here
This diff is collapsed.
This diff is collapsed.
// Copyright 2016 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 --harmony-explicit-tailcalls --stack-size=100
//
// Tail calls work only in strict mode.
//
(function() {
function f(n) {
if (n <= 0) {
return "foo";
}
return f(n - 1);
}
assertThrows(()=>{ f(1e5) });
%OptimizeFunctionOnNextCall(f);
assertThrows(()=>{ f(1e5) });
})();
//
// Tail call normal functions.
//
(function() {
"use strict";
function f(n) {
if (n <= 0) {
return "foo";
}
return continue f(n - 1);
}
assertEquals("foo", f(1e5));
%OptimizeFunctionOnNextCall(f);
assertEquals("foo", f(1e5));
})();
(function() {
"use strict";
function f(n) {
if (n <= 0) {
return "foo";
}
return continue f(n - 1, 42); // Call with arguments adaptor.
}
assertEquals("foo", f(1e5));
%OptimizeFunctionOnNextCall(f);
assertEquals("foo", f(1e5));
})();
(function() {
"use strict";
function f(n){
if (n <= 0) {
return "foo";
}
return continue g(n - 1);
}
function g(n){
if (n <= 0) {
return "bar";
}
return continue f(n - 1);
}
assertEquals("foo", f(1e5));
assertEquals("bar", f(1e5 + 1));
%OptimizeFunctionOnNextCall(f);
assertEquals("foo", f(1e5));
assertEquals("bar", f(1e5 + 1));
})();
(function() {
"use strict";
function f(n){
if (n <= 0) {
return "foo";
}
return continue g(n - 1, 42); // Call with arguments adaptor.
}
function g(n){
if (n <= 0) {
return "bar";
}
return continue f(n - 1, 42); // Call with arguments adaptor.
}
assertEquals("foo", f(1e5));
assertEquals("bar", f(1e5 + 1));
%OptimizeFunctionOnNextCall(f);
assertEquals("foo", f(1e5));
assertEquals("bar", f(1e5 + 1));
})();
//
// Tail call bound functions.
//
(function() {
"use strict";
function f0(n) {
if (n <= 0) {
return "foo";
}
return continue f_bound(n - 1);
}
var f_bound = f0.bind({});
function f(n) {
return continue f_bound(n);
}
assertEquals("foo", f(1e5));
%OptimizeFunctionOnNextCall(f);
assertEquals("foo", f(1e5));
})();
(function() {
"use strict";
function f0(n){
if (n <= 0) {
return "foo";
}
return continue g_bound(n - 1);
}
function g0(n){
if (n <= 0) {
return "bar";
}
return continue f_bound(n - 1);
}
var f_bound = f0.bind({});
var g_bound = g0.bind({});
function f(n) {
return continue f_bound(n);
}
assertEquals("foo", f(1e5));
assertEquals("bar", f(1e5 + 1));
%OptimizeFunctionOnNextCall(f);
assertEquals("foo", f(1e5));
assertEquals("bar", f(1e5 + 1));
})();
This diff is collapsed.
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