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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 259 } |
260 | 260 |
261 | 261 |
262 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) { | 262 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) { |
263 return os << Bytecodes::OperandSizeToString(operand_size); | 263 return os << Bytecodes::OperandSizeToString(operand_size); |
264 } | 264 } |
265 | 265 |
266 | 266 |
267 static const int kLastParamRegisterIndex = | 267 static const int kLastParamRegisterIndex = |
268 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; | 268 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; |
| 269 static const int kFunctionContextRegisterIndex = |
| 270 -InterpreterFrameConstants::kContextFromRegisterPointer / kPointerSize; |
269 | 271 |
270 | 272 |
271 // Registers occupy range 0-127 in 8-bit value leaving 128 unused values. | 273 // Registers occupy range 0-127 in 8-bit value leaving 128 unused values. |
272 // Parameter indices are biased with the negative value kLastParamRegisterIndex | 274 // Parameter indices are biased with the negative value kLastParamRegisterIndex |
273 // for ease of access in the interpreter. | 275 // for ease of access in the interpreter. |
274 static const int kMaxParameterIndex = 128 + kLastParamRegisterIndex; | 276 static const int kMaxParameterIndex = 128 + kLastParamRegisterIndex; |
275 | 277 |
276 | 278 |
277 Register Register::FromParameterIndex(int index, int parameter_count) { | 279 Register Register::FromParameterIndex(int index, int parameter_count) { |
278 DCHECK_GE(index, 0); | 280 DCHECK_GE(index, 0); |
279 DCHECK_LT(index, parameter_count); | 281 DCHECK_LT(index, parameter_count); |
280 DCHECK_LE(parameter_count, kMaxParameterIndex + 1); | 282 DCHECK_LE(parameter_count, kMaxParameterIndex + 1); |
281 int register_index = kLastParamRegisterIndex - parameter_count + index + 1; | 283 int register_index = kLastParamRegisterIndex - parameter_count + index + 1; |
282 DCHECK_LT(register_index, 0); | 284 DCHECK_LT(register_index, 0); |
283 DCHECK_GE(register_index, Register::kMinRegisterIndex); | 285 DCHECK_GE(register_index, Register::kMinRegisterIndex); |
284 return Register(register_index); | 286 return Register(register_index); |
285 } | 287 } |
286 | 288 |
287 | 289 |
288 int Register::ToParameterIndex(int parameter_count) const { | 290 int Register::ToParameterIndex(int parameter_count) const { |
289 DCHECK(is_parameter()); | 291 DCHECK(is_parameter()); |
290 return index() - kLastParamRegisterIndex + parameter_count - 1; | 292 return index() - kLastParamRegisterIndex + parameter_count - 1; |
291 } | 293 } |
292 | 294 |
293 | 295 |
| 296 Register Register::function_context() { |
| 297 return Register(kFunctionContextRegisterIndex); |
| 298 } |
| 299 |
| 300 |
| 301 bool Register::is_function_context() const { |
| 302 return index() == kFunctionContextRegisterIndex; |
| 303 } |
| 304 |
| 305 |
294 int Register::MaxParameterIndex() { return kMaxParameterIndex; } | 306 int Register::MaxParameterIndex() { return kMaxParameterIndex; } |
295 | 307 |
296 | 308 |
297 uint8_t Register::ToOperand() const { return static_cast<uint8_t>(-index_); } | 309 uint8_t Register::ToOperand() const { return static_cast<uint8_t>(-index_); } |
298 | 310 |
299 | 311 |
300 Register Register::FromOperand(uint8_t operand) { | 312 Register Register::FromOperand(uint8_t operand) { |
301 return Register(-static_cast<int8_t>(operand)); | 313 return Register(-static_cast<int8_t>(operand)); |
302 } | 314 } |
303 | 315 |
304 } // namespace interpreter | 316 } // namespace interpreter |
305 } // namespace internal | 317 } // namespace internal |
306 } // namespace v8 | 318 } // namespace v8 |
OLD | NEW |