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

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

Issue 1371363006: Continuing removing deprecated function from cctest (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed a bug in test-serialize.cc. Created 5 years, 2 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 | « test/cctest/test-sampler-api.cc ('k') | test/cctest/test-simd.cc » ('j') | 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // TODO(mythria): Remove this define after this flag is turned on globally
29 #define V8_IMMINENT_DEPRECATION_WARNINGS
30
28 #include <signal.h> 31 #include <signal.h>
29 32
30 #include <sys/stat.h> 33 #include <sys/stat.h>
31 34
32 #include "src/v8.h" 35 #include "src/v8.h"
33 36
34 #include "src/bootstrapper.h" 37 #include "src/bootstrapper.h"
35 #include "src/compilation-cache.h" 38 #include "src/compilation-cache.h"
36 #include "src/debug/debug.h" 39 #include "src/debug/debug.h"
37 #include "src/heap/spaces.h" 40 #include "src/heap/spaces.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 v8::Isolate* isolate = Deserialize(); 240 v8::Isolate* isolate = Deserialize();
238 { 241 {
239 v8::Isolate::Scope isolate_scope(isolate); 242 v8::Isolate::Scope isolate_scope(isolate);
240 v8::HandleScope handle_scope(isolate); 243 v8::HandleScope handle_scope(isolate);
241 244
242 245
243 v8::Local<v8::Context> env = v8::Context::New(isolate); 246 v8::Local<v8::Context> env = v8::Context::New(isolate);
244 env->Enter(); 247 env->Enter();
245 248
246 const char* c_source = "\"1234\".length"; 249 const char* c_source = "\"1234\".length";
247 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); 250 v8::Local<v8::Script> script = v8_compile(c_source);
248 v8::Local<v8::Script> script = v8::Script::Compile(source); 251 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext())
249 CHECK_EQ(4, script->Run()->Int32Value()); 252 .ToLocalChecked()
253 ->Int32Value(isolate->GetCurrentContext());
254 CHECK_EQ(4, result.FromJust());
250 } 255 }
251 isolate->Dispose(); 256 isolate->Dispose();
252 } 257 }
253 258
254 259
255 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, 260 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
256 SerializeTwice) { 261 SerializeTwice) {
257 DisableTurbofan(); 262 DisableTurbofan();
258 if (DefaultSnapshotAvailable()) return; 263 if (DefaultSnapshotAvailable()) return;
259 v8::Isolate* isolate = Deserialize(); 264 v8::Isolate* isolate = Deserialize();
260 { 265 {
261 v8::Isolate::Scope isolate_scope(isolate); 266 v8::Isolate::Scope isolate_scope(isolate);
262 v8::HandleScope handle_scope(isolate); 267 v8::HandleScope handle_scope(isolate);
263 268
264 v8::Local<v8::Context> env = v8::Context::New(isolate); 269 v8::Local<v8::Context> env = v8::Context::New(isolate);
265 env->Enter(); 270 env->Enter();
266 271
267 const char* c_source = "\"1234\".length"; 272 const char* c_source = "\"1234\".length";
268 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); 273 v8::Local<v8::Script> script = v8_compile(c_source);
269 v8::Local<v8::Script> script = v8::Script::Compile(source); 274 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext())
270 CHECK_EQ(4, script->Run()->Int32Value()); 275 .ToLocalChecked()
276 ->Int32Value(isolate->GetCurrentContext());
277 CHECK_EQ(4, result.FromJust());
271 } 278 }
272 isolate->Dispose(); 279 isolate->Dispose();
273 } 280 }
274 281
275 282
276 UNINITIALIZED_TEST(PartialSerialization) { 283 UNINITIALIZED_TEST(PartialSerialization) {
277 DisableTurbofan(); 284 DisableTurbofan();
278 if (DefaultSnapshotAvailable()) return; 285 if (DefaultSnapshotAvailable()) return;
279 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); 286 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true);
280 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 287 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
(...skipping 17 matching lines...) Expand all
298 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { 305 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
299 isolate->bootstrapper()->SourceLookup<Natives>(i); 306 isolate->bootstrapper()->SourceLookup<Natives>(i);
300 } 307 }
301 } 308 }
302 heap->CollectAllGarbage(); 309 heap->CollectAllGarbage();
303 heap->CollectAllGarbage(); 310 heap->CollectAllGarbage();
304 311
305 Object* raw_foo; 312 Object* raw_foo;
306 { 313 {
307 v8::HandleScope handle_scope(v8_isolate); 314 v8::HandleScope handle_scope(v8_isolate);
308 v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo"); 315 v8::Local<v8::String> foo = v8_str("foo");
309 DCHECK(!foo.IsEmpty()); 316 DCHECK(!foo.IsEmpty());
310 raw_foo = *(v8::Utils::OpenHandle(*foo)); 317 raw_foo = *(v8::Utils::OpenHandle(*foo));
311 } 318 }
312 319
313 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 320 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
314 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 321 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
315 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 322 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
316 323
317 { 324 {
318 v8::HandleScope handle_scope(v8_isolate); 325 v8::HandleScope handle_scope(v8_isolate);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 "})();" 544 "})();"
538 "var o = this;" 545 "var o = this;"
539 "var r = Math.random() + Math.cos(0);" 546 "var r = Math.random() + Math.cos(0);"
540 "var f = (function(a, b) { return a + b; }).bind(1, 2, 3);" 547 "var f = (function(a, b) { return a + b; }).bind(1, 2, 3);"
541 "var s = parseInt('12345');"); 548 "var s = parseInt('12345');");
542 549
543 Vector<const uint8_t> source = ConstructSource( 550 Vector<const uint8_t> source = ConstructSource(
544 STATIC_CHAR_VECTOR("function g() { return [,"), 551 STATIC_CHAR_VECTOR("function g() { return [,"),
545 STATIC_CHAR_VECTOR("1,"), 552 STATIC_CHAR_VECTOR("1,"),
546 STATIC_CHAR_VECTOR("];} a = g(); b = g(); b.push(1);"), 100000); 553 STATIC_CHAR_VECTOR("];} a = g(); b = g(); b.push(1);"), 100000);
547 v8::Handle<v8::String> source_str = v8::String::NewFromOneByte( 554 v8::MaybeLocal<v8::String> source_str = v8::String::NewFromOneByte(
548 v8_isolate, source.start(), v8::String::kNormalString, 555 v8_isolate, source.start(), v8::NewStringType::kNormal,
549 source.length()); 556 source.length());
550 CompileRun(source_str); 557 CompileRun(source_str.ToLocalChecked());
551 source.Dispose(); 558 source.Dispose();
552 } 559 }
553 // Make sure all builtin scripts are cached. 560 // Make sure all builtin scripts are cached.
554 { 561 {
555 HandleScope scope(isolate); 562 HandleScope scope(isolate);
556 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { 563 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
557 isolate->bootstrapper()->SourceLookup<Natives>(i); 564 isolate->bootstrapper()->SourceLookup<Natives>(i);
558 } 565 }
559 } 566 }
560 // If we don't do this then we end up with a stray root pointing at the 567 // If we don't do this then we end up with a stray root pointing at the
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 CHECK_EQ(3, outdated_contexts->length()); 641 CHECK_EQ(3, outdated_contexts->length());
635 } 642 }
636 CHECK(root->IsContext()); 643 CHECK(root->IsContext());
637 Handle<Context> context = Handle<Context>::cast(root); 644 Handle<Context> context = Handle<Context>::cast(root);
638 CHECK(context->global_proxy() == *global_proxy); 645 CHECK(context->global_proxy() == *global_proxy);
639 Handle<String> o = isolate->factory()->NewStringFromAsciiChecked("o"); 646 Handle<String> o = isolate->factory()->NewStringFromAsciiChecked("o");
640 Handle<JSObject> global_object(context->global_object(), isolate); 647 Handle<JSObject> global_object(context->global_object(), isolate);
641 Handle<Object> property = JSReceiver::GetDataProperty(global_object, o); 648 Handle<Object> property = JSReceiver::GetDataProperty(global_object, o);
642 CHECK(property.is_identical_to(global_proxy)); 649 CHECK(property.is_identical_to(global_proxy));
643 650
644 v8::Handle<v8::Context> v8_context = v8::Utils::ToLocal(context); 651 v8::Local<v8::Context> v8_context = v8::Utils::ToLocal(context);
645 v8::Context::Scope context_scope(v8_context); 652 v8::Context::Scope context_scope(v8_context);
646 double r = CompileRun("r")->ToNumber(v8_isolate)->Value(); 653 double r = CompileRun("r")
654 ->ToNumber(v8_isolate->GetCurrentContext())
655 .ToLocalChecked()
656 ->Value();
647 CHECK(r >= 1 && r <= 2); 657 CHECK(r >= 1 && r <= 2);
648 int f = CompileRun("f()")->ToNumber(v8_isolate)->Int32Value(); 658 int f = CompileRun("f()")
659 ->ToNumber(v8_isolate->GetCurrentContext())
660 .ToLocalChecked()
661 ->Int32Value(v8_isolate->GetCurrentContext())
662 .FromJust();
649 CHECK_EQ(5, f); 663 CHECK_EQ(5, f);
650 f = CompileRun("e('f()')")->ToNumber(v8_isolate)->Int32Value(); 664 f = CompileRun("e('f()')")
665 ->ToNumber(v8_isolate->GetCurrentContext())
666 .ToLocalChecked()
667 ->Int32Value(v8_isolate->GetCurrentContext())
668 .FromJust();
651 CHECK_EQ(5, f); 669 CHECK_EQ(5, f);
652 v8::Handle<v8::String> s = CompileRun("s")->ToString(v8_isolate); 670 v8::Local<v8::String> s = CompileRun("s")
653 CHECK(s->Equals(v8_str("12345"))); 671 ->ToString(v8_isolate->GetCurrentContext())
654 int a = CompileRun("a.length")->ToNumber(v8_isolate)->Int32Value(); 672 .ToLocalChecked();
673 CHECK(s->Equals(v8_isolate->GetCurrentContext(), v8_str("12345"))
674 .FromJust());
675 int a = CompileRun("a.length")
676 ->ToNumber(v8_isolate->GetCurrentContext())
677 .ToLocalChecked()
678 ->Int32Value(v8_isolate->GetCurrentContext())
679 .FromJust();
655 CHECK_EQ(100001, a); 680 CHECK_EQ(100001, a);
656 int b = CompileRun("b.length")->ToNumber(v8_isolate)->Int32Value(); 681 int b = CompileRun("b.length")
682 ->ToNumber(v8_isolate->GetCurrentContext())
683 .ToLocalChecked()
684 ->Int32Value(v8_isolate->GetCurrentContext())
685 .FromJust();
657 CHECK_EQ(100002, b); 686 CHECK_EQ(100002, b);
658 } 687 }
659 DeleteArray(snapshot); 688 DeleteArray(snapshot);
660 } 689 }
661 v8_isolate->Dispose(); 690 v8_isolate->Dispose();
662 } 691 }
663 692
664 693
665 TEST(PerIsolateSnapshotBlobs) { 694 TEST(PerIsolateSnapshotBlobs) {
666 DisableTurbofan(); 695 DisableTurbofan();
(...skipping 10 matching lines...) Expand all
677 params1.snapshot_blob = &data1; 706 params1.snapshot_blob = &data1;
678 params1.array_buffer_allocator = CcTest::array_buffer_allocator(); 707 params1.array_buffer_allocator = CcTest::array_buffer_allocator();
679 708
680 v8::Isolate* isolate1 = v8::Isolate::New(params1); 709 v8::Isolate* isolate1 = v8::Isolate::New(params1);
681 { 710 {
682 v8::Isolate::Scope i_scope(isolate1); 711 v8::Isolate::Scope i_scope(isolate1);
683 v8::HandleScope h_scope(isolate1); 712 v8::HandleScope h_scope(isolate1);
684 v8::Local<v8::Context> context = v8::Context::New(isolate1); 713 v8::Local<v8::Context> context = v8::Context::New(isolate1);
685 delete[] data1.data; // We can dispose of the snapshot blob now. 714 delete[] data1.data; // We can dispose of the snapshot blob now.
686 v8::Context::Scope c_scope(context); 715 v8::Context::Scope c_scope(context);
687 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value()); 716 v8::Maybe<int32_t> result =
717 CompileRun("f()")->Int32Value(isolate1->GetCurrentContext());
718 CHECK_EQ(42, result.FromJust());
688 CHECK(CompileRun("this.g")->IsUndefined()); 719 CHECK(CompileRun("this.g")->IsUndefined());
689 } 720 }
690 isolate1->Dispose(); 721 isolate1->Dispose();
691 722
692 v8::Isolate::CreateParams params2; 723 v8::Isolate::CreateParams params2;
693 params2.snapshot_blob = &data2; 724 params2.snapshot_blob = &data2;
694 params2.array_buffer_allocator = CcTest::array_buffer_allocator(); 725 params2.array_buffer_allocator = CcTest::array_buffer_allocator();
695 v8::Isolate* isolate2 = v8::Isolate::New(params2); 726 v8::Isolate* isolate2 = v8::Isolate::New(params2);
696 { 727 {
697 v8::Isolate::Scope i_scope(isolate2); 728 v8::Isolate::Scope i_scope(isolate2);
698 v8::HandleScope h_scope(isolate2); 729 v8::HandleScope h_scope(isolate2);
699 v8::Local<v8::Context> context = v8::Context::New(isolate2); 730 v8::Local<v8::Context> context = v8::Context::New(isolate2);
700 delete[] data2.data; // We can dispose of the snapshot blob now. 731 delete[] data2.data; // We can dispose of the snapshot blob now.
701 v8::Context::Scope c_scope(context); 732 v8::Context::Scope c_scope(context);
702 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); 733 v8::Maybe<int32_t> result =
703 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); 734 CompileRun("f()")->Int32Value(isolate2->GetCurrentContext());
735 CHECK_EQ(86, result.FromJust());
736 result = CompileRun("g()")->Int32Value(isolate2->GetCurrentContext());
737 CHECK_EQ(43, result.FromJust());
704 } 738 }
705 isolate2->Dispose(); 739 isolate2->Dispose();
706 } 740 }
707 741
708 742
709 static void SerializationFunctionTemplate( 743 static void SerializationFunctionTemplate(
710 const v8::FunctionCallbackInfo<v8::Value>& args) { 744 const v8::FunctionCallbackInfo<v8::Value>& args) {
711 args.GetReturnValue().Set(args[0]); 745 args.GetReturnValue().Set(args[0]);
712 } 746 }
713 747
(...skipping 30 matching lines...) Expand all
744 v8::Local<v8::ObjectTemplate> property = v8::ObjectTemplate::New(isolate); 778 v8::Local<v8::ObjectTemplate> property = v8::ObjectTemplate::New(isolate);
745 v8::Local<v8::FunctionTemplate> function = 779 v8::Local<v8::FunctionTemplate> function =
746 v8::FunctionTemplate::New(isolate, SerializationFunctionTemplate); 780 v8::FunctionTemplate::New(isolate, SerializationFunctionTemplate);
747 property->Set(isolate, "bar", function); 781 property->Set(isolate, "bar", function);
748 global->Set(isolate, "foo", property); 782 global->Set(isolate, "foo", property);
749 783
750 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); 784 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
751 delete[] data.data; // We can dispose of the snapshot blob now. 785 delete[] data.data; // We can dispose of the snapshot blob now.
752 v8::Context::Scope c_scope(context); 786 v8::Context::Scope c_scope(context);
753 v8::Local<v8::Value> result = CompileRun(source2); 787 v8::Local<v8::Value> result = CompileRun(source2);
754 CHECK(v8_str("42")->Equals(result)); 788 v8::Maybe<bool> compare = v8_str("42")->Equals(
789 v8::Isolate::GetCurrent()->GetCurrentContext(), result);
790 CHECK(compare.FromJust());
755 } 791 }
756 isolate->Dispose(); 792 isolate->Dispose();
757 } 793 }
758 794
759 795
760 TEST(PerIsolateSnapshotBlobsWithLocker) { 796 TEST(PerIsolateSnapshotBlobsWithLocker) {
761 DisableTurbofan(); 797 DisableTurbofan();
762 v8::Isolate::CreateParams create_params; 798 v8::Isolate::CreateParams create_params;
763 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); 799 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
764 v8::Isolate* isolate0 = v8::Isolate::New(create_params); 800 v8::Isolate* isolate0 = v8::Isolate::New(create_params);
765 { 801 {
766 v8::Locker locker(isolate0); 802 v8::Locker locker(isolate0);
767 v8::Isolate::Scope i_scope(isolate0); 803 v8::Isolate::Scope i_scope(isolate0);
768 v8::HandleScope h_scope(isolate0); 804 v8::HandleScope h_scope(isolate0);
769 v8::Local<v8::Context> context = v8::Context::New(isolate0); 805 v8::Local<v8::Context> context = v8::Context::New(isolate0);
770 v8::Context::Scope c_scope(context); 806 v8::Context::Scope c_scope(context);
771 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value()); 807 v8::Maybe<int32_t> result =
808 CompileRun("Math.cos(0)")->Int32Value(isolate0->GetCurrentContext());
809 CHECK_EQ(1, result.FromJust());
772 } 810 }
773 isolate0->Dispose(); 811 isolate0->Dispose();
774 812
775 const char* source1 = "function f() { return 42; }"; 813 const char* source1 = "function f() { return 42; }";
776 814
777 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); 815 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
778 816
779 v8::Isolate::CreateParams params1; 817 v8::Isolate::CreateParams params1;
780 params1.snapshot_blob = &data1; 818 params1.snapshot_blob = &data1;
781 params1.array_buffer_allocator = CcTest::array_buffer_allocator(); 819 params1.array_buffer_allocator = CcTest::array_buffer_allocator();
782 v8::Isolate* isolate1 = v8::Isolate::New(params1); 820 v8::Isolate* isolate1 = v8::Isolate::New(params1);
783 { 821 {
784 v8::Locker locker(isolate1); 822 v8::Locker locker(isolate1);
785 v8::Isolate::Scope i_scope(isolate1); 823 v8::Isolate::Scope i_scope(isolate1);
786 v8::HandleScope h_scope(isolate1); 824 v8::HandleScope h_scope(isolate1);
787 v8::Local<v8::Context> context = v8::Context::New(isolate1); 825 v8::Local<v8::Context> context = v8::Context::New(isolate1);
788 delete[] data1.data; // We can dispose of the snapshot blob now. 826 delete[] data1.data; // We can dispose of the snapshot blob now.
789 v8::Context::Scope c_scope(context); 827 v8::Context::Scope c_scope(context);
790 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value()); 828 v8::Maybe<int32_t> result = CompileRun("f()")->Int32Value(context);
829 CHECK_EQ(42, result.FromJust());
791 } 830 }
792 isolate1->Dispose(); 831 isolate1->Dispose();
793 } 832 }
794 833
795 834
796 TEST(SnapshotBlobsStackOverflow) { 835 TEST(SnapshotBlobsStackOverflow) {
797 DisableTurbofan(); 836 DisableTurbofan();
798 const char* source = 837 const char* source =
799 "var a = [0];" 838 "var a = [0];"
800 "var b = a;" 839 "var b = a;"
(...skipping 17 matching lines...) Expand all
818 v8::Local<v8::Context> context = v8::Context::New(isolate); 857 v8::Local<v8::Context> context = v8::Context::New(isolate);
819 delete[] data.data; // We can dispose of the snapshot blob now. 858 delete[] data.data; // We can dispose of the snapshot blob now.
820 v8::Context::Scope c_scope(context); 859 v8::Context::Scope c_scope(context);
821 const char* test = 860 const char* test =
822 "var sum = 0;" 861 "var sum = 0;"
823 "while (a) {" 862 "while (a) {"
824 " sum += a[0];" 863 " sum += a[0];"
825 " a = a[1];" 864 " a = a[1];"
826 "}" 865 "}"
827 "sum"; 866 "sum";
828 CHECK_EQ(9999 * 5000, CompileRun(test)->ToInt32(isolate)->Int32Value()); 867 v8::Maybe<int32_t> result =
868 CompileRun(test)->Int32Value(isolate->GetCurrentContext());
869 CHECK_EQ(9999 * 5000, result.FromJust());
829 } 870 }
830 isolate->Dispose(); 871 isolate->Dispose();
831 } 872 }
832 873
833 874
834 TEST(TestThatAlwaysSucceeds) { 875 TEST(TestThatAlwaysSucceeds) {
835 } 876 }
836 877
837 878
838 TEST(TestThatAlwaysFails) { 879 TEST(TestThatAlwaysFails) {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 v8::ScriptCompiler::kConsumeCodeCache); 1204 v8::ScriptCompiler::kConsumeCodeCache);
1164 } 1205 }
1165 CHECK_NE(*orig, *copy); 1206 CHECK_NE(*orig, *copy);
1166 1207
1167 Handle<JSFunction> copy_fun = 1208 Handle<JSFunction> copy_fun =
1168 isolate->factory()->NewFunctionFromSharedFunctionInfo( 1209 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1169 copy, isolate->native_context()); 1210 copy, isolate->native_context());
1170 1211
1171 USE(Execution::Call(isolate, copy_fun, global, 0, NULL)); 1212 USE(Execution::Call(isolate, copy_fun, global, 0, NULL));
1172 1213
1173 CHECK_EQ(600000 + 700000, CompileRun("(a + b).length")->Int32Value()); 1214 v8::Maybe<int32_t> result =
1174 CHECK_EQ(500000 + 600000, CompileRun("(b + c).length")->Int32Value()); 1215 CompileRun("(a + b).length")
1216 ->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext());
1217 CHECK_EQ(600000 + 700000, result.FromJust());
1218 result = CompileRun("(b + c).length")
1219 ->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext());
1220 CHECK_EQ(500000 + 600000, result.FromJust());
1175 Heap* heap = isolate->heap(); 1221 Heap* heap = isolate->heap();
1176 CHECK(heap->InSpace( 1222 v8::Local<v8::String> result_str =
1177 *v8::Utils::OpenHandle(*CompileRun("a")->ToString(CcTest::isolate())), 1223 CompileRun("a")
1178 OLD_SPACE)); 1224 ->ToString(CcTest::isolate()->GetCurrentContext())
1179 CHECK(heap->InSpace( 1225 .ToLocalChecked();
1180 *v8::Utils::OpenHandle(*CompileRun("b")->ToString(CcTest::isolate())), 1226 CHECK(heap->InSpace(*v8::Utils::OpenHandle(*result_str), OLD_SPACE));
1181 OLD_SPACE)); 1227 result_str = CompileRun("b")
1182 CHECK(heap->InSpace( 1228 ->ToString(CcTest::isolate()->GetCurrentContext())
1183 *v8::Utils::OpenHandle(*CompileRun("c")->ToString(CcTest::isolate())), 1229 .ToLocalChecked();
1184 OLD_SPACE)); 1230 CHECK(heap->InSpace(*v8::Utils::OpenHandle(*result_str), OLD_SPACE));
1231 result_str = CompileRun("c")
1232 ->ToString(CcTest::isolate()->GetCurrentContext())
1233 .ToLocalChecked();
1234 CHECK(heap->InSpace(*v8::Utils::OpenHandle(*result_str), OLD_SPACE));
1185 1235
1186 delete cache; 1236 delete cache;
1187 source_a.Dispose(); 1237 source_a.Dispose();
1188 source_b.Dispose(); 1238 source_b.Dispose();
1189 source_c.Dispose(); 1239 source_c.Dispose();
1190 } 1240 }
1191 1241
1192 1242
1193 class SerializerOneByteResource 1243 class SerializerOneByteResource
1194 : public v8::String::ExternalOneByteStringResource { 1244 : public v8::String::ExternalOneByteStringResource {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 v8::Isolate* isolate1 = v8::Isolate::New(create_params); 1459 v8::Isolate* isolate1 = v8::Isolate::New(create_params);
1410 { 1460 {
1411 v8::Isolate::Scope iscope(isolate1); 1461 v8::Isolate::Scope iscope(isolate1);
1412 v8::HandleScope scope(isolate1); 1462 v8::HandleScope scope(isolate1);
1413 v8::Local<v8::Context> context = v8::Context::New(isolate1); 1463 v8::Local<v8::Context> context = v8::Context::New(isolate1);
1414 v8::Context::Scope context_scope(context); 1464 v8::Context::Scope context_scope(context);
1415 1465
1416 v8::Local<v8::String> source_str = v8_str(source); 1466 v8::Local<v8::String> source_str = v8_str(source);
1417 v8::ScriptOrigin origin(v8_str("test")); 1467 v8::ScriptOrigin origin(v8_str("test"));
1418 v8::ScriptCompiler::Source source(source_str, origin); 1468 v8::ScriptCompiler::Source source(source_str, origin);
1419 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound( 1469 v8::Local<v8::UnboundScript> script =
1420 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); 1470 v8::ScriptCompiler::CompileUnboundScript(
1471 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache)
1472 .ToLocalChecked();
1421 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); 1473 const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
1422 CHECK(data); 1474 CHECK(data);
1423 // Persist cached data. 1475 // Persist cached data.
1424 uint8_t* buffer = NewArray<uint8_t>(data->length); 1476 uint8_t* buffer = NewArray<uint8_t>(data->length);
1425 MemCopy(buffer, data->data, data->length); 1477 MemCopy(buffer, data->data, data->length);
1426 cache = new v8::ScriptCompiler::CachedData( 1478 cache = new v8::ScriptCompiler::CachedData(
1427 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); 1479 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
1428 1480
1429 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1481 v8::Local<v8::Value> result = script->BindToCurrentContext()
1430 CHECK(result->ToString(isolate1)->Equals(v8_str("abcdef"))); 1482 ->Run(isolate1->GetCurrentContext())
1483 .ToLocalChecked();
1484 v8::Local<v8::String> result_string =
1485 result->ToString(isolate1->GetCurrentContext()).ToLocalChecked();
1486 CHECK(result_string->Equals(isolate1->GetCurrentContext(), v8_str("abcdef"))
1487 .FromJust());
1431 } 1488 }
1432 isolate1->Dispose(); 1489 isolate1->Dispose();
1433 return cache; 1490 return cache;
1434 } 1491 }
1435 1492
1436 1493
1437 TEST(SerializeToplevelIsolates) { 1494 TEST(SerializeToplevelIsolates) {
1438 FLAG_serialize_toplevel = true; 1495 FLAG_serialize_toplevel = true;
1439 1496
1440 const char* source = "function f() { return 'abc'; }; f() + 'def'"; 1497 const char* source = "function f() { return 'abc'; }; f() + 'def'";
(...skipping 10 matching lines...) Expand all
1451 v8::HandleScope scope(isolate2); 1508 v8::HandleScope scope(isolate2);
1452 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1509 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1453 v8::Context::Scope context_scope(context); 1510 v8::Context::Scope context_scope(context);
1454 1511
1455 v8::Local<v8::String> source_str = v8_str(source); 1512 v8::Local<v8::String> source_str = v8_str(source);
1456 v8::ScriptOrigin origin(v8_str("test")); 1513 v8::ScriptOrigin origin(v8_str("test"));
1457 v8::ScriptCompiler::Source source(source_str, origin, cache); 1514 v8::ScriptCompiler::Source source(source_str, origin, cache);
1458 v8::Local<v8::UnboundScript> script; 1515 v8::Local<v8::UnboundScript> script;
1459 { 1516 {
1460 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 1517 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
1461 script = v8::ScriptCompiler::CompileUnbound( 1518 script = v8::ScriptCompiler::CompileUnboundScript(
1462 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1519 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache)
1520 .ToLocalChecked();
1463 } 1521 }
1464 CHECK(!cache->rejected); 1522 CHECK(!cache->rejected);
1465 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1523 v8::Local<v8::Value> result = script->BindToCurrentContext()
1466 CHECK(result->ToString(isolate2)->Equals(v8_str("abcdef"))); 1524 ->Run(isolate2->GetCurrentContext())
1525 .ToLocalChecked();
1526 CHECK(result->ToString(isolate2->GetCurrentContext())
1527 .ToLocalChecked()
1528 ->Equals(isolate2->GetCurrentContext(), v8_str("abcdef"))
1529 .FromJust());
1467 } 1530 }
1468 DCHECK(toplevel_test_code_event_found); 1531 DCHECK(toplevel_test_code_event_found);
1469 isolate2->Dispose(); 1532 isolate2->Dispose();
1470 } 1533 }
1471 1534
1472 1535
1473 TEST(SerializeToplevelFlagChange) { 1536 TEST(SerializeToplevelFlagChange) {
1474 FLAG_serialize_toplevel = true; 1537 FLAG_serialize_toplevel = true;
1475 1538
1476 const char* source = "function f() { return 'abc'; }; f() + 'def'"; 1539 const char* source = "function f() { return 'abc'; }; f() + 'def'";
1477 v8::ScriptCompiler::CachedData* cache = ProduceCache(source); 1540 v8::ScriptCompiler::CachedData* cache = ProduceCache(source);
1478 1541
1479 v8::Isolate::CreateParams create_params; 1542 v8::Isolate::CreateParams create_params;
1480 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); 1543 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
1481 v8::Isolate* isolate2 = v8::Isolate::New(create_params); 1544 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
1482 1545
1483 FLAG_allow_natives_syntax = true; // Flag change should trigger cache reject. 1546 FLAG_allow_natives_syntax = true; // Flag change should trigger cache reject.
1484 FlagList::EnforceFlagImplications(); 1547 FlagList::EnforceFlagImplications();
1485 { 1548 {
1486 v8::Isolate::Scope iscope(isolate2); 1549 v8::Isolate::Scope iscope(isolate2);
1487 v8::HandleScope scope(isolate2); 1550 v8::HandleScope scope(isolate2);
1488 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1551 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1489 v8::Context::Scope context_scope(context); 1552 v8::Context::Scope context_scope(context);
1490 1553
1491 v8::Local<v8::String> source_str = v8_str(source); 1554 v8::Local<v8::String> source_str = v8_str(source);
1492 v8::ScriptOrigin origin(v8_str("test")); 1555 v8::ScriptOrigin origin(v8_str("test"));
1493 v8::ScriptCompiler::Source source(source_str, origin, cache); 1556 v8::ScriptCompiler::Source source(source_str, origin, cache);
1494 v8::ScriptCompiler::CompileUnbound(isolate2, &source, 1557 v8::ScriptCompiler::CompileUnboundScript(
1495 v8::ScriptCompiler::kConsumeCodeCache); 1558 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache)
1559 .ToLocalChecked();
1496 CHECK(cache->rejected); 1560 CHECK(cache->rejected);
1497 } 1561 }
1498 isolate2->Dispose(); 1562 isolate2->Dispose();
1499 } 1563 }
1500 1564
1501 1565
1502 TEST(SerializeToplevelBitFlip) { 1566 TEST(SerializeToplevelBitFlip) {
1503 FLAG_serialize_toplevel = true; 1567 FLAG_serialize_toplevel = true;
1504 1568
1505 const char* source = "function f() { return 'abc'; }; f() + 'def'"; 1569 const char* source = "function f() { return 'abc'; }; f() + 'def'";
1506 v8::ScriptCompiler::CachedData* cache = ProduceCache(source); 1570 v8::ScriptCompiler::CachedData* cache = ProduceCache(source);
1507 1571
1508 // Random bit flip. 1572 // Random bit flip.
1509 const_cast<uint8_t*>(cache->data)[337] ^= 0x40; 1573 const_cast<uint8_t*>(cache->data)[337] ^= 0x40;
1510 1574
1511 v8::Isolate::CreateParams create_params; 1575 v8::Isolate::CreateParams create_params;
1512 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); 1576 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
1513 v8::Isolate* isolate2 = v8::Isolate::New(create_params); 1577 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
1514 { 1578 {
1515 v8::Isolate::Scope iscope(isolate2); 1579 v8::Isolate::Scope iscope(isolate2);
1516 v8::HandleScope scope(isolate2); 1580 v8::HandleScope scope(isolate2);
1517 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1581 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1518 v8::Context::Scope context_scope(context); 1582 v8::Context::Scope context_scope(context);
1519 1583
1520 v8::Local<v8::String> source_str = v8_str(source); 1584 v8::Local<v8::String> source_str = v8_str(source);
1521 v8::ScriptOrigin origin(v8_str("test")); 1585 v8::ScriptOrigin origin(v8_str("test"));
1522 v8::ScriptCompiler::Source source(source_str, origin, cache); 1586 v8::ScriptCompiler::Source source(source_str, origin, cache);
1523 v8::ScriptCompiler::CompileUnbound(isolate2, &source, 1587 v8::ScriptCompiler::CompileUnboundScript(
1524 v8::ScriptCompiler::kConsumeCodeCache); 1588 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache)
1589 .ToLocalChecked();
1525 CHECK(cache->rejected); 1590 CHECK(cache->rejected);
1526 } 1591 }
1527 isolate2->Dispose(); 1592 isolate2->Dispose();
1528 } 1593 }
1529 1594
1530 1595
1531 TEST(SerializeWithHarmonyScoping) { 1596 TEST(SerializeWithHarmonyScoping) {
1532 FLAG_serialize_toplevel = true; 1597 FLAG_serialize_toplevel = true;
1533 1598
1534 const char* source1 = "'use strict'; let x = 'X'"; 1599 const char* source1 = "'use strict'; let x = 'X'";
(...skipping 10 matching lines...) Expand all
1545 v8::HandleScope scope(isolate1); 1610 v8::HandleScope scope(isolate1);
1546 v8::Local<v8::Context> context = v8::Context::New(isolate1); 1611 v8::Local<v8::Context> context = v8::Context::New(isolate1);
1547 v8::Context::Scope context_scope(context); 1612 v8::Context::Scope context_scope(context);
1548 1613
1549 CompileRun(source1); 1614 CompileRun(source1);
1550 CompileRun(source2); 1615 CompileRun(source2);
1551 1616
1552 v8::Local<v8::String> source_str = v8_str(source3); 1617 v8::Local<v8::String> source_str = v8_str(source3);
1553 v8::ScriptOrigin origin(v8_str("test")); 1618 v8::ScriptOrigin origin(v8_str("test"));
1554 v8::ScriptCompiler::Source source(source_str, origin); 1619 v8::ScriptCompiler::Source source(source_str, origin);
1555 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound( 1620 v8::Local<v8::UnboundScript> script =
1556 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); 1621 v8::ScriptCompiler::CompileUnboundScript(
1622 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache)
1623 .ToLocalChecked();
1557 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); 1624 const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
1558 CHECK(data); 1625 CHECK(data);
1559 // Persist cached data. 1626 // Persist cached data.
1560 uint8_t* buffer = NewArray<uint8_t>(data->length); 1627 uint8_t* buffer = NewArray<uint8_t>(data->length);
1561 MemCopy(buffer, data->data, data->length); 1628 MemCopy(buffer, data->data, data->length);
1562 cache = new v8::ScriptCompiler::CachedData( 1629 cache = new v8::ScriptCompiler::CachedData(
1563 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); 1630 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
1564 1631
1565 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1632 v8::Local<v8::Value> result = script->BindToCurrentContext()
1566 CHECK(result->ToString(isolate1)->Equals(v8_str("XY"))); 1633 ->Run(isolate1->GetCurrentContext())
1634 .ToLocalChecked();
1635 v8::Local<v8::String> result_str =
1636 result->ToString(isolate1->GetCurrentContext()).ToLocalChecked();
1637 CHECK(result_str->Equals(isolate1->GetCurrentContext(), v8_str("XY"))
1638 .FromJust());
1567 } 1639 }
1568 isolate1->Dispose(); 1640 isolate1->Dispose();
1569 1641
1570 v8::Isolate* isolate2 = v8::Isolate::New(create_params); 1642 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
1571 { 1643 {
1572 v8::Isolate::Scope iscope(isolate2); 1644 v8::Isolate::Scope iscope(isolate2);
1573 v8::HandleScope scope(isolate2); 1645 v8::HandleScope scope(isolate2);
1574 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1646 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1575 v8::Context::Scope context_scope(context); 1647 v8::Context::Scope context_scope(context);
1576 1648
1577 // Reverse order of prior running scripts. 1649 // Reverse order of prior running scripts.
1578 CompileRun(source2); 1650 CompileRun(source2);
1579 CompileRun(source1); 1651 CompileRun(source1);
1580 1652
1581 v8::Local<v8::String> source_str = v8_str(source3); 1653 v8::Local<v8::String> source_str = v8_str(source3);
1582 v8::ScriptOrigin origin(v8_str("test")); 1654 v8::ScriptOrigin origin(v8_str("test"));
1583 v8::ScriptCompiler::Source source(source_str, origin, cache); 1655 v8::ScriptCompiler::Source source(source_str, origin, cache);
1584 v8::Local<v8::UnboundScript> script; 1656 v8::Local<v8::UnboundScript> script;
1585 { 1657 {
1586 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 1658 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
1587 script = v8::ScriptCompiler::CompileUnbound( 1659 script = v8::ScriptCompiler::CompileUnboundScript(
1588 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1660 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache)
1661 .ToLocalChecked();
1589 } 1662 }
1590 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1663 v8::Local<v8::Value> result = script->BindToCurrentContext()
1591 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); 1664 ->Run(isolate2->GetCurrentContext())
1665 .ToLocalChecked();
1666 v8::Local<v8::String> result_str =
1667 result->ToString(isolate2->GetCurrentContext()).ToLocalChecked();
1668 CHECK(result_str->Equals(isolate2->GetCurrentContext(), v8_str("XY"))
1669 .FromJust());
1592 } 1670 }
1593 isolate2->Dispose(); 1671 isolate2->Dispose();
1594 } 1672 }
1595 1673
1596 1674
1597 TEST(SerializeInternalReference) { 1675 TEST(SerializeInternalReference) {
1598 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 1676 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64
1599 return; 1677 return;
1600 #endif 1678 #endif
1601 // Disable experimental natives that are loaded after deserialization. 1679 // Disable experimental natives that are loaded after deserialization.
(...skipping 28 matching lines...) Expand all
1630 v8::Isolate::CreateParams params; 1708 v8::Isolate::CreateParams params;
1631 params.snapshot_blob = &data; 1709 params.snapshot_blob = &data;
1632 params.array_buffer_allocator = CcTest::array_buffer_allocator(); 1710 params.array_buffer_allocator = CcTest::array_buffer_allocator();
1633 v8::Isolate* isolate = v8::Isolate::New(params); 1711 v8::Isolate* isolate = v8::Isolate::New(params);
1634 { 1712 {
1635 v8::Isolate::Scope i_scope(isolate); 1713 v8::Isolate::Scope i_scope(isolate);
1636 v8::HandleScope h_scope(isolate); 1714 v8::HandleScope h_scope(isolate);
1637 v8::Local<v8::Context> context = v8::Context::New(isolate); 1715 v8::Local<v8::Context> context = v8::Context::New(isolate);
1638 delete[] data.data; // We can dispose of the snapshot blob now. 1716 delete[] data.data; // We can dispose of the snapshot blob now.
1639 v8::Context::Scope c_scope(context); 1717 v8::Context::Scope c_scope(context);
1640 v8::Handle<v8::Function> foo = 1718 v8::Local<v8::Function> foo =
1641 v8::Handle<v8::Function>::Cast(CompileRun("foo")); 1719 v8::Local<v8::Function>::Cast(CompileRun("foo"));
1642 1720
1643 // There are at least 6 internal references. 1721 // There are at least 6 internal references.
1644 int mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | 1722 int mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) |
1645 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); 1723 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED);
1646 RelocIterator it(v8::Utils::OpenHandle(*foo)->code(), mask); 1724 RelocIterator it(v8::Utils::OpenHandle(*foo)->code(), mask);
1647 for (int i = 0; i < 6; ++i) { 1725 for (int i = 0; i < 6; ++i) {
1648 CHECK(!it.done()); 1726 CHECK(!it.done());
1649 it.next(); 1727 it.next();
1650 } 1728 }
1651 1729
1652 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned()); 1730 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned());
1653 CHECK_EQ(11, CompileRun("foo(0)")->ToInt32(isolate)->Int32Value()); 1731 CHECK_EQ(11, CompileRun("foo(0)")
1654 CHECK_EQ(11, CompileRun("foo(1)")->ToInt32(isolate)->Int32Value()); 1732 ->Int32Value(isolate->GetCurrentContext())
1655 CHECK_EQ(12, CompileRun("foo(2)")->ToInt32(isolate)->Int32Value()); 1733 .FromJust());
1656 CHECK_EQ(12, CompileRun("foo(3)")->ToInt32(isolate)->Int32Value()); 1734 CHECK_EQ(11, CompileRun("foo(1)")
1657 CHECK_EQ(23, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value()); 1735 ->Int32Value(isolate->GetCurrentContext())
1658 CHECK_EQ(23, CompileRun("foo(5)")->ToInt32(isolate)->Int32Value()); 1736 .FromJust());
1659 CHECK_EQ(10, CompileRun("foo(6)")->ToInt32(isolate)->Int32Value()); 1737 CHECK_EQ(12, CompileRun("foo(2)")
1738 ->Int32Value(isolate->GetCurrentContext())
1739 .FromJust());
1740 CHECK_EQ(12, CompileRun("foo(3)")
1741 ->Int32Value(isolate->GetCurrentContext())
1742 .FromJust());
1743 CHECK_EQ(23, CompileRun("foo(4)")
1744 ->Int32Value(isolate->GetCurrentContext())
1745 .FromJust());
1746 CHECK_EQ(23, CompileRun("foo(5)")
1747 ->Int32Value(isolate->GetCurrentContext())
1748 .FromJust());
1749 CHECK_EQ(10, CompileRun("foo(6)")
1750 ->Int32Value(isolate->GetCurrentContext())
1751 .FromJust());
1660 } 1752 }
1661 isolate->Dispose(); 1753 isolate->Dispose();
1662 } 1754 }
1663 1755
1664 1756
1665 TEST(Regress503552) { 1757 TEST(Regress503552) {
1666 // Test that the code serializer can deal with weak cells that form a linked 1758 // Test that the code serializer can deal with weak cells that form a linked
1667 // list during incremental marking. 1759 // list during incremental marking.
1668 1760
1669 CcTest::InitializeVM(); 1761 CcTest::InitializeVM();
(...skipping 16 matching lines...) Expand all
1686 delete script_data; 1778 delete script_data;
1687 } 1779 }
1688 1780
1689 1781
1690 TEST(SerializationMemoryStats) { 1782 TEST(SerializationMemoryStats) {
1691 FLAG_profile_deserialization = true; 1783 FLAG_profile_deserialization = true;
1692 FLAG_always_opt = false; 1784 FLAG_always_opt = false;
1693 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 1785 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
1694 delete[] blob.data; 1786 delete[] blob.data;
1695 } 1787 }
OLDNEW
« no previous file with comments | « test/cctest/test-sampler-api.cc ('k') | test/cctest/test-simd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698