Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(945)

Side by Side Diff: src/compiler/bytecode-graph-builder.h

Issue 1419373007: [Interpreter] Adds implementation of bytecode graph builder for LoadICSloppy/Strict (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moved graph generation from bytecode into helper, so that all graph generation is at one place. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
rmcilroy 2015/11/10 18:00:15 nit - you only have the immutable version here - u
mythria 2015/11/11 13:39:24 Done.
45 Node* BuildLoadImmutableObjectField(Node* object, int offset);
46
47 // Builder for accessing type feedback vector.
48 Node* BuildLoadFeedbackVector();
49
50 // Helper function for creating a pair containing type feedback vector and
51 // a feedback slot.
52 VectorSlotPair CreateVectorSlotPair(int slot_id);
53
54 // Builds deoptimization for a given node.
rmcilroy 2015/11/10 18:00:15 nit - not sure what you mean by "Builds deoptimiza
mythria 2015/11/11 13:39:24 Removed this function as discussed in today's meet
55 // TODO(mythria): Current implementation introduces empty frames. Replace
56 // them with actual frame states.
57 void PrepareFrameState(Node* node);
58
39 void set_environment(Environment* env) { environment_ = env; } 59 void set_environment(Environment* env) { environment_ = env; }
40 const Environment* environment() const { return environment_; } 60 const Environment* environment() const { return environment_; }
41 Environment* environment() { return environment_; } 61 Environment* environment() { return environment_; }
42 62
43 // Node creation helpers 63 // Node creation helpers
44 Node* NewNode(const Operator* op, bool incomplete = false) { 64 Node* NewNode(const Operator* op, bool incomplete = false) {
45 return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); 65 return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete);
46 } 66 }
47 67
48 Node* NewNode(const Operator* op, Node* n1) { 68 Node* NewNode(const Operator* op, Node* n1) {
49 Node* buffer[] = {n1}; 69 Node* buffer[] = {n1};
50 return MakeNode(op, arraysize(buffer), buffer, false); 70 return MakeNode(op, arraysize(buffer), buffer, false);
51 } 71 }
52 72
53 Node* NewNode(const Operator* op, Node* n1, Node* n2) { 73 Node* NewNode(const Operator* op, Node* n1, Node* n2) {
54 Node* buffer[] = {n1, n2}; 74 Node* buffer[] = {n1, n2};
55 return MakeNode(op, arraysize(buffer), buffer, false); 75 return MakeNode(op, arraysize(buffer), buffer, false);
56 } 76 }
57 77
78 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) {
79 Node* buffer[] = {n1, n2, n3};
80 return MakeNode(op, arraysize(buffer), buffer, false);
81 }
82
58 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs, 83 Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs,
59 bool incomplete); 84 bool incomplete);
60 85
61 Node* MergeControl(Node* control, Node* other); 86 Node* MergeControl(Node* control, Node* other);
62 87
63 Node** EnsureInputBufferSize(int size); 88 Node** EnsureInputBufferSize(int size);
64 89
65 void UpdateControlDependencyToLeaveFunction(Node* exit); 90 void UpdateControlDependencyToLeaveFunction(Node* exit);
66 91
67 void BuildBinaryOp(const Operator* op, 92 void BuildBinaryOp(const Operator* op,
68 const interpreter::BytecodeArrayIterator& iterator); 93 const interpreter::BytecodeArrayIterator& iterator);
69 94
95 void BuildNamedLoad(const interpreter::BytecodeArrayIterator& iterator);
96
70 // Growth increment for the temporary buffer used to construct input lists to 97 // Growth increment for the temporary buffer used to construct input lists to
71 // new nodes. 98 // new nodes.
72 static const int kInputBufferSizeIncrement = 64; 99 static const int kInputBufferSizeIncrement = 64;
73 100
74 // Field accessors 101 // Field accessors
75 CommonOperatorBuilder* common() const { return jsgraph_->common(); } 102 CommonOperatorBuilder* common() const { return jsgraph_->common(); }
76 Zone* graph_zone() const { return graph()->zone(); } 103 Zone* graph_zone() const { return graph()->zone(); }
77 CompilationInfo* info() const { return info_; } 104 CompilationInfo* info() const { return info_; }
78 JSGraph* jsgraph() const { return jsgraph_; } 105 JSGraph* jsgraph() const { return jsgraph_; }
79 JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); } 106 JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); }
80 Zone* local_zone() const { return local_zone_; } 107 Zone* local_zone() const { return local_zone_; }
81 const Handle<BytecodeArray>& bytecode_array() const { 108 const Handle<BytecodeArray>& bytecode_array() const {
82 return bytecode_array_; 109 return bytecode_array_;
83 } 110 }
84 111
85 LanguageMode language_mode() const { 112 LanguageMode language_mode() const {
86 // TODO(oth): need to propagate language mode through 113 // TODO(mythria): Don't rely on parse information to get language mode.
87 return LanguageMode::SLOPPY; 114 return info()->language_mode();
88 } 115 }
89 116
90 #define DECLARE_VISIT_BYTECODE(name, ...) \ 117 #define DECLARE_VISIT_BYTECODE(name, ...) \
91 void Visit##name(const interpreter::BytecodeArrayIterator& iterator); 118 void Visit##name(const interpreter::BytecodeArrayIterator& iterator);
92 BYTECODE_LIST(DECLARE_VISIT_BYTECODE) 119 BYTECODE_LIST(DECLARE_VISIT_BYTECODE)
93 #undef DECLARE_VISIT_BYTECODE 120 #undef DECLARE_VISIT_BYTECODE
94 121
95 Zone* local_zone_; 122 Zone* local_zone_;
96 CompilationInfo* info_; 123 CompilationInfo* info_;
97 JSGraph* jsgraph_; 124 JSGraph* jsgraph_;
98 Handle<BytecodeArray> bytecode_array_; 125 Handle<BytecodeArray> bytecode_array_;
99 Environment* environment_; 126 Environment* environment_;
100 127
101 // Temporary storage for building node input lists. 128 // Temporary storage for building node input lists.
102 int input_buffer_size_; 129 int input_buffer_size_;
103 Node** input_buffer_; 130 Node** input_buffer_;
104 131
105 // Nodes representing values in the activation record. 132 // Nodes representing values in the activation record.
106 SetOncePointer<Node> function_context_; 133 SetOncePointer<Node> function_context_;
134 SetOncePointer<Node> function_closure_;
135
136 // Optimization to cache loaded feedback vector.
137 SetOncePointer<Node> feedback_vector_;
107 138
108 // Control nodes that exit the function body. 139 // Control nodes that exit the function body.
109 ZoneVector<Node*> exit_controls_; 140 ZoneVector<Node*> exit_controls_;
110 141
111 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); 142 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder);
112 }; 143 };
113 144
114 145
115 class BytecodeGraphBuilder::Environment : public ZoneObject { 146 class BytecodeGraphBuilder::Environment : public ZoneObject {
116 public: 147 public:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 NodeVector values_; 196 NodeVector values_;
166 int register_base_; 197 int register_base_;
167 }; 198 };
168 199
169 200
170 } // namespace compiler 201 } // namespace compiler
171 } // namespace internal 202 } // namespace internal
172 } // namespace v8 203 } // namespace v8
173 204
174 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ 205 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/bytecode-graph-builder.cc » ('j') | test/unittests/compiler/bytecode-graph-builder-unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698