| 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_FLOW_GRAPH_COMPILER_H_ | 5 #ifndef VM_FLOW_GRAPH_COMPILER_H_ |
| 6 #define VM_FLOW_GRAPH_COMPILER_H_ | 6 #define VM_FLOW_GRAPH_COMPILER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 void CompileGraph(); | 360 void CompileGraph(); |
| 361 | 361 |
| 362 void VisitBlocks(); | 362 void VisitBlocks(); |
| 363 | 363 |
| 364 // Bail out of the flow graph compiler. Does not return to the caller. | 364 // Bail out of the flow graph compiler. Does not return to the caller. |
| 365 void Bailout(const char* reason); | 365 void Bailout(const char* reason); |
| 366 | 366 |
| 367 // Returns 'true' if regular code generation should be skipped. | 367 // Returns 'true' if regular code generation should be skipped. |
| 368 bool TryIntrinsify(); | 368 bool TryIntrinsify(); |
| 369 | 369 |
| 370 void GenerateAssertAssignable(TokenPosition token_pos, |
| 371 intptr_t deopt_id, |
| 372 const AbstractType& dst_type, |
| 373 const String& dst_name, |
| 374 LocationSummary* locs); |
| 375 |
| 376 // DBC emits calls very differently from all other architectures due to its |
| 377 // interpreted nature. |
| 378 #if !defined(TARGET_ARCH_DBC) |
| 370 void GenerateRuntimeCall(TokenPosition token_pos, | 379 void GenerateRuntimeCall(TokenPosition token_pos, |
| 371 intptr_t deopt_id, | 380 intptr_t deopt_id, |
| 372 const RuntimeEntry& entry, | 381 const RuntimeEntry& entry, |
| 373 intptr_t argument_count, | 382 intptr_t argument_count, |
| 374 LocationSummary* locs); | 383 LocationSummary* locs); |
| 375 | 384 |
| 376 void GenerateCall(TokenPosition token_pos, | 385 void GenerateCall(TokenPosition token_pos, |
| 377 const StubEntry& stub_entry, | 386 const StubEntry& stub_entry, |
| 378 RawPcDescriptors::Kind kind, | 387 RawPcDescriptors::Kind kind, |
| 379 LocationSummary* locs); | 388 LocationSummary* locs); |
| 380 | 389 |
| 381 void GenerateDartCall(intptr_t deopt_id, | 390 void GenerateDartCall(intptr_t deopt_id, |
| 382 TokenPosition token_pos, | 391 TokenPosition token_pos, |
| 383 const StubEntry& stub_entry, | 392 const StubEntry& stub_entry, |
| 384 RawPcDescriptors::Kind kind, | 393 RawPcDescriptors::Kind kind, |
| 385 LocationSummary* locs); | 394 LocationSummary* locs); |
| 386 void GenerateStaticDartCall(intptr_t deopt_id, | 395 void GenerateStaticDartCall(intptr_t deopt_id, |
| 387 TokenPosition token_pos, | 396 TokenPosition token_pos, |
| 388 const StubEntry& stub_entry, | 397 const StubEntry& stub_entry, |
| 389 RawPcDescriptors::Kind kind, | 398 RawPcDescriptors::Kind kind, |
| 390 LocationSummary* locs, | 399 LocationSummary* locs, |
| 391 const Function& target); | 400 const Function& target); |
| 392 | 401 |
| 393 void GenerateAssertAssignable(TokenPosition token_pos, | |
| 394 intptr_t deopt_id, | |
| 395 const AbstractType& dst_type, | |
| 396 const String& dst_name, | |
| 397 LocationSummary* locs); | |
| 398 | |
| 399 void GenerateInstanceOf(TokenPosition token_pos, | 402 void GenerateInstanceOf(TokenPosition token_pos, |
| 400 intptr_t deopt_id, | 403 intptr_t deopt_id, |
| 401 const AbstractType& type, | 404 const AbstractType& type, |
| 402 bool negate_result, | 405 bool negate_result, |
| 403 LocationSummary* locs); | 406 LocationSummary* locs); |
| 404 | 407 |
| 405 void GenerateInstanceCall(intptr_t deopt_id, | 408 void GenerateInstanceCall(intptr_t deopt_id, |
| 406 TokenPosition token_pos, | 409 TokenPosition token_pos, |
| 407 intptr_t argument_count, | 410 intptr_t argument_count, |
| 408 LocationSummary* locs, | 411 LocationSummary* locs, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 419 void GenerateNumberTypeCheck(Register kClassIdReg, | 422 void GenerateNumberTypeCheck(Register kClassIdReg, |
| 420 const AbstractType& type, | 423 const AbstractType& type, |
| 421 Label* is_instance_lbl, | 424 Label* is_instance_lbl, |
| 422 Label* is_not_instance_lbl); | 425 Label* is_not_instance_lbl); |
| 423 void GenerateStringTypeCheck(Register kClassIdReg, | 426 void GenerateStringTypeCheck(Register kClassIdReg, |
| 424 Label* is_instance_lbl, | 427 Label* is_instance_lbl, |
| 425 Label* is_not_instance_lbl); | 428 Label* is_not_instance_lbl); |
| 426 void GenerateListTypeCheck(Register kClassIdReg, | 429 void GenerateListTypeCheck(Register kClassIdReg, |
| 427 Label* is_instance_lbl); | 430 Label* is_instance_lbl); |
| 428 | 431 |
| 429 void EmitComment(Instruction* instr); | |
| 430 | |
| 431 bool NeedsEdgeCounter(TargetEntryInstr* block); | |
| 432 | |
| 433 void EmitEdgeCounter(intptr_t edge_id); | |
| 434 | |
| 435 void EmitOptimizedInstanceCall(const StubEntry& stub_entry, | 432 void EmitOptimizedInstanceCall(const StubEntry& stub_entry, |
| 436 const ICData& ic_data, | 433 const ICData& ic_data, |
| 437 intptr_t argument_count, | 434 intptr_t argument_count, |
| 438 intptr_t deopt_id, | 435 intptr_t deopt_id, |
| 439 TokenPosition token_pos, | 436 TokenPosition token_pos, |
| 440 LocationSummary* locs); | 437 LocationSummary* locs); |
| 441 | 438 |
| 442 void EmitInstanceCall(const StubEntry& stub_entry, | 439 void EmitInstanceCall(const StubEntry& stub_entry, |
| 443 const ICData& ic_data, | 440 const ICData& ic_data, |
| 444 intptr_t argument_count, | 441 intptr_t argument_count, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 477 |
| 481 Condition EmitEqualityRegConstCompare(Register reg, | 478 Condition EmitEqualityRegConstCompare(Register reg, |
| 482 const Object& obj, | 479 const Object& obj, |
| 483 bool needs_number_check, | 480 bool needs_number_check, |
| 484 TokenPosition token_pos); | 481 TokenPosition token_pos); |
| 485 Condition EmitEqualityRegRegCompare(Register left, | 482 Condition EmitEqualityRegRegCompare(Register left, |
| 486 Register right, | 483 Register right, |
| 487 bool needs_number_check, | 484 bool needs_number_check, |
| 488 TokenPosition token_pos); | 485 TokenPosition token_pos); |
| 489 | 486 |
| 487 bool NeedsEdgeCounter(TargetEntryInstr* block); |
| 488 |
| 489 void EmitEdgeCounter(intptr_t edge_id); |
| 490 #endif // !defined(TARGET_ARCH_DBC) |
| 491 |
| 490 void EmitTrySync(Instruction* instr, intptr_t try_index); | 492 void EmitTrySync(Instruction* instr, intptr_t try_index); |
| 491 | 493 |
| 494 void EmitComment(Instruction* instr); |
| 495 |
| 492 intptr_t StackSize() const; | 496 intptr_t StackSize() const; |
| 493 | 497 |
| 494 // Returns assembler label associated with the given block entry. | 498 // Returns assembler label associated with the given block entry. |
| 495 Label* GetJumpLabel(BlockEntryInstr* block_entry) const; | 499 Label* GetJumpLabel(BlockEntryInstr* block_entry) const; |
| 496 bool WasCompacted(BlockEntryInstr* block_entry) const; | 500 bool WasCompacted(BlockEntryInstr* block_entry) const; |
| 497 | 501 |
| 498 // Returns the label of the fall-through of the current block. | 502 // Returns the label of the fall-through of the current block. |
| 499 Label* NextNonEmptyLabel() const; | 503 Label* NextNonEmptyLabel() const; |
| 500 | 504 |
| 501 // Returns true if there is a next block after the current one in | 505 // Returns true if there is a next block after the current one in |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 intptr_t deopt_id, | 632 intptr_t deopt_id, |
| 629 TokenPosition token_pos, | 633 TokenPosition token_pos, |
| 630 LocationSummary* locs); | 634 LocationSummary* locs); |
| 631 | 635 |
| 632 void EmitUnoptimizedStaticCall(intptr_t argument_count, | 636 void EmitUnoptimizedStaticCall(intptr_t argument_count, |
| 633 intptr_t deopt_id, | 637 intptr_t deopt_id, |
| 634 TokenPosition token_pos, | 638 TokenPosition token_pos, |
| 635 LocationSummary* locs, | 639 LocationSummary* locs, |
| 636 const ICData& ic_data); | 640 const ICData& ic_data); |
| 637 | 641 |
| 642 // DBC handles type tests differently from all other architectures due |
| 643 // to its interpreted nature. |
| 644 #if !defined(TARGET_ARCH_DBC) |
| 638 // Type checking helper methods. | 645 // Type checking helper methods. |
| 639 void CheckClassIds(Register class_id_reg, | 646 void CheckClassIds(Register class_id_reg, |
| 640 const GrowableArray<intptr_t>& class_ids, | 647 const GrowableArray<intptr_t>& class_ids, |
| 641 Label* is_instance_lbl, | 648 Label* is_instance_lbl, |
| 642 Label* is_not_instance_lbl); | 649 Label* is_not_instance_lbl); |
| 643 | 650 |
| 644 RawSubtypeTestCache* GenerateInlineInstanceof(TokenPosition token_pos, | 651 RawSubtypeTestCache* GenerateInlineInstanceof(TokenPosition token_pos, |
| 645 const AbstractType& type, | 652 const AbstractType& type, |
| 646 Label* is_instance_lbl, | 653 Label* is_instance_lbl, |
| 647 Label* is_not_instance_lbl); | 654 Label* is_not_instance_lbl); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 Register temp_reg, | 688 Register temp_reg, |
| 682 Label* is_instance_lbl, | 689 Label* is_instance_lbl, |
| 683 Label* is_not_instance_lbl); | 690 Label* is_not_instance_lbl); |
| 684 | 691 |
| 685 // Returns true if checking against this type is a direct class id comparison. | 692 // Returns true if checking against this type is a direct class id comparison. |
| 686 bool TypeCheckAsClassEquality(const AbstractType& type); | 693 bool TypeCheckAsClassEquality(const AbstractType& type); |
| 687 | 694 |
| 688 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); | 695 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); |
| 689 | 696 |
| 690 void CopyParameters(); | 697 void CopyParameters(); |
| 698 #endif // !defined(TARGET_ARCH_DBC) |
| 691 | 699 |
| 692 void GenerateInlinedGetter(intptr_t offset); | 700 void GenerateInlinedGetter(intptr_t offset); |
| 693 void GenerateInlinedSetter(intptr_t offset); | 701 void GenerateInlinedSetter(intptr_t offset); |
| 694 | 702 |
| 695 // Perform a greedy local register allocation. Consider all registers free. | 703 // Perform a greedy local register allocation. Consider all registers free. |
| 696 void AllocateRegistersLocally(Instruction* instr); | 704 void AllocateRegistersLocally(Instruction* instr); |
| 697 | 705 |
| 698 // Map a block number in a forward iteration into the block number in the | 706 // Map a block number in a forward iteration into the block number in the |
| 699 // corresponding reverse iteration. Used to obtain an index into | 707 // corresponding reverse iteration. Used to obtain an index into |
| 700 // block_order for reverse iterations. | 708 // block_order for reverse iterations. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 713 | 721 |
| 714 intptr_t GetOptimizationThreshold() const; | 722 intptr_t GetOptimizationThreshold() const; |
| 715 | 723 |
| 716 StackmapTableBuilder* stackmap_table_builder() { | 724 StackmapTableBuilder* stackmap_table_builder() { |
| 717 if (stackmap_table_builder_ == NULL) { | 725 if (stackmap_table_builder_ == NULL) { |
| 718 stackmap_table_builder_ = new StackmapTableBuilder(); | 726 stackmap_table_builder_ = new StackmapTableBuilder(); |
| 719 } | 727 } |
| 720 return stackmap_table_builder_; | 728 return stackmap_table_builder_; |
| 721 } | 729 } |
| 722 | 730 |
| 723 #if defined(DEBUG) | 731 // TODO(vegorov) re-enable frame state tracking on DBC. It is |
| 732 // currently disabled because it relies on LocationSummaries and |
| 733 // we don't use them during unoptimized compilation on DBC. |
| 734 #if defined(DEBUG) && !defined(TARGET_ARCH_DBC) |
| 724 void FrameStateUpdateWith(Instruction* instr); | 735 void FrameStateUpdateWith(Instruction* instr); |
| 725 void FrameStatePush(Definition* defn); | 736 void FrameStatePush(Definition* defn); |
| 726 void FrameStatePop(intptr_t count); | 737 void FrameStatePop(intptr_t count); |
| 727 bool FrameStateIsSafeToCall(); | 738 bool FrameStateIsSafeToCall(); |
| 728 void FrameStateClear(); | 739 void FrameStateClear(); |
| 729 #endif | 740 #endif |
| 730 | 741 |
| 731 // This struct contains either function or code, the other one being NULL. | 742 // This struct contains either function or code, the other one being NULL. |
| 732 class StaticCallsStruct : public ZoneAllocated { | 743 class StaticCallsStruct : public ZoneAllocated { |
| 733 public: | 744 public: |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 const GrowableArray<const Function*>& inline_id_to_function_; | 816 const GrowableArray<const Function*>& inline_id_to_function_; |
| 806 const GrowableArray<TokenPosition>& inline_id_to_token_pos_; | 817 const GrowableArray<TokenPosition>& inline_id_to_token_pos_; |
| 807 const GrowableArray<intptr_t>& caller_inline_id_; | 818 const GrowableArray<intptr_t>& caller_inline_id_; |
| 808 | 819 |
| 809 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 820 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
| 810 }; | 821 }; |
| 811 | 822 |
| 812 } // namespace dart | 823 } // namespace dart |
| 813 | 824 |
| 814 #endif // VM_FLOW_GRAPH_COMPILER_H_ | 825 #endif // VM_FLOW_GRAPH_COMPILER_H_ |
| OLD | NEW |