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 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2643 } | 2643 } |
2644 | 2644 |
2645 | 2645 |
2646 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { | 2646 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { |
2647 Register result = ToRegister(instr->result()); | 2647 Register result = ToRegister(instr->result()); |
2648 | 2648 |
2649 // Load the result. | 2649 // Load the result. |
2650 __ mov(result, | 2650 __ mov(result, |
2651 BuildFastArrayOperand(instr->elements(), | 2651 BuildFastArrayOperand(instr->elements(), |
2652 instr->key(), | 2652 instr->key(), |
| 2653 instr->hydrogen()->key()->representation(), |
2653 FAST_ELEMENTS, | 2654 FAST_ELEMENTS, |
2654 FixedArray::kHeaderSize - kHeapObjectTag, | 2655 FixedArray::kHeaderSize - kHeapObjectTag, |
2655 instr->additional_index())); | 2656 instr->additional_index())); |
2656 | 2657 |
2657 // Check for the hole value. | 2658 // Check for the hole value. |
2658 if (instr->hydrogen()->RequiresHoleCheck()) { | 2659 if (instr->hydrogen()->RequiresHoleCheck()) { |
2659 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { | 2660 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { |
2660 __ test(result, Immediate(kSmiTagMask)); | 2661 __ test(result, Immediate(kSmiTagMask)); |
2661 DeoptimizeIf(not_equal, instr->environment()); | 2662 DeoptimizeIf(not_equal, instr->environment()); |
2662 } else { | 2663 } else { |
2663 __ cmp(result, factory()->the_hole_value()); | 2664 __ cmp(result, factory()->the_hole_value()); |
2664 DeoptimizeIf(equal, instr->environment()); | 2665 DeoptimizeIf(equal, instr->environment()); |
2665 } | 2666 } |
2666 } | 2667 } |
2667 } | 2668 } |
2668 | 2669 |
2669 | 2670 |
2670 void LCodeGen::DoLoadKeyedFastDoubleElement( | 2671 void LCodeGen::DoLoadKeyedFastDoubleElement( |
2671 LLoadKeyedFastDoubleElement* instr) { | 2672 LLoadKeyedFastDoubleElement* instr) { |
2672 XMMRegister result = ToDoubleRegister(instr->result()); | 2673 XMMRegister result = ToDoubleRegister(instr->result()); |
2673 | 2674 |
2674 if (instr->hydrogen()->RequiresHoleCheck()) { | 2675 if (instr->hydrogen()->RequiresHoleCheck()) { |
2675 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + | 2676 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + |
2676 sizeof(kHoleNanLower32); | 2677 sizeof(kHoleNanLower32); |
2677 Operand hole_check_operand = BuildFastArrayOperand( | 2678 Operand hole_check_operand = BuildFastArrayOperand( |
2678 instr->elements(), instr->key(), | 2679 instr->elements(), instr->key(), |
| 2680 instr->hydrogen()->key()->representation(), |
2679 FAST_DOUBLE_ELEMENTS, | 2681 FAST_DOUBLE_ELEMENTS, |
2680 offset, | 2682 offset, |
2681 instr->additional_index()); | 2683 instr->additional_index()); |
2682 __ cmp(hole_check_operand, Immediate(kHoleNanUpper32)); | 2684 __ cmp(hole_check_operand, Immediate(kHoleNanUpper32)); |
2683 DeoptimizeIf(equal, instr->environment()); | 2685 DeoptimizeIf(equal, instr->environment()); |
2684 } | 2686 } |
2685 | 2687 |
2686 Operand double_load_operand = BuildFastArrayOperand( | 2688 Operand double_load_operand = BuildFastArrayOperand( |
2687 instr->elements(), | 2689 instr->elements(), |
2688 instr->key(), | 2690 instr->key(), |
| 2691 instr->hydrogen()->key()->representation(), |
2689 FAST_DOUBLE_ELEMENTS, | 2692 FAST_DOUBLE_ELEMENTS, |
2690 FixedDoubleArray::kHeaderSize - kHeapObjectTag, | 2693 FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
2691 instr->additional_index()); | 2694 instr->additional_index()); |
2692 __ movdbl(result, double_load_operand); | 2695 __ movdbl(result, double_load_operand); |
2693 } | 2696 } |
2694 | 2697 |
2695 | 2698 |
2696 Operand LCodeGen::BuildFastArrayOperand( | 2699 Operand LCodeGen::BuildFastArrayOperand( |
2697 LOperand* elements_pointer, | 2700 LOperand* elements_pointer, |
2698 LOperand* key, | 2701 LOperand* key, |
| 2702 Representation key_representation, |
2699 ElementsKind elements_kind, | 2703 ElementsKind elements_kind, |
2700 uint32_t offset, | 2704 uint32_t offset, |
2701 uint32_t additional_index) { | 2705 uint32_t additional_index) { |
2702 Register elements_pointer_reg = ToRegister(elements_pointer); | 2706 Register elements_pointer_reg = ToRegister(elements_pointer); |
2703 int shift_size = ElementsKindToShiftSize(elements_kind); | 2707 int shift_size = ElementsKindToShiftSize(elements_kind); |
| 2708 if (key_representation.IsTagged() && (shift_size >= 1)) { |
| 2709 shift_size -= kSmiTagSize; |
| 2710 } |
2704 if (key->IsConstantOperand()) { | 2711 if (key->IsConstantOperand()) { |
2705 int constant_value = ToInteger32(LConstantOperand::cast(key)); | 2712 int constant_value = ToInteger32(LConstantOperand::cast(key)); |
2706 if (constant_value & 0xF0000000) { | 2713 if (constant_value & 0xF0000000) { |
2707 Abort("array index constant value too big"); | 2714 Abort("array index constant value too big"); |
2708 } | 2715 } |
2709 return Operand(elements_pointer_reg, | 2716 return Operand(elements_pointer_reg, |
2710 ((constant_value + additional_index) << shift_size) | 2717 ((constant_value + additional_index) << shift_size) |
2711 + offset); | 2718 + offset); |
2712 } else { | 2719 } else { |
2713 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); | 2720 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); |
2714 return Operand(elements_pointer_reg, | 2721 return Operand(elements_pointer_reg, |
2715 ToRegister(key), | 2722 ToRegister(key), |
2716 scale_factor, | 2723 scale_factor, |
2717 offset + (additional_index << shift_size)); | 2724 offset + (additional_index << shift_size)); |
2718 } | 2725 } |
2719 } | 2726 } |
2720 | 2727 |
2721 | 2728 |
2722 void LCodeGen::DoLoadKeyedSpecializedArrayElement( | 2729 void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
2723 LLoadKeyedSpecializedArrayElement* instr) { | 2730 LLoadKeyedSpecializedArrayElement* instr) { |
2724 ElementsKind elements_kind = instr->elements_kind(); | 2731 ElementsKind elements_kind = instr->elements_kind(); |
2725 Operand operand(BuildFastArrayOperand(instr->external_pointer(), | 2732 LOperand* key = instr->key(); |
2726 instr->key(), | 2733 if (!key->IsConstantOperand() && |
2727 elements_kind, | 2734 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), |
2728 0, | 2735 elements_kind)) { |
2729 instr->additional_index())); | 2736 __ SmiUntag(ToRegister(key)); |
| 2737 } |
| 2738 Operand operand(BuildFastArrayOperand( |
| 2739 instr->external_pointer(), |
| 2740 key, |
| 2741 instr->hydrogen()->key()->representation(), |
| 2742 elements_kind, |
| 2743 0, |
| 2744 instr->additional_index())); |
2730 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { | 2745 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
2731 XMMRegister result(ToDoubleRegister(instr->result())); | 2746 XMMRegister result(ToDoubleRegister(instr->result())); |
2732 __ movss(result, operand); | 2747 __ movss(result, operand); |
2733 __ cvtss2sd(result, result); | 2748 __ cvtss2sd(result, result); |
2734 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | 2749 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
2735 __ movdbl(ToDoubleRegister(instr->result()), operand); | 2750 __ movdbl(ToDoubleRegister(instr->result()), operand); |
2736 } else { | 2751 } else { |
2737 Register result(ToRegister(instr->result())); | 2752 Register result(ToRegister(instr->result())); |
2738 switch (elements_kind) { | 2753 switch (elements_kind) { |
2739 case EXTERNAL_BYTE_ELEMENTS: | 2754 case EXTERNAL_BYTE_ELEMENTS: |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3672 } else { | 3687 } else { |
3673 __ cmp(ToRegister(instr->index()), ToOperand(instr->length())); | 3688 __ cmp(ToRegister(instr->index()), ToOperand(instr->length())); |
3674 DeoptimizeIf(above_equal, instr->environment()); | 3689 DeoptimizeIf(above_equal, instr->environment()); |
3675 } | 3690 } |
3676 } | 3691 } |
3677 | 3692 |
3678 | 3693 |
3679 void LCodeGen::DoStoreKeyedSpecializedArrayElement( | 3694 void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
3680 LStoreKeyedSpecializedArrayElement* instr) { | 3695 LStoreKeyedSpecializedArrayElement* instr) { |
3681 ElementsKind elements_kind = instr->elements_kind(); | 3696 ElementsKind elements_kind = instr->elements_kind(); |
3682 Operand operand(BuildFastArrayOperand(instr->external_pointer(), | 3697 LOperand* key = instr->key(); |
3683 instr->key(), | 3698 if (!key->IsConstantOperand() && |
3684 elements_kind, | 3699 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), |
3685 0, | 3700 elements_kind)) { |
3686 instr->additional_index())); | 3701 __ SmiUntag(ToRegister(key)); |
| 3702 } |
| 3703 Operand operand(BuildFastArrayOperand( |
| 3704 instr->external_pointer(), |
| 3705 key, |
| 3706 instr->hydrogen()->key()->representation(), |
| 3707 elements_kind, |
| 3708 0, |
| 3709 instr->additional_index())); |
3687 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { | 3710 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
3688 __ cvtsd2ss(xmm0, ToDoubleRegister(instr->value())); | 3711 __ cvtsd2ss(xmm0, ToDoubleRegister(instr->value())); |
3689 __ movss(operand, xmm0); | 3712 __ movss(operand, xmm0); |
3690 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | 3713 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
3691 __ movdbl(operand, ToDoubleRegister(instr->value())); | 3714 __ movdbl(operand, ToDoubleRegister(instr->value())); |
3692 } else { | 3715 } else { |
3693 Register value = ToRegister(instr->value()); | 3716 Register value = ToRegister(instr->value()); |
3694 switch (elements_kind) { | 3717 switch (elements_kind) { |
3695 case EXTERNAL_PIXEL_ELEMENTS: | 3718 case EXTERNAL_PIXEL_ELEMENTS: |
3696 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3719 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
(...skipping 26 matching lines...) Expand all Loading... |
3723 | 3746 |
3724 | 3747 |
3725 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { | 3748 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
3726 Register value = ToRegister(instr->value()); | 3749 Register value = ToRegister(instr->value()); |
3727 Register elements = ToRegister(instr->object()); | 3750 Register elements = ToRegister(instr->object()); |
3728 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; | 3751 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; |
3729 | 3752 |
3730 Operand operand = BuildFastArrayOperand( | 3753 Operand operand = BuildFastArrayOperand( |
3731 instr->object(), | 3754 instr->object(), |
3732 instr->key(), | 3755 instr->key(), |
| 3756 instr->hydrogen()->key()->representation(), |
3733 FAST_ELEMENTS, | 3757 FAST_ELEMENTS, |
3734 FixedArray::kHeaderSize - kHeapObjectTag, | 3758 FixedArray::kHeaderSize - kHeapObjectTag, |
3735 instr->additional_index()); | 3759 instr->additional_index()); |
3736 __ mov(operand, value); | 3760 __ mov(operand, value); |
3737 | 3761 |
3738 if (instr->hydrogen()->NeedsWriteBarrier()) { | 3762 if (instr->hydrogen()->NeedsWriteBarrier()) { |
3739 ASSERT(!instr->key()->IsConstantOperand()); | 3763 ASSERT(!instr->key()->IsConstantOperand()); |
3740 HType type = instr->hydrogen()->value()->type(); | 3764 HType type = instr->hydrogen()->value()->type(); |
3741 SmiCheck check_needed = | 3765 SmiCheck check_needed = |
3742 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; | 3766 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; |
(...skipping 21 matching lines...) Expand all Loading... |
3764 | 3788 |
3765 ExternalReference canonical_nan_reference = | 3789 ExternalReference canonical_nan_reference = |
3766 ExternalReference::address_of_canonical_non_hole_nan(); | 3790 ExternalReference::address_of_canonical_non_hole_nan(); |
3767 __ movdbl(value, Operand::StaticVariable(canonical_nan_reference)); | 3791 __ movdbl(value, Operand::StaticVariable(canonical_nan_reference)); |
3768 __ bind(&have_value); | 3792 __ bind(&have_value); |
3769 } | 3793 } |
3770 | 3794 |
3771 Operand double_store_operand = BuildFastArrayOperand( | 3795 Operand double_store_operand = BuildFastArrayOperand( |
3772 instr->elements(), | 3796 instr->elements(), |
3773 instr->key(), | 3797 instr->key(), |
| 3798 instr->hydrogen()->key()->representation(), |
3774 FAST_DOUBLE_ELEMENTS, | 3799 FAST_DOUBLE_ELEMENTS, |
3775 FixedDoubleArray::kHeaderSize - kHeapObjectTag, | 3800 FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
3776 instr->additional_index()); | 3801 instr->additional_index()); |
3777 __ movdbl(double_store_operand, value); | 3802 __ movdbl(double_store_operand, value); |
3778 } | 3803 } |
3779 | 3804 |
3780 | 3805 |
3781 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 3806 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
3782 ASSERT(ToRegister(instr->context()).is(esi)); | 3807 ASSERT(ToRegister(instr->context()).is(esi)); |
3783 ASSERT(ToRegister(instr->object()).is(edx)); | 3808 ASSERT(ToRegister(instr->object()).is(edx)); |
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5334 FixedArray::kHeaderSize - kPointerSize)); | 5359 FixedArray::kHeaderSize - kPointerSize)); |
5335 __ bind(&done); | 5360 __ bind(&done); |
5336 } | 5361 } |
5337 | 5362 |
5338 | 5363 |
5339 #undef __ | 5364 #undef __ |
5340 | 5365 |
5341 } } // namespace v8::internal | 5366 } } // namespace v8::internal |
5342 | 5367 |
5343 #endif // V8_TARGET_ARCH_IA32 | 5368 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |