Commit 35a14c75 authored by ishell's avatar ishell Committed by Commit bot

Disable ES6 tail call elimination for native functions.

We don't want them to disappear from the stack traces.

BUG=v8:4698
LOG=N

Review URL: https://codereview.chromium.org/1818063002

Cr-Commit-Position: refs/heads/master@{#34957}
parent f7bac43d
......@@ -108,6 +108,7 @@ class ParserBase : public Traits {
stack_overflow_(false),
allow_lazy_(false),
allow_natives_(false),
allow_tailcalls_(false),
allow_harmony_sloppy_(false),
allow_harmony_sloppy_function_(false),
allow_harmony_sloppy_let_(false),
......@@ -129,6 +130,7 @@ class ParserBase : public Traits {
ALLOW_ACCESSORS(lazy);
ALLOW_ACCESSORS(natives);
ALLOW_ACCESSORS(tailcalls);
ALLOW_ACCESSORS(harmony_sloppy);
ALLOW_ACCESSORS(harmony_sloppy_function);
ALLOW_ACCESSORS(harmony_sloppy_let);
......@@ -918,6 +920,7 @@ class ParserBase : public Traits {
bool allow_lazy_;
bool allow_natives_;
bool allow_tailcalls_;
bool allow_harmony_sloppy_;
bool allow_harmony_sloppy_function_;
bool allow_harmony_sloppy_let_;
......
......@@ -783,6 +783,7 @@ Parser::Parser(ParseInfo* info)
DCHECK(!info->script().is_null() || info->source_stream() != NULL);
set_allow_lazy(info->allow_lazy_parsing());
set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native());
set_allow_harmony_sloppy(FLAG_harmony_sloppy);
set_allow_harmony_sloppy_function(FLAG_harmony_sloppy_function);
set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let);
......@@ -2680,7 +2681,7 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
}
// ES6 14.6.1 Static Semantics: IsInTailPosition
if (FLAG_harmony_tailcalls && !is_sloppy(language_mode())) {
if (allow_tailcalls() && !is_sloppy(language_mode())) {
function_state_->AddExpressionInTailPosition(return_value);
}
}
......
......@@ -47,7 +47,7 @@ f(null);
eval('f(null)');
// Check called from strict builtin functions.
// [null, null].sort(f); // Does not work because sort tail calls.
[null, null].sort(f);
[null].forEach(f, null);
// Check called from sloppy builtin functions.
......
......@@ -1149,7 +1149,7 @@ function CheckArgumentsPillDescriptor(func, name) {
function strict() {
"use strict";
// Returning result via local variable to avoid tail call optimization.
// Returning result via local variable to avoid tail call elimination.
var res = return_my_caller();
return res;
}
......@@ -1165,7 +1165,7 @@ function CheckArgumentsPillDescriptor(func, name) {
(function TestNonStrictFunctionCallerPill() {
function strict(n) {
"use strict";
// Returning result via local variable to avoid tail call optimization.
// Returning result via local variable to avoid tail call elimination.
var res = non_strict(n);
return res;
}
......@@ -1195,7 +1195,7 @@ function CheckArgumentsPillDescriptor(func, name) {
(function TestNonStrictFunctionCallerDescriptorPill() {
function strict(n) {
"use strict";
// Returning result via local variable to avoid tail call optimization.
// Returning result via local variable to avoid tail call elimination.
var res = non_strict(n);
return res;
}
......
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