LCOV - code coverage report
Current view: top level - src/interpreter - bytecode-register.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 30 47 63.8 %
Date: 2019-02-19 Functions: 10 14 71.4 %

          Line data    Source code
       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
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/interpreter/bytecode-register.h"
       6             : 
       7             : namespace v8 {
       8             : namespace internal {
       9             : namespace interpreter {
      10             : 
      11             : static const int kLastParamRegisterIndex =
      12             :     (InterpreterFrameConstants::kRegisterFileFromFp -
      13             :      InterpreterFrameConstants::kLastParamFromFp) /
      14             :     kSystemPointerSize;
      15             : static const int kFunctionClosureRegisterIndex =
      16             :     (InterpreterFrameConstants::kRegisterFileFromFp -
      17             :      StandardFrameConstants::kFunctionOffset) /
      18             :     kSystemPointerSize;
      19             : static const int kCurrentContextRegisterIndex =
      20             :     (InterpreterFrameConstants::kRegisterFileFromFp -
      21             :      StandardFrameConstants::kContextOffset) /
      22             :     kSystemPointerSize;
      23             : static const int kBytecodeArrayRegisterIndex =
      24             :     (InterpreterFrameConstants::kRegisterFileFromFp -
      25             :      InterpreterFrameConstants::kBytecodeArrayFromFp) /
      26             :     kSystemPointerSize;
      27             : static const int kBytecodeOffsetRegisterIndex =
      28             :     (InterpreterFrameConstants::kRegisterFileFromFp -
      29             :      InterpreterFrameConstants::kBytecodeOffsetFromFp) /
      30             :     kSystemPointerSize;
      31             : static const int kCallerPCOffsetRegisterIndex =
      32             :     (InterpreterFrameConstants::kRegisterFileFromFp -
      33             :      InterpreterFrameConstants::kCallerPCOffsetFromFp) /
      34             :     kSystemPointerSize;
      35             : 
      36     6043021 : Register Register::FromParameterIndex(int index, int parameter_count) {
      37             :   DCHECK_GE(index, 0);
      38             :   DCHECK_LT(index, parameter_count);
      39     6043021 :   int register_index = kLastParamRegisterIndex - parameter_count + index + 1;
      40             :   DCHECK_LT(register_index, 0);
      41     6043021 :   return Register(register_index);
      42             : }
      43             : 
      44      930420 : int Register::ToParameterIndex(int parameter_count) const {
      45             :   DCHECK(is_parameter());
      46      930421 :   return index() - kLastParamRegisterIndex + parameter_count - 1;
      47             : }
      48             : 
      49      278785 : Register Register::function_closure() {
      50      278785 :   return Register(kFunctionClosureRegisterIndex);
      51             : }
      52             : 
      53     5450592 : bool Register::is_function_closure() const {
      54     5450592 :   return index() == kFunctionClosureRegisterIndex;
      55             : }
      56             : 
      57     2580948 : Register Register::current_context() {
      58     2580948 :   return Register(kCurrentContextRegisterIndex);
      59             : }
      60             : 
      61     9245537 : bool Register::is_current_context() const {
      62     9245537 :   return index() == kCurrentContextRegisterIndex;
      63             : }
      64             : 
      65       27272 : Register Register::bytecode_array() {
      66       27272 :   return Register(kBytecodeArrayRegisterIndex);
      67             : }
      68             : 
      69           0 : bool Register::is_bytecode_array() const {
      70           0 :   return index() == kBytecodeArrayRegisterIndex;
      71             : }
      72             : 
      73       59933 : Register Register::bytecode_offset() {
      74       59933 :   return Register(kBytecodeOffsetRegisterIndex);
      75             : }
      76             : 
      77           0 : bool Register::is_bytecode_offset() const {
      78           0 :   return index() == kBytecodeOffsetRegisterIndex;
      79             : }
      80             : 
      81             : // static
      82     2106752 : Register Register::virtual_accumulator() {
      83     2106752 :   return Register(kCallerPCOffsetRegisterIndex);
      84             : }
      85             : 
      86           0 : OperandSize Register::SizeOfOperand() const {
      87             :   int32_t operand = ToOperand();
      88           0 :   if (operand >= kMinInt8 && operand <= kMaxInt8) {
      89             :     return OperandSize::kByte;
      90           0 :   } else if (operand >= kMinInt16 && operand <= kMaxInt16) {
      91             :     return OperandSize::kShort;
      92             :   } else {
      93           0 :     return OperandSize::kQuad;
      94             :   }
      95             : }
      96             : 
      97           0 : bool Register::AreContiguous(Register reg1, Register reg2, Register reg3,
      98             :                              Register reg4, Register reg5) {
      99           0 :   if (reg1.index() + 1 != reg2.index()) {
     100             :     return false;
     101             :   }
     102           0 :   if (reg3.is_valid() && reg2.index() + 1 != reg3.index()) {
     103             :     return false;
     104             :   }
     105           0 :   if (reg4.is_valid() && reg3.index() + 1 != reg4.index()) {
     106             :     return false;
     107             :   }
     108           0 :   if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) {
     109             :     return false;
     110             :   }
     111           0 :   return true;
     112             : }
     113             : 
     114          49 : std::string Register::ToString(int parameter_count) const {
     115          49 :   if (is_current_context()) {
     116           0 :     return std::string("<context>");
     117          49 :   } else if (is_function_closure()) {
     118           0 :     return std::string("<closure>");
     119          49 :   } else if (is_parameter()) {
     120             :     int parameter_index = ToParameterIndex(parameter_count);
     121           1 :     if (parameter_index == 0) {
     122           0 :       return std::string("<this>");
     123             :     } else {
     124           1 :       std::ostringstream s;
     125           1 :       s << "a" << parameter_index - 1;
     126           1 :       return s.str();
     127             :     }
     128             :   } else {
     129          48 :     std::ostringstream s;
     130          48 :     s << "r" << index();
     131          48 :     return s.str();
     132             :   }
     133             : }
     134             : 
     135             : }  // namespace interpreter
     136             : }  // namespace internal
     137             : }  // namespace v8

Generated by: LCOV version 1.10