OLD | NEW |
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 |
(...skipping 3959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3970 __ cvttsd2si(output_reg, Operand(input_reg)); | 3970 __ cvttsd2si(output_reg, Operand(input_reg)); |
3971 // Overflow is signalled with minint. | 3971 // Overflow is signalled with minint. |
3972 __ cmp(output_reg, 0x80000000u); | 3972 __ cmp(output_reg, 0x80000000u); |
3973 DeoptimizeIf(equal, instr->environment()); | 3973 DeoptimizeIf(equal, instr->environment()); |
3974 __ jmp(&done, Label::kNear); | 3974 __ jmp(&done, Label::kNear); |
3975 | 3975 |
3976 // Non-zero negative reaches here. | 3976 // Non-zero negative reaches here. |
3977 __ bind(&negative_sign); | 3977 __ bind(&negative_sign); |
3978 // Truncate, then compare and compensate. | 3978 // Truncate, then compare and compensate. |
3979 __ cvttsd2si(output_reg, Operand(input_reg)); | 3979 __ cvttsd2si(output_reg, Operand(input_reg)); |
3980 __ cvtsi2sd(xmm_scratch, output_reg); | 3980 __ Cvtsi2sd(xmm_scratch, output_reg); |
3981 __ ucomisd(input_reg, xmm_scratch); | 3981 __ ucomisd(input_reg, xmm_scratch); |
3982 __ j(equal, &done, Label::kNear); | 3982 __ j(equal, &done, Label::kNear); |
3983 __ sub(output_reg, Immediate(1)); | 3983 __ sub(output_reg, Immediate(1)); |
3984 DeoptimizeIf(overflow, instr->environment()); | 3984 DeoptimizeIf(overflow, instr->environment()); |
3985 | 3985 |
3986 __ bind(&done); | 3986 __ bind(&done); |
3987 } | 3987 } |
3988 } | 3988 } |
3989 | 3989 |
3990 | 3990 |
(...skipping 29 matching lines...) Expand all Loading... |
4020 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then | 4020 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then |
4021 // compare and compensate. | 4021 // compare and compensate. |
4022 __ movsd(input_temp, input_reg); // Do not alter input_reg. | 4022 __ movsd(input_temp, input_reg); // Do not alter input_reg. |
4023 __ subsd(input_temp, xmm_scratch); | 4023 __ subsd(input_temp, xmm_scratch); |
4024 __ cvttsd2si(output_reg, Operand(input_temp)); | 4024 __ cvttsd2si(output_reg, Operand(input_temp)); |
4025 // Catch minint due to overflow, and to prevent overflow when compensating. | 4025 // Catch minint due to overflow, and to prevent overflow when compensating. |
4026 __ cmp(output_reg, 0x80000000u); | 4026 __ cmp(output_reg, 0x80000000u); |
4027 __ RecordComment("D2I conversion overflow"); | 4027 __ RecordComment("D2I conversion overflow"); |
4028 DeoptimizeIf(equal, instr->environment()); | 4028 DeoptimizeIf(equal, instr->environment()); |
4029 | 4029 |
4030 __ cvtsi2sd(xmm_scratch, output_reg); | 4030 __ Cvtsi2sd(xmm_scratch, output_reg); |
4031 __ ucomisd(xmm_scratch, input_temp); | 4031 __ ucomisd(xmm_scratch, input_temp); |
4032 __ j(equal, &done); | 4032 __ j(equal, &done); |
4033 __ sub(output_reg, Immediate(1)); | 4033 __ sub(output_reg, Immediate(1)); |
4034 // No overflow because we already ruled out minint. | 4034 // No overflow because we already ruled out minint. |
4035 __ jmp(&done); | 4035 __ jmp(&done); |
4036 | 4036 |
4037 __ bind(&round_to_zero); | 4037 __ bind(&round_to_zero); |
4038 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if | 4038 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if |
4039 // we can ignore the difference between a result of -0 and +0. | 4039 // we can ignore the difference between a result of -0 and +0. |
4040 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 4040 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4971 } | 4971 } |
4972 | 4972 |
4973 | 4973 |
4974 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { | 4974 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { |
4975 LOperand* input = instr->value(); | 4975 LOperand* input = instr->value(); |
4976 LOperand* output = instr->result(); | 4976 LOperand* output = instr->result(); |
4977 ASSERT(input->IsRegister() || input->IsStackSlot()); | 4977 ASSERT(input->IsRegister() || input->IsStackSlot()); |
4978 ASSERT(output->IsDoubleRegister()); | 4978 ASSERT(output->IsDoubleRegister()); |
4979 if (CpuFeatures::IsSupported(SSE2)) { | 4979 if (CpuFeatures::IsSupported(SSE2)) { |
4980 CpuFeatureScope scope(masm(), SSE2); | 4980 CpuFeatureScope scope(masm(), SSE2); |
4981 __ cvtsi2sd(ToDoubleRegister(output), ToOperand(input)); | 4981 __ Cvtsi2sd(ToDoubleRegister(output), ToOperand(input)); |
4982 } else if (input->IsRegister()) { | 4982 } else if (input->IsRegister()) { |
4983 Register input_reg = ToRegister(input); | 4983 Register input_reg = ToRegister(input); |
4984 __ push(input_reg); | 4984 __ push(input_reg); |
4985 X87Mov(ToX87Register(output), Operand(esp, 0), kX87IntOperand); | 4985 X87Mov(ToX87Register(output), Operand(esp, 0), kX87IntOperand); |
4986 __ pop(input_reg); | 4986 __ pop(input_reg); |
4987 } else { | 4987 } else { |
4988 X87Mov(ToX87Register(output), ToOperand(input), kX87IntOperand); | 4988 X87Mov(ToX87Register(output), ToOperand(input), kX87IntOperand); |
4989 } | 4989 } |
4990 } | 4990 } |
4991 | 4991 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5080 Label done; | 5080 Label done; |
5081 | 5081 |
5082 if (signedness == SIGNED_INT32) { | 5082 if (signedness == SIGNED_INT32) { |
5083 // There was overflow, so bits 30 and 31 of the original integer | 5083 // There was overflow, so bits 30 and 31 of the original integer |
5084 // disagree. Try to allocate a heap number in new space and store | 5084 // disagree. Try to allocate a heap number in new space and store |
5085 // the value in there. If that fails, call the runtime system. | 5085 // the value in there. If that fails, call the runtime system. |
5086 __ SmiUntag(reg); | 5086 __ SmiUntag(reg); |
5087 __ xor_(reg, 0x80000000); | 5087 __ xor_(reg, 0x80000000); |
5088 if (CpuFeatures::IsSupported(SSE2)) { | 5088 if (CpuFeatures::IsSupported(SSE2)) { |
5089 CpuFeatureScope feature_scope(masm(), SSE2); | 5089 CpuFeatureScope feature_scope(masm(), SSE2); |
5090 __ cvtsi2sd(xmm0, Operand(reg)); | 5090 __ Cvtsi2sd(xmm0, Operand(reg)); |
5091 } else { | 5091 } else { |
5092 __ push(reg); | 5092 __ push(reg); |
5093 __ fild_s(Operand(esp, 0)); | 5093 __ fild_s(Operand(esp, 0)); |
5094 __ pop(reg); | 5094 __ pop(reg); |
5095 } | 5095 } |
5096 } else { | 5096 } else { |
5097 if (CpuFeatures::IsSupported(SSE2)) { | 5097 if (CpuFeatures::IsSupported(SSE2)) { |
5098 CpuFeatureScope feature_scope(masm(), SSE2); | 5098 CpuFeatureScope feature_scope(masm(), SSE2); |
5099 __ LoadUint32(xmm0, reg, | 5099 __ LoadUint32(xmm0, reg, |
5100 ToDoubleRegister(LNumberTagU::cast(instr)->temp())); | 5100 ToDoubleRegister(LNumberTagU::cast(instr)->temp())); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5345 DeoptimizeIf(not_zero, env); | 5345 DeoptimizeIf(not_zero, env); |
5346 } | 5346 } |
5347 __ jmp(&done, Label::kNear); | 5347 __ jmp(&done, Label::kNear); |
5348 } else { | 5348 } else { |
5349 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); | 5349 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); |
5350 } | 5350 } |
5351 | 5351 |
5352 // Smi to XMM conversion | 5352 // Smi to XMM conversion |
5353 __ bind(&load_smi); | 5353 __ bind(&load_smi); |
5354 __ SmiUntag(input_reg); // Untag smi before converting to float. | 5354 __ SmiUntag(input_reg); // Untag smi before converting to float. |
5355 __ cvtsi2sd(result_reg, Operand(input_reg)); | 5355 __ Cvtsi2sd(result_reg, Operand(input_reg)); |
5356 __ SmiTag(input_reg); // Retag smi. | 5356 __ SmiTag(input_reg); // Retag smi. |
5357 __ bind(&done); | 5357 __ bind(&done); |
5358 } | 5358 } |
5359 | 5359 |
5360 | 5360 |
5361 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { | 5361 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
5362 Register input_reg = ToRegister(instr->value()); | 5362 Register input_reg = ToRegister(instr->value()); |
5363 | 5363 |
5364 | 5364 |
5365 if (instr->truncating()) { | 5365 if (instr->truncating()) { |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6354 FixedArray::kHeaderSize - kPointerSize)); | 6354 FixedArray::kHeaderSize - kPointerSize)); |
6355 __ bind(&done); | 6355 __ bind(&done); |
6356 } | 6356 } |
6357 | 6357 |
6358 | 6358 |
6359 #undef __ | 6359 #undef __ |
6360 | 6360 |
6361 } } // namespace v8::internal | 6361 } } // namespace v8::internal |
6362 | 6362 |
6363 #endif // V8_TARGET_ARCH_IA32 | 6363 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |