OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
6 #define V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
7 | 7 |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/interpreter/bytecode-array-iterator.h" | 10 #include "src/interpreter/bytecode-array-iterator.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 BytecodeGraphBuilder(Zone* local_zone, CompilationInfo* info, | 21 BytecodeGraphBuilder(Zone* local_zone, CompilationInfo* info, |
22 JSGraph* jsgraph); | 22 JSGraph* jsgraph); |
23 | 23 |
24 // Creates a graph by visiting bytecodes. | 24 // Creates a graph by visiting bytecodes. |
25 bool CreateGraph(bool stack_check = true); | 25 bool CreateGraph(bool stack_check = true); |
26 | 26 |
27 Graph* graph() const { return jsgraph_->graph(); } | 27 Graph* graph() const { return jsgraph_->graph(); } |
28 | 28 |
29 private: | 29 private: |
30 class Environment; | 30 class Environment; |
| 31 class FrameStateBeforeAndAfter; |
31 | 32 |
32 void CreateGraphBody(bool stack_check); | 33 void CreateGraphBody(bool stack_check); |
33 void VisitBytecodes(); | 34 void VisitBytecodes(); |
34 | 35 |
35 Node* LoadAccumulator(Node* value); | 36 Node* LoadAccumulator(Node* value); |
36 | 37 |
| 38 // Get or create the node that represents the outer function closure. |
| 39 Node* GetFunctionClosure(); |
| 40 |
| 41 // Get or create the node that represents the outer function context. |
37 Node* GetFunctionContext(); | 42 Node* GetFunctionContext(); |
38 | 43 |
| 44 // Builders for accessing a (potentially immutable) object field. |
| 45 Node* BuildLoadImmutableObjectField(Node* object, int offset); |
| 46 Node* BuildLoadObjectField(Node* object, int offset); |
| 47 |
| 48 // Builders for accessing the function context. |
| 49 Node* BuildLoadFeedbackVector(); |
| 50 |
| 51 // Helper function for creating a pair of feedback vector and slot. |
| 52 // Named and keyed loads require a VectorSlotPair for successful lowering. |
| 53 VectorSlotPair CreateVectorSlotPair(FeedbackVectorSlot slot); |
| 54 |
| 55 // Builds deoptimization for a given node. |
| 56 // TODO(mythria) Current implementation introduces empty frames. Replace |
| 57 // them with actual frame states. |
| 58 void PrepareFrameState(Node* node); |
| 59 |
39 void set_environment(Environment* env) { environment_ = env; } | 60 void set_environment(Environment* env) { environment_ = env; } |
40 const Environment* environment() const { return environment_; } | 61 const Environment* environment() const { return environment_; } |
41 Environment* environment() { return environment_; } | 62 Environment* environment() { return environment_; } |
42 | 63 |
43 // Node creation helpers | 64 // Node creation helpers |
44 Node* NewNode(const Operator* op, bool incomplete = false) { | 65 Node* NewNode(const Operator* op, bool incomplete = false) { |
45 return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); | 66 return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); |
46 } | 67 } |
47 | 68 |
48 Node* NewNode(const Operator* op, Node* n1) { | 69 Node* NewNode(const Operator* op, Node* n1) { |
49 Node* buffer[] = {n1}; | 70 Node* buffer[] = {n1}; |
50 return MakeNode(op, arraysize(buffer), buffer, false); | 71 return MakeNode(op, arraysize(buffer), buffer, false); |
51 } | 72 } |
52 | 73 |
53 Node* NewNode(const Operator* op, Node* n1, Node* n2) { | 74 Node* NewNode(const Operator* op, Node* n1, Node* n2) { |
54 Node* buffer[] = {n1, n2}; | 75 Node* buffer[] = {n1, n2}; |
55 return MakeNode(op, arraysize(buffer), buffer, false); | 76 return MakeNode(op, arraysize(buffer), buffer, false); |
56 } | 77 } |
57 | 78 |
| 79 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) { |
| 80 Node* buffer[] = {n1, n2, n3}; |
| 81 return MakeNode(op, arraysize(buffer), buffer, false); |
| 82 } |
| 83 |
58 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, | 84 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, |
59 bool incomplete); | 85 bool incomplete); |
60 | 86 |
61 Node* MergeControl(Node* control, Node* other); | 87 Node* MergeControl(Node* control, Node* other); |
62 | 88 |
63 Node** EnsureInputBufferSize(int size); | 89 Node** EnsureInputBufferSize(int size); |
64 | 90 |
65 void UpdateControlDependencyToLeaveFunction(Node* exit); | 91 void UpdateControlDependencyToLeaveFunction(Node* exit); |
66 | 92 |
67 void BuildBinaryOp(const Operator* op, | 93 void BuildBinaryOp(const Operator* op, |
(...skipping 29 matching lines...) Expand all Loading... |
97 JSGraph* jsgraph_; | 123 JSGraph* jsgraph_; |
98 Handle<BytecodeArray> bytecode_array_; | 124 Handle<BytecodeArray> bytecode_array_; |
99 Environment* environment_; | 125 Environment* environment_; |
100 | 126 |
101 // Temporary storage for building node input lists. | 127 // Temporary storage for building node input lists. |
102 int input_buffer_size_; | 128 int input_buffer_size_; |
103 Node** input_buffer_; | 129 Node** input_buffer_; |
104 | 130 |
105 // Nodes representing values in the activation record. | 131 // Nodes representing values in the activation record. |
106 SetOncePointer<Node> function_context_; | 132 SetOncePointer<Node> function_context_; |
| 133 SetOncePointer<Node> function_closure_; |
| 134 |
| 135 // Optimization to cache loaded feedback vector. |
| 136 SetOncePointer<Node> feedback_vector_; |
107 | 137 |
108 // Control nodes that exit the function body. | 138 // Control nodes that exit the function body. |
109 ZoneVector<Node*> exit_controls_; | 139 ZoneVector<Node*> exit_controls_; |
110 | 140 |
111 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); | 141 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); |
112 }; | 142 }; |
113 | 143 |
114 | 144 |
115 class BytecodeGraphBuilder::Environment : public ZoneObject { | 145 class BytecodeGraphBuilder::Environment : public ZoneObject { |
116 public: | 146 public: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 NodeVector values_; | 195 NodeVector values_; |
166 int register_base_; | 196 int register_base_; |
167 }; | 197 }; |
168 | 198 |
169 | 199 |
170 } // namespace compiler | 200 } // namespace compiler |
171 } // namespace internal | 201 } // namespace internal |
172 } // namespace v8 | 202 } // namespace v8 |
173 | 203 |
174 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 204 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
OLD | NEW |