OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/crankshaft/ia32/lithium-codegen-ia32.h" | 7 #include "src/crankshaft/ia32/lithium-codegen-ia32.h" |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 3159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3170 DeferredMathAbsTaggedHeapNumber* deferred = | 3170 DeferredMathAbsTaggedHeapNumber* deferred = |
3171 new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr); | 3171 new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr); |
3172 Register input_reg = ToRegister(instr->value()); | 3172 Register input_reg = ToRegister(instr->value()); |
3173 // Smi check. | 3173 // Smi check. |
3174 __ JumpIfNotSmi(input_reg, deferred->entry()); | 3174 __ JumpIfNotSmi(input_reg, deferred->entry()); |
3175 EmitIntegerMathAbs(instr); | 3175 EmitIntegerMathAbs(instr); |
3176 __ bind(deferred->exit()); | 3176 __ bind(deferred->exit()); |
3177 } | 3177 } |
3178 } | 3178 } |
3179 | 3179 |
| 3180 void LCodeGen::DoMathFloorD(LMathFloorD* instr) { |
| 3181 XMMRegister output_reg = ToDoubleRegister(instr->result()); |
| 3182 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
| 3183 CpuFeatureScope scope(masm(), SSE4_1); |
| 3184 __ roundsd(output_reg, input_reg, kRoundDown); |
| 3185 } |
3180 | 3186 |
3181 void LCodeGen::DoMathFloor(LMathFloor* instr) { | 3187 void LCodeGen::DoMathFloorI(LMathFloorI* instr) { |
3182 XMMRegister xmm_scratch = double_scratch0(); | 3188 XMMRegister xmm_scratch = double_scratch0(); |
3183 Register output_reg = ToRegister(instr->result()); | 3189 Register output_reg = ToRegister(instr->result()); |
3184 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 3190 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
3185 | 3191 |
3186 if (CpuFeatures::IsSupported(SSE4_1)) { | 3192 if (CpuFeatures::IsSupported(SSE4_1)) { |
3187 CpuFeatureScope scope(masm(), SSE4_1); | 3193 CpuFeatureScope scope(masm(), SSE4_1); |
3188 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3194 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3189 // Deoptimize on negative zero. | 3195 // Deoptimize on negative zero. |
3190 Label non_zero; | 3196 Label non_zero; |
3191 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. | 3197 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 __ Cvtsi2sd(xmm_scratch, output_reg); | 3241 __ Cvtsi2sd(xmm_scratch, output_reg); |
3236 __ ucomisd(input_reg, xmm_scratch); | 3242 __ ucomisd(input_reg, xmm_scratch); |
3237 __ j(equal, &done, Label::kNear); | 3243 __ j(equal, &done, Label::kNear); |
3238 __ sub(output_reg, Immediate(1)); | 3244 __ sub(output_reg, Immediate(1)); |
3239 DeoptimizeIf(overflow, instr, Deoptimizer::kOverflow); | 3245 DeoptimizeIf(overflow, instr, Deoptimizer::kOverflow); |
3240 | 3246 |
3241 __ bind(&done); | 3247 __ bind(&done); |
3242 } | 3248 } |
3243 } | 3249 } |
3244 | 3250 |
| 3251 void LCodeGen::DoMathRoundD(LMathRoundD* instr) { |
| 3252 XMMRegister xmm_scratch = double_scratch0(); |
| 3253 XMMRegister output_reg = ToDoubleRegister(instr->result()); |
| 3254 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
| 3255 CpuFeatureScope scope(masm(), SSE4_1); |
| 3256 Label done; |
| 3257 __ roundsd(output_reg, input_reg, kRoundUp); |
| 3258 __ Move(xmm_scratch, -0.5); |
| 3259 __ addsd(xmm_scratch, output_reg); |
| 3260 __ ucomisd(xmm_scratch, input_reg); |
| 3261 __ j(below_equal, &done, Label::kNear); |
| 3262 __ Move(xmm_scratch, 1.0); |
| 3263 __ subsd(output_reg, xmm_scratch); |
| 3264 __ bind(&done); |
| 3265 } |
3245 | 3266 |
3246 void LCodeGen::DoMathRound(LMathRound* instr) { | 3267 void LCodeGen::DoMathRoundI(LMathRoundI* instr) { |
3247 Register output_reg = ToRegister(instr->result()); | 3268 Register output_reg = ToRegister(instr->result()); |
3248 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 3269 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
3249 XMMRegister xmm_scratch = double_scratch0(); | 3270 XMMRegister xmm_scratch = double_scratch0(); |
3250 XMMRegister input_temp = ToDoubleRegister(instr->temp()); | 3271 XMMRegister input_temp = ToDoubleRegister(instr->temp()); |
3251 ExternalReference one_half = ExternalReference::address_of_one_half(); | 3272 ExternalReference one_half = ExternalReference::address_of_one_half(); |
3252 ExternalReference minus_one_half = | 3273 ExternalReference minus_one_half = |
3253 ExternalReference::address_of_minus_one_half(); | 3274 ExternalReference::address_of_minus_one_half(); |
3254 | 3275 |
3255 Label done, round_to_zero, below_one_half, do_not_compensate; | 3276 Label done, round_to_zero, below_one_half, do_not_compensate; |
3256 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; | 3277 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5266 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); | 5287 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); |
5267 } | 5288 } |
5268 | 5289 |
5269 | 5290 |
5270 #undef __ | 5291 #undef __ |
5271 | 5292 |
5272 } // namespace internal | 5293 } // namespace internal |
5273 } // namespace v8 | 5294 } // namespace v8 |
5274 | 5295 |
5275 #endif // V8_TARGET_ARCH_IA32 | 5296 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |