OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/crankshaft/x64/lithium-codegen-x64.h" | 7 #include "src/crankshaft/x64/lithium-codegen-x64.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 3366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3377 DeferredMathAbsTaggedHeapNumber* deferred = | 3377 DeferredMathAbsTaggedHeapNumber* deferred = |
3378 new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr); | 3378 new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr); |
3379 Register input_reg = ToRegister(instr->value()); | 3379 Register input_reg = ToRegister(instr->value()); |
3380 // Smi check. | 3380 // Smi check. |
3381 __ JumpIfNotSmi(input_reg, deferred->entry()); | 3381 __ JumpIfNotSmi(input_reg, deferred->entry()); |
3382 EmitSmiMathAbs(instr); | 3382 EmitSmiMathAbs(instr); |
3383 __ bind(deferred->exit()); | 3383 __ bind(deferred->exit()); |
3384 } | 3384 } |
3385 } | 3385 } |
3386 | 3386 |
| 3387 void LCodeGen::DoMathFloorD(LMathFloorD* instr) { |
| 3388 XMMRegister output_reg = ToDoubleRegister(instr->result()); |
| 3389 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
| 3390 CpuFeatureScope scope(masm(), SSE4_1); |
| 3391 __ Roundsd(output_reg, input_reg, kRoundDown); |
| 3392 } |
3387 | 3393 |
3388 void LCodeGen::DoMathFloor(LMathFloor* instr) { | 3394 void LCodeGen::DoMathFloorI(LMathFloorI* instr) { |
3389 XMMRegister xmm_scratch = double_scratch0(); | 3395 XMMRegister xmm_scratch = double_scratch0(); |
3390 Register output_reg = ToRegister(instr->result()); | 3396 Register output_reg = ToRegister(instr->result()); |
3391 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 3397 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
3392 | 3398 |
3393 if (CpuFeatures::IsSupported(SSE4_1)) { | 3399 if (CpuFeatures::IsSupported(SSE4_1)) { |
3394 CpuFeatureScope scope(masm(), SSE4_1); | 3400 CpuFeatureScope scope(masm(), SSE4_1); |
3395 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3401 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3396 // Deoptimize if minus zero. | 3402 // Deoptimize if minus zero. |
3397 __ Movq(output_reg, input_reg); | 3403 __ Movq(output_reg, input_reg); |
3398 __ subq(output_reg, Immediate(1)); | 3404 __ subq(output_reg, Immediate(1)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3436 __ Cvtlsi2sd(xmm_scratch, output_reg); | 3442 __ Cvtlsi2sd(xmm_scratch, output_reg); |
3437 __ Ucomisd(input_reg, xmm_scratch); | 3443 __ Ucomisd(input_reg, xmm_scratch); |
3438 __ j(equal, &done, Label::kNear); | 3444 __ j(equal, &done, Label::kNear); |
3439 __ subl(output_reg, Immediate(1)); | 3445 __ subl(output_reg, Immediate(1)); |
3440 DeoptimizeIf(overflow, instr, Deoptimizer::kOverflow); | 3446 DeoptimizeIf(overflow, instr, Deoptimizer::kOverflow); |
3441 | 3447 |
3442 __ bind(&done); | 3448 __ bind(&done); |
3443 } | 3449 } |
3444 } | 3450 } |
3445 | 3451 |
| 3452 void LCodeGen::DoMathRoundD(LMathRoundD* instr) { |
| 3453 XMMRegister xmm_scratch = double_scratch0(); |
| 3454 XMMRegister output_reg = ToDoubleRegister(instr->result()); |
| 3455 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
| 3456 CpuFeatureScope scope(masm(), SSE4_1); |
| 3457 Label done; |
| 3458 __ Roundsd(output_reg, input_reg, kRoundUp); |
| 3459 __ Move(xmm_scratch, -0.5); |
| 3460 __ Addsd(xmm_scratch, output_reg); |
| 3461 __ Ucomisd(xmm_scratch, input_reg); |
| 3462 __ j(below_equal, &done, Label::kNear); |
| 3463 __ Move(xmm_scratch, 1.0); |
| 3464 __ Subsd(output_reg, xmm_scratch); |
| 3465 __ bind(&done); |
| 3466 } |
3446 | 3467 |
3447 void LCodeGen::DoMathRound(LMathRound* instr) { | 3468 void LCodeGen::DoMathRoundI(LMathRoundI* instr) { |
3448 const XMMRegister xmm_scratch = double_scratch0(); | 3469 const XMMRegister xmm_scratch = double_scratch0(); |
3449 Register output_reg = ToRegister(instr->result()); | 3470 Register output_reg = ToRegister(instr->result()); |
3450 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 3471 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
3451 XMMRegister input_temp = ToDoubleRegister(instr->temp()); | 3472 XMMRegister input_temp = ToDoubleRegister(instr->temp()); |
3452 static int64_t one_half = V8_INT64_C(0x3FE0000000000000); // 0.5 | 3473 static int64_t one_half = V8_INT64_C(0x3FE0000000000000); // 0.5 |
3453 static int64_t minus_one_half = V8_INT64_C(0xBFE0000000000000); // -0.5 | 3474 static int64_t minus_one_half = V8_INT64_C(0xBFE0000000000000); // -0.5 |
3454 | 3475 |
3455 Label done, round_to_zero, below_one_half; | 3476 Label done, round_to_zero, below_one_half; |
3456 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; | 3477 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
3457 __ movq(kScratchRegister, one_half); | 3478 __ movq(kScratchRegister, one_half); |
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5578 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), context); | 5599 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), context); |
5579 } | 5600 } |
5580 | 5601 |
5581 | 5602 |
5582 #undef __ | 5603 #undef __ |
5583 | 5604 |
5584 } // namespace internal | 5605 } // namespace internal |
5585 } // namespace v8 | 5606 } // namespace v8 |
5586 | 5607 |
5587 #endif // V8_TARGET_ARCH_X64 | 5608 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |