LCOV - code coverage report
Current view: top level - src/compiler - js-graph.h (source / functions) Hit Total Coverage
Test: app.info Lines: 9 9 100.0 %
Date: 2019-02-19 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright 2014 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_JS_GRAPH_H_
       6             : #define V8_COMPILER_JS_GRAPH_H_
       7             : 
       8             : #include "src/compiler/common-operator.h"
       9             : #include "src/compiler/graph.h"
      10             : #include "src/compiler/js-operator.h"
      11             : #include "src/compiler/machine-graph.h"
      12             : #include "src/compiler/node-properties.h"
      13             : #include "src/globals.h"
      14             : #include "src/isolate.h"
      15             : 
      16             : namespace v8 {
      17             : namespace internal {
      18             : namespace compiler {
      19             : 
      20             : class SimplifiedOperatorBuilder;
      21             : class Typer;
      22             : 
      23             : // Implements a facade on a Graph, enhancing the graph with JS-specific
      24             : // notions, including various builders for operators, canonicalized global
      25             : // constants, and various helper methods.
      26             : class V8_EXPORT_PRIVATE JSGraph : public MachineGraph {
      27             :  public:
      28     3277725 :   JSGraph(Isolate* isolate, Graph* graph, CommonOperatorBuilder* common,
      29             :           JSOperatorBuilder* javascript, SimplifiedOperatorBuilder* simplified,
      30             :           MachineOperatorBuilder* machine)
      31             :       : MachineGraph(graph, common, machine),
      32             :         isolate_(isolate),
      33             :         javascript_(javascript),
      34     3277723 :         simplified_(simplified) {
      35     3277723 :   }
      36             : 
      37             :   // CEntryStubs are cached depending on the result size and other flags.
      38             :   Node* CEntryStubConstant(int result_size,
      39             :                            SaveFPRegsMode save_doubles = kDontSaveFPRegs,
      40             :                            ArgvMode argv_mode = kArgvOnStack,
      41             :                            bool builtin_exit_frame = false);
      42             : 
      43             :   // Used for padding frames. (alias: the hole)
      44        2145 :   Node* PaddingConstant() { return TheHoleConstant(); }
      45             : 
      46             :   // Used for stubs and runtime functions with no context. (alias: SMI zero)
      47      170738 :   Node* NoContextConstant() { return ZeroConstant(); }
      48             : 
      49             :   // Creates a HeapConstant node, possibly canonicalized, and may access the
      50             :   // heap to inspect the object.
      51             :   Node* HeapConstant(Handle<HeapObject> value);
      52             : 
      53             :   // Creates a Constant node of the appropriate type for the given object.
      54             :   // Accesses the heap to inspect the object and determine whether one of the
      55             :   // canonicalized globals or a number constant should be returned.
      56             :   Node* Constant(Handle<Object> value);
      57             : 
      58             :   // Like above, but doesn't access the heap directly.
      59             :   Node* Constant(const ObjectRef& value);
      60             : 
      61             :   // Creates a NumberConstant node, usually canonicalized.
      62             :   Node* Constant(double value);
      63             : 
      64             :   // Creates a HeapConstant node for either true or false.
      65        4622 :   Node* BooleanConstant(bool is_true) {
      66        4622 :     return is_true ? TrueConstant() : FalseConstant();
      67             :   }
      68             : 
      69             :   Node* SmiConstant(int32_t immediate) {
      70             :     DCHECK(Smi::IsValid(immediate));
      71     1664047 :     return Constant(immediate);
      72             :   }
      73             : 
      74             :   JSOperatorBuilder* javascript() const { return javascript_; }
      75             :   SimplifiedOperatorBuilder* simplified() const { return simplified_; }
      76             :   Isolate* isolate() const { return isolate_; }
      77     3107724 :   Factory* factory() const { return isolate()->factory(); }
      78             : 
      79             :   // Adds all the cached nodes to the given list.
      80             :   void GetCachedNodes(NodeVector* nodes);
      81             : 
      82             : // Cached global nodes.
      83             : #define CACHED_GLOBAL_LIST(V)       \
      84             :   V(AllocateInNewSpaceStubConstant) \
      85             :   V(AllocateInOldSpaceStubConstant) \
      86             :   V(ArrayConstructorStubConstant)   \
      87             :   V(BooleanMapConstant)             \
      88             :   V(ToNumberBuiltinConstant)        \
      89             :   V(EmptyFixedArrayConstant)        \
      90             :   V(EmptyStringConstant)            \
      91             :   V(FixedArrayMapConstant)          \
      92             :   V(PropertyArrayMapConstant)       \
      93             :   V(FixedDoubleArrayMapConstant)    \
      94             :   V(HeapNumberMapConstant)          \
      95             :   V(OptimizedOutConstant)           \
      96             :   V(StaleRegisterConstant)          \
      97             :   V(UndefinedConstant)              \
      98             :   V(TheHoleConstant)                \
      99             :   V(TrueConstant)                   \
     100             :   V(FalseConstant)                  \
     101             :   V(NullConstant)                   \
     102             :   V(ZeroConstant)                   \
     103             :   V(OneConstant)                    \
     104             :   V(NaNConstant)                    \
     105             :   V(MinusOneConstant)               \
     106             :   V(EmptyStateValues)               \
     107             :   V(SingleDeadTypedStateValues)
     108             : 
     109             : // Cached global node accessor methods.
     110             : #define DECLARE_GETTER(name) Node* name();
     111             :   CACHED_GLOBAL_LIST(DECLARE_GETTER)
     112             : #undef DECLARE_FIELD
     113             : 
     114             :  private:
     115             :   Isolate* isolate_;
     116             :   JSOperatorBuilder* javascript_;
     117             :   SimplifiedOperatorBuilder* simplified_;
     118             : 
     119             : #define CACHED_CENTRY_LIST(V) \
     120             :   V(CEntryStub1Constant)      \
     121             :   V(CEntryStub2Constant)      \
     122             :   V(CEntryStub3Constant)      \
     123             :   V(CEntryStub1WithBuiltinExitFrameConstant)
     124             : 
     125             : // Canonicalized global node fields.
     126             : #define DECLARE_FIELD(name) Node* name##_ = nullptr;
     127             :   CACHED_GLOBAL_LIST(DECLARE_FIELD)
     128             :   CACHED_CENTRY_LIST(DECLARE_FIELD)
     129             : #undef DECLARE_FIELD
     130             : 
     131             :   // Internal helper to canonicalize a number constant.
     132             :   Node* NumberConstant(double value);
     133             : 
     134             :   DISALLOW_COPY_AND_ASSIGN(JSGraph);
     135             : };
     136             : 
     137             : }  // namespace compiler
     138             : }  // namespace internal
     139             : }  // namespace v8
     140             : 
     141             : #endif  // V8_COMPILER_JS_GRAPH_H_

Generated by: LCOV version 1.10