| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 | 102 |
| 103 void PositionInstr::Compile(MacroAssembler* masm) { | 103 void PositionInstr::Compile(MacroAssembler* masm) { |
| 104 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) { | 104 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) { |
| 105 __ RecordStatementPosition(pos_); | 105 __ RecordStatementPosition(pos_); |
| 106 __ RecordPosition(pos_); | 106 __ RecordPosition(pos_); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 void MoveInstr::Compile(MacroAssembler* masm) { |
| 112 location()->Move(masm, value()); |
| 113 } |
| 114 |
| 115 |
| 111 void BinaryOpInstr::Compile(MacroAssembler* masm) { | 116 void BinaryOpInstr::Compile(MacroAssembler* masm) { |
| 112 // The right-hand value should not be on the stack---if it is a | 117 // The right-hand value should not be on the stack---if it is a |
| 113 // compiler-generated temporary it is in the accumulator. | 118 // compiler-generated temporary it is in the accumulator. |
| 114 ASSERT(!val1_->is_on_stack()); | 119 ASSERT(!value1()->is_on_stack()); |
| 115 | 120 |
| 116 Comment cmnt(masm, "[ BinaryOpInstr"); | 121 Comment cmnt(masm, "[ BinaryOpInstr"); |
| 117 // We can overwrite one of the operands if it is a temporary. | 122 // We can overwrite one of the operands if it is a temporary. |
| 118 OverwriteMode mode = NO_OVERWRITE; | 123 OverwriteMode mode = NO_OVERWRITE; |
| 119 if (val0_->is_temporary()) { | 124 if (value0()->is_temporary()) { |
| 120 mode = OVERWRITE_LEFT; | 125 mode = OVERWRITE_LEFT; |
| 121 } else if (val1_->is_temporary()) { | 126 } else if (value1()->is_temporary()) { |
| 122 mode = OVERWRITE_RIGHT; | 127 mode = OVERWRITE_RIGHT; |
| 123 } | 128 } |
| 124 | 129 |
| 125 // Move left to r1 and right to r0. | 130 // Move left to r1 and right to r0. |
| 126 val0_->Get(masm, r1); | 131 value0()->Get(masm, r1); |
| 127 val1_->Get(masm, r0); | 132 value1()->Get(masm, r0); |
| 128 GenericBinaryOpStub stub(op_, mode); | 133 GenericBinaryOpStub stub(op(), mode); |
| 129 __ CallStub(&stub); | 134 __ CallStub(&stub); |
| 130 loc_->Set(masm, r0); | 135 location()->Set(masm, r0); |
| 131 } | 136 } |
| 132 | 137 |
| 133 | 138 |
| 134 void ReturnInstr::Compile(MacroAssembler* masm) { | 139 void ReturnInstr::Compile(MacroAssembler* masm) { |
| 135 // The location should be 'Effect'. As a side effect, move the value to | 140 // The location should be 'Effect'. As a side effect, move the value to |
| 136 // the accumulator. | 141 // the accumulator. |
| 137 Comment cmnt(masm, "[ ReturnInstr"); | 142 Comment cmnt(masm, "[ ReturnInstr"); |
| 138 value_->Get(masm, r0); | 143 value_->Get(masm, r0); |
| 139 } | 144 } |
| 140 | 145 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 160 const int kOffset = JavaScriptFrameConstants::kLocal0Offset; | 165 const int kOffset = JavaScriptFrameConstants::kLocal0Offset; |
| 161 return MemOperand(fp, kOffset - loc->index() * kPointerSize); | 166 return MemOperand(fp, kOffset - loc->index() * kPointerSize); |
| 162 } | 167 } |
| 163 default: | 168 default: |
| 164 UNREACHABLE(); | 169 UNREACHABLE(); |
| 165 return MemOperand(r0); | 170 return MemOperand(r0); |
| 166 } | 171 } |
| 167 } | 172 } |
| 168 | 173 |
| 169 | 174 |
| 175 void Constant::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) { |
| 176 __ mov(ip, Operand(handle_)); |
| 177 __ str(ip, ToMemOperand(loc)); |
| 178 } |
| 179 |
| 180 |
| 170 void SlotLocation::Get(MacroAssembler* masm, Register reg) { | 181 void SlotLocation::Get(MacroAssembler* masm, Register reg) { |
| 171 __ ldr(reg, ToMemOperand(this)); | 182 __ ldr(reg, ToMemOperand(this)); |
| 172 } | 183 } |
| 173 | 184 |
| 174 | 185 |
| 175 void SlotLocation::Set(MacroAssembler* masm, Register reg) { | 186 void SlotLocation::Set(MacroAssembler* masm, Register reg) { |
| 176 __ str(reg, ToMemOperand(this)); | 187 __ str(reg, ToMemOperand(this)); |
| 177 } | 188 } |
| 178 | 189 |
| 179 | 190 |
| 180 void SlotLocation::Push(MacroAssembler* masm) { | 191 void SlotLocation::Push(MacroAssembler* masm) { |
| 181 __ ldr(ip, ToMemOperand(this)); | 192 __ ldr(ip, ToMemOperand(this)); |
| 182 __ push(ip); // Push will not destroy ip. | 193 __ push(ip); // Push will not destroy ip. |
| 183 } | 194 } |
| 184 | 195 |
| 185 | 196 |
| 197 void SlotLocation::Move(MacroAssembler* masm, Value* value) { |
| 198 // Double dispatch. |
| 199 value->MoveToSlot(masm, this); |
| 200 } |
| 201 |
| 202 |
| 203 void SlotLocation::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) { |
| 204 __ ldr(ip, ToMemOperand(this)); |
| 205 __ str(ip, ToMemOperand(loc)); |
| 206 } |
| 207 |
| 208 |
| 186 void TempLocation::Get(MacroAssembler* masm, Register reg) { | 209 void TempLocation::Get(MacroAssembler* masm, Register reg) { |
| 187 switch (where_) { | 210 switch (where_) { |
| 188 case ACCUMULATOR: | 211 case ACCUMULATOR: |
| 189 if (!reg.is(r0)) __ mov(reg, r0); | 212 if (!reg.is(r0)) __ mov(reg, r0); |
| 190 break; | 213 break; |
| 191 case STACK: | 214 case STACK: |
| 192 __ pop(reg); | 215 __ pop(reg); |
| 193 break; | 216 break; |
| 194 case NOWHERE: | 217 case NOT_ALLOCATED: |
| 195 UNREACHABLE(); | 218 UNREACHABLE(); |
| 196 break; | |
| 197 } | 219 } |
| 198 } | 220 } |
| 199 | 221 |
| 200 | 222 |
| 201 void TempLocation::Set(MacroAssembler* masm, Register reg) { | 223 void TempLocation::Set(MacroAssembler* masm, Register reg) { |
| 202 switch (where_) { | 224 switch (where_) { |
| 203 case ACCUMULATOR: | 225 case ACCUMULATOR: |
| 204 if (!reg.is(r0)) __ mov(r0, reg); | 226 if (!reg.is(r0)) __ mov(r0, reg); |
| 205 break; | 227 break; |
| 206 case STACK: | 228 case STACK: |
| 207 __ push(reg); | 229 __ push(reg); |
| 208 break; | 230 break; |
| 209 case NOWHERE: | 231 case NOT_ALLOCATED: |
| 210 UNREACHABLE(); | 232 UNREACHABLE(); |
| 211 break; | |
| 212 } | 233 } |
| 213 } | 234 } |
| 214 | 235 |
| 215 | 236 |
| 216 void TempLocation::Push(MacroAssembler* masm) { | 237 void TempLocation::Push(MacroAssembler* masm) { |
| 217 switch (where_) { | 238 switch (where_) { |
| 218 case ACCUMULATOR: | 239 case ACCUMULATOR: |
| 219 __ push(r0); | 240 __ push(r0); |
| 220 break; | 241 break; |
| 221 case STACK: | 242 case STACK: |
| 222 case NOWHERE: | 243 case NOT_ALLOCATED: |
| 223 UNREACHABLE(); | 244 UNREACHABLE(); |
| 224 break; | |
| 225 } | 245 } |
| 226 } | 246 } |
| 227 | 247 |
| 228 | 248 |
| 249 void TempLocation::Move(MacroAssembler* masm, Value* value) { |
| 250 switch (where_) { |
| 251 case ACCUMULATOR: |
| 252 value->Get(masm, r0); |
| 253 case STACK: |
| 254 value->Push(masm); |
| 255 break; |
| 256 case NOT_ALLOCATED: |
| 257 UNREACHABLE(); |
| 258 } |
| 259 } |
| 260 |
| 261 |
| 262 void TempLocation::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) { |
| 263 switch (where_) { |
| 264 case ACCUMULATOR: |
| 265 __ str(r0, ToMemOperand(loc)); |
| 266 case STACK: |
| 267 __ pop(ip); |
| 268 __ str(ip, ToMemOperand(loc)); |
| 269 break; |
| 270 case NOT_ALLOCATED: |
| 271 UNREACHABLE(); |
| 272 } |
| 273 } |
| 274 |
| 229 #undef __ | 275 #undef __ |
| 230 | 276 |
| 231 } } // namespace v8::internal | 277 } } // namespace v8::internal |
| OLD | NEW |