| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 StubFailureTrampolineFrameConstants::kArgumentsLengthOffset; | 2942 StubFailureTrampolineFrameConstants::kArgumentsLengthOffset; |
| 2943 __ movp(rbx, MemOperand(rbp, parameter_count_offset)); | 2943 __ movp(rbx, MemOperand(rbp, parameter_count_offset)); |
| 2944 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 2944 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
| 2945 __ PopReturnAddressTo(rcx); | 2945 __ PopReturnAddressTo(rcx); |
| 2946 int additional_offset = | 2946 int additional_offset = |
| 2947 function_mode() == JS_FUNCTION_STUB_MODE ? kPointerSize : 0; | 2947 function_mode() == JS_FUNCTION_STUB_MODE ? kPointerSize : 0; |
| 2948 __ leap(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); | 2948 __ leap(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); |
| 2949 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. | 2949 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. |
| 2950 } | 2950 } |
| 2951 | 2951 |
| 2952 | |
| 2953 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) { | |
| 2954 __ EmitLoadTypeFeedbackVector(LoadWithVectorDescriptor::VectorRegister()); | |
| 2955 KeyedLoadICStub stub(isolate()); | |
| 2956 stub.GenerateForTrampoline(masm); | |
| 2957 } | |
| 2958 | |
| 2959 | |
| 2960 static void HandleArrayCases(MacroAssembler* masm, Register feedback, | 2952 static void HandleArrayCases(MacroAssembler* masm, Register feedback, |
| 2961 Register receiver_map, Register scratch1, | 2953 Register receiver_map, Register scratch1, |
| 2962 Register scratch2, Register scratch3, | 2954 Register scratch2, Register scratch3, |
| 2963 bool is_polymorphic, Label* miss) { | 2955 bool is_polymorphic, Label* miss) { |
| 2964 // feedback initially contains the feedback array | 2956 // feedback initially contains the feedback array |
| 2965 Label next_loop, prepare_next; | 2957 Label next_loop, prepare_next; |
| 2966 Label start_polymorphic; | 2958 Label start_polymorphic; |
| 2967 | 2959 |
| 2968 Register counter = scratch1; | 2960 Register counter = scratch1; |
| 2969 Register length = scratch2; | 2961 Register length = scratch2; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3021 __ bind(compare_map); | 3013 __ bind(compare_map); |
| 3022 __ cmpp(receiver_map, FieldOperand(feedback, WeakCell::kValueOffset)); | 3014 __ cmpp(receiver_map, FieldOperand(feedback, WeakCell::kValueOffset)); |
| 3023 __ j(not_equal, try_array); | 3015 __ j(not_equal, try_array); |
| 3024 Register handler = feedback; | 3016 Register handler = feedback; |
| 3025 __ movp(handler, FieldOperand(vector, integer_slot, times_pointer_size, | 3017 __ movp(handler, FieldOperand(vector, integer_slot, times_pointer_size, |
| 3026 FixedArray::kHeaderSize + kPointerSize)); | 3018 FixedArray::kHeaderSize + kPointerSize)); |
| 3027 __ leap(handler, FieldOperand(handler, Code::kHeaderSize)); | 3019 __ leap(handler, FieldOperand(handler, Code::kHeaderSize)); |
| 3028 __ jmp(handler); | 3020 __ jmp(handler); |
| 3029 } | 3021 } |
| 3030 | 3022 |
| 3031 | |
| 3032 void KeyedLoadICStub::Generate(MacroAssembler* masm) { | |
| 3033 GenerateImpl(masm, false); | |
| 3034 } | |
| 3035 | |
| 3036 | |
| 3037 void KeyedLoadICStub::GenerateForTrampoline(MacroAssembler* masm) { | |
| 3038 GenerateImpl(masm, true); | |
| 3039 } | |
| 3040 | |
| 3041 | |
| 3042 void KeyedLoadICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { | |
| 3043 Register receiver = LoadWithVectorDescriptor::ReceiverRegister(); // rdx | |
| 3044 Register key = LoadWithVectorDescriptor::NameRegister(); // rcx | |
| 3045 Register vector = LoadWithVectorDescriptor::VectorRegister(); // rbx | |
| 3046 Register slot = LoadWithVectorDescriptor::SlotRegister(); // rax | |
| 3047 Register feedback = rdi; | |
| 3048 Register integer_slot = r8; | |
| 3049 Register receiver_map = r9; | |
| 3050 | |
| 3051 __ SmiToInteger32(integer_slot, slot); | |
| 3052 __ movp(feedback, FieldOperand(vector, integer_slot, times_pointer_size, | |
| 3053 FixedArray::kHeaderSize)); | |
| 3054 | |
| 3055 // Try to quickly handle the monomorphic case without knowing for sure | |
| 3056 // if we have a weak cell in feedback. We do know it's safe to look | |
| 3057 // at WeakCell::kValueOffset. | |
| 3058 Label try_array, load_smi_map, compare_map; | |
| 3059 Label not_array, miss; | |
| 3060 HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector, | |
| 3061 integer_slot, &compare_map, &load_smi_map, &try_array); | |
| 3062 | |
| 3063 __ bind(&try_array); | |
| 3064 // Is it a fixed array? | |
| 3065 __ CompareRoot(FieldOperand(feedback, 0), Heap::kFixedArrayMapRootIndex); | |
| 3066 __ j(not_equal, ¬_array); | |
| 3067 | |
| 3068 // We have a polymorphic element handler. | |
| 3069 Label polymorphic, try_poly_name; | |
| 3070 __ bind(&polymorphic); | |
| 3071 HandleArrayCases(masm, feedback, receiver_map, integer_slot, r11, r15, true, | |
| 3072 &miss); | |
| 3073 | |
| 3074 __ bind(¬_array); | |
| 3075 // Is it generic? | |
| 3076 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); | |
| 3077 __ j(not_equal, &try_poly_name); | |
| 3078 Handle<Code> megamorphic_stub = | |
| 3079 KeyedLoadIC::ChooseMegamorphicStub(masm->isolate(), GetExtraICState()); | |
| 3080 __ jmp(megamorphic_stub, RelocInfo::CODE_TARGET); | |
| 3081 | |
| 3082 __ bind(&try_poly_name); | |
| 3083 // We might have a name in feedback, and a fixed array in the next slot. | |
| 3084 __ cmpp(key, feedback); | |
| 3085 __ j(not_equal, &miss); | |
| 3086 // If the name comparison succeeded, we know we have a fixed array with | |
| 3087 // at least one map/handler pair. | |
| 3088 __ movp(feedback, FieldOperand(vector, integer_slot, times_pointer_size, | |
| 3089 FixedArray::kHeaderSize + kPointerSize)); | |
| 3090 HandleArrayCases(masm, feedback, receiver_map, integer_slot, r11, r15, false, | |
| 3091 &miss); | |
| 3092 | |
| 3093 __ bind(&miss); | |
| 3094 KeyedLoadIC::GenerateMiss(masm); | |
| 3095 | |
| 3096 __ bind(&load_smi_map); | |
| 3097 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex); | |
| 3098 __ jmp(&compare_map); | |
| 3099 } | |
| 3100 | |
| 3101 void KeyedStoreICTrampolineStub::Generate(MacroAssembler* masm) { | 3023 void KeyedStoreICTrampolineStub::Generate(MacroAssembler* masm) { |
| 3102 __ EmitLoadTypeFeedbackVector(StoreWithVectorDescriptor::VectorRegister()); | 3024 __ EmitLoadTypeFeedbackVector(StoreWithVectorDescriptor::VectorRegister()); |
| 3103 KeyedStoreICStub stub(isolate(), state()); | 3025 KeyedStoreICStub stub(isolate(), state()); |
| 3104 stub.GenerateForTrampoline(masm); | 3026 stub.GenerateForTrampoline(masm); |
| 3105 } | 3027 } |
| 3106 | 3028 |
| 3107 void KeyedStoreICStub::Generate(MacroAssembler* masm) { | 3029 void KeyedStoreICStub::Generate(MacroAssembler* masm) { |
| 3108 GenerateImpl(masm, false); | 3030 GenerateImpl(masm, false); |
| 3109 } | 3031 } |
| 3110 | 3032 |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4620 kStackUnwindSpace, nullptr, return_value_operand, | 4542 kStackUnwindSpace, nullptr, return_value_operand, |
| 4621 NULL); | 4543 NULL); |
| 4622 } | 4544 } |
| 4623 | 4545 |
| 4624 #undef __ | 4546 #undef __ |
| 4625 | 4547 |
| 4626 } // namespace internal | 4548 } // namespace internal |
| 4627 } // namespace v8 | 4549 } // namespace v8 |
| 4628 | 4550 |
| 4629 #endif // V8_TARGET_ARCH_X64 | 4551 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |