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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 // previous bytecode stored the accumulator with the same register. | 275 // previous bytecode stored the accumulator with the same register. |
276 Output(Bytecode::kLdar, reg.ToOperand()); | 276 Output(Bytecode::kLdar, reg.ToOperand()); |
277 return *this; | 277 return *this; |
278 } | 278 } |
279 | 279 |
280 | 280 |
281 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( | 281 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( |
282 Register reg) { | 282 Register reg) { |
283 // TODO(oth): Avoid storing the accumulator in the register if the | 283 // TODO(oth): Avoid storing the accumulator in the register if the |
284 // previous bytecode loaded the accumulator with the same register. | 284 // previous bytecode loaded the accumulator with the same register. |
| 285 // |
| 286 // TODO(oth): If the previous bytecode is a MOV into this register, |
| 287 // the previous instruction can be removed. The logic for determining |
| 288 // these redundant MOVs appears complex. |
285 Output(Bytecode::kStar, reg.ToOperand()); | 289 Output(Bytecode::kStar, reg.ToOperand()); |
286 return *this; | 290 return *this; |
287 } | 291 } |
288 | 292 |
289 | 293 |
| 294 BytecodeArrayBuilder& BytecodeArrayBuilder::MoveRegister(Register from, |
| 295 Register to) { |
| 296 DCHECK(from != to); |
| 297 Output(Bytecode::kMov, from.ToOperand(), to.ToOperand()); |
| 298 return *this; |
| 299 } |
| 300 |
| 301 |
290 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( | 302 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( |
291 size_t name_index, int feedback_slot, LanguageMode language_mode, | 303 size_t name_index, int feedback_slot, LanguageMode language_mode, |
292 TypeofMode typeof_mode) { | 304 TypeofMode typeof_mode) { |
293 // TODO(rmcilroy): Potentially store language and typeof information in an | 305 // TODO(rmcilroy): Potentially store language and typeof information in an |
294 // operand rather than having extra bytecodes. | 306 // operand rather than having extra bytecodes. |
295 Bytecode bytecode = BytecodeForLoadGlobal(language_mode, typeof_mode); | 307 Bytecode bytecode = BytecodeForLoadGlobal(language_mode, typeof_mode); |
296 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { | 308 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
297 Output(bytecode, static_cast<uint8_t>(name_index), | 309 Output(bytecode, static_cast<uint8_t>(name_index), |
298 static_cast<uint8_t>(feedback_slot)); | 310 static_cast<uint8_t>(feedback_slot)); |
299 } else if (FitsInIdx16Operand(name_index) && | 311 } else if (FitsInIdx16Operand(name_index) && |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 DCHECK_GT(next_consecutive_count_, 0); | 1294 DCHECK_GT(next_consecutive_count_, 0); |
1283 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); | 1295 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); |
1284 allocated_.push_back(next_consecutive_register_); | 1296 allocated_.push_back(next_consecutive_register_); |
1285 next_consecutive_count_--; | 1297 next_consecutive_count_--; |
1286 return Register(next_consecutive_register_++); | 1298 return Register(next_consecutive_register_++); |
1287 } | 1299 } |
1288 | 1300 |
1289 } // namespace interpreter | 1301 } // namespace interpreter |
1290 } // namespace internal | 1302 } // namespace internal |
1291 } // namespace v8 | 1303 } // namespace v8 |
OLD | NEW |