| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 Isolate* internal_isolate = CcTest::i_isolate(); | 260 Isolate* internal_isolate = CcTest::i_isolate(); |
| 261 internal_isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "serialize"); | 261 internal_isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "serialize"); |
| 262 WriteToFile(internal_isolate, FLAG_testing_serialization_file); | 262 WriteToFile(internal_isolate, FLAG_testing_serialization_file); |
| 263 } | 263 } |
| 264 | 264 |
| 265 | 265 |
| 266 // Test that the whole heap can be serialized. | 266 // Test that the whole heap can be serialized. |
| 267 TEST(Serialize) { | 267 TEST(Serialize) { |
| 268 if (!Snapshot::HaveASnapshotToStartFrom()) { | 268 if (!Snapshot::HaveASnapshotToStartFrom()) { |
| 269 Serializer::Enable(CcTest::i_isolate()); | 269 Serializer::RequestEnable(CcTest::i_isolate()); |
| 270 v8::V8::Initialize(); | 270 v8::V8::Initialize(); |
| 271 Serialize(); | 271 Serialize(); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 | 275 |
| 276 // Test that heap serialization is non-destructive. | 276 // Test that heap serialization is non-destructive. |
| 277 TEST(SerializeTwice) { | 277 TEST(SerializeTwice) { |
| 278 if (!Snapshot::HaveASnapshotToStartFrom()) { | 278 if (!Snapshot::HaveASnapshotToStartFrom()) { |
| 279 Serializer::Enable(CcTest::i_isolate()); | 279 Serializer::RequestEnable(CcTest::i_isolate()); |
| 280 v8::V8::Initialize(); | 280 v8::V8::Initialize(); |
| 281 Serialize(); | 281 Serialize(); |
| 282 Serialize(); | 282 Serialize(); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 | 286 |
| 287 //---------------------------------------------------------------------------- | 287 //---------------------------------------------------------------------------- |
| 288 // Tests that the heap can be deserialized. | 288 // Tests that the heap can be deserialized. |
| 289 | 289 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); | 368 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); |
| 369 v8::Local<v8::Script> script = v8::Script::Compile(source); | 369 v8::Local<v8::Script> script = v8::Script::Compile(source); |
| 370 CHECK_EQ(4, script->Run()->Int32Value()); | 370 CHECK_EQ(4, script->Run()->Int32Value()); |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 | 374 |
| 375 TEST(PartialSerialization) { | 375 TEST(PartialSerialization) { |
| 376 if (!Snapshot::HaveASnapshotToStartFrom()) { | 376 if (!Snapshot::HaveASnapshotToStartFrom()) { |
| 377 Isolate* isolate = CcTest::i_isolate(); | 377 Isolate* isolate = CcTest::i_isolate(); |
| 378 Serializer::Enable(isolate); | 378 Serializer::RequestEnable(isolate); |
| 379 v8::V8::Initialize(); | 379 v8::V8::Initialize(); |
| 380 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 380 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
| 381 Heap* heap = isolate->heap(); | 381 Heap* heap = isolate->heap(); |
| 382 | 382 |
| 383 v8::Persistent<v8::Context> env; | 383 v8::Persistent<v8::Context> env; |
| 384 { | 384 { |
| 385 HandleScope scope(isolate); | 385 HandleScope scope(isolate); |
| 386 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); | 386 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); |
| 387 } | 387 } |
| 388 ASSERT(!env.IsEmpty()); | 388 ASSERT(!env.IsEmpty()); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 CHECK(root2->IsString()); | 519 CHECK(root2->IsString()); |
| 520 CHECK(*root_handle == root2); | 520 CHECK(*root_handle == root2); |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 | 524 |
| 525 | 525 |
| 526 TEST(ContextSerialization) { | 526 TEST(ContextSerialization) { |
| 527 if (!Snapshot::HaveASnapshotToStartFrom()) { | 527 if (!Snapshot::HaveASnapshotToStartFrom()) { |
| 528 Isolate* isolate = CcTest::i_isolate(); | 528 Isolate* isolate = CcTest::i_isolate(); |
| 529 Serializer::Enable(isolate); | 529 Serializer::RequestEnable(isolate); |
| 530 v8::V8::Initialize(); | 530 v8::V8::Initialize(); |
| 531 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 531 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
| 532 Heap* heap = isolate->heap(); | 532 Heap* heap = isolate->heap(); |
| 533 | 533 |
| 534 v8::Persistent<v8::Context> env; | 534 v8::Persistent<v8::Context> env; |
| 535 { | 535 { |
| 536 HandleScope scope(isolate); | 536 HandleScope scope(isolate); |
| 537 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); | 537 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); |
| 538 } | 538 } |
| 539 ASSERT(!env.IsEmpty()); | 539 ASSERT(!env.IsEmpty()); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 TEST(TestThatAlwaysFails) { | 642 TEST(TestThatAlwaysFails) { |
| 643 bool ArtificialFailure = false; | 643 bool ArtificialFailure = false; |
| 644 CHECK(ArtificialFailure); | 644 CHECK(ArtificialFailure); |
| 645 } | 645 } |
| 646 | 646 |
| 647 | 647 |
| 648 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 648 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
| 649 bool ArtificialFailure2 = false; | 649 bool ArtificialFailure2 = false; |
| 650 CHECK(ArtificialFailure2); | 650 CHECK(ArtificialFailure2); |
| 651 } | 651 } |
| OLD | NEW |