Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 2523473002: [cleanup] Drop handwritten KeyedStoreIC code (Closed)
Patch Set: rebased Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/v8.gyp ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 static void HandleArrayCases(MacroAssembler* masm, Register feedback,
2953 Register receiver_map, Register scratch1,
2954 Register scratch2, Register scratch3,
2955 bool is_polymorphic, Label* miss) {
2956 // feedback initially contains the feedback array
2957 Label next_loop, prepare_next;
2958 Label start_polymorphic;
2959
2960 Register counter = scratch1;
2961 Register length = scratch2;
2962 Register cached_map = scratch3;
2963
2964 __ movp(cached_map, FieldOperand(feedback, FixedArray::OffsetOfElementAt(0)));
2965 __ cmpp(receiver_map, FieldOperand(cached_map, WeakCell::kValueOffset));
2966 __ j(not_equal, &start_polymorphic);
2967
2968 // found, now call handler.
2969 Register handler = feedback;
2970 __ movp(handler, FieldOperand(feedback, FixedArray::OffsetOfElementAt(1)));
2971 __ leap(handler, FieldOperand(handler, Code::kHeaderSize));
2972 __ jmp(handler);
2973
2974 // Polymorphic, we have to loop from 2 to N
2975 __ bind(&start_polymorphic);
2976 __ SmiToInteger32(length, FieldOperand(feedback, FixedArray::kLengthOffset));
2977 if (!is_polymorphic) {
2978 // If the IC could be monomorphic we have to make sure we don't go past the
2979 // end of the feedback array.
2980 __ cmpl(length, Immediate(2));
2981 __ j(equal, miss);
2982 }
2983 __ movl(counter, Immediate(2));
2984
2985 __ bind(&next_loop);
2986 __ movp(cached_map, FieldOperand(feedback, counter, times_pointer_size,
2987 FixedArray::kHeaderSize));
2988 __ cmpp(receiver_map, FieldOperand(cached_map, WeakCell::kValueOffset));
2989 __ j(not_equal, &prepare_next);
2990 __ movp(handler, FieldOperand(feedback, counter, times_pointer_size,
2991 FixedArray::kHeaderSize + kPointerSize));
2992 __ leap(handler, FieldOperand(handler, Code::kHeaderSize));
2993 __ jmp(handler);
2994
2995 __ bind(&prepare_next);
2996 __ addl(counter, Immediate(2));
2997 __ cmpl(counter, length);
2998 __ j(less, &next_loop);
2999
3000 // We exhausted our array of map handler pairs.
3001 __ jmp(miss);
3002 }
3003
3004
3005 static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver,
3006 Register receiver_map, Register feedback,
3007 Register vector, Register integer_slot,
3008 Label* compare_map, Label* load_smi_map,
3009 Label* try_array) {
3010 __ JumpIfSmi(receiver, load_smi_map);
3011 __ movp(receiver_map, FieldOperand(receiver, 0));
3012
3013 __ bind(compare_map);
3014 __ cmpp(receiver_map, FieldOperand(feedback, WeakCell::kValueOffset));
3015 __ j(not_equal, try_array);
3016 Register handler = feedback;
3017 __ movp(handler, FieldOperand(vector, integer_slot, times_pointer_size,
3018 FixedArray::kHeaderSize + kPointerSize));
3019 __ leap(handler, FieldOperand(handler, Code::kHeaderSize));
3020 __ jmp(handler);
3021 }
3022
3023 void KeyedStoreICTrampolineStub::Generate(MacroAssembler* masm) {
3024 __ EmitLoadTypeFeedbackVector(StoreWithVectorDescriptor::VectorRegister());
3025 KeyedStoreICStub stub(isolate(), state());
3026 stub.GenerateForTrampoline(masm);
3027 }
3028
3029 void KeyedStoreICStub::Generate(MacroAssembler* masm) {
3030 GenerateImpl(masm, false);
3031 }
3032
3033 void KeyedStoreICStub::GenerateForTrampoline(MacroAssembler* masm) {
3034 GenerateImpl(masm, true);
3035 }
3036
3037
3038 static void HandlePolymorphicKeyedStoreCase(MacroAssembler* masm,
3039 Register receiver_map,
3040 Register feedback, Register scratch,
3041 Register scratch1,
3042 Register scratch2, Label* miss) {
3043 // feedback initially contains the feedback array
3044 Label next, next_loop, prepare_next;
3045 Label transition_call;
3046
3047 Register cached_map = scratch;
3048 Register counter = scratch1;
3049 Register length = scratch2;
3050
3051 // Polymorphic, we have to loop from 0 to N - 1
3052 __ movp(counter, Immediate(0));
3053 __ movp(length, FieldOperand(feedback, FixedArray::kLengthOffset));
3054 __ SmiToInteger32(length, length);
3055
3056 __ bind(&next_loop);
3057 __ movp(cached_map, FieldOperand(feedback, counter, times_pointer_size,
3058 FixedArray::kHeaderSize));
3059 __ cmpp(receiver_map, FieldOperand(cached_map, WeakCell::kValueOffset));
3060 __ j(not_equal, &prepare_next);
3061 __ movp(cached_map, FieldOperand(feedback, counter, times_pointer_size,
3062 FixedArray::kHeaderSize + kPointerSize));
3063 __ CompareRoot(cached_map, Heap::kUndefinedValueRootIndex);
3064 __ j(not_equal, &transition_call);
3065 __ movp(feedback, FieldOperand(feedback, counter, times_pointer_size,
3066 FixedArray::kHeaderSize + 2 * kPointerSize));
3067 __ leap(feedback, FieldOperand(feedback, Code::kHeaderSize));
3068 __ jmp(feedback);
3069
3070 __ bind(&transition_call);
3071 DCHECK(receiver_map.is(StoreTransitionDescriptor::MapRegister()));
3072 __ movp(receiver_map, FieldOperand(cached_map, WeakCell::kValueOffset));
3073 // The weak cell may have been cleared.
3074 __ JumpIfSmi(receiver_map, miss);
3075 // Get the handler in value.
3076 __ movp(feedback, FieldOperand(feedback, counter, times_pointer_size,
3077 FixedArray::kHeaderSize + 2 * kPointerSize));
3078 __ leap(feedback, FieldOperand(feedback, Code::kHeaderSize));
3079 __ jmp(feedback);
3080
3081 __ bind(&prepare_next);
3082 __ addl(counter, Immediate(3));
3083 __ cmpl(counter, length);
3084 __ j(less, &next_loop);
3085
3086 // We exhausted our array of map handler pairs.
3087 __ jmp(miss);
3088 }
3089
3090 void KeyedStoreICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
3091 Register receiver = StoreWithVectorDescriptor::ReceiverRegister(); // rdx
3092 Register key = StoreWithVectorDescriptor::NameRegister(); // rcx
3093 Register vector = StoreWithVectorDescriptor::VectorRegister(); // rbx
3094 Register slot = StoreWithVectorDescriptor::SlotRegister(); // rdi
3095 DCHECK(StoreWithVectorDescriptor::ValueRegister().is(rax)); // rax
3096 Register feedback = r8;
3097 Register integer_slot = r9;
3098 Register receiver_map = r11;
3099 DCHECK(!AreAliased(feedback, integer_slot, vector, slot, receiver_map));
3100
3101 __ SmiToInteger32(integer_slot, slot);
3102 __ movp(feedback, FieldOperand(vector, integer_slot, times_pointer_size,
3103 FixedArray::kHeaderSize));
3104
3105 // Try to quickly handle the monomorphic case without knowing for sure
3106 // if we have a weak cell in feedback. We do know it's safe to look
3107 // at WeakCell::kValueOffset.
3108 Label try_array, load_smi_map, compare_map;
3109 Label not_array, miss;
3110 HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector,
3111 integer_slot, &compare_map, &load_smi_map, &try_array);
3112
3113 // Is it a fixed array?
3114 __ bind(&try_array);
3115 __ CompareRoot(FieldOperand(feedback, 0), Heap::kFixedArrayMapRootIndex);
3116 __ j(not_equal, &not_array);
3117 HandlePolymorphicKeyedStoreCase(masm, receiver_map, feedback, integer_slot,
3118 r15, r14, &miss);
3119
3120 __ bind(&not_array);
3121 Label try_poly_name;
3122 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
3123 __ j(not_equal, &try_poly_name);
3124
3125 Handle<Code> megamorphic_stub =
3126 KeyedStoreIC::ChooseMegamorphicStub(masm->isolate(), GetExtraICState());
3127 __ jmp(megamorphic_stub, RelocInfo::CODE_TARGET);
3128
3129 __ bind(&try_poly_name);
3130 // We might have a name in feedback, and a fixed array in the next slot.
3131 __ cmpp(key, feedback);
3132 __ j(not_equal, &miss);
3133 // If the name comparison succeeded, we know we have a fixed array with
3134 // at least one map/handler pair.
3135 __ movp(feedback, FieldOperand(vector, integer_slot, times_pointer_size,
3136 FixedArray::kHeaderSize + kPointerSize));
3137 HandleArrayCases(masm, feedback, receiver_map, integer_slot, r14, r15, false,
3138 &miss);
3139
3140 __ bind(&miss);
3141 KeyedStoreIC::GenerateMiss(masm);
3142
3143 __ bind(&load_smi_map);
3144 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
3145 __ jmp(&compare_map);
3146 }
3147
3148
3149 void CallICTrampolineStub::Generate(MacroAssembler* masm) { 2952 void CallICTrampolineStub::Generate(MacroAssembler* masm) {
3150 __ EmitLoadTypeFeedbackVector(rbx); 2953 __ EmitLoadTypeFeedbackVector(rbx);
3151 CallICStub stub(isolate(), state()); 2954 CallICStub stub(isolate(), state());
3152 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); 2955 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
3153 } 2956 }
3154 2957
3155 2958
3156 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 2959 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
3157 if (masm->isolate()->function_entry_hook() != NULL) { 2960 if (masm->isolate()->function_entry_hook() != NULL) {
3158 ProfileEntryHookStub stub(masm->isolate()); 2961 ProfileEntryHookStub stub(masm->isolate());
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
4542 kStackUnwindSpace, nullptr, return_value_operand, 4345 kStackUnwindSpace, nullptr, return_value_operand,
4543 NULL); 4346 NULL);
4544 } 4347 }
4545 4348
4546 #undef __ 4349 #undef __
4547 4350
4548 } // namespace internal 4351 } // namespace internal
4549 } // namespace v8 4352 } // namespace v8
4550 4353
4551 #endif // V8_TARGET_ARCH_X64 4354 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/v8.gyp ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698