| 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/bytecodes.h" | 5 #include "src/interpreter/bytecodes.h" |
| 6 | 6 |
| 7 #include "src/frames.h" | 7 #include "src/frames.h" |
| 8 #include "src/interpreter/bytecode-traits.h" | 8 #include "src/interpreter/bytecode-traits.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 | 213 |
| 214 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) { | 214 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) { |
| 215 return os << Bytecodes::OperandTypeToString(operand_type); | 215 return os << Bytecodes::OperandTypeToString(operand_type); |
| 216 } | 216 } |
| 217 | 217 |
| 218 | 218 |
| 219 static const int kLastParamRegisterIndex = | 219 static const int kLastParamRegisterIndex = |
| 220 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; | 220 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; |
| 221 static const int kFunctionContextRegisterIndex = |
| 222 -InterpreterFrameConstants::kContextFromRegisterPointer / kPointerSize; |
| 221 | 223 |
| 222 | 224 |
| 223 // Registers occupy range 0-127 in 8-bit value leaving 128 unused values. | 225 // Registers occupy range 0-127 in 8-bit value leaving 128 unused values. |
| 224 // Parameter indices are biased with the negative value kLastParamRegisterIndex | 226 // Parameter indices are biased with the negative value kLastParamRegisterIndex |
| 225 // for ease of access in the interpreter. | 227 // for ease of access in the interpreter. |
| 226 static const int kMaxParameterIndex = 128 + kLastParamRegisterIndex; | 228 static const int kMaxParameterIndex = 128 + kLastParamRegisterIndex; |
| 227 | 229 |
| 228 | 230 |
| 229 Register Register::FromParameterIndex(int index, int parameter_count) { | 231 Register Register::FromParameterIndex(int index, int parameter_count) { |
| 230 DCHECK_GE(index, 0); | 232 DCHECK_GE(index, 0); |
| 231 DCHECK_LT(index, parameter_count); | 233 DCHECK_LT(index, parameter_count); |
| 232 DCHECK_LE(parameter_count, kMaxParameterIndex + 1); | 234 DCHECK_LE(parameter_count, kMaxParameterIndex + 1); |
| 233 int register_index = kLastParamRegisterIndex - parameter_count + index + 1; | 235 int register_index = kLastParamRegisterIndex - parameter_count + index + 1; |
| 234 DCHECK_LT(register_index, 0); | 236 DCHECK_LT(register_index, 0); |
| 235 DCHECK_GE(register_index, Register::kMinRegisterIndex); | 237 DCHECK_GE(register_index, Register::kMinRegisterIndex); |
| 236 return Register(register_index); | 238 return Register(register_index); |
| 237 } | 239 } |
| 238 | 240 |
| 239 | 241 |
| 240 int Register::ToParameterIndex(int parameter_count) const { | 242 int Register::ToParameterIndex(int parameter_count) const { |
| 241 DCHECK(is_parameter()); | 243 DCHECK(is_parameter()); |
| 242 return index() - kLastParamRegisterIndex + parameter_count - 1; | 244 return index() - kLastParamRegisterIndex + parameter_count - 1; |
| 243 } | 245 } |
| 244 | 246 |
| 245 | 247 |
| 248 Register Register::function_context() { |
| 249 return Register(kFunctionContextRegisterIndex); |
| 250 } |
| 251 |
| 252 |
| 253 bool Register::is_function_context() const { |
| 254 return index() == kFunctionContextRegisterIndex; |
| 255 } |
| 256 |
| 257 |
| 246 int Register::MaxParameterIndex() { return kMaxParameterIndex; } | 258 int Register::MaxParameterIndex() { return kMaxParameterIndex; } |
| 247 | 259 |
| 248 | 260 |
| 249 uint8_t Register::ToOperand() const { return static_cast<uint8_t>(-index_); } | 261 uint8_t Register::ToOperand() const { return static_cast<uint8_t>(-index_); } |
| 250 | 262 |
| 251 | 263 |
| 252 Register Register::FromOperand(uint8_t operand) { | 264 Register Register::FromOperand(uint8_t operand) { |
| 253 return Register(-static_cast<int8_t>(operand)); | 265 return Register(-static_cast<int8_t>(operand)); |
| 254 } | 266 } |
| 255 | 267 |
| 256 } // namespace interpreter | 268 } // namespace interpreter |
| 257 } // namespace internal | 269 } // namespace internal |
| 258 } // namespace v8 | 270 } // namespace v8 |
| OLD | NEW |