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 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3829 __ SmiUntag(ToRegister(input), SetCC); | 3829 __ SmiUntag(ToRegister(input), SetCC); |
3830 DeoptimizeIf(cs, instr->environment()); | 3830 DeoptimizeIf(cs, instr->environment()); |
3831 } else { | 3831 } else { |
3832 __ SmiUntag(ToRegister(input)); | 3832 __ SmiUntag(ToRegister(input)); |
3833 } | 3833 } |
3834 } | 3834 } |
3835 | 3835 |
3836 | 3836 |
3837 void LCodeGen::EmitNumberUntagD(Register input_reg, | 3837 void LCodeGen::EmitNumberUntagD(Register input_reg, |
3838 DoubleRegister result_reg, | 3838 DoubleRegister result_reg, |
| 3839 bool deoptimize_on_undefined, |
3839 LEnvironment* env) { | 3840 LEnvironment* env) { |
3840 Register scratch = scratch0(); | 3841 Register scratch = scratch0(); |
3841 SwVfpRegister flt_scratch = s0; | 3842 SwVfpRegister flt_scratch = s0; |
3842 ASSERT(!result_reg.is(d0)); | 3843 ASSERT(!result_reg.is(d0)); |
3843 | 3844 |
3844 Label load_smi, heap_number, done; | 3845 Label load_smi, heap_number, done; |
3845 | 3846 |
3846 // Smi check. | 3847 // Smi check. |
3847 __ tst(input_reg, Operand(kSmiTagMask)); | 3848 __ tst(input_reg, Operand(kSmiTagMask)); |
3848 __ b(eq, &load_smi); | 3849 __ b(eq, &load_smi); |
3849 | 3850 |
3850 // Heap number map check. | 3851 // Heap number map check. |
3851 __ ldr(scratch, FieldMemOperand(input_reg, HeapObject::kMapOffset)); | 3852 __ ldr(scratch, FieldMemOperand(input_reg, HeapObject::kMapOffset)); |
3852 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 3853 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
3853 __ cmp(scratch, Operand(ip)); | 3854 __ cmp(scratch, Operand(ip)); |
3854 __ b(eq, &heap_number); | 3855 if (deoptimize_on_undefined) { |
| 3856 DeoptimizeIf(ne, env); |
| 3857 } else { |
| 3858 Label heap_number; |
| 3859 __ b(eq, &heap_number); |
3855 | 3860 |
3856 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 3861 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
3857 __ cmp(input_reg, Operand(ip)); | 3862 __ cmp(input_reg, Operand(ip)); |
3858 DeoptimizeIf(ne, env); | 3863 DeoptimizeIf(ne, env); |
3859 | 3864 |
3860 // Convert undefined to NaN. | 3865 // Convert undefined to NaN. |
3861 __ LoadRoot(ip, Heap::kNanValueRootIndex); | 3866 __ LoadRoot(ip, Heap::kNanValueRootIndex); |
3862 __ sub(ip, ip, Operand(kHeapObjectTag)); | 3867 __ sub(ip, ip, Operand(kHeapObjectTag)); |
3863 __ vldr(result_reg, ip, HeapNumber::kValueOffset); | 3868 __ vldr(result_reg, ip, HeapNumber::kValueOffset); |
3864 __ jmp(&done); | 3869 __ jmp(&done); |
3865 | 3870 |
| 3871 __ bind(&heap_number); |
| 3872 } |
3866 // Heap number to double register conversion. | 3873 // Heap number to double register conversion. |
3867 __ bind(&heap_number); | |
3868 __ sub(ip, input_reg, Operand(kHeapObjectTag)); | 3874 __ sub(ip, input_reg, Operand(kHeapObjectTag)); |
3869 __ vldr(result_reg, ip, HeapNumber::kValueOffset); | 3875 __ vldr(result_reg, ip, HeapNumber::kValueOffset); |
3870 __ jmp(&done); | 3876 __ jmp(&done); |
3871 | 3877 |
3872 // Smi to double register conversion | 3878 // Smi to double register conversion |
3873 __ bind(&load_smi); | 3879 __ bind(&load_smi); |
3874 __ SmiUntag(input_reg); // Untag smi before converting to float. | 3880 __ SmiUntag(input_reg); // Untag smi before converting to float. |
3875 __ vmov(flt_scratch, input_reg); | 3881 __ vmov(flt_scratch, input_reg); |
3876 __ vcvt_f64_s32(result_reg, flt_scratch); | 3882 __ vcvt_f64_s32(result_reg, flt_scratch); |
3877 __ SmiTag(input_reg); // Retag smi. | 3883 __ SmiTag(input_reg); // Retag smi. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3991 | 3997 |
3992 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 3998 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
3993 LOperand* input = instr->InputAt(0); | 3999 LOperand* input = instr->InputAt(0); |
3994 ASSERT(input->IsRegister()); | 4000 ASSERT(input->IsRegister()); |
3995 LOperand* result = instr->result(); | 4001 LOperand* result = instr->result(); |
3996 ASSERT(result->IsDoubleRegister()); | 4002 ASSERT(result->IsDoubleRegister()); |
3997 | 4003 |
3998 Register input_reg = ToRegister(input); | 4004 Register input_reg = ToRegister(input); |
3999 DoubleRegister result_reg = ToDoubleRegister(result); | 4005 DoubleRegister result_reg = ToDoubleRegister(result); |
4000 | 4006 |
4001 EmitNumberUntagD(input_reg, result_reg, instr->environment()); | 4007 EmitNumberUntagD(input_reg, result_reg, |
| 4008 instr->hydrogen()->deoptimize_on_undefined(), |
| 4009 instr->environment()); |
4002 } | 4010 } |
4003 | 4011 |
4004 | 4012 |
4005 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 4013 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
4006 Register result_reg = ToRegister(instr->result()); | 4014 Register result_reg = ToRegister(instr->result()); |
4007 Register scratch1 = scratch0(); | 4015 Register scratch1 = scratch0(); |
4008 Register scratch2 = ToRegister(instr->TempAt(0)); | 4016 Register scratch2 = ToRegister(instr->TempAt(0)); |
4009 DwVfpRegister double_input = ToDoubleRegister(instr->InputAt(0)); | 4017 DwVfpRegister double_input = ToDoubleRegister(instr->InputAt(0)); |
4010 DwVfpRegister double_scratch = double_scratch0(); | 4018 DwVfpRegister double_scratch = double_scratch0(); |
4011 SwVfpRegister single_scratch = double_scratch0().low(); | 4019 SwVfpRegister single_scratch = double_scratch0().low(); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4571 ASSERT(osr_pc_offset_ == -1); | 4579 ASSERT(osr_pc_offset_ == -1); |
4572 osr_pc_offset_ = masm()->pc_offset(); | 4580 osr_pc_offset_ = masm()->pc_offset(); |
4573 } | 4581 } |
4574 | 4582 |
4575 | 4583 |
4576 | 4584 |
4577 | 4585 |
4578 #undef __ | 4586 #undef __ |
4579 | 4587 |
4580 } } // namespace v8::internal | 4588 } } // namespace v8::internal |
OLD | NEW |