V8 Project
graph-reducer.h
Go to the documentation of this file.
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_GRAPH_REDUCER_H_
6 #define V8_COMPILER_GRAPH_REDUCER_H_
7 
8 #include "src/zone-containers.h"
9 
10 namespace v8 {
11 namespace internal {
12 namespace compiler {
13 
14 // Forward declarations.
15 class Graph;
16 class Node;
17 
18 
19 // Represents the result of trying to reduce a node in the graph.
20 class Reduction FINAL {
21  public:
22  explicit Reduction(Node* replacement = NULL) : replacement_(replacement) {}
23 
24  Node* replacement() const { return replacement_; }
25  bool Changed() const { return replacement() != NULL; }
26 
27  private:
28  Node* replacement_;
29 };
30 
31 
32 // A reducer can reduce or simplify a given node based on its operator and
33 // inputs. This class functions as an extension point for the graph reducer for
34 // language-specific reductions (e.g. reduction based on types or constant
35 // folding of low-level operators) can be integrated into the graph reduction
36 // phase.
37 class Reducer {
38  public:
39  Reducer() {}
40  virtual ~Reducer() {}
41 
42  // Try to reduce a node if possible.
43  virtual Reduction Reduce(Node* node) = 0;
44 
45  // Helper functions for subclasses to produce reductions for a node.
46  static Reduction NoChange() { return Reduction(); }
47  static Reduction Replace(Node* node) { return Reduction(node); }
48  static Reduction Changed(Node* node) { return Reduction(node); }
49 
50  private:
52 };
53 
54 
55 // Performs an iterative reduction of a node graph.
56 class GraphReducer FINAL {
57  public:
58  explicit GraphReducer(Graph* graph);
59 
60  Graph* graph() const { return graph_; }
61 
62  void AddReducer(Reducer* reducer) { reducers_.push_back(reducer); }
63 
64  // Reduce a single node.
65  void ReduceNode(Node* node);
66  // Reduce the whole graph.
67  void ReduceGraph();
68 
69  private:
72 
73  DISALLOW_COPY_AND_ASSIGN(GraphReducer);
74 };
75 
76 } // namespace compiler
77 } // namespace internal
78 } // namespace v8
79 
80 #endif // V8_COMPILER_GRAPH_REDUCER_H_
Reduction(Node *replacement=NULL)
Definition: graph-reducer.h:22
ZoneVector< Reducer * > reducers_
Definition: graph-reducer.h:71
void AddReducer(Reducer *reducer)
Definition: graph-reducer.h:62
DISALLOW_COPY_AND_ASSIGN(GraphReducer)
static Reduction Replace(Node *node)
Definition: graph-reducer.h:47
static Reduction Changed(Node *node)
Definition: graph-reducer.h:48
virtual Reduction Reduce(Node *node)=0
#define FINAL
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20