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

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() { 53 void DisableAlwaysOpt() {
54 const char* flag = "--turbo-filter=\"\""; 54 // Isolates prepared for serialization do not optimize. The only exception is
55 FlagList::SetFlagsFromString(flag, StrLength(flag)); 55 // with the flag --always-opt.
56 FLAG_always_opt = false;
56 } 57 }
57 58
58 59
59 // TestIsolate is used for testing isolate serialization. 60 // TestIsolate is used for testing isolate serialization.
60 class TestIsolate : public Isolate { 61 class TestIsolate : public Isolate {
61 public: 62 public:
62 static v8::Isolate* NewInitialized(bool enable_serializer) { 63 static v8::Isolate* NewInitialized(bool enable_serializer) {
63 i::Isolate* isolate = new TestIsolate(enable_serializer); 64 i::Isolate* isolate = new TestIsolate(enable_serializer);
64 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 65 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
65 v8::Isolate::Scope isolate_scope(v8_isolate); 66 v8::Isolate::Scope isolate_scope(v8_isolate);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 #ifdef VERIFY_HEAP 144 #ifdef VERIFY_HEAP
144 isolate->heap()->Verify(); 145 isolate->heap()->Verify();
145 #endif 146 #endif
146 CHECK(isolate->global_object()->IsJSObject()); 147 CHECK(isolate->global_object()->IsJSObject());
147 CHECK(isolate->native_context()->IsContext()); 148 CHECK(isolate->native_context()->IsContext());
148 CHECK(isolate->heap()->string_table()->IsStringTable()); 149 CHECK(isolate->heap()->string_table()->IsStringTable());
149 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); 150 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
150 } 151 }
151 152
152 UNINITIALIZED_TEST(StartupSerializerOnce) { 153 UNINITIALIZED_TEST(StartupSerializerOnce) {
153 // The serialize-deserialize tests only work if the VM is built without 154 DisableAlwaysOpt();
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.
156 DisableTurbofan();
157 v8::Isolate* isolate = TestIsolate::NewInitialized(true); 155 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
158 Vector<const byte> blob = Serialize(isolate); 156 Vector<const byte> blob = Serialize(isolate);
159 isolate = Deserialize(blob); 157 isolate = Deserialize(blob);
160 blob.Dispose(); 158 blob.Dispose();
161 { 159 {
162 v8::HandleScope handle_scope(isolate); 160 v8::HandleScope handle_scope(isolate);
163 v8::Isolate::Scope isolate_scope(isolate); 161 v8::Isolate::Scope isolate_scope(isolate);
164 162
165 v8::Local<v8::Context> env = v8::Context::New(isolate); 163 v8::Local<v8::Context> env = v8::Context::New(isolate);
166 env->Enter(); 164 env->Enter();
167 165
168 SanityCheck(isolate); 166 SanityCheck(isolate);
169 } 167 }
170 isolate->Dispose(); 168 isolate->Dispose();
171 } 169 }
172 170
173 UNINITIALIZED_TEST(StartupSerializerTwice) { 171 UNINITIALIZED_TEST(StartupSerializerTwice) {
174 DisableTurbofan(); 172 DisableAlwaysOpt();
175 v8::Isolate* isolate = TestIsolate::NewInitialized(true); 173 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
176 Vector<const byte> blob1 = Serialize(isolate); 174 Vector<const byte> blob1 = Serialize(isolate);
177 Vector<const byte> blob2 = Serialize(isolate); 175 Vector<const byte> blob2 = Serialize(isolate);
178 blob1.Dispose(); 176 blob1.Dispose();
179 isolate = Deserialize(blob2); 177 isolate = Deserialize(blob2);
180 blob2.Dispose(); 178 blob2.Dispose();
181 { 179 {
182 v8::Isolate::Scope isolate_scope(isolate); 180 v8::Isolate::Scope isolate_scope(isolate);
183 v8::HandleScope handle_scope(isolate); 181 v8::HandleScope handle_scope(isolate);
184 182
185 v8::Local<v8::Context> env = v8::Context::New(isolate); 183 v8::Local<v8::Context> env = v8::Context::New(isolate);
186 env->Enter(); 184 env->Enter();
187 185
188 SanityCheck(isolate); 186 SanityCheck(isolate);
189 } 187 }
190 isolate->Dispose(); 188 isolate->Dispose();
191 } 189 }
192 190
193 UNINITIALIZED_TEST(StartupSerializerOnceRunScript) { 191 UNINITIALIZED_TEST(StartupSerializerOnceRunScript) {
194 DisableTurbofan(); 192 DisableAlwaysOpt();
195 v8::Isolate* isolate = TestIsolate::NewInitialized(true); 193 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
196 Vector<const byte> blob = Serialize(isolate); 194 Vector<const byte> blob = Serialize(isolate);
197 isolate = Deserialize(blob); 195 isolate = Deserialize(blob);
198 blob.Dispose(); 196 blob.Dispose();
199 { 197 {
200 v8::Isolate::Scope isolate_scope(isolate); 198 v8::Isolate::Scope isolate_scope(isolate);
201 v8::HandleScope handle_scope(isolate); 199 v8::HandleScope handle_scope(isolate);
202 200
203 201
204 v8::Local<v8::Context> env = v8::Context::New(isolate); 202 v8::Local<v8::Context> env = v8::Context::New(isolate);
205 env->Enter(); 203 env->Enter();
206 204
207 const char* c_source = "\"1234\".length"; 205 const char* c_source = "\"1234\".length";
208 v8::Local<v8::Script> script = v8_compile(c_source); 206 v8::Local<v8::Script> script = v8_compile(c_source);
209 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext()) 207 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext())
210 .ToLocalChecked() 208 .ToLocalChecked()
211 ->Int32Value(isolate->GetCurrentContext()); 209 ->Int32Value(isolate->GetCurrentContext());
212 CHECK_EQ(4, result.FromJust()); 210 CHECK_EQ(4, result.FromJust());
213 } 211 }
214 isolate->Dispose(); 212 isolate->Dispose();
215 } 213 }
216 214
217 UNINITIALIZED_TEST(StartupSerializerTwiceRunScript) { 215 UNINITIALIZED_TEST(StartupSerializerTwiceRunScript) {
218 DisableTurbofan(); 216 DisableAlwaysOpt();
219 v8::Isolate* isolate = TestIsolate::NewInitialized(true); 217 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
220 Vector<const byte> blob1 = Serialize(isolate); 218 Vector<const byte> blob1 = Serialize(isolate);
221 Vector<const byte> blob2 = Serialize(isolate); 219 Vector<const byte> blob2 = Serialize(isolate);
222 blob1.Dispose(); 220 blob1.Dispose();
223 isolate = Deserialize(blob2); 221 isolate = Deserialize(blob2);
224 blob2.Dispose(); 222 blob2.Dispose();
225 { 223 {
226 v8::Isolate::Scope isolate_scope(isolate); 224 v8::Isolate::Scope isolate_scope(isolate);
227 v8::HandleScope handle_scope(isolate); 225 v8::HandleScope handle_scope(isolate);
228 226
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 SnapshotData partial_snapshot(&partial_serializer); 294 SnapshotData partial_snapshot(&partial_serializer);
297 295
298 *partial_blob_out = WritePayload(partial_snapshot.RawData()); 296 *partial_blob_out = WritePayload(partial_snapshot.RawData());
299 *startup_blob_out = WritePayload(startup_snapshot.RawData()); 297 *startup_blob_out = WritePayload(startup_snapshot.RawData());
300 } 298 }
301 v8_isolate->Exit(); 299 v8_isolate->Exit();
302 v8_isolate->Dispose(); 300 v8_isolate->Dispose();
303 } 301 }
304 302
305 UNINITIALIZED_TEST(PartialSerializerObject) { 303 UNINITIALIZED_TEST(PartialSerializerObject) {
306 DisableTurbofan(); 304 DisableAlwaysOpt();
307 Vector<const byte> startup_blob; 305 Vector<const byte> startup_blob;
308 Vector<const byte> partial_blob; 306 Vector<const byte> partial_blob;
309 PartiallySerializeObject(&startup_blob, &partial_blob); 307 PartiallySerializeObject(&startup_blob, &partial_blob);
310 308
311 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob); 309 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob);
312 startup_blob.Dispose(); 310 startup_blob.Dispose();
313 CHECK(v8_isolate); 311 CHECK(v8_isolate);
314 { 312 {
315 v8::Isolate::Scope isolate_scope(v8_isolate); 313 v8::Isolate::Scope isolate_scope(v8_isolate);
316 314
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 SnapshotData startup_snapshot(&startup_serializer); 392 SnapshotData startup_snapshot(&startup_serializer);
395 SnapshotData partial_snapshot(&partial_serializer); 393 SnapshotData partial_snapshot(&partial_serializer);
396 394
397 *partial_blob_out = WritePayload(partial_snapshot.RawData()); 395 *partial_blob_out = WritePayload(partial_snapshot.RawData());
398 *startup_blob_out = WritePayload(startup_snapshot.RawData()); 396 *startup_blob_out = WritePayload(startup_snapshot.RawData());
399 } 397 }
400 v8_isolate->Dispose(); 398 v8_isolate->Dispose();
401 } 399 }
402 400
403 UNINITIALIZED_TEST(PartialSerializerContext) { 401 UNINITIALIZED_TEST(PartialSerializerContext) {
404 DisableTurbofan(); 402 DisableAlwaysOpt();
405 Vector<const byte> startup_blob; 403 Vector<const byte> startup_blob;
406 Vector<const byte> partial_blob; 404 Vector<const byte> partial_blob;
407 PartiallySerializeContext(&startup_blob, &partial_blob); 405 PartiallySerializeContext(&startup_blob, &partial_blob);
408 406
409 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob); 407 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob);
410 CHECK(v8_isolate); 408 CHECK(v8_isolate);
411 startup_blob.Dispose(); 409 startup_blob.Dispose();
412 { 410 {
413 v8::Isolate::Scope isolate_scope(v8_isolate); 411 v8::Isolate::Scope isolate_scope(v8_isolate);
414 412
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 SnapshotData startup_snapshot(&startup_serializer); 511 SnapshotData startup_snapshot(&startup_serializer);
514 SnapshotData partial_snapshot(&partial_serializer); 512 SnapshotData partial_snapshot(&partial_serializer);
515 513
516 *partial_blob_out = WritePayload(partial_snapshot.RawData()); 514 *partial_blob_out = WritePayload(partial_snapshot.RawData());
517 *startup_blob_out = WritePayload(startup_snapshot.RawData()); 515 *startup_blob_out = WritePayload(startup_snapshot.RawData());
518 } 516 }
519 v8_isolate->Dispose(); 517 v8_isolate->Dispose();
520 } 518 }
521 519
522 UNINITIALIZED_TEST(PartialSerializerCustomContext) { 520 UNINITIALIZED_TEST(PartialSerializerCustomContext) {
523 DisableTurbofan(); 521 DisableAlwaysOpt();
524 Vector<const byte> startup_blob; 522 Vector<const byte> startup_blob;
525 Vector<const byte> partial_blob; 523 Vector<const byte> partial_blob;
526 PartiallySerializeCustomContext(&startup_blob, &partial_blob); 524 PartiallySerializeCustomContext(&startup_blob, &partial_blob);
527 525
528 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob); 526 v8::Isolate* v8_isolate = InitializeFromBlob(startup_blob);
529 CHECK(v8_isolate); 527 CHECK(v8_isolate);
530 startup_blob.Dispose(); 528 startup_blob.Dispose();
531 { 529 {
532 v8::Isolate::Scope isolate_scope(v8_isolate); 530 v8::Isolate::Scope isolate_scope(v8_isolate);
533 531
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 ->Int32Value(v8_isolate->GetCurrentContext()) 601 ->Int32Value(v8_isolate->GetCurrentContext())
604 .FromJust(); 602 .FromJust();
605 CHECK_EQ(100002, b); 603 CHECK_EQ(100002, b);
606 } 604 }
607 partial_blob.Dispose(); 605 partial_blob.Dispose();
608 } 606 }
609 v8_isolate->Dispose(); 607 v8_isolate->Dispose();
610 } 608 }
611 609
612 TEST(CustomSnapshotDataBlob1) { 610 TEST(CustomSnapshotDataBlob1) {
613 DisableTurbofan(); 611 DisableAlwaysOpt();
614 const char* source1 = "function f() { return 42; }"; 612 const char* source1 = "function f() { return 42; }";
615 613
616 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); 614 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
617 615
618 v8::Isolate::CreateParams params1; 616 v8::Isolate::CreateParams params1;
619 params1.snapshot_blob = &data1; 617 params1.snapshot_blob = &data1;
620 params1.array_buffer_allocator = CcTest::array_buffer_allocator(); 618 params1.array_buffer_allocator = CcTest::array_buffer_allocator();
621 619
622 v8::Isolate* isolate1 = v8::Isolate::New(params1); 620 v8::Isolate* isolate1 = v8::Isolate::New(params1);
623 { 621 {
624 v8::Isolate::Scope i_scope(isolate1); 622 v8::Isolate::Scope i_scope(isolate1);
625 v8::HandleScope h_scope(isolate1); 623 v8::HandleScope h_scope(isolate1);
626 v8::Local<v8::Context> context = v8::Context::New(isolate1); 624 v8::Local<v8::Context> context = v8::Context::New(isolate1);
627 delete[] data1.data; // We can dispose of the snapshot blob now. 625 delete[] data1.data; // We can dispose of the snapshot blob now.
628 v8::Context::Scope c_scope(context); 626 v8::Context::Scope c_scope(context);
629 v8::Maybe<int32_t> result = 627 v8::Maybe<int32_t> result =
630 CompileRun("f()")->Int32Value(isolate1->GetCurrentContext()); 628 CompileRun("f()")->Int32Value(isolate1->GetCurrentContext());
631 CHECK_EQ(42, result.FromJust()); 629 CHECK_EQ(42, result.FromJust());
632 CHECK(CompileRun("this.g")->IsUndefined()); 630 CHECK(CompileRun("this.g")->IsUndefined());
633 } 631 }
634 isolate1->Dispose(); 632 isolate1->Dispose();
635 } 633 }
636 634
637 TEST(CustomSnapshotDataBlob2) { 635 TEST(CustomSnapshotDataBlob2) {
638 DisableTurbofan(); 636 DisableAlwaysOpt();
639 const char* source2 = 637 const char* source2 =
640 "function f() { return g() * 2; }" 638 "function f() { return g() * 2; }"
641 "function g() { return 43; }" 639 "function g() { return 43; }"
642 "/./.test('a')"; 640 "/./.test('a')";
643 641
644 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); 642 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2);
645 643
646 v8::Isolate::CreateParams params2; 644 v8::Isolate::CreateParams params2;
647 params2.snapshot_blob = &data2; 645 params2.snapshot_blob = &data2;
648 params2.array_buffer_allocator = CcTest::array_buffer_allocator(); 646 params2.array_buffer_allocator = CcTest::array_buffer_allocator();
(...skipping 12 matching lines...) Expand all
661 } 659 }
662 isolate2->Dispose(); 660 isolate2->Dispose();
663 } 661 }
664 662
665 static void SerializationFunctionTemplate( 663 static void SerializationFunctionTemplate(
666 const v8::FunctionCallbackInfo<v8::Value>& args) { 664 const v8::FunctionCallbackInfo<v8::Value>& args) {
667 args.GetReturnValue().Set(args[0]); 665 args.GetReturnValue().Set(args[0]);
668 } 666 }
669 667
670 TEST(CustomSnapshotDataBlobOutdatedContextWithOverflow) { 668 TEST(CustomSnapshotDataBlobOutdatedContextWithOverflow) {
671 DisableTurbofan(); 669 DisableAlwaysOpt();
672
673 const char* source1 = 670 const char* source1 =
674 "var o = {};" 671 "var o = {};"
675 "(function() {" 672 "(function() {"
676 " function f1(x) { return f2(x) instanceof Array; }" 673 " function f1(x) { return f2(x) instanceof Array; }"
677 " function f2(x) { return foo.bar(x); }" 674 " function f2(x) { return foo.bar(x); }"
678 " o.a = f2.bind(null);" 675 " o.a = f2.bind(null);"
679 " o.b = 1;" 676 " o.b = 1;"
680 " o.c = 2;" 677 " o.c = 2;"
681 " o.d = 3;" 678 " o.d = 3;"
682 " o.e = 4;" 679 " o.e = 4;"
(...skipping 24 matching lines...) Expand all
707 v8::Context::Scope c_scope(context); 704 v8::Context::Scope c_scope(context);
708 v8::Local<v8::Value> result = CompileRun(source2); 705 v8::Local<v8::Value> result = CompileRun(source2);
709 v8::Maybe<bool> compare = v8_str("42")->Equals( 706 v8::Maybe<bool> compare = v8_str("42")->Equals(
710 v8::Isolate::GetCurrent()->GetCurrentContext(), result); 707 v8::Isolate::GetCurrent()->GetCurrentContext(), result);
711 CHECK(compare.FromJust()); 708 CHECK(compare.FromJust());
712 } 709 }
713 isolate->Dispose(); 710 isolate->Dispose();
714 } 711 }
715 712
716 TEST(CustomSnapshotDataBlobWithLocker) { 713 TEST(CustomSnapshotDataBlobWithLocker) {
717 DisableTurbofan(); 714 DisableAlwaysOpt();
718 v8::Isolate::CreateParams create_params; 715 v8::Isolate::CreateParams create_params;
719 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); 716 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
720 v8::Isolate* isolate0 = v8::Isolate::New(create_params); 717 v8::Isolate* isolate0 = v8::Isolate::New(create_params);
721 { 718 {
722 v8::Locker locker(isolate0); 719 v8::Locker locker(isolate0);
723 v8::Isolate::Scope i_scope(isolate0); 720 v8::Isolate::Scope i_scope(isolate0);
724 v8::HandleScope h_scope(isolate0); 721 v8::HandleScope h_scope(isolate0);
725 v8::Local<v8::Context> context = v8::Context::New(isolate0); 722 v8::Local<v8::Context> context = v8::Context::New(isolate0);
726 v8::Context::Scope c_scope(context); 723 v8::Context::Scope c_scope(context);
727 v8::Maybe<int32_t> result = 724 v8::Maybe<int32_t> result =
(...skipping 17 matching lines...) Expand all
745 v8::Local<v8::Context> context = v8::Context::New(isolate1); 742 v8::Local<v8::Context> context = v8::Context::New(isolate1);
746 delete[] data1.data; // We can dispose of the snapshot blob now. 743 delete[] data1.data; // We can dispose of the snapshot blob now.
747 v8::Context::Scope c_scope(context); 744 v8::Context::Scope c_scope(context);
748 v8::Maybe<int32_t> result = CompileRun("f()")->Int32Value(context); 745 v8::Maybe<int32_t> result = CompileRun("f()")->Int32Value(context);
749 CHECK_EQ(42, result.FromJust()); 746 CHECK_EQ(42, result.FromJust());
750 } 747 }
751 isolate1->Dispose(); 748 isolate1->Dispose();
752 } 749 }
753 750
754 TEST(CustomSnapshotDataBlobStackOverflow) { 751 TEST(CustomSnapshotDataBlobStackOverflow) {
755 DisableTurbofan(); 752 DisableAlwaysOpt();
756 const char* source = 753 const char* source =
757 "var a = [0];" 754 "var a = [0];"
758 "var b = a;" 755 "var b = a;"
759 "for (var i = 0; i < 10000; i++) {" 756 "for (var i = 0; i < 10000; i++) {"
760 " var c = [i];" 757 " var c = [i];"
761 " b.push(c);" 758 " b.push(c);"
762 " b.push(c);" 759 " b.push(c);"
763 " b = c;" 760 " b = c;"
764 "}"; 761 "}";
765 762
(...skipping 25 matching lines...) Expand all
791 } 788 }
792 789
793 bool IsCompiled(const char* name) { 790 bool IsCompiled(const char* name) {
794 return i::Handle<i::JSFunction>::cast( 791 return i::Handle<i::JSFunction>::cast(
795 v8::Utils::OpenHandle(*CompileRun(name))) 792 v8::Utils::OpenHandle(*CompileRun(name)))
796 ->shared() 793 ->shared()
797 ->is_compiled(); 794 ->is_compiled();
798 } 795 }
799 796
800 TEST(SnapshotDataBlobWithWarmup) { 797 TEST(SnapshotDataBlobWithWarmup) {
801 DisableTurbofan(); 798 DisableAlwaysOpt();
802 const char* warmup = "Math.abs(1); Math.random = 1;"; 799 const char* warmup = "Math.abs(1); Math.random = 1;";
803 800
804 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(); 801 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob();
805 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); 802 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup);
806 delete[] cold.data; 803 delete[] cold.data;
807 804
808 v8::Isolate::CreateParams params; 805 v8::Isolate::CreateParams params;
809 params.snapshot_blob = &warm; 806 params.snapshot_blob = &warm;
810 params.array_buffer_allocator = CcTest::array_buffer_allocator(); 807 params.array_buffer_allocator = CcTest::array_buffer_allocator();
811 808
812 v8::Isolate* isolate = v8::Isolate::New(params); 809 v8::Isolate* isolate = v8::Isolate::New(params);
813 { 810 {
814 v8::Isolate::Scope i_scope(isolate); 811 v8::Isolate::Scope i_scope(isolate);
815 v8::HandleScope h_scope(isolate); 812 v8::HandleScope h_scope(isolate);
816 v8::Local<v8::Context> context = v8::Context::New(isolate); 813 v8::Local<v8::Context> context = v8::Context::New(isolate);
817 delete[] warm.data; 814 delete[] warm.data;
818 v8::Context::Scope c_scope(context); 815 v8::Context::Scope c_scope(context);
819 // Running the warmup script has effect on whether functions are 816 // Running the warmup script has effect on whether functions are
820 // pre-compiled, but does not pollute the context. 817 // pre-compiled, but does not pollute the context.
821 CHECK(IsCompiled("Math.abs")); 818 CHECK(IsCompiled("Math.abs"));
822 CHECK(!IsCompiled("String.raw")); 819 CHECK(!IsCompiled("String.raw"));
823 CHECK(CompileRun("Math.random")->IsFunction()); 820 CHECK(CompileRun("Math.random")->IsFunction());
824 } 821 }
825 isolate->Dispose(); 822 isolate->Dispose();
826 } 823 }
827 824
828 TEST(CustomSnapshotDataBlobWithWarmup) { 825 TEST(CustomSnapshotDataBlobWithWarmup) {
829 DisableTurbofan(); 826 DisableAlwaysOpt();
830 const char* source = 827 const char* source =
831 "function f() { return Math.abs(1); }\n" 828 "function f() { return Math.abs(1); }\n"
832 "function g() { return String.raw(1); }\n" 829 "function g() { return String.raw(1); }\n"
833 "Object.valueOf(1);" 830 "Object.valueOf(1);"
834 "var a = 5"; 831 "var a = 5";
835 const char* warmup = "a = f()"; 832 const char* warmup = "a = f()";
836 833
837 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(source); 834 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(source);
838 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); 835 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup);
839 delete[] cold.data; 836 delete[] cold.data;
(...skipping 15 matching lines...) Expand all
855 CHECK(IsCompiled("Math.abs")); 852 CHECK(IsCompiled("Math.abs"));
856 CHECK(!IsCompiled("g")); 853 CHECK(!IsCompiled("g"));
857 CHECK(!IsCompiled("String.raw")); 854 CHECK(!IsCompiled("String.raw"));
858 CHECK(!IsCompiled("Object.valueOf")); 855 CHECK(!IsCompiled("Object.valueOf"));
859 CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust()); 856 CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust());
860 } 857 }
861 isolate->Dispose(); 858 isolate->Dispose();
862 } 859 }
863 860
864 TEST(CustomSnapshotDataBlobImmortalImmovableRoots) { 861 TEST(CustomSnapshotDataBlobImmortalImmovableRoots) {
865 DisableTurbofan(); 862 DisableAlwaysOpt();
866 // Flood the startup snapshot with shared function infos. If they are 863 // Flood the startup snapshot with shared function infos. If they are
867 // serialized before the immortal immovable root, the root will no longer end 864 // serialized before the immortal immovable root, the root will no longer end
868 // up on the first page. 865 // up on the first page.
869 Vector<const uint8_t> source = 866 Vector<const uint8_t> source =
870 ConstructSource(STATIC_CHAR_VECTOR("var a = [];"), 867 ConstructSource(STATIC_CHAR_VECTOR("var a = [];"),
871 STATIC_CHAR_VECTOR("a.push(function() {return 7});"), 868 STATIC_CHAR_VECTOR("a.push(function() {return 7});"),
872 STATIC_CHAR_VECTOR("\0"), 10000); 869 STATIC_CHAR_VECTOR("\0"), 10000);
873 870
874 v8::StartupData data = v8::V8::CreateSnapshotDataBlob( 871 v8::StartupData data = v8::V8::CreateSnapshotDataBlob(
875 reinterpret_cast<const char*>(source.start())); 872 reinterpret_cast<const char*>(source.start()));
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 1943
1947 RelocIterator rit3(copy->code(), 1944 RelocIterator rit3(copy->code(),
1948 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT)); 1945 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT));
1949 CHECK(rit3.rinfo()->target_object()->IsHeapNumber()); 1946 CHECK(rit3.rinfo()->target_object()->IsHeapNumber());
1950 CHECK_EQ(0.3, HeapNumber::cast(rit3.rinfo()->target_object())->value()); 1947 CHECK_EQ(0.3, HeapNumber::cast(rit3.rinfo()->target_object())->value());
1951 1948
1952 delete script_data; 1949 delete script_data;
1953 } 1950 }
1954 1951
1955 TEST(SnapshotCreatorMultipleContexts) { 1952 TEST(SnapshotCreatorMultipleContexts) {
1956 DisableTurbofan(); 1953 DisableAlwaysOpt();
1957 v8::StartupData blob; 1954 v8::StartupData blob;
1958 { 1955 {
1959 v8::SnapshotCreator creator; 1956 v8::SnapshotCreator creator;
1960 v8::Isolate* isolate = creator.GetIsolate(); 1957 v8::Isolate* isolate = creator.GetIsolate();
1961 { 1958 {
1962 v8::HandleScope handle_scope(isolate); 1959 v8::HandleScope handle_scope(isolate);
1963 v8::Local<v8::Context> context = v8::Context::New(isolate); 1960 v8::Local<v8::Context> context = v8::Context::New(isolate);
1964 v8::Context::Scope context_scope(context); 1961 v8::Context::Scope context_scope(context);
1965 CompileRun("var f = function() { return 1; }"); 1962 CompileRun("var f = function() { return 1; }");
1966 CHECK_EQ(0, creator.AddContext(context)); 1963 CHECK_EQ(0, creator.AddContext(context));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 args.GetReturnValue().Set(v8_num(1337)); 2020 args.GetReturnValue().Set(v8_num(1337));
2024 } 2021 }
2025 2022
2026 intptr_t original_external_references[] = { 2023 intptr_t original_external_references[] = {
2027 reinterpret_cast<intptr_t>(SerializedCallback), 0}; 2024 reinterpret_cast<intptr_t>(SerializedCallback), 0};
2028 2025
2029 intptr_t replaced_external_references[] = { 2026 intptr_t replaced_external_references[] = {
2030 reinterpret_cast<intptr_t>(SerializedCallbackReplacement), 0}; 2027 reinterpret_cast<intptr_t>(SerializedCallbackReplacement), 0};
2031 2028
2032 TEST(SnapshotCreatorExternalReferences) { 2029 TEST(SnapshotCreatorExternalReferences) {
2033 DisableTurbofan(); 2030 DisableAlwaysOpt();
2034 v8::StartupData blob; 2031 v8::StartupData blob;
2035 { 2032 {
2036 v8::SnapshotCreator creator(original_external_references); 2033 v8::SnapshotCreator creator(original_external_references);
2037 v8::Isolate* isolate = creator.GetIsolate(); 2034 v8::Isolate* isolate = creator.GetIsolate();
2038 { 2035 {
2039 v8::HandleScope handle_scope(isolate); 2036 v8::HandleScope handle_scope(isolate);
2040 v8::Local<v8::Context> context = v8::Context::New(isolate); 2037 v8::Local<v8::Context> context = v8::Context::New(isolate);
2041 v8::Context::Scope context_scope(context); 2038 v8::Context::Scope context_scope(context);
2042 v8::Local<v8::FunctionTemplate> callback = 2039 v8::Local<v8::FunctionTemplate> callback =
2043 v8::FunctionTemplate::New(isolate, SerializedCallback); 2040 v8::FunctionTemplate::New(isolate, SerializedCallback);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked(); 2080 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked();
2084 v8::Context::Scope context_scope(context); 2081 v8::Context::Scope context_scope(context);
2085 ExpectInt32("f()", 1337); 2082 ExpectInt32("f()", 1337);
2086 } 2083 }
2087 isolate->Dispose(); 2084 isolate->Dispose();
2088 } 2085 }
2089 delete[] blob.data; 2086 delete[] blob.data;
2090 } 2087 }
2091 2088
2092 TEST(SnapshotCreatorUnknownExternalReferences) { 2089 TEST(SnapshotCreatorUnknownExternalReferences) {
2093 DisableTurbofan(); 2090 DisableAlwaysOpt();
2094 v8::SnapshotCreator creator; 2091 v8::SnapshotCreator creator;
2095 v8::Isolate* isolate = creator.GetIsolate(); 2092 v8::Isolate* isolate = creator.GetIsolate();
2096 { 2093 {
2097 v8::HandleScope handle_scope(isolate); 2094 v8::HandleScope handle_scope(isolate);
2098 v8::Local<v8::Context> context = v8::Context::New(isolate); 2095 v8::Local<v8::Context> context = v8::Context::New(isolate);
2099 v8::Context::Scope context_scope(context); 2096 v8::Context::Scope context_scope(context);
2100 2097
2101 v8::Local<v8::FunctionTemplate> callback = 2098 v8::Local<v8::FunctionTemplate> callback =
2102 v8::FunctionTemplate::New(isolate, SerializedCallback); 2099 v8::FunctionTemplate::New(isolate, SerializedCallback);
2103 v8::Local<v8::Value> function = 2100 v8::Local<v8::Value> function =
(...skipping 25 matching lines...) Expand all
2129 } 2126 }
2130 2127
2131 void DeserializeInternalFields(v8::Local<v8::Object> holder, int index, 2128 void DeserializeInternalFields(v8::Local<v8::Object> holder, int index,
2132 v8::StartupData payload) { 2129 v8::StartupData payload) {
2133 InternalFieldData* data = new InternalFieldData{0}; 2130 InternalFieldData* data = new InternalFieldData{0};
2134 memcpy(data, payload.data, payload.raw_size); 2131 memcpy(data, payload.data, payload.raw_size);
2135 holder->SetAlignedPointerInInternalField(index, data); 2132 holder->SetAlignedPointerInInternalField(index, data);
2136 } 2133 }
2137 2134
2138 TEST(SnapshotCreatorTemplates) { 2135 TEST(SnapshotCreatorTemplates) {
2139 DisableTurbofan(); 2136 DisableAlwaysOpt();
2140 v8::StartupData blob; 2137 v8::StartupData blob;
2141 2138
2142 { 2139 {
2143 InternalFieldData* a1 = new InternalFieldData{11}; 2140 InternalFieldData* a1 = new InternalFieldData{11};
2144 InternalFieldData* b0 = new InternalFieldData{20}; 2141 InternalFieldData* b0 = new InternalFieldData{20};
2145 InternalFieldData* c0 = new InternalFieldData{30}; 2142 InternalFieldData* c0 = new InternalFieldData{30};
2146 InternalFieldData* c1 = new InternalFieldData{31}; 2143 InternalFieldData* c1 = new InternalFieldData{31};
2147 2144
2148 v8::SnapshotCreator creator(original_external_references); 2145 v8::SnapshotCreator creator(original_external_references);
2149 v8::Isolate* isolate = creator.GetIsolate(); 2146 v8::Isolate* isolate = creator.GetIsolate();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 } 2284 }
2288 delete[] blob.data; 2285 delete[] blob.data;
2289 } 2286 }
2290 2287
2291 TEST(SerializationMemoryStats) { 2288 TEST(SerializationMemoryStats) {
2292 FLAG_profile_deserialization = true; 2289 FLAG_profile_deserialization = true;
2293 FLAG_always_opt = false; 2290 FLAG_always_opt = false;
2294 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2291 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2295 delete[] blob.data; 2292 delete[] blob.data;
2296 } 2293 }
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