LCOV - code coverage report
Current view: top level - src/compiler - node-properties.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 2013 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_NODE_PROPERTIES_H_
       6             : #define V8_COMPILER_NODE_PROPERTIES_H_
       7             : 
       8             : #include "src/compiler/node.h"
       9             : #include "src/compiler/types.h"
      10             : #include "src/globals.h"
      11             : #include "src/zone/zone-handle-set.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : namespace compiler {
      16             : 
      17             : class Graph;
      18             : class Operator;
      19             : class CommonOperatorBuilder;
      20             : 
      21             : // A facade that simplifies access to the different kinds of inputs to a node.
      22             : class V8_EXPORT_PRIVATE NodeProperties final {
      23             :  public:
      24             :   // ---------------------------------------------------------------------------
      25             :   // Input layout.
      26             :   // Inputs are always arranged in order as follows:
      27             :   //     0 [ values, context, frame state, effects, control ] node->InputCount()
      28             : 
      29             :   static int FirstValueIndex(Node* node) { return 0; }
      30       17030 :   static int FirstContextIndex(Node* node) { return PastValueIndex(node); }
      31          18 :   static int FirstFrameStateIndex(Node* node) { return PastContextIndex(node); }
      32   906134601 :   static int FirstEffectIndex(Node* node) { return PastFrameStateIndex(node); }
      33    56894711 :   static int FirstControlIndex(Node* node) { return PastEffectIndex(node); }
      34             :   static int PastValueIndex(Node* node);
      35             :   static int PastContextIndex(Node* node);
      36             :   static int PastFrameStateIndex(Node* node);
      37             :   static int PastEffectIndex(Node* node);
      38             :   static int PastControlIndex(Node* node);
      39             : 
      40             : 
      41             :   // ---------------------------------------------------------------------------
      42             :   // Input accessors.
      43             : 
      44             :   static Node* GetValueInput(Node* node, int index);
      45             :   static Node* GetContextInput(Node* node);
      46             :   static Node* GetFrameStateInput(Node* node);
      47             :   static Node* GetEffectInput(Node* node, int index = 0);
      48             :   static Node* GetControlInput(Node* node, int index = 0);
      49             : 
      50             : 
      51             :   // ---------------------------------------------------------------------------
      52             :   // Edge kinds.
      53             : 
      54             :   static bool IsValueEdge(Edge edge);
      55             :   static bool IsContextEdge(Edge edge);
      56             :   static bool IsFrameStateEdge(Edge edge);
      57             :   static bool IsEffectEdge(Edge edge);
      58             :   static bool IsControlEdge(Edge edge);
      59             : 
      60             : 
      61             :   // ---------------------------------------------------------------------------
      62             :   // Miscellaneous predicates.
      63             : 
      64             :   static bool IsCommon(Node* node) {
      65             :     return IrOpcode::IsCommonOpcode(node->opcode());
      66             :   }
      67         120 :   static bool IsControl(Node* node) {
      68             :     return IrOpcode::IsControlOpcode(node->opcode());
      69             :   }
      70    31804657 :   static bool IsConstant(Node* node) {
      71             :     return IrOpcode::IsConstantOpcode(node->opcode());
      72             :   }
      73    18758264 :   static bool IsPhi(Node* node) {
      74             :     return IrOpcode::IsPhiOpcode(node->opcode());
      75             :   }
      76             : 
      77             :   // Determines whether exceptions thrown by the given node are handled locally
      78             :   // within the graph (i.e. an IfException projection is present). Optionally
      79             :   // the present IfException projection is returned via {out_exception}.
      80             :   static bool IsExceptionalCall(Node* node, Node** out_exception = nullptr);
      81             : 
      82             :   // Returns the node producing the successful control output of {node}. This is
      83             :   // the IfSuccess projection of {node} if present and {node} itself otherwise.
      84             :   static Node* FindSuccessfulControlProjection(Node* node);
      85             : 
      86             :   // ---------------------------------------------------------------------------
      87             :   // Miscellaneous mutators.
      88             : 
      89             :   static void ReplaceValueInput(Node* node, Node* value, int index);
      90             :   static void ReplaceContextInput(Node* node, Node* context);
      91             :   static void ReplaceControlInput(Node* node, Node* control, int index = 0);
      92             :   static void ReplaceEffectInput(Node* node, Node* effect, int index = 0);
      93             :   static void ReplaceFrameStateInput(Node* node, Node* frame_state);
      94             :   static void RemoveNonValueInputs(Node* node);
      95             :   static void RemoveValueInputs(Node* node);
      96             : 
      97             :   // Replaces all value inputs of {node} with the single input {value}.
      98             :   static void ReplaceValueInputs(Node* node, Node* value);
      99             : 
     100             :   // Merge the control node {node} into the end of the graph, introducing a
     101             :   // merge node or expanding an existing merge node if necessary.
     102             :   static void MergeControlToEnd(Graph* graph, CommonOperatorBuilder* common,
     103             :                                 Node* node);
     104             : 
     105             :   // Replace all uses of {node} with the given replacement nodes. All occurring
     106             :   // use kinds need to be replaced, {nullptr} is only valid if a use kind is
     107             :   // guaranteed not to exist.
     108             :   static void ReplaceUses(Node* node, Node* value, Node* effect = nullptr,
     109             :                           Node* success = nullptr, Node* exception = nullptr);
     110             : 
     111             :   // Safe wrapper to mutate the operator of a node. Checks that the node is
     112             :   // currently in a state that satisfies constraints of the new operator.
     113             :   static void ChangeOp(Node* node, const Operator* new_op);
     114             : 
     115             :   // ---------------------------------------------------------------------------
     116             :   // Miscellaneous utilities.
     117             : 
     118             :   // Find the last frame state that is effect-wise before the given node. This
     119             :   // assumes a linear effect-chain up to a {CheckPoint} node in the graph.
     120             :   static Node* FindFrameStateBefore(Node* node);
     121             : 
     122             :   // Collect the output-value projection for the given output index.
     123             :   static Node* FindProjection(Node* node, size_t projection_index);
     124             : 
     125             :   // Collect the branch-related projections from a node, such as IfTrue,
     126             :   // IfFalse, IfSuccess, IfException, IfValue and IfDefault.
     127             :   //  - Branch: [ IfTrue, IfFalse ]
     128             :   //  - Call  : [ IfSuccess, IfException ]
     129             :   //  - Switch: [ IfValue, ..., IfDefault ]
     130             :   static void CollectControlProjections(Node* node, Node** proj, size_t count);
     131             : 
     132             :   // Checks if two nodes are the same, looking past {CheckHeapObject}.
     133             :   static bool IsSame(Node* a, Node* b);
     134             : 
     135             :   // Check if two nodes have equal operators and reference-equal inputs. Used
     136             :   // for value numbering/hash-consing.
     137             :   static bool Equals(Node* a, Node* b);
     138             :   // A corresponding hash function.
     139             :   static size_t HashCode(Node* node);
     140             : 
     141             :   // Walks up the {effect} chain to find a witness that provides map
     142             :   // information about the {receiver}. Can look through potentially
     143             :   // side effecting nodes.
     144             :   enum InferReceiverMapsResult {
     145             :     kNoReceiverMaps,         // No receiver maps inferred.
     146             :     kReliableReceiverMaps,   // Receiver maps can be trusted.
     147             :     kUnreliableReceiverMaps  // Receiver maps might have changed (side-effect),
     148             :                              // but instance type is reliable.
     149             :   };
     150             :   static InferReceiverMapsResult InferReceiverMaps(
     151             :       Node* receiver, Node* effect, ZoneHandleSet<Map>* maps_return);
     152             : 
     153             :   // Walks up the {effect} chain to check that there's no observable side-effect
     154             :   // between the {effect} and it's {dominator}. Aborts the walk if there's join
     155             :   // in the effect chain.
     156             :   static bool NoObservableSideEffectBetween(Node* effect, Node* dominator);
     157             : 
     158             :   // ---------------------------------------------------------------------------
     159             :   // Context.
     160             : 
     161             :   // Walk up the context chain from the given {node} until we reduce the {depth}
     162             :   // to 0 or hit a node that does not extend the context chain ({depth} will be
     163             :   // updated accordingly).
     164             :   static Node* GetOuterContext(Node* node, size_t* depth);
     165             : 
     166             :   // ---------------------------------------------------------------------------
     167             :   // Type.
     168             : 
     169    64722832 :   static bool IsTyped(Node* node) { return node->type() != nullptr; }
     170    56758215 :   static Type* GetType(Node* node) {
     171             :     DCHECK(IsTyped(node));
     172             :     return node->type();
     173             :   }
     174             :   static Type* GetTypeOrAny(Node* node);
     175             :   static void SetType(Node* node, Type* type) {
     176             :     DCHECK_NOT_NULL(type);
     177             :     node->set_type(type);
     178             :   }
     179             :   static void RemoveType(Node* node) { node->set_type(nullptr); }
     180             :   static bool AllValueInputsAreTyped(Node* node);
     181             : 
     182             :  private:
     183             :   static inline bool IsInputRange(Edge edge, int first, int count);
     184             : };
     185             : 
     186             : }  // namespace compiler
     187             : }  // namespace internal
     188             : }  // namespace v8
     189             : 
     190             : #endif  // V8_COMPILER_NODE_PROPERTIES_H_

Generated by: LCOV version 1.10