e7a46253f2
In some cases, PreParser cannot replicate the Scope structure created by Parser. It happens esp. with arrow function parameters, since the relevant information is already lost by the time we figure out it's an arrow function. In these cases, PreParser should bail out of trying to create data for skipping inner functions. Implementation notes: - The arrow function case is more fundamental; the non-arrow case could be hacked together somehow if we implemented tracking is_simple for each param separately; but now that it's possible to bail out consistently from both cases, I don't think the is_simple complication is worth it. - The added mjsunit test cases are based on the test262 test cases which exposed the problem. - cctest/preparser/PreParserScopeAnalysis was exercising similar cases, but the problem didn't show up because the function parameters didn't contain skippable functions. Those test cases have been repurposed for testing the bailout. - Extra precaution: the bailout tests are in a separate file, to guard from the bug that a bailout case results in bailing out of *all* data creation, which would make all skipping tests in the same file useless. BUG=v8:5516 Change-Id: I4324749a5ec602fa5d7dc27647ade0284a6842fe Reviewed-on: https://chromium-review.googlesource.com/599849 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/master@{#47170}
79 lines
1.9 KiB
JavaScript
79 lines
1.9 KiB
JavaScript
// Copyright 2017 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: --experimental-preparser-scope-analysis
|
|
|
|
// Tests for cases where PreParser must bail out of creating data for skipping
|
|
// inner functions, since it cannot replicate the Scope structure created by
|
|
// Parser.
|
|
|
|
function TestBailoutBecauseOfSloppyEvalInArrowParams() {
|
|
let bailout = (a = function() {}, b = eval('')) => 0
|
|
bailout();
|
|
|
|
function not_skippable() {}
|
|
}
|
|
TestBailoutBecauseOfSloppyEvalInArrowParams();
|
|
|
|
function TestBailoutBecauseOfSloppyEvalInArrowParams2() {
|
|
let bailout = (a = function() {}, b = eval('')) => {}
|
|
bailout();
|
|
|
|
function not_skippable() {}
|
|
}
|
|
TestBailoutBecauseOfSloppyEvalInArrowParams2();
|
|
|
|
function TestBailoutBecauseOfSloppyEvalInParams() {
|
|
function bailout(a = function() {}, b = eval('')) {
|
|
function not_skippable() {}
|
|
}
|
|
bailout();
|
|
|
|
function not_skippable_either() {}
|
|
}
|
|
TestBailoutBecauseOfSloppyEvalInParams();
|
|
|
|
// Test bailing out from 2 places.
|
|
function TestMultiBailout1() {
|
|
function bailout(a = function() {}, b = eval('')) {
|
|
function not_skippable() {}
|
|
}
|
|
bailout();
|
|
|
|
function bailout_too(a = function() {}, b = eval('')) {
|
|
function not_skippable_either() {}
|
|
}
|
|
bailout_too();
|
|
}
|
|
TestMultiBailout1();
|
|
|
|
function TestMultiBailout2() {
|
|
function f(a = function() {}, b = eval('')) {
|
|
function not_skippable() {}
|
|
}
|
|
f();
|
|
|
|
function not_skippable_either() {
|
|
function bailout_too(a = function() {}, b = eval('')) {
|
|
function inner_not_skippable() {}
|
|
}
|
|
bailout_too();
|
|
}
|
|
not_skippable_either();
|
|
}
|
|
TestMultiBailout2();
|
|
|
|
function TestMultiBailout3() {
|
|
function bailout(a = function() {}, b = eval('')) {
|
|
function bailout_too(a = function() {}, b = eval('')) {
|
|
function not_skippable() {}
|
|
}
|
|
bailout_too();
|
|
}
|
|
bailout();
|
|
|
|
function not_skippable_either() {}
|
|
}
|
|
TestMultiBailout3();
|