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 3936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3947 __ cvttsd2si(output_reg, Operand(input_reg)); | 3947 __ cvttsd2si(output_reg, Operand(input_reg)); |
3948 // Overflow is signalled with minint. | 3948 // Overflow is signalled with minint. |
3949 __ cmp(output_reg, 0x80000000u); | 3949 __ cmp(output_reg, 0x80000000u); |
3950 DeoptimizeIf(equal, instr->environment()); | 3950 DeoptimizeIf(equal, instr->environment()); |
3951 __ jmp(&done, Label::kNear); | 3951 __ jmp(&done, Label::kNear); |
3952 | 3952 |
3953 // Non-zero negative reaches here. | 3953 // Non-zero negative reaches here. |
3954 __ bind(&negative_sign); | 3954 __ bind(&negative_sign); |
3955 // Truncate, then compare and compensate. | 3955 // Truncate, then compare and compensate. |
3956 __ cvttsd2si(output_reg, Operand(input_reg)); | 3956 __ cvttsd2si(output_reg, Operand(input_reg)); |
3957 __ cvtsi2sd(xmm_scratch, output_reg); | 3957 __ Cvtsi2sd(xmm_scratch, output_reg); |
3958 __ ucomisd(input_reg, xmm_scratch); | 3958 __ ucomisd(input_reg, xmm_scratch); |
3959 __ j(equal, &done, Label::kNear); | 3959 __ j(equal, &done, Label::kNear); |
3960 __ sub(output_reg, Immediate(1)); | 3960 __ sub(output_reg, Immediate(1)); |
3961 DeoptimizeIf(overflow, instr->environment()); | 3961 DeoptimizeIf(overflow, instr->environment()); |
3962 | 3962 |
3963 __ bind(&done); | 3963 __ bind(&done); |
3964 } | 3964 } |
3965 } | 3965 } |
3966 | 3966 |
3967 | 3967 |
(...skipping 29 matching lines...) Expand all Loading... |
3997 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then | 3997 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then |
3998 // compare and compensate. | 3998 // compare and compensate. |
3999 __ movsd(input_temp, input_reg); // Do not alter input_reg. | 3999 __ movsd(input_temp, input_reg); // Do not alter input_reg. |
4000 __ subsd(input_temp, xmm_scratch); | 4000 __ subsd(input_temp, xmm_scratch); |
4001 __ cvttsd2si(output_reg, Operand(input_temp)); | 4001 __ cvttsd2si(output_reg, Operand(input_temp)); |
4002 // Catch minint due to overflow, and to prevent overflow when compensating. | 4002 // Catch minint due to overflow, and to prevent overflow when compensating. |
4003 __ cmp(output_reg, 0x80000000u); | 4003 __ cmp(output_reg, 0x80000000u); |
4004 __ RecordComment("D2I conversion overflow"); | 4004 __ RecordComment("D2I conversion overflow"); |
4005 DeoptimizeIf(equal, instr->environment()); | 4005 DeoptimizeIf(equal, instr->environment()); |
4006 | 4006 |
4007 __ cvtsi2sd(xmm_scratch, output_reg); | 4007 __ Cvtsi2sd(xmm_scratch, output_reg); |
4008 __ ucomisd(xmm_scratch, input_temp); | 4008 __ ucomisd(xmm_scratch, input_temp); |
4009 __ j(equal, &done); | 4009 __ j(equal, &done); |
4010 __ sub(output_reg, Immediate(1)); | 4010 __ sub(output_reg, Immediate(1)); |
4011 // No overflow because we already ruled out minint. | 4011 // No overflow because we already ruled out minint. |
4012 __ jmp(&done); | 4012 __ jmp(&done); |
4013 | 4013 |
4014 __ bind(&round_to_zero); | 4014 __ bind(&round_to_zero); |
4015 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if | 4015 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if |
4016 // we can ignore the difference between a result of -0 and +0. | 4016 // we can ignore the difference between a result of -0 and +0. |
4017 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 4017 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4967 } | 4967 } |
4968 | 4968 |
4969 | 4969 |
4970 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { | 4970 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { |
4971 LOperand* input = instr->value(); | 4971 LOperand* input = instr->value(); |
4972 LOperand* output = instr->result(); | 4972 LOperand* output = instr->result(); |
4973 ASSERT(input->IsRegister() || input->IsStackSlot()); | 4973 ASSERT(input->IsRegister() || input->IsStackSlot()); |
4974 ASSERT(output->IsDoubleRegister()); | 4974 ASSERT(output->IsDoubleRegister()); |
4975 if (CpuFeatures::IsSupported(SSE2)) { | 4975 if (CpuFeatures::IsSupported(SSE2)) { |
4976 CpuFeatureScope scope(masm(), SSE2); | 4976 CpuFeatureScope scope(masm(), SSE2); |
4977 __ cvtsi2sd(ToDoubleRegister(output), ToOperand(input)); | 4977 __ Cvtsi2sd(ToDoubleRegister(output), ToOperand(input)); |
4978 } else if (input->IsRegister()) { | 4978 } else if (input->IsRegister()) { |
4979 Register input_reg = ToRegister(input); | 4979 Register input_reg = ToRegister(input); |
4980 __ push(input_reg); | 4980 __ push(input_reg); |
4981 X87Mov(ToX87Register(output), Operand(esp, 0), kX87IntOperand); | 4981 X87Mov(ToX87Register(output), Operand(esp, 0), kX87IntOperand); |
4982 __ pop(input_reg); | 4982 __ pop(input_reg); |
4983 } else { | 4983 } else { |
4984 X87Mov(ToX87Register(output), ToOperand(input), kX87IntOperand); | 4984 X87Mov(ToX87Register(output), ToOperand(input), kX87IntOperand); |
4985 } | 4985 } |
4986 } | 4986 } |
4987 | 4987 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5076 Label done; | 5076 Label done; |
5077 | 5077 |
5078 if (signedness == SIGNED_INT32) { | 5078 if (signedness == SIGNED_INT32) { |
5079 // There was overflow, so bits 30 and 31 of the original integer | 5079 // There was overflow, so bits 30 and 31 of the original integer |
5080 // disagree. Try to allocate a heap number in new space and store | 5080 // disagree. Try to allocate a heap number in new space and store |
5081 // the value in there. If that fails, call the runtime system. | 5081 // the value in there. If that fails, call the runtime system. |
5082 __ SmiUntag(reg); | 5082 __ SmiUntag(reg); |
5083 __ xor_(reg, 0x80000000); | 5083 __ xor_(reg, 0x80000000); |
5084 if (CpuFeatures::IsSupported(SSE2)) { | 5084 if (CpuFeatures::IsSupported(SSE2)) { |
5085 CpuFeatureScope feature_scope(masm(), SSE2); | 5085 CpuFeatureScope feature_scope(masm(), SSE2); |
5086 __ cvtsi2sd(xmm0, Operand(reg)); | 5086 __ Cvtsi2sd(xmm0, Operand(reg)); |
5087 } else { | 5087 } else { |
5088 __ push(reg); | 5088 __ push(reg); |
5089 __ fild_s(Operand(esp, 0)); | 5089 __ fild_s(Operand(esp, 0)); |
5090 __ pop(reg); | 5090 __ pop(reg); |
5091 } | 5091 } |
5092 } else { | 5092 } else { |
5093 if (CpuFeatures::IsSupported(SSE2)) { | 5093 if (CpuFeatures::IsSupported(SSE2)) { |
5094 CpuFeatureScope feature_scope(masm(), SSE2); | 5094 CpuFeatureScope feature_scope(masm(), SSE2); |
5095 __ LoadUint32(xmm0, reg, | 5095 __ LoadUint32(xmm0, reg, |
5096 ToDoubleRegister(LNumberTagU::cast(instr)->temp())); | 5096 ToDoubleRegister(LNumberTagU::cast(instr)->temp())); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5341 DeoptimizeIf(not_zero, env); | 5341 DeoptimizeIf(not_zero, env); |
5342 } | 5342 } |
5343 __ jmp(&done, Label::kNear); | 5343 __ jmp(&done, Label::kNear); |
5344 } else { | 5344 } else { |
5345 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); | 5345 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); |
5346 } | 5346 } |
5347 | 5347 |
5348 // Smi to XMM conversion | 5348 // Smi to XMM conversion |
5349 __ bind(&load_smi); | 5349 __ bind(&load_smi); |
5350 __ SmiUntag(input_reg); // Untag smi before converting to float. | 5350 __ SmiUntag(input_reg); // Untag smi before converting to float. |
5351 __ cvtsi2sd(result_reg, Operand(input_reg)); | 5351 __ Cvtsi2sd(result_reg, Operand(input_reg)); |
5352 __ SmiTag(input_reg); // Retag smi. | 5352 __ SmiTag(input_reg); // Retag smi. |
5353 __ bind(&done); | 5353 __ bind(&done); |
5354 } | 5354 } |
5355 | 5355 |
5356 | 5356 |
5357 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { | 5357 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
5358 Register input_reg = ToRegister(instr->value()); | 5358 Register input_reg = ToRegister(instr->value()); |
5359 | 5359 |
5360 | 5360 |
5361 if (instr->truncating()) { | 5361 if (instr->truncating()) { |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6350 FixedArray::kHeaderSize - kPointerSize)); | 6350 FixedArray::kHeaderSize - kPointerSize)); |
6351 __ bind(&done); | 6351 __ bind(&done); |
6352 } | 6352 } |
6353 | 6353 |
6354 | 6354 |
6355 #undef __ | 6355 #undef __ |
6356 | 6356 |
6357 } } // namespace v8::internal | 6357 } } // namespace v8::internal |
6358 | 6358 |
6359 #endif // V8_TARGET_ARCH_IA32 | 6359 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |