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

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 9564006: Implement StaticCall and InstanceCall in the new code generator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h"
9 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
10 #include "vm/handles_impl.h" 11 #include "vm/handles_impl.h"
11 #include "vm/object.h" 12 #include "vm/object.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 class FlowGraphVisitor; 16 class FlowGraphVisitor;
16 class LocalVariable; 17 class LocalVariable;
17 18
18 // Computations and values. 19 // Computations and values.
19 // 20 //
20 // <Computation> ::= <Value> 21 // <Computation> ::=
21 // | AssertAssignable <Value> <AbstractType> 22 // <Value>
22 // | InstanceCall <cstring> <Value> ... 23 // | AssertAssignable <Value> <AbstractType>
23 // | StaticCall <Function> <Value> ... 24 // | InstanceCall <AstNode> <String> <Value> ...
24 // | LoadLocal <LocalVariable> 25 // | StaticCall <StaticCallNode> <Value> ...
25 // | StoreLocal <LocalVariable> <Value> 26 // | LoadLocal <LocalVariable>
26 // | StrictCompare <Token::kind> <Value> <Value> 27 // | StoreLocal <LocalVariable> <Value>
28 // | StrictCompare <Token::kind> <Value> <Value>
27 // 29 //
28 // <Value> ::= Temp <int> 30 // <Value> ::=
29 // | Constant <Instance> 31 // Temp <int>
32 // | Constant <Instance>
30 33
31 // M is a two argument macro. It is applied to each concrete value's 34 // M is a two argument macro. It is applied to each concrete value's
32 // typename and classname. 35 // typename and classname.
33 #define FOR_EACH_VALUE(M) \ 36 #define FOR_EACH_VALUE(M) \
34 M(Temp, TempVal) \ 37 M(Temp, TempVal) \
35 M(Constant, ConstantVal) 38 M(Constant, ConstantVal)
36 39
37 // M is a two argument macro. It is applied to each concrete instruction's 40 // M is a two argument macro. It is applied to each concrete instruction's
38 // (including the values) typename and classname. 41 // (including the values) typename and classname.
39 #define FOR_EACH_COMPUTATION(M) \ 42 #define FOR_EACH_COMPUTATION(M) \
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 private: 138 private:
136 Value* value_; 139 Value* value_;
137 const AbstractType& type_; 140 const AbstractType& type_;
138 141
139 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); 142 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp);
140 }; 143 };
141 144
142 145
143 class InstanceCallComp : public Computation { 146 class InstanceCallComp : public Computation {
144 public: 147 public:
145 InstanceCallComp(const char* name, ZoneGrowableArray<Value*>* arguments) 148 InstanceCallComp(AstNode* node,
146 : name_(name), arguments_(arguments) { 149 const String& function_name,
150 ZoneGrowableArray<Value*>* arguments,
151 const Array& argument_names,
152 intptr_t checked_argument_count)
153 : ast_node_(*node),
154 function_name_(function_name),
155 arguments_(arguments),
156 argument_names_(argument_names),
157 checked_argument_count_(checked_argument_count) {
158 ASSERT(function_name.IsZoneHandle());
147 ASSERT(!arguments->is_empty()); 159 ASSERT(!arguments->is_empty());
160 ASSERT(argument_names.IsZoneHandle());
148 } 161 }
149 162
150 DECLARE_COMPUTATION(InstanceCall) 163 DECLARE_COMPUTATION(InstanceCall)
151 164
152 const char* name() const { return name_; } 165 // Accessors forwarded to the AST node.
166 intptr_t node_id() const { return ast_node_.id(); }
167 intptr_t token_index() const { return ast_node_.token_index(); }
168
169 const String& function_name() const { return function_name_; }
153 int ArgumentCount() const { return arguments_->length(); } 170 int ArgumentCount() const { return arguments_->length(); }
154 Value* ArgumentAt(int index) const { return (*arguments_)[index]; } 171 Value* ArgumentAt(int index) const { return (*arguments_)[index]; }
172 const Array& argument_names() const { return argument_names_; }
173 intptr_t checked_argument_count() const { return checked_argument_count_; }
155 174
156 private: 175 private:
157 const char* name_; 176 const AstNode& ast_node_;
158 ZoneGrowableArray<Value*>* arguments_; 177 const String& function_name_;
178 ZoneGrowableArray<Value*>* const arguments_;
179 const Array& argument_names_;
180 const intptr_t checked_argument_count_;
159 181
160 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); 182 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp);
161 }; 183 };
162 184
163 185
164 class StrictCompareComp : public Computation { 186 class StrictCompareComp : public Computation {
165 public: 187 public:
166 StrictCompareComp(Token::Kind kind, Value* left, Value* right) 188 StrictCompareComp(Token::Kind kind, Value* left, Value* right)
167 : kind_(kind), left_(left), right_(right) { 189 : kind_(kind), left_(left), right_(right) {
168 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); 190 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT));
169 } 191 }
170 192
171 DECLARE_COMPUTATION(StrictCompare) 193 DECLARE_COMPUTATION(StrictCompare)
172 194
173 Token::Kind kind() const { return kind_; } 195 Token::Kind kind() const { return kind_; }
174 Value* left() const { return left_; } 196 Value* left() const { return left_; }
175 Value* right() const { return right_; } 197 Value* right() const { return right_; }
176 198
177 private: 199 private:
178 const Token::Kind kind_; 200 const Token::Kind kind_;
179 Value* left_; 201 Value* left_;
180 Value* right_; 202 Value* right_;
181 203
182 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); 204 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
183 }; 205 };
184 206
185 207
186 class StaticCallComp : public Computation { 208 class StaticCallComp : public Computation {
187 public: 209 public:
188 StaticCallComp(const Function& function, ZoneGrowableArray<Value*>* arguments) 210 StaticCallComp(StaticCallNode* node, ZoneGrowableArray<Value*>* arguments)
189 : function_(function), arguments_(arguments) { 211 : ast_node_(*node), arguments_(arguments) { }
190 ASSERT(function.IsZoneHandle());
191 }
192 212
193 DECLARE_COMPUTATION(StaticCall) 213 DECLARE_COMPUTATION(StaticCall)
194 214
195 const Function& function() const { return function_; } 215 // Accessors forwarded to the AST node.
216 const Function& function() const { return ast_node_.function(); }
217 const Array& argument_names() const { return ast_node_.arguments()->names(); }
218 intptr_t token_index() const { return ast_node_.token_index(); }
219
196 int ArgumentCount() const { return arguments_->length(); } 220 int ArgumentCount() const { return arguments_->length(); }
197 Value* ArgumentAt(int index) const { return (*arguments_)[index]; } 221 Value* ArgumentAt(int index) const { return (*arguments_)[index]; }
198 222
199 private: 223 private:
200 const Function& function_; 224 const StaticCallNode& ast_node_;
201 ZoneGrowableArray<Value*>* arguments_; 225 ZoneGrowableArray<Value*>* arguments_;
202 226
203 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); 227 DISALLOW_COPY_AND_ASSIGN(StaticCallComp);
204 }; 228 };
205 229
206 230
207 class LoadLocalComp : public Computation { 231 class LoadLocalComp : public Computation {
208 public: 232 public:
209 explicit LoadLocalComp(const LocalVariable& local) : local_(local) { } 233 explicit LoadLocalComp(const LocalVariable& local) : local_(local) { }
210 234
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 #undef DECLARE_VISIT_INSTRUCTION 531 #undef DECLARE_VISIT_INSTRUCTION
508 532
509 private: 533 private:
510 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 534 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
511 }; 535 };
512 536
513 537
514 } // namespace dart 538 } // namespace dart
515 539
516 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 540 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/flow_graph_compiler_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698