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

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

Issue 6049008: SSE2 truncating double-to-i. (Closed)
Patch Set: Update exponent limit description Created 9 years, 11 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
« no previous file with comments | « src/ia32/disasm-ia32.cc ('k') | src/ia32/lithium-ia32.h » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 __ add(Operand(esp), Immediate(kDoubleSize)); 2878 __ add(Operand(esp), Immediate(kDoubleSize));
2879 DeoptimizeIf(no_condition, instr->environment()); 2879 DeoptimizeIf(no_condition, instr->environment());
2880 __ bind(&convert); 2880 __ bind(&convert);
2881 // Do conversion, which cannot fail because we checked the exponent. 2881 // Do conversion, which cannot fail because we checked the exponent.
2882 __ fld_d(Operand(esp, 0)); 2882 __ fld_d(Operand(esp, 0));
2883 __ fisttp_d(Operand(esp, 0)); 2883 __ fisttp_d(Operand(esp, 0));
2884 __ mov(result_reg, Operand(esp, 0)); // Low word of answer is the result. 2884 __ mov(result_reg, Operand(esp, 0)); // Low word of answer is the result.
2885 __ add(Operand(esp), Immediate(kDoubleSize)); 2885 __ add(Operand(esp), Immediate(kDoubleSize));
2886 __ bind(&done); 2886 __ bind(&done);
2887 } else { 2887 } else {
2888 // This will bail out if the input was not in the int32 range (or, 2888 NearLabel done;
2889 // unfortunately, if the input was 0x80000000). 2889 Register temp_reg = ToRegister(instr->temporary());
2890 DeoptimizeIf(equal, instr->environment()); 2890 XMMRegister xmm_scratch = xmm0;
2891
2892 // If cvttsd2si succeeded, we're done. Otherwise, we attempt
2893 // manual conversion.
2894 __ j(not_equal, &done);
2895
2896 // Get high 32 bits of the input in temp_reg.
2897 __ pshufd(xmm_scratch, input_reg, 1);
2898 __ movd(Operand(temp_reg), xmm_scratch);
2899
2900 // Zero out the sign and the exponent in the input (by shifting
2901 // it to the left) and restore the implicit mantissa bit,
2902 // i.e. convert the input to unsigned int64 shifted left by
2903 // kExponentBits.
2904 ExternalReference minus_zero = ExternalReference::address_of_minus_zero();
2905 // Minus zero has the most significant bit set and the other
2906 // bits cleared.
2907 __ movdbl(xmm_scratch, Operand::StaticVariable(minus_zero));
2908 __ psllq(input_reg, HeapNumber::kExponentBits);
2909 __ por(input_reg, xmm_scratch);
2910
2911 // Save high 32 bits of the input in result_reg.
2912 __ mov(result_reg, temp_reg);
2913
2914 // Prepare negation mask in temp_reg.
2915 __ sar(temp_reg, kBitsPerInt - 1);
2916
2917 // Extract the exponent from result_reg and subtract adjusted
2918 // bias from it. The adjustment is selected in a way such that
2919 // when the difference is zero, the answer is in the low 32 bits
2920 // of the input, otherwise a shift has to be performed.
2921 __ shr(result_reg, HeapNumber::kExponentShift);
2922 __ and_(result_reg,
2923 HeapNumber::kExponentMask >> HeapNumber::kExponentShift);
2924 __ sub(Operand(result_reg),
2925 Immediate(HeapNumber::kExponentBias +
2926 HeapNumber::kExponentBits +
2927 HeapNumber::kMantissaBits));
2928 // Don't handle big (> kMantissaBits + kExponentBits == 63) or
2929 // special exponents.
2930 DeoptimizeIf(greater, instr->environment());
2931
2932 // Get the amount to shift the input right in xmm_scratch.
2933 __ neg(result_reg);
2934 __ movd(xmm_scratch, Operand(result_reg));
2935
2936 // Shift the input right and extract low 32 bits.
2937 __ psrlq(input_reg, xmm_scratch);
2938 __ movd(Operand(result_reg), input_reg);
2939
2940 // Use the prepared mask in temp_reg to negate the result if necessary.
2941 __ xor_(result_reg, Operand(temp_reg));
2942 __ sub(result_reg, Operand(temp_reg));
2943 __ bind(&done);
2891 } 2944 }
2892 } else { 2945 } else {
2893 NearLabel done; 2946 NearLabel done;
2894 __ cvttsd2si(result_reg, Operand(input_reg)); 2947 __ cvttsd2si(result_reg, Operand(input_reg));
2895 __ cvtsi2sd(xmm0, Operand(result_reg)); 2948 __ cvtsi2sd(xmm0, Operand(result_reg));
2896 __ ucomisd(xmm0, input_reg); 2949 __ ucomisd(xmm0, input_reg);
2897 DeoptimizeIf(not_equal, instr->environment()); 2950 DeoptimizeIf(not_equal, instr->environment());
2898 DeoptimizeIf(parity_even, instr->environment()); // NaN. 2951 DeoptimizeIf(parity_even, instr->environment()); // NaN.
2899 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 2952 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2900 // The integer converted back is equal to the original. We 2953 // The integer converted back is equal to the original. We
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3300 ASSERT(!environment->HasBeenRegistered()); 3353 ASSERT(!environment->HasBeenRegistered());
3301 RegisterEnvironmentForDeoptimization(environment); 3354 RegisterEnvironmentForDeoptimization(environment);
3302 ASSERT(osr_pc_offset_ == -1); 3355 ASSERT(osr_pc_offset_ == -1);
3303 osr_pc_offset_ = masm()->pc_offset(); 3356 osr_pc_offset_ = masm()->pc_offset();
3304 } 3357 }
3305 3358
3306 3359
3307 #undef __ 3360 #undef __
3308 3361
3309 } } // namespace v8::internal 3362 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/disasm-ia32.cc ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698