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 3599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3610 if (instr->needs_check()) { | 3610 if (instr->needs_check()) { |
3611 __ test(ToRegister(input), Immediate(kSmiTagMask)); | 3611 __ test(ToRegister(input), Immediate(kSmiTagMask)); |
3612 DeoptimizeIf(not_zero, instr->environment()); | 3612 DeoptimizeIf(not_zero, instr->environment()); |
3613 } | 3613 } |
3614 __ SmiUntag(ToRegister(input)); | 3614 __ SmiUntag(ToRegister(input)); |
3615 } | 3615 } |
3616 | 3616 |
3617 | 3617 |
3618 void LCodeGen::EmitNumberUntagD(Register input_reg, | 3618 void LCodeGen::EmitNumberUntagD(Register input_reg, |
3619 XMMRegister result_reg, | 3619 XMMRegister result_reg, |
| 3620 bool deoptimize_on_undefined, |
3620 LEnvironment* env) { | 3621 LEnvironment* env) { |
3621 Label load_smi, heap_number, done; | 3622 Label load_smi, done; |
3622 | 3623 |
3623 // Smi check. | 3624 // Smi check. |
3624 __ test(input_reg, Immediate(kSmiTagMask)); | 3625 __ test(input_reg, Immediate(kSmiTagMask)); |
3625 __ j(zero, &load_smi, Label::kNear); | 3626 __ j(zero, &load_smi, Label::kNear); |
3626 | 3627 |
3627 // Heap number map check. | 3628 // Heap number map check. |
3628 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 3629 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
3629 factory()->heap_number_map()); | 3630 factory()->heap_number_map()); |
3630 __ j(equal, &heap_number, Label::kNear); | 3631 if (deoptimize_on_undefined) { |
| 3632 DeoptimizeIf(not_equal, env); |
| 3633 } else { |
| 3634 Label heap_number; |
| 3635 __ j(equal, &heap_number, Label::kNear); |
3631 | 3636 |
3632 __ cmp(input_reg, factory()->undefined_value()); | 3637 __ cmp(input_reg, factory()->undefined_value()); |
3633 DeoptimizeIf(not_equal, env); | 3638 DeoptimizeIf(not_equal, env); |
3634 | 3639 |
3635 // Convert undefined to NaN. | 3640 // Convert undefined to NaN. |
3636 ExternalReference nan = ExternalReference::address_of_nan(); | 3641 ExternalReference nan = ExternalReference::address_of_nan(); |
3637 __ movdbl(result_reg, Operand::StaticVariable(nan)); | 3642 __ movdbl(result_reg, Operand::StaticVariable(nan)); |
3638 __ jmp(&done, Label::kNear); | 3643 __ jmp(&done, Label::kNear); |
3639 | 3644 |
| 3645 __ bind(&heap_number); |
| 3646 } |
3640 // Heap number to XMM conversion. | 3647 // Heap number to XMM conversion. |
3641 __ bind(&heap_number); | |
3642 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 3648 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
3643 __ jmp(&done, Label::kNear); | 3649 __ jmp(&done, Label::kNear); |
3644 | 3650 |
3645 // Smi to XMM conversion | 3651 // Smi to XMM conversion |
3646 __ bind(&load_smi); | 3652 __ bind(&load_smi); |
3647 __ SmiUntag(input_reg); // Untag smi before converting to float. | 3653 __ SmiUntag(input_reg); // Untag smi before converting to float. |
3648 __ cvtsi2sd(result_reg, Operand(input_reg)); | 3654 __ cvtsi2sd(result_reg, Operand(input_reg)); |
3649 __ SmiTag(input_reg); // Retag smi. | 3655 __ SmiTag(input_reg); // Retag smi. |
3650 __ bind(&done); | 3656 __ bind(&done); |
3651 } | 3657 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3763 | 3769 |
3764 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 3770 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
3765 LOperand* input = instr->InputAt(0); | 3771 LOperand* input = instr->InputAt(0); |
3766 ASSERT(input->IsRegister()); | 3772 ASSERT(input->IsRegister()); |
3767 LOperand* result = instr->result(); | 3773 LOperand* result = instr->result(); |
3768 ASSERT(result->IsDoubleRegister()); | 3774 ASSERT(result->IsDoubleRegister()); |
3769 | 3775 |
3770 Register input_reg = ToRegister(input); | 3776 Register input_reg = ToRegister(input); |
3771 XMMRegister result_reg = ToDoubleRegister(result); | 3777 XMMRegister result_reg = ToDoubleRegister(result); |
3772 | 3778 |
3773 EmitNumberUntagD(input_reg, result_reg, instr->environment()); | 3779 EmitNumberUntagD(input_reg, result_reg, |
| 3780 instr->hydrogen()->deoptimize_on_undefined(), |
| 3781 instr->environment()); |
3774 } | 3782 } |
3775 | 3783 |
3776 | 3784 |
3777 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 3785 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
3778 LOperand* input = instr->InputAt(0); | 3786 LOperand* input = instr->InputAt(0); |
3779 ASSERT(input->IsDoubleRegister()); | 3787 ASSERT(input->IsDoubleRegister()); |
3780 LOperand* result = instr->result(); | 3788 LOperand* result = instr->result(); |
3781 ASSERT(result->IsRegister()); | 3789 ASSERT(result->IsRegister()); |
3782 | 3790 |
3783 XMMRegister input_reg = ToDoubleRegister(input); | 3791 XMMRegister input_reg = ToDoubleRegister(input); |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4444 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 4452 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
4445 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4453 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4446 } | 4454 } |
4447 | 4455 |
4448 | 4456 |
4449 #undef __ | 4457 #undef __ |
4450 | 4458 |
4451 } } // namespace v8::internal | 4459 } } // namespace v8::internal |
4452 | 4460 |
4453 #endif // V8_TARGET_ARCH_IA32 | 4461 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |