Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/interpreter/bytecode-array-iterator.cc

Issue 1651133002: [interpreter] Move temporary register allocator into own file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate review comments from rmcilroy. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-iterator.h" 5 #include "src/interpreter/bytecode-array-iterator.h"
6 6
7 #include "src/objects-inl.h" 7 #include "src/objects-inl.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 uint32_t operand = GetRawOperand(operand_index, operand_type); 82 uint32_t operand = GetRawOperand(operand_index, operand_type);
83 return static_cast<int>(operand); 83 return static_cast<int>(operand);
84 } 84 }
85 85
86 86
87 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { 87 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const {
88 OperandType operand_type = 88 OperandType operand_type =
89 Bytecodes::GetOperandType(current_bytecode(), operand_index); 89 Bytecodes::GetOperandType(current_bytecode(), operand_index);
90 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); 90 DCHECK(Bytecodes::IsRegisterOperandType(operand_type));
91 uint32_t operand = GetRawOperand(operand_index, operand_type); 91 uint32_t operand = GetRawOperand(operand_index, operand_type);
92 Register reg;
92 switch (Bytecodes::GetOperandSize(current_bytecode(), operand_index)) { 93 switch (Bytecodes::GetOperandSize(current_bytecode(), operand_index)) {
93 case OperandSize::kByte: 94 case OperandSize::kByte:
94 return Register::FromOperand(static_cast<uint8_t>(operand)); 95 reg = Register::FromOperand(static_cast<uint8_t>(operand));
96 break;
95 case OperandSize::kShort: 97 case OperandSize::kShort:
96 return Register::FromWideOperand(static_cast<uint16_t>(operand)); 98 reg = Register::FromWideOperand(static_cast<uint16_t>(operand));
99 break;
97 case OperandSize::kNone: 100 case OperandSize::kNone:
98 UNREACHABLE(); 101 UNREACHABLE();
102 reg = Register::invalid_value();
103 break;
99 } 104 }
100 return Register(); 105 DCHECK_GE(reg.index(),
106 Register::FromParameterIndex(0, bytecode_array()->parameter_count())
107 .index());
108 DCHECK(reg.index() < bytecode_array()->register_count() ||
109 (reg.index() == 0 &&
110 Bytecodes::IsMaybeRegisterOperandType(
111 Bytecodes::GetOperandType(current_bytecode(), operand_index))));
112 return reg;
101 } 113 }
102 114
103 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { 115 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const {
104 interpreter::OperandType operand_type = 116 interpreter::OperandType operand_type =
105 Bytecodes::GetOperandType(current_bytecode(), operand_index); 117 Bytecodes::GetOperandType(current_bytecode(), operand_index);
106 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); 118 DCHECK(Bytecodes::IsRegisterOperandType(operand_type));
107 switch (operand_type) { 119 switch (operand_type) {
108 case OperandType::kRegPair8: 120 case OperandType::kRegPair8:
109 case OperandType::kRegPair16: 121 case OperandType::kRegPair16:
110 case OperandType::kRegOutPair8: 122 case OperandType::kRegOutPair8:
111 case OperandType::kRegOutPair16: 123 case OperandType::kRegOutPair16:
112 return 2; 124 return 2;
113 case OperandType::kRegOutTriple8: 125 case OperandType::kRegOutTriple8:
114 case OperandType::kRegOutTriple16: 126 case OperandType::kRegOutTriple16:
115 return 3; 127 return 3;
116 default: { 128 default: {
117 if (operand_index + 1 != 129 if (operand_index + 1 !=
118 Bytecodes::NumberOfOperands(current_bytecode())) { 130 Bytecodes::NumberOfOperands(current_bytecode())) {
119 // TODO(oth): Ensure all bytecodes specify the full range of registers 131 // TODO(oth): Ensure all bytecodes specify the full range of registers
120 // with kRegCount (currently Call/CallJSRuntime are off by one due to 132 // with kRegCount (currently Call/CallJSRuntime are off by one due to
121 // reciever. 133 // reciever.
122 OperandType next_operand_type = 134 OperandType next_operand_type =
123 Bytecodes::GetOperandType(current_bytecode(), operand_index + 1); 135 Bytecodes::GetOperandType(current_bytecode(), operand_index + 1);
124 if (next_operand_type == OperandType::kRegCount8 || 136 if (Bytecodes::IsRegisterCountOperandType(next_operand_type)) {
125 next_operand_type == OperandType::kRegCount16) {
126 return GetCountOperand(operand_index + 1); 137 return GetCountOperand(operand_index + 1);
127 } 138 }
128 } 139 }
129 return 1; 140 return 1;
130 } 141 }
131 } 142 }
132 } 143 }
133 144
134 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( 145 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand(
135 int operand_index) const { 146 int operand_index) const {
(...skipping 14 matching lines...) Expand all
150 return current_offset() + smi->value(); 161 return current_offset() + smi->value();
151 } else { 162 } else {
152 UNREACHABLE(); 163 UNREACHABLE();
153 return kMinInt; 164 return kMinInt;
154 } 165 }
155 } 166 }
156 167
157 } // namespace interpreter 168 } // namespace interpreter
158 } // namespace internal 169 } // namespace internal
159 } // namespace v8 170 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698