| OLD | NEW | 
|---|
| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 171     i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 
| 172     scanner.Initialize(stream.get()); | 172     scanner.Initialize(stream.get()); | 
| 173     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 173     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 174     i::AstValueFactory ast_value_factory( | 174     i::AstValueFactory ast_value_factory( | 
| 175         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 175         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 
| 176     i::PreParser preparser(&zone, &scanner, &ast_value_factory, stack_limit); | 176     i::PendingCompilationErrorHandler pending_error_handler; | 
|  | 177     i::PreParser preparser(&zone, &scanner, &ast_value_factory, | 
|  | 178                            &pending_error_handler, stack_limit); | 
| 177     preparser.set_allow_lazy(true); | 179     preparser.set_allow_lazy(true); | 
| 178     i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 180     i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 
| 179     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 181     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 
| 180     CHECK(!preparser.logger()->has_error()); | 182     CHECK(!pending_error_handler.has_pending_error()); | 
| 181   } | 183   } | 
| 182 | 184 | 
| 183   for (int i = 0; fail_tests[i]; i++) { | 185   for (int i = 0; fail_tests[i]; i++) { | 
| 184     const char* source = fail_tests[i]; | 186     const char* source = fail_tests[i]; | 
| 185     auto stream = i::ScannerStream::ForTesting(source); | 187     auto stream = i::ScannerStream::ForTesting(source); | 
| 186     i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 188     i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 
| 187     scanner.Initialize(stream.get()); | 189     scanner.Initialize(stream.get()); | 
| 188     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 190     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 189     i::AstValueFactory ast_value_factory( | 191     i::AstValueFactory ast_value_factory( | 
| 190         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 192         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 
| 191     i::PreParser preparser(&zone, &scanner, &ast_value_factory, stack_limit); | 193     i::PendingCompilationErrorHandler pending_error_handler; | 
|  | 194     i::PreParser preparser(&zone, &scanner, &ast_value_factory, | 
|  | 195                            &pending_error_handler, stack_limit); | 
| 192     preparser.set_allow_lazy(true); | 196     preparser.set_allow_lazy(true); | 
| 193     i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 197     i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 
| 194     // Even in the case of a syntax error, kPreParseSuccess is returned. | 198     // Even in the case of a syntax error, kPreParseSuccess is returned. | 
| 195     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 199     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 
| 196     CHECK(preparser.logger()->has_error()); | 200     CHECK(pending_error_handler.has_pending_error()); | 
| 197   } | 201   } | 
| 198 } | 202 } | 
| 199 | 203 | 
| 200 | 204 | 
| 201 class ScriptResource : public v8::String::ExternalOneByteStringResource { | 205 class ScriptResource : public v8::String::ExternalOneByteStringResource { | 
| 202  public: | 206  public: | 
| 203   ScriptResource(const char* data, size_t length) | 207   ScriptResource(const char* data, size_t length) | 
| 204       : data_(data), length_(length) { } | 208       : data_(data), length_(length) { } | 
| 205 | 209 | 
| 206   const char* data() const { return data_; } | 210   const char* data() const { return data_; } | 
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 353 | 357 | 
| 354   uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 358   uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 
| 355   for (int i = 0; programs[i]; i++) { | 359   for (int i = 0; programs[i]; i++) { | 
| 356     auto stream = i::ScannerStream::ForTesting(programs[i]); | 360     auto stream = i::ScannerStream::ForTesting(programs[i]); | 
| 357     i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 361     i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 
| 358     scanner.Initialize(stream.get()); | 362     scanner.Initialize(stream.get()); | 
| 359 | 363 | 
| 360     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 364     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 361     i::AstValueFactory ast_value_factory( | 365     i::AstValueFactory ast_value_factory( | 
| 362         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 366         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 
| 363     i::PreParser preparser(&zone, &scanner, &ast_value_factory, stack_limit); | 367     i::PendingCompilationErrorHandler pending_error_handler; | 
|  | 368     i::PreParser preparser(&zone, &scanner, &ast_value_factory, | 
|  | 369                            &pending_error_handler, stack_limit); | 
| 364     preparser.set_allow_lazy(true); | 370     preparser.set_allow_lazy(true); | 
| 365     preparser.set_allow_natives(true); | 371     preparser.set_allow_natives(true); | 
| 366     i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 372     i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 
| 367     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 373     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 
| 368     CHECK(!preparser.logger()->has_error()); | 374     CHECK(!pending_error_handler.has_pending_error()); | 
| 369   } | 375   } | 
| 370 } | 376 } | 
| 371 | 377 | 
| 372 | 378 | 
| 373 TEST(StandAlonePreParserNoNatives) { | 379 TEST(StandAlonePreParserNoNatives) { | 
| 374   v8::V8::Initialize(); | 380   v8::V8::Initialize(); | 
| 375 | 381 | 
| 376   CcTest::i_isolate()->stack_guard()->SetStackLimit( | 382   CcTest::i_isolate()->stack_guard()->SetStackLimit( | 
| 377       i::GetCurrentStackPosition() - 128 * 1024); | 383       i::GetCurrentStackPosition() - 128 * 1024); | 
| 378 | 384 | 
| 379   const char* programs[] = { | 385   const char* programs[] = { | 
| 380       "%ArgleBargle(glop);", | 386       "%ArgleBargle(glop);", | 
| 381       "var x = %_IsSmi(42);", | 387       "var x = %_IsSmi(42);", | 
| 382       NULL | 388       NULL | 
| 383   }; | 389   }; | 
| 384 | 390 | 
| 385   uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 391   uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 
| 386   for (int i = 0; programs[i]; i++) { | 392   for (int i = 0; programs[i]; i++) { | 
| 387     auto stream = i::ScannerStream::ForTesting(programs[i]); | 393     auto stream = i::ScannerStream::ForTesting(programs[i]); | 
| 388     i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 394     i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 
| 389     scanner.Initialize(stream.get()); | 395     scanner.Initialize(stream.get()); | 
| 390 | 396 | 
| 391     // Preparser defaults to disallowing natives syntax. | 397     // Preparser defaults to disallowing natives syntax. | 
| 392     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 398     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 393     i::AstValueFactory ast_value_factory( | 399     i::AstValueFactory ast_value_factory( | 
| 394         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 400         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 
| 395     i::PreParser preparser(&zone, &scanner, &ast_value_factory, stack_limit); | 401     i::PendingCompilationErrorHandler pending_error_handler; | 
|  | 402     i::PreParser preparser(&zone, &scanner, &ast_value_factory, | 
|  | 403                            &pending_error_handler, stack_limit); | 
| 396     preparser.set_allow_lazy(true); | 404     preparser.set_allow_lazy(true); | 
| 397     i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 405     i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 
| 398     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 406     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 
| 399     CHECK(preparser.logger()->has_error()); | 407     CHECK(pending_error_handler.has_pending_error()); | 
| 400   } | 408   } | 
| 401 } | 409 } | 
| 402 | 410 | 
| 403 | 411 | 
| 404 TEST(PreparsingObjectLiterals) { | 412 TEST(PreparsingObjectLiterals) { | 
| 405   // Regression test for a bug where the symbol stream produced by PreParser | 413   // Regression test for a bug where the symbol stream produced by PreParser | 
| 406   // didn't match what Parser wanted to consume. | 414   // didn't match what Parser wanted to consume. | 
| 407   v8::Isolate* isolate = CcTest::isolate(); | 415   v8::Isolate* isolate = CcTest::isolate(); | 
| 408   v8::HandleScope handles(isolate); | 416   v8::HandleScope handles(isolate); | 
| 409   v8::Local<v8::Context> context = v8::Context::New(isolate); | 417   v8::Local<v8::Context> context = v8::Context::New(isolate); | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 450   // Before fix, didn't check *ok after Expect(Token::Identifier, ok), | 458   // Before fix, didn't check *ok after Expect(Token::Identifier, ok), | 
| 451   // and then used the invalid currently scanned literal. This always | 459   // and then used the invalid currently scanned literal. This always | 
| 452   // failed in debug mode, and sometimes crashed in release mode. | 460   // failed in debug mode, and sometimes crashed in release mode. | 
| 453 | 461 | 
| 454   auto stream = i::ScannerStream::ForTesting(program); | 462   auto stream = i::ScannerStream::ForTesting(program); | 
| 455   i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 463   i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 
| 456   scanner.Initialize(stream.get()); | 464   scanner.Initialize(stream.get()); | 
| 457   i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 465   i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 458   i::AstValueFactory ast_value_factory(&zone, | 466   i::AstValueFactory ast_value_factory(&zone, | 
| 459                                        CcTest::i_isolate()->heap()->HashSeed()); | 467                                        CcTest::i_isolate()->heap()->HashSeed()); | 
|  | 468   i::PendingCompilationErrorHandler pending_error_handler; | 
| 460   i::PreParser preparser(&zone, &scanner, &ast_value_factory, | 469   i::PreParser preparser(&zone, &scanner, &ast_value_factory, | 
|  | 470                          &pending_error_handler, | 
| 461                          CcTest::i_isolate()->stack_guard()->real_climit()); | 471                          CcTest::i_isolate()->stack_guard()->real_climit()); | 
| 462   preparser.set_allow_lazy(true); | 472   preparser.set_allow_lazy(true); | 
| 463   i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 473   i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 
| 464   // Even in the case of a syntax error, kPreParseSuccess is returned. | 474   // Even in the case of a syntax error, kPreParseSuccess is returned. | 
| 465   CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 475   CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 
| 466   CHECK(preparser.logger()->has_error()); | 476   CHECK(pending_error_handler.has_pending_error()); | 
| 467 } | 477 } | 
| 468 | 478 | 
| 469 | 479 | 
| 470 TEST(Regress928) { | 480 TEST(Regress928) { | 
| 471   // Test only applies when lazy parsing. | 481   // Test only applies when lazy parsing. | 
| 472   if (!i::FLAG_lazy) return; | 482   if (!i::FLAG_lazy) return; | 
| 473   i::FLAG_min_preparse_length = 0; | 483   i::FLAG_min_preparse_length = 0; | 
| 474 | 484 | 
| 475   // Tests that the first non-toplevel function is not included in the preparse | 485   // Tests that the first non-toplevel function is not included in the preparse | 
| 476   // data. | 486   // data. | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 523 | 533 | 
| 524   uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 534   uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 
| 525 | 535 | 
| 526   auto stream = i::ScannerStream::ForTesting(program.get(), kProgramSize); | 536   auto stream = i::ScannerStream::ForTesting(program.get(), kProgramSize); | 
| 527   i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 537   i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 
| 528   scanner.Initialize(stream.get()); | 538   scanner.Initialize(stream.get()); | 
| 529 | 539 | 
| 530   i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 540   i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 531   i::AstValueFactory ast_value_factory(&zone, | 541   i::AstValueFactory ast_value_factory(&zone, | 
| 532                                        CcTest::i_isolate()->heap()->HashSeed()); | 542                                        CcTest::i_isolate()->heap()->HashSeed()); | 
| 533   i::PreParser preparser(&zone, &scanner, &ast_value_factory, stack_limit); | 543   i::PendingCompilationErrorHandler pending_error_handler; | 
|  | 544   i::PreParser preparser(&zone, &scanner, &ast_value_factory, | 
|  | 545                          &pending_error_handler, stack_limit); | 
| 534   preparser.set_allow_lazy(true); | 546   preparser.set_allow_lazy(true); | 
| 535   i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 547   i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 
| 536   CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); | 548   CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); | 
| 537 } | 549 } | 
| 538 | 550 | 
| 539 | 551 | 
| 540 void TestStreamScanner(i::Utf16CharacterStream* stream, | 552 void TestStreamScanner(i::Utf16CharacterStream* stream, | 
| 541                        i::Token::Value* expected_tokens, | 553                        i::Token::Value* expected_tokens, | 
| 542                        int skip_pos = 0,  // Zero means not skipping. | 554                        int skip_pos = 0,  // Zero means not skipping. | 
| 543                        int skip_to = 0) { | 555                        int skip_to = 0) { | 
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1263   int length = start[0]; | 1275   int length = start[0]; | 
| 1264   char* result = i::NewArray<char>(length + 1); | 1276   char* result = i::NewArray<char>(length + 1); | 
| 1265   for (int i = 0; i < length; i++) { | 1277   for (int i = 0; i < length; i++) { | 
| 1266     result[i] = start[i + 1]; | 1278     result[i] = start[i + 1]; | 
| 1267   } | 1279   } | 
| 1268   result[length] = '\0'; | 1280   result[length] = '\0'; | 
| 1269   return result; | 1281   return result; | 
| 1270 } | 1282 } | 
| 1271 | 1283 | 
| 1272 | 1284 | 
| 1273 i::Handle<i::String> FormatMessage(i::Vector<unsigned> data) { |  | 
| 1274   i::Isolate* isolate = CcTest::i_isolate(); |  | 
| 1275   int message = data[i::PreparseDataConstants::kMessageTemplatePos]; |  | 
| 1276   int arg_count = data[i::PreparseDataConstants::kMessageArgCountPos]; |  | 
| 1277   i::Handle<i::Object> arg_object; |  | 
| 1278   if (arg_count == 1) { |  | 
| 1279     // Position after text found by skipping past length field and |  | 
| 1280     // length field content words. |  | 
| 1281     const char* arg = |  | 
| 1282         ReadString(&data[i::PreparseDataConstants::kMessageArgPos]); |  | 
| 1283     arg_object = v8::Utils::OpenHandle(*v8_str(arg)); |  | 
| 1284     i::DeleteArray(arg); |  | 
| 1285   } else { |  | 
| 1286     CHECK_EQ(0, arg_count); |  | 
| 1287     arg_object = isolate->factory()->undefined_value(); |  | 
| 1288   } |  | 
| 1289 |  | 
| 1290   data.Dispose(); |  | 
| 1291   return i::MessageTemplate::FormatMessage(isolate, message, arg_object); |  | 
| 1292 } |  | 
| 1293 |  | 
| 1294 enum ParserFlag { | 1285 enum ParserFlag { | 
| 1295   kAllowLazy, | 1286   kAllowLazy, | 
| 1296   kAllowNatives, | 1287   kAllowNatives, | 
| 1297   kAllowHarmonyFunctionSent, | 1288   kAllowHarmonyFunctionSent, | 
| 1298   kAllowHarmonyAsyncAwait, | 1289   kAllowHarmonyAsyncAwait, | 
| 1299   kAllowHarmonyRestrictiveGenerators, | 1290   kAllowHarmonyRestrictiveGenerators, | 
| 1300   kAllowHarmonyTrailingCommas, | 1291   kAllowHarmonyTrailingCommas, | 
| 1301   kAllowHarmonyClassFields, | 1292   kAllowHarmonyClassFields, | 
| 1302 }; | 1293 }; | 
| 1303 | 1294 | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 1331                              bool is_module = false, | 1322                              bool is_module = false, | 
| 1332                              bool test_preparser = true) { | 1323                              bool test_preparser = true) { | 
| 1333   i::Isolate* isolate = CcTest::i_isolate(); | 1324   i::Isolate* isolate = CcTest::i_isolate(); | 
| 1334   i::Factory* factory = isolate->factory(); | 1325   i::Factory* factory = isolate->factory(); | 
| 1335 | 1326 | 
| 1336   uintptr_t stack_limit = isolate->stack_guard()->real_climit(); | 1327   uintptr_t stack_limit = isolate->stack_guard()->real_climit(); | 
| 1337   int preparser_materialized_literals = -1; | 1328   int preparser_materialized_literals = -1; | 
| 1338   int parser_materialized_literals = -2; | 1329   int parser_materialized_literals = -2; | 
| 1339 | 1330 | 
| 1340   // Preparse the data. | 1331   // Preparse the data. | 
| 1341   i::ParserLogger log; | 1332   i::PendingCompilationErrorHandler pending_error_handler; | 
| 1342   if (test_preparser) { | 1333   if (test_preparser) { | 
| 1343     i::Scanner scanner(isolate->unicode_cache()); | 1334     i::Scanner scanner(isolate->unicode_cache()); | 
| 1344     std::unique_ptr<i::Utf16CharacterStream> stream( | 1335     std::unique_ptr<i::Utf16CharacterStream> stream( | 
| 1345         i::ScannerStream::For(source)); | 1336         i::ScannerStream::For(source)); | 
| 1346     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 1337     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 1347     i::AstValueFactory ast_value_factory( | 1338     i::AstValueFactory ast_value_factory( | 
| 1348         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 1339         &zone, CcTest::i_isolate()->heap()->HashSeed()); | 
| 1349     i::PreParser preparser(&zone, &scanner, &ast_value_factory, stack_limit); | 1340     i::PreParser preparser(&zone, &scanner, &ast_value_factory, | 
|  | 1341                            &pending_error_handler, stack_limit); | 
| 1350     SetParserFlags(&preparser, flags); | 1342     SetParserFlags(&preparser, flags); | 
| 1351     scanner.Initialize(stream.get()); | 1343     scanner.Initialize(stream.get()); | 
| 1352     i::PreParser::PreParseResult result = | 1344     i::PreParser::PreParseResult result = | 
| 1353         preparser.PreParseProgram(&preparser_materialized_literals, is_module); | 1345         preparser.PreParseProgram(&preparser_materialized_literals, is_module); | 
| 1354     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 1346     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 
| 1355     i::PreParserLogger* logger = preparser.logger(); |  | 
| 1356     // Convert to complete log. |  | 
| 1357     if (logger->has_error()) { |  | 
| 1358       log.LogMessage(logger->start(), logger->end(), logger->message(), |  | 
| 1359                      logger->argument_opt(), logger->error_type()); |  | 
| 1360     } |  | 
| 1361   } | 1347   } | 
| 1362   bool preparse_error = log.HasError(); |  | 
| 1363 | 1348 | 
| 1364   // Parse the data | 1349   // Parse the data | 
| 1365   i::FunctionLiteral* function; | 1350   i::FunctionLiteral* function; | 
| 1366   { | 1351   { | 
| 1367     i::Handle<i::Script> script = factory->NewScript(source); | 1352     i::Handle<i::Script> script = factory->NewScript(source); | 
| 1368     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 1353     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 1369     i::ParseInfo info(&zone, script); | 1354     i::ParseInfo info(&zone, script); | 
| 1370     i::Parser parser(&info); | 1355     i::Parser parser(&info); | 
| 1371     SetParserFlags(&parser, flags); | 1356     SetParserFlags(&parser, flags); | 
| 1372     if (is_module) info.set_module(); | 1357     if (is_module) info.set_module(); | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 1392       v8::base::OS::Print( | 1377       v8::base::OS::Print( | 
| 1393           "Parser failed on:\n" | 1378           "Parser failed on:\n" | 
| 1394           "\t%s\n" | 1379           "\t%s\n" | 
| 1395           "with error:\n" | 1380           "with error:\n" | 
| 1396           "\t%s\n" | 1381           "\t%s\n" | 
| 1397           "However, we expected no error.", | 1382           "However, we expected no error.", | 
| 1398           source->ToCString().get(), message_string->ToCString().get()); | 1383           source->ToCString().get(), message_string->ToCString().get()); | 
| 1399       CHECK(false); | 1384       CHECK(false); | 
| 1400     } | 1385     } | 
| 1401 | 1386 | 
| 1402     if (test_preparser && !preparse_error) { | 1387     if (test_preparser && !pending_error_handler.has_pending_error()) { | 
| 1403       v8::base::OS::Print( | 1388       v8::base::OS::Print( | 
| 1404           "Parser failed on:\n" | 1389           "Parser failed on:\n" | 
| 1405           "\t%s\n" | 1390           "\t%s\n" | 
| 1406           "with error:\n" | 1391           "with error:\n" | 
| 1407           "\t%s\n" | 1392           "\t%s\n" | 
| 1408           "However, the preparser succeeded", | 1393           "However, the preparser succeeded", | 
| 1409           source->ToCString().get(), message_string->ToCString().get()); | 1394           source->ToCString().get(), message_string->ToCString().get()); | 
| 1410       CHECK(false); | 1395       CHECK(false); | 
| 1411     } | 1396     } | 
| 1412     // Check that preparser and parser produce the same error. | 1397     // Check that preparser and parser produce the same error. | 
| 1413     if (test_preparser) { | 1398     if (test_preparser) { | 
| 1414       i::Handle<i::String> preparser_message = | 1399       i::Handle<i::String> preparser_message = | 
| 1415           FormatMessage(log.ErrorMessageData()); | 1400           pending_error_handler.FormatMessage(CcTest::i_isolate()); | 
| 1416       if (!i::String::Equals(message_string, preparser_message)) { | 1401       if (!i::String::Equals(message_string, preparser_message)) { | 
| 1417         v8::base::OS::Print( | 1402         v8::base::OS::Print( | 
| 1418             "Expected parser and preparser to produce the same error on:\n" | 1403             "Expected parser and preparser to produce the same error on:\n" | 
| 1419             "\t%s\n" | 1404             "\t%s\n" | 
| 1420             "However, found the following error messages\n" | 1405             "However, found the following error messages\n" | 
| 1421             "\tparser:    %s\n" | 1406             "\tparser:    %s\n" | 
| 1422             "\tpreparser: %s\n", | 1407             "\tpreparser: %s\n", | 
| 1423             source->ToCString().get(), message_string->ToCString().get(), | 1408             source->ToCString().get(), message_string->ToCString().get(), | 
| 1424             preparser_message->ToCString().get()); | 1409             preparser_message->ToCString().get()); | 
| 1425         CHECK(false); | 1410         CHECK(false); | 
| 1426       } | 1411       } | 
| 1427     } | 1412     } | 
| 1428   } else if (test_preparser && preparse_error) { | 1413   } else if (test_preparser && pending_error_handler.has_pending_error()) { | 
| 1429     v8::base::OS::Print( | 1414     v8::base::OS::Print( | 
| 1430         "Preparser failed on:\n" | 1415         "Preparser failed on:\n" | 
| 1431         "\t%s\n" | 1416         "\t%s\n" | 
| 1432         "with error:\n" | 1417         "with error:\n" | 
| 1433         "\t%s\n" | 1418         "\t%s\n" | 
| 1434         "However, the parser succeeded", | 1419         "However, the parser succeeded", | 
| 1435         source->ToCString().get(), | 1420         source->ToCString().get(), | 
| 1436         FormatMessage(log.ErrorMessageData())->ToCString().get()); | 1421         pending_error_handler.FormatMessage(CcTest::i_isolate()) | 
|  | 1422             ->ToCString() | 
|  | 1423             .get()); | 
| 1437     CHECK(false); | 1424     CHECK(false); | 
| 1438   } else if (result == kError) { | 1425   } else if (result == kError) { | 
| 1439     v8::base::OS::Print( | 1426     v8::base::OS::Print( | 
| 1440         "Expected error on:\n" | 1427         "Expected error on:\n" | 
| 1441         "\t%s\n" | 1428         "\t%s\n" | 
| 1442         "However, parser and preparser succeeded", | 1429         "However, parser and preparser succeeded", | 
| 1443         source->ToCString().get()); | 1430         source->ToCString().get()); | 
| 1444     CHECK(false); | 1431     CHECK(false); | 
| 1445   } else if (test_preparser && | 1432   } else if (test_preparser && | 
| 1446              preparser_materialized_literals != parser_materialized_literals) { | 1433              preparser_materialized_literals != parser_materialized_literals) { | 
| (...skipping 6876 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 8323     const char* data[] = { | 8310     const char* data[] = { | 
| 8324       "const arguments = 1", | 8311       "const arguments = 1", | 
| 8325       "let arguments", | 8312       "let arguments", | 
| 8326       "var arguments", | 8313       "var arguments", | 
| 8327       NULL | 8314       NULL | 
| 8328     }; | 8315     }; | 
| 8329     // clang-format on | 8316     // clang-format on | 
| 8330     RunParserSyncTest(context_data, data, kSuccess); | 8317     RunParserSyncTest(context_data, data, kSuccess); | 
| 8331   } | 8318   } | 
| 8332 } | 8319 } | 
| OLD | NEW | 
|---|