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 4089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4100 ToDoubleRegister(temp)); | 4100 ToDoubleRegister(temp)); |
4101 } | 4101 } |
4102 | 4102 |
4103 | 4103 |
4104 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { | 4104 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
4105 class DeferredNumberTagI: public LDeferredCode { | 4105 class DeferredNumberTagI: public LDeferredCode { |
4106 public: | 4106 public: |
4107 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) | 4107 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) |
4108 : LDeferredCode(codegen), instr_(instr) { } | 4108 : LDeferredCode(codegen), instr_(instr) { } |
4109 virtual void Generate() { | 4109 virtual void Generate() { |
4110 codegen()->DoDeferredNumberTagI(instr_, SIGNED_INT32); | 4110 codegen()->DoDeferredNumberTagI(instr_, |
| 4111 instr_->InputAt(0), |
| 4112 SIGNED_INT32); |
4111 } | 4113 } |
4112 virtual LInstruction* instr() { return instr_; } | 4114 virtual LInstruction* instr() { return instr_; } |
4113 private: | 4115 private: |
4114 LNumberTagI* instr_; | 4116 LNumberTagI* instr_; |
4115 }; | 4117 }; |
4116 | 4118 |
4117 LOperand* input = instr->InputAt(0); | 4119 LOperand* input = instr->InputAt(0); |
4118 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 4120 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
4119 Register reg = ToRegister(input); | 4121 Register reg = ToRegister(input); |
4120 | 4122 |
4121 DeferredNumberTagI* deferred = new(zone()) DeferredNumberTagI(this, instr); | 4123 DeferredNumberTagI* deferred = new(zone()) DeferredNumberTagI(this, instr); |
4122 __ SmiTag(reg); | 4124 __ SmiTag(reg); |
4123 __ j(overflow, deferred->entry()); | 4125 __ j(overflow, deferred->entry()); |
4124 __ bind(deferred->exit()); | 4126 __ bind(deferred->exit()); |
4125 } | 4127 } |
4126 | 4128 |
4127 | 4129 |
4128 void LCodeGen::DoNumberTagU(LNumberTagU* instr) { | 4130 void LCodeGen::DoNumberTagU(LNumberTagU* instr) { |
4129 class DeferredNumberTagU: public LDeferredCode { | 4131 class DeferredNumberTagU: public LDeferredCode { |
4130 public: | 4132 public: |
4131 DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr) | 4133 DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr) |
4132 : LDeferredCode(codegen), instr_(instr) { } | 4134 : LDeferredCode(codegen), instr_(instr) { } |
4133 virtual void Generate() { | 4135 virtual void Generate() { |
4134 codegen()->DoDeferredNumberTagI(instr_, UNSIGNED_INT32); | 4136 codegen()->DoDeferredNumberTagI(instr_, |
| 4137 instr_->InputAt(0), |
| 4138 UNSIGNED_INT32); |
4135 } | 4139 } |
4136 virtual LInstruction* instr() { return instr_; } | 4140 virtual LInstruction* instr() { return instr_; } |
4137 private: | 4141 private: |
4138 LNumberTagU* instr_; | 4142 LNumberTagU* instr_; |
4139 }; | 4143 }; |
4140 | 4144 |
4141 LOperand* input = instr->InputAt(0); | 4145 LOperand* input = instr->InputAt(0); |
4142 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 4146 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
4143 Register reg = ToRegister(input); | 4147 Register reg = ToRegister(input); |
4144 | 4148 |
4145 DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr); | 4149 DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr); |
4146 __ cmp(reg, Immediate(Smi::kMaxValue)); | 4150 __ cmp(reg, Immediate(Smi::kMaxValue)); |
4147 __ j(above, deferred->entry()); | 4151 __ j(above, deferred->entry()); |
4148 __ SmiTag(reg); | 4152 __ SmiTag(reg); |
4149 __ bind(deferred->exit()); | 4153 __ bind(deferred->exit()); |
4150 } | 4154 } |
4151 | 4155 |
4152 | 4156 |
4153 void LCodeGen::DoDeferredNumberTagI(LInstruction* instr, | 4157 void LCodeGen::DoDeferredNumberTagI(LInstruction* instr, |
| 4158 LOperand* value, |
4154 IntegerSignedness signedness) { | 4159 IntegerSignedness signedness) { |
4155 Label slow; | 4160 Label slow; |
4156 Register reg = ToRegister(instr->InputAt(0)); | 4161 Register reg = ToRegister(value); |
4157 Register tmp = reg.is(eax) ? ecx : eax; | 4162 Register tmp = reg.is(eax) ? ecx : eax; |
4158 | 4163 |
4159 // Preserve the value of all registers. | 4164 // Preserve the value of all registers. |
4160 PushSafepointRegistersScope scope(this); | 4165 PushSafepointRegistersScope scope(this); |
4161 | 4166 |
4162 Label done; | 4167 Label done; |
4163 | 4168 |
4164 if (signedness == SIGNED_INT32) { | 4169 if (signedness == SIGNED_INT32) { |
4165 // There was overflow, so bits 30 and 31 of the original integer | 4170 // There was overflow, so bits 30 and 31 of the original integer |
4166 // disagree. Try to allocate a heap number in new space and store | 4171 // disagree. Try to allocate a heap number in new space and store |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5499 FixedArray::kHeaderSize - kPointerSize)); | 5504 FixedArray::kHeaderSize - kPointerSize)); |
5500 __ bind(&done); | 5505 __ bind(&done); |
5501 } | 5506 } |
5502 | 5507 |
5503 | 5508 |
5504 #undef __ | 5509 #undef __ |
5505 | 5510 |
5506 } } // namespace v8::internal | 5511 } } // namespace v8::internal |
5507 | 5512 |
5508 #endif // V8_TARGET_ARCH_IA32 | 5513 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |