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

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

Issue 317633003: Revert "Support external startup data in V8." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/snapshot-source-sink.cc ('k') | tools/concatenate-files.py » ('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 2007-2010 the V8 project authors. All rights reserved. 1 // Copyright 2007-2010 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 v8::V8::Initialize(); 276 v8::V8::Initialize();
277 Serialize(); 277 Serialize();
278 Serialize(); 278 Serialize();
279 } 279 }
280 } 280 }
281 281
282 282
283 //---------------------------------------------------------------------------- 283 //----------------------------------------------------------------------------
284 // Tests that the heap can be deserialized. 284 // Tests that the heap can be deserialized.
285 285
286 286 static void Deserialize() {
287 static void ReserveSpaceForSnapshot(Deserializer* deserializer, 287 CHECK(Snapshot::Initialize(FLAG_testing_serialization_file));
288 const char* file_name) {
289 int file_name_length = StrLength(file_name) + 10;
290 Vector<char> name = Vector<char>::New(file_name_length + 1);
291 OS::SNPrintF(name, "%s.size", file_name);
292 FILE* fp = OS::FOpen(name.start(), "r");
293 name.Dispose();
294 int new_size, pointer_size, data_size, code_size, map_size, cell_size,
295 property_cell_size;
296 #ifdef _MSC_VER
297 // Avoid warning about unsafe fscanf from MSVC.
298 // Please note that this is only fine if %c and %s are not being used.
299 #define fscanf fscanf_s
300 #endif
301 CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size));
302 CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size));
303 CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size));
304 CHECK_EQ(1, fscanf(fp, "code %d\n", &code_size));
305 CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size));
306 CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size));
307 CHECK_EQ(1, fscanf(fp, "property cell %d\n", &property_cell_size));
308 #ifdef _MSC_VER
309 #undef fscanf
310 #endif
311 fclose(fp);
312 deserializer->set_reservation(NEW_SPACE, new_size);
313 deserializer->set_reservation(OLD_POINTER_SPACE, pointer_size);
314 deserializer->set_reservation(OLD_DATA_SPACE, data_size);
315 deserializer->set_reservation(CODE_SPACE, code_size);
316 deserializer->set_reservation(MAP_SPACE, map_size);
317 deserializer->set_reservation(CELL_SPACE, cell_size);
318 deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size);
319 } 288 }
320 289
321 290
322 bool InitializeFromFile(const char* snapshot_file) {
323 int len;
324 byte* str = ReadBytes(snapshot_file, &len);
325 if (!str) return false;
326 bool success;
327 {
328 SnapshotByteSource source(str, len);
329 Deserializer deserializer(&source);
330 ReserveSpaceForSnapshot(&deserializer, snapshot_file);
331 success = V8::Initialize(&deserializer);
332 }
333 DeleteArray(str);
334 return success;
335 }
336
337
338 static void Deserialize() {
339 CHECK(InitializeFromFile(FLAG_testing_serialization_file));
340 }
341
342
343 static void SanityCheck() { 291 static void SanityCheck() {
344 Isolate* isolate = CcTest::i_isolate(); 292 Isolate* isolate = CcTest::i_isolate();
345 v8::HandleScope scope(CcTest::isolate()); 293 v8::HandleScope scope(CcTest::isolate());
346 #ifdef VERIFY_HEAP 294 #ifdef VERIFY_HEAP
347 CcTest::heap()->Verify(); 295 CcTest::heap()->Verify();
348 #endif 296 #endif
349 CHECK(isolate->global_object()->IsJSObject()); 297 CHECK(isolate->global_object()->IsJSObject());
350 CHECK(isolate->native_context()->IsContext()); 298 CHECK(isolate->native_context()->IsContext());
351 CHECK(CcTest::heap()->string_table()->IsStringTable()); 299 CHECK(CcTest::heap()->string_table()->IsStringTable());
352 isolate->factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); 300 isolate->factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), 436 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
489 startup_serializer.CurrentAllocationAddress(CODE_SPACE), 437 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
490 startup_serializer.CurrentAllocationAddress(MAP_SPACE), 438 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
491 startup_serializer.CurrentAllocationAddress(CELL_SPACE), 439 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
492 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); 440 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
493 startup_name.Dispose(); 441 startup_name.Dispose();
494 } 442 }
495 } 443 }
496 444
497 445
446 static void ReserveSpaceForSnapshot(Deserializer* deserializer,
447 const char* file_name) {
448 int file_name_length = StrLength(file_name) + 10;
449 Vector<char> name = Vector<char>::New(file_name_length + 1);
450 OS::SNPrintF(name, "%s.size", file_name);
451 FILE* fp = OS::FOpen(name.start(), "r");
452 name.Dispose();
453 int new_size, pointer_size, data_size, code_size, map_size, cell_size,
454 property_cell_size;
455 #ifdef _MSC_VER
456 // Avoid warning about unsafe fscanf from MSVC.
457 // Please note that this is only fine if %c and %s are not being used.
458 #define fscanf fscanf_s
459 #endif
460 CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size));
461 CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size));
462 CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size));
463 CHECK_EQ(1, fscanf(fp, "code %d\n", &code_size));
464 CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size));
465 CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size));
466 CHECK_EQ(1, fscanf(fp, "property cell %d\n", &property_cell_size));
467 #ifdef _MSC_VER
468 #undef fscanf
469 #endif
470 fclose(fp);
471 deserializer->set_reservation(NEW_SPACE, new_size);
472 deserializer->set_reservation(OLD_POINTER_SPACE, pointer_size);
473 deserializer->set_reservation(OLD_DATA_SPACE, data_size);
474 deserializer->set_reservation(CODE_SPACE, code_size);
475 deserializer->set_reservation(MAP_SPACE, map_size);
476 deserializer->set_reservation(CELL_SPACE, cell_size);
477 deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size);
478 }
479
480
498 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { 481 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
499 if (!Snapshot::HaveASnapshotToStartFrom()) { 482 if (!Snapshot::IsEnabled()) {
500 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 483 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
501 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 484 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
502 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 485 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
503 486
504 CHECK(InitializeFromFile(startup_name.start())); 487 CHECK(Snapshot::Initialize(startup_name.start()));
505 startup_name.Dispose(); 488 startup_name.Dispose();
506 489
507 const char* file_name = FLAG_testing_serialization_file; 490 const char* file_name = FLAG_testing_serialization_file;
508 491
509 int snapshot_size = 0; 492 int snapshot_size = 0;
510 byte* snapshot = ReadBytes(file_name, &snapshot_size); 493 byte* snapshot = ReadBytes(file_name, &snapshot_size);
511 494
512 Isolate* isolate = CcTest::i_isolate(); 495 Isolate* isolate = CcTest::i_isolate();
513 Object* root; 496 Object* root;
514 { 497 {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 589 }
607 } 590 }
608 591
609 592
610 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { 593 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
611 if (!Snapshot::HaveASnapshotToStartFrom()) { 594 if (!Snapshot::HaveASnapshotToStartFrom()) {
612 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 595 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
613 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 596 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
614 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 597 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
615 598
616 CHECK(InitializeFromFile(startup_name.start())); 599 CHECK(Snapshot::Initialize(startup_name.start()));
617 startup_name.Dispose(); 600 startup_name.Dispose();
618 601
619 const char* file_name = FLAG_testing_serialization_file; 602 const char* file_name = FLAG_testing_serialization_file;
620 603
621 int snapshot_size = 0; 604 int snapshot_size = 0;
622 byte* snapshot = ReadBytes(file_name, &snapshot_size); 605 byte* snapshot = ReadBytes(file_name, &snapshot_size);
623 606
624 Isolate* isolate = CcTest::i_isolate(); 607 Isolate* isolate = CcTest::i_isolate();
625 Object* root; 608 Object* root;
626 { 609 {
(...skipping 27 matching lines...) Expand all
654 TEST(TestThatAlwaysFails) { 637 TEST(TestThatAlwaysFails) {
655 bool ArtificialFailure = false; 638 bool ArtificialFailure = false;
656 CHECK(ArtificialFailure); 639 CHECK(ArtificialFailure);
657 } 640 }
658 641
659 642
660 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 643 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
661 bool ArtificialFailure2 = false; 644 bool ArtificialFailure2 = false;
662 CHECK(ArtificialFailure2); 645 CHECK(ArtificialFailure2);
663 } 646 }
OLDNEW
« no previous file with comments | « src/snapshot-source-sink.cc ('k') | tools/concatenate-files.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698