| OLD | NEW |
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void FileByteSink::WriteSpaceUsed( | 203 void FileByteSink::WriteSpaceUsed( |
| 204 int new_space_used, | 204 int new_space_used, |
| 205 int pointer_space_used, | 205 int pointer_space_used, |
| 206 int data_space_used, | 206 int data_space_used, |
| 207 int code_space_used, | 207 int code_space_used, |
| 208 int map_space_used, | 208 int map_space_used, |
| 209 int cell_space_used, | 209 int cell_space_used, |
| 210 int property_cell_space_used) { | 210 int property_cell_space_used) { |
| 211 int file_name_length = StrLength(file_name_) + 10; | 211 int file_name_length = StrLength(file_name_) + 10; |
| 212 Vector<char> name = Vector<char>::New(file_name_length + 1); | 212 Vector<char> name = Vector<char>::New(file_name_length + 1); |
| 213 OS::SNPrintF(name, "%s.size", file_name_); | 213 SNPrintF(name, "%s.size", file_name_); |
| 214 FILE* fp = OS::FOpen(name.start(), "w"); | 214 FILE* fp = OS::FOpen(name.start(), "w"); |
| 215 name.Dispose(); | 215 name.Dispose(); |
| 216 fprintf(fp, "new %d\n", new_space_used); | 216 fprintf(fp, "new %d\n", new_space_used); |
| 217 fprintf(fp, "pointer %d\n", pointer_space_used); | 217 fprintf(fp, "pointer %d\n", pointer_space_used); |
| 218 fprintf(fp, "data %d\n", data_space_used); | 218 fprintf(fp, "data %d\n", data_space_used); |
| 219 fprintf(fp, "code %d\n", code_space_used); | 219 fprintf(fp, "code %d\n", code_space_used); |
| 220 fprintf(fp, "map %d\n", map_space_used); | 220 fprintf(fp, "map %d\n", map_space_used); |
| 221 fprintf(fp, "cell %d\n", cell_space_used); | 221 fprintf(fp, "cell %d\n", cell_space_used); |
| 222 fprintf(fp, "property cell %d\n", property_cell_space_used); | 222 fprintf(fp, "property cell %d\n", property_cell_space_used); |
| 223 fclose(fp); | 223 fclose(fp); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 Object* raw_foo; | 397 Object* raw_foo; |
| 398 { | 398 { |
| 399 v8::HandleScope handle_scope(v8_isolate); | 399 v8::HandleScope handle_scope(v8_isolate); |
| 400 v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo"); | 400 v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo"); |
| 401 ASSERT(!foo.IsEmpty()); | 401 ASSERT(!foo.IsEmpty()); |
| 402 raw_foo = *(v8::Utils::OpenHandle(*foo)); | 402 raw_foo = *(v8::Utils::OpenHandle(*foo)); |
| 403 } | 403 } |
| 404 | 404 |
| 405 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 405 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 406 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 406 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 407 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 407 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 408 | 408 |
| 409 { | 409 { |
| 410 v8::HandleScope handle_scope(v8_isolate); | 410 v8::HandleScope handle_scope(v8_isolate); |
| 411 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 411 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
| 412 } | 412 } |
| 413 env.Reset(); | 413 env.Reset(); |
| 414 | 414 |
| 415 FileByteSink startup_sink(startup_name.start()); | 415 FileByteSink startup_sink(startup_name.start()); |
| 416 StartupSerializer startup_serializer(isolate, &startup_sink); | 416 StartupSerializer startup_serializer(isolate, &startup_sink); |
| 417 startup_serializer.SerializeStrongReferences(); | 417 startup_serializer.SerializeStrongReferences(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 440 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); | 440 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); |
| 441 startup_name.Dispose(); | 441 startup_name.Dispose(); |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 | 445 |
| 446 static void ReserveSpaceForSnapshot(Deserializer* deserializer, | 446 static void ReserveSpaceForSnapshot(Deserializer* deserializer, |
| 447 const char* file_name) { | 447 const char* file_name) { |
| 448 int file_name_length = StrLength(file_name) + 10; | 448 int file_name_length = StrLength(file_name) + 10; |
| 449 Vector<char> name = Vector<char>::New(file_name_length + 1); | 449 Vector<char> name = Vector<char>::New(file_name_length + 1); |
| 450 OS::SNPrintF(name, "%s.size", file_name); | 450 SNPrintF(name, "%s.size", file_name); |
| 451 FILE* fp = OS::FOpen(name.start(), "r"); | 451 FILE* fp = OS::FOpen(name.start(), "r"); |
| 452 name.Dispose(); | 452 name.Dispose(); |
| 453 int new_size, pointer_size, data_size, code_size, map_size, cell_size, | 453 int new_size, pointer_size, data_size, code_size, map_size, cell_size, |
| 454 property_cell_size; | 454 property_cell_size; |
| 455 #ifdef _MSC_VER | 455 #ifdef _MSC_VER |
| 456 // Avoid warning about unsafe fscanf from MSVC. | 456 // Avoid warning about unsafe fscanf from MSVC. |
| 457 // Please note that this is only fine if %c and %s are not being used. | 457 // Please note that this is only fine if %c and %s are not being used. |
| 458 #define fscanf fscanf_s | 458 #define fscanf fscanf_s |
| 459 #endif | 459 #endif |
| 460 CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size)); | 460 CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 475 deserializer->set_reservation(MAP_SPACE, map_size); | 475 deserializer->set_reservation(MAP_SPACE, map_size); |
| 476 deserializer->set_reservation(CELL_SPACE, cell_size); | 476 deserializer->set_reservation(CELL_SPACE, cell_size); |
| 477 deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size); | 477 deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size); |
| 478 } | 478 } |
| 479 | 479 |
| 480 | 480 |
| 481 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { | 481 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { |
| 482 if (!Snapshot::IsEnabled()) { | 482 if (!Snapshot::IsEnabled()) { |
| 483 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 483 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 484 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 484 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 485 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 485 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 486 | 486 |
| 487 CHECK(Snapshot::Initialize(startup_name.start())); | 487 CHECK(Snapshot::Initialize(startup_name.start())); |
| 488 startup_name.Dispose(); | 488 startup_name.Dispose(); |
| 489 | 489 |
| 490 const char* file_name = FLAG_testing_serialization_file; | 490 const char* file_name = FLAG_testing_serialization_file; |
| 491 | 491 |
| 492 int snapshot_size = 0; | 492 int snapshot_size = 0; |
| 493 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 493 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 494 | 494 |
| 495 Isolate* isolate = CcTest::i_isolate(); | 495 Isolate* isolate = CcTest::i_isolate(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 541 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
| 542 isolate->bootstrapper()->NativesSourceLookup(i); | 542 isolate->bootstrapper()->NativesSourceLookup(i); |
| 543 } | 543 } |
| 544 } | 544 } |
| 545 // If we don't do this then we end up with a stray root pointing at the | 545 // If we don't do this then we end up with a stray root pointing at the |
| 546 // context even after we have disposed of env. | 546 // context even after we have disposed of env. |
| 547 heap->CollectAllGarbage(Heap::kNoGCFlags); | 547 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 548 | 548 |
| 549 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 549 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 550 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 550 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 551 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 551 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 552 | 552 |
| 553 { | 553 { |
| 554 v8::HandleScope handle_scope(v8_isolate); | 554 v8::HandleScope handle_scope(v8_isolate); |
| 555 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); | 555 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); |
| 556 } | 556 } |
| 557 | 557 |
| 558 i::Object* raw_context = *v8::Utils::OpenPersistent(env); | 558 i::Object* raw_context = *v8::Utils::OpenPersistent(env); |
| 559 | 559 |
| 560 env.Reset(); | 560 env.Reset(); |
| 561 | 561 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 587 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); | 587 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); |
| 588 startup_name.Dispose(); | 588 startup_name.Dispose(); |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 | 591 |
| 592 | 592 |
| 593 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { | 593 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { |
| 594 if (!Snapshot::HaveASnapshotToStartFrom()) { | 594 if (!Snapshot::HaveASnapshotToStartFrom()) { |
| 595 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 595 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 596 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 596 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 597 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 597 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 598 | 598 |
| 599 CHECK(Snapshot::Initialize(startup_name.start())); | 599 CHECK(Snapshot::Initialize(startup_name.start())); |
| 600 startup_name.Dispose(); | 600 startup_name.Dispose(); |
| 601 | 601 |
| 602 const char* file_name = FLAG_testing_serialization_file; | 602 const char* file_name = FLAG_testing_serialization_file; |
| 603 | 603 |
| 604 int snapshot_size = 0; | 604 int snapshot_size = 0; |
| 605 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 605 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 606 | 606 |
| 607 Isolate* isolate = CcTest::i_isolate(); | 607 Isolate* isolate = CcTest::i_isolate(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 637 TEST(TestThatAlwaysFails) { | 637 TEST(TestThatAlwaysFails) { |
| 638 bool ArtificialFailure = false; | 638 bool ArtificialFailure = false; |
| 639 CHECK(ArtificialFailure); | 639 CHECK(ArtificialFailure); |
| 640 } | 640 } |
| 641 | 641 |
| 642 | 642 |
| 643 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 643 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
| 644 bool ArtificialFailure2 = false; | 644 bool ArtificialFailure2 = false; |
| 645 CHECK(ArtificialFailure2); | 645 CHECK(ArtificialFailure2); |
| 646 } | 646 } |
| OLD | NEW |