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

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

Issue 573018: * Generate contexts involving extensions using partial snapshots. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 10 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
« src/bootstrapper.cc ('K') | « src/v8-counters.h ('k') | no next file » | 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 #endif 283 #endif
284 CHECK(Top::global()->IsJSObject()); 284 CHECK(Top::global()->IsJSObject());
285 CHECK(Top::global_context()->IsContext()); 285 CHECK(Top::global_context()->IsContext());
286 CHECK(Top::special_function_table()->IsFixedArray()); 286 CHECK(Top::special_function_table()->IsFixedArray());
287 CHECK(Heap::symbol_table()->IsSymbolTable()); 287 CHECK(Heap::symbol_table()->IsSymbolTable());
288 CHECK(!Factory::LookupAsciiSymbol("Empty")->IsFailure()); 288 CHECK(!Factory::LookupAsciiSymbol("Empty")->IsFailure());
289 } 289 }
290 290
291 291
292 DEPENDENT_TEST(Deserialize, Serialize) { 292 DEPENDENT_TEST(Deserialize, Serialize) {
293 v8::HandleScope scope; 293 // The serialize-deserialize tests only work if the VM is built without
294 // serialization. That doesn't matter. We don't need to be able to
295 // serialize a snapshot in a VM that is booted from a snapshot.
296 if (!Snapshot::IsEnabled()) {
297 v8::HandleScope scope;
294 298
295 Deserialize(); 299 Deserialize();
296 300
297 v8::Persistent<v8::Context> env = v8::Context::New(); 301 v8::Persistent<v8::Context> env = v8::Context::New();
298 env->Enter(); 302 env->Enter();
299 303
300 SanityCheck(); 304 SanityCheck();
305 }
301 } 306 }
302 307
303 308
304 DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { 309 DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) {
305 v8::HandleScope scope; 310 if (!Snapshot::IsEnabled()) {
311 v8::HandleScope scope;
306 312
307 Deserialize(); 313 Deserialize();
308 314
309 v8::Persistent<v8::Context> env = v8::Context::New(); 315 v8::Persistent<v8::Context> env = v8::Context::New();
310 env->Enter(); 316 env->Enter();
311 317
312 SanityCheck(); 318 SanityCheck();
319 }
313 } 320 }
314 321
315 322
316 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { 323 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
317 v8::HandleScope scope; 324 if (!Snapshot::IsEnabled()) {
325 v8::HandleScope scope;
318 326
319 Deserialize(); 327 Deserialize();
320 328
321 v8::Persistent<v8::Context> env = v8::Context::New(); 329 v8::Persistent<v8::Context> env = v8::Context::New();
322 env->Enter(); 330 env->Enter();
323 331
324 const char* c_source = "\"1234\".length"; 332 const char* c_source = "\"1234\".length";
325 v8::Local<v8::String> source = v8::String::New(c_source); 333 v8::Local<v8::String> source = v8::String::New(c_source);
326 v8::Local<v8::Script> script = v8::Script::Compile(source); 334 v8::Local<v8::Script> script = v8::Script::Compile(source);
327 CHECK_EQ(4, script->Run()->Int32Value()); 335 CHECK_EQ(4, script->Run()->Int32Value());
336 }
328 } 337 }
329 338
330 339
331 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, 340 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
332 SerializeTwice) { 341 SerializeTwice) {
333 v8::HandleScope scope; 342 if (!Snapshot::IsEnabled()) {
343 v8::HandleScope scope;
334 344
335 Deserialize(); 345 Deserialize();
336 346
337 v8::Persistent<v8::Context> env = v8::Context::New(); 347 v8::Persistent<v8::Context> env = v8::Context::New();
338 env->Enter(); 348 env->Enter();
339 349
340 const char* c_source = "\"1234\".length"; 350 const char* c_source = "\"1234\".length";
341 v8::Local<v8::String> source = v8::String::New(c_source); 351 v8::Local<v8::String> source = v8::String::New(c_source);
342 v8::Local<v8::Script> script = v8::Script::Compile(source); 352 v8::Local<v8::Script> script = v8::Script::Compile(source);
343 CHECK_EQ(4, script->Run()->Int32Value()); 353 CHECK_EQ(4, script->Run()->Int32Value());
354 }
344 } 355 }
345 356
346 357
347 TEST(PartialSerialization) { 358 TEST(PartialSerialization) {
348 Serializer::Enable(); 359 Serializer::Enable();
349 v8::V8::Initialize(); 360 v8::V8::Initialize();
350 361
351 v8::Persistent<v8::Context> env = v8::Context::New(); 362 v8::Persistent<v8::Context> env = v8::Context::New();
352 ASSERT(!env.IsEmpty()); 363 ASSERT(!env.IsEmpty());
353 env->Enter(); 364 env->Enter();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 pointer_size, 431 pointer_size,
421 data_size, 432 data_size,
422 code_size, 433 code_size,
423 map_size, 434 map_size,
424 cell_size, 435 cell_size,
425 large_size); 436 large_size);
426 } 437 }
427 438
428 439
429 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { 440 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
430 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 441 if (!Snapshot::IsEnabled()) {
431 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 442 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
432 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 443 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
444 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
433 445
434 CHECK(Snapshot::Initialize(startup_name.start())); 446 CHECK(Snapshot::Initialize(startup_name.start()));
435 447
436 const char* file_name = FLAG_testing_serialization_file; 448 const char* file_name = FLAG_testing_serialization_file;
437 ReserveSpaceForPartialSnapshot(file_name); 449 ReserveSpaceForPartialSnapshot(file_name);
438 450
439 int snapshot_size = 0; 451 int snapshot_size = 0;
440 byte* snapshot = ReadBytes(file_name, &snapshot_size); 452 byte* snapshot = ReadBytes(file_name, &snapshot_size);
441 453
442 Object* root; 454 Object* root;
443 { 455 {
444 SnapshotByteSource source(snapshot, snapshot_size); 456 SnapshotByteSource source(snapshot, snapshot_size);
445 Deserializer deserializer(&source); 457 Deserializer deserializer(&source);
446 deserializer.DeserializePartial(&root); 458 deserializer.DeserializePartial(&root);
447 CHECK(root->IsString()); 459 CHECK(root->IsString());
448 } 460 }
449 v8::HandleScope handle_scope; 461 v8::HandleScope handle_scope;
450 Handle<Object>root_handle(root); 462 Handle<Object>root_handle(root);
451 463
452 Object* root2; 464 Object* root2;
453 { 465 {
454 SnapshotByteSource source(snapshot, snapshot_size); 466 SnapshotByteSource source(snapshot, snapshot_size);
455 Deserializer deserializer(&source); 467 Deserializer deserializer(&source);
456 deserializer.DeserializePartial(&root2); 468 deserializer.DeserializePartial(&root2);
457 CHECK(root2->IsString()); 469 CHECK(root2->IsString());
458 CHECK(*root_handle == root2); 470 CHECK(*root_handle == root2);
471 }
459 } 472 }
460 } 473 }
461 474
462 475
463 TEST(ContextSerialization) { 476 TEST(ContextSerialization) {
464 Serializer::Enable(); 477 Serializer::Enable();
465 v8::V8::Initialize(); 478 v8::V8::Initialize();
466 479
467 v8::Persistent<v8::Context> env = v8::Context::New(); 480 v8::Persistent<v8::Context> env = v8::Context::New();
468 ASSERT(!env.IsEmpty()); 481 ASSERT(!env.IsEmpty());
(...skipping 30 matching lines...) Expand all
499 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), 512 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
500 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), 513 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
501 p_ser.CurrentAllocationAddress(CODE_SPACE), 514 p_ser.CurrentAllocationAddress(CODE_SPACE),
502 p_ser.CurrentAllocationAddress(MAP_SPACE), 515 p_ser.CurrentAllocationAddress(MAP_SPACE),
503 p_ser.CurrentAllocationAddress(CELL_SPACE), 516 p_ser.CurrentAllocationAddress(CELL_SPACE),
504 p_ser.CurrentAllocationAddress(LO_SPACE)); 517 p_ser.CurrentAllocationAddress(LO_SPACE));
505 } 518 }
506 519
507 520
508 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { 521 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
509 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 522 if (!Snapshot::IsEnabled()) {
510 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 523 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
511 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 524 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
525 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
512 526
513 CHECK(Snapshot::Initialize(startup_name.start())); 527 CHECK(Snapshot::Initialize(startup_name.start()));
514 528
515 const char* file_name = FLAG_testing_serialization_file; 529 const char* file_name = FLAG_testing_serialization_file;
516 ReserveSpaceForPartialSnapshot(file_name); 530 ReserveSpaceForPartialSnapshot(file_name);
517 531
518 int snapshot_size = 0; 532 int snapshot_size = 0;
519 byte* snapshot = ReadBytes(file_name, &snapshot_size); 533 byte* snapshot = ReadBytes(file_name, &snapshot_size);
520 534
521 Object* root; 535 Object* root;
522 { 536 {
523 SnapshotByteSource source(snapshot, snapshot_size); 537 SnapshotByteSource source(snapshot, snapshot_size);
524 Deserializer deserializer(&source); 538 Deserializer deserializer(&source);
525 deserializer.DeserializePartial(&root); 539 deserializer.DeserializePartial(&root);
526 CHECK(root->IsContext()); 540 CHECK(root->IsContext());
527 } 541 }
528 v8::HandleScope handle_scope; 542 v8::HandleScope handle_scope;
529 Handle<Object>root_handle(root); 543 Handle<Object>root_handle(root);
530 544
531 Object* root2; 545 Object* root2;
532 { 546 {
533 SnapshotByteSource source(snapshot, snapshot_size); 547 SnapshotByteSource source(snapshot, snapshot_size);
534 Deserializer deserializer(&source); 548 Deserializer deserializer(&source);
535 deserializer.DeserializePartial(&root2); 549 deserializer.DeserializePartial(&root2);
536 CHECK(root2->IsContext()); 550 CHECK(root2->IsContext());
537 CHECK(*root_handle != root2); 551 CHECK(*root_handle != root2);
552 }
538 } 553 }
539 } 554 }
540 555
541 556
542 TEST(LinearAllocation) { 557 TEST(LinearAllocation) {
543 v8::V8::Initialize(); 558 v8::V8::Initialize();
544 int new_space_max = 512 * KB; 559 int new_space_max = 512 * KB;
560
545 for (int size = 1000; size < 5 * MB; size += size >> 1) { 561 for (int size = 1000; size < 5 * MB; size += size >> 1) {
546 int new_space_size = (size < new_space_max) ? size : new_space_max; 562 int new_space_size = (size < new_space_max) ? size : new_space_max;
547 Heap::ReserveSpace( 563 Heap::ReserveSpace(
548 new_space_size, 564 new_space_size,
549 size, // Old pointer space. 565 size, // Old pointer space.
550 size, // Old data space. 566 size, // Old data space.
551 size, // Code space. 567 size, // Code space.
552 size, // Map space. 568 size, // Map space.
553 size, // Cell space. 569 size, // Cell space.
554 size); // Large object space. 570 size); // Large object space.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 TEST(TestThatAlwaysFails) { 663 TEST(TestThatAlwaysFails) {
648 bool ArtificialFailure = false; 664 bool ArtificialFailure = false;
649 CHECK(ArtificialFailure); 665 CHECK(ArtificialFailure);
650 } 666 }
651 667
652 668
653 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 669 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
654 bool ArtificialFailure2 = false; 670 bool ArtificialFailure2 = false;
655 CHECK(ArtificialFailure2); 671 CHECK(ArtificialFailure2);
656 } 672 }
OLDNEW
« src/bootstrapper.cc ('K') | « src/v8-counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698