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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 Factory* factory = isolate->factory(); | 255 Factory* factory = isolate->factory(); |
256 | 256 |
257 HandleScope sc(isolate); | 257 HandleScope sc(isolate); |
258 // Check GC. | 258 // Check GC. |
259 heap->CollectGarbage(NEW_SPACE); | 259 heap->CollectGarbage(NEW_SPACE); |
260 | 260 |
261 Handle<String> name = factory->InternalizeUtf8String("theFunction"); | 261 Handle<String> name = factory->InternalizeUtf8String("theFunction"); |
262 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); | 262 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); |
263 Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx"); | 263 Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx"); |
264 Handle<String> obj_name = factory->InternalizeUtf8String("theObject"); | 264 Handle<String> obj_name = factory->InternalizeUtf8String("theObject"); |
| 265 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
| 266 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); |
265 | 267 |
266 { | 268 { |
267 HandleScope inner_scope(isolate); | 269 HandleScope inner_scope(isolate); |
268 // Allocate a function and keep it in global object's property. | 270 // Allocate a function and keep it in global object's property. |
269 Handle<JSFunction> function = | 271 Handle<JSFunction> function = |
270 factory->NewFunction(name, factory->undefined_value()); | 272 factory->NewFunction(name, factory->undefined_value()); |
271 Handle<Map> initial_map = | 273 Handle<Map> initial_map = |
272 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 274 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
273 function->set_initial_map(*initial_map); | 275 function->set_initial_map(*initial_map); |
274 Isolate::Current()->context()->global_object()->SetProperty( | 276 Handle<GlobalObject> global(Isolate::Current()->context()->global_object()); |
275 *name, *function, NONE, kNonStrictMode)->ToObjectChecked(); | 277 JSReceiver::SetProperty(global, name, function, NONE, kNonStrictMode); |
276 // Allocate an object. Unrooted after leaving the scope. | 278 // Allocate an object. Unrooted after leaving the scope. |
277 Handle<JSObject> obj = factory->NewJSObject(function); | 279 Handle<JSObject> obj = factory->NewJSObject(function); |
278 obj->SetProperty( | 280 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); |
279 *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); | 281 JSReceiver::SetProperty(obj, prop_namex, twenty_four, NONE, kNonStrictMode); |
280 obj->SetProperty( | |
281 *prop_namex, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked(); | |
282 | 282 |
283 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); | 283 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); |
284 CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex)); | 284 CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex)); |
285 } | 285 } |
286 | 286 |
287 heap->CollectGarbage(NEW_SPACE); | 287 heap->CollectGarbage(NEW_SPACE); |
288 | 288 |
289 // Function should be alive. | 289 // Function should be alive. |
290 CHECK(Isolate::Current()->context()->global_object()-> | 290 CHECK(Isolate::Current()->context()->global_object()-> |
291 HasLocalProperty(*name)); | 291 HasLocalProperty(*name)); |
292 // Check function is retained. | 292 // Check function is retained. |
293 Object* func_value = Isolate::Current()->context()->global_object()-> | 293 Object* func_value = Isolate::Current()->context()->global_object()-> |
294 GetProperty(*name)->ToObjectChecked(); | 294 GetProperty(*name)->ToObjectChecked(); |
295 CHECK(func_value->IsJSFunction()); | 295 CHECK(func_value->IsJSFunction()); |
296 Handle<JSFunction> function(JSFunction::cast(func_value)); | 296 Handle<JSFunction> function(JSFunction::cast(func_value)); |
297 | 297 |
298 { | 298 { |
299 HandleScope inner_scope(isolate); | 299 HandleScope inner_scope(isolate); |
300 // Allocate another object, make it reachable from global. | 300 // Allocate another object, make it reachable from global. |
301 Handle<JSObject> obj = factory->NewJSObject(function); | 301 Handle<JSObject> obj = factory->NewJSObject(function); |
302 Isolate::Current()->context()->global_object()->SetProperty( | 302 Handle<GlobalObject> global(Isolate::Current()->context()->global_object()); |
303 *obj_name, *obj, NONE, kNonStrictMode)->ToObjectChecked(); | 303 JSReceiver::SetProperty(global, obj_name, obj, NONE, kNonStrictMode); |
304 obj->SetProperty( | 304 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); |
305 *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); | |
306 } | 305 } |
307 | 306 |
308 // After gc, it should survive. | 307 // After gc, it should survive. |
309 heap->CollectGarbage(NEW_SPACE); | 308 heap->CollectGarbage(NEW_SPACE); |
310 | 309 |
311 CHECK(Isolate::Current()->context()->global_object()-> | 310 CHECK(Isolate::Current()->context()->global_object()-> |
312 HasLocalProperty(*obj_name)); | 311 HasLocalProperty(*obj_name)); |
313 CHECK(Isolate::Current()->context()->global_object()-> | 312 CHECK(Isolate::Current()->context()->global_object()-> |
314 GetProperty(*obj_name)->ToObjectChecked()->IsJSObject()); | 313 GetProperty(*obj_name)->ToObjectChecked()->IsJSObject()); |
315 Object* obj = Isolate::Current()->context()->global_object()-> | 314 Object* obj = Isolate::Current()->context()->global_object()-> |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 Factory* factory = isolate->factory(); | 620 Factory* factory = isolate->factory(); |
622 | 621 |
623 v8::HandleScope sc(CcTest::isolate()); | 622 v8::HandleScope sc(CcTest::isolate()); |
624 Handle<String> name = factory->InternalizeUtf8String("theFunction"); | 623 Handle<String> name = factory->InternalizeUtf8String("theFunction"); |
625 Handle<JSFunction> function = | 624 Handle<JSFunction> function = |
626 factory->NewFunction(name, factory->undefined_value()); | 625 factory->NewFunction(name, factory->undefined_value()); |
627 Handle<Map> initial_map = | 626 Handle<Map> initial_map = |
628 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 627 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
629 function->set_initial_map(*initial_map); | 628 function->set_initial_map(*initial_map); |
630 | 629 |
| 630 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
| 631 Handle<Smi> twenty_four(Smi::FromInt(24), isolate); |
| 632 |
631 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); | 633 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); |
632 Handle<JSObject> obj = factory->NewJSObject(function); | 634 Handle<JSObject> obj = factory->NewJSObject(function); |
633 obj->SetProperty( | 635 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); |
634 *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); | |
635 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); | 636 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); |
636 // Check that we can add properties to function objects. | 637 // Check that we can add properties to function objects. |
637 function->SetProperty( | 638 JSReceiver::SetProperty(function, prop_name, twenty_four, NONE, |
638 *prop_name, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked(); | 639 kNonStrictMode); |
639 CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name)); | 640 CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name)); |
640 } | 641 } |
641 | 642 |
642 | 643 |
643 TEST(ObjectProperties) { | 644 TEST(ObjectProperties) { |
644 CcTest::InitializeVM(); | 645 CcTest::InitializeVM(); |
645 Isolate* isolate = Isolate::Current(); | 646 Isolate* isolate = Isolate::Current(); |
646 Factory* factory = isolate->factory(); | 647 Factory* factory = isolate->factory(); |
647 | 648 |
648 v8::HandleScope sc(CcTest::isolate()); | 649 v8::HandleScope sc(CcTest::isolate()); |
649 String* object_string = String::cast(HEAP->Object_string()); | 650 String* object_string = String::cast(HEAP->Object_string()); |
650 Object* raw_object = Isolate::Current()->context()->global_object()-> | 651 Object* raw_object = Isolate::Current()->context()->global_object()-> |
651 GetProperty(object_string)->ToObjectChecked(); | 652 GetProperty(object_string)->ToObjectChecked(); |
652 JSFunction* object_function = JSFunction::cast(raw_object); | 653 JSFunction* object_function = JSFunction::cast(raw_object); |
653 Handle<JSFunction> constructor(object_function); | 654 Handle<JSFunction> constructor(object_function); |
654 Handle<JSObject> obj = factory->NewJSObject(constructor); | 655 Handle<JSObject> obj = factory->NewJSObject(constructor); |
655 Handle<String> first = factory->InternalizeUtf8String("first"); | 656 Handle<String> first = factory->InternalizeUtf8String("first"); |
656 Handle<String> second = factory->InternalizeUtf8String("second"); | 657 Handle<String> second = factory->InternalizeUtf8String("second"); |
657 | 658 |
| 659 Handle<Smi> one(Smi::FromInt(1), isolate); |
| 660 Handle<Smi> two(Smi::FromInt(2), isolate); |
| 661 |
658 // check for empty | 662 // check for empty |
659 CHECK(!obj->HasLocalProperty(*first)); | 663 CHECK(!obj->HasLocalProperty(*first)); |
660 | 664 |
661 // add first | 665 // add first |
662 obj->SetProperty( | 666 JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode); |
663 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); | |
664 CHECK(obj->HasLocalProperty(*first)); | 667 CHECK(obj->HasLocalProperty(*first)); |
665 | 668 |
666 // delete first | 669 // delete first |
667 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); | 670 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); |
668 CHECK(!obj->HasLocalProperty(*first)); | 671 CHECK(!obj->HasLocalProperty(*first)); |
669 | 672 |
670 // add first and then second | 673 // add first and then second |
671 obj->SetProperty( | 674 JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode); |
672 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); | 675 JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode); |
673 obj->SetProperty( | |
674 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); | |
675 CHECK(obj->HasLocalProperty(*first)); | 676 CHECK(obj->HasLocalProperty(*first)); |
676 CHECK(obj->HasLocalProperty(*second)); | 677 CHECK(obj->HasLocalProperty(*second)); |
677 | 678 |
678 // delete first and then second | 679 // delete first and then second |
679 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); | 680 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); |
680 CHECK(obj->HasLocalProperty(*second)); | 681 CHECK(obj->HasLocalProperty(*second)); |
681 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION); | 682 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION); |
682 CHECK(!obj->HasLocalProperty(*first)); | 683 CHECK(!obj->HasLocalProperty(*first)); |
683 CHECK(!obj->HasLocalProperty(*second)); | 684 CHECK(!obj->HasLocalProperty(*second)); |
684 | 685 |
685 // add first and then second | 686 // add first and then second |
686 obj->SetProperty( | 687 JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode); |
687 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); | 688 JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode); |
688 obj->SetProperty( | |
689 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); | |
690 CHECK(obj->HasLocalProperty(*first)); | 689 CHECK(obj->HasLocalProperty(*first)); |
691 CHECK(obj->HasLocalProperty(*second)); | 690 CHECK(obj->HasLocalProperty(*second)); |
692 | 691 |
693 // delete second and then first | 692 // delete second and then first |
694 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION); | 693 JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION); |
695 CHECK(obj->HasLocalProperty(*first)); | 694 CHECK(obj->HasLocalProperty(*first)); |
696 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); | 695 JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); |
697 CHECK(!obj->HasLocalProperty(*first)); | 696 CHECK(!obj->HasLocalProperty(*first)); |
698 CHECK(!obj->HasLocalProperty(*second)); | 697 CHECK(!obj->HasLocalProperty(*second)); |
699 | 698 |
700 // check string and internalized string match | 699 // check string and internalized string match |
701 const char* string1 = "fisk"; | 700 const char* string1 = "fisk"; |
702 Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1)); | 701 Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1)); |
703 obj->SetProperty( | 702 JSReceiver::SetProperty(obj, s1, one, NONE, kNonStrictMode); |
704 *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); | |
705 Handle<String> s1_string = factory->InternalizeUtf8String(string1); | 703 Handle<String> s1_string = factory->InternalizeUtf8String(string1); |
706 CHECK(obj->HasLocalProperty(*s1_string)); | 704 CHECK(obj->HasLocalProperty(*s1_string)); |
707 | 705 |
708 // check internalized string and string match | 706 // check internalized string and string match |
709 const char* string2 = "fugl"; | 707 const char* string2 = "fugl"; |
710 Handle<String> s2_string = factory->InternalizeUtf8String(string2); | 708 Handle<String> s2_string = factory->InternalizeUtf8String(string2); |
711 obj->SetProperty( | 709 JSReceiver::SetProperty(obj, s2_string, one, NONE, kNonStrictMode); |
712 *s2_string, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); | |
713 Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2)); | 710 Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2)); |
714 CHECK(obj->HasLocalProperty(*s2)); | 711 CHECK(obj->HasLocalProperty(*s2)); |
715 } | 712 } |
716 | 713 |
717 | 714 |
718 TEST(JSObjectMaps) { | 715 TEST(JSObjectMaps) { |
719 CcTest::InitializeVM(); | 716 CcTest::InitializeVM(); |
720 Isolate* isolate = Isolate::Current(); | 717 Isolate* isolate = Isolate::Current(); |
721 Factory* factory = isolate->factory(); | 718 Factory* factory = isolate->factory(); |
722 | 719 |
723 v8::HandleScope sc(CcTest::isolate()); | 720 v8::HandleScope sc(CcTest::isolate()); |
724 Handle<String> name = factory->InternalizeUtf8String("theFunction"); | 721 Handle<String> name = factory->InternalizeUtf8String("theFunction"); |
725 Handle<JSFunction> function = | 722 Handle<JSFunction> function = |
726 factory->NewFunction(name, factory->undefined_value()); | 723 factory->NewFunction(name, factory->undefined_value()); |
727 Handle<Map> initial_map = | 724 Handle<Map> initial_map = |
728 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 725 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
729 function->set_initial_map(*initial_map); | 726 function->set_initial_map(*initial_map); |
730 | 727 |
731 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); | 728 Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); |
732 Handle<JSObject> obj = factory->NewJSObject(function); | 729 Handle<JSObject> obj = factory->NewJSObject(function); |
733 | 730 |
734 // Set a propery | 731 // Set a propery |
735 obj->SetProperty( | 732 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
736 *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); | 733 JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); |
737 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); | 734 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); |
738 | 735 |
739 // Check the map has changed | 736 // Check the map has changed |
740 CHECK(*initial_map != obj->map()); | 737 CHECK(*initial_map != obj->map()); |
741 } | 738 } |
742 | 739 |
743 | 740 |
744 TEST(JSArray) { | 741 TEST(JSArray) { |
745 CcTest::InitializeVM(); | 742 CcTest::InitializeVM(); |
746 Isolate* isolate = Isolate::Current(); | 743 Isolate* isolate = Isolate::Current(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 v8::HandleScope sc(CcTest::isolate()); | 795 v8::HandleScope sc(CcTest::isolate()); |
799 String* object_string = String::cast(HEAP->Object_string()); | 796 String* object_string = String::cast(HEAP->Object_string()); |
800 Object* raw_object = Isolate::Current()->context()->global_object()-> | 797 Object* raw_object = Isolate::Current()->context()->global_object()-> |
801 GetProperty(object_string)->ToObjectChecked(); | 798 GetProperty(object_string)->ToObjectChecked(); |
802 JSFunction* object_function = JSFunction::cast(raw_object); | 799 JSFunction* object_function = JSFunction::cast(raw_object); |
803 Handle<JSFunction> constructor(object_function); | 800 Handle<JSFunction> constructor(object_function); |
804 Handle<JSObject> obj = factory->NewJSObject(constructor); | 801 Handle<JSObject> obj = factory->NewJSObject(constructor); |
805 Handle<String> first = factory->InternalizeUtf8String("first"); | 802 Handle<String> first = factory->InternalizeUtf8String("first"); |
806 Handle<String> second = factory->InternalizeUtf8String("second"); | 803 Handle<String> second = factory->InternalizeUtf8String("second"); |
807 | 804 |
808 obj->SetProperty( | 805 Handle<Smi> one(Smi::FromInt(1), isolate); |
809 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); | 806 Handle<Smi> two(Smi::FromInt(2), isolate); |
810 obj->SetProperty( | 807 |
811 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); | 808 JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode); |
| 809 JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode); |
812 | 810 |
813 obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked(); | 811 obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked(); |
814 obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked(); | 812 obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked(); |
815 | 813 |
816 // Make the clone. | 814 // Make the clone. |
817 Handle<JSObject> clone = JSObject::Copy(obj); | 815 Handle<JSObject> clone = JSObject::Copy(obj); |
818 CHECK(!clone.is_identical_to(obj)); | 816 CHECK(!clone.is_identical_to(obj)); |
819 | 817 |
820 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 0)); | 818 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 0)); |
821 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 1)); | 819 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 1)); |
822 | 820 |
823 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); | 821 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); |
824 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); | 822 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); |
825 | 823 |
826 // Flip the values. | 824 // Flip the values. |
827 clone->SetProperty( | 825 JSReceiver::SetProperty(clone, first, two, NONE, kNonStrictMode); |
828 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); | 826 JSReceiver::SetProperty(clone, second, one, NONE, kNonStrictMode); |
829 clone->SetProperty( | |
830 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); | |
831 | 827 |
832 clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked(); | 828 clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked(); |
833 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked(); | 829 clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked(); |
834 | 830 |
835 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0)); | 831 CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0)); |
836 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1)); | 832 CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1)); |
837 | 833 |
838 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); | 834 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); |
839 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); | 835 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); |
840 } | 836 } |
(...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3002 " 'f' + i + '();');" | 2998 " 'f' + i + '();');" |
3003 "}"); | 2999 "}"); |
3004 } | 3000 } |
3005 heap->CollectAllGarbage(Heap::kNoGCFlags); | 3001 heap->CollectAllGarbage(Heap::kNoGCFlags); |
3006 | 3002 |
3007 // Fourth is the tricky part. Make sure the code containing the CallIC is | 3003 // Fourth is the tricky part. Make sure the code containing the CallIC is |
3008 // visited first without clearing the IC. The shared function info is then | 3004 // visited first without clearing the IC. The shared function info is then |
3009 // visited later, causing the CallIC to be cleared. | 3005 // visited later, causing the CallIC to be cleared. |
3010 Handle<String> name = isolate->factory()->InternalizeUtf8String("call"); | 3006 Handle<String> name = isolate->factory()->InternalizeUtf8String("call"); |
3011 Handle<GlobalObject> global(isolate->context()->global_object()); | 3007 Handle<GlobalObject> global(isolate->context()->global_object()); |
| 3008 Handle<Smi> zero(Smi::FromInt(0), isolate); |
3012 MaybeObject* maybe_call = global->GetProperty(*name); | 3009 MaybeObject* maybe_call = global->GetProperty(*name); |
3013 JSFunction* call = JSFunction::cast(maybe_call->ToObjectChecked()); | 3010 JSFunction* call = JSFunction::cast(maybe_call->ToObjectChecked()); |
3014 USE(global->SetProperty(*name, Smi::FromInt(0), NONE, kNonStrictMode)); | 3011 JSReceiver::SetProperty(global, name, zero, NONE, kNonStrictMode); |
3015 isolate->compilation_cache()->Clear(); | 3012 isolate->compilation_cache()->Clear(); |
3016 call->shared()->set_ic_age(heap->global_ic_age() + 1); | 3013 call->shared()->set_ic_age(heap->global_ic_age() + 1); |
3017 Handle<Object> call_code(call->code(), isolate); | 3014 Handle<Object> call_code(call->code(), isolate); |
3018 Handle<Object> call_function(call, isolate); | 3015 Handle<Object> call_function(call, isolate); |
3019 | 3016 |
3020 // Now we are ready to mess up the heap. | 3017 // Now we are ready to mess up the heap. |
3021 heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); | 3018 heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); |
3022 | 3019 |
3023 // Either heap verification caught the problem already or we go kaboom once | 3020 // Either heap verification caught the problem already or we go kaboom once |
3024 // the CallIC is executed the next time. | 3021 // the CallIC is executed the next time. |
3025 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); | 3022 JSReceiver::SetProperty(global, name, call_function, NONE, kNonStrictMode); |
3026 CompileRun("call();"); | 3023 CompileRun("call();"); |
3027 } | 3024 } |
3028 | 3025 |
3029 | 3026 |
3030 TEST(Regress159140) { | 3027 TEST(Regress159140) { |
3031 i::FLAG_allow_natives_syntax = true; | 3028 i::FLAG_allow_natives_syntax = true; |
3032 i::FLAG_flush_code_incrementally = true; | 3029 i::FLAG_flush_code_incrementally = true; |
3033 CcTest::InitializeVM(); | 3030 CcTest::InitializeVM(); |
3034 Isolate* isolate = Isolate::Current(); | 3031 Isolate* isolate = Isolate::Current(); |
3035 Heap* heap = isolate->heap(); | 3032 Heap* heap = isolate->heap(); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3443 " var a = new Array(n);" | 3440 " var a = new Array(n);" |
3444 " for (var i = 0; i < n; i += 100) a[i] = i;" | 3441 " for (var i = 0; i < n; i += 100) a[i] = i;" |
3445 "};" | 3442 "};" |
3446 "f(10 * 1024 * 1024);"); | 3443 "f(10 * 1024 * 1024);"); |
3447 IncrementalMarking* marking = HEAP->incremental_marking(); | 3444 IncrementalMarking* marking = HEAP->incremental_marking(); |
3448 if (marking->IsStopped()) marking->Start(); | 3445 if (marking->IsStopped()) marking->Start(); |
3449 // This big step should be sufficient to mark the whole array. | 3446 // This big step should be sufficient to mark the whole array. |
3450 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 3447 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
3451 ASSERT(marking->IsComplete()); | 3448 ASSERT(marking->IsComplete()); |
3452 } | 3449 } |
OLD | NEW |