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

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
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 10 matching lines...) Expand all
21 // <Computation> ::= 21 // <Computation> ::=
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 // | StoreIndexed <Value> <Value> <Value> <Value> 28 // | StoreIndexed <Value> <Value> <Value> <Value>
29 // | StrictCompare <Token::kind> <Value> <Value> 29 // | StrictCompare <Token::kind> <Value> <Value>
30 // | NativeCall <NativeBodyNode> 30 // | NativeCall <NativeBodyNode>
31 // | LoadInstanceField <LoadInstanceFieldNode> <Value>
32 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value>
33 // | LoadStaticField <Field>
34 // | StoreStaticField <StoreStaticFieldNode> <Value>
31 // 35 //
32 // <Value> ::= 36 // <Value> ::=
33 // Temp <int> 37 // Temp <int>
34 // | Constant <Instance> 38 // | Constant <Instance>
35 39
36 // M is a two argument macro. It is applied to each concrete value's 40 // M is a two argument macro. It is applied to each concrete value's
37 // typename and classname. 41 // typename and classname.
38 #define FOR_EACH_VALUE(M) \ 42 #define FOR_EACH_VALUE(M) \
39 M(Temp, TempVal) \ 43 M(Temp, TempVal) \
40 M(Constant, ConstantVal) \ 44 M(Constant, ConstantVal) \
41 45
42 46
43 // M is a two argument macro. It is applied to each concrete instruction's 47 // M is a two argument macro. It is applied to each concrete instruction's
44 // (including the values) typename and classname. 48 // (including the values) typename and classname.
45 #define FOR_EACH_COMPUTATION(M) \ 49 #define FOR_EACH_COMPUTATION(M) \
46 FOR_EACH_VALUE(M) \ 50 FOR_EACH_VALUE(M) \
47 M(AssertAssignable, AssertAssignableComp) \ 51 M(AssertAssignable, AssertAssignableComp) \
48 M(InstanceCall, InstanceCallComp) \ 52 M(InstanceCall, InstanceCallComp) \
49 M(StaticCall, StaticCallComp) \ 53 M(StaticCall, StaticCallComp) \
50 M(LoadLocal, LoadLocalComp) \ 54 M(LoadLocal, LoadLocalComp) \
51 M(StoreLocal, StoreLocalComp) \ 55 M(StoreLocal, StoreLocalComp) \
52 M(StrictCompare, StrictCompareComp) \ 56 M(StrictCompare, StrictCompareComp) \
53 M(NativeCall, NativeCallComp) \ 57 M(NativeCall, NativeCallComp) \
54 M(StoreIndexed, StoreIndexedComp) \ 58 M(StoreIndexed, StoreIndexedComp) \
55 M(InstanceSetter, InstanceSetterComp) \ 59 M(InstanceSetter, InstanceSetterComp) \
60 M(StoreInstanceField, StoreInstanceFieldComp) \
61 M(LoadInstanceField, LoadInstanceFieldComp) \
62 M(LoadStaticField, LoadStaticFieldComp) \
63 M(StoreStaticField, StoreStaticFieldComp)
56 64
57 65
58 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 66 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
59 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 67 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
60 #undef FORWARD_DECLARATION 68 #undef FORWARD_DECLARATION
61 69
62 class Computation : public ZoneAllocated { 70 class Computation : public ZoneAllocated {
63 public: 71 public:
64 Computation() { } 72 Computation() { }
65 73
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return ast_node_.native_c_function_name(); 285 return ast_node_.native_c_function_name();
278 } 286 }
279 287
280 private: 288 private:
281 const NativeBodyNode& ast_node_; 289 const NativeBodyNode& ast_node_;
282 290
283 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); 291 DISALLOW_COPY_AND_ASSIGN(NativeCallComp);
284 }; 292 };
285 293
286 294
295 class LoadInstanceFieldComp : public Computation {
296 public:
297 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance)
298 : ast_node_(*ast_node), instance_(instance) {
299 ASSERT(instance_ != NULL);
300 }
301
302 DECLARE_COMPUTATION(LoadInstanceFieldComp)
303
304 RawString* name() const { return ast_node_.field().name(); }
Kevin Millikin (Google) 2012/03/05 11:02:41 Might also just expose a const Field& accessor ins
srdjan 2012/03/05 18:35:21 Using Field type as suggested
305 intptr_t field_offset() const { return ast_node_.field().Offset(); }
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 RawString* field_name() const { return ast_node_.field().name(); }
332 RawAbstractType* field_type() const { return ast_node_.field().type(); }
333 intptr_t field_offset() const { return ast_node_.field().Offset(); }
334
335 Value* instance() const { return instance_; }
336 Value* value() const { return value_; }
337
338 private:
339 const StoreInstanceFieldNode& ast_node_;
340 Value* instance_;
341 Value* value_;
342
343 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp);
344 };
345
346
347 class LoadStaticFieldComp : public Computation {
348 public:
349 explicit LoadStaticFieldComp(const Field& field) : field_(field) {}
350
351 DECLARE_COMPUTATION(LoadStaticFieldComp);
352
353 const Field& field() const { return field_; }
354
355 private:
356 const Field& field_;
357
358 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp);
359 };
360
361
362 class StoreStaticFieldComp : public Computation {
363 public:
364 StoreStaticFieldComp(StoreStaticFieldNode* ast_node, Value* value)
365 : ast_node_(*ast_node), value_(value) {
366 ASSERT(value != NULL);
367 }
368
369 DECLARE_COMPUTATION(StoreStaticFieldComp);
370
371 intptr_t token_index() const { return ast_node_.token_index(); }
372 intptr_t node_id() const { return ast_node_.id(); }
373 const Field& field() const { return ast_node_.field(); }
374 Value* value() const { return value_; }
375
376 private:
377 const StoreStaticFieldNode& ast_node_;
378 Value* value_;
379
380 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp);
381 };
382
383
287 // Not simply an InstanceCall because it has somewhat more complicated 384 // Not simply an InstanceCall because it has somewhat more complicated
288 // semantics: the value operand is preserved in a placeholder (the first 385 // semantics: the value operand is preserved in a placeholder (the first
289 // operand is a preallocated slot that can be used). 386 // operand is a preallocated slot that can be used).
290 class StoreIndexedComp : public Computation { 387 class StoreIndexedComp : public Computation {
291 public: 388 public:
292 StoreIndexedComp(StoreIndexedNode* node, 389 StoreIndexedComp(StoreIndexedNode* node,
293 Value* placeholder, 390 Value* placeholder,
294 Value* array, 391 Value* array,
295 Value* index, 392 Value* index,
296 Value* value) 393 Value* value)
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 #undef DECLARE_VISIT_INSTRUCTION 725 #undef DECLARE_VISIT_INSTRUCTION
629 726
630 private: 727 private:
631 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 728 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
632 }; 729 };
633 730
634 731
635 } // namespace dart 732 } // namespace dart
636 733
637 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 734 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« runtime/vm/flow_graph_compiler_x64.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