| 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" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 M(StoreLocal, StoreLocalComp) \ | 58 M(StoreLocal, StoreLocalComp) \ |
| 59 M(StrictCompare, StrictCompareComp) \ | 59 M(StrictCompare, StrictCompareComp) \ |
| 60 M(NativeCall, NativeCallComp) \ | 60 M(NativeCall, NativeCallComp) \ |
| 61 M(StoreIndexed, StoreIndexedComp) \ | 61 M(StoreIndexed, StoreIndexedComp) \ |
| 62 M(InstanceSetter, InstanceSetterComp) \ | 62 M(InstanceSetter, InstanceSetterComp) \ |
| 63 M(LoadInstanceField, LoadInstanceFieldComp) \ | 63 M(LoadInstanceField, LoadInstanceFieldComp) \ |
| 64 M(StoreInstanceField, StoreInstanceFieldComp) \ | 64 M(StoreInstanceField, StoreInstanceFieldComp) \ |
| 65 M(LoadStaticField, LoadStaticFieldComp) \ | 65 M(LoadStaticField, LoadStaticFieldComp) \ |
| 66 M(StoreStaticField, StoreStaticFieldComp) \ | 66 M(StoreStaticField, StoreStaticFieldComp) \ |
| 67 M(BooleanNegate, BooleanNegateComp) \ | 67 M(BooleanNegate, BooleanNegateComp) \ |
| 68 M(InstanceOf, InstanceOfComp) | 68 M(InstanceOf, InstanceOfComp) \ |
| 69 M(CreateArray, CreateArrayComp) \ |
| 69 | 70 |
| 70 | 71 |
| 71 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; | 72 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; |
| 72 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) | 73 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) |
| 73 #undef FORWARD_DECLARATION | 74 #undef FORWARD_DECLARATION |
| 74 | 75 |
| 75 class Computation : public ZoneAllocated { | 76 class Computation : public ZoneAllocated { |
| 76 public: | 77 public: |
| 77 Computation() { } | 78 Computation() { } |
| 78 | 79 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 }; | 299 }; |
| 299 | 300 |
| 300 | 301 |
| 301 class LoadInstanceFieldComp : public Computation { | 302 class LoadInstanceFieldComp : public Computation { |
| 302 public: | 303 public: |
| 303 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance) | 304 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance) |
| 304 : ast_node_(*ast_node), instance_(instance) { | 305 : ast_node_(*ast_node), instance_(instance) { |
| 305 ASSERT(instance_ != NULL); | 306 ASSERT(instance_ != NULL); |
| 306 } | 307 } |
| 307 | 308 |
| 308 DECLARE_COMPUTATION(LoadInstanceFieldComp) | 309 DECLARE_COMPUTATION(LoadInstanceField) |
| 309 | 310 |
| 310 const Field& field() const { return ast_node_.field(); } | 311 const Field& field() const { return ast_node_.field(); } |
| 311 | 312 |
| 312 Value* instance() const { return instance_; } | 313 Value* instance() const { return instance_; } |
| 313 | 314 |
| 314 private: | 315 private: |
| 315 const LoadInstanceFieldNode& ast_node_; | 316 const LoadInstanceFieldNode& ast_node_; |
| 316 Value* instance_; | 317 Value* instance_; |
| 317 | 318 |
| 318 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); | 319 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); |
| 319 }; | 320 }; |
| 320 | 321 |
| 321 | 322 |
| 322 class StoreInstanceFieldComp : public Computation { | 323 class StoreInstanceFieldComp : public Computation { |
| 323 public: | 324 public: |
| 324 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, | 325 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, |
| 325 Value* instance, | 326 Value* instance, |
| 326 Value* value) | 327 Value* value) |
| 327 : ast_node_(*ast_node), instance_(instance), value_(value) { | 328 : ast_node_(*ast_node), instance_(instance), value_(value) { |
| 328 ASSERT(instance_ != NULL); | 329 ASSERT(instance_ != NULL); |
| 329 ASSERT(value_ != NULL); | 330 ASSERT(value_ != NULL); |
| 330 } | 331 } |
| 331 | 332 |
| 332 DECLARE_COMPUTATION(StoreInstanceFieldComp) | 333 DECLARE_COMPUTATION(StoreInstanceField) |
| 333 | 334 |
| 334 intptr_t node_id() const { return ast_node_.id(); } | 335 intptr_t node_id() const { return ast_node_.id(); } |
| 335 intptr_t token_index() const { return ast_node_.token_index(); } | 336 intptr_t token_index() const { return ast_node_.token_index(); } |
| 336 const Field& field() const { return ast_node_.field(); } | 337 const Field& field() const { return ast_node_.field(); } |
| 337 | 338 |
| 338 Value* instance() const { return instance_; } | 339 Value* instance() const { return instance_; } |
| 339 Value* value() const { return value_; } | 340 Value* value() const { return value_; } |
| 340 | 341 |
| 341 private: | 342 private: |
| 342 const StoreInstanceFieldNode& ast_node_; | 343 const StoreInstanceFieldNode& ast_node_; |
| 343 Value* instance_; | 344 Value* instance_; |
| 344 Value* value_; | 345 Value* value_; |
| 345 | 346 |
| 346 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); | 347 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); |
| 347 }; | 348 }; |
| 348 | 349 |
| 349 | 350 |
| 350 class LoadStaticFieldComp : public Computation { | 351 class LoadStaticFieldComp : public Computation { |
| 351 public: | 352 public: |
| 352 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} | 353 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} |
| 353 | 354 |
| 354 DECLARE_COMPUTATION(LoadStaticFieldComp); | 355 DECLARE_COMPUTATION(LoadStaticField); |
| 355 | 356 |
| 356 const Field& field() const { return field_; } | 357 const Field& field() const { return field_; } |
| 357 | 358 |
| 358 private: | 359 private: |
| 359 const Field& field_; | 360 const Field& field_; |
| 360 | 361 |
| 361 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); | 362 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); |
| 362 }; | 363 }; |
| 363 | 364 |
| 364 | 365 |
| 365 class StoreStaticFieldComp : public Computation { | 366 class StoreStaticFieldComp : public Computation { |
| 366 public: | 367 public: |
| 367 StoreStaticFieldComp(const Field& field, Value* value) | 368 StoreStaticFieldComp(const Field& field, Value* value) |
| 368 : field_(field), | 369 : field_(field), |
| 369 value_(value) { | 370 value_(value) { |
| 370 ASSERT(field.IsZoneHandle()); | 371 ASSERT(field.IsZoneHandle()); |
| 371 ASSERT(value != NULL); | 372 ASSERT(value != NULL); |
| 372 } | 373 } |
| 373 | 374 |
| 374 DECLARE_COMPUTATION(StoreStaticFieldComp); | 375 DECLARE_COMPUTATION(StoreStaticField); |
| 375 | 376 |
| 376 const Field& field() const { return field_; } | 377 const Field& field() const { return field_; } |
| 377 Value* value() const { return value_; } | 378 Value* value() const { return value_; } |
| 378 | 379 |
| 379 private: | 380 private: |
| 380 const Field& field_; | 381 const Field& field_; |
| 381 Value* const value_; | 382 Value* const value_; |
| 382 | 383 |
| 383 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); | 384 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); |
| 384 }; | 385 }; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 451 |
| 451 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); | 452 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); |
| 452 }; | 453 }; |
| 453 | 454 |
| 454 | 455 |
| 455 // Note overrideable, built-in: value? false : true. | 456 // Note overrideable, built-in: value? false : true. |
| 456 class BooleanNegateComp : public Computation { | 457 class BooleanNegateComp : public Computation { |
| 457 public: | 458 public: |
| 458 explicit BooleanNegateComp(Value* value) : value_(value) {} | 459 explicit BooleanNegateComp(Value* value) : value_(value) {} |
| 459 | 460 |
| 460 DECLARE_COMPUTATION(BooleanNegateComp) | 461 DECLARE_COMPUTATION(BooleanNegate) |
| 461 | 462 |
| 462 Value* value() const { return value_; } | 463 Value* value() const { return value_; } |
| 463 | 464 |
| 464 private: | 465 private: |
| 465 Value* value_; | 466 Value* value_; |
| 466 | 467 |
| 467 DISALLOW_COPY_AND_ASSIGN(BooleanNegateComp); | 468 DISALLOW_COPY_AND_ASSIGN(BooleanNegateComp); |
| 468 }; | 469 }; |
| 469 | 470 |
| 470 | 471 |
| 471 class InstanceOfComp : public Computation { | 472 class InstanceOfComp : public Computation { |
| 472 public: | 473 public: |
| 473 InstanceOfComp(intptr_t node_id, | 474 InstanceOfComp(intptr_t node_id, |
| 474 intptr_t token_index, | 475 intptr_t token_index, |
| 475 Value* value, | 476 Value* value, |
| 476 const AbstractType& type, | 477 const AbstractType& type, |
| 477 bool negate_result) | 478 bool negate_result) |
| 478 : node_id_(node_id), | 479 : node_id_(node_id), |
| 479 token_index_(token_index), | 480 token_index_(token_index), |
| 480 value_(value), | 481 value_(value), |
| 481 type_(type), | 482 type_(type), |
| 482 negate_result_(negate_result) {} | 483 negate_result_(negate_result) {} |
| 483 | 484 |
| 484 DECLARE_COMPUTATION(InstanceOfComp) | 485 DECLARE_COMPUTATION(InstanceOf) |
| 485 | 486 |
| 486 Value* value() const { return value_; } | 487 Value* value() const { return value_; } |
| 487 bool negate_result() const { return negate_result_; } | 488 bool negate_result() const { return negate_result_; } |
| 488 const AbstractType& type() const { return type_; } | 489 const AbstractType& type() const { return type_; } |
| 489 | 490 |
| 490 private: | 491 private: |
| 491 const intptr_t node_id_; | 492 const intptr_t node_id_; |
| 492 const intptr_t token_index_; | 493 const intptr_t token_index_; |
| 493 Value* value_; | 494 Value* value_; |
| 494 const AbstractType& type_; | 495 const AbstractType& type_; |
| 495 const bool negate_result_; | 496 const bool negate_result_; |
| 496 | 497 |
| 497 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); | 498 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); |
| 498 }; | 499 }; |
| 499 | 500 |
| 500 | 501 |
| 502 class CreateArrayComp : public Computation { |
| 503 public: |
| 504 CreateArrayComp(ArrayNode* node, ZoneGrowableArray<Value*>* elements) |
| 505 : ast_node_(*node), elements_(elements) { } |
| 506 |
| 507 DECLARE_COMPUTATION(CreateArray) |
| 508 |
| 509 intptr_t token_index() const { return ast_node_.token_index(); } |
| 510 const AbstractTypeArguments& type_arguments() const { |
| 511 return ast_node_.type_arguments(); |
| 512 } |
| 513 intptr_t ElementCount() const { return elements_->length(); } |
| 514 Value* ElementAt(intptr_t i) const { return (*elements_)[i]; } |
| 515 |
| 516 private: |
| 517 const ArrayNode& ast_node_; |
| 518 ZoneGrowableArray<Value*>* const elements_; |
| 519 |
| 520 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); |
| 521 }; |
| 522 |
| 523 |
| 501 #undef DECLARE_COMPUTATION | 524 #undef DECLARE_COMPUTATION |
| 502 | 525 |
| 503 | 526 |
| 504 // Instructions. | 527 // Instructions. |
| 505 // | 528 // |
| 506 // <Instruction> ::= JoinEntry <Instruction> | 529 // <Instruction> ::= JoinEntry <Instruction> |
| 507 // | TargetEntry <Instruction> | 530 // | TargetEntry <Instruction> |
| 508 // | PickTemp <int> <int> <Instruction> | 531 // | PickTemp <int> <int> <Instruction> |
| 509 // | TuckTemp <int> <int> <Instruction> | 532 // | TuckTemp <int> <int> <Instruction> |
| 510 // | Do <Computation> <Instruction> | 533 // | Do <Computation> <Instruction> |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 #undef DECLARE_VISIT_INSTRUCTION | 863 #undef DECLARE_VISIT_INSTRUCTION |
| 841 | 864 |
| 842 private: | 865 private: |
| 843 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 866 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 844 }; | 867 }; |
| 845 | 868 |
| 846 | 869 |
| 847 } // namespace dart | 870 } // namespace dart |
| 848 | 871 |
| 849 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 872 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |