Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1455)

Unified Diff: test/cctest/test-parsing.cc

Issue 2421833002: Remove "is function lazy" logic from Preparser + tiny error reporting refactoring. (Closed)
Patch Set: kill unused var Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/preparser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 5a1db2d6a1dad57fbbb24f02d195bbf856cf6711..64a8824a9dfa1b6be6e4184781e82192b0364913 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -461,35 +461,29 @@ TEST(RegressChromium62639) {
TEST(Regress928) {
- v8::V8::Initialize();
- i::Isolate* isolate = CcTest::i_isolate();
-
- // Preparsing didn't consider the catch clause of a try statement
- // as with-content, which made it assume that a function inside
- // the block could be lazily compiled, and an extra, unexpected,
- // entry was added to the data.
- isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
- 128 * 1024);
+ // Test only applies when lazy parsing.
+ if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return;
+ i::FLAG_min_preparse_length = 0;
+ // Tests that the first non-toplevel function is not included in the preparse
+ // data.
const char* program =
"try { } catch (e) { var foo = function () { /* first */ } }"
"var bar = function () { /* second */ }";
- v8::HandleScope handles(CcTest::isolate());
- auto stream = i::ScannerStream::ForTesting(program);
- i::CompleteParserRecorder log;
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
- scanner.Initialize(stream.get());
- i::Zone zone(CcTest::i_isolate()->allocator());
- i::AstValueFactory ast_value_factory(&zone,
- CcTest::i_isolate()->heap()->HashSeed());
- i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
- CcTest::i_isolate()->stack_guard()->real_climit());
- preparser.set_allow_lazy(true);
- i::PreParser::PreParseResult result = preparser.PreParseProgram();
- CHECK_EQ(i::PreParser::kPreParseSuccess, result);
- i::ScriptData* sd = log.GetScriptData();
- i::ParseData* pd = i::ParseData::FromCachedData(sd);
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handles(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
+ v8::ScriptCompiler::Source script_source(v8_str(program));
+ v8::ScriptCompiler::Compile(context, &script_source,
+ v8::ScriptCompiler::kProduceParserCache)
+ .ToLocalChecked();
+
+ const v8::ScriptCompiler::CachedData* cached_data =
+ script_source.GetCachedData();
+ i::ScriptData script_data(cached_data->data, cached_data->length);
+ std::unique_ptr<i::ParseData> pd(i::ParseData::FromCachedData(&script_data));
pd->Initialize();
int first_function =
@@ -507,8 +501,6 @@ TEST(Regress928) {
i::FunctionEntry entry2 = pd->GetFunctionEntry(second_lbrace);
CHECK(entry2.is_valid());
CHECK_EQ('}', program[entry2.end_pos() - 1]);
- delete sd;
- delete pd;
}
« no previous file with comments | « src/parsing/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698