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

Side by Side Diff: src/mips/code-stubs-mips.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/ic/x87/stub-cache-x87.cc ('k') | src/mips/codegen-mips.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_MIPS 5 #if V8_TARGET_ARCH_MIPS
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 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after
3259 __ Ret(USE_DELAY_SLOT); 3259 __ Ret(USE_DELAY_SLOT);
3260 __ Addu(sp, sp, a1); 3260 __ Addu(sp, sp, a1);
3261 } 3261 }
3262 3262
3263 void CallICTrampolineStub::Generate(MacroAssembler* masm) { 3263 void CallICTrampolineStub::Generate(MacroAssembler* masm) {
3264 __ EmitLoadTypeFeedbackVector(a2); 3264 __ EmitLoadTypeFeedbackVector(a2);
3265 CallICStub stub(isolate(), state()); 3265 CallICStub stub(isolate(), state());
3266 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 3266 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
3267 } 3267 }
3268 3268
3269
3270 static void HandleArrayCases(MacroAssembler* masm, Register feedback,
3271 Register receiver_map, Register scratch1,
3272 Register scratch2, bool is_polymorphic,
3273 Label* miss) {
3274 // feedback initially contains the feedback array
3275 Label next_loop, prepare_next;
3276 Label start_polymorphic;
3277
3278 Register cached_map = scratch1;
3279
3280 __ lw(cached_map,
3281 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(0)));
3282 __ lw(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
3283 __ Branch(&start_polymorphic, ne, receiver_map, Operand(cached_map));
3284 // found, now call handler.
3285 Register handler = feedback;
3286 __ lw(handler, FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(1)));
3287 __ Addu(t9, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
3288 __ Jump(t9);
3289
3290
3291 Register length = scratch2;
3292 __ bind(&start_polymorphic);
3293 __ lw(length, FieldMemOperand(feedback, FixedArray::kLengthOffset));
3294 if (!is_polymorphic) {
3295 // If the IC could be monomorphic we have to make sure we don't go past the
3296 // end of the feedback array.
3297 __ Branch(miss, eq, length, Operand(Smi::FromInt(2)));
3298 }
3299
3300 Register too_far = length;
3301 Register pointer_reg = feedback;
3302
3303 // +-----+------+------+-----+-----+ ... ----+
3304 // | map | len | wm0 | h0 | wm1 | hN |
3305 // +-----+------+------+-----+-----+ ... ----+
3306 // 0 1 2 len-1
3307 // ^ ^
3308 // | |
3309 // pointer_reg too_far
3310 // aka feedback scratch2
3311 // also need receiver_map
3312 // use cached_map (scratch1) to look in the weak map values.
3313 __ Lsa(too_far, feedback, length, kPointerSizeLog2 - kSmiTagSize);
3314 __ Addu(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
3315 __ Addu(pointer_reg, feedback,
3316 Operand(FixedArray::OffsetOfElementAt(2) - kHeapObjectTag));
3317
3318 __ bind(&next_loop);
3319 __ lw(cached_map, MemOperand(pointer_reg));
3320 __ lw(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
3321 __ Branch(&prepare_next, ne, receiver_map, Operand(cached_map));
3322 __ lw(handler, MemOperand(pointer_reg, kPointerSize));
3323 __ Addu(t9, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
3324 __ Jump(t9);
3325
3326 __ bind(&prepare_next);
3327 __ Addu(pointer_reg, pointer_reg, Operand(kPointerSize * 2));
3328 __ Branch(&next_loop, lt, pointer_reg, Operand(too_far));
3329
3330 // We exhausted our array of map handler pairs.
3331 __ jmp(miss);
3332 }
3333
3334
3335 static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver,
3336 Register receiver_map, Register feedback,
3337 Register vector, Register slot,
3338 Register scratch, Label* compare_map,
3339 Label* load_smi_map, Label* try_array) {
3340 __ JumpIfSmi(receiver, load_smi_map);
3341 __ lw(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
3342 __ bind(compare_map);
3343 Register cached_map = scratch;
3344 // Move the weak map into the weak_cell register.
3345 __ lw(cached_map, FieldMemOperand(feedback, WeakCell::kValueOffset));
3346 __ Branch(try_array, ne, cached_map, Operand(receiver_map));
3347 Register handler = feedback;
3348
3349 __ Lsa(handler, vector, slot, kPointerSizeLog2 - kSmiTagSize);
3350 __ lw(handler,
3351 FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize));
3352 __ Addu(t9, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
3353 __ Jump(t9);
3354 }
3355
3356 void KeyedStoreICTrampolineStub::Generate(MacroAssembler* masm) {
3357 __ EmitLoadTypeFeedbackVector(StoreWithVectorDescriptor::VectorRegister());
3358 KeyedStoreICStub stub(isolate(), state());
3359 stub.GenerateForTrampoline(masm);
3360 }
3361
3362 void KeyedStoreICStub::Generate(MacroAssembler* masm) {
3363 GenerateImpl(masm, false);
3364 }
3365
3366 void KeyedStoreICStub::GenerateForTrampoline(MacroAssembler* masm) {
3367 GenerateImpl(masm, true);
3368 }
3369
3370
3371 static void HandlePolymorphicStoreCase(MacroAssembler* masm, Register feedback,
3372 Register receiver_map, Register scratch1,
3373 Register scratch2, Label* miss) {
3374 // feedback initially contains the feedback array
3375 Label next_loop, prepare_next;
3376 Label start_polymorphic;
3377 Label transition_call;
3378
3379 Register cached_map = scratch1;
3380 Register too_far = scratch2;
3381 Register pointer_reg = feedback;
3382 __ lw(too_far, FieldMemOperand(feedback, FixedArray::kLengthOffset));
3383
3384 // +-----+------+------+-----+-----+-----+ ... ----+
3385 // | map | len | wm0 | wt0 | h0 | wm1 | hN |
3386 // +-----+------+------+-----+-----+ ----+ ... ----+
3387 // 0 1 2 len-1
3388 // ^ ^
3389 // | |
3390 // pointer_reg too_far
3391 // aka feedback scratch2
3392 // also need receiver_map
3393 // use cached_map (scratch1) to look in the weak map values.
3394 __ Lsa(too_far, feedback, too_far, kPointerSizeLog2 - kSmiTagSize);
3395 __ Addu(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
3396 __ Addu(pointer_reg, feedback,
3397 Operand(FixedArray::OffsetOfElementAt(0) - kHeapObjectTag));
3398
3399 __ bind(&next_loop);
3400 __ lw(cached_map, MemOperand(pointer_reg));
3401 __ lw(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
3402 __ Branch(&prepare_next, ne, receiver_map, Operand(cached_map));
3403 // Is it a transitioning store?
3404 __ lw(too_far, MemOperand(pointer_reg, kPointerSize));
3405 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
3406 __ Branch(&transition_call, ne, too_far, Operand(at));
3407 __ lw(pointer_reg, MemOperand(pointer_reg, kPointerSize * 2));
3408 __ Addu(t9, pointer_reg, Operand(Code::kHeaderSize - kHeapObjectTag));
3409 __ Jump(t9);
3410
3411 __ bind(&transition_call);
3412 __ lw(too_far, FieldMemOperand(too_far, WeakCell::kValueOffset));
3413 __ JumpIfSmi(too_far, miss);
3414
3415 __ lw(receiver_map, MemOperand(pointer_reg, kPointerSize * 2));
3416
3417 // Load the map into the correct register.
3418 DCHECK(feedback.is(StoreTransitionDescriptor::MapRegister()));
3419 __ mov(feedback, too_far);
3420
3421 __ Addu(t9, receiver_map, Operand(Code::kHeaderSize - kHeapObjectTag));
3422 __ Jump(t9);
3423
3424 __ bind(&prepare_next);
3425 __ Addu(pointer_reg, pointer_reg, Operand(kPointerSize * 3));
3426 __ Branch(&next_loop, lt, pointer_reg, Operand(too_far));
3427
3428 // We exhausted our array of map handler pairs.
3429 __ jmp(miss);
3430 }
3431
3432 void KeyedStoreICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
3433 Register receiver = StoreWithVectorDescriptor::ReceiverRegister(); // a1
3434 Register key = StoreWithVectorDescriptor::NameRegister(); // a2
3435 Register vector = StoreWithVectorDescriptor::VectorRegister(); // a3
3436 Register slot = StoreWithVectorDescriptor::SlotRegister(); // t0
3437 DCHECK(StoreWithVectorDescriptor::ValueRegister().is(a0)); // a0
3438 Register feedback = t1;
3439 Register receiver_map = t2;
3440 Register scratch1 = t5;
3441
3442 __ Lsa(feedback, vector, slot, kPointerSizeLog2 - kSmiTagSize);
3443 __ lw(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
3444
3445 // Try to quickly handle the monomorphic case without knowing for sure
3446 // if we have a weak cell in feedback. We do know it's safe to look
3447 // at WeakCell::kValueOffset.
3448 Label try_array, load_smi_map, compare_map;
3449 Label not_array, miss;
3450 HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector, slot,
3451 scratch1, &compare_map, &load_smi_map, &try_array);
3452
3453 __ bind(&try_array);
3454 // Is it a fixed array?
3455 __ lw(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
3456 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
3457 __ Branch(&not_array, ne, scratch1, Operand(at));
3458
3459 // We have a polymorphic element handler.
3460 Label polymorphic, try_poly_name;
3461 __ bind(&polymorphic);
3462
3463 Register scratch2 = t4;
3464
3465 HandlePolymorphicStoreCase(masm, feedback, receiver_map, scratch1, scratch2,
3466 &miss);
3467
3468 __ bind(&not_array);
3469 // Is it generic?
3470 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex);
3471 __ Branch(&try_poly_name, ne, feedback, Operand(at));
3472 Handle<Code> megamorphic_stub =
3473 KeyedStoreIC::ChooseMegamorphicStub(masm->isolate(), GetExtraICState());
3474 __ Jump(megamorphic_stub, RelocInfo::CODE_TARGET);
3475
3476 __ bind(&try_poly_name);
3477 // We might have a name in feedback, and a fixed array in the next slot.
3478 __ Branch(&miss, ne, key, Operand(feedback));
3479 // If the name comparison succeeded, we know we have a fixed array with
3480 // at least one map/handler pair.
3481 __ Lsa(feedback, vector, slot, kPointerSizeLog2 - kSmiTagSize);
3482 __ lw(feedback,
3483 FieldMemOperand(feedback, FixedArray::kHeaderSize + kPointerSize));
3484 HandleArrayCases(masm, feedback, receiver_map, scratch1, scratch2, false,
3485 &miss);
3486
3487 __ bind(&miss);
3488 KeyedStoreIC::GenerateMiss(masm);
3489
3490 __ bind(&load_smi_map);
3491 __ Branch(USE_DELAY_SLOT, &compare_map);
3492 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex); // In delay slot.
3493 }
3494
3495
3496 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 3269 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
3497 if (masm->isolate()->function_entry_hook() != NULL) { 3270 if (masm->isolate()->function_entry_hook() != NULL) {
3498 ProfileEntryHookStub stub(masm->isolate()); 3271 ProfileEntryHookStub stub(masm->isolate());
3499 __ push(ra); 3272 __ push(ra);
3500 __ CallStub(&stub); 3273 __ CallStub(&stub);
3501 __ pop(ra); 3274 __ pop(ra);
3502 } 3275 }
3503 } 3276 }
3504 3277
3505 3278
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
4766 kStackUnwindSpace, kInvalidStackOffset, 4539 kStackUnwindSpace, kInvalidStackOffset,
4767 return_value_operand, NULL); 4540 return_value_operand, NULL);
4768 } 4541 }
4769 4542
4770 #undef __ 4543 #undef __
4771 4544
4772 } // namespace internal 4545 } // namespace internal
4773 } // namespace v8 4546 } // namespace v8
4774 4547
4775 #endif // V8_TARGET_ARCH_MIPS 4548 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ic/x87/stub-cache-x87.cc ('k') | src/mips/codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698