OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_S390 | 5 #if V8_TARGET_ARCH_S390 |
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 3127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3138 __ la(sp, MemOperand(r3, sp)); | 3138 __ la(sp, MemOperand(r3, sp)); |
3139 __ Ret(); | 3139 __ Ret(); |
3140 } | 3140 } |
3141 | 3141 |
3142 void CallICTrampolineStub::Generate(MacroAssembler* masm) { | 3142 void CallICTrampolineStub::Generate(MacroAssembler* masm) { |
3143 __ EmitLoadTypeFeedbackVector(r4); | 3143 __ EmitLoadTypeFeedbackVector(r4); |
3144 CallICStub stub(isolate(), state()); | 3144 CallICStub stub(isolate(), state()); |
3145 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3145 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
3146 } | 3146 } |
3147 | 3147 |
3148 static void HandleArrayCases(MacroAssembler* masm, Register feedback, | |
3149 Register receiver_map, Register scratch1, | |
3150 Register scratch2, bool is_polymorphic, | |
3151 Label* miss) { | |
3152 // feedback initially contains the feedback array | |
3153 Label next_loop, prepare_next; | |
3154 Label start_polymorphic; | |
3155 | |
3156 Register cached_map = scratch1; | |
3157 | |
3158 __ LoadP(cached_map, | |
3159 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(0))); | |
3160 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset)); | |
3161 __ CmpP(receiver_map, cached_map); | |
3162 __ bne(&start_polymorphic, Label::kNear); | |
3163 // found, now call handler. | |
3164 Register handler = feedback; | |
3165 __ LoadP(handler, | |
3166 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(1))); | |
3167 __ AddP(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
3168 __ Jump(ip); | |
3169 | |
3170 Register length = scratch2; | |
3171 __ bind(&start_polymorphic); | |
3172 __ LoadP(length, FieldMemOperand(feedback, FixedArray::kLengthOffset)); | |
3173 if (!is_polymorphic) { | |
3174 // If the IC could be monomorphic we have to make sure we don't go past the | |
3175 // end of the feedback array. | |
3176 __ CmpSmiLiteral(length, Smi::FromInt(2), r0); | |
3177 __ beq(miss); | |
3178 } | |
3179 | |
3180 Register too_far = length; | |
3181 Register pointer_reg = feedback; | |
3182 | |
3183 // +-----+------+------+-----+-----+ ... ----+ | |
3184 // | map | len | wm0 | h0 | wm1 | hN | | |
3185 // +-----+------+------+-----+-----+ ... ----+ | |
3186 // 0 1 2 len-1 | |
3187 // ^ ^ | |
3188 // | | | |
3189 // pointer_reg too_far | |
3190 // aka feedback scratch2 | |
3191 // also need receiver_map | |
3192 // use cached_map (scratch1) to look in the weak map values. | |
3193 __ SmiToPtrArrayOffset(r0, length); | |
3194 __ AddP(too_far, feedback, r0); | |
3195 __ AddP(too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
3196 __ AddP(pointer_reg, feedback, | |
3197 Operand(FixedArray::OffsetOfElementAt(2) - kHeapObjectTag)); | |
3198 | |
3199 __ bind(&next_loop); | |
3200 __ LoadP(cached_map, MemOperand(pointer_reg)); | |
3201 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset)); | |
3202 __ CmpP(receiver_map, cached_map); | |
3203 __ bne(&prepare_next, Label::kNear); | |
3204 __ LoadP(handler, MemOperand(pointer_reg, kPointerSize)); | |
3205 __ AddP(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
3206 __ Jump(ip); | |
3207 | |
3208 __ bind(&prepare_next); | |
3209 __ AddP(pointer_reg, Operand(kPointerSize * 2)); | |
3210 __ CmpP(pointer_reg, too_far); | |
3211 __ blt(&next_loop, Label::kNear); | |
3212 | |
3213 // We exhausted our array of map handler pairs. | |
3214 __ b(miss); | |
3215 } | |
3216 | |
3217 static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver, | |
3218 Register receiver_map, Register feedback, | |
3219 Register vector, Register slot, | |
3220 Register scratch, Label* compare_map, | |
3221 Label* load_smi_map, Label* try_array) { | |
3222 __ JumpIfSmi(receiver, load_smi_map); | |
3223 __ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
3224 __ bind(compare_map); | |
3225 Register cached_map = scratch; | |
3226 // Move the weak map into the weak_cell register. | |
3227 __ LoadP(cached_map, FieldMemOperand(feedback, WeakCell::kValueOffset)); | |
3228 __ CmpP(cached_map, receiver_map); | |
3229 __ bne(try_array); | |
3230 Register handler = feedback; | |
3231 __ SmiToPtrArrayOffset(r1, slot); | |
3232 __ LoadP(handler, | |
3233 FieldMemOperand(r1, vector, FixedArray::kHeaderSize + kPointerSize)); | |
3234 __ AddP(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
3235 __ Jump(ip); | |
3236 } | |
3237 | |
3238 void KeyedStoreICTrampolineStub::Generate(MacroAssembler* masm) { | |
3239 __ EmitLoadTypeFeedbackVector(StoreWithVectorDescriptor::VectorRegister()); | |
3240 KeyedStoreICStub stub(isolate(), state()); | |
3241 stub.GenerateForTrampoline(masm); | |
3242 } | |
3243 | |
3244 void KeyedStoreICStub::Generate(MacroAssembler* masm) { | |
3245 GenerateImpl(masm, false); | |
3246 } | |
3247 | |
3248 void KeyedStoreICStub::GenerateForTrampoline(MacroAssembler* masm) { | |
3249 GenerateImpl(masm, true); | |
3250 } | |
3251 | |
3252 static void HandlePolymorphicStoreCase(MacroAssembler* masm, Register feedback, | |
3253 Register receiver_map, Register scratch1, | |
3254 Register scratch2, Label* miss) { | |
3255 // feedback initially contains the feedback array | |
3256 Label next_loop, prepare_next; | |
3257 Label start_polymorphic; | |
3258 Label transition_call; | |
3259 | |
3260 Register cached_map = scratch1; | |
3261 Register too_far = scratch2; | |
3262 Register pointer_reg = feedback; | |
3263 __ LoadP(too_far, FieldMemOperand(feedback, FixedArray::kLengthOffset)); | |
3264 | |
3265 // +-----+------+------+-----+-----+-----+ ... ----+ | |
3266 // | map | len | wm0 | wt0 | h0 | wm1 | hN | | |
3267 // +-----+------+------+-----+-----+ ----+ ... ----+ | |
3268 // 0 1 2 len-1 | |
3269 // ^ ^ | |
3270 // | | | |
3271 // pointer_reg too_far | |
3272 // aka feedback scratch2 | |
3273 // also need receiver_map | |
3274 // use cached_map (scratch1) to look in the weak map values. | |
3275 __ SmiToPtrArrayOffset(r0, too_far); | |
3276 __ AddP(too_far, feedback, r0); | |
3277 __ AddP(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
3278 __ AddP(pointer_reg, feedback, | |
3279 Operand(FixedArray::OffsetOfElementAt(0) - kHeapObjectTag)); | |
3280 | |
3281 __ bind(&next_loop); | |
3282 __ LoadP(cached_map, MemOperand(pointer_reg)); | |
3283 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset)); | |
3284 __ CmpP(receiver_map, cached_map); | |
3285 __ bne(&prepare_next); | |
3286 // Is it a transitioning store? | |
3287 __ LoadP(too_far, MemOperand(pointer_reg, kPointerSize)); | |
3288 __ CompareRoot(too_far, Heap::kUndefinedValueRootIndex); | |
3289 __ bne(&transition_call); | |
3290 __ LoadP(pointer_reg, MemOperand(pointer_reg, kPointerSize * 2)); | |
3291 __ AddP(ip, pointer_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
3292 __ Jump(ip); | |
3293 | |
3294 __ bind(&transition_call); | |
3295 __ LoadP(too_far, FieldMemOperand(too_far, WeakCell::kValueOffset)); | |
3296 __ JumpIfSmi(too_far, miss); | |
3297 | |
3298 __ LoadP(receiver_map, MemOperand(pointer_reg, kPointerSize * 2)); | |
3299 | |
3300 // Load the map into the correct register. | |
3301 DCHECK(feedback.is(StoreTransitionDescriptor::MapRegister())); | |
3302 __ LoadRR(feedback, too_far); | |
3303 | |
3304 __ AddP(ip, receiver_map, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
3305 __ Jump(ip); | |
3306 | |
3307 __ bind(&prepare_next); | |
3308 __ AddP(pointer_reg, pointer_reg, Operand(kPointerSize * 3)); | |
3309 __ CmpLogicalP(pointer_reg, too_far); | |
3310 __ blt(&next_loop); | |
3311 | |
3312 // We exhausted our array of map handler pairs. | |
3313 __ b(miss); | |
3314 } | |
3315 | |
3316 void KeyedStoreICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { | |
3317 Register receiver = StoreWithVectorDescriptor::ReceiverRegister(); // r3 | |
3318 Register key = StoreWithVectorDescriptor::NameRegister(); // r4 | |
3319 Register vector = StoreWithVectorDescriptor::VectorRegister(); // r5 | |
3320 Register slot = StoreWithVectorDescriptor::SlotRegister(); // r6 | |
3321 DCHECK(StoreWithVectorDescriptor::ValueRegister().is(r2)); // r2 | |
3322 Register feedback = r7; | |
3323 Register receiver_map = r8; | |
3324 Register scratch1 = r9; | |
3325 | |
3326 __ SmiToPtrArrayOffset(r0, slot); | |
3327 __ AddP(feedback, vector, r0); | |
3328 __ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); | |
3329 | |
3330 // Try to quickly handle the monomorphic case without knowing for sure | |
3331 // if we have a weak cell in feedback. We do know it's safe to look | |
3332 // at WeakCell::kValueOffset. | |
3333 Label try_array, load_smi_map, compare_map; | |
3334 Label not_array, miss; | |
3335 HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector, slot, | |
3336 scratch1, &compare_map, &load_smi_map, &try_array); | |
3337 | |
3338 __ bind(&try_array); | |
3339 // Is it a fixed array? | |
3340 __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset)); | |
3341 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex); | |
3342 __ bne(¬_array); | |
3343 | |
3344 // We have a polymorphic element handler. | |
3345 Label polymorphic, try_poly_name; | |
3346 __ bind(&polymorphic); | |
3347 | |
3348 Register scratch2 = ip; | |
3349 | |
3350 HandlePolymorphicStoreCase(masm, feedback, receiver_map, scratch1, scratch2, | |
3351 &miss); | |
3352 | |
3353 __ bind(¬_array); | |
3354 // Is it generic? | |
3355 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); | |
3356 __ bne(&try_poly_name); | |
3357 Handle<Code> megamorphic_stub = | |
3358 KeyedStoreIC::ChooseMegamorphicStub(masm->isolate(), GetExtraICState()); | |
3359 __ Jump(megamorphic_stub, RelocInfo::CODE_TARGET); | |
3360 | |
3361 __ bind(&try_poly_name); | |
3362 // We might have a name in feedback, and a fixed array in the next slot. | |
3363 __ CmpP(key, feedback); | |
3364 __ bne(&miss); | |
3365 // If the name comparison succeeded, we know we have a fixed array with | |
3366 // at least one map/handler pair. | |
3367 __ SmiToPtrArrayOffset(r0, slot); | |
3368 __ AddP(feedback, vector, r0); | |
3369 __ LoadP(feedback, | |
3370 FieldMemOperand(feedback, FixedArray::kHeaderSize + kPointerSize)); | |
3371 HandleArrayCases(masm, feedback, receiver_map, scratch1, scratch2, false, | |
3372 &miss); | |
3373 | |
3374 __ bind(&miss); | |
3375 KeyedStoreIC::GenerateMiss(masm); | |
3376 | |
3377 __ bind(&load_smi_map); | |
3378 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex); | |
3379 __ b(&compare_map); | |
3380 } | |
3381 | |
3382 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 3148 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
3383 if (masm->isolate()->function_entry_hook() != NULL) { | 3149 if (masm->isolate()->function_entry_hook() != NULL) { |
3384 PredictableCodeSizeScope predictable(masm, | 3150 PredictableCodeSizeScope predictable(masm, |
3385 #if V8_TARGET_ARCH_S390X | 3151 #if V8_TARGET_ARCH_S390X |
3386 40); | 3152 40); |
3387 #elif V8_HOST_ARCH_S390 | 3153 #elif V8_HOST_ARCH_S390 |
3388 36); | 3154 36); |
3389 #else | 3155 #else |
3390 32); | 3156 32); |
3391 #endif | 3157 #endif |
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4748 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 4514 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
4749 kStackUnwindSpace, NULL, return_value_operand, NULL); | 4515 kStackUnwindSpace, NULL, return_value_operand, NULL); |
4750 } | 4516 } |
4751 | 4517 |
4752 #undef __ | 4518 #undef __ |
4753 | 4519 |
4754 } // namespace internal | 4520 } // namespace internal |
4755 } // namespace v8 | 4521 } // namespace v8 |
4756 | 4522 |
4757 #endif // V8_TARGET_ARCH_S390 | 4523 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |