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

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

Issue 24265002: bulk replace v8::Isolate::GetCurrent in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | « test/cctest/test-regexp.cc ('k') | test/cctest/test-strings.cc » ('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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 return true; 245 return true;
246 } 246 }
247 247
248 248
249 static void Serialize() { 249 static void Serialize() {
250 // We have to create one context. One reason for this is so that the builtins 250 // We have to create one context. One reason for this is so that the builtins
251 // can be loaded from v8natives.js and their addresses can be processed. This 251 // can be loaded from v8natives.js and their addresses can be processed. This
252 // will clear the pending fixups array, which would otherwise contain GC roots 252 // will clear the pending fixups array, which would otherwise contain GC roots
253 // that would confuse the serialization/deserialization process. 253 // that would confuse the serialization/deserialization process.
254 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 254 v8::Isolate* isolate = CcTest::isolate();
255 { 255 {
256 v8::HandleScope scope(isolate); 256 v8::HandleScope scope(isolate);
257 v8::Context::New(isolate); 257 v8::Context::New(isolate);
258 } 258 }
259 WriteToFile(reinterpret_cast<Isolate*>(isolate), 259 WriteToFile(reinterpret_cast<Isolate*>(isolate),
260 FLAG_testing_serialization_file); 260 FLAG_testing_serialization_file);
261 } 261 }
262 262
263 263
264 // Test that the whole heap can be serialized. 264 // Test that the whole heap can be serialized.
(...skipping 20 matching lines...) Expand all
285 //---------------------------------------------------------------------------- 285 //----------------------------------------------------------------------------
286 // Tests that the heap can be deserialized. 286 // Tests that the heap can be deserialized.
287 287
288 static void Deserialize() { 288 static void Deserialize() {
289 CHECK(Snapshot::Initialize(FLAG_testing_serialization_file)); 289 CHECK(Snapshot::Initialize(FLAG_testing_serialization_file));
290 } 290 }
291 291
292 292
293 static void SanityCheck() { 293 static void SanityCheck() {
294 Isolate* isolate = Isolate::Current(); 294 Isolate* isolate = Isolate::Current();
295 v8::HandleScope scope(v8::Isolate::GetCurrent()); 295 v8::HandleScope scope(CcTest::isolate());
296 #ifdef VERIFY_HEAP 296 #ifdef VERIFY_HEAP
297 HEAP->Verify(); 297 HEAP->Verify();
298 #endif 298 #endif
299 CHECK(isolate->global_object()->IsJSObject()); 299 CHECK(isolate->global_object()->IsJSObject());
300 CHECK(isolate->native_context()->IsContext()); 300 CHECK(isolate->native_context()->IsContext());
301 CHECK(HEAP->string_table()->IsStringTable()); 301 CHECK(HEAP->string_table()->IsStringTable());
302 CHECK(!isolate->factory()->InternalizeOneByteString( 302 CHECK(!isolate->factory()->InternalizeOneByteString(
303 STATIC_ASCII_VECTOR("Empty"))->IsFailure()); 303 STATIC_ASCII_VECTOR("Empty"))->IsFailure());
304 } 304 }
305 305
306 306
307 DEPENDENT_TEST(Deserialize, Serialize) { 307 DEPENDENT_TEST(Deserialize, Serialize) {
308 // The serialize-deserialize tests only work if the VM is built without 308 // The serialize-deserialize tests only work if the VM is built without
309 // serialization. That doesn't matter. We don't need to be able to 309 // serialization. That doesn't matter. We don't need to be able to
310 // serialize a snapshot in a VM that is booted from a snapshot. 310 // serialize a snapshot in a VM that is booted from a snapshot.
311 if (!Snapshot::HaveASnapshotToStartFrom()) { 311 if (!Snapshot::HaveASnapshotToStartFrom()) {
312 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 312 v8::Isolate* isolate = CcTest::isolate();
313 v8::HandleScope scope(isolate); 313 v8::HandleScope scope(isolate);
314 Deserialize(); 314 Deserialize();
315 315
316 v8::Local<v8::Context> env = v8::Context::New(isolate); 316 v8::Local<v8::Context> env = v8::Context::New(isolate);
317 env->Enter(); 317 env->Enter();
318 318
319 SanityCheck(); 319 SanityCheck();
320 } 320 }
321 } 321 }
322 322
323 323
324 DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { 324 DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) {
325 if (!Snapshot::HaveASnapshotToStartFrom()) { 325 if (!Snapshot::HaveASnapshotToStartFrom()) {
326 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 326 v8::Isolate* isolate = CcTest::isolate();
327 v8::HandleScope scope(isolate); 327 v8::HandleScope scope(isolate);
328 Deserialize(); 328 Deserialize();
329 329
330 v8::Local<v8::Context> env = v8::Context::New(isolate); 330 v8::Local<v8::Context> env = v8::Context::New(isolate);
331 env->Enter(); 331 env->Enter();
332 332
333 SanityCheck(); 333 SanityCheck();
334 } 334 }
335 } 335 }
336 336
337 337
338 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { 338 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
339 if (!Snapshot::HaveASnapshotToStartFrom()) { 339 if (!Snapshot::HaveASnapshotToStartFrom()) {
340 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 340 v8::Isolate* isolate = CcTest::isolate();
341 v8::HandleScope scope(isolate); 341 v8::HandleScope scope(isolate);
342 Deserialize(); 342 Deserialize();
343 343
344 v8::Local<v8::Context> env = v8::Context::New(isolate); 344 v8::Local<v8::Context> env = v8::Context::New(isolate);
345 env->Enter(); 345 env->Enter();
346 346
347 const char* c_source = "\"1234\".length"; 347 const char* c_source = "\"1234\".length";
348 v8::Local<v8::String> source = v8::String::New(c_source); 348 v8::Local<v8::String> source = v8::String::New(c_source);
349 v8::Local<v8::Script> script = v8::Script::Compile(source); 349 v8::Local<v8::Script> script = v8::Script::Compile(source);
350 CHECK_EQ(4, script->Run()->Int32Value()); 350 CHECK_EQ(4, script->Run()->Int32Value());
351 } 351 }
352 } 352 }
353 353
354 354
355 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, 355 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
356 SerializeTwice) { 356 SerializeTwice) {
357 if (!Snapshot::HaveASnapshotToStartFrom()) { 357 if (!Snapshot::HaveASnapshotToStartFrom()) {
358 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 358 v8::Isolate* isolate = CcTest::isolate();
359 v8::HandleScope scope(isolate); 359 v8::HandleScope scope(isolate);
360 Deserialize(); 360 Deserialize();
361 361
362 v8::Local<v8::Context> env = v8::Context::New(isolate); 362 v8::Local<v8::Context> env = v8::Context::New(isolate);
363 env->Enter(); 363 env->Enter();
364 364
365 const char* c_source = "\"1234\".length"; 365 const char* c_source = "\"1234\".length";
366 v8::Local<v8::String> source = v8::String::New(c_source); 366 v8::Local<v8::String> source = v8::String::New(c_source);
367 v8::Local<v8::Script> script = v8::Script::Compile(source); 367 v8::Local<v8::Script> script = v8::Script::Compile(source);
368 CHECK_EQ(4, script->Run()->Int32Value()); 368 CHECK_EQ(4, script->Run()->Int32Value());
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 TEST(TestThatAlwaysFails) { 640 TEST(TestThatAlwaysFails) {
641 bool ArtificialFailure = false; 641 bool ArtificialFailure = false;
642 CHECK(ArtificialFailure); 642 CHECK(ArtificialFailure);
643 } 643 }
644 644
645 645
646 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 646 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
647 bool ArtificialFailure2 = false; 647 bool ArtificialFailure2 = false;
648 CHECK(ArtificialFailure2); 648 CHECK(ArtificialFailure2);
649 } 649 }
OLDNEW
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698