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

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

Issue 214883002: Two-threaded parser (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 8 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
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index cd38724e3746d8bbf0507f87bbc7c00caf577aea..ae1641cb554b175d68f89d5eb8f714db9a2d54b2 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -152,7 +152,7 @@ TEST(ScanHTMLEndComments) {
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
- i::PreParser preparser(&scanner, &log, stack_limit);
+ i::PreParser preparser(&scanner, &log, stack_limit, NULL);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
@@ -167,7 +167,7 @@ TEST(ScanHTMLEndComments) {
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
- i::PreParser preparser(&scanner, &log, stack_limit);
+ i::PreParser preparser(&scanner, &log, stack_limit, NULL);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
// Even in the case of a syntax error, kPreParseSuccess is returned.
@@ -353,7 +353,7 @@ TEST(StandAlonePreParser) {
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
- i::PreParser preparser(&scanner, &log, stack_limit);
+ i::PreParser preparser(&scanner, &log, stack_limit, NULL);
preparser.set_allow_lazy(true);
preparser.set_allow_natives_syntax(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
@@ -388,7 +388,7 @@ TEST(StandAlonePreParserNoNatives) {
scanner.Initialize(&stream);
// Preparser defaults to disallowing natives syntax.
- i::PreParser preparser(&scanner, &log, stack_limit);
+ i::PreParser preparser(&scanner, &log, stack_limit, NULL);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
@@ -504,8 +504,8 @@ TEST(RegressChromium62639) {
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
- i::PreParser preparser(&scanner, &log,
- CcTest::i_isolate()->stack_guard()->real_climit());
+ i::PreParser preparser(
+ &scanner, &log, CcTest::i_isolate()->stack_guard()->real_climit(), NULL);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
// Even in the case of a syntax error, kPreParseSuccess is returned.
@@ -539,8 +539,8 @@ TEST(Regress928) {
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
- i::PreParser preparser(&scanner, &log,
- CcTest::i_isolate()->stack_guard()->real_climit());
+ i::PreParser preparser(
+ &scanner, &log, CcTest::i_isolate()->stack_guard()->real_climit(), NULL);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
@@ -587,7 +587,7 @@ TEST(PreParseOverflow) {
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
- i::PreParser preparser(&scanner, &log, stack_limit);
+ i::PreParser preparser(&scanner, &log, stack_limit, NULL);
preparser.set_allow_lazy(true);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseStackOverflow, result);
@@ -637,7 +637,8 @@ void TestCharacterStream(const char* ascii_source,
factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked());
i::ExternalTwoByteStringUtf16CharacterStream uc16_stream(
- i::Handle<i::ExternalTwoByteString>::cast(uc16_string), start, end);
+ i::Handle<i::ExternalTwoByteString>::cast(uc16_string)->GetTwoByteData(0),
+ start, end);
i::GenericStringUtf16CharacterStream string_stream(ascii_string, start, end);
i::Utf8ToUtf16CharacterStream utf8_stream(
reinterpret_cast<const i::byte*>(ascii_source), end);
@@ -1313,7 +1314,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
{
i::Scanner scanner(isolate->unicode_cache());
i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
- i::PreParser preparser(&scanner, &log, stack_limit);
+ i::PreParser preparser(&scanner, &log, stack_limit, NULL);
SetParserFlags(&preparser, flags);
scanner.Initialize(&stream);
i::PreParser::PreParseResult result = preparser.PreParseProgram();
@@ -2574,3 +2575,62 @@ TEST(InvalidLeftHandSide) {
RunParserSyncTest(postfix_context_data, good_statement_data, kSuccess);
RunParserSyncTest(postfix_context_data, bad_statement_data_common, kError);
}
+
+
+TEST(ParallelParsing) {
+ // Make lazy parsing and parallel parsing work for short scripts.
+ i::FLAG_min_preparse_length = 0;
+ i::FLAG_min_parallel_parse_length = 0;
+
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handles(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
+ int marker;
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
+
+ const char* code =
+ "var outside_var = 8;\n"
+ "function this_is_lazy() { return 5 + outside_var; }\n"
+ "(function not_lazy() { return this_is_lazy(); })()";
+ v8::ScriptCompiler::Source source(v8::String::NewExternal(
+ isolate, new ScriptResource(code, i::StrLength(code))));
+ v8::TryCatch try_catch;
+ v8::Handle<v8::Script> script = v8::ScriptCompiler::Compile(
+ isolate, &source, v8::ScriptCompiler::kProduceDataToCache);
+ CHECK(!script.IsEmpty());
+ CHECK(!try_catch.HasCaught());
+ v8::Local<v8::Value> result = script->Run();
+ CHECK(result->IsInt32());
+ CHECK_EQ(13, result->Int32Value());
+}
+
+
+TEST(ParallelParsingErrorInLazyFunction) {
+ // Make lazy parsing and parallel parsing work for short scripts.
+ i::FLAG_min_preparse_length = 0;
+ i::FLAG_min_parallel_parse_length = 0;
+
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handles(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
+ int marker;
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
+
+ // Compile code which has error inside a lazy function. Check that we get an
+ // error.
+ const char* code =
+ "function this_is_lazy() { 1 2 3 error }";
+ v8::ScriptCompiler::Source source(v8::String::NewExternal(
+ isolate, new ScriptResource(code, i::StrLength(code))));
+ v8::TryCatch try_catch;
+ v8::Handle<v8::Script> script = v8::ScriptCompiler::Compile(
+ isolate, &source, v8::ScriptCompiler::kProduceDataToCache);
+ CHECK(try_catch.HasCaught());
+ v8::String::Utf8Value exception(try_catch.Exception());
+ CHECK_EQ("SyntaxError: Unexpected number", *exception);
+ CHECK(script.IsEmpty());
+}
« src/preparse-data.h ('K') | « src/scanner-character-streams.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698