| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return (ic_data() != NULL) && !ic_data()->IsNull(); | 135 return (ic_data() != NULL) && !ic_data()->IsNull(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Visiting support. | 138 // Visiting support. |
| 139 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr) = 0; | 139 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr) = 0; |
| 140 | 140 |
| 141 virtual intptr_t InputCount() const = 0; | 141 virtual intptr_t InputCount() const = 0; |
| 142 virtual Value* InputAt(intptr_t i) const = 0; | 142 virtual Value* InputAt(intptr_t i) const = 0; |
| 143 virtual void SetInputAt(intptr_t i, Value* value) = 0; | 143 virtual void SetInputAt(intptr_t i, Value* value) = 0; |
| 144 | 144 |
| 145 // Call computations override this function and return the |
| 146 // number of pushed arguments. |
| 147 virtual intptr_t ArgumentCount() const = 0; |
| 148 |
| 145 // Static type of the computation. | 149 // Static type of the computation. |
| 146 virtual RawAbstractType* StaticType() const = 0; | 150 virtual RawAbstractType* StaticType() const = 0; |
| 147 | 151 |
| 148 // Mutate assigned_vars to add the local variable index for all | 152 // Mutate assigned_vars to add the local variable index for all |
| 149 // frame-allocated locals assigned to by the computation. | 153 // frame-allocated locals assigned to by the computation. |
| 150 virtual void RecordAssignedVars(BitVector* assigned_vars, | 154 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| 151 intptr_t fixed_parameter_count); | 155 intptr_t fixed_parameter_count); |
| 152 | 156 |
| 153 virtual const char* DebugName() const = 0; | 157 virtual const char* DebugName() const = 0; |
| 154 | 158 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 DISALLOW_COPY_AND_ASSIGN(Value); | 301 DISALLOW_COPY_AND_ASSIGN(Value); |
| 298 }; | 302 }; |
| 299 | 303 |
| 300 | 304 |
| 301 // Functions defined in all concrete computation classes. | 305 // Functions defined in all concrete computation classes. |
| 302 #define DECLARE_COMPUTATION(ShortName) \ | 306 #define DECLARE_COMPUTATION(ShortName) \ |
| 303 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ | 307 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ |
| 304 virtual ComputationType computation_type() const { \ | 308 virtual ComputationType computation_type() const { \ |
| 305 return Computation::k##ShortName; \ | 309 return Computation::k##ShortName; \ |
| 306 } \ | 310 } \ |
| 311 virtual intptr_t ArgumentCount() const { return 0; } \ |
| 307 virtual const char* DebugName() const { return #ShortName; } \ | 312 virtual const char* DebugName() const { return #ShortName; } \ |
| 308 virtual RawAbstractType* StaticType() const; \ | 313 virtual RawAbstractType* StaticType() const; \ |
| 309 virtual LocationSummary* MakeLocationSummary() const; \ | 314 virtual LocationSummary* MakeLocationSummary() const; \ |
| 310 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | 315 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 311 | 316 |
| 312 // Functions defined in all concrete value classes. | 317 // Functions defined in all concrete value classes. |
| 313 #define DECLARE_VALUE(ShortName) \ | 318 #define DECLARE_VALUE(ShortName) \ |
| 314 DECLARE_COMPUTATION(ShortName) \ | 319 DECLARE_COMPUTATION(ShortName) \ |
| 315 virtual void PrintTo(BufferFormatter* f) const; | 320 virtual void PrintTo(BufferFormatter* f) const; |
| 316 | 321 |
| 317 | 322 |
| 323 // Function defined in all call computation classes. |
| 324 #define DECLARE_CALL_COMPUTATION(ShortName) \ |
| 325 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ |
| 326 virtual ComputationType computation_type() const { \ |
| 327 return Computation::k##ShortName; \ |
| 328 } \ |
| 329 virtual intptr_t InputCount() const { return 0; } \ |
| 330 virtual Value* InputAt(intptr_t i) const { \ |
| 331 UNREACHABLE(); \ |
| 332 return NULL; \ |
| 333 } \ |
| 334 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } \ |
| 335 virtual const char* DebugName() const { return #ShortName; } \ |
| 336 virtual RawAbstractType* StaticType() const; \ |
| 337 virtual LocationSummary* MakeLocationSummary() const; \ |
| 338 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 339 |
| 340 |
| 318 class Definition; | 341 class Definition; |
| 319 class PhiInstr; | 342 class PhiInstr; |
| 320 | 343 |
| 321 class UseVal : public Value { | 344 class UseVal : public Value { |
| 322 public: | 345 public: |
| 323 explicit UseVal(Definition* definition) : definition_(definition) {} | 346 explicit UseVal(Definition* definition) : definition_(definition) {} |
| 324 | 347 |
| 325 DECLARE_VALUE(Use) | 348 DECLARE_VALUE(Use) |
| 326 | 349 |
| 327 inline Definition* definition() const; | 350 inline Definition* definition() const; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 482 |
| 460 class ClosureCallComp : public Computation { | 483 class ClosureCallComp : public Computation { |
| 461 public: | 484 public: |
| 462 ClosureCallComp(ClosureCallNode* node, | 485 ClosureCallComp(ClosureCallNode* node, |
| 463 intptr_t try_index, | 486 intptr_t try_index, |
| 464 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 487 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
| 465 : ast_node_(*node), | 488 : ast_node_(*node), |
| 466 try_index_(try_index), | 489 try_index_(try_index), |
| 467 arguments_(arguments) { } | 490 arguments_(arguments) { } |
| 468 | 491 |
| 469 DECLARE_COMPUTATION(ClosureCall) | 492 DECLARE_CALL_COMPUTATION(ClosureCall) |
| 470 | 493 |
| 471 const Array& argument_names() const { return ast_node_.arguments()->names(); } | 494 const Array& argument_names() const { return ast_node_.arguments()->names(); } |
| 472 intptr_t token_pos() const { return ast_node_.token_pos(); } | 495 intptr_t token_pos() const { return ast_node_.token_pos(); } |
| 473 intptr_t try_index() const { return try_index_; } | 496 intptr_t try_index() const { return try_index_; } |
| 474 | 497 |
| 475 intptr_t ArgumentCount() const { return arguments_->length(); } | 498 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 476 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 499 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
| 477 return (*arguments_)[index]; | 500 return (*arguments_)[index]; |
| 478 } | 501 } |
| 479 | 502 |
| 480 virtual intptr_t InputCount() const { return 0; } | |
| 481 virtual Value* InputAt(intptr_t i) const { | |
| 482 UNREACHABLE(); | |
| 483 return NULL; | |
| 484 } | |
| 485 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } | |
| 486 | |
| 487 virtual void PrintOperandsTo(BufferFormatter* f) const; | 503 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 488 | 504 |
| 489 private: | 505 private: |
| 490 const ClosureCallNode& ast_node_; | 506 const ClosureCallNode& ast_node_; |
| 491 const intptr_t try_index_; | 507 const intptr_t try_index_; |
| 492 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 508 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
| 493 | 509 |
| 494 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); | 510 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); |
| 495 }; | 511 }; |
| 496 | 512 |
| 497 | 513 |
| 498 class InstanceCallComp : public Computation { | 514 class InstanceCallComp : public Computation { |
| 499 public: | 515 public: |
| 500 InstanceCallComp(intptr_t token_pos, | 516 InstanceCallComp(intptr_t token_pos, |
| 501 intptr_t try_index, | 517 intptr_t try_index, |
| 502 const String& function_name, | 518 const String& function_name, |
| 503 Token::Kind token_kind, | 519 Token::Kind token_kind, |
| 504 ZoneGrowableArray<Value*>* arguments, | 520 ZoneGrowableArray<PushArgumentInstr*>* arguments, |
| 505 const Array& argument_names, | 521 const Array& argument_names, |
| 506 intptr_t checked_argument_count) | 522 intptr_t checked_argument_count) |
| 507 : token_pos_(token_pos), | 523 : token_pos_(token_pos), |
| 508 try_index_(try_index), | 524 try_index_(try_index), |
| 509 function_name_(function_name), | 525 function_name_(function_name), |
| 510 token_kind_(token_kind), | 526 token_kind_(token_kind), |
| 511 arguments_(arguments), | 527 arguments_(arguments), |
| 512 argument_names_(argument_names), | 528 argument_names_(argument_names), |
| 513 checked_argument_count_(checked_argument_count) { | 529 checked_argument_count_(checked_argument_count) { |
| 514 ASSERT(function_name.IsZoneHandle()); | 530 ASSERT(function_name.IsZoneHandle()); |
| 515 ASSERT(!arguments->is_empty()); | 531 ASSERT(!arguments->is_empty()); |
| 516 ASSERT(argument_names.IsZoneHandle()); | 532 ASSERT(argument_names.IsZoneHandle()); |
| 517 ASSERT(Token::IsBinaryToken(token_kind) || | 533 ASSERT(Token::IsBinaryToken(token_kind) || |
| 518 Token::IsUnaryToken(token_kind) || | 534 Token::IsUnaryToken(token_kind) || |
| 519 token_kind == Token::kGET || | 535 token_kind == Token::kGET || |
| 520 token_kind == Token::kILLEGAL); | 536 token_kind == Token::kILLEGAL); |
| 521 } | 537 } |
| 522 | 538 |
| 523 DECLARE_COMPUTATION(InstanceCall) | 539 DECLARE_CALL_COMPUTATION(InstanceCall) |
| 524 | 540 |
| 525 intptr_t token_pos() const { return token_pos_; } | 541 intptr_t token_pos() const { return token_pos_; } |
| 526 intptr_t try_index() const { return try_index_; } | 542 intptr_t try_index() const { return try_index_; } |
| 527 const String& function_name() const { return function_name_; } | 543 const String& function_name() const { return function_name_; } |
| 528 Token::Kind token_kind() const { return token_kind_; } | 544 Token::Kind token_kind() const { return token_kind_; } |
| 529 intptr_t ArgumentCount() const { return arguments_->length(); } | 545 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 530 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 546 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
| 547 return (*arguments_)[index]; |
| 548 } |
| 531 const Array& argument_names() const { return argument_names_; } | 549 const Array& argument_names() const { return argument_names_; } |
| 532 intptr_t checked_argument_count() const { return checked_argument_count_; } | 550 intptr_t checked_argument_count() const { return checked_argument_count_; } |
| 533 | 551 |
| 534 virtual intptr_t InputCount() const; | |
| 535 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } | |
| 536 virtual void SetInputAt(intptr_t i, Value* value) { | |
| 537 (*arguments_)[i] = value; | |
| 538 } | |
| 539 | |
| 540 virtual void PrintOperandsTo(BufferFormatter* f) const; | 552 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 541 | 553 |
| 542 bool VerifyComputation(); | |
| 543 | |
| 544 private: | 554 private: |
| 545 const intptr_t token_pos_; | 555 const intptr_t token_pos_; |
| 546 const intptr_t try_index_; | 556 const intptr_t try_index_; |
| 547 const String& function_name_; | 557 const String& function_name_; |
| 548 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. | 558 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. |
| 549 ZoneGrowableArray<Value*>* const arguments_; | 559 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
| 550 const Array& argument_names_; | 560 const Array& argument_names_; |
| 551 const intptr_t checked_argument_count_; | 561 const intptr_t checked_argument_count_; |
| 552 | 562 |
| 553 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); | 563 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); |
| 554 }; | 564 }; |
| 555 | 565 |
| 556 | 566 |
| 557 class PolymorphicInstanceCallComp : public Computation { | 567 class PolymorphicInstanceCallComp : public Computation { |
| 558 public: | 568 public: |
| 559 explicit PolymorphicInstanceCallComp(InstanceCallComp* comp) | 569 explicit PolymorphicInstanceCallComp(InstanceCallComp* comp) |
| 560 : instance_call_(comp) { | 570 : instance_call_(comp) { |
| 561 ASSERT(instance_call_ != NULL); | 571 ASSERT(instance_call_ != NULL); |
| 562 } | 572 } |
| 563 | 573 |
| 564 InstanceCallComp* instance_call() const { return instance_call_; } | 574 InstanceCallComp* instance_call() const { return instance_call_; } |
| 565 | 575 |
| 566 virtual intptr_t InputCount() const { return instance_call()->InputCount(); } | 576 virtual intptr_t InputCount() const { return 0; } |
| 567 virtual Value* InputAt(intptr_t i) const { | 577 virtual Value* InputAt(intptr_t i) const { |
| 568 return instance_call()->ArgumentAt(i); | 578 UNREACHABLE(); |
| 579 return NULL; |
| 569 } | 580 } |
| 570 virtual void SetInputAt(intptr_t index, Value* value) { | 581 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } |
| 571 instance_call()->SetInputAt(index, value); | |
| 572 } | |
| 573 | 582 |
| 574 void PrintTo(BufferFormatter* f) const; | 583 void PrintTo(BufferFormatter* f) const; |
| 575 | 584 |
| 576 DECLARE_COMPUTATION(PolymorphicInstanceCall) | 585 DECLARE_COMPUTATION(PolymorphicInstanceCall) |
| 577 | 586 |
| 578 private: | 587 private: |
| 579 InstanceCallComp* instance_call_; | 588 InstanceCallComp* instance_call_; |
| 580 | 589 |
| 581 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallComp); | 590 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallComp); |
| 582 }; | 591 }; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 : token_pos_(token_pos), | 708 : token_pos_(token_pos), |
| 700 try_index_(try_index), | 709 try_index_(try_index), |
| 701 function_(function), | 710 function_(function), |
| 702 argument_names_(argument_names), | 711 argument_names_(argument_names), |
| 703 arguments_(arguments), | 712 arguments_(arguments), |
| 704 recognized_(MethodRecognizer::kUnknown) { | 713 recognized_(MethodRecognizer::kUnknown) { |
| 705 ASSERT(function.IsZoneHandle()); | 714 ASSERT(function.IsZoneHandle()); |
| 706 ASSERT(argument_names.IsZoneHandle()); | 715 ASSERT(argument_names.IsZoneHandle()); |
| 707 } | 716 } |
| 708 | 717 |
| 709 DECLARE_COMPUTATION(StaticCall) | 718 DECLARE_CALL_COMPUTATION(StaticCall) |
| 710 | 719 |
| 711 // Accessors forwarded to the AST node. | 720 // Accessors forwarded to the AST node. |
| 712 const Function& function() const { return function_; } | 721 const Function& function() const { return function_; } |
| 713 const Array& argument_names() const { return argument_names_; } | 722 const Array& argument_names() const { return argument_names_; } |
| 714 intptr_t token_pos() const { return token_pos_; } | 723 intptr_t token_pos() const { return token_pos_; } |
| 715 intptr_t try_index() const { return try_index_; } | 724 intptr_t try_index() const { return try_index_; } |
| 716 | 725 |
| 717 intptr_t ArgumentCount() const { return arguments_->length(); } | 726 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 718 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 727 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
| 719 return (*arguments_)[index]; | 728 return (*arguments_)[index]; |
| 720 } | 729 } |
| 721 | 730 |
| 722 MethodRecognizer::Kind recognized() const { return recognized_; } | 731 MethodRecognizer::Kind recognized() const { return recognized_; } |
| 723 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } | 732 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } |
| 724 | 733 |
| 725 virtual intptr_t InputCount() const { return 0; } | |
| 726 virtual Value* InputAt(intptr_t i) const { | |
| 727 UNREACHABLE(); | |
| 728 return NULL; | |
| 729 } | |
| 730 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } | |
| 731 | |
| 732 virtual void PrintOperandsTo(BufferFormatter* f) const; | 734 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 733 | 735 |
| 734 private: | 736 private: |
| 735 const intptr_t token_pos_; | 737 const intptr_t token_pos_; |
| 736 const intptr_t try_index_; | 738 const intptr_t try_index_; |
| 737 const Function& function_; | 739 const Function& function_; |
| 738 const Array& argument_names_; | 740 const Array& argument_names_; |
| 739 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 741 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
| 740 MethodRecognizer::Kind recognized_; | 742 MethodRecognizer::Kind recognized_; |
| 741 | 743 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 | 1239 |
| 1238 private: | 1240 private: |
| 1239 const intptr_t token_pos_; | 1241 const intptr_t token_pos_; |
| 1240 const intptr_t try_index_; | 1242 const intptr_t try_index_; |
| 1241 ZoneGrowableArray<Value*>* const elements_; | 1243 ZoneGrowableArray<Value*>* const elements_; |
| 1242 | 1244 |
| 1243 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); | 1245 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); |
| 1244 }; | 1246 }; |
| 1245 | 1247 |
| 1246 | 1248 |
| 1247 class CreateClosureComp : public TemplateComputation<0> { | 1249 class CreateClosureComp : public Computation { |
| 1248 public: | 1250 public: |
| 1249 CreateClosureComp(ClosureNode* node, | 1251 CreateClosureComp(ClosureNode* node, |
| 1250 intptr_t try_index, | 1252 intptr_t try_index, |
| 1251 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 1253 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
| 1252 : ast_node_(*node), | 1254 : ast_node_(*node), |
| 1253 try_index_(try_index), | 1255 try_index_(try_index), |
| 1254 arguments_(arguments) { } | 1256 arguments_(arguments) { } |
| 1255 | 1257 |
| 1256 DECLARE_COMPUTATION(CreateClosure) | 1258 DECLARE_CALL_COMPUTATION(CreateClosure) |
| 1257 | 1259 |
| 1258 intptr_t token_pos() const { return ast_node_.token_pos(); } | 1260 intptr_t token_pos() const { return ast_node_.token_pos(); } |
| 1259 intptr_t try_index() const { return try_index_; } | 1261 intptr_t try_index() const { return try_index_; } |
| 1260 const Function& function() const { return ast_node_.function(); } | 1262 const Function& function() const { return ast_node_.function(); } |
| 1261 | 1263 |
| 1262 intptr_t ArgumentCount() const { return arguments_->length(); } | 1264 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 1263 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 1265 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
| 1264 return (*arguments_)[index]; | 1266 return (*arguments_)[index]; |
| 1265 } | 1267 } |
| 1266 | 1268 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 BlockEntryInstr* AsBlockEntry() { | 1748 BlockEntryInstr* AsBlockEntry() { |
| 1747 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL; | 1749 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL; |
| 1748 } | 1750 } |
| 1749 virtual bool IsDefinition() const { return false; } | 1751 virtual bool IsDefinition() const { return false; } |
| 1750 virtual Definition* AsDefinition() { return NULL; } | 1752 virtual Definition* AsDefinition() { return NULL; } |
| 1751 | 1753 |
| 1752 virtual intptr_t InputCount() const = 0; | 1754 virtual intptr_t InputCount() const = 0; |
| 1753 virtual Value* InputAt(intptr_t i) const = 0; | 1755 virtual Value* InputAt(intptr_t i) const = 0; |
| 1754 virtual void SetInputAt(intptr_t i, Value* value) = 0; | 1756 virtual void SetInputAt(intptr_t i, Value* value) = 0; |
| 1755 | 1757 |
| 1758 // Call instructions override this function and return the |
| 1759 // number of pushed arguments. |
| 1760 virtual intptr_t ArgumentCount() const = 0; |
| 1761 |
| 1756 // Visiting support. | 1762 // Visiting support. |
| 1757 virtual void Accept(FlowGraphVisitor* visitor) = 0; | 1763 virtual void Accept(FlowGraphVisitor* visitor) = 0; |
| 1758 | 1764 |
| 1759 Instruction* previous() const { return previous_; } | 1765 Instruction* previous() const { return previous_; } |
| 1760 void set_previous(Instruction* instr) { | 1766 void set_previous(Instruction* instr) { |
| 1761 ASSERT(!IsBlockEntry()); | 1767 ASSERT(!IsBlockEntry()); |
| 1762 previous_ = instr; | 1768 previous_ = instr; |
| 1763 } | 1769 } |
| 1764 | 1770 |
| 1765 Instruction* next() const { return next_; } | 1771 Instruction* next() const { return next_; } |
| 1766 void set_next(Instruction* instr) { | 1772 void set_next(Instruction* instr) { |
| 1767 ASSERT(!IsGraphEntry()); | 1773 ASSERT(!IsGraphEntry()); |
| 1768 ASSERT(!IsReturn()); | 1774 ASSERT(!IsReturn()); |
| 1769 ASSERT(!IsBranch()); | 1775 ASSERT(!IsBranch()); |
| 1770 ASSERT(!IsPhi()); | 1776 ASSERT(!IsPhi()); |
| 1771 ASSERT(instr == NULL || !instr->IsBlockEntry()); | 1777 ASSERT(instr == NULL || !instr->IsBlockEntry()); |
| 1772 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions | 1778 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions |
| 1773 // that do not have a successor. Currently, the graph builder will continue | 1779 // that do not have a successor. Currently, the graph builder will continue |
| 1774 // to append instruction in case of a Throw inside an expression. This | 1780 // to append instruction in case of a Throw inside an expression. This |
| 1775 // condition should be handled in the graph builder | 1781 // condition should be handled in the graph builder |
| 1776 next_ = instr; | 1782 next_ = instr; |
| 1777 } | 1783 } |
| 1778 | 1784 |
| 1785 // Removed this instruction from the graph. |
| 1786 Instruction* RemoveFromGraph(bool return_previous = true); |
| 1787 |
| 1779 // Normal instructions can have 0 (inside a block) or 1 (last instruction in | 1788 // Normal instructions can have 0 (inside a block) or 1 (last instruction in |
| 1780 // a block) successors. Branch instruction with >1 successors override this | 1789 // a block) successors. Branch instruction with >1 successors override this |
| 1781 // function. | 1790 // function. |
| 1782 virtual intptr_t SuccessorCount() const; | 1791 virtual intptr_t SuccessorCount() const; |
| 1783 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; | 1792 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
| 1784 | 1793 |
| 1785 void Goto(JoinEntryInstr* entry); | 1794 void Goto(JoinEntryInstr* entry); |
| 1786 | 1795 |
| 1787 // Discover basic-block structure by performing a recursive depth first | 1796 // Discover basic-block structure by performing a recursive depth first |
| 1788 // traversal of the instruction graph reachable from this instruction. As | 1797 // traversal of the instruction graph reachable from this instruction. As |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 Instruction* next_; | 1862 Instruction* next_; |
| 1854 Environment* env_; | 1863 Environment* env_; |
| 1855 DISALLOW_COPY_AND_ASSIGN(Instruction); | 1864 DISALLOW_COPY_AND_ASSIGN(Instruction); |
| 1856 }; | 1865 }; |
| 1857 | 1866 |
| 1858 | 1867 |
| 1859 class InstructionWithInputs : public Instruction { | 1868 class InstructionWithInputs : public Instruction { |
| 1860 public: | 1869 public: |
| 1861 InstructionWithInputs() : locs_(NULL) { } | 1870 InstructionWithInputs() : locs_(NULL) { } |
| 1862 | 1871 |
| 1872 virtual intptr_t ArgumentCount() const { return 0; } |
| 1873 |
| 1863 virtual LocationSummary* locs() { | 1874 virtual LocationSummary* locs() { |
| 1864 if (locs_ == NULL) { | 1875 if (locs_ == NULL) { |
| 1865 locs_ = MakeLocationSummary(); | 1876 locs_ = MakeLocationSummary(); |
| 1866 } | 1877 } |
| 1867 return locs_; | 1878 return locs_; |
| 1868 } | 1879 } |
| 1869 | 1880 |
| 1870 virtual LocationSummary* MakeLocationSummary() const = 0; | 1881 virtual LocationSummary* MakeLocationSummary() const = 0; |
| 1871 | 1882 |
| 1872 private: | 1883 private: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1919 | 1930 |
| 1920 virtual void DiscoverBlocks( | 1931 virtual void DiscoverBlocks( |
| 1921 BlockEntryInstr* current_block, | 1932 BlockEntryInstr* current_block, |
| 1922 GrowableArray<BlockEntryInstr*>* preorder, | 1933 GrowableArray<BlockEntryInstr*>* preorder, |
| 1923 GrowableArray<BlockEntryInstr*>* postorder, | 1934 GrowableArray<BlockEntryInstr*>* postorder, |
| 1924 GrowableArray<intptr_t>* parent, | 1935 GrowableArray<intptr_t>* parent, |
| 1925 GrowableArray<BitVector*>* assigned_vars, | 1936 GrowableArray<BitVector*>* assigned_vars, |
| 1926 intptr_t variable_count, | 1937 intptr_t variable_count, |
| 1927 intptr_t fixed_parameter_count); | 1938 intptr_t fixed_parameter_count); |
| 1928 | 1939 |
| 1940 virtual intptr_t ArgumentCount() const { return 0; } |
| 1941 |
| 1929 protected: | 1942 protected: |
| 1930 BlockEntryInstr() | 1943 BlockEntryInstr() |
| 1931 : preorder_number_(-1), | 1944 : preorder_number_(-1), |
| 1932 postorder_number_(-1), | 1945 postorder_number_(-1), |
| 1933 block_id_(-1), | 1946 block_id_(-1), |
| 1934 dominator_(NULL), | 1947 dominator_(NULL), |
| 1935 dominated_blocks_(1), | 1948 dominated_blocks_(1), |
| 1936 last_instruction_(NULL) { } | 1949 last_instruction_(NULL) { } |
| 1937 | 1950 |
| 1938 private: | 1951 private: |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 public: | 2190 public: |
| 2178 enum UseKind { kUnused, kUsed }; | 2191 enum UseKind { kUnused, kUsed }; |
| 2179 | 2192 |
| 2180 BindInstr(UseKind used, Computation* computation) | 2193 BindInstr(UseKind used, Computation* computation) |
| 2181 : computation_(computation), is_used_(used != kUnused) { | 2194 : computation_(computation), is_used_(used != kUnused) { |
| 2182 ASSERT(computation != NULL); | 2195 ASSERT(computation != NULL); |
| 2183 } | 2196 } |
| 2184 | 2197 |
| 2185 DECLARE_INSTRUCTION(Bind) | 2198 DECLARE_INSTRUCTION(Bind) |
| 2186 | 2199 |
| 2200 virtual intptr_t ArgumentCount() const { |
| 2201 return computation()->ArgumentCount(); |
| 2202 } |
| 2203 |
| 2187 Computation* computation() const { return computation_; } | 2204 Computation* computation() const { return computation_; } |
| 2188 void set_computation(Computation* value) { computation_ = value; } | 2205 void set_computation(Computation* value) { computation_ = value; } |
| 2189 bool is_used() const { return is_used_; } | 2206 bool is_used() const { return is_used_; } |
| 2190 | 2207 |
| 2191 // Static type of the underlying computation. | 2208 // Static type of the underlying computation. |
| 2192 virtual RawAbstractType* StaticType() const { | 2209 virtual RawAbstractType* StaticType() const { |
| 2193 return computation()->StaticType(); | 2210 return computation()->StaticType(); |
| 2194 } | 2211 } |
| 2195 | 2212 |
| 2196 virtual void RecordAssignedVars(BitVector* assigned_vars, | 2213 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2214 public: | 2231 public: |
| 2215 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) { | 2232 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) { |
| 2216 for (intptr_t i = 0; i < num_inputs; ++i) { | 2233 for (intptr_t i = 0; i < num_inputs; ++i) { |
| 2217 inputs_.Add(NULL); | 2234 inputs_.Add(NULL); |
| 2218 } | 2235 } |
| 2219 } | 2236 } |
| 2220 | 2237 |
| 2221 // Least upper bound of the static types of the inputs. | 2238 // Least upper bound of the static types of the inputs. |
| 2222 virtual RawAbstractType* StaticType() const; | 2239 virtual RawAbstractType* StaticType() const; |
| 2223 | 2240 |
| 2241 virtual intptr_t ArgumentCount() const { return 0; } |
| 2242 |
| 2224 DECLARE_INSTRUCTION(Phi) | 2243 DECLARE_INSTRUCTION(Phi) |
| 2225 | 2244 |
| 2226 private: | 2245 private: |
| 2227 GrowableArray<Value*> inputs_; | 2246 GrowableArray<Value*> inputs_; |
| 2228 | 2247 |
| 2229 DISALLOW_COPY_AND_ASSIGN(PhiInstr); | 2248 DISALLOW_COPY_AND_ASSIGN(PhiInstr); |
| 2230 }; | 2249 }; |
| 2231 | 2250 |
| 2232 | 2251 |
| 2233 class ParameterInstr : public Definition { | 2252 class ParameterInstr : public Definition { |
| 2234 public: | 2253 public: |
| 2235 explicit ParameterInstr(intptr_t index) : index_(index) { } | 2254 explicit ParameterInstr(intptr_t index) : index_(index) { } |
| 2236 | 2255 |
| 2237 intptr_t index() const { return index_; } | 2256 intptr_t index() const { return index_; } |
| 2238 | 2257 |
| 2239 // Static type of the passed-in parameter. | 2258 // Static type of the passed-in parameter. |
| 2240 virtual RawAbstractType* StaticType() const; | 2259 virtual RawAbstractType* StaticType() const; |
| 2241 | 2260 |
| 2261 virtual intptr_t ArgumentCount() const { return 0; } |
| 2262 |
| 2242 DECLARE_INSTRUCTION(Parameter) | 2263 DECLARE_INSTRUCTION(Parameter) |
| 2243 | 2264 |
| 2244 private: | 2265 private: |
| 2245 const intptr_t index_; | 2266 const intptr_t index_; |
| 2246 | 2267 |
| 2247 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); | 2268 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); |
| 2248 }; | 2269 }; |
| 2249 | 2270 |
| 2250 | 2271 |
| 2251 class PushArgumentInstr : public InstructionWithInputs { | 2272 class PushArgumentInstr : public InstructionWithInputs { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2510 }; | 2531 }; |
| 2511 | 2532 |
| 2512 | 2533 |
| 2513 class ParallelMoveInstr : public Instruction { | 2534 class ParallelMoveInstr : public Instruction { |
| 2514 public: | 2535 public: |
| 2515 ParallelMoveInstr() : moves_(4) { | 2536 ParallelMoveInstr() : moves_(4) { |
| 2516 } | 2537 } |
| 2517 | 2538 |
| 2518 DECLARE_INSTRUCTION(ParallelMove) | 2539 DECLARE_INSTRUCTION(ParallelMove) |
| 2519 | 2540 |
| 2541 virtual intptr_t ArgumentCount() const { return 0; } |
| 2542 |
| 2520 MoveOperands* AddMove(Location dest, Location src) { | 2543 MoveOperands* AddMove(Location dest, Location src) { |
| 2521 MoveOperands* move = new MoveOperands(dest, src); | 2544 MoveOperands* move = new MoveOperands(dest, src); |
| 2522 moves_.Add(move); | 2545 moves_.Add(move); |
| 2523 return move; | 2546 return move; |
| 2524 } | 2547 } |
| 2525 | 2548 |
| 2526 MoveOperands* MoveOperandsAt(intptr_t index) const { return moves_[index]; } | 2549 MoveOperands* MoveOperandsAt(intptr_t index) const { return moves_[index]; } |
| 2527 | 2550 |
| 2528 void SetSrcSlotAt(intptr_t index, const Location& loc); | 2551 void SetSrcSlotAt(intptr_t index, const Location& loc); |
| 2529 void SetDestSlotAt(intptr_t index, const Location& loc); | 2552 void SetDestSlotAt(intptr_t index, const Location& loc); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2614 const GrowableArray<BlockEntryInstr*>& block_order_; | 2637 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 2615 | 2638 |
| 2616 private: | 2639 private: |
| 2617 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2640 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 2618 }; | 2641 }; |
| 2619 | 2642 |
| 2620 | 2643 |
| 2621 } // namespace dart | 2644 } // namespace dart |
| 2622 | 2645 |
| 2623 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2646 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |