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

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

Issue 724053004: Revert "Soft fail for invalid cache data." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month 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-api.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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); 447 i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
448 i::CompleteParserRecorder log; 448 i::CompleteParserRecorder log;
449 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 449 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
450 scanner.Initialize(&stream); 450 scanner.Initialize(&stream);
451 i::PreParser preparser(&scanner, &log, 451 i::PreParser preparser(&scanner, &log,
452 CcTest::i_isolate()->stack_guard()->real_climit()); 452 CcTest::i_isolate()->stack_guard()->real_climit());
453 preparser.set_allow_lazy(true); 453 preparser.set_allow_lazy(true);
454 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 454 i::PreParser::PreParseResult result = preparser.PreParseProgram();
455 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 455 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
456 i::ScriptData* sd = log.GetScriptData(); 456 i::ScriptData* sd = log.GetScriptData();
457 i::ParseData* pd = i::ParseData::FromCachedData(sd); 457 i::ParseData pd(sd);
458 pd->Initialize(); 458 pd.Initialize();
459 459
460 int first_function = 460 int first_function =
461 static_cast<int>(strstr(program, "function") - program); 461 static_cast<int>(strstr(program, "function") - program);
462 int first_lbrace = first_function + i::StrLength("function () "); 462 int first_lbrace = first_function + i::StrLength("function () ");
463 CHECK_EQ('{', program[first_lbrace]); 463 CHECK_EQ('{', program[first_lbrace]);
464 i::FunctionEntry entry1 = pd->GetFunctionEntry(first_lbrace); 464 i::FunctionEntry entry1 = pd.GetFunctionEntry(first_lbrace);
465 CHECK(!entry1.is_valid()); 465 CHECK(!entry1.is_valid());
466 466
467 int second_function = 467 int second_function =
468 static_cast<int>(strstr(program + first_lbrace, "function") - program); 468 static_cast<int>(strstr(program + first_lbrace, "function") - program);
469 int second_lbrace = 469 int second_lbrace =
470 second_function + i::StrLength("function () "); 470 second_function + i::StrLength("function () ");
471 CHECK_EQ('{', program[second_lbrace]); 471 CHECK_EQ('{', program[second_lbrace]);
472 i::FunctionEntry entry2 = pd->GetFunctionEntry(second_lbrace); 472 i::FunctionEntry entry2 = pd.GetFunctionEntry(second_lbrace);
473 CHECK(entry2.is_valid()); 473 CHECK(entry2.is_valid());
474 CHECK_EQ('}', program[entry2.end_pos() - 1]); 474 CHECK_EQ('}', program[entry2.end_pos() - 1]);
475 delete sd; 475 delete sd;
476 delete pd;
477 } 476 }
478 477
479 478
480 TEST(PreParseOverflow) { 479 TEST(PreParseOverflow) {
481 v8::V8::Initialize(); 480 v8::V8::Initialize();
482 481
483 CcTest::i_isolate()->stack_guard()->SetStackLimit( 482 CcTest::i_isolate()->stack_guard()->SetStackLimit(
484 i::GetCurrentStackPosition() - 128 * 1024); 483 i::GetCurrentStackPosition() - 128 * 1024);
485 484
486 size_t kProgramSize = 1024 * 1024; 485 size_t kProgramSize = 1024 * 1024;
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 for (int i = 0; test_cases[i].program; i++) { 2444 for (int i = 0; test_cases[i].program; i++) {
2446 const char* program = test_cases[i].program; 2445 const char* program = test_cases[i].program;
2447 i::Factory* factory = CcTest::i_isolate()->factory(); 2446 i::Factory* factory = CcTest::i_isolate()->factory();
2448 i::Handle<i::String> source = 2447 i::Handle<i::String> source =
2449 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); 2448 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked();
2450 i::Handle<i::Script> script = factory->NewScript(source); 2449 i::Handle<i::Script> script = factory->NewScript(source);
2451 i::CompilationInfoWithZone info(script); 2450 i::CompilationInfoWithZone info(script);
2452 i::ScriptData* sd = NULL; 2451 i::ScriptData* sd = NULL;
2453 info.SetCachedData(&sd, v8::ScriptCompiler::kProduceParserCache); 2452 info.SetCachedData(&sd, v8::ScriptCompiler::kProduceParserCache);
2454 i::Parser::Parse(&info, true); 2453 i::Parser::Parse(&info, true);
2455 i::ParseData* pd = i::ParseData::FromCachedData(sd); 2454 i::ParseData pd(sd);
2456 2455
2457 if (pd->FunctionCount() != test_cases[i].functions) { 2456 if (pd.FunctionCount() != test_cases[i].functions) {
2458 v8::base::OS::Print( 2457 v8::base::OS::Print(
2459 "Expected preparse data for program:\n" 2458 "Expected preparse data for program:\n"
2460 "\t%s\n" 2459 "\t%s\n"
2461 "to contain %d functions, however, received %d functions.\n", 2460 "to contain %d functions, however, received %d functions.\n",
2462 program, test_cases[i].functions, pd->FunctionCount()); 2461 program, test_cases[i].functions, pd.FunctionCount());
2463 CHECK(false); 2462 CHECK(false);
2464 } 2463 }
2465 delete sd; 2464 delete sd;
2466 delete pd;
2467 } 2465 }
2468 } 2466 }
2469 2467
2470 2468
2471 TEST(FunctionDeclaresItselfStrict) { 2469 TEST(FunctionDeclaresItselfStrict) {
2472 // Tests that we produce the right kinds of errors when a function declares 2470 // Tests that we produce the right kinds of errors when a function declares
2473 // itself strict (we cannot produce there errors as soon as we see the 2471 // itself strict (we cannot produce there errors as soon as we see the
2474 // offending identifiers, because we don't know at that point whether the 2472 // offending identifiers, because we don't know at that point whether the
2475 // function is strict or not). 2473 // function is strict or not).
2476 const char* context_data[][2] = { 2474 const char* context_data[][2] = {
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
4313 const char* data[] = { 4311 const char* data[] = {
4314 "var foob\\u123r = 0;", 4312 "var foob\\u123r = 0;",
4315 "var \\u123roo = 0;", 4313 "var \\u123roo = 0;",
4316 "\"foob\\u123rr\"", 4314 "\"foob\\u123rr\"",
4317 // No escapes allowed in regexp flags 4315 // No escapes allowed in regexp flags
4318 "/regex/\\u0069g", 4316 "/regex/\\u0069g",
4319 "/regex/\\u006g", 4317 "/regex/\\u006g",
4320 NULL}; 4318 NULL};
4321 RunParserSyncTest(context_data, data, kError); 4319 RunParserSyncTest(context_data, data, kError);
4322 } 4320 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698