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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 int pointer_space_used, | 209 int pointer_space_used, |
210 int data_space_used, | 210 int data_space_used, |
211 int code_space_used, | 211 int code_space_used, |
212 int map_space_used, | 212 int map_space_used, |
213 int cell_space_used, | 213 int cell_space_used, |
214 int large_space_used) { | 214 int large_space_used) { |
215 int file_name_length = StrLength(file_name_) + 10; | 215 int file_name_length = StrLength(file_name_) + 10; |
216 Vector<char> name = Vector<char>::New(file_name_length + 1); | 216 Vector<char> name = Vector<char>::New(file_name_length + 1); |
217 OS::SNPrintF(name, "%s.size", file_name_); | 217 OS::SNPrintF(name, "%s.size", file_name_); |
218 FILE* fp = OS::FOpen(name.start(), "w"); | 218 FILE* fp = OS::FOpen(name.start(), "w"); |
| 219 name.Dispose(); |
219 fprintf(fp, "new %d\n", new_space_used); | 220 fprintf(fp, "new %d\n", new_space_used); |
220 fprintf(fp, "pointer %d\n", pointer_space_used); | 221 fprintf(fp, "pointer %d\n", pointer_space_used); |
221 fprintf(fp, "data %d\n", data_space_used); | 222 fprintf(fp, "data %d\n", data_space_used); |
222 fprintf(fp, "code %d\n", code_space_used); | 223 fprintf(fp, "code %d\n", code_space_used); |
223 fprintf(fp, "map %d\n", map_space_used); | 224 fprintf(fp, "map %d\n", map_space_used); |
224 fprintf(fp, "cell %d\n", cell_space_used); | 225 fprintf(fp, "cell %d\n", cell_space_used); |
225 fprintf(fp, "large %d\n", large_space_used); | 226 fprintf(fp, "large %d\n", large_space_used); |
226 fclose(fp); | 227 fclose(fp); |
227 } | 228 } |
228 | 229 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 375 } |
375 | 376 |
376 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 377 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
377 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 378 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
378 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 379 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
379 | 380 |
380 env->Exit(); | 381 env->Exit(); |
381 env.Dispose(); | 382 env.Dispose(); |
382 | 383 |
383 FileByteSink startup_sink(startup_name.start()); | 384 FileByteSink startup_sink(startup_name.start()); |
| 385 startup_name.Dispose(); |
384 StartupSerializer startup_serializer(&startup_sink); | 386 StartupSerializer startup_serializer(&startup_sink); |
385 startup_serializer.SerializeStrongReferences(); | 387 startup_serializer.SerializeStrongReferences(); |
386 | 388 |
387 FileByteSink partial_sink(FLAG_testing_serialization_file); | 389 FileByteSink partial_sink(FLAG_testing_serialization_file); |
388 PartialSerializer p_ser(&startup_serializer, &partial_sink); | 390 PartialSerializer p_ser(&startup_serializer, &partial_sink); |
389 p_ser.Serialize(&raw_foo); | 391 p_ser.Serialize(&raw_foo); |
390 startup_serializer.SerializeWeakReferences(); | 392 startup_serializer.SerializeWeakReferences(); |
391 partial_sink.WriteSpaceUsed(p_ser.CurrentAllocationAddress(NEW_SPACE), | 393 partial_sink.WriteSpaceUsed(p_ser.CurrentAllocationAddress(NEW_SPACE), |
392 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), | 394 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), |
393 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), | 395 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), |
394 p_ser.CurrentAllocationAddress(CODE_SPACE), | 396 p_ser.CurrentAllocationAddress(CODE_SPACE), |
395 p_ser.CurrentAllocationAddress(MAP_SPACE), | 397 p_ser.CurrentAllocationAddress(MAP_SPACE), |
396 p_ser.CurrentAllocationAddress(CELL_SPACE), | 398 p_ser.CurrentAllocationAddress(CELL_SPACE), |
397 p_ser.CurrentAllocationAddress(LO_SPACE)); | 399 p_ser.CurrentAllocationAddress(LO_SPACE)); |
398 } | 400 } |
399 | 401 |
400 | 402 |
401 static void ReserveSpaceForPartialSnapshot(const char* file_name) { | 403 static void ReserveSpaceForPartialSnapshot(const char* file_name) { |
402 int file_name_length = StrLength(file_name) + 10; | 404 int file_name_length = StrLength(file_name) + 10; |
403 Vector<char> name = Vector<char>::New(file_name_length + 1); | 405 Vector<char> name = Vector<char>::New(file_name_length + 1); |
404 OS::SNPrintF(name, "%s.size", file_name); | 406 OS::SNPrintF(name, "%s.size", file_name); |
405 FILE* fp = OS::FOpen(name.start(), "r"); | 407 FILE* fp = OS::FOpen(name.start(), "r"); |
| 408 name.Dispose(); |
406 int new_size, pointer_size, data_size, code_size, map_size, cell_size; | 409 int new_size, pointer_size, data_size, code_size, map_size, cell_size; |
407 int large_size; | 410 int large_size; |
408 #ifdef _MSC_VER | 411 #ifdef _MSC_VER |
409 // Avoid warning about unsafe fscanf from MSVC. | 412 // Avoid warning about unsafe fscanf from MSVC. |
410 // Please note that this is only fine if %c and %s are not being used. | 413 // Please note that this is only fine if %c and %s are not being used. |
411 #define fscanf fscanf_s | 414 #define fscanf fscanf_s |
412 #endif | 415 #endif |
413 CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size)); | 416 CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size)); |
414 CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size)); | 417 CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size)); |
415 CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size)); | 418 CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size)); |
(...skipping 15 matching lines...) Expand all Loading... |
431 } | 434 } |
432 | 435 |
433 | 436 |
434 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { | 437 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { |
435 if (!Snapshot::IsEnabled()) { | 438 if (!Snapshot::IsEnabled()) { |
436 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 439 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
437 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 440 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
438 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 441 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
439 | 442 |
440 CHECK(Snapshot::Initialize(startup_name.start())); | 443 CHECK(Snapshot::Initialize(startup_name.start())); |
| 444 startup_name.Dispose(); |
441 | 445 |
442 const char* file_name = FLAG_testing_serialization_file; | 446 const char* file_name = FLAG_testing_serialization_file; |
443 ReserveSpaceForPartialSnapshot(file_name); | 447 ReserveSpaceForPartialSnapshot(file_name); |
444 | 448 |
445 int snapshot_size = 0; | 449 int snapshot_size = 0; |
446 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 450 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
447 | 451 |
448 Object* root; | 452 Object* root; |
449 { | 453 { |
450 SnapshotByteSource source(snapshot, snapshot_size); | 454 SnapshotByteSource source(snapshot, snapshot_size); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 492 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
489 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 493 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
490 | 494 |
491 env->Exit(); | 495 env->Exit(); |
492 | 496 |
493 Object* raw_context = *(v8::Utils::OpenHandle(*env)); | 497 Object* raw_context = *(v8::Utils::OpenHandle(*env)); |
494 | 498 |
495 env.Dispose(); | 499 env.Dispose(); |
496 | 500 |
497 FileByteSink startup_sink(startup_name.start()); | 501 FileByteSink startup_sink(startup_name.start()); |
| 502 startup_name.Dispose(); |
498 StartupSerializer startup_serializer(&startup_sink); | 503 StartupSerializer startup_serializer(&startup_sink); |
499 startup_serializer.SerializeStrongReferences(); | 504 startup_serializer.SerializeStrongReferences(); |
500 | 505 |
501 FileByteSink partial_sink(FLAG_testing_serialization_file); | 506 FileByteSink partial_sink(FLAG_testing_serialization_file); |
502 PartialSerializer p_ser(&startup_serializer, &partial_sink); | 507 PartialSerializer p_ser(&startup_serializer, &partial_sink); |
503 p_ser.Serialize(&raw_context); | 508 p_ser.Serialize(&raw_context); |
504 startup_serializer.SerializeWeakReferences(); | 509 startup_serializer.SerializeWeakReferences(); |
505 partial_sink.WriteSpaceUsed(p_ser.CurrentAllocationAddress(NEW_SPACE), | 510 partial_sink.WriteSpaceUsed(p_ser.CurrentAllocationAddress(NEW_SPACE), |
506 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), | 511 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), |
507 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), | 512 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), |
508 p_ser.CurrentAllocationAddress(CODE_SPACE), | 513 p_ser.CurrentAllocationAddress(CODE_SPACE), |
509 p_ser.CurrentAllocationAddress(MAP_SPACE), | 514 p_ser.CurrentAllocationAddress(MAP_SPACE), |
510 p_ser.CurrentAllocationAddress(CELL_SPACE), | 515 p_ser.CurrentAllocationAddress(CELL_SPACE), |
511 p_ser.CurrentAllocationAddress(LO_SPACE)); | 516 p_ser.CurrentAllocationAddress(LO_SPACE)); |
512 } | 517 } |
513 | 518 |
514 | 519 |
515 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { | 520 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { |
516 if (!Snapshot::IsEnabled()) { | 521 if (!Snapshot::IsEnabled()) { |
517 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 522 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
518 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 523 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
519 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 524 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
520 | 525 |
521 CHECK(Snapshot::Initialize(startup_name.start())); | 526 CHECK(Snapshot::Initialize(startup_name.start())); |
| 527 startup_name.Dispose(); |
522 | 528 |
523 const char* file_name = FLAG_testing_serialization_file; | 529 const char* file_name = FLAG_testing_serialization_file; |
524 ReserveSpaceForPartialSnapshot(file_name); | 530 ReserveSpaceForPartialSnapshot(file_name); |
525 | 531 |
526 int snapshot_size = 0; | 532 int snapshot_size = 0; |
527 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 533 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
528 | 534 |
529 Object* root; | 535 Object* root; |
530 { | 536 { |
531 SnapshotByteSource source(snapshot, snapshot_size); | 537 SnapshotByteSource source(snapshot, snapshot_size); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 TEST(TestThatAlwaysFails) { | 668 TEST(TestThatAlwaysFails) { |
663 bool ArtificialFailure = false; | 669 bool ArtificialFailure = false; |
664 CHECK(ArtificialFailure); | 670 CHECK(ArtificialFailure); |
665 } | 671 } |
666 | 672 |
667 | 673 |
668 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 674 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
669 bool ArtificialFailure2 = false; | 675 bool ArtificialFailure2 = false; |
670 CHECK(ArtificialFailure2); | 676 CHECK(ArtificialFailure2); |
671 } | 677 } |
OLD | NEW |