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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 527763002: Refactor Parser to make it usable on a background thread. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: whitespace Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 source_data[i].outer_prefix, 1121 source_data[i].outer_prefix,
1122 source_data[i].inner_source, 1122 source_data[i].inner_source,
1123 source_data[i].outer_suffix); 1123 source_data[i].outer_suffix);
1124 1124
1125 // Parse program source. 1125 // Parse program source.
1126 i::Handle<i::String> source = factory->NewStringFromUtf8( 1126 i::Handle<i::String> source = factory->NewStringFromUtf8(
1127 i::CStrVector(program.start())).ToHandleChecked(); 1127 i::CStrVector(program.start())).ToHandleChecked();
1128 CHECK_EQ(source->length(), kProgramSize); 1128 CHECK_EQ(source->length(), kProgramSize);
1129 i::Handle<i::Script> script = factory->NewScript(source); 1129 i::Handle<i::Script> script = factory->NewScript(source);
1130 i::CompilationInfoWithZone info(script); 1130 i::CompilationInfoWithZone info(script);
1131 i::Parser parser(&info); 1131 i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
1132 isolate->heap()->HashSeed(),
1133 isolate->unicode_cache()};
1134 i::Parser parser(&info, &parse_info);
1132 parser.set_allow_lazy(true); 1135 parser.set_allow_lazy(true);
1133 parser.set_allow_harmony_scoping(true); 1136 parser.set_allow_harmony_scoping(true);
1134 parser.set_allow_arrow_functions(true); 1137 parser.set_allow_arrow_functions(true);
1135 info.MarkAsGlobal(); 1138 info.MarkAsGlobal();
1136 info.SetStrictMode(source_data[i].strict_mode); 1139 info.SetStrictMode(source_data[i].strict_mode);
1137 parser.Parse(); 1140 parser.Parse();
1138 CHECK(info.function() != NULL); 1141 CHECK(info.function() != NULL);
1139 1142
1140 // Check scope types and positions. 1143 // Check scope types and positions.
1141 i::Scope* scope = info.function()->scope(); 1144 i::Scope* scope = info.function()->scope();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 1259 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1257 } 1260 }
1258 1261
1259 bool preparse_error = log.HasError(); 1262 bool preparse_error = log.HasError();
1260 1263
1261 // Parse the data 1264 // Parse the data
1262 i::FunctionLiteral* function; 1265 i::FunctionLiteral* function;
1263 { 1266 {
1264 i::Handle<i::Script> script = factory->NewScript(source); 1267 i::Handle<i::Script> script = factory->NewScript(source);
1265 i::CompilationInfoWithZone info(script); 1268 i::CompilationInfoWithZone info(script);
1266 i::Parser parser(&info); 1269 i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(),
1270 isolate->heap()->HashSeed(),
1271 isolate->unicode_cache()};
1272 i::Parser parser(&info, &parse_info);
1267 SetParserFlags(&parser, flags); 1273 SetParserFlags(&parser, flags);
1268 info.MarkAsGlobal(); 1274 info.MarkAsGlobal();
1269 parser.Parse(); 1275 parser.Parse();
1270 function = info.function(); 1276 function = info.function();
1271 } 1277 }
1272 1278
1273 // Check that preparsing fails iff parsing fails. 1279 // Check that preparsing fails iff parsing fails.
1274 if (function == NULL) { 1280 if (function == NULL) {
1275 // Extract exception from the parser. 1281 // Extract exception from the parser.
1276 CHECK(isolate->has_pending_exception()); 1282 CHECK(isolate->has_pending_exception());
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
3118 3124
3119 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer, 3125 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer,
3120 midfix, inner_comment, inner, suffix); 3126 midfix, inner_comment, inner, suffix);
3121 i::Handle<i::String> source = 3127 i::Handle<i::String> source =
3122 factory->InternalizeUtf8String(program.start()); 3128 factory->InternalizeUtf8String(program.start());
3123 source->PrintOn(stdout); 3129 source->PrintOn(stdout);
3124 printf("\n"); 3130 printf("\n");
3125 3131
3126 i::Handle<i::Script> script = factory->NewScript(source); 3132 i::Handle<i::Script> script = factory->NewScript(source);
3127 i::CompilationInfoWithZone info(script); 3133 i::CompilationInfoWithZone info(script);
3128 i::Parser parser(&info); 3134 i::Parser::ParseInfo parse_info = {
3135 isolate->stack_guard()->real_climit(),
3136 isolate->heap()->HashSeed(), isolate->unicode_cache()};
3137 i::Parser parser(&info, &parse_info);
3129 parser.set_allow_harmony_scoping(true); 3138 parser.set_allow_harmony_scoping(true);
3130 CHECK(parser.Parse()); 3139 CHECK(parser.Parse());
3131 CHECK(i::Rewriter::Rewrite(&info)); 3140 CHECK(i::Rewriter::Rewrite(&info));
3132 CHECK(i::Scope::Analyze(&info)); 3141 CHECK(i::Scope::Analyze(&info));
3133 CHECK(info.function() != NULL); 3142 CHECK(info.function() != NULL);
3134 3143
3135 i::Scope* scope = info.function()->scope(); 3144 i::Scope* scope = info.function()->scope();
3136 CHECK_EQ(scope->inner_scopes()->length(), 1); 3145 CHECK_EQ(scope->inner_scopes()->length(), 1);
3137 i::Scope* inner_scope = scope->inner_scopes()->at(0); 3146 i::Scope* inner_scope = scope->inner_scopes()->at(0);
3138 const i::AstRawString* var_name = 3147 const i::AstRawString* var_name =
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 const char* statement_data[] = { 3382 const char* statement_data[] = {
3374 "super = x", 3383 "super = x",
3375 "y = super", 3384 "y = super",
3376 "f(super)", 3385 "f(super)",
3377 NULL}; 3386 NULL};
3378 3387
3379 static const ParserFlag always_flags[] = {kAllowClasses}; 3388 static const ParserFlag always_flags[] = {kAllowClasses};
3380 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, 3389 RunParserSyncTest(context_data, statement_data, kError, NULL, 0,
3381 always_flags, arraysize(always_flags)); 3390 always_flags, arraysize(always_flags));
3382 } 3391 }
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698