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 16 matching lines...) Expand all Loading... |
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 | 31 |
32 void CreateGraphBody(bool stack_check); | 32 void CreateGraphBody(bool stack_check); |
33 void VisitBytecodes(); | 33 void VisitBytecodes(); |
34 | 34 |
35 Node* LoadAccumulator(Node* value); | 35 Node* LoadAccumulator(Node* value); |
36 | 36 |
| 37 // Get or create the node that represents the outer function closure. |
| 38 Node* GetFunctionClosure(); |
| 39 |
| 40 // Get or create the node that represents the outer function context. |
37 Node* GetFunctionContext(); | 41 Node* GetFunctionContext(); |
38 | 42 |
| 43 // Builders for accessing an immutable object field. |
| 44 Node* BuildLoadImmutableObjectField(Node* object, int offset); |
| 45 |
| 46 // Builder for accessing type feedback vector. |
| 47 Node* BuildLoadFeedbackVector(); |
| 48 |
| 49 // Helper function for creating a pair containing type feedback vector and |
| 50 // a feedback slot. |
| 51 VectorSlotPair CreateVectorSlotPair(int slot_id); |
| 52 |
| 53 // Replaces the frame state inputs with empty frame states. |
| 54 void AddEmptyFrameStateInputs(Node* node); |
| 55 |
39 void set_environment(Environment* env) { environment_ = env; } | 56 void set_environment(Environment* env) { environment_ = env; } |
40 const Environment* environment() const { return environment_; } | 57 const Environment* environment() const { return environment_; } |
41 Environment* environment() { return environment_; } | 58 Environment* environment() { return environment_; } |
42 | 59 |
43 // Node creation helpers | 60 // Node creation helpers |
44 Node* NewNode(const Operator* op, bool incomplete = false) { | 61 Node* NewNode(const Operator* op, bool incomplete = false) { |
45 return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); | 62 return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); |
46 } | 63 } |
47 | 64 |
48 Node* NewNode(const Operator* op, Node* n1) { | 65 Node* NewNode(const Operator* op, Node* n1) { |
49 Node* buffer[] = {n1}; | 66 Node* buffer[] = {n1}; |
50 return MakeNode(op, arraysize(buffer), buffer, false); | 67 return MakeNode(op, arraysize(buffer), buffer, false); |
51 } | 68 } |
52 | 69 |
53 Node* NewNode(const Operator* op, Node* n1, Node* n2) { | 70 Node* NewNode(const Operator* op, Node* n1, Node* n2) { |
54 Node* buffer[] = {n1, n2}; | 71 Node* buffer[] = {n1, n2}; |
55 return MakeNode(op, arraysize(buffer), buffer, false); | 72 return MakeNode(op, arraysize(buffer), buffer, false); |
56 } | 73 } |
57 | 74 |
| 75 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) { |
| 76 Node* buffer[] = {n1, n2, n3}; |
| 77 return MakeNode(op, arraysize(buffer), buffer, false); |
| 78 } |
| 79 |
58 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, | 80 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, |
59 bool incomplete); | 81 bool incomplete); |
60 | 82 |
61 Node* MergeControl(Node* control, Node* other); | 83 Node* MergeControl(Node* control, Node* other); |
62 | 84 |
63 Node** EnsureInputBufferSize(int size); | 85 Node** EnsureInputBufferSize(int size); |
64 | 86 |
65 void UpdateControlDependencyToLeaveFunction(Node* exit); | 87 void UpdateControlDependencyToLeaveFunction(Node* exit); |
66 | 88 |
67 void BuildBinaryOp(const Operator* op, | 89 void BuildBinaryOp(const Operator* op, |
68 const interpreter::BytecodeArrayIterator& iterator); | 90 const interpreter::BytecodeArrayIterator& iterator); |
69 | 91 |
| 92 void BuildNamedLoad(const interpreter::BytecodeArrayIterator& iterator); |
| 93 |
70 // Growth increment for the temporary buffer used to construct input lists to | 94 // Growth increment for the temporary buffer used to construct input lists to |
71 // new nodes. | 95 // new nodes. |
72 static const int kInputBufferSizeIncrement = 64; | 96 static const int kInputBufferSizeIncrement = 64; |
73 | 97 |
74 // Field accessors | 98 // Field accessors |
75 CommonOperatorBuilder* common() const { return jsgraph_->common(); } | 99 CommonOperatorBuilder* common() const { return jsgraph_->common(); } |
76 Zone* graph_zone() const { return graph()->zone(); } | 100 Zone* graph_zone() const { return graph()->zone(); } |
77 CompilationInfo* info() const { return info_; } | 101 CompilationInfo* info() const { return info_; } |
78 JSGraph* jsgraph() const { return jsgraph_; } | 102 JSGraph* jsgraph() const { return jsgraph_; } |
79 JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); } | 103 JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); } |
80 Zone* local_zone() const { return local_zone_; } | 104 Zone* local_zone() const { return local_zone_; } |
81 const Handle<BytecodeArray>& bytecode_array() const { | 105 const Handle<BytecodeArray>& bytecode_array() const { |
82 return bytecode_array_; | 106 return bytecode_array_; |
83 } | 107 } |
84 | 108 |
85 LanguageMode language_mode() const { | 109 LanguageMode language_mode() const { |
86 // TODO(oth): need to propagate language mode through | 110 // TODO(mythria): Don't rely on parse information to get language mode. |
87 return LanguageMode::SLOPPY; | 111 return info()->language_mode(); |
88 } | 112 } |
89 | 113 |
90 #define DECLARE_VISIT_BYTECODE(name, ...) \ | 114 #define DECLARE_VISIT_BYTECODE(name, ...) \ |
91 void Visit##name(const interpreter::BytecodeArrayIterator& iterator); | 115 void Visit##name(const interpreter::BytecodeArrayIterator& iterator); |
92 BYTECODE_LIST(DECLARE_VISIT_BYTECODE) | 116 BYTECODE_LIST(DECLARE_VISIT_BYTECODE) |
93 #undef DECLARE_VISIT_BYTECODE | 117 #undef DECLARE_VISIT_BYTECODE |
94 | 118 |
95 Zone* local_zone_; | 119 Zone* local_zone_; |
96 CompilationInfo* info_; | 120 CompilationInfo* info_; |
97 JSGraph* jsgraph_; | 121 JSGraph* jsgraph_; |
98 Handle<BytecodeArray> bytecode_array_; | 122 Handle<BytecodeArray> bytecode_array_; |
99 Environment* environment_; | 123 Environment* environment_; |
100 | 124 |
101 // Temporary storage for building node input lists. | 125 // Temporary storage for building node input lists. |
102 int input_buffer_size_; | 126 int input_buffer_size_; |
103 Node** input_buffer_; | 127 Node** input_buffer_; |
104 | 128 |
105 // Nodes representing values in the activation record. | 129 // Nodes representing values in the activation record. |
106 SetOncePointer<Node> function_context_; | 130 SetOncePointer<Node> function_context_; |
| 131 SetOncePointer<Node> function_closure_; |
| 132 |
| 133 // Optimization to cache loaded feedback vector. |
| 134 SetOncePointer<Node> feedback_vector_; |
107 | 135 |
108 // Control nodes that exit the function body. | 136 // Control nodes that exit the function body. |
109 ZoneVector<Node*> exit_controls_; | 137 ZoneVector<Node*> exit_controls_; |
110 | 138 |
111 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); | 139 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); |
112 }; | 140 }; |
113 | 141 |
114 | 142 |
115 class BytecodeGraphBuilder::Environment : public ZoneObject { | 143 class BytecodeGraphBuilder::Environment : public ZoneObject { |
116 public: | 144 public: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 NodeVector values_; | 193 NodeVector values_; |
166 int register_base_; | 194 int register_base_; |
167 }; | 195 }; |
168 | 196 |
169 | 197 |
170 } // namespace compiler | 198 } // namespace compiler |
171 } // namespace internal | 199 } // namespace internal |
172 } // namespace v8 | 200 } // namespace v8 |
173 | 201 |
174 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ | 202 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ |
OLD | NEW |