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

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

Issue 12033011: Add Isolate parameter to Persistent class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added new kind of callback Created 7 years, 11 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
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 return true; 242 return true;
243 } 243 }
244 244
245 245
246 static void Serialize() { 246 static void Serialize() {
247 // We have to create one context. One reason for this is so that the builtins 247 // We have to create one context. One reason for this is so that the builtins
248 // can be loaded from v8natives.js and their addresses can be processed. This 248 // can be loaded from v8natives.js and their addresses can be processed. This
249 // will clear the pending fixups array, which would otherwise contain GC roots 249 // will clear the pending fixups array, which would otherwise contain GC roots
250 // that would confuse the serialization/deserialization process. 250 // that would confuse the serialization/deserialization process.
251 v8::Persistent<v8::Context> env = v8::Context::New(); 251 v8::Persistent<v8::Context> env = v8::Context::New();
252 env.Dispose(); 252 env.Dispose(env->GetIsolate());
253 WriteToFile(FLAG_testing_serialization_file); 253 WriteToFile(FLAG_testing_serialization_file);
254 } 254 }
255 255
256 256
257 // Test that the whole heap can be serialized. 257 // Test that the whole heap can be serialized.
258 TEST(Serialize) { 258 TEST(Serialize) {
259 if (!Snapshot::HaveASnapshotToStartFrom()) { 259 if (!Snapshot::HaveASnapshotToStartFrom()) {
260 Serializer::Enable(); 260 Serializer::Enable();
261 v8::V8::Initialize(); 261 v8::V8::Initialize();
262 Serialize(); 262 Serialize();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 v8::Local<v8::String> foo = v8::String::New("foo"); 381 v8::Local<v8::String> foo = v8::String::New("foo");
382 ASSERT(!foo.IsEmpty()); 382 ASSERT(!foo.IsEmpty());
383 raw_foo = *(v8::Utils::OpenHandle(*foo)); 383 raw_foo = *(v8::Utils::OpenHandle(*foo));
384 } 384 }
385 385
386 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 386 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
387 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 387 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
388 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 388 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
389 389
390 env->Exit(); 390 env->Exit();
391 env.Dispose(); 391 env.Dispose(env->GetIsolate());
392 392
393 FileByteSink startup_sink(startup_name.start()); 393 FileByteSink startup_sink(startup_name.start());
394 StartupSerializer startup_serializer(&startup_sink); 394 StartupSerializer startup_serializer(&startup_sink);
395 startup_serializer.SerializeStrongReferences(); 395 startup_serializer.SerializeStrongReferences();
396 396
397 FileByteSink partial_sink(FLAG_testing_serialization_file); 397 FileByteSink partial_sink(FLAG_testing_serialization_file);
398 PartialSerializer p_ser(&startup_serializer, &partial_sink); 398 PartialSerializer p_ser(&startup_serializer, &partial_sink);
399 p_ser.Serialize(&raw_foo); 399 p_ser.Serialize(&raw_foo);
400 startup_serializer.SerializeWeakReferences(); 400 startup_serializer.SerializeWeakReferences();
401 401
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 509 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
510 510
511 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 511 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
512 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 512 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
513 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 513 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
514 514
515 env->Exit(); 515 env->Exit();
516 516
517 Object* raw_context = *(v8::Utils::OpenHandle(*env)); 517 Object* raw_context = *(v8::Utils::OpenHandle(*env));
518 518
519 env.Dispose(); 519 env.Dispose(env->GetIsolate());
520 520
521 FileByteSink startup_sink(startup_name.start()); 521 FileByteSink startup_sink(startup_name.start());
522 StartupSerializer startup_serializer(&startup_sink); 522 StartupSerializer startup_serializer(&startup_sink);
523 startup_serializer.SerializeStrongReferences(); 523 startup_serializer.SerializeStrongReferences();
524 524
525 FileByteSink partial_sink(FLAG_testing_serialization_file); 525 FileByteSink partial_sink(FLAG_testing_serialization_file);
526 PartialSerializer p_ser(&startup_serializer, &partial_sink); 526 PartialSerializer p_ser(&startup_serializer, &partial_sink);
527 p_ser.Serialize(&raw_context); 527 p_ser.Serialize(&raw_context);
528 startup_serializer.SerializeWeakReferences(); 528 startup_serializer.SerializeWeakReferences();
529 529
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 TEST(TestThatAlwaysFails) { 593 TEST(TestThatAlwaysFails) {
594 bool ArtificialFailure = false; 594 bool ArtificialFailure = false;
595 CHECK(ArtificialFailure); 595 CHECK(ArtificialFailure);
596 } 596 }
597 597
598 598
599 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 599 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
600 bool ArtificialFailure2 = false; 600 bool ArtificialFailure2 = false;
601 CHECK(ArtificialFailure2); 601 CHECK(ArtificialFailure2);
602 } 602 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698