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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 case interpreter::OperandType::kImm8: | 221 case interpreter::OperandType::kImm8: |
222 os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); | 222 os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); |
223 break; | 223 break; |
224 case interpreter::OperandType::kReg8: | 224 case interpreter::OperandType::kReg8: |
225 case interpreter::OperandType::kMaybeReg8: { | 225 case interpreter::OperandType::kMaybeReg8: { |
226 Register reg = Register::FromOperand(*operand_start); | 226 Register reg = Register::FromOperand(*operand_start); |
227 if (reg.is_function_context()) { | 227 if (reg.is_function_context()) { |
228 os << "<context>"; | 228 os << "<context>"; |
229 } else if (reg.is_function_closure()) { | 229 } else if (reg.is_function_closure()) { |
230 os << "<closure>"; | 230 os << "<closure>"; |
| 231 } else if (reg.is_new_target()) { |
| 232 os << "<new.target>"; |
231 } else if (reg.is_parameter()) { | 233 } else if (reg.is_parameter()) { |
232 int parameter_index = reg.ToParameterIndex(parameter_count); | 234 int parameter_index = reg.ToParameterIndex(parameter_count); |
233 if (parameter_index == 0) { | 235 if (parameter_index == 0) { |
234 os << "<this>"; | 236 os << "<this>"; |
235 } else { | 237 } else { |
236 os << "a" << parameter_index - 1; | 238 os << "a" << parameter_index - 1; |
237 } | 239 } |
238 } else { | 240 } else { |
239 os << "r" << reg.index(); | 241 os << "r" << reg.index(); |
240 } | 242 } |
(...skipping 25 matching lines...) Expand all Loading... |
266 return os << Bytecodes::OperandSizeToString(operand_size); | 268 return os << Bytecodes::OperandSizeToString(operand_size); |
267 } | 269 } |
268 | 270 |
269 | 271 |
270 static const int kLastParamRegisterIndex = | 272 static const int kLastParamRegisterIndex = |
271 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; | 273 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; |
272 static const int kFunctionClosureRegisterIndex = | 274 static const int kFunctionClosureRegisterIndex = |
273 -InterpreterFrameConstants::kFunctionFromRegisterPointer / kPointerSize; | 275 -InterpreterFrameConstants::kFunctionFromRegisterPointer / kPointerSize; |
274 static const int kFunctionContextRegisterIndex = | 276 static const int kFunctionContextRegisterIndex = |
275 -InterpreterFrameConstants::kContextFromRegisterPointer / kPointerSize; | 277 -InterpreterFrameConstants::kContextFromRegisterPointer / kPointerSize; |
| 278 static const int kNewTargetRegisterIndex = |
| 279 -InterpreterFrameConstants::kNewTargetFromRegisterPointer / kPointerSize; |
276 | 280 |
277 | 281 |
278 // Registers occupy range 0-127 in 8-bit value leaving 128 unused values. | 282 // Registers occupy range 0-127 in 8-bit value leaving 128 unused values. |
279 // Parameter indices are biased with the negative value kLastParamRegisterIndex | 283 // Parameter indices are biased with the negative value kLastParamRegisterIndex |
280 // for ease of access in the interpreter. | 284 // for ease of access in the interpreter. |
281 static const int kMaxParameterIndex = 128 + kLastParamRegisterIndex; | 285 static const int kMaxParameterIndex = 128 + kLastParamRegisterIndex; |
282 | 286 |
283 | 287 |
284 Register Register::FromParameterIndex(int index, int parameter_count) { | 288 Register Register::FromParameterIndex(int index, int parameter_count) { |
285 DCHECK_GE(index, 0); | 289 DCHECK_GE(index, 0); |
(...skipping 25 matching lines...) Expand all Loading... |
311 Register Register::function_context() { | 315 Register Register::function_context() { |
312 return Register(kFunctionContextRegisterIndex); | 316 return Register(kFunctionContextRegisterIndex); |
313 } | 317 } |
314 | 318 |
315 | 319 |
316 bool Register::is_function_context() const { | 320 bool Register::is_function_context() const { |
317 return index() == kFunctionContextRegisterIndex; | 321 return index() == kFunctionContextRegisterIndex; |
318 } | 322 } |
319 | 323 |
320 | 324 |
| 325 Register Register::new_target() { return Register(kNewTargetRegisterIndex); } |
| 326 |
| 327 |
| 328 bool Register::is_new_target() const { |
| 329 return index() == kNewTargetRegisterIndex; |
| 330 } |
| 331 |
| 332 |
321 int Register::MaxParameterIndex() { return kMaxParameterIndex; } | 333 int Register::MaxParameterIndex() { return kMaxParameterIndex; } |
322 | 334 |
323 | 335 |
324 uint8_t Register::ToOperand() const { return static_cast<uint8_t>(-index_); } | 336 uint8_t Register::ToOperand() const { return static_cast<uint8_t>(-index_); } |
325 | 337 |
326 | 338 |
327 Register Register::FromOperand(uint8_t operand) { | 339 Register Register::FromOperand(uint8_t operand) { |
328 return Register(-static_cast<int8_t>(operand)); | 340 return Register(-static_cast<int8_t>(operand)); |
329 } | 341 } |
330 | 342 |
(...skipping 11 matching lines...) Expand all Loading... |
342 } | 354 } |
343 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { | 355 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { |
344 return false; | 356 return false; |
345 } | 357 } |
346 return true; | 358 return true; |
347 } | 359 } |
348 | 360 |
349 } // namespace interpreter | 361 } // namespace interpreter |
350 } // namespace internal | 362 } // namespace internal |
351 } // namespace v8 | 363 } // namespace v8 |
OLD | NEW |