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

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

Issue 9586024: Add Load/Store Static/Instance fields. (Closed) Base URL: http://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
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 11 matching lines...) Expand all
22 // <Value> 22 // <Value>
23 // | AssertAssignable <Value> <AbstractType> 23 // | AssertAssignable <Value> <AbstractType>
24 // | InstanceCall <AstNode> <String> <Value> ... 24 // | InstanceCall <AstNode> <String> <Value> ...
25 // | StaticCall <StaticCallNode> <Value> ... 25 // | StaticCall <StaticCallNode> <Value> ...
26 // | LoadLocal <LocalVariable> 26 // | LoadLocal <LocalVariable>
27 // | StoreLocal <LocalVariable> <Value> 27 // | StoreLocal <LocalVariable> <Value>
28 // | StrictCompare <Token::kind> <Value> <Value> 28 // | StrictCompare <Token::kind> <Value> <Value>
29 // | NativeCall <NativeBodyNode> 29 // | NativeCall <NativeBodyNode>
30 // | StoreIndexed <StoreIndexedNode> <Value> <Value> <Value> 30 // | StoreIndexed <StoreIndexedNode> <Value> <Value> <Value>
31 // | InstanceSetter <InstanceSetterNode> <Value> <Value> 31 // | InstanceSetter <InstanceSetterNode> <Value> <Value>
32 // | LoadInstanceField <LoadInstanceFieldNode> <Value>
33 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value>
34 // | LoadStaticField <Field>
35 // | StoreStaticField <StoreStaticFieldNode> <Value>
32 // 36 //
33 // <Value> ::= 37 // <Value> ::=
34 // Temp <int> 38 // Temp <int>
35 // | Constant <Instance> 39 // | Constant <Instance>
36 40
37 // M is a two argument macro. It is applied to each concrete value's 41 // M is a two argument macro. It is applied to each concrete value's
38 // typename and classname. 42 // typename and classname.
39 #define FOR_EACH_VALUE(M) \ 43 #define FOR_EACH_VALUE(M) \
40 M(Temp, TempVal) \ 44 M(Temp, TempVal) \
41 M(Constant, ConstantVal) \ 45 M(Constant, ConstantVal) \
42 46
43 47
44 // M is a two argument macro. It is applied to each concrete instruction's 48 // M is a two argument macro. It is applied to each concrete instruction's
45 // (including the values) typename and classname. 49 // (including the values) typename and classname.
46 #define FOR_EACH_COMPUTATION(M) \ 50 #define FOR_EACH_COMPUTATION(M) \
47 FOR_EACH_VALUE(M) \ 51 FOR_EACH_VALUE(M) \
48 M(AssertAssignable, AssertAssignableComp) \ 52 M(AssertAssignable, AssertAssignableComp) \
49 M(InstanceCall, InstanceCallComp) \ 53 M(InstanceCall, InstanceCallComp) \
50 M(StaticCall, StaticCallComp) \ 54 M(StaticCall, StaticCallComp) \
51 M(LoadLocal, LoadLocalComp) \ 55 M(LoadLocal, LoadLocalComp) \
52 M(StoreLocal, StoreLocalComp) \ 56 M(StoreLocal, StoreLocalComp) \
53 M(StrictCompare, StrictCompareComp) \ 57 M(StrictCompare, StrictCompareComp) \
54 M(NativeCall, NativeCallComp) \ 58 M(NativeCall, NativeCallComp) \
55 M(StoreIndexed, StoreIndexedComp) \ 59 M(StoreIndexed, StoreIndexedComp) \
56 M(InstanceSetter, InstanceSetterComp) \ 60 M(InstanceSetter, InstanceSetterComp) \
61 M(LoadInstanceField, LoadInstanceFieldComp) \
62 M(StoreInstanceField, StoreInstanceFieldComp) \
63 M(LoadStaticField, LoadStaticFieldComp) \
64 M(StoreStaticField, StoreStaticFieldComp)
57 65
58 66
59 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 67 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
60 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 68 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
61 #undef FORWARD_DECLARATION 69 #undef FORWARD_DECLARATION
62 70
63 class Computation : public ZoneAllocated { 71 class Computation : public ZoneAllocated {
64 public: 72 public:
65 Computation() { } 73 Computation() { }
66 74
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return ast_node_.native_c_function_name(); 286 return ast_node_.native_c_function_name();
279 } 287 }
280 288
281 private: 289 private:
282 const NativeBodyNode& ast_node_; 290 const NativeBodyNode& ast_node_;
283 291
284 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); 292 DISALLOW_COPY_AND_ASSIGN(NativeCallComp);
285 }; 293 };
286 294
287 295
296 class LoadInstanceFieldComp : public Computation {
297 public:
298 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance)
299 : ast_node_(*ast_node), instance_(instance) {
300 ASSERT(instance_ != NULL);
301 }
302
303 DECLARE_COMPUTATION(LoadInstanceFieldComp)
304
305 const Field& field() const { return ast_node_.field(); }
306
307 Value* instance() const { return instance_; }
308
309 private:
310 const LoadInstanceFieldNode& ast_node_;
311 Value* instance_;
312
313 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp);
314 };
315
316
317 class StoreInstanceFieldComp : public Computation {
318 public:
319 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node,
320 Value* instance,
321 Value* value)
322 : ast_node_(*ast_node), instance_(instance), value_(value) {
323 ASSERT(instance_ != NULL);
324 ASSERT(value_ != NULL);
325 }
326
327 DECLARE_COMPUTATION(StoreInstanceFieldComp)
328
329 intptr_t node_id() const { return ast_node_.id(); }
330 intptr_t token_index() const { return ast_node_.token_index(); }
331 const Field& field() const { return ast_node_.field(); }
332
333 Value* instance() const { return instance_; }
334 Value* value() const { return value_; }
335
336 private:
337 const StoreInstanceFieldNode& ast_node_;
338 Value* instance_;
339 Value* value_;
340
341 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp);
342 };
343
344
345 class LoadStaticFieldComp : public Computation {
346 public:
347 explicit LoadStaticFieldComp(const Field& field) : field_(field) {}
348
349 DECLARE_COMPUTATION(LoadStaticFieldComp);
350
351 const Field& field() const { return field_; }
352
353 private:
354 const Field& field_;
355
356 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp);
357 };
358
359
360 class StoreStaticFieldComp : public Computation {
361 public:
362 StoreStaticFieldComp(StoreStaticFieldNode* ast_node, Value* value)
363 : ast_node_(*ast_node), value_(value) {
364 ASSERT(value != NULL);
365 }
366
367 DECLARE_COMPUTATION(StoreStaticFieldComp);
368
369 intptr_t token_index() const { return ast_node_.token_index(); }
370 intptr_t node_id() const { return ast_node_.id(); }
371 const Field& field() const { return ast_node_.field(); }
372 Value* value() const { return value_; }
373
374 private:
375 const StoreStaticFieldNode& ast_node_;
376 Value* value_;
377
378 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp);
379 };
380
381
288 // Not simply an InstanceCall because it has somewhat more complicated 382 // Not simply an InstanceCall because it has somewhat more complicated
289 // semantics: the value operand is preserved before the call. 383 // semantics: the value operand is preserved before the call.
290 class StoreIndexedComp : public Computation { 384 class StoreIndexedComp : public Computation {
291 public: 385 public:
292 StoreIndexedComp(StoreIndexedNode* node, 386 StoreIndexedComp(StoreIndexedNode* node,
293 Value* array, 387 Value* array,
294 Value* index, 388 Value* index,
295 Value* value) 389 Value* value)
296 : ast_node_(*node), 390 : ast_node_(*node),
297 array_(array), 391 array_(array),
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 #undef DECLARE_VISIT_INSTRUCTION 713 #undef DECLARE_VISIT_INSTRUCTION
620 714
621 private: 715 private:
622 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 716 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
623 }; 717 };
624 718
625 719
626 } // namespace dart 720 } // namespace dart
627 721
628 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 722 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « 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