| 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 18 matching lines...) Expand all Loading... |
| 29 // M is a two argument macro. It is applied to each concrete instruction's | 29 // M is a two argument macro. It is applied to each concrete instruction's |
| 30 // (including the values) typename and classname. | 30 // (including the values) typename and classname. |
| 31 #define FOR_EACH_COMPUTATION(M) \ | 31 #define FOR_EACH_COMPUTATION(M) \ |
| 32 FOR_EACH_VALUE(M) \ | 32 FOR_EACH_VALUE(M) \ |
| 33 M(AssertAssignable, AssertAssignableComp) \ | 33 M(AssertAssignable, AssertAssignableComp) \ |
| 34 M(AssertBoolean, AssertBooleanComp) \ | 34 M(AssertBoolean, AssertBooleanComp) \ |
| 35 M(CurrentContext, CurrentContextComp) \ | 35 M(CurrentContext, CurrentContextComp) \ |
| 36 M(StoreContext, StoreContextComp) \ | 36 M(StoreContext, StoreContextComp) \ |
| 37 M(ClosureCall, ClosureCallComp) \ | 37 M(ClosureCall, ClosureCallComp) \ |
| 38 M(InstanceCall, InstanceCallComp) \ | 38 M(InstanceCall, InstanceCallComp) \ |
| 39 M(PolymorphicInstanceCall, PolymorphicInstanceCallComp) \ |
| 39 M(StaticCall, StaticCallComp) \ | 40 M(StaticCall, StaticCallComp) \ |
| 40 M(LoadLocal, LoadLocalComp) \ | 41 M(LoadLocal, LoadLocalComp) \ |
| 41 M(StoreLocal, StoreLocalComp) \ | 42 M(StoreLocal, StoreLocalComp) \ |
| 42 M(StrictCompare, StrictCompareComp) \ | 43 M(StrictCompare, StrictCompareComp) \ |
| 43 M(EqualityCompare, EqualityCompareComp) \ | 44 M(EqualityCompare, EqualityCompareComp) \ |
| 44 M(RelationalOp, RelationalOpComp) \ | 45 M(RelationalOp, RelationalOpComp) \ |
| 45 M(NativeCall, NativeCallComp) \ | 46 M(NativeCall, NativeCallComp) \ |
| 46 M(LoadIndexed, LoadIndexedComp) \ | 47 M(LoadIndexed, LoadIndexedComp) \ |
| 47 M(StoreIndexed, StoreIndexedComp) \ | 48 M(StoreIndexed, StoreIndexedComp) \ |
| 48 M(InstanceSetter, InstanceSetterComp) \ | 49 M(InstanceSetter, InstanceSetterComp) \ |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Create a location summary for this computation. | 141 // Create a location summary for this computation. |
| 141 // TODO(fschneider): Temporarily returns NULL for instructions | 142 // TODO(fschneider): Temporarily returns NULL for instructions |
| 142 // that are not yet converted to the location based code generation. | 143 // that are not yet converted to the location based code generation. |
| 143 virtual LocationSummary* MakeLocationSummary() const = 0; | 144 virtual LocationSummary* MakeLocationSummary() const = 0; |
| 144 | 145 |
| 145 // TODO(fschneider): Make EmitNativeCode and locs const. | 146 // TODO(fschneider): Make EmitNativeCode and locs const. |
| 146 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; | 147 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; |
| 147 | 148 |
| 148 static LocationSummary* MakeCallSummary(); | 149 static LocationSummary* MakeCallSummary(); |
| 149 | 150 |
| 151 void ReplaceWith(Computation* other); |
| 152 |
| 150 // Declare an enum value used to define type-test predicates. | 153 // Declare an enum value used to define type-test predicates. |
| 151 enum ComputationType { | 154 enum ComputationType { |
| 152 #define DECLARE_COMPUTATION_TYPE(ShortName, ClassName) k##ShortName, | 155 #define DECLARE_COMPUTATION_TYPE(ShortName, ClassName) k##ShortName, |
| 153 | 156 |
| 154 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_TYPE) | 157 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_TYPE) |
| 155 | 158 |
| 156 #undef DECLARE_COMPUTATION_TYPE | 159 #undef DECLARE_COMPUTATION_TYPE |
| 157 }; | 160 }; |
| 158 | 161 |
| 159 virtual ComputationType computation_type() const = 0; | 162 virtual ComputationType computation_type() const = 0; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 const intptr_t try_index_; | 500 const intptr_t try_index_; |
| 498 const String& function_name_; | 501 const String& function_name_; |
| 499 ZoneGrowableArray<Value*>* const arguments_; | 502 ZoneGrowableArray<Value*>* const arguments_; |
| 500 const Array& argument_names_; | 503 const Array& argument_names_; |
| 501 const intptr_t checked_argument_count_; | 504 const intptr_t checked_argument_count_; |
| 502 | 505 |
| 503 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); | 506 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); |
| 504 }; | 507 }; |
| 505 | 508 |
| 506 | 509 |
| 510 class PolymorphicInstanceCallComp : public Computation { |
| 511 public: |
| 512 PolymorphicInstanceCallComp(InstanceCallComp* comp, |
| 513 const ZoneGrowableArray<intptr_t>& class_ids, |
| 514 const ZoneGrowableArray<Function*>& targets) |
| 515 : instance_call_(comp), |
| 516 class_ids_(class_ids), |
| 517 targets_(targets) { |
| 518 ASSERT(instance_call_ != NULL); |
| 519 } |
| 520 |
| 521 InstanceCallComp* instance_call() const { return instance_call_; } |
| 522 const ZoneGrowableArray<intptr_t>& class_ids() const { return class_ids_; } |
| 523 const ZoneGrowableArray<Function*>& targets() const { return targets_; } |
| 524 |
| 525 virtual intptr_t InputCount() const { return instance_call()->InputCount(); } |
| 526 virtual Value* InputAt(intptr_t i) const { |
| 527 return instance_call()->ArgumentAt(i); |
| 528 } |
| 529 |
| 530 virtual void PrintOperandsTo(BufferFormatter* f) const { |
| 531 instance_call()->PrintOperandsTo(f); |
| 532 } |
| 533 |
| 534 DECLARE_COMPUTATION(PolymorphicInstanceCall) |
| 535 |
| 536 private: |
| 537 InstanceCallComp* instance_call_; |
| 538 const ZoneGrowableArray<intptr_t>& class_ids_; |
| 539 const ZoneGrowableArray<Function*>& targets_; |
| 540 |
| 541 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallComp); |
| 542 }; |
| 543 |
| 544 |
| 507 class ComparisonComp : public TemplateComputation<2> { | 545 class ComparisonComp : public TemplateComputation<2> { |
| 508 public: | 546 public: |
| 509 ComparisonComp(Value* left, Value* right) | 547 ComparisonComp(Value* left, Value* right) |
| 510 : fused_with_branch_(NULL) { | 548 : fused_with_branch_(NULL) { |
| 511 ASSERT(left != NULL); | 549 ASSERT(left != NULL); |
| 512 ASSERT(right != NULL); | 550 ASSERT(right != NULL); |
| 513 inputs_[0] = left; | 551 inputs_[0] = left; |
| 514 inputs_[1] = right; | 552 inputs_[1] = right; |
| 515 } | 553 } |
| 516 | 554 |
| 517 void MarkFusedWithBranch(BranchInstr* branch) { | 555 void MarkFusedWithBranch(BranchInstr* branch) { |
| 518 fused_with_branch_ = branch; | 556 fused_with_branch_ = branch; |
| 519 } | 557 } |
| 520 | 558 |
| 521 BranchInstr* fused_with_branch() const { | 559 BranchInstr* fused_with_branch() const { |
| 560 ASSERT(is_fused_with_branch()); |
| 522 return fused_with_branch_; | 561 return fused_with_branch_; |
| 523 } | 562 } |
| 524 | 563 |
| 525 bool is_fused_with_branch() const { | 564 bool is_fused_with_branch() const { |
| 526 return fused_with_branch_ != NULL; | 565 return fused_with_branch_ != NULL; |
| 527 } | 566 } |
| 528 | 567 |
| 529 Value* left() const { return inputs_[0]; } | 568 Value* left() const { return inputs_[0]; } |
| 530 Value* right() const { return inputs_[1]; } | 569 Value* right() const { return inputs_[1]; } |
| 531 | 570 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 555 | 594 |
| 556 | 595 |
| 557 class EqualityCompareComp : public ComparisonComp { | 596 class EqualityCompareComp : public ComparisonComp { |
| 558 public: | 597 public: |
| 559 EqualityCompareComp(intptr_t token_index, | 598 EqualityCompareComp(intptr_t token_index, |
| 560 intptr_t try_index, | 599 intptr_t try_index, |
| 561 Value* left, | 600 Value* left, |
| 562 Value* right) | 601 Value* right) |
| 563 : ComparisonComp(left, right), | 602 : ComparisonComp(left, right), |
| 564 token_index_(token_index), | 603 token_index_(token_index), |
| 565 try_index_(try_index) { | 604 try_index_(try_index), |
| 605 operands_class_id_(kObject) { |
| 566 } | 606 } |
| 567 | 607 |
| 568 DECLARE_COMPUTATION(EqualityCompare) | 608 DECLARE_COMPUTATION(EqualityCompare) |
| 569 | 609 |
| 570 intptr_t token_index() const { return token_index_; } | 610 intptr_t token_index() const { return token_index_; } |
| 571 intptr_t try_index() const { return try_index_; } | 611 intptr_t try_index() const { return try_index_; } |
| 612 void set_operands_class_id(intptr_t value) { |
| 613 operands_class_id_ = value; |
| 614 } |
| 615 intptr_t operands_class_id() const { return operands_class_id_; } |
| 572 | 616 |
| 573 virtual void PrintOperandsTo(BufferFormatter* f) const; | 617 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 574 | 618 |
| 575 private: | 619 private: |
| 576 const intptr_t token_index_; | 620 const intptr_t token_index_; |
| 577 const intptr_t try_index_; | 621 const intptr_t try_index_; |
| 622 intptr_t operands_class_id_; // class id of both operands. |
| 578 | 623 |
| 579 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); | 624 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); |
| 580 }; | 625 }; |
| 581 | 626 |
| 582 | 627 |
| 583 class RelationalOpComp : public ComparisonComp { | 628 class RelationalOpComp : public ComparisonComp { |
| 584 public: | 629 public: |
| 585 RelationalOpComp(intptr_t token_index, | 630 RelationalOpComp(intptr_t token_index, |
| 586 intptr_t try_index, | 631 intptr_t try_index, |
| 587 Token::Kind kind, | 632 Token::Kind kind, |
| (...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 const GrowableArray<BlockEntryInstr*>& block_order_; | 2360 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 2316 | 2361 |
| 2317 private: | 2362 private: |
| 2318 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2363 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 2319 }; | 2364 }; |
| 2320 | 2365 |
| 2321 | 2366 |
| 2322 } // namespace dart | 2367 } // namespace dart |
| 2323 | 2368 |
| 2324 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2369 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |