LCOV - code coverage report
Current view: top level - src/compiler - frame-states.h (source / functions) Hit Total Coverage
Test: app.info Lines: 9 9 100.0 %
Date: 2017-10-20 Functions: 0 0 -

          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             : #ifndef V8_COMPILER_FRAME_STATES_H_
       6             : #define V8_COMPILER_FRAME_STATES_H_
       7             : 
       8             : #include "src/builtins/builtins.h"
       9             : #include "src/handles.h"
      10             : #include "src/objects/shared-function-info.h"
      11             : #include "src/utils.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : namespace compiler {
      17             : 
      18             : class JSGraph;
      19             : class Node;
      20             : 
      21             : // Flag that describes how to combine the current environment with
      22             : // the output of a node to obtain a framestate for lazy bailout.
      23             : class OutputFrameStateCombine {
      24             :  public:
      25             :   static const size_t kInvalidIndex = SIZE_MAX;
      26             : 
      27             :   static OutputFrameStateCombine Ignore() {
      28             :     return OutputFrameStateCombine(kInvalidIndex);
      29             :   }
      30             :   static OutputFrameStateCombine PokeAt(size_t index) {
      31             :     return OutputFrameStateCombine(index);
      32             :   }
      33             : 
      34             :   size_t GetOffsetToPokeAt() const {
      35             :     DCHECK_NE(parameter_, kInvalidIndex);
      36             :     return parameter_;
      37             :   }
      38             : 
      39             :   bool IsOutputIgnored() const { return parameter_ == kInvalidIndex; }
      40             : 
      41     2733719 :   size_t ConsumedOutputCount() const { return IsOutputIgnored() ? 0 : 1; }
      42             : 
      43             :   bool operator==(OutputFrameStateCombine const& other) const {
      44     3302953 :     return parameter_ == other.parameter_;
      45             :   }
      46             :   bool operator!=(OutputFrameStateCombine const& other) const {
      47             :     return !(*this == other);
      48             :   }
      49             : 
      50             :   friend size_t hash_value(OutputFrameStateCombine const&);
      51             :   friend std::ostream& operator<<(std::ostream&,
      52             :                                   OutputFrameStateCombine const&);
      53             : 
      54             :  private:
      55             :   explicit OutputFrameStateCombine(size_t parameter) : parameter_(parameter) {}
      56             : 
      57             :   size_t const parameter_;
      58             : };
      59             : 
      60             : 
      61             : // The type of stack frame that a FrameState node represents.
      62             : enum class FrameStateType {
      63             :   kInterpretedFunction,  // Represents an InterpretedFrame.
      64             :   kArgumentsAdaptor,     // Represents an ArgumentsAdaptorFrame.
      65             :   kConstructStub,        // Represents a ConstructStubFrame.
      66             :   kGetterStub,           // Represents a GetterStubFrame.
      67             :   kSetterStub,           // Represents a SetterStubFrame.
      68             :   kBuiltinContinuation,  // Represents a continuation to a stub.
      69             :   kJavaScriptBuiltinContinuation  // Represents a continuation to a JavaScipt
      70             :                                   // builtin.
      71             : };
      72             : 
      73             : class FrameStateFunctionInfo {
      74             :  public:
      75             :   FrameStateFunctionInfo(FrameStateType type, int parameter_count,
      76             :                          int local_count,
      77             :                          Handle<SharedFunctionInfo> shared_info)
      78             :       : type_(type),
      79             :         parameter_count_(parameter_count),
      80             :         local_count_(local_count),
      81      547351 :         shared_info_(shared_info) {}
      82             : 
      83             :   int local_count() const { return local_count_; }
      84             :   int parameter_count() const { return parameter_count_; }
      85             :   Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
      86             :   FrameStateType type() const { return type_; }
      87             : 
      88             :   static bool IsJSFunctionType(FrameStateType type) {
      89    40027097 :     return type == FrameStateType::kInterpretedFunction ||
      90    40027097 :            type == FrameStateType::kJavaScriptBuiltinContinuation;
      91             :   }
      92             : 
      93             :  private:
      94             :   FrameStateType const type_;
      95             :   int const parameter_count_;
      96             :   int const local_count_;
      97             :   Handle<SharedFunctionInfo> const shared_info_;
      98             : };
      99             : 
     100             : 
     101             : class FrameStateInfo final {
     102             :  public:
     103             :   FrameStateInfo(BailoutId bailout_id, OutputFrameStateCombine state_combine,
     104             :                  const FrameStateFunctionInfo* info)
     105             :       : bailout_id_(bailout_id),
     106             :         frame_state_combine_(state_combine),
     107             :         info_(info) {}
     108             : 
     109             :   FrameStateType type() const {
     110    43480422 :     return info_ == nullptr ? FrameStateType::kInterpretedFunction
     111    43480410 :                             : info_->type();
     112             :   }
     113             :   BailoutId bailout_id() const { return bailout_id_; }
     114             :   OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
     115             :   MaybeHandle<SharedFunctionInfo> shared_info() const {
     116             :     return info_ == nullptr ? MaybeHandle<SharedFunctionInfo>()
     117     3716759 :                             : info_->shared_info();
     118             :   }
     119             :   int parameter_count() const {
     120        2766 :     return info_ == nullptr ? 0 : info_->parameter_count();
     121             :   }
     122             :   int local_count() const {
     123             :     return info_ == nullptr ? 0 : info_->local_count();
     124             :   }
     125             :   const FrameStateFunctionInfo* function_info() const { return info_; }
     126             : 
     127             :  private:
     128             :   BailoutId const bailout_id_;
     129             :   OutputFrameStateCombine const frame_state_combine_;
     130             :   const FrameStateFunctionInfo* const info_;
     131             : };
     132             : 
     133             : bool operator==(FrameStateInfo const&, FrameStateInfo const&);
     134             : bool operator!=(FrameStateInfo const&, FrameStateInfo const&);
     135             : 
     136             : size_t hash_value(FrameStateInfo const&);
     137             : 
     138             : std::ostream& operator<<(std::ostream&, FrameStateInfo const&);
     139             : 
     140             : static const int kFrameStateParametersInput = 0;
     141             : static const int kFrameStateLocalsInput = 1;
     142             : static const int kFrameStateStackInput = 2;
     143             : static const int kFrameStateContextInput = 3;
     144             : static const int kFrameStateFunctionInput = 4;
     145             : static const int kFrameStateOuterStateInput = 5;
     146             : static const int kFrameStateInputCount = kFrameStateOuterStateInput + 1;
     147             : 
     148             : enum class ContinuationFrameStateMode { EAGER, LAZY };
     149             : 
     150             : Node* CreateStubBuiltinContinuationFrameState(JSGraph* graph,
     151             :                                               Builtins::Name name,
     152             :                                               Node* context, Node** parameters,
     153             :                                               int parameter_count,
     154             :                                               Node* outer_frame_state,
     155             :                                               ContinuationFrameStateMode mode);
     156             : 
     157             : Node* CreateJavaScriptBuiltinContinuationFrameState(
     158             :     JSGraph* graph, Handle<JSFunction> function, Builtins::Name name,
     159             :     Node* target, Node* context, Node** stack_parameters,
     160             :     int stack_parameter_count, Node* outer_frame_state,
     161             :     ContinuationFrameStateMode mode);
     162             : 
     163             : }  // namespace compiler
     164             : }  // namespace internal
     165             : }  // namespace v8
     166             : 
     167             : #endif  // V8_COMPILER_FRAME_STATES_H_

Generated by: LCOV version 1.10