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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 v8::Local<v8::Script> script = v8::Script::Compile(source); | 357 v8::Local<v8::Script> script = v8::Script::Compile(source); |
358 CHECK_EQ(4, script->Run()->Int32Value()); | 358 CHECK_EQ(4, script->Run()->Int32Value()); |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 | 362 |
363 TEST(PartialSerialization) { | 363 TEST(PartialSerialization) { |
364 if (!Snapshot::HaveASnapshotToStartFrom()) { | 364 if (!Snapshot::HaveASnapshotToStartFrom()) { |
365 Serializer::Enable(); | 365 Serializer::Enable(); |
366 v8::V8::Initialize(); | 366 v8::V8::Initialize(); |
| 367 Isolate* isolate = Isolate::Current(); |
| 368 Heap* heap = isolate->heap(); |
367 | 369 |
368 v8::Persistent<v8::Context> env = v8::Context::New(); | 370 v8::Persistent<v8::Context> env = v8::Context::New(); |
369 ASSERT(!env.IsEmpty()); | 371 ASSERT(!env.IsEmpty()); |
370 env->Enter(); | 372 env->Enter(); |
371 // Make sure all builtin scripts are cached. | 373 // Make sure all builtin scripts are cached. |
372 { HandleScope scope; | 374 { HandleScope scope(isolate); |
373 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 375 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
374 Isolate::Current()->bootstrapper()->NativesSourceLookup(i); | 376 isolate->bootstrapper()->NativesSourceLookup(i); |
375 } | 377 } |
376 } | 378 } |
377 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 379 heap->CollectAllGarbage(Heap::kNoGCFlags); |
378 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 380 heap->CollectAllGarbage(Heap::kNoGCFlags); |
379 | 381 |
380 Object* raw_foo; | 382 Object* raw_foo; |
381 { | 383 { |
382 v8::HandleScope handle_scope; | 384 v8::HandleScope handle_scope; |
383 v8::Local<v8::String> foo = v8::String::New("foo"); | 385 v8::Local<v8::String> foo = v8::String::New("foo"); |
384 ASSERT(!foo.IsEmpty()); | 386 ASSERT(!foo.IsEmpty()); |
385 raw_foo = *(v8::Utils::OpenHandle(*foo)); | 387 raw_foo = *(v8::Utils::OpenHandle(*foo)); |
386 } | 388 } |
387 | 389 |
388 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 390 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 CHECK(*root_handle == root2); | 491 CHECK(*root_handle == root2); |
490 } | 492 } |
491 } | 493 } |
492 } | 494 } |
493 | 495 |
494 | 496 |
495 TEST(ContextSerialization) { | 497 TEST(ContextSerialization) { |
496 if (!Snapshot::HaveASnapshotToStartFrom()) { | 498 if (!Snapshot::HaveASnapshotToStartFrom()) { |
497 Serializer::Enable(); | 499 Serializer::Enable(); |
498 v8::V8::Initialize(); | 500 v8::V8::Initialize(); |
| 501 Isolate* isolate = Isolate::Current(); |
| 502 Heap* heap = isolate->heap(); |
499 | 503 |
500 v8::Persistent<v8::Context> env = v8::Context::New(); | 504 v8::Persistent<v8::Context> env = v8::Context::New(); |
501 ASSERT(!env.IsEmpty()); | 505 ASSERT(!env.IsEmpty()); |
502 env->Enter(); | 506 env->Enter(); |
503 // Make sure all builtin scripts are cached. | 507 // Make sure all builtin scripts are cached. |
504 { HandleScope scope; | 508 { HandleScope scope(isolate); |
505 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 509 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
506 Isolate::Current()->bootstrapper()->NativesSourceLookup(i); | 510 isolate->bootstrapper()->NativesSourceLookup(i); |
507 } | 511 } |
508 } | 512 } |
509 // If we don't do this then we end up with a stray root pointing at the | 513 // If we don't do this then we end up with a stray root pointing at the |
510 // context even after we have disposed of env. | 514 // context even after we have disposed of env. |
511 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 515 heap->CollectAllGarbage(Heap::kNoGCFlags); |
512 | 516 |
513 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 517 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
514 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 518 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
515 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 519 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
516 | 520 |
517 env->Exit(); | 521 env->Exit(); |
518 | 522 |
519 Object* raw_context = *(v8::Utils::OpenHandle(*env)); | 523 Object* raw_context = *(v8::Utils::OpenHandle(*env)); |
520 | 524 |
521 env.Dispose(env->GetIsolate()); | 525 env.Dispose(env->GetIsolate()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 TEST(TestThatAlwaysFails) { | 599 TEST(TestThatAlwaysFails) { |
596 bool ArtificialFailure = false; | 600 bool ArtificialFailure = false; |
597 CHECK(ArtificialFailure); | 601 CHECK(ArtificialFailure); |
598 } | 602 } |
599 | 603 |
600 | 604 |
601 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 605 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
602 bool ArtificialFailure2 = false; | 606 bool ArtificialFailure2 = false; |
603 CHECK(ArtificialFailure2); | 607 CHECK(ArtificialFailure2); |
604 } | 608 } |
OLD | NEW |