OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 283 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
284 function->set_initial_map(*initial_map); | 284 function->set_initial_map(*initial_map); |
285 JSReceiver::SetProperty(global, name, function, NONE, SLOPPY).Check(); | 285 JSReceiver::SetProperty(global, name, function, NONE, SLOPPY).Check(); |
286 // Allocate an object. Unrooted after leaving the scope. | 286 // Allocate an object. Unrooted after leaving the scope. |
287 Handle<JSObject> obj = factory->NewJSObject(function); | 287 Handle<JSObject> obj = factory->NewJSObject(function); |
288 JSReceiver::SetProperty( | 288 JSReceiver::SetProperty( |
289 obj, prop_name, twenty_three, NONE, SLOPPY).Check(); | 289 obj, prop_name, twenty_three, NONE, SLOPPY).Check(); |
290 JSReceiver::SetProperty( | 290 JSReceiver::SetProperty( |
291 obj, prop_namex, twenty_four, NONE, SLOPPY).Check(); | 291 obj, prop_namex, twenty_four, NONE, SLOPPY).Check(); |
292 | 292 |
293 CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name)); | 293 CHECK_EQ(Smi::FromInt(23), |
294 CHECK_EQ(Smi::FromInt(24), *Object::GetProperty(obj, prop_namex)); | 294 *Object::GetProperty(obj, prop_name).ToHandleChecked()); |
| 295 CHECK_EQ(Smi::FromInt(24), |
| 296 *Object::GetProperty(obj, prop_namex).ToHandleChecked()); |
295 } | 297 } |
296 | 298 |
297 heap->CollectGarbage(NEW_SPACE); | 299 heap->CollectGarbage(NEW_SPACE); |
298 | 300 |
299 // Function should be alive. | 301 // Function should be alive. |
300 CHECK(JSReceiver::HasLocalProperty(global, name)); | 302 CHECK(JSReceiver::HasLocalProperty(global, name)); |
301 // Check function is retained. | 303 // Check function is retained. |
302 Handle<Object> func_value = Object::GetProperty(global, name); | 304 Handle<Object> func_value = |
| 305 Object::GetProperty(global, name).ToHandleChecked(); |
303 CHECK(func_value->IsJSFunction()); | 306 CHECK(func_value->IsJSFunction()); |
304 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); | 307 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); |
305 | 308 |
306 { | 309 { |
307 HandleScope inner_scope(isolate); | 310 HandleScope inner_scope(isolate); |
308 // Allocate another object, make it reachable from global. | 311 // Allocate another object, make it reachable from global. |
309 Handle<JSObject> obj = factory->NewJSObject(function); | 312 Handle<JSObject> obj = factory->NewJSObject(function); |
310 JSReceiver::SetProperty(global, obj_name, obj, NONE, SLOPPY).Check(); | 313 JSReceiver::SetProperty(global, obj_name, obj, NONE, SLOPPY).Check(); |
311 JSReceiver::SetProperty( | 314 JSReceiver::SetProperty( |
312 obj, prop_name, twenty_three, NONE, SLOPPY).Check(); | 315 obj, prop_name, twenty_three, NONE, SLOPPY).Check(); |
313 } | 316 } |
314 | 317 |
315 // After gc, it should survive. | 318 // After gc, it should survive. |
316 heap->CollectGarbage(NEW_SPACE); | 319 heap->CollectGarbage(NEW_SPACE); |
317 | 320 |
318 CHECK(JSReceiver::HasLocalProperty(global, obj_name)); | 321 CHECK(JSReceiver::HasLocalProperty(global, obj_name)); |
319 Handle<Object> obj = Object::GetProperty(global, obj_name); | 322 Handle<Object> obj = |
| 323 Object::GetProperty(global, obj_name).ToHandleChecked(); |
320 CHECK(obj->IsJSObject()); | 324 CHECK(obj->IsJSObject()); |
321 CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name)); | 325 CHECK_EQ(Smi::FromInt(23), |
| 326 *Object::GetProperty(obj, prop_name).ToHandleChecked()); |
322 } | 327 } |
323 | 328 |
324 | 329 |
325 static void VerifyStringAllocation(Isolate* isolate, const char* string) { | 330 static void VerifyStringAllocation(Isolate* isolate, const char* string) { |
326 HandleScope scope(isolate); | 331 HandleScope scope(isolate); |
327 Handle<String> s = isolate->factory()->NewStringFromUtf8(CStrVector(string)); | 332 Handle<String> s = isolate->factory()->NewStringFromUtf8(CStrVector(string)); |
328 CHECK_EQ(StrLength(string), s->length()); | 333 CHECK_EQ(StrLength(string), s->length()); |
329 for (int index = 0; index < s->length(); index++) { | 334 for (int index = 0; index < s->length(); index++) { |
330 CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index)); | 335 CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index)); |
331 } | 336 } |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 Handle<Map> initial_map = | 640 Handle<Map> initial_map = |
636 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 641 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
637 function->set_initial_map(*initial_map); | 642 function->set_initial_map(*initial_map); |
638 | 643 |
639 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); | 644 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
640 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); | 645 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); |
641 | 646 |
642 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); | 647 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); |
643 Handle<JSObject> obj = factory->NewJSObject(function); | 648 Handle<JSObject> obj = factory->NewJSObject(function); |
644 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); | 649 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); |
645 CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name)); | 650 CHECK_EQ(Smi::FromInt(23), |
| 651 *Object::GetProperty(obj, prop_name).ToHandleChecked()); |
646 // Check that we can add properties to function objects. | 652 // Check that we can add properties to function objects. |
647 JSReceiver::SetProperty( | 653 JSReceiver::SetProperty( |
648 function, prop_name, twenty_four, NONE, SLOPPY).Check(); | 654 function, prop_name, twenty_four, NONE, SLOPPY).Check(); |
649 CHECK_EQ(Smi::FromInt(24), *Object::GetProperty(function, prop_name)); | 655 CHECK_EQ(Smi::FromInt(24), |
| 656 *Object::GetProperty(function, prop_name).ToHandleChecked()); |
650 } | 657 } |
651 | 658 |
652 | 659 |
653 TEST(ObjectProperties) { | 660 TEST(ObjectProperties) { |
654 CcTest::InitializeVM(); | 661 CcTest::InitializeVM(); |
655 Isolate* isolate = CcTest::i_isolate(); | 662 Isolate* isolate = CcTest::i_isolate(); |
656 Factory* factory = isolate->factory(); | 663 Factory* factory = isolate->factory(); |
657 | 664 |
658 v8::HandleScope sc(CcTest::isolate()); | 665 v8::HandleScope sc(CcTest::isolate()); |
659 Handle<String> object_string(String::cast(CcTest::heap()->Object_string())); | 666 Handle<String> object_string(String::cast(CcTest::heap()->Object_string())); |
660 Handle<Object> object = | 667 Handle<Object> object = Object::GetProperty( |
661 Object::GetProperty(CcTest::i_isolate()->global_object(), object_string); | 668 CcTest::i_isolate()->global_object(), object_string).ToHandleChecked(); |
662 Handle<JSFunction> constructor = Handle<JSFunction>::cast(object); | 669 Handle<JSFunction> constructor = Handle<JSFunction>::cast(object); |
663 Handle<JSObject> obj = factory->NewJSObject(constructor); | 670 Handle<JSObject> obj = factory->NewJSObject(constructor); |
664 Handle<String> first = factory->InternalizeUtf8String("first"); | 671 Handle<String> first = factory->InternalizeUtf8String("first"); |
665 Handle<String> second = factory->InternalizeUtf8String("second"); | 672 Handle<String> second = factory->InternalizeUtf8String("second"); |
666 | 673 |
667 Handle<Smi> one(Smi::FromInt(1), isolate); | 674 Handle<Smi> one(Smi::FromInt(1), isolate); |
668 Handle<Smi> two(Smi::FromInt(2), isolate); | 675 Handle<Smi> two(Smi::FromInt(2), isolate); |
669 | 676 |
670 // check for empty | 677 // check for empty |
671 CHECK(!JSReceiver::HasLocalProperty(obj, first)); | 678 CHECK(!JSReceiver::HasLocalProperty(obj, first)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 Handle<Map> initial_map = | 739 Handle<Map> initial_map = |
733 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 740 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
734 function->set_initial_map(*initial_map); | 741 function->set_initial_map(*initial_map); |
735 | 742 |
736 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); | 743 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); |
737 Handle<JSObject> obj = factory->NewJSObject(function); | 744 Handle<JSObject> obj = factory->NewJSObject(function); |
738 | 745 |
739 // Set a propery | 746 // Set a propery |
740 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); | 747 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
741 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); | 748 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); |
742 CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name)); | 749 CHECK_EQ(Smi::FromInt(23), |
| 750 *Object::GetProperty(obj, prop_name).ToHandleChecked()); |
743 | 751 |
744 // Check the map has changed | 752 // Check the map has changed |
745 CHECK(*initial_map != obj->map()); | 753 CHECK(*initial_map != obj->map()); |
746 } | 754 } |
747 | 755 |
748 | 756 |
749 TEST(JSArray) { | 757 TEST(JSArray) { |
750 CcTest::InitializeVM(); | 758 CcTest::InitializeVM(); |
751 Isolate* isolate = CcTest::i_isolate(); | 759 Isolate* isolate = CcTest::i_isolate(); |
752 Factory* factory = isolate->factory(); | 760 Factory* factory = isolate->factory(); |
753 | 761 |
754 v8::HandleScope sc(CcTest::isolate()); | 762 v8::HandleScope sc(CcTest::isolate()); |
755 Handle<String> name = factory->InternalizeUtf8String("Array"); | 763 Handle<String> name = factory->InternalizeUtf8String("Array"); |
756 Handle<Object> fun_obj = | 764 Handle<Object> fun_obj = Object::GetProperty( |
757 Object::GetProperty(CcTest::i_isolate()->global_object(), name); | 765 CcTest::i_isolate()->global_object(), name).ToHandleChecked(); |
758 Handle<JSFunction> function = Handle<JSFunction>::cast(fun_obj); | 766 Handle<JSFunction> function = Handle<JSFunction>::cast(fun_obj); |
759 | 767 |
760 // Allocate the object. | 768 // Allocate the object. |
761 Handle<JSObject> object = factory->NewJSObject(function); | 769 Handle<JSObject> object = factory->NewJSObject(function); |
762 Handle<JSArray> array = Handle<JSArray>::cast(object); | 770 Handle<JSArray> array = Handle<JSArray>::cast(object); |
763 // We just initialized the VM, no heap allocation failure yet. | 771 // We just initialized the VM, no heap allocation failure yet. |
764 JSArray::Initialize(array, 0); | 772 JSArray::Initialize(array, 0); |
765 | 773 |
766 // Set array length to 0. | 774 // Set array length to 0. |
767 JSArray::SetElementsLength(array, handle(Smi::FromInt(0), isolate)).Check(); | 775 JSArray::SetElementsLength(array, handle(Smi::FromInt(0), isolate)).Check(); |
(...skipping 27 matching lines...) Expand all Loading... |
795 } | 803 } |
796 | 804 |
797 | 805 |
798 TEST(JSObjectCopy) { | 806 TEST(JSObjectCopy) { |
799 CcTest::InitializeVM(); | 807 CcTest::InitializeVM(); |
800 Isolate* isolate = CcTest::i_isolate(); | 808 Isolate* isolate = CcTest::i_isolate(); |
801 Factory* factory = isolate->factory(); | 809 Factory* factory = isolate->factory(); |
802 | 810 |
803 v8::HandleScope sc(CcTest::isolate()); | 811 v8::HandleScope sc(CcTest::isolate()); |
804 Handle<String> object_string(String::cast(CcTest::heap()->Object_string())); | 812 Handle<String> object_string(String::cast(CcTest::heap()->Object_string())); |
805 Handle<Object> object = | 813 Handle<Object> object = Object::GetProperty( |
806 Object::GetProperty(CcTest::i_isolate()->global_object(), object_string); | 814 CcTest::i_isolate()->global_object(), object_string).ToHandleChecked(); |
807 Handle<JSFunction> constructor = Handle<JSFunction>::cast(object); | 815 Handle<JSFunction> constructor = Handle<JSFunction>::cast(object); |
808 Handle<JSObject> obj = factory->NewJSObject(constructor); | 816 Handle<JSObject> obj = factory->NewJSObject(constructor); |
809 Handle<String> first = factory->InternalizeUtf8String("first"); | 817 Handle<String> first = factory->InternalizeUtf8String("first"); |
810 Handle<String> second = factory->InternalizeUtf8String("second"); | 818 Handle<String> second = factory->InternalizeUtf8String("second"); |
811 | 819 |
812 Handle<Smi> one(Smi::FromInt(1), isolate); | 820 Handle<Smi> one(Smi::FromInt(1), isolate); |
813 Handle<Smi> two(Smi::FromInt(2), isolate); | 821 Handle<Smi> two(Smi::FromInt(2), isolate); |
814 | 822 |
815 JSReceiver::SetProperty(obj, first, one, NONE, SLOPPY).Check(); | 823 JSReceiver::SetProperty(obj, first, one, NONE, SLOPPY).Check(); |
816 JSReceiver::SetProperty(obj, second, two, NONE, SLOPPY).Check(); | 824 JSReceiver::SetProperty(obj, second, two, NONE, SLOPPY).Check(); |
817 | 825 |
818 JSReceiver::SetElement(obj, 0, first, NONE, SLOPPY).Check(); | 826 JSReceiver::SetElement(obj, 0, first, NONE, SLOPPY).Check(); |
819 JSReceiver::SetElement(obj, 1, second, NONE, SLOPPY).Check(); | 827 JSReceiver::SetElement(obj, 1, second, NONE, SLOPPY).Check(); |
820 | 828 |
821 // Make the clone. | 829 // Make the clone. |
822 Handle<JSObject> clone = JSObject::Copy(obj); | 830 Handle<JSObject> clone = JSObject::Copy(obj); |
823 CHECK(!clone.is_identical_to(obj)); | 831 CHECK(!clone.is_identical_to(obj)); |
824 | 832 |
825 CHECK_EQ(*i::Object::GetElement(isolate, obj, 0).ToHandleChecked(), | 833 CHECK_EQ(*i::Object::GetElement(isolate, obj, 0).ToHandleChecked(), |
826 *i::Object::GetElement(isolate, clone, 0).ToHandleChecked()); | 834 *i::Object::GetElement(isolate, clone, 0).ToHandleChecked()); |
827 CHECK_EQ(*i::Object::GetElement(isolate, obj, 1).ToHandleChecked(), | 835 CHECK_EQ(*i::Object::GetElement(isolate, obj, 1).ToHandleChecked(), |
828 *i::Object::GetElement(isolate, clone, 1).ToHandleChecked()); | 836 *i::Object::GetElement(isolate, clone, 1).ToHandleChecked()); |
829 | 837 |
830 CHECK_EQ(*Object::GetProperty(obj, first), | 838 CHECK_EQ(*Object::GetProperty(obj, first).ToHandleChecked(), |
831 *Object::GetProperty(clone, first)); | 839 *Object::GetProperty(clone, first).ToHandleChecked()); |
832 CHECK_EQ(*Object::GetProperty(obj, second), | 840 CHECK_EQ(*Object::GetProperty(obj, second).ToHandleChecked(), |
833 *Object::GetProperty(clone, second)); | 841 *Object::GetProperty(clone, second).ToHandleChecked()); |
834 | 842 |
835 // Flip the values. | 843 // Flip the values. |
836 JSReceiver::SetProperty(clone, first, two, NONE, SLOPPY).Check(); | 844 JSReceiver::SetProperty(clone, first, two, NONE, SLOPPY).Check(); |
837 JSReceiver::SetProperty(clone, second, one, NONE, SLOPPY).Check(); | 845 JSReceiver::SetProperty(clone, second, one, NONE, SLOPPY).Check(); |
838 | 846 |
839 JSReceiver::SetElement(clone, 0, second, NONE, SLOPPY).Check(); | 847 JSReceiver::SetElement(clone, 0, second, NONE, SLOPPY).Check(); |
840 JSReceiver::SetElement(clone, 1, first, NONE, SLOPPY).Check(); | 848 JSReceiver::SetElement(clone, 1, first, NONE, SLOPPY).Check(); |
841 | 849 |
842 CHECK_EQ(*i::Object::GetElement(isolate, obj, 1).ToHandleChecked(), | 850 CHECK_EQ(*i::Object::GetElement(isolate, obj, 1).ToHandleChecked(), |
843 *i::Object::GetElement(isolate, clone, 0).ToHandleChecked()); | 851 *i::Object::GetElement(isolate, clone, 0).ToHandleChecked()); |
844 CHECK_EQ(*i::Object::GetElement(isolate, obj, 0).ToHandleChecked(), | 852 CHECK_EQ(*i::Object::GetElement(isolate, obj, 0).ToHandleChecked(), |
845 *i::Object::GetElement(isolate, clone, 1).ToHandleChecked()); | 853 *i::Object::GetElement(isolate, clone, 1).ToHandleChecked()); |
846 | 854 |
847 CHECK_EQ(*Object::GetProperty(obj, second), | 855 CHECK_EQ(*Object::GetProperty(obj, second).ToHandleChecked(), |
848 *Object::GetProperty(clone, first)); | 856 *Object::GetProperty(clone, first).ToHandleChecked()); |
849 CHECK_EQ(*Object::GetProperty(obj, first), | 857 CHECK_EQ(*Object::GetProperty(obj, first).ToHandleChecked(), |
850 *Object::GetProperty(clone, second)); | 858 *Object::GetProperty(clone, second).ToHandleChecked()); |
851 } | 859 } |
852 | 860 |
853 | 861 |
854 TEST(StringAllocation) { | 862 TEST(StringAllocation) { |
855 CcTest::InitializeVM(); | 863 CcTest::InitializeVM(); |
856 Isolate* isolate = CcTest::i_isolate(); | 864 Isolate* isolate = CcTest::i_isolate(); |
857 Factory* factory = isolate->factory(); | 865 Factory* factory = isolate->factory(); |
858 | 866 |
859 const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 }; | 867 const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 }; |
860 for (int length = 0; length < 100; length++) { | 868 for (int length = 0; length < 100; length++) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 "};" | 1067 "};" |
1060 "foo()"; | 1068 "foo()"; |
1061 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); | 1069 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
1062 | 1070 |
1063 // This compile will add the code to the compilation cache. | 1071 // This compile will add the code to the compilation cache. |
1064 { v8::HandleScope scope(CcTest::isolate()); | 1072 { v8::HandleScope scope(CcTest::isolate()); |
1065 CompileRun(source); | 1073 CompileRun(source); |
1066 } | 1074 } |
1067 | 1075 |
1068 // Check function is compiled. | 1076 // Check function is compiled. |
1069 Handle<Object> func_value = | 1077 Handle<Object> func_value = Object::GetProperty( |
1070 Object::GetProperty(CcTest::i_isolate()->global_object(), foo_name); | 1078 CcTest::i_isolate()->global_object(), foo_name).ToHandleChecked(); |
1071 CHECK(func_value->IsJSFunction()); | 1079 CHECK(func_value->IsJSFunction()); |
1072 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); | 1080 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); |
1073 CHECK(function->shared()->is_compiled()); | 1081 CHECK(function->shared()->is_compiled()); |
1074 | 1082 |
1075 // The code will survive at least two GCs. | 1083 // The code will survive at least two GCs. |
1076 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1084 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1077 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1085 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1078 CHECK(function->shared()->is_compiled()); | 1086 CHECK(function->shared()->is_compiled()); |
1079 | 1087 |
1080 // Simulate several GCs that use full marking. | 1088 // Simulate several GCs that use full marking. |
(...skipping 29 matching lines...) Expand all Loading... |
1110 "foo()"; | 1118 "foo()"; |
1111 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); | 1119 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
1112 | 1120 |
1113 // Compile foo, but don't run it. | 1121 // Compile foo, but don't run it. |
1114 { v8::HandleScope scope(CcTest::isolate()); | 1122 { v8::HandleScope scope(CcTest::isolate()); |
1115 CompileRun(source); | 1123 CompileRun(source); |
1116 } | 1124 } |
1117 | 1125 |
1118 // Check function is compiled. | 1126 // Check function is compiled. |
1119 Handle<Object> func_value = | 1127 Handle<Object> func_value = |
1120 Object::GetProperty(isolate->global_object(), foo_name); | 1128 Object::GetProperty(isolate->global_object(), foo_name).ToHandleChecked(); |
1121 CHECK(func_value->IsJSFunction()); | 1129 CHECK(func_value->IsJSFunction()); |
1122 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); | 1130 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); |
1123 CHECK(function->shared()->is_compiled()); | 1131 CHECK(function->shared()->is_compiled()); |
1124 | 1132 |
1125 // The code has been run so will survive at least one GC. | 1133 // The code has been run so will survive at least one GC. |
1126 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1134 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1127 CHECK(function->shared()->is_compiled()); | 1135 CHECK(function->shared()->is_compiled()); |
1128 | 1136 |
1129 // The code was only run once, so it should be pre-aged and collected on the | 1137 // The code was only run once, so it should be pre-aged and collected on the |
1130 // next GC. | 1138 // next GC. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 "foo()"; | 1183 "foo()"; |
1176 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); | 1184 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
1177 | 1185 |
1178 // This compile will add the code to the compilation cache. | 1186 // This compile will add the code to the compilation cache. |
1179 { v8::HandleScope scope(CcTest::isolate()); | 1187 { v8::HandleScope scope(CcTest::isolate()); |
1180 CompileRun(source); | 1188 CompileRun(source); |
1181 } | 1189 } |
1182 | 1190 |
1183 // Check function is compiled. | 1191 // Check function is compiled. |
1184 Handle<Object> func_value = | 1192 Handle<Object> func_value = |
1185 Object::GetProperty(isolate->global_object(), foo_name); | 1193 Object::GetProperty(isolate->global_object(), foo_name).ToHandleChecked(); |
1186 CHECK(func_value->IsJSFunction()); | 1194 CHECK(func_value->IsJSFunction()); |
1187 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); | 1195 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); |
1188 CHECK(function->shared()->is_compiled()); | 1196 CHECK(function->shared()->is_compiled()); |
1189 | 1197 |
1190 // The code will survive at least two GCs. | 1198 // The code will survive at least two GCs. |
1191 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1199 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1192 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1200 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1193 CHECK(function->shared()->is_compiled()); | 1201 CHECK(function->shared()->is_compiled()); |
1194 | 1202 |
1195 // Simulate several GCs that use incremental marking. | 1203 // Simulate several GCs that use incremental marking. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 // Perfrom one initial GC to enable code flushing. | 1260 // Perfrom one initial GC to enable code flushing. |
1253 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1261 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1254 | 1262 |
1255 // This compile will add the code to the compilation cache. | 1263 // This compile will add the code to the compilation cache. |
1256 { v8::HandleScope scope(CcTest::isolate()); | 1264 { v8::HandleScope scope(CcTest::isolate()); |
1257 CompileRun(source); | 1265 CompileRun(source); |
1258 } | 1266 } |
1259 | 1267 |
1260 // Check functions are compiled. | 1268 // Check functions are compiled. |
1261 Handle<Object> func_value = | 1269 Handle<Object> func_value = |
1262 Object::GetProperty(isolate->global_object(), foo_name); | 1270 Object::GetProperty(isolate->global_object(), foo_name).ToHandleChecked(); |
1263 CHECK(func_value->IsJSFunction()); | 1271 CHECK(func_value->IsJSFunction()); |
1264 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); | 1272 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); |
1265 CHECK(function->shared()->is_compiled()); | 1273 CHECK(function->shared()->is_compiled()); |
1266 Handle<Object> func_value2 = | 1274 Handle<Object> func_value2 = |
1267 Object::GetProperty(isolate->global_object(), bar_name); | 1275 Object::GetProperty(isolate->global_object(), bar_name).ToHandleChecked(); |
1268 CHECK(func_value2->IsJSFunction()); | 1276 CHECK(func_value2->IsJSFunction()); |
1269 Handle<JSFunction> function2 = Handle<JSFunction>::cast(func_value2); | 1277 Handle<JSFunction> function2 = Handle<JSFunction>::cast(func_value2); |
1270 CHECK(function2->shared()->is_compiled()); | 1278 CHECK(function2->shared()->is_compiled()); |
1271 | 1279 |
1272 // Clear references to functions so that one of them can die. | 1280 // Clear references to functions so that one of them can die. |
1273 { v8::HandleScope scope(CcTest::isolate()); | 1281 { v8::HandleScope scope(CcTest::isolate()); |
1274 CompileRun("foo = 0; bar = 0;"); | 1282 CompileRun("foo = 0; bar = 0;"); |
1275 } | 1283 } |
1276 | 1284 |
1277 // Bump the code age so that flushing is triggered while the function | 1285 // Bump the code age so that flushing is triggered while the function |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 "foo()"; | 1322 "foo()"; |
1315 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); | 1323 Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
1316 | 1324 |
1317 // This compile will add the code to the compilation cache. | 1325 // This compile will add the code to the compilation cache. |
1318 { v8::HandleScope scope(CcTest::isolate()); | 1326 { v8::HandleScope scope(CcTest::isolate()); |
1319 CompileRun(source); | 1327 CompileRun(source); |
1320 } | 1328 } |
1321 | 1329 |
1322 // Check function is compiled. | 1330 // Check function is compiled. |
1323 Handle<Object> func_value = | 1331 Handle<Object> func_value = |
1324 Object::GetProperty(isolate->global_object(), foo_name); | 1332 Object::GetProperty(isolate->global_object(), foo_name).ToHandleChecked(); |
1325 CHECK(func_value->IsJSFunction()); | 1333 CHECK(func_value->IsJSFunction()); |
1326 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); | 1334 Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); |
1327 CHECK(function->shared()->is_compiled()); | 1335 CHECK(function->shared()->is_compiled()); |
1328 | 1336 |
1329 // The code will survive at least two GCs. | 1337 // The code will survive at least two GCs. |
1330 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1338 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1331 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 1339 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
1332 CHECK(function->shared()->is_compiled()); | 1340 CHECK(function->shared()->is_compiled()); |
1333 | 1341 |
1334 // Bump the code age so that flushing is triggered. | 1342 // Bump the code age so that flushing is triggered. |
(...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4040 v8::Context::Scope cscope(context); | 4048 v8::Context::Scope cscope(context); |
4041 | 4049 |
4042 v8::Local<v8::Value> result = CompileRun( | 4050 v8::Local<v8::Value> result = CompileRun( |
4043 "var locals = '';" | 4051 "var locals = '';" |
4044 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" | 4052 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" |
4045 "eval('function f() {' + locals + 'return function() { return v0; }; }');" | 4053 "eval('function f() {' + locals + 'return function() { return v0; }; }');" |
4046 "interrupt();" // This triggers a fake stack overflow in f. | 4054 "interrupt();" // This triggers a fake stack overflow in f. |
4047 "f()()"); | 4055 "f()()"); |
4048 CHECK_EQ(42.0, result->ToNumber()->Value()); | 4056 CHECK_EQ(42.0, result->ToNumber()->Value()); |
4049 } | 4057 } |
OLD | NEW |