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

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: Added unittests and addressed review comments 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.
45 Node* BuildLoadImmutableObjectField(Node* object, int offset);
46
47 // Builders for accessing the function context.
rmcilroy 2015/11/09 15:23:00 Fix comment
mythria 2015/11/10 09:55:35 Done.
48 Node* BuildLoadFeedbackVector();
49
50 // Helper function for creating a pair of feedback vector and slot.
rmcilroy 2015/11/09 15:23:00 /s/pair of feedback vector and slot./pair containi
mythria 2015/11/10 09:55:35 Done.
51 // Named and keyed loads require a VectorSlotPair for successful lowering.
rmcilroy 2015/11/09 15:23:00 no need for second line of comment (there are a bu
mythria 2015/11/10 09:55:35 Done.
52 VectorSlotPair CreateVectorSlotPair(FeedbackVectorSlot slot);
53 VectorSlotPair CreateVectorSlotPair(int slot_id);
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,
68 const interpreter::BytecodeArrayIterator& iterator); 94 const interpreter::BytecodeArrayIterator& iterator);
69 95
96 void BuildNamedLoad(const interpreter::BytecodeArrayIterator& iterator);
97
70 // Growth increment for the temporary buffer used to construct input lists to 98 // Growth increment for the temporary buffer used to construct input lists to
71 // new nodes. 99 // new nodes.
72 static const int kInputBufferSizeIncrement = 64; 100 static const int kInputBufferSizeIncrement = 64;
73 101
74 // Field accessors 102 // Field accessors
75 CommonOperatorBuilder* common() const { return jsgraph_->common(); } 103 CommonOperatorBuilder* common() const { return jsgraph_->common(); }
76 Zone* graph_zone() const { return graph()->zone(); } 104 Zone* graph_zone() const { return graph()->zone(); }
77 CompilationInfo* info() const { return info_; } 105 CompilationInfo* info() const { return info_; }
78 JSGraph* jsgraph() const { return jsgraph_; } 106 JSGraph* jsgraph() const { return jsgraph_; }
79 JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); } 107 JSOperatorBuilder* javascript() const { return jsgraph_->javascript(); }
80 Zone* local_zone() const { return local_zone_; } 108 Zone* local_zone() const { return local_zone_; }
81 const Handle<BytecodeArray>& bytecode_array() const { 109 const Handle<BytecodeArray>& bytecode_array() const {
82 return bytecode_array_; 110 return bytecode_array_;
83 } 111 }
84 112
85 LanguageMode language_mode() const { 113 LanguageMode language_mode() const {
86 // TODO(oth): need to propagate language mode through 114 // TODO(mythria): info() should not be used here.
rmcilroy 2015/11/09 15:23:00 /s/info() should not be used here/Don't rely on pa
mythria 2015/11/10 09:55:35 Done.
87 return LanguageMode::SLOPPY; 115 return info()->language_mode();
88 } 116 }
89 117
90 #define DECLARE_VISIT_BYTECODE(name, ...) \ 118 #define DECLARE_VISIT_BYTECODE(name, ...) \
91 void Visit##name(const interpreter::BytecodeArrayIterator& iterator); 119 void Visit##name(const interpreter::BytecodeArrayIterator& iterator);
92 BYTECODE_LIST(DECLARE_VISIT_BYTECODE) 120 BYTECODE_LIST(DECLARE_VISIT_BYTECODE)
93 #undef DECLARE_VISIT_BYTECODE 121 #undef DECLARE_VISIT_BYTECODE
94 122
95 Zone* local_zone_; 123 Zone* local_zone_;
96 CompilationInfo* info_; 124 CompilationInfo* info_;
97 JSGraph* jsgraph_; 125 JSGraph* jsgraph_;
98 Handle<BytecodeArray> bytecode_array_; 126 Handle<BytecodeArray> bytecode_array_;
99 Environment* environment_; 127 Environment* environment_;
100 128
101 // Temporary storage for building node input lists. 129 // Temporary storage for building node input lists.
102 int input_buffer_size_; 130 int input_buffer_size_;
103 Node** input_buffer_; 131 Node** input_buffer_;
104 132
105 // Nodes representing values in the activation record. 133 // Nodes representing values in the activation record.
106 SetOncePointer<Node> function_context_; 134 SetOncePointer<Node> function_context_;
135 SetOncePointer<Node> function_closure_;
136
137 // Optimization to cache loaded feedback vector.
138 SetOncePointer<Node> feedback_vector_;
107 139
108 // Control nodes that exit the function body. 140 // Control nodes that exit the function body.
109 ZoneVector<Node*> exit_controls_; 141 ZoneVector<Node*> exit_controls_;
110 142
111 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder); 143 DISALLOW_COPY_AND_ASSIGN(BytecodeGraphBuilder);
112 }; 144 };
113 145
114 146
115 class BytecodeGraphBuilder::Environment : public ZoneObject { 147 class BytecodeGraphBuilder::Environment : public ZoneObject {
116 public: 148 public:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 NodeVector values_; 197 NodeVector values_;
166 int register_base_; 198 int register_base_;
167 }; 199 };
168 200
169 201
170 } // namespace compiler 202 } // namespace compiler
171 } // namespace internal 203 } // namespace internal
172 } // namespace v8 204 } // namespace v8
173 205
174 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_ 206 #endif // V8_COMPILER_BYTECODE_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/bytecode-graph-builder.cc » ('j') | src/compiler/bytecode-graph-builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698