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 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2596 DO_SMI_CHECK); | 2596 DO_SMI_CHECK); |
2597 | 2597 |
2598 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); | 2598 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); |
2599 __ jmp(ic, RelocInfo::CODE_TARGET); | 2599 __ jmp(ic, RelocInfo::CODE_TARGET); |
2600 | 2600 |
2601 // Return the generated code. | 2601 // Return the generated code. |
2602 return GetCode(NORMAL, NULL); | 2602 return GetCode(NORMAL, NULL); |
2603 } | 2603 } |
2604 | 2604 |
2605 | 2605 |
2606 MaybeObject* KeyedStoreStubCompiler::CompileStoreElementWithTransition( | 2606 MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( |
2607 Map* transitioned_map, | 2607 MapList* receiver_maps, |
2608 Map* untransitioned_map_1, | 2608 CodeList* handler_stubs, |
2609 Map* untransitioned_map_2) { | 2609 MapList* transitioned_maps) { |
2610 // ----------- S t a t e ------------- | 2610 // ----------- S t a t e ------------- |
2611 // -- rax : value | 2611 // -- rax : value |
2612 // -- rcx : key | 2612 // -- rcx : key |
2613 // -- rdx : receiver | |
2614 // -- rsp[0] : return address | |
2615 // ----------------------------------- | |
2616 | |
2617 // The order of map occurrences in the generated code below is important. | |
2618 // Both IC code and Crankshaft rely on |transitioned_map| being the first | |
2619 // map in the stub. | |
2620 | |
2621 Code* notransition_stub; | |
2622 ElementsKind elements_kind = transitioned_map->elements_kind(); | |
2623 bool is_js_array = transitioned_map->instance_type() == JS_ARRAY_TYPE; | |
2624 MaybeObject* maybe_stub = | |
2625 KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode(); | |
2626 if (!maybe_stub->To(¬ransition_stub)) return maybe_stub; | |
2627 | |
2628 Label just_store, miss; | |
2629 __ JumpIfSmi(rdx, &miss, Label::kNear); | |
2630 __ movq(rbx, FieldOperand(rdx, HeapObject::kMapOffset)); | |
2631 // rbx: receiver->map(). | |
2632 __ Cmp(rbx, Handle<Map>(transitioned_map)); | |
2633 __ j(equal, &just_store); | |
2634 ASSERT_NE(untransitioned_map_1, NULL); | |
2635 __ Cmp(rbx, Handle<Map>(untransitioned_map_1)); | |
2636 Code* generic_stub = (strict_mode_ == kStrictMode) | |
2637 ? isolate()->builtins()->builtin(Builtins::kKeyedStoreIC_Generic_Strict) | |
2638 : isolate()->builtins()->builtin(Builtins::kKeyedStoreIC_Generic); | |
2639 __ j(equal, Handle<Code>(generic_stub), RelocInfo::CODE_TARGET); | |
2640 if (untransitioned_map_2 != NULL) { | |
2641 __ Cmp(rbx, Handle<Map>(untransitioned_map_2)); | |
2642 __ j(equal, Handle<Code>(generic_stub), RelocInfo::CODE_TARGET); | |
2643 } | |
2644 __ bind(&miss); | |
2645 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); | |
2646 __ jmp(ic, RelocInfo::CODE_TARGET); | |
2647 | |
2648 __ bind(&just_store); | |
2649 __ jmp(Handle<Code>(notransition_stub), RelocInfo::CODE_TARGET); | |
2650 | |
2651 // Return the generated code. | |
2652 return GetCode(NORMAL, NULL, MEGAMORPHIC); | |
2653 } | |
2654 | |
2655 | |
2656 MaybeObject* KeyedStoreStubCompiler::CompileStoreMegamorphic( | |
2657 MapList* receiver_maps, | |
2658 CodeList* handler_ics) { | |
2659 // ----------- S t a t e ------------- | |
2660 // -- rax : value | |
2661 // -- rcx : key | |
2662 // -- rdx : receiver | 2613 // -- rdx : receiver |
2663 // -- rsp[0] : return address | 2614 // -- rsp[0] : return address |
2664 // ----------------------------------- | 2615 // ----------------------------------- |
2665 Label miss; | 2616 Label miss; |
2666 __ JumpIfSmi(rdx, &miss); | 2617 __ JumpIfSmi(rdx, &miss, Label::kNear); |
2667 | 2618 |
2668 Register map_reg = rbx; | 2619 __ movq(rdi, FieldOperand(rdx, HeapObject::kMapOffset)); |
2669 __ movq(map_reg, FieldOperand(rdx, HeapObject::kMapOffset)); | |
2670 int receiver_count = receiver_maps->length(); | 2620 int receiver_count = receiver_maps->length(); |
2671 for (int current = 0; current < receiver_count; ++current) { | 2621 for (int i = 0; i < receiver_count; ++i) { |
2672 // Check map and tail call if there's a match | 2622 // Check map and tail call if there's a match |
2673 Handle<Map> map(receiver_maps->at(current)); | 2623 Handle<Map> map(receiver_maps->at(i)); |
2674 __ Cmp(map_reg, map); | 2624 __ Cmp(rdi, map); |
2675 __ j(equal, | 2625 if (transitioned_maps->at(i) == NULL) { |
2676 Handle<Code>(handler_ics->at(current)), | 2626 __ j(equal, Handle<Code>(handler_stubs->at(i)), RelocInfo::CODE_TARGET); |
2677 RelocInfo::CODE_TARGET); | 2627 } else { |
| 2628 Label next_map; |
| 2629 __ j(not_equal, &next_map, Label::kNear); |
| 2630 __ movq(rbx, |
| 2631 Handle<Map>(transitioned_maps->at(i)), |
| 2632 RelocInfo::EMBEDDED_OBJECT); |
| 2633 __ jmp(Handle<Code>(handler_stubs->at(i)), RelocInfo::CODE_TARGET); |
| 2634 __ bind(&next_map); |
| 2635 } |
2678 } | 2636 } |
2679 | 2637 |
2680 __ bind(&miss); | 2638 __ bind(&miss); |
2681 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); | 2639 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); |
2682 __ jmp(ic, RelocInfo::CODE_TARGET); | 2640 __ jmp(ic, RelocInfo::CODE_TARGET); |
2683 | 2641 |
2684 // Return the generated code. | 2642 // Return the generated code. |
2685 return GetCode(NORMAL, NULL, MEGAMORPHIC); | 2643 return GetCode(NORMAL, NULL, MEGAMORPHIC); |
2686 } | 2644 } |
2687 | 2645 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3103 DO_SMI_CHECK); | 3061 DO_SMI_CHECK); |
3104 | 3062 |
3105 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss(); | 3063 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss(); |
3106 __ jmp(ic, RelocInfo::CODE_TARGET); | 3064 __ jmp(ic, RelocInfo::CODE_TARGET); |
3107 | 3065 |
3108 // Return the generated code. | 3066 // Return the generated code. |
3109 return GetCode(NORMAL, NULL); | 3067 return GetCode(NORMAL, NULL); |
3110 } | 3068 } |
3111 | 3069 |
3112 | 3070 |
3113 MaybeObject* KeyedLoadStubCompiler::CompileLoadMegamorphic( | 3071 MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic( |
3114 MapList* receiver_maps, | 3072 MapList* receiver_maps, |
3115 CodeList* handler_ics) { | 3073 CodeList* handler_ics) { |
3116 // ----------- S t a t e ------------- | 3074 // ----------- S t a t e ------------- |
3117 // -- rax : key | 3075 // -- rax : key |
3118 // -- rdx : receiver | 3076 // -- rdx : receiver |
3119 // -- rsp[0] : return address | 3077 // -- rsp[0] : return address |
3120 // ----------------------------------- | 3078 // ----------------------------------- |
3121 Label miss; | 3079 Label miss; |
3122 __ JumpIfSmi(rdx, &miss); | 3080 __ JumpIfSmi(rdx, &miss); |
3123 | 3081 |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3844 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); | 3802 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); |
3845 __ jmp(ic_miss, RelocInfo::CODE_TARGET); | 3803 __ jmp(ic_miss, RelocInfo::CODE_TARGET); |
3846 } | 3804 } |
3847 | 3805 |
3848 | 3806 |
3849 #undef __ | 3807 #undef __ |
3850 | 3808 |
3851 } } // namespace v8::internal | 3809 } } // namespace v8::internal |
3852 | 3810 |
3853 #endif // V8_TARGET_ARCH_X64 | 3811 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |