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 5066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5077 DeoptimizeIf(not_zero, instr->environment()); | 5077 DeoptimizeIf(not_zero, instr->environment()); |
5078 } else { | 5078 } else { |
5079 __ AssertSmi(result); | 5079 __ AssertSmi(result); |
5080 } | 5080 } |
5081 __ SmiUntag(result); | 5081 __ SmiUntag(result); |
5082 } | 5082 } |
5083 | 5083 |
5084 | 5084 |
5085 void LCodeGen::EmitNumberUntagDNoSSE2(Register input_reg, | 5085 void LCodeGen::EmitNumberUntagDNoSSE2(Register input_reg, |
5086 Register temp_reg, | 5086 Register temp_reg, |
5087 bool deoptimize_on_undefined, | 5087 bool allow_undefined_as_nan, |
5088 bool deoptimize_on_minus_zero, | 5088 bool deoptimize_on_minus_zero, |
5089 LEnvironment* env, | 5089 LEnvironment* env, |
5090 NumberUntagDMode mode) { | 5090 NumberUntagDMode mode) { |
5091 Label load_smi, done; | 5091 Label load_smi, done; |
5092 | 5092 |
5093 STATIC_ASSERT(NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE > | 5093 STATIC_ASSERT(NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE > |
5094 NUMBER_CANDIDATE_IS_ANY_TAGGED); | 5094 NUMBER_CANDIDATE_IS_ANY_TAGGED); |
5095 if (mode >= NUMBER_CANDIDATE_IS_ANY_TAGGED) { | 5095 if (mode >= NUMBER_CANDIDATE_IS_ANY_TAGGED) { |
5096 // Smi check. | 5096 // Smi check. |
5097 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); | 5097 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); |
5098 | 5098 |
5099 // Heap number map check. | 5099 // Heap number map check. |
5100 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 5100 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
5101 factory()->heap_number_map()); | 5101 factory()->heap_number_map()); |
5102 if (deoptimize_on_undefined) { | 5102 if (!allow_undefined_as_nan) { |
5103 DeoptimizeIf(not_equal, env); | 5103 DeoptimizeIf(not_equal, env); |
5104 } else { | 5104 } else { |
5105 Label heap_number, convert; | 5105 Label heap_number, convert; |
5106 __ j(equal, &heap_number, Label::kNear); | 5106 __ j(equal, &heap_number, Label::kNear); |
5107 | 5107 |
5108 // Convert undefined (or hole) to NaN. | 5108 // Convert undefined (or hole) to NaN. |
5109 __ cmp(input_reg, factory()->undefined_value()); | 5109 __ cmp(input_reg, factory()->undefined_value()); |
5110 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE) { | 5110 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE) { |
5111 __ j(equal, &convert, Label::kNear); | 5111 __ j(equal, &convert, Label::kNear); |
5112 __ cmp(input_reg, factory()->the_hole_value()); | 5112 __ cmp(input_reg, factory()->the_hole_value()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5149 __ fild_s(Operand(esp, 0)); | 5149 __ fild_s(Operand(esp, 0)); |
5150 __ pop(input_reg); | 5150 __ pop(input_reg); |
5151 __ SmiTag(input_reg); // Retag smi. | 5151 __ SmiTag(input_reg); // Retag smi. |
5152 __ bind(&done); | 5152 __ bind(&done); |
5153 } | 5153 } |
5154 | 5154 |
5155 | 5155 |
5156 void LCodeGen::EmitNumberUntagD(Register input_reg, | 5156 void LCodeGen::EmitNumberUntagD(Register input_reg, |
5157 Register temp_reg, | 5157 Register temp_reg, |
5158 XMMRegister result_reg, | 5158 XMMRegister result_reg, |
5159 bool deoptimize_on_undefined, | 5159 bool allow_undefined_as_nan, |
5160 bool deoptimize_on_minus_zero, | 5160 bool deoptimize_on_minus_zero, |
5161 LEnvironment* env, | 5161 LEnvironment* env, |
5162 NumberUntagDMode mode) { | 5162 NumberUntagDMode mode) { |
5163 Label load_smi, done; | 5163 Label load_smi, done; |
5164 | 5164 |
5165 STATIC_ASSERT(NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE > | 5165 STATIC_ASSERT(NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE > |
5166 NUMBER_CANDIDATE_IS_ANY_TAGGED); | 5166 NUMBER_CANDIDATE_IS_ANY_TAGGED); |
5167 if (mode >= NUMBER_CANDIDATE_IS_ANY_TAGGED) { | 5167 if (mode >= NUMBER_CANDIDATE_IS_ANY_TAGGED) { |
5168 // Smi check. | 5168 // Smi check. |
5169 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); | 5169 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); |
5170 | 5170 |
5171 // Heap number map check. | 5171 // Heap number map check. |
5172 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 5172 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
5173 factory()->heap_number_map()); | 5173 factory()->heap_number_map()); |
5174 if (deoptimize_on_undefined) { | 5174 if (!allow_undefined_as_nan) { |
5175 DeoptimizeIf(not_equal, env); | 5175 DeoptimizeIf(not_equal, env); |
5176 } else { | 5176 } else { |
5177 Label heap_number, convert; | 5177 Label heap_number, convert; |
5178 __ j(equal, &heap_number, Label::kNear); | 5178 __ j(equal, &heap_number, Label::kNear); |
5179 | 5179 |
5180 // Convert undefined (and hole) to NaN. | 5180 // Convert undefined (and hole) to NaN. |
5181 __ cmp(input_reg, factory()->undefined_value()); | 5181 __ cmp(input_reg, factory()->undefined_value()); |
5182 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE) { | 5182 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE) { |
5183 __ j(equal, &convert, Label::kNear); | 5183 __ j(equal, &convert, Label::kNear); |
5184 __ cmp(input_reg, factory()->the_hole_value()); | 5184 __ cmp(input_reg, factory()->the_hole_value()); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5512 mode = NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE; | 5512 mode = NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE; |
5513 } | 5513 } |
5514 } | 5514 } |
5515 | 5515 |
5516 if (CpuFeatures::IsSupported(SSE2)) { | 5516 if (CpuFeatures::IsSupported(SSE2)) { |
5517 CpuFeatureScope scope(masm(), SSE2); | 5517 CpuFeatureScope scope(masm(), SSE2); |
5518 XMMRegister result_reg = ToDoubleRegister(result); | 5518 XMMRegister result_reg = ToDoubleRegister(result); |
5519 EmitNumberUntagD(input_reg, | 5519 EmitNumberUntagD(input_reg, |
5520 temp_reg, | 5520 temp_reg, |
5521 result_reg, | 5521 result_reg, |
5522 instr->hydrogen()->deoptimize_on_undefined(), | 5522 instr->hydrogen()->allow_undefined_as_nan(), |
5523 deoptimize_on_minus_zero, | 5523 deoptimize_on_minus_zero, |
5524 instr->environment(), | 5524 instr->environment(), |
5525 mode); | 5525 mode); |
5526 } else { | 5526 } else { |
5527 EmitNumberUntagDNoSSE2(input_reg, | 5527 EmitNumberUntagDNoSSE2(input_reg, |
5528 temp_reg, | 5528 temp_reg, |
5529 instr->hydrogen()->deoptimize_on_undefined(), | 5529 instr->hydrogen()->allow_undefined_as_nan(), |
5530 deoptimize_on_minus_zero, | 5530 deoptimize_on_minus_zero, |
5531 instr->environment(), | 5531 instr->environment(), |
5532 mode); | 5532 mode); |
5533 CurrentInstructionReturnsX87Result(); | 5533 CurrentInstructionReturnsX87Result(); |
5534 } | 5534 } |
5535 } | 5535 } |
5536 | 5536 |
5537 | 5537 |
5538 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 5538 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
5539 LOperand* input = instr->value(); | 5539 LOperand* input = instr->value(); |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6585 FixedArray::kHeaderSize - kPointerSize)); | 6585 FixedArray::kHeaderSize - kPointerSize)); |
6586 __ bind(&done); | 6586 __ bind(&done); |
6587 } | 6587 } |
6588 | 6588 |
6589 | 6589 |
6590 #undef __ | 6590 #undef __ |
6591 | 6591 |
6592 } } // namespace v8::internal | 6592 } } // namespace v8::internal |
6593 | 6593 |
6594 #endif // V8_TARGET_ARCH_IA32 | 6594 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |