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

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

Issue 2394213003: Named all zones in the project (Closed)
Patch Set: Merge branch 'master' into zonenames 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-liveedit.cc ('k') | test/cctest/test-regexp.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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Parser/Scanner needs a stack limit. 164 // Parser/Scanner needs a stack limit.
165 CcTest::i_isolate()->stack_guard()->SetStackLimit( 165 CcTest::i_isolate()->stack_guard()->SetStackLimit(
166 i::GetCurrentStackPosition() - 128 * 1024); 166 i::GetCurrentStackPosition() - 128 * 1024);
167 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 167 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
168 for (int i = 0; tests[i]; i++) { 168 for (int i = 0; tests[i]; i++) {
169 const char* source = tests[i]; 169 const char* source = tests[i];
170 auto stream = i::ScannerStream::ForTesting(source); 170 auto stream = i::ScannerStream::ForTesting(source);
171 i::CompleteParserRecorder log; 171 i::CompleteParserRecorder log;
172 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 172 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
173 scanner.Initialize(stream.get()); 173 scanner.Initialize(stream.get());
174 i::Zone zone(CcTest::i_isolate()->allocator()); 174 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
175 i::AstValueFactory ast_value_factory( 175 i::AstValueFactory ast_value_factory(
176 &zone, CcTest::i_isolate()->heap()->HashSeed()); 176 &zone, CcTest::i_isolate()->heap()->HashSeed());
177 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 177 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
178 stack_limit); 178 stack_limit);
179 preparser.set_allow_lazy(true); 179 preparser.set_allow_lazy(true);
180 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 180 i::PreParser::PreParseResult result = preparser.PreParseProgram();
181 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 181 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
182 CHECK(!log.HasError()); 182 CHECK(!log.HasError());
183 } 183 }
184 184
185 for (int i = 0; fail_tests[i]; i++) { 185 for (int i = 0; fail_tests[i]; i++) {
186 const char* source = fail_tests[i]; 186 const char* source = fail_tests[i];
187 auto stream = i::ScannerStream::ForTesting(source); 187 auto stream = i::ScannerStream::ForTesting(source);
188 i::CompleteParserRecorder log; 188 i::CompleteParserRecorder log;
189 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 189 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
190 scanner.Initialize(stream.get()); 190 scanner.Initialize(stream.get());
191 i::Zone zone(CcTest::i_isolate()->allocator()); 191 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
192 i::AstValueFactory ast_value_factory( 192 i::AstValueFactory ast_value_factory(
193 &zone, CcTest::i_isolate()->heap()->HashSeed()); 193 &zone, CcTest::i_isolate()->heap()->HashSeed());
194 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 194 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
195 stack_limit); 195 stack_limit);
196 preparser.set_allow_lazy(true); 196 preparser.set_allow_lazy(true);
197 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 197 i::PreParser::PreParseResult result = preparser.PreParseProgram();
198 // Even in the case of a syntax error, kPreParseSuccess is returned. 198 // Even in the case of a syntax error, kPreParseSuccess is returned.
199 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 199 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
200 CHECK(log.HasError()); 200 CHECK(log.HasError());
201 } 201 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 NULL 339 NULL
340 }; 340 };
341 341
342 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 342 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
343 for (int i = 0; programs[i]; i++) { 343 for (int i = 0; programs[i]; i++) {
344 auto stream = i::ScannerStream::ForTesting(programs[i]); 344 auto stream = i::ScannerStream::ForTesting(programs[i]);
345 i::CompleteParserRecorder log; 345 i::CompleteParserRecorder log;
346 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 346 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
347 scanner.Initialize(stream.get()); 347 scanner.Initialize(stream.get());
348 348
349 i::Zone zone(CcTest::i_isolate()->allocator()); 349 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
350 i::AstValueFactory ast_value_factory( 350 i::AstValueFactory ast_value_factory(
351 &zone, CcTest::i_isolate()->heap()->HashSeed()); 351 &zone, CcTest::i_isolate()->heap()->HashSeed());
352 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 352 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
353 stack_limit); 353 stack_limit);
354 preparser.set_allow_lazy(true); 354 preparser.set_allow_lazy(true);
355 preparser.set_allow_natives(true); 355 preparser.set_allow_natives(true);
356 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 356 i::PreParser::PreParseResult result = preparser.PreParseProgram();
357 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 357 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
358 CHECK(!log.HasError()); 358 CHECK(!log.HasError());
359 } 359 }
(...skipping 13 matching lines...) Expand all
373 }; 373 };
374 374
375 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 375 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
376 for (int i = 0; programs[i]; i++) { 376 for (int i = 0; programs[i]; i++) {
377 auto stream = i::ScannerStream::ForTesting(programs[i]); 377 auto stream = i::ScannerStream::ForTesting(programs[i]);
378 i::CompleteParserRecorder log; 378 i::CompleteParserRecorder log;
379 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 379 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
380 scanner.Initialize(stream.get()); 380 scanner.Initialize(stream.get());
381 381
382 // Preparser defaults to disallowing natives syntax. 382 // Preparser defaults to disallowing natives syntax.
383 i::Zone zone(CcTest::i_isolate()->allocator()); 383 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
384 i::AstValueFactory ast_value_factory( 384 i::AstValueFactory ast_value_factory(
385 &zone, CcTest::i_isolate()->heap()->HashSeed()); 385 &zone, CcTest::i_isolate()->heap()->HashSeed());
386 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 386 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
387 stack_limit); 387 stack_limit);
388 preparser.set_allow_lazy(true); 388 preparser.set_allow_lazy(true);
389 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 389 i::PreParser::PreParseResult result = preparser.PreParseProgram();
390 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 390 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
391 CHECK(log.HasError()); 391 CHECK(log.HasError());
392 } 392 }
393 } 393 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 "escape: function() {}"; 440 "escape: function() {}";
441 // Fails parsing expecting an identifier after "function". 441 // Fails parsing expecting an identifier after "function".
442 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), 442 // Before fix, didn't check *ok after Expect(Token::Identifier, ok),
443 // and then used the invalid currently scanned literal. This always 443 // and then used the invalid currently scanned literal. This always
444 // failed in debug mode, and sometimes crashed in release mode. 444 // failed in debug mode, and sometimes crashed in release mode.
445 445
446 auto stream = i::ScannerStream::ForTesting(program); 446 auto stream = i::ScannerStream::ForTesting(program);
447 i::CompleteParserRecorder log; 447 i::CompleteParserRecorder log;
448 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 448 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
449 scanner.Initialize(stream.get()); 449 scanner.Initialize(stream.get());
450 i::Zone zone(CcTest::i_isolate()->allocator()); 450 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
451 i::AstValueFactory ast_value_factory(&zone, 451 i::AstValueFactory ast_value_factory(&zone,
452 CcTest::i_isolate()->heap()->HashSeed()); 452 CcTest::i_isolate()->heap()->HashSeed());
453 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 453 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
454 CcTest::i_isolate()->stack_guard()->real_climit()); 454 CcTest::i_isolate()->stack_guard()->real_climit());
455 preparser.set_allow_lazy(true); 455 preparser.set_allow_lazy(true);
456 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 456 i::PreParser::PreParseResult result = preparser.PreParseProgram();
457 // Even in the case of a syntax error, kPreParseSuccess is returned. 457 // Even in the case of a syntax error, kPreParseSuccess is returned.
458 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 458 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
459 CHECK(log.HasError()); 459 CHECK(log.HasError());
460 } 460 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 memset(program.get(), '(', kProgramSize); 515 memset(program.get(), '(', kProgramSize);
516 program[kProgramSize] = '\0'; 516 program[kProgramSize] = '\0';
517 517
518 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 518 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
519 519
520 auto stream = i::ScannerStream::ForTesting(program.get(), kProgramSize); 520 auto stream = i::ScannerStream::ForTesting(program.get(), kProgramSize);
521 i::CompleteParserRecorder log; 521 i::CompleteParserRecorder log;
522 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 522 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
523 scanner.Initialize(stream.get()); 523 scanner.Initialize(stream.get());
524 524
525 i::Zone zone(CcTest::i_isolate()->allocator()); 525 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
526 i::AstValueFactory ast_value_factory(&zone, 526 i::AstValueFactory ast_value_factory(&zone,
527 CcTest::i_isolate()->heap()->HashSeed()); 527 CcTest::i_isolate()->heap()->HashSeed());
528 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 528 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
529 stack_limit); 529 stack_limit);
530 preparser.set_allow_lazy(true); 530 preparser.set_allow_lazy(true);
531 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 531 i::PreParser::PreParseResult result = preparser.PreParseProgram();
532 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); 532 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result);
533 } 533 }
534 534
535 535
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 void TestScanRegExp(const char* re_source, const char* expected) { 615 void TestScanRegExp(const char* re_source, const char* expected) {
616 auto stream = i::ScannerStream::ForTesting(re_source); 616 auto stream = i::ScannerStream::ForTesting(re_source);
617 i::HandleScope scope(CcTest::i_isolate()); 617 i::HandleScope scope(CcTest::i_isolate());
618 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 618 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
619 scanner.Initialize(stream.get()); 619 scanner.Initialize(stream.get());
620 620
621 i::Token::Value start = scanner.peek(); 621 i::Token::Value start = scanner.peek();
622 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); 622 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV);
623 CHECK(scanner.ScanRegExpPattern()); 623 CHECK(scanner.ScanRegExpPattern());
624 scanner.Next(); // Current token is now the regexp literal. 624 scanner.Next(); // Current token is now the regexp literal.
625 i::Zone zone(CcTest::i_isolate()->allocator()); 625 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
626 i::AstValueFactory ast_value_factory(&zone, 626 i::AstValueFactory ast_value_factory(&zone,
627 CcTest::i_isolate()->heap()->HashSeed()); 627 CcTest::i_isolate()->heap()->HashSeed());
628 const i::AstRawString* current_symbol = 628 const i::AstRawString* current_symbol =
629 scanner.CurrentSymbol(&ast_value_factory); 629 scanner.CurrentSymbol(&ast_value_factory);
630 ast_value_factory.Internalize(CcTest::i_isolate()); 630 ast_value_factory.Internalize(CcTest::i_isolate());
631 i::Handle<i::String> val = current_symbol->string(); 631 i::Handle<i::String> val = current_symbol->string();
632 i::DisallowHeapAllocation no_alloc; 632 i::DisallowHeapAllocation no_alloc;
633 i::String::FlatContent content = val->GetFlatContent(); 633 i::String::FlatContent content = val->GetFlatContent();
634 CHECK(content.IsOneByte()); 634 CHECK(content.IsOneByte());
635 i::Vector<const uint8_t> actual = content.ToOneByteVector(); 635 i::Vector<const uint8_t> actual = content.ToOneByteVector();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 int kProgramByteSize = i::StrLength(surroundings[j].prefix) + 840 int kProgramByteSize = i::StrLength(surroundings[j].prefix) +
841 i::StrLength(surroundings[j].suffix) + 841 i::StrLength(surroundings[j].suffix) +
842 i::StrLength(source_data[i].body); 842 i::StrLength(source_data[i].body);
843 i::ScopedVector<char> program(kProgramByteSize + 1); 843 i::ScopedVector<char> program(kProgramByteSize + 1);
844 i::SNPrintF(program, "%s%s%s", surroundings[j].prefix, 844 i::SNPrintF(program, "%s%s%s", surroundings[j].prefix,
845 source_data[i].body, surroundings[j].suffix); 845 source_data[i].body, surroundings[j].suffix);
846 i::Handle<i::String> source = 846 i::Handle<i::String> source =
847 factory->NewStringFromUtf8(i::CStrVector(program.start())) 847 factory->NewStringFromUtf8(i::CStrVector(program.start()))
848 .ToHandleChecked(); 848 .ToHandleChecked();
849 i::Handle<i::Script> script = factory->NewScript(source); 849 i::Handle<i::Script> script = factory->NewScript(source);
850 i::Zone zone(CcTest::i_isolate()->allocator()); 850 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
851 i::ParseInfo info(&zone, script); 851 i::ParseInfo info(&zone, script);
852 i::Parser parser(&info); 852 i::Parser parser(&info);
853 CHECK(parser.Parse(&info)); 853 CHECK(parser.Parse(&info));
854 CHECK(i::Rewriter::Rewrite(&info)); 854 CHECK(i::Rewriter::Rewrite(&info));
855 i::DeclarationScope::Analyze(&info, i::AnalyzeMode::kRegular); 855 i::DeclarationScope::Analyze(&info, i::AnalyzeMode::kRegular);
856 CHECK(info.literal() != NULL); 856 CHECK(info.literal() != NULL);
857 857
858 i::DeclarationScope* script_scope = info.literal()->scope(); 858 i::DeclarationScope* script_scope = info.literal()->scope();
859 CHECK(script_scope->is_script_scope()); 859 CHECK(script_scope->is_script_scope());
860 860
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 i::SNPrintF(program, "%s%s%s", 1157 i::SNPrintF(program, "%s%s%s",
1158 source_data[i].outer_prefix, 1158 source_data[i].outer_prefix,
1159 source_data[i].inner_source, 1159 source_data[i].inner_source,
1160 source_data[i].outer_suffix); 1160 source_data[i].outer_suffix);
1161 1161
1162 // Parse program source. 1162 // Parse program source.
1163 i::Handle<i::String> source = factory->NewStringFromUtf8( 1163 i::Handle<i::String> source = factory->NewStringFromUtf8(
1164 i::CStrVector(program.start())).ToHandleChecked(); 1164 i::CStrVector(program.start())).ToHandleChecked();
1165 CHECK_EQ(source->length(), kProgramSize); 1165 CHECK_EQ(source->length(), kProgramSize);
1166 i::Handle<i::Script> script = factory->NewScript(source); 1166 i::Handle<i::Script> script = factory->NewScript(source);
1167 i::Zone zone(CcTest::i_isolate()->allocator()); 1167 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
1168 i::ParseInfo info(&zone, script); 1168 i::ParseInfo info(&zone, script);
1169 i::Parser parser(&info); 1169 i::Parser parser(&info);
1170 parser.set_allow_lazy(true); 1170 parser.set_allow_lazy(true);
1171 info.set_language_mode(source_data[i].language_mode); 1171 info.set_language_mode(source_data[i].language_mode);
1172 parser.Parse(&info); 1172 parser.Parse(&info);
1173 CHECK(info.literal() != NULL); 1173 CHECK(info.literal() != NULL);
1174 1174
1175 // Check scope types and positions. 1175 // Check scope types and positions.
1176 i::Scope* scope = info.literal()->scope(); 1176 i::Scope* scope = info.literal()->scope();
1177 CHECK(scope->is_script_scope()); 1177 CHECK(scope->is_script_scope());
(...skipping 28 matching lines...) Expand all
1206 i::Isolate* isolate = CcTest::i_isolate(); 1206 i::Isolate* isolate = CcTest::i_isolate();
1207 i::Factory* factory = isolate->factory(); 1207 i::Factory* factory = isolate->factory();
1208 v8::HandleScope handles(CcTest::isolate()); 1208 v8::HandleScope handles(CcTest::isolate());
1209 i::FunctionLiteral* function; 1209 i::FunctionLiteral* function;
1210 1210
1211 for (int i = 0; discard_sources[i]; i++) { 1211 for (int i = 0; discard_sources[i]; i++) {
1212 const char* source = discard_sources[i]; 1212 const char* source = discard_sources[i];
1213 i::Handle<i::String> source_code = 1213 i::Handle<i::String> source_code =
1214 factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked(); 1214 factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked();
1215 i::Handle<i::Script> script = factory->NewScript(source_code); 1215 i::Handle<i::Script> script = factory->NewScript(source_code);
1216 i::Zone zone(CcTest::i_isolate()->allocator()); 1216 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
1217 i::ParseInfo info(&zone, script); 1217 i::ParseInfo info(&zone, script);
1218 info.set_allow_lazy_parsing(); 1218 info.set_allow_lazy_parsing();
1219 i::Parser parser(&info); 1219 i::Parser parser(&info);
1220 parser.Parse(&info); 1220 parser.Parse(&info);
1221 function = info.literal(); 1221 function = info.literal();
1222 CHECK_NOT_NULL(function); 1222 CHECK_NOT_NULL(function);
1223 CHECK_NOT_NULL(function->body()); 1223 CHECK_NOT_NULL(function->body());
1224 CHECK_EQ(1, function->body()->length()); 1224 CHECK_EQ(1, function->body()->length());
1225 i::FunctionLiteral* inner = 1225 i::FunctionLiteral* inner =
1226 function->body()->first()->AsExpressionStatement()->expression()-> 1226 function->body()->first()->AsExpressionStatement()->expression()->
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); 1332 uintptr_t stack_limit = isolate->stack_guard()->real_climit();
1333 int preparser_materialized_literals = -1; 1333 int preparser_materialized_literals = -1;
1334 int parser_materialized_literals = -2; 1334 int parser_materialized_literals = -2;
1335 1335
1336 // Preparse the data. 1336 // Preparse the data.
1337 i::CompleteParserRecorder log; 1337 i::CompleteParserRecorder log;
1338 if (test_preparser) { 1338 if (test_preparser) {
1339 i::Scanner scanner(isolate->unicode_cache()); 1339 i::Scanner scanner(isolate->unicode_cache());
1340 std::unique_ptr<i::Utf16CharacterStream> stream( 1340 std::unique_ptr<i::Utf16CharacterStream> stream(
1341 i::ScannerStream::For(source)); 1341 i::ScannerStream::For(source));
1342 i::Zone zone(CcTest::i_isolate()->allocator()); 1342 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
1343 i::AstValueFactory ast_value_factory( 1343 i::AstValueFactory ast_value_factory(
1344 &zone, CcTest::i_isolate()->heap()->HashSeed()); 1344 &zone, CcTest::i_isolate()->heap()->HashSeed());
1345 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 1345 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
1346 stack_limit); 1346 stack_limit);
1347 SetParserFlags(&preparser, flags); 1347 SetParserFlags(&preparser, flags);
1348 scanner.Initialize(stream.get()); 1348 scanner.Initialize(stream.get());
1349 i::PreParser::PreParseResult result = 1349 i::PreParser::PreParseResult result =
1350 preparser.PreParseProgram(&preparser_materialized_literals, is_module); 1350 preparser.PreParseProgram(&preparser_materialized_literals, is_module);
1351 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 1351 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1352 } 1352 }
1353 bool preparse_error = log.HasError(); 1353 bool preparse_error = log.HasError();
1354 1354
1355 // Parse the data 1355 // Parse the data
1356 i::FunctionLiteral* function; 1356 i::FunctionLiteral* function;
1357 { 1357 {
1358 i::Handle<i::Script> script = factory->NewScript(source); 1358 i::Handle<i::Script> script = factory->NewScript(source);
1359 i::Zone zone(CcTest::i_isolate()->allocator()); 1359 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
1360 i::ParseInfo info(&zone, script); 1360 i::ParseInfo info(&zone, script);
1361 i::Parser parser(&info); 1361 i::Parser parser(&info);
1362 SetParserFlags(&parser, flags); 1362 SetParserFlags(&parser, flags);
1363 if (is_module) info.set_module(); 1363 if (is_module) info.set_module();
1364 parser.Parse(&info); 1364 parser.Parse(&info);
1365 function = info.literal(); 1365 function = info.literal();
1366 if (function) { 1366 if (function) {
1367 parser_materialized_literals = function->materialized_literal_count(); 1367 parser_materialized_literals = function->materialized_literal_count();
1368 } 1368 }
1369 } 1369 }
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 {"function lazy() { var x = {get foo(){} } }", 1}, 2479 {"function lazy() { var x = {get foo(){} } }", 1},
2480 {NULL, 0} 2480 {NULL, 0}
2481 }; 2481 };
2482 2482
2483 for (int i = 0; test_cases[i].program; i++) { 2483 for (int i = 0; test_cases[i].program; i++) {
2484 const char* program = test_cases[i].program; 2484 const char* program = test_cases[i].program;
2485 i::Factory* factory = CcTest::i_isolate()->factory(); 2485 i::Factory* factory = CcTest::i_isolate()->factory();
2486 i::Handle<i::String> source = 2486 i::Handle<i::String> source =
2487 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); 2487 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked();
2488 i::Handle<i::Script> script = factory->NewScript(source); 2488 i::Handle<i::Script> script = factory->NewScript(source);
2489 i::Zone zone(CcTest::i_isolate()->allocator()); 2489 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
2490 i::ParseInfo info(&zone, script); 2490 i::ParseInfo info(&zone, script);
2491 i::ScriptData* sd = NULL; 2491 i::ScriptData* sd = NULL;
2492 info.set_cached_data(&sd); 2492 info.set_cached_data(&sd);
2493 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); 2493 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache);
2494 info.set_allow_lazy_parsing(); 2494 info.set_allow_lazy_parsing();
2495 i::Parser::ParseStatic(&info); 2495 i::Parser::ParseStatic(&info);
2496 i::ParseData* pd = i::ParseData::FromCachedData(sd); 2496 i::ParseData* pd = i::ParseData::FromCachedData(sd);
2497 2497
2498 if (pd->FunctionCount() != test_cases[i].functions) { 2498 if (pd->FunctionCount() != test_cases[i].functions) {
2499 v8::base::OS::Print( 2499 v8::base::OS::Print(
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 " assertResult([2]);" 3185 " assertResult([2]);"
3186 " return f;" 3186 " return f;"
3187 "};" 3187 "};"
3188 "h();"; 3188 "h();";
3189 3189
3190 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1); 3190 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
3191 i::SNPrintF(program, "%s", src); 3191 i::SNPrintF(program, "%s", src);
3192 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3192 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3193 source->PrintOn(stdout); 3193 source->PrintOn(stdout);
3194 printf("\n"); 3194 printf("\n");
3195 i::Zone zone(CcTest::i_isolate()->allocator()); 3195 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
3196 v8::Local<v8::Value> v = CompileRun(src); 3196 v8::Local<v8::Value> v = CompileRun(src);
3197 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3197 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3198 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3198 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3199 i::Context* context = f->context(); 3199 i::Context* context = f->context();
3200 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3200 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3201 const i::AstRawString* name = avf.GetOneByteString("result"); 3201 const i::AstRawString* name = avf.GetOneByteString("result");
3202 avf.Internalize(isolate); 3202 avf.Internalize(isolate);
3203 i::Handle<i::String> str = name->string(); 3203 i::Handle<i::String> str = name->string();
3204 CHECK(str->IsInternalizedString()); 3204 CHECK(str->IsInternalizedString());
3205 i::DeclarationScope* script_scope = 3205 i::DeclarationScope* script_scope =
(...skipping 29 matching lines...) Expand all
3235 " };" 3235 " };"
3236 " return g;" 3236 " return g;"
3237 " }" 3237 " }"
3238 "f(0);"; 3238 "f(0);";
3239 3239
3240 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1); 3240 i::ScopedVector<char> program(Utf8LengthHelper(src) + 1);
3241 i::SNPrintF(program, "%s", src); 3241 i::SNPrintF(program, "%s", src);
3242 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start()); 3242 i::Handle<i::String> source = factory->InternalizeUtf8String(program.start());
3243 source->PrintOn(stdout); 3243 source->PrintOn(stdout);
3244 printf("\n"); 3244 printf("\n");
3245 i::Zone zone(CcTest::i_isolate()->allocator()); 3245 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
3246 v8::Local<v8::Value> v = CompileRun(src); 3246 v8::Local<v8::Value> v = CompileRun(src);
3247 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3247 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3248 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3248 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3249 i::Context* context = f->context(); 3249 i::Context* context = f->context();
3250 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3250 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3251 const i::AstRawString* name_x = avf.GetOneByteString("x"); 3251 const i::AstRawString* name_x = avf.GetOneByteString("x");
3252 avf.Internalize(isolate); 3252 avf.Internalize(isolate);
3253 3253
3254 i::DeclarationScope* script_scope = 3254 i::DeclarationScope* script_scope =
3255 new (&zone) i::DeclarationScope(&zone, &avf); 3255 new (&zone) i::DeclarationScope(&zone, &avf);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 if (outers[i].strict && inners[j].with) continue; 3364 if (outers[i].strict && inners[j].with) continue;
3365 const char* inner = inners[j].source; 3365 const char* inner = inners[j].source;
3366 int inner_len = Utf8LengthHelper(inner); 3366 int inner_len = Utf8LengthHelper(inner);
3367 3367
3368 int len = prefix_len + outer_len + midfix_len + inner_len + suffix_len; 3368 int len = prefix_len + outer_len + midfix_len + inner_len + suffix_len;
3369 i::ScopedVector<char> program(len + 1); 3369 i::ScopedVector<char> program(len + 1);
3370 3370
3371 i::SNPrintF(program, "%s%s%s%s%s", prefix, outer, midfix, inner, 3371 i::SNPrintF(program, "%s%s%s%s%s", prefix, outer, midfix, inner,
3372 suffix); 3372 suffix);
3373 3373
3374 i::Zone zone(CcTest::i_isolate()->allocator()); 3374 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
3375 std::unique_ptr<i::ParseInfo> info; 3375 std::unique_ptr<i::ParseInfo> info;
3376 if (lazy) { 3376 if (lazy) {
3377 printf("%s\n", program.start()); 3377 printf("%s\n", program.start());
3378 v8::Local<v8::Value> v = CompileRun(program.start()); 3378 v8::Local<v8::Value> v = CompileRun(program.start());
3379 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3379 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3380 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3380 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3381 i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); 3381 i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared());
3382 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared)); 3382 info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared));
3383 } else { 3383 } else {
3384 i::Handle<i::String> source = 3384 i::Handle<i::String> source =
(...skipping 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after
5643 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5643 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5644 128 * 1024); 5644 128 * 1024);
5645 5645
5646 for (unsigned i = 0; i < arraysize(kSources); ++i) { 5646 for (unsigned i = 0; i < arraysize(kSources); ++i) {
5647 i::Handle<i::String> source = 5647 i::Handle<i::String> source =
5648 factory->NewStringFromAsciiChecked(kSources[i]); 5648 factory->NewStringFromAsciiChecked(kSources[i]);
5649 5649
5650 // Show that parsing as a module works 5650 // Show that parsing as a module works
5651 { 5651 {
5652 i::Handle<i::Script> script = factory->NewScript(source); 5652 i::Handle<i::Script> script = factory->NewScript(source);
5653 i::Zone zone(CcTest::i_isolate()->allocator()); 5653 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
5654 i::ParseInfo info(&zone, script); 5654 i::ParseInfo info(&zone, script);
5655 i::Parser parser(&info); 5655 i::Parser parser(&info);
5656 info.set_module(); 5656 info.set_module();
5657 if (!parser.Parse(&info)) { 5657 if (!parser.Parse(&info)) {
5658 i::Handle<i::JSObject> exception_handle( 5658 i::Handle<i::JSObject> exception_handle(
5659 i::JSObject::cast(isolate->pending_exception())); 5659 i::JSObject::cast(isolate->pending_exception()));
5660 i::Handle<i::String> message_string = i::Handle<i::String>::cast( 5660 i::Handle<i::String> message_string = i::Handle<i::String>::cast(
5661 i::JSReceiver::GetProperty(isolate, exception_handle, "message") 5661 i::JSReceiver::GetProperty(isolate, exception_handle, "message")
5662 .ToHandleChecked()); 5662 .ToHandleChecked());
5663 isolate->clear_pending_exception(); 5663 isolate->clear_pending_exception();
5664 5664
5665 v8::base::OS::Print( 5665 v8::base::OS::Print(
5666 "Parser failed on:\n" 5666 "Parser failed on:\n"
5667 "\t%s\n" 5667 "\t%s\n"
5668 "with error:\n" 5668 "with error:\n"
5669 "\t%s\n" 5669 "\t%s\n"
5670 "However, we expected no error.", 5670 "However, we expected no error.",
5671 source->ToCString().get(), message_string->ToCString().get()); 5671 source->ToCString().get(), message_string->ToCString().get());
5672 CHECK(false); 5672 CHECK(false);
5673 } 5673 }
5674 } 5674 }
5675 5675
5676 // And that parsing a script does not. 5676 // And that parsing a script does not.
5677 { 5677 {
5678 i::Handle<i::Script> script = factory->NewScript(source); 5678 i::Handle<i::Script> script = factory->NewScript(source);
5679 i::Zone zone(CcTest::i_isolate()->allocator()); 5679 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
5680 i::ParseInfo info(&zone, script); 5680 i::ParseInfo info(&zone, script);
5681 i::Parser parser(&info); 5681 i::Parser parser(&info);
5682 CHECK(!parser.Parse(&info)); 5682 CHECK(!parser.Parse(&info));
5683 isolate->clear_pending_exception(); 5683 isolate->clear_pending_exception();
5684 } 5684 }
5685 } 5685 }
5686 } 5686 }
5687 5687
5688 5688
5689 TEST(ImportExportParsingErrors) { 5689 TEST(ImportExportParsingErrors) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
5761 v8::Context::Scope context_scope(context); 5761 v8::Context::Scope context_scope(context);
5762 5762
5763 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5763 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5764 128 * 1024); 5764 128 * 1024);
5765 5765
5766 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { 5766 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
5767 i::Handle<i::String> source = 5767 i::Handle<i::String> source =
5768 factory->NewStringFromAsciiChecked(kErrorSources[i]); 5768 factory->NewStringFromAsciiChecked(kErrorSources[i]);
5769 5769
5770 i::Handle<i::Script> script = factory->NewScript(source); 5770 i::Handle<i::Script> script = factory->NewScript(source);
5771 i::Zone zone(CcTest::i_isolate()->allocator()); 5771 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
5772 i::ParseInfo info(&zone, script); 5772 i::ParseInfo info(&zone, script);
5773 i::Parser parser(&info); 5773 i::Parser parser(&info);
5774 info.set_module(); 5774 info.set_module();
5775 CHECK(!parser.Parse(&info)); 5775 CHECK(!parser.Parse(&info));
5776 isolate->clear_pending_exception(); 5776 isolate->clear_pending_exception();
5777 } 5777 }
5778 } 5778 }
5779 5779
5780 TEST(ModuleTopLevelFunctionDecl) { 5780 TEST(ModuleTopLevelFunctionDecl) {
5781 // clang-format off 5781 // clang-format off
(...skipping 17 matching lines...) Expand all
5799 v8::Context::Scope context_scope(context); 5799 v8::Context::Scope context_scope(context);
5800 5800
5801 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5801 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5802 128 * 1024); 5802 128 * 1024);
5803 5803
5804 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) { 5804 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
5805 i::Handle<i::String> source = 5805 i::Handle<i::String> source =
5806 factory->NewStringFromAsciiChecked(kErrorSources[i]); 5806 factory->NewStringFromAsciiChecked(kErrorSources[i]);
5807 5807
5808 i::Handle<i::Script> script = factory->NewScript(source); 5808 i::Handle<i::Script> script = factory->NewScript(source);
5809 i::Zone zone(CcTest::i_isolate()->allocator()); 5809 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
5810 i::ParseInfo info(&zone, script); 5810 i::ParseInfo info(&zone, script);
5811 i::Parser parser(&info); 5811 i::Parser parser(&info);
5812 info.set_module(); 5812 info.set_module();
5813 CHECK(!parser.Parse(&info)); 5813 CHECK(!parser.Parse(&info));
5814 isolate->clear_pending_exception(); 5814 isolate->clear_pending_exception();
5815 } 5815 }
5816 } 5816 }
5817 5817
5818 TEST(ModuleAwaitReserved) { 5818 TEST(ModuleAwaitReserved) {
5819 // clang-format off 5819 // clang-format off
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
5998 "import 'q.js';" 5998 "import 'q.js';"
5999 "let nonexport = 42;" 5999 "let nonexport = 42;"
6000 "import {m as mm} from 'm.js';" 6000 "import {m as mm} from 'm.js';"
6001 "import {aa} from 'm.js';" 6001 "import {aa} from 'm.js';"
6002 "export {aa as bb, x};" 6002 "export {aa as bb, x};"
6003 "import * as loo from 'bar.js';" 6003 "import * as loo from 'bar.js';"
6004 "import * as foob from 'bar.js';" 6004 "import * as foob from 'bar.js';"
6005 "export {foob};"; 6005 "export {foob};";
6006 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); 6006 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
6007 i::Handle<i::Script> script = factory->NewScript(source); 6007 i::Handle<i::Script> script = factory->NewScript(source);
6008 i::Zone zone(CcTest::i_isolate()->allocator()); 6008 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
6009 i::ParseInfo info(&zone, script); 6009 i::ParseInfo info(&zone, script);
6010 i::Parser parser(&info); 6010 i::Parser parser(&info);
6011 info.set_module(); 6011 info.set_module();
6012 CHECK(parser.Parse(&info)); 6012 CHECK(parser.Parse(&info));
6013 CHECK(i::Compiler::Analyze(&info)); 6013 CHECK(i::Compiler::Analyze(&info));
6014 i::FunctionLiteral* func = info.literal(); 6014 i::FunctionLiteral* func = info.literal();
6015 i::ModuleScope* module_scope = func->scope()->AsModuleScope(); 6015 i::ModuleScope* module_scope = func->scope()->AsModuleScope();
6016 i::Scope* outer_scope = module_scope->outer_scope(); 6016 i::Scope* outer_scope = module_scope->outer_scope();
6017 CHECK(outer_scope->is_script_scope()); 6017 CHECK(outer_scope->is_script_scope());
6018 CHECK_NULL(outer_scope->outer_scope()); 6018 CHECK_NULL(outer_scope->outer_scope());
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
6247 i::Isolate* isolate = CcTest::i_isolate(); 6247 i::Isolate* isolate = CcTest::i_isolate();
6248 i::Factory* factory = isolate->factory(); 6248 i::Factory* factory = isolate->factory();
6249 v8::HandleScope handles(CcTest::isolate()); 6249 v8::HandleScope handles(CcTest::isolate());
6250 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); 6250 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
6251 v8::Context::Scope context_scope(context); 6251 v8::Context::Scope context_scope(context);
6252 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 6252 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
6253 128 * 1024); 6253 128 * 1024);
6254 6254
6255 i::Handle<i::Script> script = 6255 i::Handle<i::Script> script =
6256 factory->NewScript(factory->NewStringFromAsciiChecked(source)); 6256 factory->NewScript(factory->NewStringFromAsciiChecked(source));
6257 i::Zone zone(CcTest::i_isolate()->allocator()); 6257 i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
6258 i::ParseInfo info(&zone, script); 6258 i::ParseInfo info(&zone, script);
6259 i::Parser parser(&info); 6259 i::Parser parser(&info);
6260 parser.Parse(&info); 6260 parser.Parse(&info);
6261 CHECK(info.literal() != NULL); 6261 CHECK(info.literal() != NULL);
6262 CHECK_EQ(expected_language_mode, info.literal()->language_mode()); 6262 CHECK_EQ(expected_language_mode, info.literal()->language_mode());
6263 } 6263 }
6264 6264
6265 6265
6266 TEST(LanguageModeDirectives) { 6266 TEST(LanguageModeDirectives) {
6267 TestLanguageMode("\"use nothing\"", i::SLOPPY); 6267 TestLanguageMode("\"use nothing\"", i::SLOPPY);
(...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after
8325 const char* data[] = { 8325 const char* data[] = {
8326 "const arguments = 1", 8326 "const arguments = 1",
8327 "let arguments", 8327 "let arguments",
8328 "var arguments", 8328 "var arguments",
8329 NULL 8329 NULL
8330 }; 8330 };
8331 // clang-format on 8331 // clang-format on
8332 RunParserSyncTest(context_data, data, kSuccess); 8332 RunParserSyncTest(context_data, data, kSuccess);
8333 } 8333 }
8334 } 8334 }
OLDNEW
« no previous file with comments | « test/cctest/test-liveedit.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698