| OLD | NEW |
| 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" |
| 11 #include "vm/handles_impl.h" | 11 #include "vm/handles_impl.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 class FlowGraphVisitor; | 16 class FlowGraphVisitor; |
| 17 class LocalVariable; | 17 class LocalVariable; |
| 18 | 18 |
| 19 // Computations and values. | 19 // Computations and values. |
| 20 // | 20 // |
| 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 // | 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 <Value> <Value> <Value> |
| 31 // | InstanceSetter <InstanceSetterNode> <Value> <Value> | 31 // | InstanceSetter <String> <Value> <Value> |
| 32 // | LoadInstanceField <LoadInstanceFieldNode> <Value> | 32 // | LoadInstanceField <LoadInstanceFieldNode> <Value> |
| 33 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value> | 33 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value> |
| 34 // | LoadStaticField <Field> | 34 // | LoadStaticField <Field> |
| 35 // | StoreStaticField <StoreStaticFieldNode> <Value> | 35 // | StoreStaticField <Field> <Value> |
| 36 // | 36 // |
| 37 // <Value> ::= | 37 // <Value> ::= |
| 38 // Temp <int> | 38 // Temp <int> |
| 39 // | Constant <Instance> | 39 // | Constant <Instance> |
| 40 | 40 |
| 41 // 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 |
| 42 // typename and classname. | 42 // typename and classname. |
| 43 #define FOR_EACH_VALUE(M) \ | 43 #define FOR_EACH_VALUE(M) \ |
| 44 M(Temp, TempVal) \ | 44 M(Temp, TempVal) \ |
| 45 M(Constant, ConstantVal) \ | 45 M(Constant, ConstantVal) \ |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 private: | 354 private: |
| 355 const Field& field_; | 355 const Field& field_; |
| 356 | 356 |
| 357 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); | 357 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); |
| 358 }; | 358 }; |
| 359 | 359 |
| 360 | 360 |
| 361 class StoreStaticFieldComp : public Computation { | 361 class StoreStaticFieldComp : public Computation { |
| 362 public: | 362 public: |
| 363 StoreStaticFieldComp(StoreStaticFieldNode* ast_node, Value* value) | 363 StoreStaticFieldComp(const Field& field, Value* value) |
| 364 : ast_node_(*ast_node), value_(value) { | 364 : field_(field), |
| 365 value_(value) { |
| 366 ASSERT(field.IsZoneHandle()); |
| 365 ASSERT(value != NULL); | 367 ASSERT(value != NULL); |
| 366 } | 368 } |
| 367 | 369 |
| 368 DECLARE_COMPUTATION(StoreStaticFieldComp); | 370 DECLARE_COMPUTATION(StoreStaticFieldComp); |
| 369 | 371 |
| 370 intptr_t token_index() const { return ast_node_.token_index(); } | 372 const Field& field() const { return field_; } |
| 371 intptr_t node_id() const { return ast_node_.id(); } | |
| 372 const Field& field() const { return ast_node_.field(); } | |
| 373 Value* value() const { return value_; } | 373 Value* value() const { return value_; } |
| 374 | 374 |
| 375 private: | 375 private: |
| 376 const StoreStaticFieldNode& ast_node_; | 376 const Field& field_; |
| 377 Value* value_; | 377 Value* const value_; |
| 378 | 378 |
| 379 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); | 379 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); |
| 380 }; | 380 }; |
| 381 | 381 |
| 382 | 382 |
| 383 // Not simply an InstanceCall because it has somewhat more complicated | 383 // Not simply an InstanceCall because it has somewhat more complicated |
| 384 // semantics: the value operand is preserved before the call. | 384 // semantics: the value operand is preserved before the call. |
| 385 class StoreIndexedComp : public Computation { | 385 class StoreIndexedComp : public Computation { |
| 386 public: | 386 public: |
| 387 StoreIndexedComp(StoreIndexedNode* node, | 387 StoreIndexedComp(intptr_t node_id, |
| 388 intptr_t token_index, |
| 388 Value* array, | 389 Value* array, |
| 389 Value* index, | 390 Value* index, |
| 390 Value* value) | 391 Value* value) |
| 391 : ast_node_(*node), | 392 : node_id_(node_id), |
| 393 token_index_(token_index), |
| 392 array_(array), | 394 array_(array), |
| 393 index_(index), | 395 index_(index), |
| 394 value_(value) { } | 396 value_(value) { } |
| 395 | 397 |
| 396 DECLARE_COMPUTATION(StoreIndexed) | 398 DECLARE_COMPUTATION(StoreIndexed) |
| 397 | 399 |
| 398 // Accessors forwarded to the AST node. | 400 intptr_t node_id() const { return node_id_; } |
| 399 intptr_t node_id() const { return ast_node_.id(); } | 401 intptr_t token_index() const { return token_index_; } |
| 400 intptr_t token_index() const { return ast_node_.token_index(); } | |
| 401 | |
| 402 Value* array() const { return array_; } | 402 Value* array() const { return array_; } |
| 403 Value* index() const { return index_; } | 403 Value* index() const { return index_; } |
| 404 Value* value() const { return value_; } | 404 Value* value() const { return value_; } |
| 405 | 405 |
| 406 private: | 406 private: |
| 407 const StoreIndexedNode& ast_node_; | 407 intptr_t node_id_; |
| 408 intptr_t token_index_; |
| 408 Value* array_; | 409 Value* array_; |
| 409 Value* index_; | 410 Value* index_; |
| 410 Value* value_; | 411 Value* value_; |
| 411 | 412 |
| 412 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); | 413 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); |
| 413 }; | 414 }; |
| 414 | 415 |
| 415 | 416 |
| 416 // Not simply an InstanceCall because it has somewhat more complicated | 417 // Not simply an InstanceCall because it has somewhat more complicated |
| 417 // semantics: the value operand is preserved before the call. | 418 // semantics: the value operand is preserved before the call. |
| 418 class InstanceSetterComp : public Computation { | 419 class InstanceSetterComp : public Computation { |
| 419 public: | 420 public: |
| 420 InstanceSetterComp(InstanceSetterNode* node, | 421 InstanceSetterComp(intptr_t node_id, |
| 422 intptr_t token_index, |
| 423 const String& field_name, |
| 421 Value* receiver, | 424 Value* receiver, |
| 422 Value* value) | 425 Value* value) |
| 423 : ast_node_(*node), | 426 : node_id_(node_id), |
| 427 token_index_(token_index), |
| 428 field_name_(field_name), |
| 424 receiver_(receiver), | 429 receiver_(receiver), |
| 425 value_(value) { } | 430 value_(value) { } |
| 426 | 431 |
| 427 DECLARE_COMPUTATION(InstanceSetter) | 432 DECLARE_COMPUTATION(InstanceSetter) |
| 428 | 433 |
| 429 // Accessors forwarded to the AST node. | 434 intptr_t node_id() const { return node_id_; } |
| 430 intptr_t node_id() const { return ast_node_.id(); } | 435 intptr_t token_index() const { return token_index_; } |
| 431 intptr_t token_index() const { return ast_node_.token_index(); } | 436 const String& field_name() const { return field_name_; } |
| 432 const String& field_name() const { return ast_node_.field_name(); } | |
| 433 | |
| 434 Value* receiver() const { return receiver_; } | 437 Value* receiver() const { return receiver_; } |
| 435 Value* value() const { return value_; } | 438 Value* value() const { return value_; } |
| 436 | 439 |
| 437 private: | 440 private: |
| 438 const InstanceSetterNode& ast_node_; | 441 const intptr_t node_id_; |
| 439 Value* receiver_; | 442 const intptr_t token_index_; |
| 440 Value* value_; | 443 const String& field_name_; |
| 444 Value* const receiver_; |
| 445 Value* const value_; |
| 441 | 446 |
| 442 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); | 447 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); |
| 443 }; | 448 }; |
| 444 | 449 |
| 445 | 450 |
| 446 #undef DECLARE_COMPUTATION | 451 #undef DECLARE_COMPUTATION |
| 447 | 452 |
| 448 | 453 |
| 449 // Instructions. | 454 // Instructions. |
| 450 // | 455 // |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 #undef DECLARE_VISIT_INSTRUCTION | 792 #undef DECLARE_VISIT_INSTRUCTION |
| 788 | 793 |
| 789 private: | 794 private: |
| 790 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 795 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 791 }; | 796 }; |
| 792 | 797 |
| 793 | 798 |
| 794 } // namespace dart | 799 } // namespace dart |
| 795 | 800 |
| 796 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 801 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |