OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace interpreter { | 9 namespace interpreter { |
10 | 10 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // previous bytecode stored the accumulator with the same register. | 269 // previous bytecode stored the accumulator with the same register. |
270 Output(Bytecode::kLdar, reg.ToOperand()); | 270 Output(Bytecode::kLdar, reg.ToOperand()); |
271 return *this; | 271 return *this; |
272 } | 272 } |
273 | 273 |
274 | 274 |
275 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( | 275 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( |
276 Register reg) { | 276 Register reg) { |
277 // TODO(oth): Avoid storing the accumulator in the register if the | 277 // TODO(oth): Avoid storing the accumulator in the register if the |
278 // previous bytecode loaded the accumulator with the same register. | 278 // previous bytecode loaded the accumulator with the same register. |
| 279 // |
| 280 // TODO(oth): If the previous bytecode is a MOV into this register, |
| 281 // the previous instruction can be removed. The logic for determining |
| 282 // these redundant MOVs appears complex. |
279 Output(Bytecode::kStar, reg.ToOperand()); | 283 Output(Bytecode::kStar, reg.ToOperand()); |
280 return *this; | 284 return *this; |
281 } | 285 } |
282 | 286 |
283 | 287 |
| 288 BytecodeArrayBuilder& BytecodeArrayBuilder::MoveRegister(Register from, |
| 289 Register to) { |
| 290 DCHECK(from != to); |
| 291 Output(Bytecode::kMov, from.ToOperand(), to.ToOperand()); |
| 292 return *this; |
| 293 } |
| 294 |
| 295 |
284 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( | 296 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( |
285 size_t name_index, int feedback_slot, LanguageMode language_mode) { | 297 size_t name_index, int feedback_slot, LanguageMode language_mode) { |
286 Bytecode bytecode = BytecodeForLoadGlobal(language_mode); | 298 Bytecode bytecode = BytecodeForLoadGlobal(language_mode); |
287 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { | 299 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
288 Output(bytecode, static_cast<uint8_t>(name_index), | 300 Output(bytecode, static_cast<uint8_t>(name_index), |
289 static_cast<uint8_t>(feedback_slot)); | 301 static_cast<uint8_t>(feedback_slot)); |
290 } else if (FitsInIdx16Operand(name_index) && | 302 } else if (FitsInIdx16Operand(name_index) && |
291 FitsInIdx16Operand(feedback_slot)) { | 303 FitsInIdx16Operand(feedback_slot)) { |
292 Output(BytecodeForWideOperands(bytecode), static_cast<uint16_t>(name_index), | 304 Output(BytecodeForWideOperands(bytecode), static_cast<uint16_t>(name_index), |
293 static_cast<uint16_t>(feedback_slot)); | 305 static_cast<uint16_t>(feedback_slot)); |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 DCHECK_GT(next_consecutive_count_, 0); | 1251 DCHECK_GT(next_consecutive_count_, 0); |
1240 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); | 1252 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); |
1241 allocated_.push_back(next_consecutive_register_); | 1253 allocated_.push_back(next_consecutive_register_); |
1242 next_consecutive_count_--; | 1254 next_consecutive_count_--; |
1243 return Register(next_consecutive_register_++); | 1255 return Register(next_consecutive_register_++); |
1244 } | 1256 } |
1245 | 1257 |
1246 } // namespace interpreter | 1258 } // namespace interpreter |
1247 } // namespace internal | 1259 } // namespace internal |
1248 } // namespace v8 | 1260 } // namespace v8 |
OLD | NEW |