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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 SnapshotByteSink startup_sink; | 323 SnapshotByteSink startup_sink; |
324 StartupSerializer startup_serializer(isolate, &startup_sink); | 324 StartupSerializer startup_serializer(isolate, &startup_sink); |
325 startup_serializer.SerializeStrongReferences(); | 325 startup_serializer.SerializeStrongReferences(); |
326 | 326 |
327 SnapshotByteSink partial_sink; | 327 SnapshotByteSink partial_sink; |
328 PartialSerializer partial_serializer(isolate, &startup_serializer, | 328 PartialSerializer partial_serializer(isolate, &startup_serializer, |
329 &partial_sink); | 329 &partial_sink); |
330 partial_serializer.Serialize(&raw_foo); | 330 partial_serializer.Serialize(&raw_foo); |
331 | 331 |
332 startup_serializer.SerializeWeakReferencesAndDeferred(); | 332 startup_serializer.SerializeWeakReferences(); |
333 | 333 |
334 SnapshotData startup_snapshot(startup_serializer); | 334 SnapshotData startup_snapshot(startup_serializer); |
335 SnapshotData partial_snapshot(partial_serializer); | 335 SnapshotData partial_snapshot(partial_serializer); |
336 | 336 |
337 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); | 337 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); |
338 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 338 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
339 | 339 |
340 startup_name.Dispose(); | 340 startup_name.Dispose(); |
341 } | 341 } |
342 v8_isolate->Exit(); | 342 v8_isolate->Exit(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 env.Reset(); | 440 env.Reset(); |
441 | 441 |
442 SnapshotByteSink startup_sink; | 442 SnapshotByteSink startup_sink; |
443 StartupSerializer startup_serializer(isolate, &startup_sink); | 443 StartupSerializer startup_serializer(isolate, &startup_sink); |
444 startup_serializer.SerializeStrongReferences(); | 444 startup_serializer.SerializeStrongReferences(); |
445 | 445 |
446 SnapshotByteSink partial_sink; | 446 SnapshotByteSink partial_sink; |
447 PartialSerializer partial_serializer(isolate, &startup_serializer, | 447 PartialSerializer partial_serializer(isolate, &startup_serializer, |
448 &partial_sink); | 448 &partial_sink); |
449 partial_serializer.Serialize(&raw_context); | 449 partial_serializer.Serialize(&raw_context); |
450 startup_serializer.SerializeWeakReferencesAndDeferred(); | 450 startup_serializer.SerializeWeakReferences(); |
451 | 451 |
452 SnapshotData startup_snapshot(startup_serializer); | 452 SnapshotData startup_snapshot(startup_serializer); |
453 SnapshotData partial_snapshot(partial_serializer); | 453 SnapshotData partial_snapshot(partial_serializer); |
454 | 454 |
455 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); | 455 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); |
456 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 456 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
457 | 457 |
458 startup_name.Dispose(); | 458 startup_name.Dispose(); |
459 } | 459 } |
460 v8_isolate->Dispose(); | 460 v8_isolate->Dispose(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 env.Reset(); | 575 env.Reset(); |
576 | 576 |
577 SnapshotByteSink startup_sink; | 577 SnapshotByteSink startup_sink; |
578 StartupSerializer startup_serializer(isolate, &startup_sink); | 578 StartupSerializer startup_serializer(isolate, &startup_sink); |
579 startup_serializer.SerializeStrongReferences(); | 579 startup_serializer.SerializeStrongReferences(); |
580 | 580 |
581 SnapshotByteSink partial_sink; | 581 SnapshotByteSink partial_sink; |
582 PartialSerializer partial_serializer(isolate, &startup_serializer, | 582 PartialSerializer partial_serializer(isolate, &startup_serializer, |
583 &partial_sink); | 583 &partial_sink); |
584 partial_serializer.Serialize(&raw_context); | 584 partial_serializer.Serialize(&raw_context); |
585 startup_serializer.SerializeWeakReferencesAndDeferred(); | 585 startup_serializer.SerializeWeakReferences(); |
586 | 586 |
587 SnapshotData startup_snapshot(startup_serializer); | 587 SnapshotData startup_snapshot(startup_serializer); |
588 SnapshotData partial_snapshot(partial_serializer); | 588 SnapshotData partial_snapshot(partial_serializer); |
589 | 589 |
590 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); | 590 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); |
591 WritePayload(startup_snapshot.RawData(), startup_name.start()); | 591 WritePayload(startup_snapshot.RawData(), startup_name.start()); |
592 | 592 |
593 startup_name.Dispose(); | 593 startup_name.Dispose(); |
594 } | 594 } |
595 v8_isolate->Dispose(); | 595 v8_isolate->Dispose(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 v8::HandleScope h_scope(isolate1); | 731 v8::HandleScope h_scope(isolate1); |
732 v8::Local<v8::Context> context = v8::Context::New(isolate1); | 732 v8::Local<v8::Context> context = v8::Context::New(isolate1); |
733 delete[] data1.data; // We can dispose of the snapshot blob now. | 733 delete[] data1.data; // We can dispose of the snapshot blob now. |
734 v8::Context::Scope c_scope(context); | 734 v8::Context::Scope c_scope(context); |
735 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value()); | 735 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value()); |
736 } | 736 } |
737 isolate1->Dispose(); | 737 isolate1->Dispose(); |
738 } | 738 } |
739 | 739 |
740 | 740 |
741 TEST(SnapshotBlobsStackOverflow) { | |
742 DisableTurbofan(); | |
743 const char* source = | |
744 "var a = [0];" | |
745 "var b = a;" | |
746 "for (var i = 0; i < 10000; i++) {" | |
747 " var c = [i];" | |
748 " b.push(c);" | |
749 " b.push(c);" | |
750 " b = c;" | |
751 "}"; | |
752 | |
753 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source); | |
754 | |
755 v8::Isolate::CreateParams params; | |
756 params.snapshot_blob = &data; | |
757 params.array_buffer_allocator = CcTest::array_buffer_allocator(); | |
758 | |
759 v8::Isolate* isolate = v8::Isolate::New(params); | |
760 { | |
761 v8::Isolate::Scope i_scope(isolate); | |
762 v8::HandleScope h_scope(isolate); | |
763 v8::Local<v8::Context> context = v8::Context::New(isolate); | |
764 delete[] data.data; // We can dispose of the snapshot blob now. | |
765 v8::Context::Scope c_scope(context); | |
766 const char* test = | |
767 "var sum = 0;" | |
768 "while (a) {" | |
769 " sum += a[0];" | |
770 " a = a[1];" | |
771 "}" | |
772 "sum"; | |
773 CHECK_EQ(9999 * 5000, CompileRun(test)->ToInt32(isolate)->Int32Value()); | |
774 } | |
775 isolate->Dispose(); | |
776 } | |
777 | |
778 | |
779 TEST(TestThatAlwaysSucceeds) { | 741 TEST(TestThatAlwaysSucceeds) { |
780 } | 742 } |
781 | 743 |
782 | 744 |
783 TEST(TestThatAlwaysFails) { | 745 TEST(TestThatAlwaysFails) { |
784 bool ArtificialFailure = false; | 746 bool ArtificialFailure = false; |
785 CHECK(ArtificialFailure); | 747 CHECK(ArtificialFailure); |
786 } | 748 } |
787 | 749 |
788 | 750 |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 isolate->Dispose(); | 1569 isolate->Dispose(); |
1608 } | 1570 } |
1609 | 1571 |
1610 | 1572 |
1611 TEST(SerializationMemoryStats) { | 1573 TEST(SerializationMemoryStats) { |
1612 FLAG_profile_deserialization = true; | 1574 FLAG_profile_deserialization = true; |
1613 FLAG_always_opt = false; | 1575 FLAG_always_opt = false; |
1614 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1576 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
1615 delete[] blob.data; | 1577 delete[] blob.data; |
1616 } | 1578 } |
OLD | NEW |