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 5290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5301 } | 5301 } |
5302 | 5302 |
5303 | 5303 |
5304 void LCodeGen::EmitNumberUntagD(Register input_reg, | 5304 void LCodeGen::EmitNumberUntagD(Register input_reg, |
5305 Register temp_reg, | 5305 Register temp_reg, |
5306 XMMRegister result_reg, | 5306 XMMRegister result_reg, |
5307 bool can_convert_undefined_to_nan, | 5307 bool can_convert_undefined_to_nan, |
5308 bool deoptimize_on_minus_zero, | 5308 bool deoptimize_on_minus_zero, |
5309 LEnvironment* env, | 5309 LEnvironment* env, |
5310 NumberUntagDMode mode) { | 5310 NumberUntagDMode mode) { |
5311 Label load_smi, done; | 5311 Label convert, load_smi, done; |
5312 | 5312 |
5313 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) { | 5313 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) { |
5314 // Smi check. | 5314 // Smi check. |
5315 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); | 5315 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); |
5316 | 5316 |
5317 // Heap number map check. | 5317 // Heap number map check. |
5318 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 5318 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
5319 factory()->heap_number_map()); | 5319 factory()->heap_number_map()); |
5320 if (!can_convert_undefined_to_nan) { | 5320 if (can_convert_undefined_to_nan) { |
| 5321 __ j(not_equal, &convert, Label::kNear); |
| 5322 } else { |
5321 DeoptimizeIf(not_equal, env); | 5323 DeoptimizeIf(not_equal, env); |
5322 } else { | 5324 } |
5323 Label heap_number, convert; | |
5324 __ j(equal, &heap_number, Label::kNear); | |
5325 | 5325 |
5326 // Convert undefined (and hole) to NaN. | |
5327 __ cmp(input_reg, factory()->undefined_value()); | |
5328 DeoptimizeIf(not_equal, env); | |
5329 | |
5330 __ bind(&convert); | |
5331 ExternalReference nan = | |
5332 ExternalReference::address_of_canonical_non_hole_nan(); | |
5333 __ movdbl(result_reg, Operand::StaticVariable(nan)); | |
5334 __ jmp(&done, Label::kNear); | |
5335 | |
5336 __ bind(&heap_number); | |
5337 } | |
5338 // Heap number to XMM conversion. | 5326 // Heap number to XMM conversion. |
5339 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 5327 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 5328 |
5340 if (deoptimize_on_minus_zero) { | 5329 if (deoptimize_on_minus_zero) { |
5341 XMMRegister xmm_scratch = xmm0; | 5330 XMMRegister xmm_scratch = xmm0; |
5342 __ xorps(xmm_scratch, xmm_scratch); | 5331 __ xorps(xmm_scratch, xmm_scratch); |
5343 __ ucomisd(result_reg, xmm_scratch); | 5332 __ ucomisd(result_reg, xmm_scratch); |
5344 __ j(not_zero, &done, Label::kNear); | 5333 __ j(not_zero, &done, Label::kNear); |
5345 __ movmskpd(temp_reg, result_reg); | 5334 __ movmskpd(temp_reg, result_reg); |
5346 __ test_b(temp_reg, 1); | 5335 __ test_b(temp_reg, 1); |
5347 DeoptimizeIf(not_zero, env); | 5336 DeoptimizeIf(not_zero, env); |
5348 } | 5337 } |
5349 __ jmp(&done, Label::kNear); | 5338 __ jmp(&done, Label::kNear); |
| 5339 |
| 5340 if (can_convert_undefined_to_nan) { |
| 5341 __ bind(&convert); |
| 5342 |
| 5343 // Convert undefined (and hole) to NaN. |
| 5344 __ cmp(input_reg, factory()->undefined_value()); |
| 5345 DeoptimizeIf(not_equal, env); |
| 5346 |
| 5347 ExternalReference nan = |
| 5348 ExternalReference::address_of_canonical_non_hole_nan(); |
| 5349 __ movdbl(result_reg, Operand::StaticVariable(nan)); |
| 5350 __ jmp(&done, Label::kNear); |
| 5351 } |
5350 } else { | 5352 } else { |
5351 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); | 5353 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); |
5352 } | 5354 } |
5353 | 5355 |
5354 __ bind(&load_smi); | 5356 __ bind(&load_smi); |
5355 // Smi to XMM conversion. Clobbering a temp is faster than re-tagging the | 5357 // Smi to XMM conversion. Clobbering a temp is faster than re-tagging the |
5356 // input register since we avoid dependencies. | 5358 // input register since we avoid dependencies. |
5357 __ mov(temp_reg, input_reg); | 5359 __ mov(temp_reg, input_reg); |
5358 __ SmiUntag(temp_reg); // Untag smi before converting to float. | 5360 __ SmiUntag(temp_reg); // Untag smi before converting to float. |
5359 __ Cvtsi2sd(result_reg, Operand(temp_reg)); | 5361 __ Cvtsi2sd(result_reg, Operand(temp_reg)); |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6357 FixedArray::kHeaderSize - kPointerSize)); | 6359 FixedArray::kHeaderSize - kPointerSize)); |
6358 __ bind(&done); | 6360 __ bind(&done); |
6359 } | 6361 } |
6360 | 6362 |
6361 | 6363 |
6362 #undef __ | 6364 #undef __ |
6363 | 6365 |
6364 } } // namespace v8::internal | 6366 } } // namespace v8::internal |
6365 | 6367 |
6366 #endif // V8_TARGET_ARCH_IA32 | 6368 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |