Remove FLAG_min_preparse_length.

It originates from the era where we used to run a separate preparse step
before parsing and store the function data. Now the usage of preparser
is something completely different, so this flag doesn't make sense any
more.

In addition, this way we get more test coverage for preparser (for small
scripts).

BUG=

Review-Url: https://codereview.chromium.org/2513563002
Cr-Commit-Position: refs/heads/master@{#41110}
This commit is contained in:
marja 2016-11-18 06:06:25 -08:00 committed by Commit bot
parent b9f8ad002e
commit 4a5b7e32c4
34 changed files with 44 additions and 88 deletions

View File

@ -642,8 +642,6 @@ DEFINE_BOOL(external_reference_stats, false,
#endif // DEBUG
// compiler.cc
DEFINE_INT(min_preparse_length, 1024,
"minimum length for automatic enable preparsing")
DEFINE_INT(max_opt_count, 10,
"maximum number of optimization attempts before giving up.")

View File

@ -63,8 +63,7 @@ ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared)
ParseInfo::ParseInfo(Zone* zone, Handle<Script> script) : ParseInfo(zone) {
isolate_ = script->GetIsolate();
set_allow_lazy_parsing(String::cast(script->source())->length() >
FLAG_min_preparse_length);
set_allow_lazy_parsing();
set_toplevel();
set_hash_seed(isolate_->heap()->HashSeed());
set_stack_limit(isolate_->stack_guard()->real_climit());

View File

@ -97,9 +97,6 @@ class V8_EXPORT_PRIVATE ParseInfo {
return compile_options_;
}
void set_compile_options(ScriptCompiler::CompileOptions compile_options) {
if (compile_options == ScriptCompiler::kConsumeParserCache) {
set_allow_lazy_parsing();
}
compile_options_ = compile_options;
}

View File

@ -15363,7 +15363,6 @@ TEST(PreCompileSerialization) {
v8::Isolate* isolate = env->GetIsolate();
HandleScope handle_scope(isolate);
i::FLAG_min_preparse_length = 0;
const char* script = "function foo(a) { return a+1; }";
v8::ScriptCompiler::Source source(v8_str(script));
v8::ScriptCompiler::Compile(env.local(), &source,
@ -24670,7 +24669,6 @@ TEST(StreamingUtf8ScriptWithSplitCharactersInvalidEdgeCases) {
TEST(StreamingProducesParserCache) {
i::FLAG_min_preparse_length = 0;
const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ",
NULL};
@ -24703,7 +24701,6 @@ TEST(StreamingWithDebuggingEnabledLate) {
// fully parsed. However, we may compile inner functions eagerly when
// debugging. Make sure that we can deal with this when turning on debugging
// after streaming parser has already finished parsing.
i::FLAG_min_preparse_length = 0;
const char* chunks[] = {"with({x:1}) {",
" var foo = function foo(y) {",
" return x + y;",
@ -24950,7 +24947,6 @@ TEST(ParserCacheRejectedGracefully) {
// Producing cached parser data while parsing eagerly is not supported.
if (!i::FLAG_lazy) return;
i::FLAG_min_preparse_length = 0;
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
LocalContext context;

View File

@ -251,7 +251,6 @@ TEST(UsingCachedData) {
v8::String::NewExternalOneByte(isolate,
new ScriptResource(source, source_length))
.ToLocalChecked());
i::FLAG_min_preparse_length = 0;
v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &script_source,
v8::ScriptCompiler::kProduceParserCache)
.ToLocalChecked();
@ -278,9 +277,6 @@ TEST(PreparseFunctionDataIsUsed) {
// This tests that we actually do use the function data generated by the
// preparser.
// Make preparsing work for short scripts.
i::FLAG_min_preparse_length = 0;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handles(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
@ -484,7 +480,6 @@ TEST(RegressChromium62639) {
TEST(Regress928) {
// Test only applies when lazy parsing.
if (!i::FLAG_lazy) return;
i::FLAG_min_preparse_length = 0;
// Tests that the first non-toplevel function is not included in the preparse
// data.
@ -822,6 +817,8 @@ TEST(ScopeUsesArgumentsSuperThis) {
i::Handle<i::Script> script = factory->NewScript(source);
i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
// The information we're checking is only produced when eager parsing.
info.set_allow_lazy_parsing(false);
i::Parser parser(&info);
CHECK(parser.Parse(&info));
CHECK(i::Rewriter::Rewrite(&info));
@ -1178,7 +1175,6 @@ TEST(ScopePositions) {
i::ParseInfo info(&zone, script);
i::Parser parser(&info);
info.set_language_mode(source_data[i].language_mode);
info.set_allow_lazy_parsing();
parser.Parse(&info);
CHECK_NOT_NULL(info.literal());
@ -1225,7 +1221,6 @@ TEST(DiscardFunctionBody) {
i::Handle<i::Script> script = factory->NewScript(source_code);
i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
info.set_allow_lazy_parsing();
i::Parser parser(&info);
parser.Parse(&info);
function = info.literal();
@ -2482,7 +2477,6 @@ TEST(DontRegressPreParserDataSizes) {
i::ScriptData* sd = NULL;
info.set_cached_data(&sd);
info.set_compile_options(v8::ScriptCompiler::kProduceParserCache);
info.set_allow_lazy_parsing();
i::Parser::ParseStatic(&info);
i::ParseData* pd = i::ParseData::FromCachedData(sd);
@ -3148,7 +3142,6 @@ TEST(RegressionLazyFunctionWithErrorWithArg) {
v8::HandleScope scope(isolate);
LocalContext env;
i::FLAG_lazy = true;
i::FLAG_min_preparse_length = 0;
CompileRun("function this_is_lazy() {\n"
" break p;\n"
"}\n"
@ -3377,6 +3370,7 @@ TEST(InnerAssignment) {
printf("\n");
i::Handle<i::Script> script = factory->NewScript(source);
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, script));
info->set_allow_lazy_parsing(false);
}
i::Parser parser(info.get());
CHECK(parser.Parse(info.get()));
@ -3552,6 +3546,8 @@ TEST(SloppyModeUseCount) {
LocalContext env;
int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
global_use_counts = use_counts;
// Force eager parsing (preparser doesn't update use counts).
i::FLAG_lazy = false;
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
CompileRun("function bar() { var baz = 1; }");
CHECK_LT(0, use_counts[v8::Isolate::kSloppyMode]);
@ -3565,6 +3561,8 @@ TEST(BothModesUseCount) {
LocalContext env;
int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
global_use_counts = use_counts;
// Force eager parsing (preparser doesn't update use counts).
i::FLAG_lazy = false;
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
CompileRun("function bar() { 'use strict'; var baz = 1; }");
CHECK_LT(0, use_counts[v8::Isolate::kSloppyMode]);

View File

@ -1771,7 +1771,6 @@ TEST(CodeSerializerEagerCompilationAndPreAge) {
FLAG_serialize_toplevel = true;
FLAG_serialize_age_code = true;
FLAG_serialize_eager = true;
FLAG_min_preparse_length = 1;
static const char* source =
"function f() {"

View File

@ -1,9 +1,5 @@
// Copyright 2015 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.
//
// TODO(adamk): Remove flag after the test runner tests all message tests with
// the preparser: https://code.google.com/p/v8/issues/detail?id=4372
// Flags: --min-preparse-length=0
function f() { for ("unassignable" in {}); }

View File

@ -1,4 +1,4 @@
*%(basename)s:9: SyntaxError: Invalid left-hand side in for-loop
*%(basename)s:5: SyntaxError: Invalid left-hand side in for-loop
function f() { for ("unassignable" in {}); }
^^^^^^^^^^^^^^
SyntaxError: Invalid left-hand side in for-loop

View File

@ -0,0 +1,21 @@
// 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.
// from test/webkit/fast/js/kde/parse.js
assertThrows("function test() { while(0) break lab; } lab: 1");
assertThrows("function test() { while(0) continue lab; } lab: 1");
assertThrows("function test() { while(0) break lab } lab: 1");
assertThrows("function test() { while(0) continue lab } lab: 1");
// from test/webkit/fast/js/parser-syntax-check.js
assertThrows("break ; break your_limits ; continue ; continue living ; debugger");
assertThrows("function f() { break ; break your_limits ; continue ; continue living ; debugger }");
assertThrows("try { break } catch(e) {}");
assertThrows("function f() { try { break } catch(e) {} }");
assertThrows("L: L: ;");
assertThrows("function f() { L: L: ; }");
assertThrows("L: L1: L: ;");
assertThrows("function f() { L: L1: L: ; }");
assertThrows("L: L1: L2: L3: L4: L: ;");
assertThrows("function f() { L: L1: L2: L3: L4: L: ; }");

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
// The test functions in this file will be eagerly compiled. The functions
// inside will be eagerly parsed but lazily compiled.

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
(function testRestIndex() {
assertEquals(5, ((...args) => args.length)(1,2,3,4,5));
assertEquals(4, ((a, ...args) => args.length)(1,2,3,4,5));

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
let xxx = 1;
let f = undefined;
{

View File

@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
'use strict';
let xxx = 1;

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
'use strict';
class Base {

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
function f() {
var a, b;
[ a, b ] = [1, 2];

View File

@ -2,7 +2,5 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
function borked(a = [], b = {}, c) {}
borked();

View File

@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --lazy --min-preparse-length=0
(function() {
function CRASH(defaultParameter =
(function() { function functionDeclaration() { return 0; } }())) {

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=1
(function TestLazyInnerFunctionCallsEval() {
var i = (function eager_outer() {
var a = 41; // Should be context-allocated

View File

@ -3,7 +3,6 @@
// found in the LICENSE file.
//
// MODULE
// Flags: --min-preparse-length=0
let foo = 42;
function testFoo(x) { assertEquals(x, foo); }

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
"use strict";
var x = 1;
var g = eval("var y = 100; function h(s) { if (s) x = s; return x+y; }; h");

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=1
// Arrow function parsing (commit r22366) changed the flags stored in
// PreParserExpression, and IsValidReferenceExpression() would return
// false for certain valid expressions. This case is the minimum amount

View File

@ -2,6 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=1
(function(_ = function() {}){})

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --min-preparse-length=10
// Flags: --expose-debug-as debug
var source =
"var foo = function foo() {\n" +

View File

@ -1,8 +1,6 @@
// 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: --min-preparse-length=0
"use strict";
{

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
(function () {
function foo() {
const arguments = 42;

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --min-preparse-length=10
// Flags: --allow-natives-syntax
let x;
function f(a) {

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --min-preparse-length=10
// Flags: --allow-natives-syntax
(function() {
var x = 23;

View File

@ -447,7 +447,16 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=5537
'built-ins/global/*': [SKIP],
######################## NEEDS INVESTIGATION ###########################
# PreParser doesn't produce early errors
# https://bugs.chromium.org/p/v8/issues/detail?id=2728
'language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate': [FAIL],
'language/expressions/async-function/early-errors-expression-formals-body-duplicate': [FAIL],
'language/expressions/object/method-definition/generator-param-redecl-const': [FAIL],
'language/expressions/object/method-definition/generator-param-redecl-let': [FAIL],
'language/expressions/object/method-definition/name-param-redecl': [FAIL],
'language/statements/async-function/early-errors-declaration-formals-body-duplicate': [FAIL],
######################## NEEDS INVESTIGATION ###########################
# These test failures are specific to the intl402 suite and need investigation
# to be either marked as bugs with issues filed for them or as deliberate

View File

@ -30,14 +30,10 @@ PASS function test() { return;}; lab: 1 is 1
PASS function test() { while(0) break; } lab: 1 is 1
PASS function test() { while(0) continue; } lab: 1 is 1
PASS function test() { return lab;} lab: 1 is 1
PASS function test() { while(0) break lab; } lab: 1 threw exception SyntaxError: Undefined label 'lab'.
PASS function test() { while(0) continue lab; } lab: 1 threw exception SyntaxError: Undefined label 'lab'.
PASS function test() { return } lab: 1 is 1
PASS function test() { while(0) break } lab: 1 is 1
PASS function test() { while(0) continue } lab: 1 is 1
PASS function test() { return 0 } lab: 1 is 1
PASS function test() { while(0) break lab } lab: 1 threw exception SyntaxError: Undefined label 'lab'.
PASS function test() { while(0) continue lab } lab: 1 threw exception SyntaxError: Undefined label 'lab'.
PASS var éĀʯΈᢨ = 101; éĀʯΈᢨ; is 101
PASS var f÷; threw exception SyntaxError: Invalid or unexpected token.
PASS var \u0061 = 102; a is 102

View File

@ -28,16 +28,12 @@ shouldBe("function test() { while(0) break; } lab: 1", "1");
shouldBe("function test() { while(0) continue; } lab: 1", "1");
shouldBe("function test() { return lab;} lab: 1", "1");
shouldThrow("function test() { while(0) break lab; } lab: 1");
shouldThrow("function test() { while(0) continue lab; } lab: 1");
shouldBe("function test() { return } lab: 1", "1");
shouldBe("function test() { while(0) break } lab: 1", "1");
shouldBe("function test() { while(0) continue } lab: 1", "1");
shouldBe("function test() { return 0 } lab: 1", "1");
shouldThrow("function test() { while(0) break lab } lab: 1");
shouldThrow("function test() { while(0) continue lab } lab: 1");
a = 1
b = 123 // comment

View File

@ -288,8 +288,6 @@ PASS Valid: "do while (0) if (a) {} else y; while(0)"
PASS Valid: "function f() { do while (0) if (a) {} else y; while(0) }"
PASS Valid: "if (a) while (b) if (c) with(d) {} else e; else f"
PASS Valid: "function f() { if (a) while (b) if (c) with(d) {} else e; else f }"
PASS Invalid: "break ; break your_limits ; continue ; continue living ; debugger"
PASS Invalid: "function f() { break ; break your_limits ; continue ; continue living ; debugger }"
PASS Invalid: "debugger X"
PASS Invalid: "function f() { debugger X }"
PASS Invalid: "break 0.2"
@ -475,8 +473,6 @@ PASS Invalid: "function f() { for (var (a) in b) { } }"
PASS Valid: "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}"
PASS Valid: "function f() { for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {} }"
try statement
PASS Invalid: "try { break } catch(e) {}"
PASS Invalid: "function f() { try { break } catch(e) {} }"
PASS Valid: "try {} finally { c++ }"
PASS Valid: "function f() { try {} finally { c++ } }"
PASS Valid: "try { with (x) { } } catch(e) {} finally { if (a) ; }"
@ -554,12 +550,6 @@ PASS Invalid: "switch (4 - ) { }"
PASS Invalid: "function f() { switch (4 - ) { } }"
PASS Invalid: "switch (l) { default case: 5; }"
PASS Invalid: "function f() { switch (l) { default case: 5; } }"
PASS Invalid: "L: L: ;"
PASS Invalid: "function f() { L: L: ; }"
PASS Invalid: "L: L1: L: ;"
PASS Invalid: "function f() { L: L1: L: ; }"
PASS Invalid: "L: L1: L2: L3: L4: L: ;"
PASS Invalid: "function f() { L: L1: L2: L3: L4: L: ; }"
PASS Invalid: "for(var a,b 'this shouldn't be allowed' false ; ) ;"
PASS Invalid: "function f() { for(var a,b 'this shouldn't be allowed' false ; ) ; }"
PASS Invalid: "for(var a,b '"

View File

@ -219,7 +219,6 @@ invalid("do g; while ((4)");
valid ("{ { do do do ; while(0) while(0) while(0) } }");
valid ("do while (0) if (a) {} else y; while(0)");
valid ("if (a) while (b) if (c) with(d) {} else e; else f");
invalid("break ; break your_limits ; continue ; continue living ; debugger");
invalid("debugger X");
invalid("break 0.2");
invalid("continue a++");
@ -320,7 +319,6 @@ valid ("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}");
debug ("try statement");
invalid("try { break } catch(e) {}");
valid ("try {} finally { c++ }");
valid ("try { with (x) { } } catch(e) {} finally { if (a) ; }");
invalid("try {}");
@ -363,10 +361,6 @@ valid ("switch (l) { case 1: a: with(g) switch (g) { case 2: default: } default
invalid("switch (4 - ) { }");
invalid("switch (l) { default case: 5; }");
invalid("L: L: ;");
invalid("L: L1: L: ;");
invalid("L: L1: L2: L3: L4: L: ;");
invalid("for(var a,b 'this shouldn\'t be allowed' false ; ) ;");
invalid("for(var a,b '");

View File

@ -99,8 +99,6 @@ std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser(
info.set_compile_options(v8::ScriptCompiler::kProduceParserCache);
v8::base::ElapsedTimer timer;
timer.Start();
// Allow lazy parsing; otherwise we won't produce cached data.
info.set_allow_lazy_parsing();
bool success = Parser::ParseStatic(&info);
parse_time1 = timer.Elapsed();
if (!success) {
@ -116,8 +114,6 @@ std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser(
info.set_compile_options(v8::ScriptCompiler::kConsumeParserCache);
v8::base::ElapsedTimer timer;
timer.Start();
// Allow lazy parsing; otherwise cached data won't help.
info.set_allow_lazy_parsing();
bool success = Parser::ParseStatic(&info);
parse_time2 = timer.Elapsed();
if (!success) {

View File

@ -12,7 +12,6 @@ ALL_VARIANT_FLAGS = {
"ignition": [["--ignition"]],
"ignition_staging": [["--ignition-staging"]],
"ignition_turbofan": [["--ignition-staging", "--turbo"]],
"preparser": [["--min-preparse-length=0"]],
"asm_wasm": [["--validate-asm"]],
"wasm_traps": [["--wasm_guard_pages", "--invoke-weak-callbacks"]],
}
@ -26,11 +25,10 @@ FAST_VARIANT_FLAGS = {
"ignition": [["--ignition"]],
"ignition_staging": [["--ignition-staging"]],
"ignition_turbofan": [["--ignition-staging", "--turbo"]],
"preparser": [["--min-preparse-length=0"]],
"asm_wasm": [["--validate-asm"]],
"wasm_traps": [["--wasm_guard_pages", "--invoke-weak-callbacks"]],
}
ALL_VARIANTS = set(["default", "stress", "turbofan", "turbofan_opt",
"nocrankshaft", "ignition", "ignition_staging",
"ignition_turbofan", "preparser", "asm_wasm", "wasm_traps"])
"ignition_turbofan", "asm_wasm", "wasm_traps"])