| 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 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1300 | 1300 | 
| 1301 void TestParserSyncWithFlags(i::Handle<i::String> source, | 1301 void TestParserSyncWithFlags(i::Handle<i::String> source, | 
| 1302                              i::EnumSet<ParserFlag> flags, | 1302                              i::EnumSet<ParserFlag> flags, | 
| 1303                              ParserSyncTestResult result, | 1303                              ParserSyncTestResult result, | 
| 1304                              bool is_module = false, bool test_preparser = true, | 1304                              bool is_module = false, bool test_preparser = true, | 
| 1305                              bool ignore_error_msg = false) { | 1305                              bool ignore_error_msg = false) { | 
| 1306   i::Isolate* isolate = CcTest::i_isolate(); | 1306   i::Isolate* isolate = CcTest::i_isolate(); | 
| 1307   i::Factory* factory = isolate->factory(); | 1307   i::Factory* factory = isolate->factory(); | 
| 1308 | 1308 | 
| 1309   uintptr_t stack_limit = isolate->stack_guard()->real_climit(); | 1309   uintptr_t stack_limit = isolate->stack_guard()->real_climit(); | 
| 1310   int preparser_materialized_literals = -1; |  | 
| 1311   int parser_materialized_literals = -2; |  | 
| 1312 | 1310 | 
| 1313   // Preparse the data. | 1311   // Preparse the data. | 
| 1314   i::PendingCompilationErrorHandler pending_error_handler; | 1312   i::PendingCompilationErrorHandler pending_error_handler; | 
| 1315   if (test_preparser) { | 1313   if (test_preparser) { | 
| 1316     i::Scanner scanner(isolate->unicode_cache()); | 1314     i::Scanner scanner(isolate->unicode_cache()); | 
| 1317     std::unique_ptr<i::Utf16CharacterStream> stream( | 1315     std::unique_ptr<i::Utf16CharacterStream> stream( | 
| 1318         i::ScannerStream::For(source)); | 1316         i::ScannerStream::For(source)); | 
| 1319     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 1317     i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); | 
| 1320     i::AstValueFactory ast_value_factory( | 1318     i::AstValueFactory ast_value_factory( | 
| 1321         &zone, CcTest::i_isolate()->ast_string_constants(), | 1319         &zone, CcTest::i_isolate()->ast_string_constants(), | 
| 1322         CcTest::i_isolate()->heap()->HashSeed()); | 1320         CcTest::i_isolate()->heap()->HashSeed()); | 
| 1323     i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, | 1321     i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, | 
| 1324                            &pending_error_handler, | 1322                            &pending_error_handler, | 
| 1325                            isolate->counters()->runtime_call_stats()); | 1323                            isolate->counters()->runtime_call_stats()); | 
| 1326     SetParserFlags(&preparser, flags); | 1324     SetParserFlags(&preparser, flags); | 
| 1327     scanner.Initialize(stream.get()); | 1325     scanner.Initialize(stream.get()); | 
| 1328     i::PreParser::PreParseResult result = | 1326     i::PreParser::PreParseResult result = preparser.PreParseProgram(is_module); | 
| 1329         preparser.PreParseProgram(&preparser_materialized_literals, is_module); |  | 
| 1330     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 1327     CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 
| 1331   } | 1328   } | 
| 1332 | 1329 | 
| 1333   // Parse the data | 1330   // Parse the data | 
| 1334   i::FunctionLiteral* function; | 1331   i::FunctionLiteral* function; | 
| 1335   { | 1332   { | 
| 1336     i::Handle<i::Script> script = factory->NewScript(source); | 1333     i::Handle<i::Script> script = factory->NewScript(source); | 
| 1337     i::ParseInfo info(script); | 1334     i::ParseInfo info(script); | 
| 1338     info.set_allow_lazy_parsing(flags.Contains(kAllowLazy)); | 1335     info.set_allow_lazy_parsing(flags.Contains(kAllowLazy)); | 
| 1339     SetGlobalFlags(flags); | 1336     SetGlobalFlags(flags); | 
| 1340     if (is_module) info.set_module(); | 1337     if (is_module) info.set_module(); | 
| 1341     i::parsing::ParseProgram(&info); | 1338     i::parsing::ParseProgram(&info); | 
| 1342     function = info.literal(); | 1339     function = info.literal(); | 
| 1343     if (function) { |  | 
| 1344       parser_materialized_literals = function->materialized_literal_count(); |  | 
| 1345     } |  | 
| 1346   } | 1340   } | 
| 1347 | 1341 | 
| 1348   // Check that preparsing fails iff parsing fails. | 1342   // Check that preparsing fails iff parsing fails. | 
| 1349   if (function == NULL) { | 1343   if (function == NULL) { | 
| 1350     // Extract exception from the parser. | 1344     // Extract exception from the parser. | 
| 1351     CHECK(isolate->has_pending_exception()); | 1345     CHECK(isolate->has_pending_exception()); | 
| 1352     i::Handle<i::JSObject> exception_handle( | 1346     i::Handle<i::JSObject> exception_handle( | 
| 1353         i::JSObject::cast(isolate->pending_exception())); | 1347         i::JSObject::cast(isolate->pending_exception())); | 
| 1354     i::Handle<i::String> message_string = i::Handle<i::String>::cast( | 1348     i::Handle<i::String> message_string = i::Handle<i::String>::cast( | 
| 1355         i::JSReceiver::GetProperty(isolate, exception_handle, "message") | 1349         i::JSReceiver::GetProperty(isolate, exception_handle, "message") | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1405             ->ToCString() | 1399             ->ToCString() | 
| 1406             .get()); | 1400             .get()); | 
| 1407     CHECK(false); | 1401     CHECK(false); | 
| 1408   } else if (result == kError) { | 1402   } else if (result == kError) { | 
| 1409     v8::base::OS::Print( | 1403     v8::base::OS::Print( | 
| 1410         "Expected error on:\n" | 1404         "Expected error on:\n" | 
| 1411         "\t%s\n" | 1405         "\t%s\n" | 
| 1412         "However, parser and preparser succeeded", | 1406         "However, parser and preparser succeeded", | 
| 1413         source->ToCString().get()); | 1407         source->ToCString().get()); | 
| 1414     CHECK(false); | 1408     CHECK(false); | 
| 1415   } else if (test_preparser && |  | 
| 1416              preparser_materialized_literals != parser_materialized_literals) { |  | 
| 1417     v8::base::OS::Print( |  | 
| 1418         "Preparser materialized literals (%d) differ from Parser materialized " |  | 
| 1419         "literals (%d) on:\n" |  | 
| 1420         "\t%s\n" |  | 
| 1421         "However, parser and preparser succeeded", |  | 
| 1422         preparser_materialized_literals, parser_materialized_literals, |  | 
| 1423         source->ToCString().get()); |  | 
| 1424     CHECK(false); |  | 
| 1425   } | 1409   } | 
| 1426 } | 1410 } | 
| 1427 | 1411 | 
| 1428 void TestParserSync(const char* source, const ParserFlag* varying_flags, | 1412 void TestParserSync(const char* source, const ParserFlag* varying_flags, | 
| 1429                     size_t varying_flags_length, | 1413                     size_t varying_flags_length, | 
| 1430                     ParserSyncTestResult result = kSuccessOrError, | 1414                     ParserSyncTestResult result = kSuccessOrError, | 
| 1431                     const ParserFlag* always_true_flags = NULL, | 1415                     const ParserFlag* always_true_flags = NULL, | 
| 1432                     size_t always_true_flags_length = 0, | 1416                     size_t always_true_flags_length = 0, | 
| 1433                     const ParserFlag* always_false_flags = NULL, | 1417                     const ParserFlag* always_false_flags = NULL, | 
| 1434                     size_t always_false_flags_length = 0, | 1418                     size_t always_false_flags_length = 0, | 
| (...skipping 8024 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 9459                                   "function l\u0065t() { }", | 9443                                   "function l\u0065t() { }", | 
| 9460                                   "(function l\u0065t() { })", | 9444                                   "(function l\u0065t() { })", | 
| 9461                                   "async function l\u0065t() { }", | 9445                                   "async function l\u0065t() { }", | 
| 9462                                   "(async function l\u0065t() { })", | 9446                                   "(async function l\u0065t() { })", | 
| 9463                                   "l\u0065t => 42", | 9447                                   "l\u0065t => 42", | 
| 9464                                   "async l\u0065t => 42", | 9448                                   "async l\u0065t => 42", | 
| 9465                                   NULL}; | 9449                                   NULL}; | 
| 9466 | 9450 | 
| 9467   RunParserSyncTest(context_data, statement_data, kSuccess); | 9451   RunParserSyncTest(context_data, statement_data, kSuccess); | 
| 9468 } | 9452 } | 
| OLD | NEW | 
|---|