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

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: rebased Created 6 years, 7 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/scanner-character-streams.cc ('k') | tools/gyp/v8.gyp » ('j') | 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 80a116f1155b592213285f4c7e23182dcfcc0646..ded131b6b36878f5ee8f7b4d33ca747a5267196f 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.
@@ -303,7 +303,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();
@@ -338,7 +338,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);
@@ -407,8 +407,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.
@@ -441,8 +441,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);
@@ -489,7 +489,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);
@@ -539,7 +539,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);
@@ -1212,7 +1213,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();
@@ -2456,3 +2457,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());
+}
« no previous file with comments | « 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