OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2518 __ subu(length, length, index); | 2518 __ subu(length, length, index); |
2519 __ Addu(length, length, Operand(1)); | 2519 __ Addu(length, length, Operand(1)); |
2520 __ sll(length, length, kPointerSizeLog2); | 2520 __ sll(length, length, kPointerSizeLog2); |
2521 __ Addu(at, arguments, Operand(length)); | 2521 __ Addu(at, arguments, Operand(length)); |
2522 __ lw(result, MemOperand(at, 0)); | 2522 __ lw(result, MemOperand(at, 0)); |
2523 } | 2523 } |
2524 | 2524 |
2525 | 2525 |
2526 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { | 2526 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { |
2527 Register elements = ToRegister(instr->elements()); | 2527 Register elements = ToRegister(instr->elements()); |
2528 Register key = EmitLoadRegister(instr->key(), scratch0()); | |
2529 Register result = ToRegister(instr->result()); | 2528 Register result = ToRegister(instr->result()); |
2530 Register scratch = scratch0(); | 2529 Register scratch = scratch0(); |
2531 | 2530 |
2532 // Load the result. | 2531 if (instr->key()->IsConstantOperand()) { |
2533 if (instr->hydrogen()->key()->representation().IsTagged()) { | 2532 LConstantOperand* const_operand = LConstantOperand::cast(instr->key()); |
2534 __ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize); | 2533 int offset = |
2535 __ addu(scratch, elements, scratch); | 2534 (ToInteger32(const_operand) + instr->additional_index()) * kPointerSize |
| 2535 + FixedArray::kHeaderSize; |
| 2536 __ lw(result, FieldMemOperand(elements, offset)); |
2536 } else { | 2537 } else { |
2537 __ sll(scratch, key, kPointerSizeLog2); | 2538 Register key = EmitLoadRegister(instr->key(), scratch); |
2538 __ addu(scratch, elements, scratch); | 2539 // Even though the HLoadKeyedFastElement instruction forces the input |
| 2540 // representation for the key to be an integer, the input gets replaced |
| 2541 // during bound check elimination with the index argument to the bounds |
| 2542 // check, which can be tagged, so that case must be handled here, too. |
| 2543 if (instr->hydrogen()->key()->representation().IsTagged()) { |
| 2544 __ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize); |
| 2545 __ addu(scratch, elements, scratch); |
| 2546 } else { |
| 2547 __ sll(scratch, key, kPointerSizeLog2); |
| 2548 __ addu(scratch, elements, scratch); |
| 2549 } |
| 2550 uint32_t offset = FixedArray::kHeaderSize + |
| 2551 (instr->additional_index() << kPointerSizeLog2); |
| 2552 __ lw(result, FieldMemOperand(scratch, offset)); |
2539 } | 2553 } |
2540 uint32_t offset = FixedArray::kHeaderSize + | |
2541 (instr->additional_index() << kPointerSizeLog2); | |
2542 __ lw(result, FieldMemOperand(scratch, offset)); | |
2543 | 2554 |
2544 // Check for the hole value. | 2555 // Check for the hole value. |
2545 if (instr->hydrogen()->RequiresHoleCheck()) { | 2556 if (instr->hydrogen()->RequiresHoleCheck()) { |
2546 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { | 2557 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { |
2547 __ And(scratch, result, Operand(kSmiTagMask)); | 2558 __ And(scratch, result, Operand(kSmiTagMask)); |
2548 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg)); | 2559 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg)); |
2549 } else { | 2560 } else { |
2550 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); | 2561 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); |
2551 DeoptimizeIf(eq, instr->environment(), result, Operand(scratch)); | 2562 DeoptimizeIf(eq, instr->environment(), result, Operand(scratch)); |
2552 } | 2563 } |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3578 // Name is always in a2. | 3589 // Name is always in a2. |
3579 __ li(a2, Operand(instr->name())); | 3590 __ li(a2, Operand(instr->name())); |
3580 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) | 3591 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) |
3581 ? isolate()->builtins()->StoreIC_Initialize_Strict() | 3592 ? isolate()->builtins()->StoreIC_Initialize_Strict() |
3582 : isolate()->builtins()->StoreIC_Initialize(); | 3593 : isolate()->builtins()->StoreIC_Initialize(); |
3583 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3594 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
3584 } | 3595 } |
3585 | 3596 |
3586 | 3597 |
3587 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { | 3598 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { |
3588 DeoptimizeIf(hs, | 3599 if (instr->index()->IsConstantOperand()) { |
3589 instr->environment(), | 3600 int constant_index = |
3590 ToRegister(instr->index()), | 3601 ToInteger32(LConstantOperand::cast(instr->index())); |
3591 Operand(ToRegister(instr->length()))); | 3602 if (instr->hydrogen()->length()->representation().IsTagged()) { |
| 3603 __ li(at, Operand(Smi::FromInt(constant_index))); |
| 3604 } else { |
| 3605 __ li(at, Operand(constant_index)); |
| 3606 } |
| 3607 DeoptimizeIf(hs, |
| 3608 instr->environment(), |
| 3609 at, |
| 3610 Operand(ToRegister(instr->length()))); |
| 3611 } else { |
| 3612 DeoptimizeIf(hs, |
| 3613 instr->environment(), |
| 3614 ToRegister(instr->index()), |
| 3615 Operand(ToRegister(instr->length()))); |
| 3616 } |
3592 } | 3617 } |
3593 | 3618 |
3594 | 3619 |
3595 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { | 3620 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
3596 Register value = ToRegister(instr->value()); | 3621 Register value = ToRegister(instr->value()); |
3597 Register elements = ToRegister(instr->object()); | 3622 Register elements = ToRegister(instr->object()); |
3598 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; | 3623 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; |
3599 Register scratch = scratch0(); | 3624 Register scratch = scratch0(); |
3600 | 3625 |
3601 // Do the store. | 3626 // Do the store. |
3602 if (instr->key()->IsConstantOperand()) { | 3627 if (instr->key()->IsConstantOperand()) { |
3603 ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); | 3628 ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); |
3604 LConstantOperand* const_operand = LConstantOperand::cast(instr->key()); | 3629 LConstantOperand* const_operand = LConstantOperand::cast(instr->key()); |
3605 int offset = | 3630 int offset = |
3606 (ToInteger32(const_operand) + instr->additional_index()) * kPointerSize | 3631 (ToInteger32(const_operand) + instr->additional_index()) * kPointerSize |
3607 + FixedArray::kHeaderSize; | 3632 + FixedArray::kHeaderSize; |
3608 __ sw(value, FieldMemOperand(elements, offset)); | 3633 __ sw(value, FieldMemOperand(elements, offset)); |
3609 } else { | 3634 } else { |
| 3635 // Even though the HLoadKeyedFastElement instruction forces the input |
| 3636 // representation for the key to be an integer, the input gets replaced |
| 3637 // during bound check elimination with the index argument to the bounds |
| 3638 // check, which can be tagged, so that case must be handled here, too. |
3610 if (instr->hydrogen()->key()->representation().IsTagged()) { | 3639 if (instr->hydrogen()->key()->representation().IsTagged()) { |
3611 __ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize); | 3640 __ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize); |
3612 __ addu(scratch, elements, scratch); | 3641 __ addu(scratch, elements, scratch); |
3613 } else { | 3642 } else { |
3614 __ sll(scratch, key, kPointerSizeLog2); | 3643 __ sll(scratch, key, kPointerSizeLog2); |
3615 __ addu(scratch, elements, scratch); | 3644 __ addu(scratch, elements, scratch); |
3616 } | 3645 } |
3617 if (instr->additional_index() != 0) { | 3646 uint32_t offset = FixedArray::kHeaderSize + |
3618 __ Addu(scratch, | 3647 (instr->additional_index() << kPointerSizeLog2); |
3619 scratch, | 3648 __ sw(value, FieldMemOperand(scratch, offset)); |
3620 instr->additional_index() << kPointerSizeLog2); | |
3621 } | |
3622 __ sw(value, FieldMemOperand(scratch, FixedArray::kHeaderSize)); | |
3623 } | 3649 } |
3624 | 3650 |
3625 if (instr->hydrogen()->NeedsWriteBarrier()) { | 3651 if (instr->hydrogen()->NeedsWriteBarrier()) { |
3626 HType type = instr->hydrogen()->value()->type(); | 3652 HType type = instr->hydrogen()->value()->type(); |
3627 SmiCheck check_needed = | 3653 SmiCheck check_needed = |
3628 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; | 3654 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; |
3629 // Compute address of modified element and store it into key register. | 3655 // Compute address of modified element and store it into key register. |
3630 __ Addu(key, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 3656 __ Addu(key, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
3631 __ RecordWrite(elements, | 3657 __ RecordWrite(elements, |
3632 key, | 3658 key, |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5239 __ Subu(scratch, result, scratch); | 5265 __ Subu(scratch, result, scratch); |
5240 __ lw(result, FieldMemOperand(scratch, | 5266 __ lw(result, FieldMemOperand(scratch, |
5241 FixedArray::kHeaderSize - kPointerSize)); | 5267 FixedArray::kHeaderSize - kPointerSize)); |
5242 __ bind(&done); | 5268 __ bind(&done); |
5243 } | 5269 } |
5244 | 5270 |
5245 | 5271 |
5246 #undef __ | 5272 #undef __ |
5247 | 5273 |
5248 } } // namespace v8::internal | 5274 } } // namespace v8::internal |
OLD | NEW |