OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 __ test(eax, Immediate(kSmiTagMask)); | 749 __ test(eax, Immediate(kSmiTagMask)); |
750 __ j(zero, &convert); | 750 __ j(zero, &convert); |
751 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ecx); | 751 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ecx); |
752 __ j(above_equal, &done_convert); | 752 __ j(above_equal, &done_convert); |
753 __ bind(&convert); | 753 __ bind(&convert); |
754 __ push(eax); | 754 __ push(eax); |
755 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 755 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
756 __ bind(&done_convert); | 756 __ bind(&done_convert); |
757 __ push(eax); | 757 __ push(eax); |
758 | 758 |
759 // TODO(kasperl): Check cache validity in generated code. This is a | 759 // Check cache validity in generated code. This is a fast case for |
760 // fast case for the JSObject::IsSimpleEnum cache validity | 760 // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
761 // checks. If we cannot guarantee cache validity, call the runtime | 761 // guarantee cache validity, call the runtime system to check cache |
762 // system to check cache validity or get the property names in a | 762 // validity or get the property names in a fixed array. |
763 // fixed array. | 763 Label next, call_runtime; |
| 764 __ mov(ecx, eax); |
| 765 __ bind(&next); |
| 766 |
| 767 // Check that there are no elements. Register ecx contains the |
| 768 // current JS object we've reached through the prototype chain. |
| 769 __ cmp(FieldOperand(ecx, JSObject::kElementsOffset), |
| 770 Factory::empty_fixed_array()); |
| 771 __ j(not_equal, &call_runtime); |
| 772 |
| 773 // Check that instance descriptors are not empty so that we can |
| 774 // check for an enum cache. Leave the map in ebx for the subsequent |
| 775 // prototype load. |
| 776 __ mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset)); |
| 777 __ mov(edx, FieldOperand(ebx, Map::kInstanceDescriptorsOffset)); |
| 778 __ cmp(edx, Factory::empty_descriptor_array()); |
| 779 __ j(equal, &call_runtime); |
| 780 |
| 781 // Check that there in an enum cache in the non-empty instance |
| 782 // descriptors (edx). This is the case if the next enumeration |
| 783 // index field does not contain a smi. |
| 784 __ mov(edx, FieldOperand(edx, DescriptorArray::kEnumerationIndexOffset)); |
| 785 __ test(edx, Immediate(kSmiTagMask)); |
| 786 __ j(zero, &call_runtime); |
| 787 |
| 788 // For all objects but the receiver, check that the cache is empty. |
| 789 Label check_prototype; |
| 790 __ cmp(ecx, Operand(eax)); |
| 791 __ j(equal, &check_prototype); |
| 792 __ mov(edx, FieldOperand(edx, DescriptorArray::kEnumCacheBridgeCacheOffset)); |
| 793 __ cmp(edx, Factory::empty_fixed_array()); |
| 794 __ j(not_equal, &call_runtime); |
| 795 |
| 796 // Load the prototype from the map and loop if non-null. |
| 797 __ bind(&check_prototype); |
| 798 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
| 799 __ cmp(ecx, Factory::null_value()); |
| 800 __ j(not_equal, &next); |
| 801 |
| 802 // The enum cache is valid. Load the map of the object being |
| 803 // iterated over and use the cache for the iteration. |
| 804 Label use_cache; |
| 805 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); |
| 806 __ jmp(&use_cache); |
764 | 807 |
765 // Get the set of properties to enumerate. | 808 // Get the set of properties to enumerate. |
| 809 __ bind(&call_runtime); |
766 __ push(eax); // Duplicate the enumerable object on the stack. | 810 __ push(eax); // Duplicate the enumerable object on the stack. |
767 __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); | 811 __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); |
768 | 812 |
769 // If we got a map from the runtime call, we can do a fast | 813 // If we got a map from the runtime call, we can do a fast |
770 // modification check. Otherwise, we got a fixed array, and we have | 814 // modification check. Otherwise, we got a fixed array, and we have |
771 // to do a slow check. | 815 // to do a slow check. |
772 Label fixed_array; | 816 Label fixed_array; |
773 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), Factory::meta_map()); | 817 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), Factory::meta_map()); |
774 __ j(not_equal, &fixed_array); | 818 __ j(not_equal, &fixed_array); |
775 | 819 |
776 // We got a map in register eax. Get the enumeration cache from it. | 820 // We got a map in register eax. Get the enumeration cache from it. |
| 821 __ bind(&use_cache); |
777 __ mov(ecx, FieldOperand(eax, Map::kInstanceDescriptorsOffset)); | 822 __ mov(ecx, FieldOperand(eax, Map::kInstanceDescriptorsOffset)); |
778 __ mov(ecx, FieldOperand(ecx, DescriptorArray::kEnumerationIndexOffset)); | 823 __ mov(ecx, FieldOperand(ecx, DescriptorArray::kEnumerationIndexOffset)); |
779 __ mov(edx, FieldOperand(ecx, DescriptorArray::kEnumCacheBridgeCacheOffset)); | 824 __ mov(edx, FieldOperand(ecx, DescriptorArray::kEnumCacheBridgeCacheOffset)); |
780 | 825 |
781 // Setup the four remaining stack slots. | 826 // Setup the four remaining stack slots. |
782 __ push(eax); // Map. | 827 __ push(eax); // Map. |
783 __ push(edx); // Enumeration cache. | 828 __ push(edx); // Enumeration cache. |
784 __ mov(eax, FieldOperand(edx, FixedArray::kLengthOffset)); | 829 __ mov(eax, FieldOperand(edx, FixedArray::kLengthOffset)); |
785 __ push(eax); // Enumeration cache length (as smi). | 830 __ push(eax); // Enumeration cache length (as smi). |
786 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 831 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
(...skipping 2944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3731 // And return. | 3776 // And return. |
3732 __ ret(0); | 3777 __ ret(0); |
3733 } | 3778 } |
3734 | 3779 |
3735 | 3780 |
3736 #undef __ | 3781 #undef __ |
3737 | 3782 |
3738 } } // namespace v8::internal | 3783 } } // namespace v8::internal |
3739 | 3784 |
3740 #endif // V8_TARGET_ARCH_IA32 | 3785 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |