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

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

Issue 974213002: Extract ParseInfo from CompilationInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « test/cctest/compiler/test-pipeline.cc ('k') | test/cctest/test-serialize.cc » ('j') | 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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 int kProgramByteSize = i::StrLength(surroundings[j].prefix) + 1038 int kProgramByteSize = i::StrLength(surroundings[j].prefix) +
1039 i::StrLength(surroundings[j].suffix) + 1039 i::StrLength(surroundings[j].suffix) +
1040 i::StrLength(source_data[i].body); 1040 i::StrLength(source_data[i].body);
1041 i::ScopedVector<char> program(kProgramByteSize + 1); 1041 i::ScopedVector<char> program(kProgramByteSize + 1);
1042 i::SNPrintF(program, "%s%s%s", surroundings[j].prefix, 1042 i::SNPrintF(program, "%s%s%s", surroundings[j].prefix,
1043 source_data[i].body, surroundings[j].suffix); 1043 source_data[i].body, surroundings[j].suffix);
1044 i::Handle<i::String> source = 1044 i::Handle<i::String> source =
1045 factory->NewStringFromUtf8(i::CStrVector(program.start())) 1045 factory->NewStringFromUtf8(i::CStrVector(program.start()))
1046 .ToHandleChecked(); 1046 .ToHandleChecked();
1047 i::Handle<i::Script> script = factory->NewScript(source); 1047 i::Handle<i::Script> script = factory->NewScript(source);
1048 i::CompilationInfoWithZone info(script); 1048 i::Zone zone;
1049 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 1049 i::ParseInfo info(&zone);
1050 isolate->heap()->HashSeed(), isolate->unicode_cache()); 1050 info.InitializeFromScript(script);
1051 i::Parser parser(&info);
1051 parser.set_allow_harmony_arrow_functions(true); 1052 parser.set_allow_harmony_arrow_functions(true);
1052 parser.set_allow_harmony_classes(true); 1053 parser.set_allow_harmony_classes(true);
1053 parser.set_allow_harmony_object_literals(true); 1054 parser.set_allow_harmony_object_literals(true);
1054 parser.set_allow_harmony_scoping(true); 1055 parser.set_allow_harmony_scoping(true);
1055 parser.set_allow_harmony_sloppy(true); 1056 parser.set_allow_harmony_sloppy(true);
1056 info.MarkAsGlobal(); 1057 info.set_global();
1057 CHECK(parser.Parse(&info)); 1058 CHECK(parser.Parse(&info));
1058 CHECK(i::Rewriter::Rewrite(&info)); 1059 CHECK(i::Rewriter::Rewrite(&info));
1059 CHECK(i::Scope::Analyze(&info)); 1060 CHECK(i::Scope::Analyze(&info));
1060 CHECK(info.function() != NULL); 1061 CHECK(info.function() != NULL);
1061 1062
1062 i::Scope* script_scope = info.function()->scope(); 1063 i::Scope* script_scope = info.function()->scope();
1063 CHECK(script_scope->is_script_scope()); 1064 CHECK(script_scope->is_script_scope());
1064 CHECK_EQ(1, script_scope->inner_scopes()->length()); 1065 CHECK_EQ(1, script_scope->inner_scopes()->length());
1065 1066
1066 i::Scope* scope = script_scope->inner_scopes()->at(0); 1067 i::Scope* scope = script_scope->inner_scopes()->at(0);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 i::SNPrintF(program, "%s%s%s", 1291 i::SNPrintF(program, "%s%s%s",
1291 source_data[i].outer_prefix, 1292 source_data[i].outer_prefix,
1292 source_data[i].inner_source, 1293 source_data[i].inner_source,
1293 source_data[i].outer_suffix); 1294 source_data[i].outer_suffix);
1294 1295
1295 // Parse program source. 1296 // Parse program source.
1296 i::Handle<i::String> source = factory->NewStringFromUtf8( 1297 i::Handle<i::String> source = factory->NewStringFromUtf8(
1297 i::CStrVector(program.start())).ToHandleChecked(); 1298 i::CStrVector(program.start())).ToHandleChecked();
1298 CHECK_EQ(source->length(), kProgramSize); 1299 CHECK_EQ(source->length(), kProgramSize);
1299 i::Handle<i::Script> script = factory->NewScript(source); 1300 i::Handle<i::Script> script = factory->NewScript(source);
1300 i::CompilationInfoWithZone info(script); 1301 i::Zone zone;
1301 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 1302 i::ParseInfo info(&zone);
1302 isolate->heap()->HashSeed(), isolate->unicode_cache()); 1303 info.InitializeFromScript(script);
1304 i::Parser parser(&info);
1303 parser.set_allow_lazy(true); 1305 parser.set_allow_lazy(true);
1304 parser.set_allow_harmony_scoping(true); 1306 parser.set_allow_harmony_scoping(true);
1305 parser.set_allow_harmony_arrow_functions(true); 1307 parser.set_allow_harmony_arrow_functions(true);
1306 info.MarkAsGlobal(); 1308 info.set_global();
1307 info.SetLanguageMode(source_data[i].language_mode); 1309 info.set_language_mode(source_data[i].language_mode);
1308 parser.Parse(&info); 1310 parser.Parse(&info);
1309 CHECK(info.function() != NULL); 1311 CHECK(info.function() != NULL);
1310 1312
1311 // Check scope types and positions. 1313 // Check scope types and positions.
1312 i::Scope* scope = info.function()->scope(); 1314 i::Scope* scope = info.function()->scope();
1313 CHECK(scope->is_script_scope()); 1315 CHECK(scope->is_script_scope());
1314 CHECK_EQ(scope->start_position(), 0); 1316 CHECK_EQ(scope->start_position(), 0);
1315 CHECK_EQ(scope->end_position(), kProgramSize); 1317 CHECK_EQ(scope->end_position(), kProgramSize);
1316 CHECK_EQ(scope->inner_scopes()->length(), 1); 1318 CHECK_EQ(scope->inner_scopes()->length(), 1);
1317 1319
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 &preparser_materialized_literals); 1451 &preparser_materialized_literals);
1450 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 1452 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1451 } 1453 }
1452 1454
1453 bool preparse_error = log.HasError(); 1455 bool preparse_error = log.HasError();
1454 1456
1455 // Parse the data 1457 // Parse the data
1456 i::FunctionLiteral* function; 1458 i::FunctionLiteral* function;
1457 { 1459 {
1458 i::Handle<i::Script> script = factory->NewScript(source); 1460 i::Handle<i::Script> script = factory->NewScript(source);
1459 i::CompilationInfoWithZone info(script); 1461 i::Zone zone;
1460 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 1462 i::ParseInfo info(&zone);
1461 isolate->heap()->HashSeed(), isolate->unicode_cache()); 1463 info.InitializeFromScript(script);
1464 i::Parser parser(&info);
1462 SetParserFlags(&parser, flags); 1465 SetParserFlags(&parser, flags);
1463 info.MarkAsGlobal(); 1466 info.set_global();
1464 parser.Parse(&info); 1467 parser.Parse(&info);
1465 function = info.function(); 1468 function = info.function();
1466 if (function) { 1469 if (function) {
1467 parser_materialized_literals = function->materialized_literal_count(); 1470 parser_materialized_literals = function->materialized_literal_count();
1468 } 1471 }
1469 } 1472 }
1470 1473
1471 // Check that preparsing fails iff parsing fails. 1474 // Check that preparsing fails iff parsing fails.
1472 if (function == NULL) { 1475 if (function == NULL) {
1473 // Extract exception from the parser. 1476 // Extract exception from the parser.
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 {"function lazy() { var x = {get foo(){} } }", 1}, 2540 {"function lazy() { var x = {get foo(){} } }", 1},
2538 {NULL, 0} 2541 {NULL, 0}
2539 }; 2542 };
2540 2543
2541 for (int i = 0; test_cases[i].program; i++) { 2544 for (int i = 0; test_cases[i].program; i++) {
2542 const char* program = test_cases[i].program; 2545 const char* program = test_cases[i].program;
2543 i::Factory* factory = CcTest::i_isolate()->factory(); 2546 i::Factory* factory = CcTest::i_isolate()->factory();
2544 i::Handle<i::String> source = 2547 i::Handle<i::String> source =
2545 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); 2548 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked();
2546 i::Handle<i::Script> script = factory->NewScript(source); 2549 i::Handle<i::Script> script = factory->NewScript(source);
2547 i::CompilationInfoWithZone info(script); 2550 i::Zone zone;
2551 i::ParseInfo info(&zone);
2552 info.InitializeFromScript(script);
2548 i::ScriptData* sd = NULL; 2553 i::ScriptData* sd = NULL;
2549 info.SetCachedData(&sd, v8::ScriptCompiler::kProduceParserCache); 2554 info.set_cached_data(&sd);
2550 i::Parser::ParseStatic(&info, true); 2555 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache);
2556 info.set_allow_lazy_parsing();
2557 i::Parser::ParseStatic(&info);
2551 i::ParseData* pd = i::ParseData::FromCachedData(sd); 2558 i::ParseData* pd = i::ParseData::FromCachedData(sd);
2552 2559
2553 if (pd->FunctionCount() != test_cases[i].functions) { 2560 if (pd->FunctionCount() != test_cases[i].functions) {
2554 v8::base::OS::Print( 2561 v8::base::OS::Print(
2555 "Expected preparse data for program:\n" 2562 "Expected preparse data for program:\n"
2556 "\t%s\n" 2563 "\t%s\n"
2557 "to contain %d functions, however, received %d functions.\n", 2564 "to contain %d functions, however, received %d functions.\n",
2558 program, test_cases[i].functions, pd->FunctionCount()); 2565 program, test_cases[i].functions, pd->FunctionCount());
2559 CHECK(false); 2566 CHECK(false);
2560 } 2567 }
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
3360 i::ScopedVector<char> program(len + 1); 3367 i::ScopedVector<char> program(len + 1);
3361 3368
3362 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer, 3369 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer,
3363 midfix, inner_comment, inner, suffix); 3370 midfix, inner_comment, inner, suffix);
3364 i::Handle<i::String> source = 3371 i::Handle<i::String> source =
3365 factory->InternalizeUtf8String(program.start()); 3372 factory->InternalizeUtf8String(program.start());
3366 source->PrintOn(stdout); 3373 source->PrintOn(stdout);
3367 printf("\n"); 3374 printf("\n");
3368 3375
3369 i::Handle<i::Script> script = factory->NewScript(source); 3376 i::Handle<i::Script> script = factory->NewScript(source);
3370 i::CompilationInfoWithZone info(script); 3377 i::Zone zone;
3371 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 3378 i::ParseInfo info(&zone);
3372 isolate->heap()->HashSeed(), 3379 info.InitializeFromScript(script);
3373 isolate->unicode_cache()); 3380 i::Parser parser(&info);
3374 parser.set_allow_harmony_scoping(true); 3381 parser.set_allow_harmony_scoping(true);
3375 CHECK(parser.Parse(&info)); 3382 CHECK(parser.Parse(&info));
3376 CHECK(i::Compiler::Analyze(&info)); 3383 CHECK(i::Compiler::Analyze(&info));
3377 CHECK(info.function() != NULL); 3384 CHECK(info.function() != NULL);
3378 3385
3379 i::Scope* scope = info.function()->scope(); 3386 i::Scope* scope = info.function()->scope();
3380 CHECK_EQ(scope->inner_scopes()->length(), 1); 3387 CHECK_EQ(scope->inner_scopes()->length(), 1);
3381 i::Scope* inner_scope = scope->inner_scopes()->at(0); 3388 i::Scope* inner_scope = scope->inner_scopes()->at(0);
3382 const i::AstRawString* var_name = 3389 const i::AstRawString* var_name =
3383 info.ast_value_factory()->GetOneByteString("x"); 3390 info.ast_value_factory()->GetOneByteString("x");
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
5071 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5078 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5072 128 * 1024); 5079 128 * 1024);
5073 5080
5074 for (unsigned i = 0; i < arraysize(kSources); ++i) { 5081 for (unsigned i = 0; i < arraysize(kSources); ++i) {
5075 i::Handle<i::String> source = 5082 i::Handle<i::String> source =
5076 factory->NewStringFromAsciiChecked(kSources[i]); 5083 factory->NewStringFromAsciiChecked(kSources[i]);
5077 5084
5078 // Show that parsing as a module works 5085 // Show that parsing as a module works
5079 { 5086 {
5080 i::Handle<i::Script> script = factory->NewScript(source); 5087 i::Handle<i::Script> script = factory->NewScript(source);
5081 i::CompilationInfoWithZone info(script); 5088 i::Zone zone;
5082 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5089 i::ParseInfo info(&zone);
5083 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5090 info.InitializeFromScript(script);
5091 i::Parser parser(&info);
5084 parser.set_allow_harmony_classes(true); 5092 parser.set_allow_harmony_classes(true);
5085 parser.set_allow_harmony_modules(true); 5093 parser.set_allow_harmony_modules(true);
5086 parser.set_allow_harmony_scoping(true); 5094 parser.set_allow_harmony_scoping(true);
5087 info.MarkAsModule(); 5095 info.set_module();
5088 if (!parser.Parse(&info)) { 5096 if (!parser.Parse(&info)) {
5089 i::Handle<i::JSObject> exception_handle( 5097 i::Handle<i::JSObject> exception_handle(
5090 i::JSObject::cast(isolate->pending_exception())); 5098 i::JSObject::cast(isolate->pending_exception()));
5091 i::Handle<i::String> message_string = 5099 i::Handle<i::String> message_string =
5092 i::Handle<i::String>::cast(i::Object::GetProperty( 5100 i::Handle<i::String>::cast(i::Object::GetProperty(
5093 isolate, exception_handle, "message").ToHandleChecked()); 5101 isolate, exception_handle, "message").ToHandleChecked());
5094 5102
5095 v8::base::OS::Print( 5103 v8::base::OS::Print(
5096 "Parser failed on:\n" 5104 "Parser failed on:\n"
5097 "\t%s\n" 5105 "\t%s\n"
5098 "with error:\n" 5106 "with error:\n"
5099 "\t%s\n" 5107 "\t%s\n"
5100 "However, we expected no error.", 5108 "However, we expected no error.",
5101 source->ToCString().get(), message_string->ToCString().get()); 5109 source->ToCString().get(), message_string->ToCString().get());
5102 CHECK(false); 5110 CHECK(false);
5103 } 5111 }
5104 } 5112 }
5105 5113
5106 // And that parsing a script does not. 5114 // And that parsing a script does not.
5107 { 5115 {
5108 i::Handle<i::Script> script = factory->NewScript(source); 5116 i::Handle<i::Script> script = factory->NewScript(source);
5109 i::CompilationInfoWithZone info(script); 5117 i::Zone zone;
5110 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5118 i::ParseInfo info(&zone);
5111 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5119 info.InitializeFromScript(script);
5120 i::Parser parser(&info);
5112 parser.set_allow_harmony_classes(true); 5121 parser.set_allow_harmony_classes(true);
5113 parser.set_allow_harmony_modules(true); 5122 parser.set_allow_harmony_modules(true);
5114 parser.set_allow_harmony_scoping(true); 5123 parser.set_allow_harmony_scoping(true);
5115 info.MarkAsGlobal(); 5124 info.set_global();
5116 CHECK(!parser.Parse(&info)); 5125 CHECK(!parser.Parse(&info));
5117 } 5126 }
5118 } 5127 }
5119 } 5128 }
5120 5129
5121 5130
5122 TEST(ImportExportParsingErrors) { 5131 TEST(ImportExportParsingErrors) {
5123 const char* kErrorSources[] = { 5132 const char* kErrorSources[] = {
5124 "export {", 5133 "export {",
5125 "var a; export { a", 5134 "var a; export { a",
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5190 v8::Context::Scope context_scope(context); 5199 v8::Context::Scope context_scope(context);
5191 5200
5192 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5201 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5193 128 * 1024); 5202 128 * 1024);
5194 5203
5195 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { 5204 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
5196 i::Handle<i::String> source = 5205 i::Handle<i::String> source =
5197 factory->NewStringFromAsciiChecked(kErrorSources[i]); 5206 factory->NewStringFromAsciiChecked(kErrorSources[i]);
5198 5207
5199 i::Handle<i::Script> script = factory->NewScript(source); 5208 i::Handle<i::Script> script = factory->NewScript(source);
5200 i::CompilationInfoWithZone info(script); 5209 i::Zone zone;
5201 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5210 i::ParseInfo info(&zone);
5202 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5211 info.InitializeFromScript(script);
5212 i::Parser parser(&info);
5203 parser.set_allow_harmony_classes(true); 5213 parser.set_allow_harmony_classes(true);
5204 parser.set_allow_harmony_modules(true); 5214 parser.set_allow_harmony_modules(true);
5205 parser.set_allow_harmony_scoping(true); 5215 parser.set_allow_harmony_scoping(true);
5206 info.MarkAsModule(); 5216 info.set_module();
5207 CHECK(!parser.Parse(&info)); 5217 CHECK(!parser.Parse(&info));
5208 } 5218 }
5209 } 5219 }
5210 5220
5211 5221
5212 TEST(ModuleParsingInternals) { 5222 TEST(ModuleParsingInternals) {
5213 i::Isolate* isolate = CcTest::i_isolate(); 5223 i::Isolate* isolate = CcTest::i_isolate();
5214 i::Factory* factory = isolate->factory(); 5224 i::Factory* factory = isolate->factory();
5215 v8::HandleScope handles(CcTest::isolate()); 5225 v8::HandleScope handles(CcTest::isolate());
5216 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 5226 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
5217 v8::Context::Scope context_scope(context); 5227 v8::Context::Scope context_scope(context);
5218 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5228 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5219 128 * 1024); 5229 128 * 1024);
5220 5230
5221 static const char kSource[] = 5231 static const char kSource[] =
5222 "let x = 5;" 5232 "let x = 5;"
5223 "export { x as y };" 5233 "export { x as y };"
5224 "import { q as z } from 'm.js';" 5234 "import { q as z } from 'm.js';"
5225 "import n from 'n.js'"; 5235 "import n from 'n.js'";
5226 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); 5236 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
5227 i::Handle<i::Script> script = factory->NewScript(source); 5237 i::Handle<i::Script> script = factory->NewScript(source);
5228 i::CompilationInfoWithZone info(script); 5238 i::Zone zone;
5229 i::Zone* zone = info.zone(); 5239 i::ParseInfo info(&zone);
5230 i::AstValueFactory avf(zone, isolate->heap()->HashSeed()); 5240 info.InitializeFromScript(script);
5231 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5241 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
5232 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5242 i::Parser parser(&info);
5233 parser.set_allow_harmony_modules(true); 5243 parser.set_allow_harmony_modules(true);
5234 parser.set_allow_harmony_scoping(true); 5244 parser.set_allow_harmony_scoping(true);
5235 info.MarkAsModule(); 5245 info.set_module();
5236 CHECK(parser.Parse(&info)); 5246 CHECK(parser.Parse(&info));
5237 i::FunctionLiteral* func = info.function(); 5247 i::FunctionLiteral* func = info.function();
5238 CHECK_EQ(i::MODULE_SCOPE, func->scope()->scope_type()); 5248 CHECK_EQ(i::MODULE_SCOPE, func->scope()->scope_type());
5239 i::ModuleDescriptor* descriptor = func->scope()->module(); 5249 i::ModuleDescriptor* descriptor = func->scope()->module();
5240 CHECK_NOT_NULL(descriptor); 5250 CHECK_NOT_NULL(descriptor);
5241 CHECK_EQ(1, descriptor->Length()); 5251 CHECK_EQ(1, descriptor->Length());
5242 const i::AstRawString* export_name = avf.GetOneByteString("y"); 5252 const i::AstRawString* export_name = avf.GetOneByteString("y");
5243 const i::AstRawString* local_name = 5253 const i::AstRawString* local_name =
5244 descriptor->LookupLocalExport(export_name, zone); 5254 descriptor->LookupLocalExport(export_name, &zone);
5245 CHECK_NOT_NULL(local_name); 5255 CHECK_NOT_NULL(local_name);
5246 CHECK(local_name->IsOneByteEqualTo("x")); 5256 CHECK(local_name->IsOneByteEqualTo("x"));
5247 i::ZoneList<i::Declaration*>* declarations = func->scope()->declarations(); 5257 i::ZoneList<i::Declaration*>* declarations = func->scope()->declarations();
5248 CHECK_EQ(3, declarations->length()); 5258 CHECK_EQ(3, declarations->length());
5249 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); 5259 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x"));
5250 i::ImportDeclaration* import_decl = 5260 i::ImportDeclaration* import_decl =
5251 declarations->at(1)->AsImportDeclaration(); 5261 declarations->at(1)->AsImportDeclaration();
5252 CHECK(import_decl->import_name()->IsOneByteEqualTo("q")); 5262 CHECK(import_decl->import_name()->IsOneByteEqualTo("q"));
5253 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("z")); 5263 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("z"));
5254 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("m.js")); 5264 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("m.js"));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5334 i::Isolate* isolate = CcTest::i_isolate(); 5344 i::Isolate* isolate = CcTest::i_isolate();
5335 i::Factory* factory = isolate->factory(); 5345 i::Factory* factory = isolate->factory();
5336 v8::HandleScope handles(CcTest::isolate()); 5346 v8::HandleScope handles(CcTest::isolate());
5337 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 5347 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
5338 v8::Context::Scope context_scope(context); 5348 v8::Context::Scope context_scope(context);
5339 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5349 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5340 128 * 1024); 5350 128 * 1024);
5341 5351
5342 i::Handle<i::Script> script = 5352 i::Handle<i::Script> script =
5343 factory->NewScript(factory->NewStringFromAsciiChecked(source)); 5353 factory->NewScript(factory->NewStringFromAsciiChecked(source));
5344 i::CompilationInfoWithZone info(script); 5354 i::Zone zone;
5345 i::Parser parser(&info, isolate->stack_guard()->real_climit(), 5355 i::ParseInfo info(&zone);
5346 isolate->heap()->HashSeed(), isolate->unicode_cache()); 5356 info.InitializeFromScript(script);
5357 i::Parser parser(&info);
5347 parser.set_allow_strong_mode(true); 5358 parser.set_allow_strong_mode(true);
5348 info.MarkAsGlobal(); 5359 info.set_global();
5349 parser.Parse(&info); 5360 parser.Parse(&info);
5350 CHECK(info.function() != NULL); 5361 CHECK(info.function() != NULL);
5351 CHECK_EQ(expected_language_mode, info.function()->language_mode()); 5362 CHECK_EQ(expected_language_mode, info.function()->language_mode());
5352 } 5363 }
5353 5364
5354 5365
5355 TEST(LanguageModeDirectives) { 5366 TEST(LanguageModeDirectives) {
5356 TestLanguageMode("\"use nothing\"", i::SLOPPY); 5367 TestLanguageMode("\"use nothing\"", i::SLOPPY);
5357 TestLanguageMode("\"use strict\"", i::STRICT); 5368 TestLanguageMode("\"use strict\"", i::STRICT);
5358 TestLanguageMode("\"use strong\"", i::STRONG); 5369 TestLanguageMode("\"use strong\"", i::STRONG);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
5546 static const ParserFlag always_flags[] = { 5557 static const ParserFlag always_flags[] = {
5547 kAllowStrongMode, kAllowHarmonyScoping 5558 kAllowStrongMode, kAllowHarmonyScoping
5548 }; 5559 };
5549 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, 5560 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags,
5550 arraysize(always_flags)); 5561 arraysize(always_flags));
5551 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, 5562 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags,
5552 arraysize(always_flags)); 5563 arraysize(always_flags));
5553 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, 5564 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags,
5554 arraysize(always_flags)); 5565 arraysize(always_flags));
5555 } 5566 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-pipeline.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698