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

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

Issue 2479823002: [test] no longer disable turbofan for serializer tests. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "src/snapshot/deserializer.h" 43 #include "src/snapshot/deserializer.h"
44 #include "src/snapshot/natives.h" 44 #include "src/snapshot/natives.h"
45 #include "src/snapshot/partial-serializer.h" 45 #include "src/snapshot/partial-serializer.h"
46 #include "src/snapshot/snapshot.h" 46 #include "src/snapshot/snapshot.h"
47 #include "src/snapshot/startup-serializer.h" 47 #include "src/snapshot/startup-serializer.h"
48 #include "test/cctest/cctest.h" 48 #include "test/cctest/cctest.h"
49 #include "test/cctest/heap/heap-utils.h" 49 #include "test/cctest/heap/heap-utils.h"
50 50
51 using namespace v8::internal; 51 using namespace v8::internal;
52 52
53 void DisableTurbofan() {
54 const char* flag = "--turbo-filter=\"\"";
55 FlagList::SetFlagsFromString(flag, StrLength(flag));
56 }
57
58
59 // TestIsolate is used for testing isolate serialization. 53 // TestIsolate is used for testing isolate serialization.
60 class TestIsolate : public Isolate { 54 class TestIsolate : public Isolate {
61 public: 55 public:
62 static v8::Isolate* NewInitialized(bool enable_serializer) { 56 static v8::Isolate* NewInitialized(bool enable_serializer) {
63 i::Isolate* isolate = new TestIsolate(enable_serializer); 57 i::Isolate* isolate = new TestIsolate(enable_serializer);
64 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 58 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
65 v8::Isolate::Scope isolate_scope(v8_isolate); 59 v8::Isolate::Scope isolate_scope(v8_isolate);
66 isolate->Init(NULL); 60 isolate->Init(NULL);
67 return v8_isolate; 61 return v8_isolate;
68 } 62 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 #ifdef VERIFY_HEAP 137 #ifdef VERIFY_HEAP
144 isolate->heap()->Verify(); 138 isolate->heap()->Verify();
145 #endif 139 #endif
146 CHECK(isolate->global_object()->IsJSObject()); 140 CHECK(isolate->global_object()->IsJSObject());
147 CHECK(isolate->native_context()->IsContext()); 141 CHECK(isolate->native_context()->IsContext());
148 CHECK(isolate->heap()->string_table()->IsStringTable()); 142 CHECK(isolate->heap()->string_table()->IsStringTable());
149 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); 143 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
150 } 144 }
151 145
152 UNINITIALIZED_TEST(StartupSerializerOnce) { 146 UNINITIALIZED_TEST(StartupSerializerOnce) {
153 // The serialize-deserialize tests only work if the VM is built without
154 // serialization. That doesn't matter. We don't need to be able to
155 // serialize a snapshot in a VM that is booted from a snapshot.
Yang 2016/11/04 09:00:29 This comment doesn't make any sense nowadays.
156 DisableTurbofan();
157 v8::Isolate* isolate = TestIsolate::NewInitialized(true); 147 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
158 Vector<const byte> blob = Serialize(isolate); 148 Vector<const byte> blob = Serialize(isolate);
159 isolate = Deserialize(blob); 149 isolate = Deserialize(blob);
160 blob.Dispose(); 150 blob.Dispose();
161 { 151 {
162 v8::HandleScope handle_scope(isolate); 152 v8::HandleScope handle_scope(isolate);
163 v8::Isolate::Scope isolate_scope(isolate); 153 v8::Isolate::Scope isolate_scope(isolate);
164 154
165 v8::Local<v8::Context> env = v8::Context::New(isolate); 155 v8::Local<v8::Context> env = v8::Context::New(isolate);
166 env->Enter(); 156 env->Enter();
167 157
168 SanityCheck(isolate); 158 SanityCheck(isolate);
169 } 159 }
170 isolate->Dispose(); 160 isolate->Dispose();
171 } 161 }
172 162
173 UNINITIALIZED_TEST(StartupSerializerTwice) { 163 UNINITIALIZED_TEST(StartupSerializerTwice) {
174 DisableTurbofan();
175 v8::Isolate* isolate = TestIsolate::NewInitialized(true); 164 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
176 Vector<const byte> blob1 = Serialize(isolate); 165 Vector<const byte> blob1 = Serialize(isolate);
177 Vector<const byte> blob2 = Serialize(isolate); 166 Vector<const byte> blob2 = Serialize(isolate);
178 blob1.Dispose(); 167 blob1.Dispose();
179 isolate = Deserialize(blob2); 168 isolate = Deserialize(blob2);
180 blob2.Dispose(); 169 blob2.Dispose();
181 { 170 {
182 v8::Isolate::Scope isolate_scope(isolate); 171 v8::Isolate::Scope isolate_scope(isolate);
183 v8::HandleScope handle_scope(isolate); 172 v8::HandleScope handle_scope(isolate);
184 173
185 v8::Local<v8::Context> env = v8::Context::New(isolate); 174 v8::Local<v8::Context> env = v8::Context::New(isolate);
186 env->Enter(); 175 env->Enter();
187 176
188 SanityCheck(isolate); 177 SanityCheck(isolate);
189 } 178 }
190 isolate->Dispose(); 179 isolate->Dispose();
191 } 180 }
192 181
193 UNINITIALIZED_TEST(StartupSerializerOnceRunScript) { 182 UNINITIALIZED_TEST(StartupSerializerOnceRunScript) {
194 DisableTurbofan();
195 v8::Isolate* isolate = TestIsolate::NewInitialized(true); 183 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
196 Vector<const byte> blob = Serialize(isolate); 184 Vector<const byte> blob = Serialize(isolate);
197 isolate = Deserialize(blob); 185 isolate = Deserialize(blob);
198 blob.Dispose(); 186 blob.Dispose();
199 { 187 {
200 v8::Isolate::Scope isolate_scope(isolate); 188 v8::Isolate::Scope isolate_scope(isolate);
201 v8::HandleScope handle_scope(isolate); 189 v8::HandleScope handle_scope(isolate);
202 190
203 191
204 v8::Local<v8::Context> env = v8::Context::New(isolate); 192 v8::Local<v8::Context> env = v8::Context::New(isolate);
205 env->Enter(); 193 env->Enter();
206 194
207 const char* c_source = "\"1234\".length"; 195 const char* c_source = "\"1234\".length";
208 v8::Local<v8::Script> script = v8_compile(c_source); 196 v8::Local<v8::Script> script = v8_compile(c_source);
209 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext()) 197 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext())
210 .ToLocalChecked() 198 .ToLocalChecked()
211 ->Int32Value(isolate->GetCurrentContext()); 199 ->Int32Value(isolate->GetCurrentContext());
212 CHECK_EQ(4, result.FromJust()); 200 CHECK_EQ(4, result.FromJust());
213 } 201 }
214 isolate->Dispose(); 202 isolate->Dispose();
215 } 203 }
216 204
217 UNINITIALIZED_TEST(StartupSerializerTwiceRunScript) { 205 UNINITIALIZED_TEST(StartupSerializerTwiceRunScript) {
218 DisableTurbofan();
219 v8::Isolate* isolate = TestIsolate::NewInitialized(true); 206 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
220 Vector<const byte> blob1 = Serialize(isolate); 207 Vector<const byte> blob1 = Serialize(isolate);
221 Vector<const byte> blob2 = Serialize(isolate); 208 Vector<const byte> blob2 = Serialize(isolate);
222 blob1.Dispose(); 209 blob1.Dispose();
223 isolate = Deserialize(blob2); 210 isolate = Deserialize(blob2);
224 blob2.Dispose(); 211 blob2.Dispose();
225 { 212 {
226 v8::Isolate::Scope isolate_scope(isolate); 213 v8::Isolate::Scope isolate_scope(isolate);
227 v8::HandleScope handle_scope(isolate); 214 v8::HandleScope handle_scope(isolate);
228 215
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 SnapshotData partial_snapshot(&partial_serializer); 283 SnapshotData partial_snapshot(&partial_serializer);
297 284
298 *partial_blob_out = WritePayload(partial_snapshot.RawData()); 285 *partial_blob_out = WritePayload(partial_snapshot.RawData());
299 *startup_blob_out = WritePayload(startup_snapshot.RawData()); 286 *startup_blob_out = WritePayload(startup_snapshot.RawData());
300 } 287 }
301 v8_isolate->Exit(); 288 v8_isolate->Exit();
302 v8_isolate->Dispose(); 289 v8_isolate->Dispose();
303 } 290 }
304 291
305 UNINITIALIZED_TEST(PartialSerializerObject) { 292 UNINITIALIZED_TEST(PartialSerializerObject) {
306 DisableTurbofan();
307 Vector<const byte> startup_blob; 293 Vector<const byte> startup_blob;
308 Vector<const byte> partial_blob; 294 Vector<const byte> partial_blob;
309 PartiallySerializeObject(&startup_blob, &partial_blob); 295 PartiallySerializeObject(&startup_blob, &partial_blob);
310 296
311 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob); 297 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob);
312 startup_blob.Dispose(); 298 startup_blob.Dispose();
313 CHECK(v8_isolate); 299 CHECK(v8_isolate);
314 { 300 {
315 v8::Isolate::Scope isolate_scope(v8_isolate); 301 v8::Isolate::Scope isolate_scope(v8_isolate);
316 302
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 SnapshotData startup_snapshot(&startup_serializer); 380 SnapshotData startup_snapshot(&startup_serializer);
395 SnapshotData partial_snapshot(&partial_serializer); 381 SnapshotData partial_snapshot(&partial_serializer);
396 382
397 *partial_blob_out = WritePayload(partial_snapshot.RawData()); 383 *partial_blob_out = WritePayload(partial_snapshot.RawData());
398 *startup_blob_out = WritePayload(startup_snapshot.RawData()); 384 *startup_blob_out = WritePayload(startup_snapshot.RawData());
399 } 385 }
400 v8_isolate->Dispose(); 386 v8_isolate->Dispose();
401 } 387 }
402 388
403 UNINITIALIZED_TEST(PartialSerializerContext) { 389 UNINITIALIZED_TEST(PartialSerializerContext) {
404 DisableTurbofan();
405 Vector<const byte> startup_blob; 390 Vector<const byte> startup_blob;
406 Vector<const byte> partial_blob; 391 Vector<const byte> partial_blob;
407 PartiallySerializeContext(&startup_blob, &partial_blob); 392 PartiallySerializeContext(&startup_blob, &partial_blob);
408 393
409 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob); 394 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob);
410 CHECK(v8_isolate); 395 CHECK(v8_isolate);
411 startup_blob.Dispose(); 396 startup_blob.Dispose();
412 { 397 {
413 v8::Isolate::Scope isolate_scope(v8_isolate); 398 v8::Isolate::Scope isolate_scope(v8_isolate);
414 399
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 SnapshotData startup_snapshot(&startup_serializer); 498 SnapshotData startup_snapshot(&startup_serializer);
514 SnapshotData partial_snapshot(&partial_serializer); 499 SnapshotData partial_snapshot(&partial_serializer);
515 500
516 *partial_blob_out = WritePayload(partial_snapshot.RawData()); 501 *partial_blob_out = WritePayload(partial_snapshot.RawData());
517 *startup_blob_out = WritePayload(startup_snapshot.RawData()); 502 *startup_blob_out = WritePayload(startup_snapshot.RawData());
518 } 503 }
519 v8_isolate->Dispose(); 504 v8_isolate->Dispose();
520 } 505 }
521 506
522 UNINITIALIZED_TEST(PartialSerializerCustomContext) { 507 UNINITIALIZED_TEST(PartialSerializerCustomContext) {
523 DisableTurbofan();
524 Vector<const byte> startup_blob; 508 Vector<const byte> startup_blob;
525 Vector<const byte> partial_blob; 509 Vector<const byte> partial_blob;
526 PartiallySerializeCustomContext(&startup_blob, &partial_blob); 510 PartiallySerializeCustomContext(&startup_blob, &partial_blob);
527 511
528 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob); 512 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob);
529 CHECK(v8_isolate); 513 CHECK(v8_isolate);
530 startup_blob.Dispose(); 514 startup_blob.Dispose();
531 { 515 {
532 v8::Isolate::Scope isolate_scope(v8_isolate); 516 v8::Isolate::Scope isolate_scope(v8_isolate);
533 517
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 ->Int32Value(v8_isolate->GetCurrentContext()) 587 ->Int32Value(v8_isolate->GetCurrentContext())
604 .FromJust(); 588 .FromJust();
605 CHECK_EQ(100002, b); 589 CHECK_EQ(100002, b);
606 } 590 }
607 partial_blob.Dispose(); 591 partial_blob.Dispose();
608 } 592 }
609 v8_isolate->Dispose(); 593 v8_isolate->Dispose();
610 } 594 }
611 595
612 TEST(CustomSnapshotDataBlob) { 596 TEST(CustomSnapshotDataBlob) {
613 DisableTurbofan();
614 const char* source1 = "function f() { return 42; }"; 597 const char* source1 = "function f() { return 42; }";
615 const char* source2 = 598 const char* source2 =
616 "function f() { return g() * 2; }" 599 "function f() { return g() * 2; }"
617 "function g() { return 43; }" 600 "function g() { return 43; }"
618 "/./.test('a')"; 601 "/./.test('a')";
619 602
620 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); 603 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
621 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); 604 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2);
622 605
623 v8::Isolate::CreateParams params1; 606 v8::Isolate::CreateParams params1;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 isolate2->Dispose(); 640 isolate2->Dispose();
658 } 641 }
659 642
660 643
661 static void SerializationFunctionTemplate( 644 static void SerializationFunctionTemplate(
662 const v8::FunctionCallbackInfo<v8::Value>& args) { 645 const v8::FunctionCallbackInfo<v8::Value>& args) {
663 args.GetReturnValue().Set(args[0]); 646 args.GetReturnValue().Set(args[0]);
664 } 647 }
665 648
666 TEST(CustomSnapshotDataBlobOutdatedContextWithOverflow) { 649 TEST(CustomSnapshotDataBlobOutdatedContextWithOverflow) {
667 DisableTurbofan();
668
669 const char* source1 = 650 const char* source1 =
670 "var o = {};" 651 "var o = {};"
671 "(function() {" 652 "(function() {"
672 " function f1(x) { return f2(x) instanceof Array; }" 653 " function f1(x) { return f2(x) instanceof Array; }"
673 " function f2(x) { return foo.bar(x); }" 654 " function f2(x) { return foo.bar(x); }"
674 " o.a = f2.bind(null);" 655 " o.a = f2.bind(null);"
675 " o.b = 1;" 656 " o.b = 1;"
676 " o.c = 2;" 657 " o.c = 2;"
677 " o.d = 3;" 658 " o.d = 3;"
678 " o.e = 4;" 659 " o.e = 4;"
(...skipping 24 matching lines...) Expand all
703 v8::Context::Scope c_scope(context); 684 v8::Context::Scope c_scope(context);
704 v8::Local<v8::Value> result = CompileRun(source2); 685 v8::Local<v8::Value> result = CompileRun(source2);
705 v8::Maybe<bool> compare = v8_str("42")->Equals( 686 v8::Maybe<bool> compare = v8_str("42")->Equals(
706 v8::Isolate::GetCurrent()->GetCurrentContext(), result); 687 v8::Isolate::GetCurrent()->GetCurrentContext(), result);
707 CHECK(compare.FromJust()); 688 CHECK(compare.FromJust());
708 } 689 }
709 isolate->Dispose(); 690 isolate->Dispose();
710 } 691 }
711 692
712 TEST(CustomSnapshotDataBlobWithLocker) { 693 TEST(CustomSnapshotDataBlobWithLocker) {
713 DisableTurbofan();
714 v8::Isolate::CreateParams create_params; 694 v8::Isolate::CreateParams create_params;
715 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); 695 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
716 v8::Isolate* isolate0 = v8::Isolate::New(create_params); 696 v8::Isolate* isolate0 = v8::Isolate::New(create_params);
717 { 697 {
718 v8::Locker locker(isolate0); 698 v8::Locker locker(isolate0);
719 v8::Isolate::Scope i_scope(isolate0); 699 v8::Isolate::Scope i_scope(isolate0);
720 v8::HandleScope h_scope(isolate0); 700 v8::HandleScope h_scope(isolate0);
721 v8::Local<v8::Context> context = v8::Context::New(isolate0); 701 v8::Local<v8::Context> context = v8::Context::New(isolate0);
722 v8::Context::Scope c_scope(context); 702 v8::Context::Scope c_scope(context);
723 v8::Maybe<int32_t> result = 703 v8::Maybe<int32_t> result =
(...skipping 17 matching lines...) Expand all
741 v8::Local<v8::Context> context = v8::Context::New(isolate1); 721 v8::Local<v8::Context> context = v8::Context::New(isolate1);
742 delete[] data1.data; // We can dispose of the snapshot blob now. 722 delete[] data1.data; // We can dispose of the snapshot blob now.
743 v8::Context::Scope c_scope(context); 723 v8::Context::Scope c_scope(context);
744 v8::Maybe<int32_t> result = CompileRun("f()")->Int32Value(context); 724 v8::Maybe<int32_t> result = CompileRun("f()")->Int32Value(context);
745 CHECK_EQ(42, result.FromJust()); 725 CHECK_EQ(42, result.FromJust());
746 } 726 }
747 isolate1->Dispose(); 727 isolate1->Dispose();
748 } 728 }
749 729
750 TEST(CustomSnapshotDataBlobStackOverflow) { 730 TEST(CustomSnapshotDataBlobStackOverflow) {
751 DisableTurbofan();
752 const char* source = 731 const char* source =
753 "var a = [0];" 732 "var a = [0];"
754 "var b = a;" 733 "var b = a;"
755 "for (var i = 0; i < 10000; i++) {" 734 "for (var i = 0; i < 10000; i++) {"
756 " var c = [i];" 735 " var c = [i];"
757 " b.push(c);" 736 " b.push(c);"
758 " b.push(c);" 737 " b.push(c);"
759 " b = c;" 738 " b = c;"
760 "}"; 739 "}";
761 740
(...skipping 25 matching lines...) Expand all
787 } 766 }
788 767
789 bool IsCompiled(const char* name) { 768 bool IsCompiled(const char* name) {
790 return i::Handle<i::JSFunction>::cast( 769 return i::Handle<i::JSFunction>::cast(
791 v8::Utils::OpenHandle(*CompileRun(name))) 770 v8::Utils::OpenHandle(*CompileRun(name)))
792 ->shared() 771 ->shared()
793 ->is_compiled(); 772 ->is_compiled();
794 } 773 }
795 774
796 TEST(SnapshotDataBlobWithWarmup) { 775 TEST(SnapshotDataBlobWithWarmup) {
797 DisableTurbofan();
798 const char* warmup = "Math.abs(1); Math.random = 1;"; 776 const char* warmup = "Math.abs(1); Math.random = 1;";
799 777
800 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(); 778 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob();
801 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); 779 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup);
802 delete[] cold.data; 780 delete[] cold.data;
803 781
804 v8::Isolate::CreateParams params; 782 v8::Isolate::CreateParams params;
805 params.snapshot_blob = &warm; 783 params.snapshot_blob = &warm;
806 params.array_buffer_allocator = CcTest::array_buffer_allocator(); 784 params.array_buffer_allocator = CcTest::array_buffer_allocator();
807 785
808 v8::Isolate* isolate = v8::Isolate::New(params); 786 v8::Isolate* isolate = v8::Isolate::New(params);
809 { 787 {
810 v8::Isolate::Scope i_scope(isolate); 788 v8::Isolate::Scope i_scope(isolate);
811 v8::HandleScope h_scope(isolate); 789 v8::HandleScope h_scope(isolate);
812 v8::Local<v8::Context> context = v8::Context::New(isolate); 790 v8::Local<v8::Context> context = v8::Context::New(isolate);
813 delete[] warm.data; 791 delete[] warm.data;
814 v8::Context::Scope c_scope(context); 792 v8::Context::Scope c_scope(context);
815 // Running the warmup script has effect on whether functions are 793 // Running the warmup script has effect on whether functions are
816 // pre-compiled, but does not pollute the context. 794 // pre-compiled, but does not pollute the context.
817 CHECK(IsCompiled("Math.abs")); 795 CHECK(IsCompiled("Math.abs"));
818 CHECK(!IsCompiled("String.raw")); 796 CHECK(!IsCompiled("String.raw"));
819 CHECK(CompileRun("Math.random")->IsFunction()); 797 CHECK(CompileRun("Math.random")->IsFunction());
820 } 798 }
821 isolate->Dispose(); 799 isolate->Dispose();
822 } 800 }
823 801
824 TEST(CustomSnapshotDataBlobWithWarmup) { 802 TEST(CustomSnapshotDataBlobWithWarmup) {
825 DisableTurbofan();
826 const char* source = 803 const char* source =
827 "function f() { return Math.abs(1); }\n" 804 "function f() { return Math.abs(1); }\n"
828 "function g() { return String.raw(1); }\n" 805 "function g() { return String.raw(1); }\n"
829 "Object.valueOf(1);" 806 "Object.valueOf(1);"
830 "var a = 5"; 807 "var a = 5";
831 const char* warmup = "a = f()"; 808 const char* warmup = "a = f()";
832 809
833 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(source); 810 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(source);
834 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); 811 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup);
835 delete[] cold.data; 812 delete[] cold.data;
(...skipping 15 matching lines...) Expand all
851 CHECK(IsCompiled("Math.abs")); 828 CHECK(IsCompiled("Math.abs"));
852 CHECK(!IsCompiled("g")); 829 CHECK(!IsCompiled("g"));
853 CHECK(!IsCompiled("String.raw")); 830 CHECK(!IsCompiled("String.raw"));
854 CHECK(!IsCompiled("Object.valueOf")); 831 CHECK(!IsCompiled("Object.valueOf"));
855 CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust()); 832 CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust());
856 } 833 }
857 isolate->Dispose(); 834 isolate->Dispose();
858 } 835 }
859 836
860 TEST(CustomSnapshotDataBlobImmortalImmovableRoots) { 837 TEST(CustomSnapshotDataBlobImmortalImmovableRoots) {
861 DisableTurbofan();
862 // Flood the startup snapshot with shared function infos. If they are 838 // Flood the startup snapshot with shared function infos. If they are
863 // serialized before the immortal immovable root, the root will no longer end 839 // serialized before the immortal immovable root, the root will no longer end
864 // up on the first page. 840 // up on the first page.
865 Vector<const uint8_t> source = 841 Vector<const uint8_t> source =
866 ConstructSource(STATIC_CHAR_VECTOR("var a = [];"), 842 ConstructSource(STATIC_CHAR_VECTOR("var a = [];"),
867 STATIC_CHAR_VECTOR("a.push(function() {return 7});"), 843 STATIC_CHAR_VECTOR("a.push(function() {return 7});"),
868 STATIC_CHAR_VECTOR("\0"), 10000); 844 STATIC_CHAR_VECTOR("\0"), 10000);
869 845
870 v8::StartupData data = v8::V8::CreateSnapshotDataBlob( 846 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(
871 reinterpret_cast<const char*>(source.start())); 847 reinterpret_cast<const char*>(source.start()));
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 1918
1943 RelocIterator rit3(copy->code(), 1919 RelocIterator rit3(copy->code(),
1944 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT)); 1920 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT));
1945 CHECK(rit3.rinfo()->target_object()->IsHeapNumber()); 1921 CHECK(rit3.rinfo()->target_object()->IsHeapNumber());
1946 CHECK_EQ(0.3, HeapNumber::cast(rit3.rinfo()->target_object())->value()); 1922 CHECK_EQ(0.3, HeapNumber::cast(rit3.rinfo()->target_object())->value());
1947 1923
1948 delete script_data; 1924 delete script_data;
1949 } 1925 }
1950 1926
1951 TEST(SnapshotCreatorMultipleContexts) { 1927 TEST(SnapshotCreatorMultipleContexts) {
1952 DisableTurbofan();
1953 v8::StartupData blob; 1928 v8::StartupData blob;
1954 { 1929 {
1955 v8::SnapshotCreator creator; 1930 v8::SnapshotCreator creator;
1956 v8::Isolate* isolate = creator.GetIsolate(); 1931 v8::Isolate* isolate = creator.GetIsolate();
1957 { 1932 {
1958 v8::HandleScope handle_scope(isolate); 1933 v8::HandleScope handle_scope(isolate);
1959 v8::Local<v8::Context> context = v8::Context::New(isolate); 1934 v8::Local<v8::Context> context = v8::Context::New(isolate);
1960 v8::Context::Scope context_scope(context); 1935 v8::Context::Scope context_scope(context);
1961 CompileRun("var f = function() { return 1; }"); 1936 CompileRun("var f = function() { return 1; }");
1962 CHECK_EQ(0, creator.AddContext(context)); 1937 CHECK_EQ(0, creator.AddContext(context));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 args.GetReturnValue().Set(v8_num(1337)); 1994 args.GetReturnValue().Set(v8_num(1337));
2020 } 1995 }
2021 1996
2022 intptr_t original_external_references[] = { 1997 intptr_t original_external_references[] = {
2023 reinterpret_cast<intptr_t>(SerializedCallback), 0}; 1998 reinterpret_cast<intptr_t>(SerializedCallback), 0};
2024 1999
2025 intptr_t replaced_external_references[] = { 2000 intptr_t replaced_external_references[] = {
2026 reinterpret_cast<intptr_t>(SerializedCallbackReplacement), 0}; 2001 reinterpret_cast<intptr_t>(SerializedCallbackReplacement), 0};
2027 2002
2028 TEST(SnapshotCreatorExternalReferences) { 2003 TEST(SnapshotCreatorExternalReferences) {
2029 DisableTurbofan();
2030 v8::StartupData blob; 2004 v8::StartupData blob;
2031 { 2005 {
2032 v8::SnapshotCreator creator(original_external_references); 2006 v8::SnapshotCreator creator(original_external_references);
2033 v8::Isolate* isolate = creator.GetIsolate(); 2007 v8::Isolate* isolate = creator.GetIsolate();
2034 { 2008 {
2035 v8::HandleScope handle_scope(isolate); 2009 v8::HandleScope handle_scope(isolate);
2036 v8::Local<v8::Context> context = v8::Context::New(isolate); 2010 v8::Local<v8::Context> context = v8::Context::New(isolate);
2037 v8::Context::Scope context_scope(context); 2011 v8::Context::Scope context_scope(context);
2038 v8::Local<v8::FunctionTemplate> callback = 2012 v8::Local<v8::FunctionTemplate> callback =
2039 v8::FunctionTemplate::New(isolate, SerializedCallback); 2013 v8::FunctionTemplate::New(isolate, SerializedCallback);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked(); 2053 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked();
2080 v8::Context::Scope context_scope(context); 2054 v8::Context::Scope context_scope(context);
2081 ExpectInt32("f()", 1337); 2055 ExpectInt32("f()", 1337);
2082 } 2056 }
2083 isolate->Dispose(); 2057 isolate->Dispose();
2084 } 2058 }
2085 delete[] blob.data; 2059 delete[] blob.data;
2086 } 2060 }
2087 2061
2088 TEST(SnapshotCreatorUnknownExternalReferences) { 2062 TEST(SnapshotCreatorUnknownExternalReferences) {
2089 DisableTurbofan();
2090 v8::SnapshotCreator creator; 2063 v8::SnapshotCreator creator;
2091 v8::Isolate* isolate = creator.GetIsolate(); 2064 v8::Isolate* isolate = creator.GetIsolate();
2092 { 2065 {
2093 v8::HandleScope handle_scope(isolate); 2066 v8::HandleScope handle_scope(isolate);
2094 v8::Local<v8::Context> context = v8::Context::New(isolate); 2067 v8::Local<v8::Context> context = v8::Context::New(isolate);
2095 v8::Context::Scope context_scope(context); 2068 v8::Context::Scope context_scope(context);
2096 2069
2097 v8::Local<v8::FunctionTemplate> callback = 2070 v8::Local<v8::FunctionTemplate> callback =
2098 v8::FunctionTemplate::New(isolate, SerializedCallback); 2071 v8::FunctionTemplate::New(isolate, SerializedCallback);
2099 v8::Local<v8::Value> function = 2072 v8::Local<v8::Value> function =
(...skipping 25 matching lines...) Expand all
2125 } 2098 }
2126 2099
2127 void DeserializeInternalFields(v8::Local<v8::Object> holder, int index, 2100 void DeserializeInternalFields(v8::Local<v8::Object> holder, int index,
2128 v8::StartupData payload) { 2101 v8::StartupData payload) {
2129 InternalFieldData* data = new InternalFieldData{0}; 2102 InternalFieldData* data = new InternalFieldData{0};
2130 memcpy(data, payload.data, payload.raw_size); 2103 memcpy(data, payload.data, payload.raw_size);
2131 holder->SetAlignedPointerInInternalField(index, data); 2104 holder->SetAlignedPointerInInternalField(index, data);
2132 } 2105 }
2133 2106
2134 TEST(SnapshotCreatorTemplates) { 2107 TEST(SnapshotCreatorTemplates) {
2135 DisableTurbofan();
2136 v8::StartupData blob; 2108 v8::StartupData blob;
2137 2109
2138 { 2110 {
2139 InternalFieldData* a1 = new InternalFieldData{11}; 2111 InternalFieldData* a1 = new InternalFieldData{11};
2140 InternalFieldData* b0 = new InternalFieldData{20}; 2112 InternalFieldData* b0 = new InternalFieldData{20};
2141 InternalFieldData* c0 = new InternalFieldData{30}; 2113 InternalFieldData* c0 = new InternalFieldData{30};
2142 InternalFieldData* c1 = new InternalFieldData{31}; 2114 InternalFieldData* c1 = new InternalFieldData{31};
2143 2115
2144 v8::SnapshotCreator creator(original_external_references); 2116 v8::SnapshotCreator creator(original_external_references);
2145 v8::Isolate* isolate = creator.GetIsolate(); 2117 v8::Isolate* isolate = creator.GetIsolate();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 } 2255 }
2284 delete[] blob.data; 2256 delete[] blob.data;
2285 } 2257 }
2286 2258
2287 TEST(SerializationMemoryStats) { 2259 TEST(SerializationMemoryStats) {
2288 FLAG_profile_deserialization = true; 2260 FLAG_profile_deserialization = true;
2289 FLAG_always_opt = false; 2261 FLAG_always_opt = false;
2290 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2262 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2291 delete[] blob.data; 2263 delete[] blob.data;
2292 } 2264 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698