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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 12315005: Constant fold math and string operations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "double.h"
30 #include "factory.h" 31 #include "factory.h"
31 #include "hydrogen.h" 32 #include "hydrogen.h"
32 33
33 #if V8_TARGET_ARCH_IA32 34 #if V8_TARGET_ARCH_IA32
34 #include "ia32/lithium-ia32.h" 35 #include "ia32/lithium-ia32.h"
35 #elif V8_TARGET_ARCH_X64 36 #elif V8_TARGET_ARCH_X64
36 #include "x64/lithium-x64.h" 37 #include "x64/lithium-x64.h"
37 #elif V8_TARGET_ARCH_ARM 38 #elif V8_TARGET_ARCH_ARM
38 #include "arm/lithium-arm.h" 39 #include "arm/lithium-arm.h"
39 #elif V8_TARGET_ARCH_MIPS 40 #elif V8_TARGET_ARCH_MIPS
(...skipping 2708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 Representation::Integer32()) 2749 Representation::Integer32())
2749 #define H_CONSTANT_DOUBLE(val) \ 2750 #define H_CONSTANT_DOUBLE(val) \
2750 new(zone) HConstant(FACTORY->NewNumber(val, TENURED), \ 2751 new(zone) HConstant(FACTORY->NewNumber(val, TENURED), \
2751 Representation::Double()) 2752 Representation::Double())
2752 2753
2753 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ 2754 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \
2754 HInstruction* HInstr::New##HInstr(Zone* zone, \ 2755 HInstruction* HInstr::New##HInstr(Zone* zone, \
2755 HValue* context, \ 2756 HValue* context, \
2756 HValue* left, \ 2757 HValue* left, \
2757 HValue* right) { \ 2758 HValue* right) { \
2758 if (left->IsConstant() && right->IsConstant()) { \ 2759 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \
2759 HConstant* c_left = HConstant::cast(left); \ 2760 HConstant* c_left = HConstant::cast(left); \
2760 HConstant* c_right = HConstant::cast(right); \ 2761 HConstant* c_right = HConstant::cast(right); \
2761 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ 2762 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \
2762 double double_res = c_left->DoubleValue() op c_right->DoubleValue(); \ 2763 double double_res = c_left->DoubleValue() op c_right->DoubleValue(); \
2763 if (TypeInfo::IsInt32Double(double_res)) { \ 2764 if (TypeInfo::IsInt32Double(double_res)) { \
2764 return H_CONSTANT_INT32(static_cast<int32_t>(double_res)); \ 2765 return H_CONSTANT_INT32(static_cast<int32_t>(double_res)); \
2765 } \ 2766 } \
2766 return H_CONSTANT_DOUBLE(double_res); \ 2767 return H_CONSTANT_DOUBLE(double_res); \
2767 } \ 2768 } \
2768 } \ 2769 } \
2769 return new(zone) HInstr(context, left, right); \ 2770 return new(zone) HInstr(context, left, right); \
2770 } 2771 }
2771 2772
2772 2773
2773 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) 2774 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +)
2774 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) 2775 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *)
2775 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) 2776 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -)
2776 2777
2777 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR 2778 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR
2778 2779
2779 2780
2781 HInstruction* HStringAdd::NewHStringAdd(Zone* zone,
2782 HValue* context,
2783 HValue* left,
2784 HValue* right) {
2785 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
2786 HConstant* c_right = HConstant::cast(right);
2787 HConstant* c_left = HConstant::cast(left);
2788 if (c_left->HasStringValue() && c_right->HasStringValue()) {
2789 return new(zone) HConstant(FACTORY->NewConsString(c_left->StringValue(),
2790 c_right->StringValue()),
2791 Representation::Tagged());
2792 }
2793 }
2794 return new(zone) HStringAdd(context, left, right);
2795 }
2796
2797
2798 HInstruction* HStringCharFromCode::NewHStringCharFromCode(Zone* zone,
2799 HValue* context,
2800 HValue* char_code) {
2801 if (FLAG_fold_constants && char_code->IsConstant()) {
2802 HConstant* c_code = HConstant::cast(char_code);
2803 if (c_code->HasNumberValue()) {
2804 if (isfinite(c_code->DoubleValue())) {
2805 uint32_t code = c_code->NumberValueAsInteger32() & 0xffff;
2806 return new(zone) HConstant(LookupSingleCharacterStringFromCode(code),
2807 Representation::Tagged());
2808 }
2809 return new(zone) HConstant(FACTORY->empty_string(),
2810 Representation::Tagged());
2811 }
2812 }
2813 return new(zone) HStringCharFromCode(context, char_code);
2814 }
2815
2816
2817 HInstruction* HStringLength::NewHStringLength(Zone* zone, HValue* string) {
2818 if (FLAG_fold_constants && string->IsConstant()) {
2819 HConstant* c_string = HConstant::cast(string);
2820 if (c_string->HasStringValue()) {
2821 return H_CONSTANT_INT32(c_string->StringValue()->length());
2822 }
2823 }
2824 return new(zone) HStringLength(string);
2825 }
2826
2827
2828 HInstruction* HUnaryMathOperation::NewHUnaryMathOperation(
2829 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) {
2830 do {
2831 if (!FLAG_fold_constants) break;
2832 if (!value->IsConstant()) break;
2833 HConstant* constant = HConstant::cast(value);
2834 if (!constant->HasNumberValue()) break;
2835 double d = constant->DoubleValue();
2836 if (isnan(d)) { // NaN poisons everything.
2837 return H_CONSTANT_DOUBLE(OS::nan_value());
2838 }
2839 if (isinf(d)) { // +Inifinity and -Infinity.
Jakob Kummerow 2013/02/20 15:31:04 nit: "Inifinity" sounds nice, but has an "i" too m
Yang 2013/02/20 17:51:15 Done.
2840 switch (op) {
2841 case kMathSin:
2842 case kMathCos:
2843 case kMathTan:
2844 return H_CONSTANT_DOUBLE(OS::nan_value());
2845 case kMathExp:
2846 return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0);
2847 case kMathLog:
2848 case kMathSqrt:
2849 return H_CONSTANT_DOUBLE((d > 0.0) ? d : OS::nan_value());
2850 case kMathPowHalf:
2851 case kMathAbs:
2852 return H_CONSTANT_DOUBLE((d > 0.0) ? d : -d);
2853 case kMathRound:
2854 case kMathFloor:
2855 return H_CONSTANT_DOUBLE(d);
2856 default:
2857 UNREACHABLE();
2858 break;
2859 }
2860 }
2861 switch (op) {
2862 case kMathSin:
2863 return H_CONSTANT_DOUBLE(fast_sin(d));
2864 case kMathCos:
2865 return H_CONSTANT_DOUBLE(fast_cos(d));
2866 case kMathTan:
2867 return H_CONSTANT_DOUBLE(fast_tan(d));
2868 case kMathExp:
2869 return H_CONSTANT_DOUBLE(fast_exp(d));
2870 case kMathLog:
2871 return H_CONSTANT_DOUBLE(fast_log(d));
2872 case kMathSqrt:
2873 return H_CONSTANT_DOUBLE(fast_sqrt(d));
2874 case kMathPowHalf:
2875 return H_CONSTANT_DOUBLE(power_double_double(d, 0.5));
2876 case kMathAbs:
2877 return H_CONSTANT_DOUBLE((d >= 0.0) ? d + 0.0 : -d);
2878 case kMathRound:
2879 if (d >= -0.5 && d < 0.0) return H_CONSTANT_DOUBLE(-0.0);
2880 // Doubles are represented as Significant * 2 ^ Exponent. If the
2881 // Exponent is not negative, the double value is already an integer.
2882 if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d);
Jakob Kummerow 2013/02/20 15:31:04 I'm not convinced having this "fast path" is worth
Yang 2013/02/20 17:51:15 This is not a fast path, but for correctness. The
2883 return H_CONSTANT_DOUBLE(floor(d + 0.5));
2884 case kMathFloor:
2885 return H_CONSTANT_DOUBLE(floor(d));
2886 default:
2887 UNREACHABLE();
2888 break;
2889 }
2890 } while (false);
2891 return new(zone) HUnaryMathOperation(context, value, op);
2892 }
2893
2894
2895 HInstruction* HPower::NewHPower(Zone* zone,
2896 HValue* left,
2897 HValue* right) {
2898 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
2899 HConstant* c_left = HConstant::cast(left);
2900 HConstant* c_right = HConstant::cast(right);
2901 if (c_left->HasNumberValue() && c_right->HasNumberValue()) {
2902 double result = power_helper(c_left->DoubleValue(),
2903 c_right->DoubleValue());
2904 return H_CONSTANT_DOUBLE(isnan(result) ? OS::nan_value() : result);
2905 }
2906 }
2907 return new(zone) HPower(left, right);
2908 }
2909
2910
2911 HInstruction* HMathMinMax::NewHMathMinMax(Zone* zone,
2912 HValue* context,
2913 HValue* left,
2914 HValue* right,
2915 Operation op) {
2916 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
2917 HConstant* c_left = HConstant::cast(left);
2918 HConstant* c_right = HConstant::cast(right);
2919 if (c_left->HasNumberValue() && c_right->HasNumberValue()) {
2920 double d_left = c_left->DoubleValue();
2921 double d_right = c_right->DoubleValue();
2922 if (op == kMathMin) {
Jakob Kummerow 2013/02/20 15:31:04 nit: double space
2923 if (d_left > d_right) return H_CONSTANT_DOUBLE(d_right);
2924 if (d_left < d_right) return H_CONSTANT_DOUBLE(d_left);
2925 if (d_left == d_right) {
2926 // Handle +0 and -0.
2927 return H_CONSTANT_DOUBLE((Double(d_left).Sign() == -1) ? d_left
2928 : d_right);
2929 }
2930 } else {
2931 if (d_left < d_right) return H_CONSTANT_DOUBLE(d_right);
2932 if (d_left > d_right) return H_CONSTANT_DOUBLE(d_left);
2933 if (d_left == d_right) {
2934 // Handle +0 and -0.
2935 return H_CONSTANT_DOUBLE((Double(d_left).Sign() == -1) ? d_right
2936 : d_left);
2937 }
2938 }
2939 // All comparisons failed, must be NaN.
2940 return H_CONSTANT_DOUBLE(OS::nan_value());
2941 }
2942 }
2943 return new(zone) HMathMinMax(context, left, right, op);
2944 }
2945
2946
2780 HInstruction* HMod::NewHMod(Zone* zone, 2947 HInstruction* HMod::NewHMod(Zone* zone,
2781 HValue* context, 2948 HValue* context,
2782 HValue* left, 2949 HValue* left,
2783 HValue* right) { 2950 HValue* right) {
2784 if (left->IsConstant() && right->IsConstant()) { 2951 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
2785 HConstant* c_left = HConstant::cast(left); 2952 HConstant* c_left = HConstant::cast(left);
2786 HConstant* c_right = HConstant::cast(right); 2953 HConstant* c_right = HConstant::cast(right);
2787 if (c_left->HasInteger32Value() && c_right->HasInteger32Value()) { 2954 if (c_left->HasInteger32Value() && c_right->HasInteger32Value()) {
2788 int32_t dividend = c_left->Integer32Value(); 2955 int32_t dividend = c_left->Integer32Value();
2789 int32_t divisor = c_right->Integer32Value(); 2956 int32_t divisor = c_right->Integer32Value();
2790 if (divisor != 0) { 2957 if (divisor != 0) {
2791 int32_t res = dividend % divisor; 2958 int32_t res = dividend % divisor;
2792 if ((res == 0) && (dividend < 0)) { 2959 if ((res == 0) && (dividend < 0)) {
2793 return H_CONSTANT_DOUBLE(-0.0); 2960 return H_CONSTANT_DOUBLE(-0.0);
2794 } 2961 }
2795 return H_CONSTANT_INT32(res); 2962 return H_CONSTANT_INT32(res);
2796 } 2963 }
2797 } 2964 }
2798 } 2965 }
2799 return new(zone) HMod(context, left, right); 2966 return new(zone) HMod(context, left, right);
2800 } 2967 }
2801 2968
2802 2969
2803 HInstruction* HDiv::NewHDiv(Zone* zone, 2970 HInstruction* HDiv::NewHDiv(Zone* zone,
2804 HValue* context, 2971 HValue* context,
2805 HValue* left, 2972 HValue* left,
2806 HValue* right) { 2973 HValue* right) {
2807 // If left and right are constant values, try to return a constant value. 2974 // If left and right are constant values, try to return a constant value.
2808 if (left->IsConstant() && right->IsConstant()) { 2975 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
2809 HConstant* c_left = HConstant::cast(left); 2976 HConstant* c_left = HConstant::cast(left);
2810 HConstant* c_right = HConstant::cast(right); 2977 HConstant* c_right = HConstant::cast(right);
2811 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { 2978 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) {
2812 if (c_right->DoubleValue() != 0) { 2979 if (c_right->DoubleValue() != 0) {
2813 double double_res = c_left->DoubleValue() / c_right->DoubleValue(); 2980 double double_res = c_left->DoubleValue() / c_right->DoubleValue();
2814 if (TypeInfo::IsInt32Double(double_res)) { 2981 if (TypeInfo::IsInt32Double(double_res)) {
2815 return H_CONSTANT_INT32(static_cast<int32_t>(double_res)); 2982 return H_CONSTANT_INT32(static_cast<int32_t>(double_res));
2816 } 2983 }
2817 return H_CONSTANT_DOUBLE(double_res); 2984 return H_CONSTANT_DOUBLE(double_res);
2985 } else {
2986 int sign = Double(c_left->DoubleValue()).Sign() *
2987 Double(c_right->DoubleValue()).Sign(); // Right could be -0.
2988 return H_CONSTANT_DOUBLE(sign * V8_INFINITY);
2818 } 2989 }
2819 } 2990 }
2820 } 2991 }
2821 return new(zone) HDiv(context, left, right); 2992 return new(zone) HDiv(context, left, right);
2822 } 2993 }
2823 2994
2824 2995
2825 HInstruction* HBitwise::NewHBitwise(Zone* zone, 2996 HInstruction* HBitwise::NewHBitwise(Zone* zone,
2826 Token::Value op, 2997 Token::Value op,
2827 HValue* context, 2998 HValue* context,
2828 HValue* left, 2999 HValue* left,
2829 HValue* right) { 3000 HValue* right) {
2830 if (left->IsConstant() && right->IsConstant()) { 3001 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
2831 HConstant* c_left = HConstant::cast(left); 3002 HConstant* c_left = HConstant::cast(left);
2832 HConstant* c_right = HConstant::cast(right); 3003 HConstant* c_right = HConstant::cast(right);
2833 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { 3004 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) {
2834 int32_t result; 3005 int32_t result;
2835 int32_t v_left = c_left->NumberValueAsInteger32(); 3006 int32_t v_left = c_left->NumberValueAsInteger32();
2836 int32_t v_right = c_right->NumberValueAsInteger32(); 3007 int32_t v_right = c_right->NumberValueAsInteger32();
2837 switch (op) { 3008 switch (op) {
2838 case Token::BIT_XOR: 3009 case Token::BIT_XOR:
2839 result = v_left ^ v_right; 3010 result = v_left ^ v_right;
2840 break; 3011 break;
(...skipping 12 matching lines...) Expand all
2853 } 3024 }
2854 return new(zone) HBitwise(op, context, left, right); 3025 return new(zone) HBitwise(op, context, left, right);
2855 } 3026 }
2856 3027
2857 3028
2858 #define DEFINE_NEW_H_BITWISE_INSTR(HInstr, result) \ 3029 #define DEFINE_NEW_H_BITWISE_INSTR(HInstr, result) \
2859 HInstruction* HInstr::New##HInstr(Zone* zone, \ 3030 HInstruction* HInstr::New##HInstr(Zone* zone, \
2860 HValue* context, \ 3031 HValue* context, \
2861 HValue* left, \ 3032 HValue* left, \
2862 HValue* right) { \ 3033 HValue* right) { \
2863 if (left->IsConstant() && right->IsConstant()) { \ 3034 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \
2864 HConstant* c_left = HConstant::cast(left); \ 3035 HConstant* c_left = HConstant::cast(left); \
2865 HConstant* c_right = HConstant::cast(right); \ 3036 HConstant* c_right = HConstant::cast(right); \
2866 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ 3037 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \
2867 return H_CONSTANT_INT32(result); \ 3038 return H_CONSTANT_INT32(result); \
2868 } \ 3039 } \
2869 } \ 3040 } \
2870 return new(zone) HInstr(context, left, right); \ 3041 return new(zone) HInstr(context, left, right); \
2871 } 3042 }
2872 3043
2873 3044
2874 DEFINE_NEW_H_BITWISE_INSTR(HSar, 3045 DEFINE_NEW_H_BITWISE_INSTR(HSar,
2875 c_left->NumberValueAsInteger32() >> (c_right->NumberValueAsInteger32() & 0x1f)) 3046 c_left->NumberValueAsInteger32() >> (c_right->NumberValueAsInteger32() & 0x1f))
2876 DEFINE_NEW_H_BITWISE_INSTR(HShl, 3047 DEFINE_NEW_H_BITWISE_INSTR(HShl,
2877 c_left->NumberValueAsInteger32() << (c_right->NumberValueAsInteger32() & 0x1f)) 3048 c_left->NumberValueAsInteger32() << (c_right->NumberValueAsInteger32() & 0x1f))
2878 3049
2879 #undef DEFINE_NEW_H_BITWISE_INSTR 3050 #undef DEFINE_NEW_H_BITWISE_INSTR
2880 3051
2881 3052
2882 HInstruction* HShr::NewHShr(Zone* zone, 3053 HInstruction* HShr::NewHShr(Zone* zone,
2883 HValue* context, 3054 HValue* context,
2884 HValue* left, 3055 HValue* left,
2885 HValue* right) { 3056 HValue* right) {
2886 if (left->IsConstant() && right->IsConstant()) { 3057 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
2887 HConstant* c_left = HConstant::cast(left); 3058 HConstant* c_left = HConstant::cast(left);
2888 HConstant* c_right = HConstant::cast(right); 3059 HConstant* c_right = HConstant::cast(right);
2889 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { 3060 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) {
2890 int32_t left_val = c_left->NumberValueAsInteger32(); 3061 int32_t left_val = c_left->NumberValueAsInteger32();
2891 int32_t right_val = c_right->NumberValueAsInteger32() & 0x1f; 3062 int32_t right_val = c_right->NumberValueAsInteger32() & 0x1f;
2892 if ((right_val == 0) && (left_val < 0)) { 3063 if ((right_val == 0) && (left_val < 0)) {
2893 return H_CONSTANT_DOUBLE( 3064 return H_CONSTANT_DOUBLE(
2894 static_cast<double>(static_cast<uint32_t>(left_val))); 3065 static_cast<double>(static_cast<uint32_t>(left_val)));
2895 } 3066 }
2896 return H_CONSTANT_INT32(static_cast<uint32_t>(left_val) >> right_val); 3067 return H_CONSTANT_INT32(static_cast<uint32_t>(left_val) >> right_val);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3060 3231
3061 3232
3062 void HCheckFunction::Verify() { 3233 void HCheckFunction::Verify() {
3063 HInstruction::Verify(); 3234 HInstruction::Verify();
3064 ASSERT(HasNoUses()); 3235 ASSERT(HasNoUses());
3065 } 3236 }
3066 3237
3067 #endif 3238 #endif
3068 3239
3069 } } // namespace v8::internal 3240 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698