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 3596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3607 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 3607 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
3608 ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)); | 3608 ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)); |
3609 __ SmiTag(ToRegister(input)); | 3609 __ SmiTag(ToRegister(input)); |
3610 } | 3610 } |
3611 | 3611 |
3612 | 3612 |
3613 void LCodeGen::DoSmiUntag(LSmiUntag* instr) { | 3613 void LCodeGen::DoSmiUntag(LSmiUntag* instr) { |
3614 LOperand* input = instr->InputAt(0); | 3614 LOperand* input = instr->InputAt(0); |
3615 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 3615 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
3616 if (instr->needs_check()) { | 3616 if (instr->needs_check()) { |
3617 __ tst(ToRegister(input), Operand(kSmiTagMask)); | 3617 ASSERT(kHeapObjectTag == 1); |
3618 DeoptimizeIf(ne, instr->environment()); | 3618 // If the input is a HeapObject, SmiUntag will set the carry flag. |
| 3619 __ SmiUntag(ToRegister(input), SetCC); |
| 3620 DeoptimizeIf(cs, instr->environment()); |
| 3621 } else { |
| 3622 __ SmiUntag(ToRegister(input)); |
3619 } | 3623 } |
3620 __ SmiUntag(ToRegister(input)); | |
3621 } | 3624 } |
3622 | 3625 |
3623 | 3626 |
3624 void LCodeGen::EmitNumberUntagD(Register input_reg, | 3627 void LCodeGen::EmitNumberUntagD(Register input_reg, |
3625 DoubleRegister result_reg, | 3628 DoubleRegister result_reg, |
3626 LEnvironment* env) { | 3629 LEnvironment* env) { |
3627 Register scratch = scratch0(); | 3630 Register scratch = scratch0(); |
3628 SwVfpRegister flt_scratch = s0; | 3631 SwVfpRegister flt_scratch = s0; |
3629 ASSERT(!result_reg.is(d0)); | 3632 ASSERT(!result_reg.is(d0)); |
3630 | 3633 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3681 Register scratch1 = scratch0(); | 3684 Register scratch1 = scratch0(); |
3682 Register scratch2 = ToRegister(instr->TempAt(0)); | 3685 Register scratch2 = ToRegister(instr->TempAt(0)); |
3683 DwVfpRegister double_scratch = double_scratch0(); | 3686 DwVfpRegister double_scratch = double_scratch0(); |
3684 SwVfpRegister single_scratch = double_scratch.low(); | 3687 SwVfpRegister single_scratch = double_scratch.low(); |
3685 | 3688 |
3686 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); | 3689 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); |
3687 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); | 3690 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); |
3688 | 3691 |
3689 Label done; | 3692 Label done; |
3690 | 3693 |
| 3694 // The input was optimistically untagged; revert it. |
| 3695 // The carry flag is set when we reach this deferred code as we just executed |
| 3696 // SmiUntag(heap_object, SetCC) |
| 3697 ASSERT(kHeapObjectTag == 1); |
| 3698 __ adc(input_reg, input_reg, Operand(input_reg)); |
| 3699 |
3691 // Heap number map check. | 3700 // Heap number map check. |
3692 __ ldr(scratch1, FieldMemOperand(input_reg, HeapObject::kMapOffset)); | 3701 __ ldr(scratch1, FieldMemOperand(input_reg, HeapObject::kMapOffset)); |
3693 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 3702 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
3694 __ cmp(scratch1, Operand(ip)); | 3703 __ cmp(scratch1, Operand(ip)); |
3695 | 3704 |
3696 if (instr->truncating()) { | 3705 if (instr->truncating()) { |
3697 Register scratch3 = ToRegister(instr->TempAt(1)); | 3706 Register scratch3 = ToRegister(instr->TempAt(1)); |
3698 DwVfpRegister double_scratch2 = ToDoubleRegister(instr->TempAt(2)); | 3707 DwVfpRegister double_scratch2 = ToDoubleRegister(instr->TempAt(2)); |
3699 ASSERT(!scratch3.is(input_reg) && | 3708 ASSERT(!scratch3.is(input_reg) && |
3700 !scratch3.is(scratch1) && | 3709 !scratch3.is(scratch1) && |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3753 | 3762 |
3754 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 3763 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
3755 LOperand* input = instr->InputAt(0); | 3764 LOperand* input = instr->InputAt(0); |
3756 ASSERT(input->IsRegister()); | 3765 ASSERT(input->IsRegister()); |
3757 ASSERT(input->Equals(instr->result())); | 3766 ASSERT(input->Equals(instr->result())); |
3758 | 3767 |
3759 Register input_reg = ToRegister(input); | 3768 Register input_reg = ToRegister(input); |
3760 | 3769 |
3761 DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr); | 3770 DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr); |
3762 | 3771 |
3763 // Smi check. | 3772 // Optimistically untag the input. |
3764 __ tst(input_reg, Operand(kSmiTagMask)); | 3773 // If the input is a HeapObject, SmiUntag will set the carry flag. |
3765 __ b(ne, deferred->entry()); | 3774 __ SmiUntag(input_reg, SetCC); |
3766 | 3775 // Branch to deferred code if the input was tagged. |
3767 // Smi to int32 conversion | 3776 // The deferred code will take care of restoring the tag. |
3768 __ SmiUntag(input_reg); // Untag smi. | 3777 __ b(cs, deferred->entry()); |
3769 | |
3770 __ bind(deferred->exit()); | 3778 __ bind(deferred->exit()); |
3771 } | 3779 } |
3772 | 3780 |
3773 | 3781 |
3774 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 3782 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
3775 LOperand* input = instr->InputAt(0); | 3783 LOperand* input = instr->InputAt(0); |
3776 ASSERT(input->IsRegister()); | 3784 ASSERT(input->IsRegister()); |
3777 LOperand* result = instr->result(); | 3785 LOperand* result = instr->result(); |
3778 ASSERT(result->IsDoubleRegister()); | 3786 ASSERT(result->IsDoubleRegister()); |
3779 | 3787 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4261 ASSERT(!environment->HasBeenRegistered()); | 4269 ASSERT(!environment->HasBeenRegistered()); |
4262 RegisterEnvironmentForDeoptimization(environment); | 4270 RegisterEnvironmentForDeoptimization(environment); |
4263 ASSERT(osr_pc_offset_ == -1); | 4271 ASSERT(osr_pc_offset_ == -1); |
4264 osr_pc_offset_ = masm()->pc_offset(); | 4272 osr_pc_offset_ = masm()->pc_offset(); |
4265 } | 4273 } |
4266 | 4274 |
4267 | 4275 |
4268 #undef __ | 4276 #undef __ |
4269 | 4277 |
4270 } } // namespace v8::internal | 4278 } } // namespace v8::internal |
OLD | NEW |