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

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

Issue 1325983002: [Intepreter] Extend and move Register class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix bug in test. Created 5 years, 3 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
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-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 19 matching lines...) Expand all
30 30
31 31
32 void BytecodeArrayBuilder::set_parameter_count(int number_of_parameters) { 32 void BytecodeArrayBuilder::set_parameter_count(int number_of_parameters) {
33 parameter_count_ = number_of_parameters; 33 parameter_count_ = number_of_parameters;
34 } 34 }
35 35
36 36
37 int BytecodeArrayBuilder::parameter_count() const { return parameter_count_; } 37 int BytecodeArrayBuilder::parameter_count() const { return parameter_count_; }
38 38
39 39
40 Register BytecodeArrayBuilder::Parameter(int param_index) { 40 Register BytecodeArrayBuilder::Parameter(int parameter_index) {
41 DCHECK_GE(param_index, 0); 41 DCHECK_GE(parameter_index, 0);
42 DCHECK_LT(param_index, parameter_count_); 42 DCHECK_LT(parameter_index, parameter_count_);
43 return Register(kLastParamRegisterIndex - parameter_count_ + param_index + 1); 43 uint8_t parameter_operand =
44 Bytecodes::ParameterIndexToOperand(parameter_index, parameter_count_);
45 return Register::FromOperand(parameter_operand);
44 } 46 }
45 47
46 48
47 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { 49 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() {
48 DCHECK_EQ(bytecode_generated_, false); 50 DCHECK_EQ(bytecode_generated_, false);
49 DCHECK_GE(parameter_count_, 0); 51 DCHECK_GE(parameter_count_, 0);
50 DCHECK_GE(local_register_count_, 0); 52 DCHECK_GE(local_register_count_, 0);
51 int bytecode_size = static_cast<int>(bytecodes_.size()); 53 int bytecode_size = static_cast<int>(bytecodes_.size());
52 int register_count = local_register_count_ + temporary_register_count_; 54 int register_count = local_register_count_ + temporary_register_count_;
53 int frame_size = register_count * kPointerSize; 55 int frame_size = register_count * kPointerSize;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 uint8_t operand_value) const { 193 uint8_t operand_value) const {
192 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); 194 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index);
193 switch (operand_type) { 195 switch (operand_type) {
194 case OperandType::kNone: 196 case OperandType::kNone:
195 return false; 197 return false;
196 case OperandType::kImm8: 198 case OperandType::kImm8:
197 return true; 199 return true;
198 case OperandType::kIdx: 200 case OperandType::kIdx:
199 return operand_value < constants_.size(); 201 return operand_value < constants_.size();
200 case OperandType::kReg: { 202 case OperandType::kReg: {
201 int reg_index = Register::FromOperand(operand_value).index(); 203 int reg_index = Bytecodes::RegisterIndexFromOperand(operand_value);
202 return (reg_index >= 0 && reg_index < temporary_register_next_) || 204 if (reg_index >= 0) {
203 (reg_index <= kLastParamRegisterIndex && 205 return (reg_index >= 0 && reg_index < temporary_register_next_);
204 reg_index > kLastParamRegisterIndex - parameter_count_); 206 } else {
207 int parameter_index = Bytecodes::ParameterIndexFromOperand(
208 operand_value, parameter_count_);
209 return parameter_index >= 0 && parameter_index < parameter_count_;
210 }
205 } 211 }
206 } 212 }
207 UNREACHABLE(); 213 UNREACHABLE();
208 return false; 214 return false;
209 } 215 }
210 216
211 217
212 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint8_t operand0, 218 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint8_t operand0,
213 uint8_t operand1, uint8_t operand2) { 219 uint8_t operand1, uint8_t operand2) {
214 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3); 220 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 286
281 Register TemporaryRegisterScope::NewRegister() { 287 Register TemporaryRegisterScope::NewRegister() {
282 count_++; 288 count_++;
283 last_register_index_ = builder_->BorrowTemporaryRegister(); 289 last_register_index_ = builder_->BorrowTemporaryRegister();
284 return Register(last_register_index_); 290 return Register(last_register_index_);
285 } 291 }
286 292
287 } // namespace interpreter 293 } // namespace interpreter
288 } // namespace internal 294 } // namespace internal
289 } // namespace v8 295 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698