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

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

Issue 2523473002: [cleanup] Drop handwritten KeyedStoreIC code (Closed)
Patch Set: rebased Created 4 years, 1 month 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/codegen.h ('k') | src/ia32/codegen-ia32.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_IA32 5 #if V8_TARGET_ARCH_IA32
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/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after
3009 StubFailureTrampolineFrameConstants::kArgumentsLengthOffset; 3009 StubFailureTrampolineFrameConstants::kArgumentsLengthOffset;
3010 __ mov(ebx, MemOperand(ebp, parameter_count_offset)); 3010 __ mov(ebx, MemOperand(ebp, parameter_count_offset));
3011 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); 3011 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE);
3012 __ pop(ecx); 3012 __ pop(ecx);
3013 int additional_offset = 3013 int additional_offset =
3014 function_mode() == JS_FUNCTION_STUB_MODE ? kPointerSize : 0; 3014 function_mode() == JS_FUNCTION_STUB_MODE ? kPointerSize : 0;
3015 __ lea(esp, MemOperand(esp, ebx, times_pointer_size, additional_offset)); 3015 __ lea(esp, MemOperand(esp, ebx, times_pointer_size, additional_offset));
3016 __ jmp(ecx); // Return to IC Miss stub, continuation still on stack. 3016 __ jmp(ecx); // Return to IC Miss stub, continuation still on stack.
3017 } 3017 }
3018 3018
3019 void KeyedStoreICTrampolineStub::Generate(MacroAssembler* masm) {
3020 __ EmitLoadTypeFeedbackVector(StoreWithVectorDescriptor::VectorRegister());
3021 KeyedStoreICStub stub(isolate(), state());
3022 stub.GenerateForTrampoline(masm);
3023 }
3024
3025 // value is on the stack already.
3026 static void HandlePolymorphicStoreCase(MacroAssembler* masm, Register receiver,
3027 Register key, Register vector,
3028 Register slot, Register feedback,
3029 bool is_polymorphic, Label* miss) {
3030 // feedback initially contains the feedback array
3031 Label next, next_loop, prepare_next;
3032 Label load_smi_map, compare_map;
3033 Label start_polymorphic;
3034 Label pop_and_miss;
3035
3036 __ push(receiver);
3037 // Value, vector and slot are passed on the stack, so no need to save/restore
3038 // them.
3039
3040 Register receiver_map = receiver;
3041 Register cached_map = vector;
3042
3043 // Receiver might not be a heap object.
3044 __ JumpIfSmi(receiver, &load_smi_map);
3045 __ mov(receiver_map, FieldOperand(receiver, 0));
3046 __ bind(&compare_map);
3047 __ mov(cached_map, FieldOperand(feedback, FixedArray::OffsetOfElementAt(0)));
3048
3049 // A named keyed store might have a 2 element array, all other cases can count
3050 // on an array with at least 2 {map, handler} pairs, so they can go right
3051 // into polymorphic array handling.
3052 __ cmp(receiver_map, FieldOperand(cached_map, WeakCell::kValueOffset));
3053 __ j(not_equal, &start_polymorphic);
3054
3055 // found, now call handler.
3056 Register handler = feedback;
3057 DCHECK(handler.is(StoreWithVectorDescriptor::ValueRegister()));
3058 __ mov(handler, FieldOperand(feedback, FixedArray::OffsetOfElementAt(1)));
3059 __ pop(receiver);
3060 __ lea(handler, FieldOperand(handler, Code::kHeaderSize));
3061 __ jmp(handler);
3062
3063 // Polymorphic, we have to loop from 2 to N
3064 __ bind(&start_polymorphic);
3065 __ push(key);
3066 Register counter = key;
3067 __ mov(counter, Immediate(Smi::FromInt(2)));
3068
3069 if (!is_polymorphic) {
3070 // If is_polymorphic is false, we may only have a two element array.
3071 // Check against length now in that case.
3072 __ cmp(counter, FieldOperand(feedback, FixedArray::kLengthOffset));
3073 __ j(greater_equal, &pop_and_miss);
3074 }
3075
3076 __ bind(&next_loop);
3077 __ mov(cached_map, FieldOperand(feedback, counter, times_half_pointer_size,
3078 FixedArray::kHeaderSize));
3079 __ cmp(receiver_map, FieldOperand(cached_map, WeakCell::kValueOffset));
3080 __ j(not_equal, &prepare_next);
3081 __ mov(handler, FieldOperand(feedback, counter, times_half_pointer_size,
3082 FixedArray::kHeaderSize + kPointerSize));
3083 __ lea(handler, FieldOperand(handler, Code::kHeaderSize));
3084 __ pop(key);
3085 __ pop(receiver);
3086 __ jmp(handler);
3087
3088 __ bind(&prepare_next);
3089 __ add(counter, Immediate(Smi::FromInt(2)));
3090 __ cmp(counter, FieldOperand(feedback, FixedArray::kLengthOffset));
3091 __ j(less, &next_loop);
3092
3093 // We exhausted our array of map handler pairs.
3094 __ bind(&pop_and_miss);
3095 __ pop(key);
3096 __ pop(receiver);
3097 __ jmp(miss);
3098
3099 __ bind(&load_smi_map);
3100 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
3101 __ jmp(&compare_map);
3102 }
3103
3104
3105 static void HandleMonomorphicStoreCase(MacroAssembler* masm, Register receiver,
3106 Register key, Register vector,
3107 Register slot, Register weak_cell,
3108 Label* miss) {
3109 // The store ic value is on the stack.
3110 DCHECK(weak_cell.is(StoreWithVectorDescriptor::ValueRegister()));
3111
3112 // feedback initially contains the feedback array
3113 Label compare_smi_map;
3114
3115 // Move the weak map into the weak_cell register.
3116 Register ic_map = weak_cell;
3117 __ mov(ic_map, FieldOperand(weak_cell, WeakCell::kValueOffset));
3118
3119 // Receiver might not be a heap object.
3120 __ JumpIfSmi(receiver, &compare_smi_map);
3121 __ cmp(ic_map, FieldOperand(receiver, 0));
3122 __ j(not_equal, miss);
3123 __ mov(weak_cell, FieldOperand(vector, slot, times_half_pointer_size,
3124 FixedArray::kHeaderSize + kPointerSize));
3125 __ lea(weak_cell, FieldOperand(weak_cell, Code::kHeaderSize));
3126 // jump to the handler.
3127 __ jmp(weak_cell);
3128
3129 // In microbenchmarks, it made sense to unroll this code so that the call to
3130 // the handler is duplicated for a HeapObject receiver and a Smi receiver.
3131 __ bind(&compare_smi_map);
3132 __ CompareRoot(ic_map, Heap::kHeapNumberMapRootIndex);
3133 __ j(not_equal, miss);
3134 __ mov(weak_cell, FieldOperand(vector, slot, times_half_pointer_size,
3135 FixedArray::kHeaderSize + kPointerSize));
3136 __ lea(weak_cell, FieldOperand(weak_cell, Code::kHeaderSize));
3137 // jump to the handler.
3138 __ jmp(weak_cell);
3139 }
3140
3141 void KeyedStoreICStub::Generate(MacroAssembler* masm) {
3142 GenerateImpl(masm, false);
3143 }
3144
3145 void KeyedStoreICStub::GenerateForTrampoline(MacroAssembler* masm) {
3146 GenerateImpl(masm, true);
3147 }
3148
3149
3150 static void HandlePolymorphicKeyedStoreCase(MacroAssembler* masm,
3151 Register receiver, Register key,
3152 Register vector, Register slot,
3153 Register feedback, Label* miss) {
3154 // feedback initially contains the feedback array
3155 Label next, next_loop, prepare_next;
3156 Label load_smi_map, compare_map;
3157 Label transition_call;
3158 Label pop_and_miss;
3159
3160 __ push(receiver);
3161 // Value, vector and slot are passed on the stack, so no need to save/restore
3162 // them.
3163
3164 Register receiver_map = receiver;
3165 Register cached_map = vector;
3166
3167 // Receiver might not be a heap object.
3168 __ JumpIfSmi(receiver, &load_smi_map);
3169 __ mov(receiver_map, FieldOperand(receiver, 0));
3170 __ bind(&compare_map);
3171
3172 // Polymorphic, we have to loop from 0 to N - 1
3173 __ push(key);
3174 // Current stack layout:
3175 // - esp[0] -- key
3176 // - esp[4] -- receiver
3177 // - esp[8] -- return address
3178 // - esp[12] -- vector
3179 // - esp[16] -- slot
3180 // - esp[20] -- value
3181 //
3182 // Required stack layout for handler call (see StoreWithVectorDescriptor):
3183 // - esp[0] -- return address
3184 // - esp[4] -- vector
3185 // - esp[8] -- slot
3186 // - esp[12] -- value
3187 // - receiver, key, handler in registers.
3188 Register counter = key;
3189 __ mov(counter, Immediate(Smi::kZero));
3190 __ bind(&next_loop);
3191 __ mov(cached_map, FieldOperand(feedback, counter, times_half_pointer_size,
3192 FixedArray::kHeaderSize));
3193 __ cmp(receiver_map, FieldOperand(cached_map, WeakCell::kValueOffset));
3194 __ j(not_equal, &prepare_next);
3195 __ mov(cached_map, FieldOperand(feedback, counter, times_half_pointer_size,
3196 FixedArray::kHeaderSize + kPointerSize));
3197 __ CompareRoot(cached_map, Heap::kUndefinedValueRootIndex);
3198 __ j(not_equal, &transition_call);
3199 __ mov(feedback, FieldOperand(feedback, counter, times_half_pointer_size,
3200 FixedArray::kHeaderSize + 2 * kPointerSize));
3201 __ pop(key);
3202 __ pop(receiver);
3203 __ lea(feedback, FieldOperand(feedback, Code::kHeaderSize));
3204 __ jmp(feedback);
3205
3206 __ bind(&transition_call);
3207 // Current stack layout:
3208 // - esp[0] -- key
3209 // - esp[4] -- receiver
3210 // - esp[8] -- return address
3211 // - esp[12] -- vector
3212 // - esp[16] -- slot
3213 // - esp[20] -- value
3214 //
3215 // Required stack layout for handler call (see StoreTransitionDescriptor):
3216 // - esp[0] -- return address
3217 // - esp[4] -- vector
3218 // - esp[8] -- slot
3219 // - esp[12] -- value
3220 // - receiver, key, map, handler in registers.
3221 __ mov(feedback, FieldOperand(feedback, counter, times_half_pointer_size,
3222 FixedArray::kHeaderSize + 2 * kPointerSize));
3223 __ lea(feedback, FieldOperand(feedback, Code::kHeaderSize));
3224
3225 __ mov(cached_map, FieldOperand(cached_map, WeakCell::kValueOffset));
3226 // The weak cell may have been cleared.
3227 __ JumpIfSmi(cached_map, &pop_and_miss);
3228 DCHECK(!cached_map.is(StoreTransitionDescriptor::MapRegister()));
3229 __ mov(StoreTransitionDescriptor::MapRegister(), cached_map);
3230
3231 // Call store transition handler using StoreTransitionDescriptor calling
3232 // convention.
3233 __ pop(key);
3234 __ pop(receiver);
3235 // Ensure that the transition handler we are going to call has the same
3236 // number of stack arguments which means that we don't have to adapt them
3237 // before the call.
3238 STATIC_ASSERT(StoreWithVectorDescriptor::kStackArgumentsCount == 3);
3239 STATIC_ASSERT(StoreTransitionDescriptor::kStackArgumentsCount == 3);
3240 STATIC_ASSERT(StoreWithVectorDescriptor::kParameterCount -
3241 StoreWithVectorDescriptor::kValue ==
3242 StoreTransitionDescriptor::kParameterCount -
3243 StoreTransitionDescriptor::kValue);
3244 STATIC_ASSERT(StoreWithVectorDescriptor::kParameterCount -
3245 StoreWithVectorDescriptor::kSlot ==
3246 StoreTransitionDescriptor::kParameterCount -
3247 StoreTransitionDescriptor::kSlot);
3248 STATIC_ASSERT(StoreWithVectorDescriptor::kParameterCount -
3249 StoreWithVectorDescriptor::kVector ==
3250 StoreTransitionDescriptor::kParameterCount -
3251 StoreTransitionDescriptor::kVector);
3252 __ jmp(feedback);
3253
3254 __ bind(&prepare_next);
3255 __ add(counter, Immediate(Smi::FromInt(3)));
3256 __ cmp(counter, FieldOperand(feedback, FixedArray::kLengthOffset));
3257 __ j(less, &next_loop);
3258
3259 // We exhausted our array of map handler pairs.
3260 __ bind(&pop_and_miss);
3261 __ pop(key);
3262 __ pop(receiver);
3263 __ jmp(miss);
3264
3265 __ bind(&load_smi_map);
3266 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
3267 __ jmp(&compare_map);
3268 }
3269
3270 void KeyedStoreICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
3271 Register receiver = StoreWithVectorDescriptor::ReceiverRegister(); // edx
3272 Register key = StoreWithVectorDescriptor::NameRegister(); // ecx
3273 Register value = StoreWithVectorDescriptor::ValueRegister(); // eax
3274 Register vector = StoreWithVectorDescriptor::VectorRegister(); // ebx
3275 Register slot = StoreWithVectorDescriptor::SlotRegister(); // edi
3276 Label miss;
3277
3278 if (StoreWithVectorDescriptor::kPassLastArgsOnStack) {
3279 // Current stack layout:
3280 // - esp[8] -- value
3281 // - esp[4] -- slot
3282 // - esp[0] -- return address
3283 STATIC_ASSERT(StoreDescriptor::kStackArgumentsCount == 2);
3284 STATIC_ASSERT(StoreWithVectorDescriptor::kStackArgumentsCount == 3);
3285 if (in_frame) {
3286 __ RecordComment("[ StoreDescriptor -> StoreWithVectorDescriptor");
3287 // If the vector is not on the stack, then insert the vector beneath
3288 // return address in order to prepare for calling handler with
3289 // StoreWithVector calling convention.
3290 __ push(Operand(esp, 0));
3291 __ mov(Operand(esp, 4), StoreWithVectorDescriptor::VectorRegister());
3292 __ RecordComment("]");
3293 } else {
3294 __ mov(vector, Operand(esp, 1 * kPointerSize));
3295 }
3296 __ mov(slot, Operand(esp, 2 * kPointerSize));
3297 }
3298
3299 Register scratch = value;
3300 __ mov(scratch, FieldOperand(vector, slot, times_half_pointer_size,
3301 FixedArray::kHeaderSize));
3302
3303 // Is it a weak cell?
3304 Label try_array;
3305 Label not_array, smi_key, key_okay;
3306 __ CompareRoot(FieldOperand(scratch, 0), Heap::kWeakCellMapRootIndex);
3307 __ j(not_equal, &try_array);
3308 HandleMonomorphicStoreCase(masm, receiver, key, vector, slot, scratch, &miss);
3309
3310 // Is it a fixed array?
3311 __ bind(&try_array);
3312 __ CompareRoot(FieldOperand(scratch, 0), Heap::kFixedArrayMapRootIndex);
3313 __ j(not_equal, &not_array);
3314 HandlePolymorphicKeyedStoreCase(masm, receiver, key, vector, slot, scratch,
3315 &miss);
3316
3317 __ bind(&not_array);
3318 Label try_poly_name;
3319 __ CompareRoot(scratch, Heap::kmegamorphic_symbolRootIndex);
3320 __ j(not_equal, &try_poly_name);
3321
3322 Handle<Code> megamorphic_stub =
3323 KeyedStoreIC::ChooseMegamorphicStub(masm->isolate(), GetExtraICState());
3324 __ jmp(megamorphic_stub, RelocInfo::CODE_TARGET);
3325
3326 __ bind(&try_poly_name);
3327 // We might have a name in feedback, and a fixed array in the next slot.
3328 __ cmp(key, scratch);
3329 __ j(not_equal, &miss);
3330 // If the name comparison succeeded, we know we have a fixed array with
3331 // at least one map/handler pair.
3332 __ mov(scratch, FieldOperand(vector, slot, times_half_pointer_size,
3333 FixedArray::kHeaderSize + kPointerSize));
3334 HandlePolymorphicStoreCase(masm, receiver, key, vector, slot, scratch, false,
3335 &miss);
3336
3337 __ bind(&miss);
3338 KeyedStoreIC::GenerateMiss(masm);
3339 }
3340
3341
3342 void CallICTrampolineStub::Generate(MacroAssembler* masm) { 3019 void CallICTrampolineStub::Generate(MacroAssembler* masm) {
3343 __ EmitLoadTypeFeedbackVector(ebx); 3020 __ EmitLoadTypeFeedbackVector(ebx);
3344 CallICStub stub(isolate(), state()); 3021 CallICStub stub(isolate(), state());
3345 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); 3022 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
3346 } 3023 }
3347 3024
3348 3025
3349 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 3026 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
3350 if (masm->isolate()->function_entry_hook() != NULL) { 3027 if (masm->isolate()->function_entry_hook() != NULL) {
3351 ProfileEntryHookStub stub(masm->isolate()); 3028 ProfileEntryHookStub stub(masm->isolate());
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
4752 kStackUnwindSpace, nullptr, return_value_operand, 4429 kStackUnwindSpace, nullptr, return_value_operand,
4753 NULL); 4430 NULL);
4754 } 4431 }
4755 4432
4756 #undef __ 4433 #undef __
4757 4434
4758 } // namespace internal 4435 } // namespace internal
4759 } // namespace v8 4436 } // namespace v8
4760 4437
4761 #endif // V8_TARGET_ARCH_IA32 4438 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/codegen.h ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698