OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2748 DO_SMI_CHECK); | 2748 DO_SMI_CHECK); |
2749 | 2749 |
2750 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); | 2750 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); |
2751 __ jmp(ic, RelocInfo::CODE_TARGET); | 2751 __ jmp(ic, RelocInfo::CODE_TARGET); |
2752 | 2752 |
2753 // Return the generated code. | 2753 // Return the generated code. |
2754 return GetCode(NORMAL, NULL); | 2754 return GetCode(NORMAL, NULL); |
2755 } | 2755 } |
2756 | 2756 |
2757 | 2757 |
2758 MaybeObject* KeyedStoreStubCompiler::CompileStoreElementWithTransition( | 2758 MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( |
2759 Map* transitioned_map, | 2759 MapList* receiver_maps, |
2760 Map* untransitioned_map_1, | 2760 CodeList* handler_stubs, |
2761 Map* untransitioned_map_2) { | 2761 MapList* transitioned_maps) { |
2762 // ----------- S t a t e ------------- | 2762 // ----------- S t a t e ------------- |
2763 // -- eax : value | 2763 // -- eax : value |
2764 // -- ecx : key | 2764 // -- ecx : key |
2765 // -- edx : receiver | |
2766 // -- esp[0] : return address | |
2767 // ----------------------------------- | |
2768 | |
2769 // The order of map occurrences in the generated code below is important. | |
2770 // Both IC code and Crankshaft rely on |transitioned_map| being the first | |
2771 // map in the stub. | |
2772 | |
2773 Code* notransition_stub; | |
2774 ElementsKind elements_kind = transitioned_map->elements_kind(); | |
2775 bool is_jsarray = transitioned_map->instance_type() == JS_ARRAY_TYPE; | |
2776 MaybeObject* maybe_stub = | |
2777 KeyedStoreElementStub(is_jsarray, elements_kind).TryGetCode(); | |
2778 if (!maybe_stub->To(¬ransition_stub)) return maybe_stub; | |
2779 | |
2780 Label just_store, miss; | |
2781 __ JumpIfSmi(edx, &miss, Label::kNear); | |
2782 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); | |
2783 // ebx: receiver->map(). | |
2784 __ cmp(ebx, Handle<Map>(transitioned_map)); | |
2785 __ j(equal, &just_store); | |
2786 ASSERT_NE(untransitioned_map_1, NULL); | |
2787 __ cmp(ebx, Handle<Map>(untransitioned_map_1)); | |
2788 // TODO(jkummerow): When we have specialized code to do the transition, | |
2789 // call that code here, then jump to just_store when the call returns. | |
2790 // <temporary: just use the generic stub> | |
2791 Code* generic_stub = (strict_mode_ == kStrictMode) | |
2792 ? isolate()->builtins()->builtin(Builtins::kKeyedStoreIC_Generic_Strict) | |
2793 : isolate()->builtins()->builtin(Builtins::kKeyedStoreIC_Generic); | |
2794 __ j(equal, Handle<Code>(generic_stub)); | |
2795 // </temporary> | |
2796 if (untransitioned_map_2 != NULL) { | |
2797 __ cmp(ebx, Handle<Map>(untransitioned_map_2)); | |
2798 // <temporary: see above, same here> | |
2799 __ j(equal, Handle<Code>(generic_stub)); | |
2800 // </temporary> | |
2801 } | |
2802 __ bind(&miss); | |
2803 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); | |
2804 __ jmp(ic, RelocInfo::CODE_TARGET); | |
2805 | |
2806 __ bind(&just_store); | |
2807 __ jmp(Handle<Code>(notransition_stub), RelocInfo::CODE_TARGET); | |
2808 | |
2809 // Return the generated code. | |
2810 return GetCode(NORMAL, NULL, MEGAMORPHIC); | |
2811 } | |
2812 | |
2813 | |
2814 MaybeObject* KeyedStoreStubCompiler::CompileStoreMegamorphic( | |
2815 MapList* receiver_maps, | |
2816 CodeList* handler_ics) { | |
2817 // ----------- S t a t e ------------- | |
2818 // -- eax : value | |
2819 // -- ecx : key | |
2820 // -- edx : receiver | 2765 // -- edx : receiver |
2821 // -- esp[0] : return address | 2766 // -- esp[0] : return address |
2822 // ----------------------------------- | 2767 // ----------------------------------- |
2823 Label miss; | 2768 Label miss; |
2824 __ JumpIfSmi(edx, &miss); | 2769 __ JumpIfSmi(edx, &miss, Label::kNear); |
2825 | 2770 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); |
2826 Register map_reg = ebx; | 2771 // ebx: receiver->map(). |
2827 __ mov(map_reg, FieldOperand(edx, HeapObject::kMapOffset)); | 2772 for (int i = 0; i < receiver_maps->length(); ++i) { |
2828 int receiver_count = receiver_maps->length(); | 2773 Handle<Map> map(receiver_maps->at(i)); |
2829 for (int current = 0; current < receiver_count; ++current) { | 2774 __ cmp(edi, map); |
2830 Handle<Map> map(receiver_maps->at(current)); | 2775 if (transitioned_maps->at(i) == NULL) { |
2831 __ cmp(map_reg, map); | 2776 __ j(equal, Handle<Code>(handler_stubs->at(i))); |
2832 __ j(equal, Handle<Code>(handler_ics->at(current))); | 2777 } else { |
| 2778 Label next_map; |
| 2779 __ j(not_equal, &next_map, Label::kNear); |
| 2780 __ mov(ebx, Immediate(Handle<Map>(transitioned_maps->at(i)))); |
| 2781 __ jmp(Handle<Code>(handler_stubs->at(i)), RelocInfo::CODE_TARGET); |
| 2782 __ bind(&next_map); |
| 2783 } |
2833 } | 2784 } |
2834 __ bind(&miss); | 2785 __ bind(&miss); |
2835 Handle<Code> miss_ic = isolate()->builtins()->KeyedStoreIC_Miss(); | 2786 Handle<Code> miss_ic = isolate()->builtins()->KeyedStoreIC_Miss(); |
2836 __ jmp(miss_ic, RelocInfo::CODE_TARGET); | 2787 __ jmp(miss_ic, RelocInfo::CODE_TARGET); |
2837 | 2788 |
2838 // Return the generated code. | 2789 // Return the generated code. |
2839 return GetCode(NORMAL, NULL, MEGAMORPHIC); | 2790 return GetCode(NORMAL, NULL, MEGAMORPHIC); |
2840 } | 2791 } |
2841 | 2792 |
2842 | 2793 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3262 Handle<Code>(stub), | 3213 Handle<Code>(stub), |
3263 DO_SMI_CHECK); | 3214 DO_SMI_CHECK); |
3264 | 3215 |
3265 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 3216 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
3266 | 3217 |
3267 // Return the generated code. | 3218 // Return the generated code. |
3268 return GetCode(NORMAL, NULL); | 3219 return GetCode(NORMAL, NULL); |
3269 } | 3220 } |
3270 | 3221 |
3271 | 3222 |
3272 MaybeObject* KeyedLoadStubCompiler::CompileLoadMegamorphic( | 3223 MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic( |
3273 MapList* receiver_maps, | 3224 MapList* receiver_maps, |
3274 CodeList* handler_ics) { | 3225 CodeList* handler_ics) { |
3275 // ----------- S t a t e ------------- | 3226 // ----------- S t a t e ------------- |
3276 // -- eax : key | 3227 // -- eax : key |
3277 // -- edx : receiver | 3228 // -- edx : receiver |
3278 // -- esp[0] : return address | 3229 // -- esp[0] : return address |
3279 // ----------------------------------- | 3230 // ----------------------------------- |
3280 Label miss; | 3231 Label miss; |
3281 __ JumpIfSmi(edx, &miss); | 3232 __ JumpIfSmi(edx, &miss); |
3282 | 3233 |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4075 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); | 4026 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); |
4076 __ jmp(ic_miss, RelocInfo::CODE_TARGET); | 4027 __ jmp(ic_miss, RelocInfo::CODE_TARGET); |
4077 } | 4028 } |
4078 | 4029 |
4079 | 4030 |
4080 #undef __ | 4031 #undef __ |
4081 | 4032 |
4082 } } // namespace v8::internal | 4033 } } // namespace v8::internal |
4083 | 4034 |
4084 #endif // V8_TARGET_ARCH_IA32 | 4035 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |