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

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

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

Powered by Google App Engine
This is Rietveld 408576698