OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 double v = instr->value(); | 1055 double v = instr->value(); |
1056 // Use xor to produce +0.0 in a fast and compact way, but avoid to | 1056 // Use xor to produce +0.0 in a fast and compact way, but avoid to |
1057 // do so if the constant is -0.0. | 1057 // do so if the constant is -0.0. |
1058 if (BitCast<uint64_t, double>(v) == 0) { | 1058 if (BitCast<uint64_t, double>(v) == 0) { |
1059 __ xorpd(res, res); | 1059 __ xorpd(res, res); |
1060 } else { | 1060 } else { |
1061 Register temp = ToRegister(instr->TempAt(0)); | 1061 Register temp = ToRegister(instr->TempAt(0)); |
1062 uint64_t int_val = BitCast<uint64_t, double>(v); | 1062 uint64_t int_val = BitCast<uint64_t, double>(v); |
1063 int32_t lower = static_cast<int32_t>(int_val); | 1063 int32_t lower = static_cast<int32_t>(int_val); |
1064 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); | 1064 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); |
1065 if (isolate()->cpu_features()->IsSupported(SSE4_1)) { | 1065 if (CpuFeatures::IsSupported(SSE4_1)) { |
1066 CpuFeatures::Scope scope(SSE4_1); | 1066 CpuFeatures::Scope scope(SSE4_1); |
1067 if (lower != 0) { | 1067 if (lower != 0) { |
1068 __ Set(temp, Immediate(lower)); | 1068 __ Set(temp, Immediate(lower)); |
1069 __ movd(res, Operand(temp)); | 1069 __ movd(res, Operand(temp)); |
1070 __ Set(temp, Immediate(upper)); | 1070 __ Set(temp, Immediate(upper)); |
1071 __ pinsrd(res, Operand(temp), 1); | 1071 __ pinsrd(res, Operand(temp), 1); |
1072 } else { | 1072 } else { |
1073 __ xorpd(res, res); | 1073 __ xorpd(res, res); |
1074 __ Set(temp, Immediate(upper)); | 1074 __ Set(temp, Immediate(upper)); |
1075 __ pinsrd(res, Operand(temp), 1); | 1075 __ pinsrd(res, Operand(temp), 1); |
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3420 if (instr->truncating()) { | 3420 if (instr->truncating()) { |
3421 __ j(equal, &heap_number); | 3421 __ j(equal, &heap_number); |
3422 // Check for undefined. Undefined is converted to zero for truncating | 3422 // Check for undefined. Undefined is converted to zero for truncating |
3423 // conversions. | 3423 // conversions. |
3424 __ cmp(input_reg, factory()->undefined_value()); | 3424 __ cmp(input_reg, factory()->undefined_value()); |
3425 DeoptimizeIf(not_equal, instr->environment()); | 3425 DeoptimizeIf(not_equal, instr->environment()); |
3426 __ mov(input_reg, 0); | 3426 __ mov(input_reg, 0); |
3427 __ jmp(&done); | 3427 __ jmp(&done); |
3428 | 3428 |
3429 __ bind(&heap_number); | 3429 __ bind(&heap_number); |
3430 if (isolate()->cpu_features()->IsSupported(SSE3)) { | 3430 if (CpuFeatures::IsSupported(SSE3)) { |
3431 CpuFeatures::Scope scope(SSE3); | 3431 CpuFeatures::Scope scope(SSE3); |
3432 NearLabel convert; | 3432 NearLabel convert; |
3433 // Use more powerful conversion when sse3 is available. | 3433 // Use more powerful conversion when sse3 is available. |
3434 // Load x87 register with heap number. | 3434 // Load x87 register with heap number. |
3435 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); | 3435 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); |
3436 // Get exponent alone and check for too-big exponent. | 3436 // Get exponent alone and check for too-big exponent. |
3437 __ mov(input_reg, FieldOperand(input_reg, HeapNumber::kExponentOffset)); | 3437 __ mov(input_reg, FieldOperand(input_reg, HeapNumber::kExponentOffset)); |
3438 __ and_(input_reg, HeapNumber::kExponentMask); | 3438 __ and_(input_reg, HeapNumber::kExponentMask); |
3439 const uint32_t kTooBigExponent = | 3439 const uint32_t kTooBigExponent = |
3440 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift; | 3440 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3530 ASSERT(result->IsRegister()); | 3530 ASSERT(result->IsRegister()); |
3531 | 3531 |
3532 XMMRegister input_reg = ToDoubleRegister(input); | 3532 XMMRegister input_reg = ToDoubleRegister(input); |
3533 Register result_reg = ToRegister(result); | 3533 Register result_reg = ToRegister(result); |
3534 | 3534 |
3535 if (instr->truncating()) { | 3535 if (instr->truncating()) { |
3536 // Performs a truncating conversion of a floating point number as used by | 3536 // Performs a truncating conversion of a floating point number as used by |
3537 // the JS bitwise operations. | 3537 // the JS bitwise operations. |
3538 __ cvttsd2si(result_reg, Operand(input_reg)); | 3538 __ cvttsd2si(result_reg, Operand(input_reg)); |
3539 __ cmp(result_reg, 0x80000000u); | 3539 __ cmp(result_reg, 0x80000000u); |
3540 if (isolate()->cpu_features()->IsSupported(SSE3)) { | 3540 if (CpuFeatures::IsSupported(SSE3)) { |
3541 // This will deoptimize if the exponent of the input in out of range. | 3541 // This will deoptimize if the exponent of the input in out of range. |
3542 CpuFeatures::Scope scope(SSE3); | 3542 CpuFeatures::Scope scope(SSE3); |
3543 NearLabel convert, done; | 3543 NearLabel convert, done; |
3544 __ j(not_equal, &done); | 3544 __ j(not_equal, &done); |
3545 __ sub(Operand(esp), Immediate(kDoubleSize)); | 3545 __ sub(Operand(esp), Immediate(kDoubleSize)); |
3546 __ movdbl(Operand(esp, 0), input_reg); | 3546 __ movdbl(Operand(esp, 0), input_reg); |
3547 // Get exponent alone and check for too-big exponent. | 3547 // Get exponent alone and check for too-big exponent. |
3548 __ mov(result_reg, Operand(esp, sizeof(int32_t))); | 3548 __ mov(result_reg, Operand(esp, sizeof(int32_t))); |
3549 __ and_(result_reg, HeapNumber::kExponentMask); | 3549 __ and_(result_reg, HeapNumber::kExponentMask); |
3550 const uint32_t kTooBigExponent = | 3550 const uint32_t kTooBigExponent = |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4103 ASSERT(osr_pc_offset_ == -1); | 4103 ASSERT(osr_pc_offset_ == -1); |
4104 osr_pc_offset_ = masm()->pc_offset(); | 4104 osr_pc_offset_ = masm()->pc_offset(); |
4105 } | 4105 } |
4106 | 4106 |
4107 | 4107 |
4108 #undef __ | 4108 #undef __ |
4109 | 4109 |
4110 } } // namespace v8::internal | 4110 } } // namespace v8::internal |
4111 | 4111 |
4112 #endif // V8_TARGET_ARCH_IA32 | 4112 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |