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

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

Issue 1181053003: Version 4.3.61.28 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.3
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/snapshot/serialize.cc ('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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 320
321 SnapshotByteSink startup_sink; 321 SnapshotByteSink startup_sink;
322 StartupSerializer startup_serializer(isolate, &startup_sink); 322 StartupSerializer startup_serializer(isolate, &startup_sink);
323 startup_serializer.SerializeStrongReferences(); 323 startup_serializer.SerializeStrongReferences();
324 324
325 SnapshotByteSink partial_sink; 325 SnapshotByteSink partial_sink;
326 PartialSerializer partial_serializer(isolate, &startup_serializer, 326 PartialSerializer partial_serializer(isolate, &startup_serializer,
327 &partial_sink); 327 &partial_sink);
328 partial_serializer.Serialize(&raw_foo); 328 partial_serializer.Serialize(&raw_foo);
329 329
330 startup_serializer.SerializeWeakReferences(); 330 startup_serializer.SerializeWeakReferencesAndDeferred();
331 331
332 SnapshotData startup_snapshot(startup_serializer); 332 SnapshotData startup_snapshot(startup_serializer);
333 SnapshotData partial_snapshot(partial_serializer); 333 SnapshotData partial_snapshot(partial_serializer);
334 334
335 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 335 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
336 WritePayload(startup_snapshot.RawData(), startup_name.start()); 336 WritePayload(startup_snapshot.RawData(), startup_name.start());
337 337
338 startup_name.Dispose(); 338 startup_name.Dispose();
339 } 339 }
340 v8_isolate->Exit(); 340 v8_isolate->Exit();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 env.Reset(); 438 env.Reset();
439 439
440 SnapshotByteSink startup_sink; 440 SnapshotByteSink startup_sink;
441 StartupSerializer startup_serializer(isolate, &startup_sink); 441 StartupSerializer startup_serializer(isolate, &startup_sink);
442 startup_serializer.SerializeStrongReferences(); 442 startup_serializer.SerializeStrongReferences();
443 443
444 SnapshotByteSink partial_sink; 444 SnapshotByteSink partial_sink;
445 PartialSerializer partial_serializer(isolate, &startup_serializer, 445 PartialSerializer partial_serializer(isolate, &startup_serializer,
446 &partial_sink); 446 &partial_sink);
447 partial_serializer.Serialize(&raw_context); 447 partial_serializer.Serialize(&raw_context);
448 startup_serializer.SerializeWeakReferences(); 448 startup_serializer.SerializeWeakReferencesAndDeferred();
449 449
450 SnapshotData startup_snapshot(startup_serializer); 450 SnapshotData startup_snapshot(startup_serializer);
451 SnapshotData partial_snapshot(partial_serializer); 451 SnapshotData partial_snapshot(partial_serializer);
452 452
453 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 453 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
454 WritePayload(startup_snapshot.RawData(), startup_name.start()); 454 WritePayload(startup_snapshot.RawData(), startup_name.start());
455 455
456 startup_name.Dispose(); 456 startup_name.Dispose();
457 } 457 }
458 v8_isolate->Dispose(); 458 v8_isolate->Dispose();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 env.Reset(); 573 env.Reset();
574 574
575 SnapshotByteSink startup_sink; 575 SnapshotByteSink startup_sink;
576 StartupSerializer startup_serializer(isolate, &startup_sink); 576 StartupSerializer startup_serializer(isolate, &startup_sink);
577 startup_serializer.SerializeStrongReferences(); 577 startup_serializer.SerializeStrongReferences();
578 578
579 SnapshotByteSink partial_sink; 579 SnapshotByteSink partial_sink;
580 PartialSerializer partial_serializer(isolate, &startup_serializer, 580 PartialSerializer partial_serializer(isolate, &startup_serializer,
581 &partial_sink); 581 &partial_sink);
582 partial_serializer.Serialize(&raw_context); 582 partial_serializer.Serialize(&raw_context);
583 startup_serializer.SerializeWeakReferences(); 583 startup_serializer.SerializeWeakReferencesAndDeferred();
584 584
585 SnapshotData startup_snapshot(startup_serializer); 585 SnapshotData startup_snapshot(startup_serializer);
586 SnapshotData partial_snapshot(partial_serializer); 586 SnapshotData partial_snapshot(partial_serializer);
587 587
588 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 588 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
589 WritePayload(startup_snapshot.RawData(), startup_name.start()); 589 WritePayload(startup_snapshot.RawData(), startup_name.start());
590 590
591 startup_name.Dispose(); 591 startup_name.Dispose();
592 } 592 }
593 v8_isolate->Dispose(); 593 v8_isolate->Dispose();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 v8::HandleScope h_scope(isolate1); 723 v8::HandleScope h_scope(isolate1);
724 v8::Local<v8::Context> context = v8::Context::New(isolate1); 724 v8::Local<v8::Context> context = v8::Context::New(isolate1);
725 delete[] data1.data; // We can dispose of the snapshot blob now. 725 delete[] data1.data; // We can dispose of the snapshot blob now.
726 v8::Context::Scope c_scope(context); 726 v8::Context::Scope c_scope(context);
727 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value()); 727 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value());
728 } 728 }
729 isolate1->Dispose(); 729 isolate1->Dispose();
730 } 730 }
731 731
732 732
733 TEST(SnapshotBlobsStackOverflow) {
734 DisableTurbofan();
735 const char* source =
736 "var a = [0];"
737 "var b = a;"
738 "for (var i = 0; i < 10000; i++) {"
739 " var c = [i];"
740 " b.push(c);"
741 " b.push(c);"
742 " b = c;"
743 "}";
744
745 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source);
746
747 v8::Isolate::CreateParams params;
748 params.snapshot_blob = &data;
749
750 v8::Isolate* isolate = v8::Isolate::New(params);
751 {
752 v8::Isolate::Scope i_scope(isolate);
753 v8::HandleScope h_scope(isolate);
754 v8::Local<v8::Context> context = v8::Context::New(isolate);
755 delete[] data.data; // We can dispose of the snapshot blob now.
756 v8::Context::Scope c_scope(context);
757 const char* test =
758 "var sum = 0;"
759 "while (a) {"
760 " sum += a[0];"
761 " a = a[1];"
762 "}"
763 "sum";
764 CHECK_EQ(9999 * 5000, CompileRun(test)->ToInt32(isolate)->Int32Value());
765 }
766 isolate->Dispose();
767 }
768
769
733 TEST(TestThatAlwaysSucceeds) { 770 TEST(TestThatAlwaysSucceeds) {
734 } 771 }
735 772
736 773
737 TEST(TestThatAlwaysFails) { 774 TEST(TestThatAlwaysFails) {
738 bool ArtificialFailure = false; 775 bool ArtificialFailure = false;
739 CHECK(ArtificialFailure); 776 CHECK(ArtificialFailure);
740 } 777 }
741 778
742 779
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 CHECK_EQ(11, CompileRun("foo(0)")->ToInt32(isolate)->Int32Value()); 1579 CHECK_EQ(11, CompileRun("foo(0)")->ToInt32(isolate)->Int32Value());
1543 CHECK_EQ(11, CompileRun("foo(1)")->ToInt32(isolate)->Int32Value()); 1580 CHECK_EQ(11, CompileRun("foo(1)")->ToInt32(isolate)->Int32Value());
1544 CHECK_EQ(12, CompileRun("foo(2)")->ToInt32(isolate)->Int32Value()); 1581 CHECK_EQ(12, CompileRun("foo(2)")->ToInt32(isolate)->Int32Value());
1545 CHECK_EQ(12, CompileRun("foo(3)")->ToInt32(isolate)->Int32Value()); 1582 CHECK_EQ(12, CompileRun("foo(3)")->ToInt32(isolate)->Int32Value());
1546 CHECK_EQ(23, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value()); 1583 CHECK_EQ(23, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value());
1547 CHECK_EQ(23, CompileRun("foo(5)")->ToInt32(isolate)->Int32Value()); 1584 CHECK_EQ(23, CompileRun("foo(5)")->ToInt32(isolate)->Int32Value());
1548 CHECK_EQ(10, CompileRun("foo(6)")->ToInt32(isolate)->Int32Value()); 1585 CHECK_EQ(10, CompileRun("foo(6)")->ToInt32(isolate)->Int32Value());
1549 } 1586 }
1550 isolate->Dispose(); 1587 isolate->Dispose();
1551 } 1588 }
OLDNEW
« no previous file with comments | « src/snapshot/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698