| 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 RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ | 5 #ifndef RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ |
| 6 #define RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ | 6 #define RUNTIME_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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 private: | 226 private: |
| 227 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; | 227 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; |
| 228 | 228 |
| 229 Label entry_label_; | 229 Label entry_label_; |
| 230 Label exit_label_; | 230 Label exit_label_; |
| 231 | 231 |
| 232 DISALLOW_COPY_AND_ASSIGN(SlowPathCode); | 232 DISALLOW_COPY_AND_ASSIGN(SlowPathCode); |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 | 235 |
| 236 struct CidRangeTarget { |
| 237 intptr_t cid_start; |
| 238 intptr_t cid_end; |
| 239 Function* target; |
| 240 intptr_t count; |
| 241 CidRangeTarget(intptr_t cid_start_arg, |
| 242 intptr_t cid_end_arg, |
| 243 Function* target_arg, |
| 244 intptr_t count_arg) |
| 245 : cid_start(cid_start_arg), |
| 246 cid_end(cid_end_arg), |
| 247 target(target_arg), |
| 248 count(count_arg) {} |
| 249 }; |
| 250 |
| 251 |
| 236 class FlowGraphCompiler : public ValueObject { | 252 class FlowGraphCompiler : public ValueObject { |
| 237 private: | 253 private: |
| 238 class BlockInfo : public ZoneAllocated { | 254 class BlockInfo : public ZoneAllocated { |
| 239 public: | 255 public: |
| 240 BlockInfo() | 256 BlockInfo() |
| 241 : block_label_(), | 257 : block_label_(), |
| 242 jump_label_(&block_label_), | 258 jump_label_(&block_label_), |
| 243 next_nonempty_label_(NULL), | 259 next_nonempty_label_(NULL), |
| 244 is_marked_(false) {} | 260 is_marked_(false) {} |
| 245 | 261 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 TokenPosition token_pos, | 427 TokenPosition token_pos, |
| 412 LocationSummary* locs); | 428 LocationSummary* locs); |
| 413 | 429 |
| 414 void EmitInstanceCall(const StubEntry& stub_entry, | 430 void EmitInstanceCall(const StubEntry& stub_entry, |
| 415 const ICData& ic_data, | 431 const ICData& ic_data, |
| 416 intptr_t argument_count, | 432 intptr_t argument_count, |
| 417 intptr_t deopt_id, | 433 intptr_t deopt_id, |
| 418 TokenPosition token_pos, | 434 TokenPosition token_pos, |
| 419 LocationSummary* locs); | 435 LocationSummary* locs); |
| 420 | 436 |
| 421 void EmitPolymorphicInstanceCall( | 437 void EmitPolymorphicInstanceCall(const ICData& ic_data, |
| 422 const CallTargets& targets, | 438 intptr_t argument_count, |
| 423 const InstanceCallInstr& original_instruction, | 439 const Array& argument_names, |
| 424 intptr_t argument_count, | 440 intptr_t deopt_id, |
| 425 const Array& argument_names, | 441 TokenPosition token_pos, |
| 426 intptr_t deopt_id, | 442 LocationSummary* locs, |
| 427 TokenPosition token_pos, | 443 bool complete, |
| 428 LocationSummary* locs, | 444 intptr_t total_call_count); |
| 429 bool complete, | |
| 430 intptr_t total_call_count); | |
| 431 | 445 |
| 432 // Pass a value for try-index where block is not available (e.g. slow path). | 446 // Pass a value for try-index where block is not available (e.g. slow path). |
| 433 void EmitMegamorphicInstanceCall(const String& function_name, | 447 void EmitMegamorphicInstanceCall(const ICData& ic_data, |
| 434 const Array& arguments_descriptor, | |
| 435 intptr_t argument_count, | 448 intptr_t argument_count, |
| 436 intptr_t deopt_id, | 449 intptr_t deopt_id, |
| 437 TokenPosition token_pos, | 450 TokenPosition token_pos, |
| 438 LocationSummary* locs, | 451 LocationSummary* locs, |
| 439 intptr_t try_index, | 452 intptr_t try_index, |
| 440 intptr_t slow_path_argument_count = 0); | 453 intptr_t slow_path_argument_count = 0); |
| 441 | 454 |
| 442 void EmitSwitchableInstanceCall(const ICData& ic_data, | 455 void EmitSwitchableInstanceCall(const ICData& ic_data, |
| 443 intptr_t argument_count, | 456 intptr_t argument_count, |
| 444 intptr_t deopt_id, | 457 intptr_t deopt_id, |
| 445 TokenPosition token_pos, | 458 TokenPosition token_pos, |
| 446 LocationSummary* locs); | 459 LocationSummary* locs); |
| 447 | 460 |
| 448 void EmitTestAndCall(const CallTargets& targets, | 461 void EmitTestAndCall(const ICData& ic_data, |
| 449 const String& function_name, | |
| 450 intptr_t arg_count, | 462 intptr_t arg_count, |
| 451 const Array& arg_names, | 463 const Array& arg_names, |
| 452 Label* failed, | 464 Label* failed, |
| 453 Label* match_found, | 465 Label* match_found, |
| 454 intptr_t deopt_id, | 466 intptr_t deopt_id, |
| 455 TokenPosition token_index, | 467 TokenPosition token_index, |
| 456 LocationSummary* locs, | 468 LocationSummary* locs, |
| 457 bool complete, | 469 bool complete, |
| 458 intptr_t total_ic_calls); | 470 intptr_t total_ic_calls); |
| 459 | 471 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 const ICData* GetOrAddInstanceCallICData(intptr_t deopt_id, | 594 const ICData* GetOrAddInstanceCallICData(intptr_t deopt_id, |
| 583 const String& target_name, | 595 const String& target_name, |
| 584 const Array& arguments_descriptor, | 596 const Array& arguments_descriptor, |
| 585 intptr_t num_args_tested); | 597 intptr_t num_args_tested); |
| 586 | 598 |
| 587 const ICData* GetOrAddStaticCallICData(intptr_t deopt_id, | 599 const ICData* GetOrAddStaticCallICData(intptr_t deopt_id, |
| 588 const Function& target, | 600 const Function& target, |
| 589 const Array& arguments_descriptor, | 601 const Array& arguments_descriptor, |
| 590 intptr_t num_args_tested); | 602 intptr_t num_args_tested); |
| 591 | 603 |
| 592 static const CallTargets* ResolveCallTargetsForReceiverCid( | 604 static const ICData& TrySpecializeICDataByReceiverCid(const ICData& ic_data, |
| 593 intptr_t cid, | 605 intptr_t cid); |
| 594 const String& selector, | |
| 595 const Array& args_desc_array); | |
| 596 | 606 |
| 597 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data() const { | 607 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data() const { |
| 598 return *deopt_id_to_ic_data_; | 608 return *deopt_id_to_ic_data_; |
| 599 } | 609 } |
| 600 | 610 |
| 601 Thread* thread() const { return thread_; } | 611 Thread* thread() const { return thread_; } |
| 602 Isolate* isolate() const { return thread_->isolate(); } | 612 Isolate* isolate() const { return thread_->isolate(); } |
| 603 Zone* zone() const { return zone_; } | 613 Zone* zone() const { return zone_; } |
| 604 | 614 |
| 605 void AddStubCallTarget(const Code& code); | 615 void AddStubCallTarget(const Code& code); |
| 606 | 616 |
| 607 RawArray* edge_counters_array() const { return edge_counters_array_.raw(); } | 617 RawArray* edge_counters_array() const { return edge_counters_array_.raw(); } |
| 608 | 618 |
| 609 RawArray* InliningIdToFunction() const; | 619 RawArray* InliningIdToFunction() const; |
| 610 | 620 |
| 611 void BeginCodeSourceRange(); | 621 void BeginCodeSourceRange(); |
| 612 void EndCodeSourceRange(TokenPosition token_pos); | 622 void EndCodeSourceRange(TokenPosition token_pos); |
| 613 | 623 |
| 614 static bool LookupMethodFor(int class_id, | |
| 615 const String& name, | |
| 616 const ArgumentsDescriptor& args_desc, | |
| 617 Function* fn_return); | |
| 618 | |
| 619 #if defined(TARGET_ARCH_DBC) | 624 #if defined(TARGET_ARCH_DBC) |
| 620 enum CallResult { | 625 enum CallResult { |
| 621 kHasResult, | 626 kHasResult, |
| 622 kNoResult, | 627 kNoResult, |
| 623 }; | 628 }; |
| 624 void RecordAfterCallHelper(TokenPosition token_pos, | 629 void RecordAfterCallHelper(TokenPosition token_pos, |
| 625 intptr_t deopt_id, | 630 intptr_t deopt_id, |
| 626 intptr_t argument_count, | 631 intptr_t argument_count, |
| 627 CallResult result, | 632 CallResult result, |
| 628 LocationSummary* locs); | 633 LocationSummary* locs); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 654 LocationSummary* locs); | 659 LocationSummary* locs); |
| 655 | 660 |
| 656 void EmitUnoptimizedStaticCall(intptr_t argument_count, | 661 void EmitUnoptimizedStaticCall(intptr_t argument_count, |
| 657 intptr_t deopt_id, | 662 intptr_t deopt_id, |
| 658 TokenPosition token_pos, | 663 TokenPosition token_pos, |
| 659 LocationSummary* locs, | 664 LocationSummary* locs, |
| 660 const ICData& ic_data); | 665 const ICData& ic_data); |
| 661 | 666 |
| 662 // Helper for TestAndCall that calculates a good bias that | 667 // Helper for TestAndCall that calculates a good bias that |
| 663 // allows more compact instructions to be emitted. | 668 // allows more compact instructions to be emitted. |
| 664 intptr_t ComputeGoodBiasForCidComparison(const CallTargets& sorted, | 669 intptr_t ComputeGoodBiasForCidComparison( |
| 665 intptr_t max_immediate); | 670 const GrowableArray<CidRangeTarget>& sorted, |
| 666 | 671 intptr_t max_immediate); |
| 667 // More helpers for EmitTestAndCall. | |
| 668 void EmitTestAndCallLoadReceiver(intptr_t argument_count, | |
| 669 const Array& arguments_descriptor); | |
| 670 | |
| 671 void EmitTestAndCallSmiBranch(Label* label, bool if_smi); | |
| 672 | |
| 673 void EmitTestAndCallLoadCid(); | |
| 674 | |
| 675 // Returns new class-id bias. | |
| 676 int EmitTestAndCallCheckCid(Label* next_label, | |
| 677 const CidRangeTarget& target, | |
| 678 int bias); | |
| 679 | 672 |
| 680 // DBC handles type tests differently from all other architectures due | 673 // DBC handles type tests differently from all other architectures due |
| 681 // to its interpreted nature. | 674 // to its interpreted nature. |
| 682 #if !defined(TARGET_ARCH_DBC) | 675 #if !defined(TARGET_ARCH_DBC) |
| 683 // Type checking helper methods. | 676 // Type checking helper methods. |
| 684 void CheckClassIds(Register class_id_reg, | 677 void CheckClassIds(Register class_id_reg, |
| 685 const GrowableArray<intptr_t>& class_ids, | 678 const GrowableArray<intptr_t>& class_ids, |
| 686 Label* is_instance_lbl, | 679 Label* is_instance_lbl, |
| 687 Label* is_not_instance_lbl); | 680 Label* is_not_instance_lbl); |
| 688 | 681 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data_; | 839 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data_; |
| 847 | 840 |
| 848 Array& edge_counters_array_; | 841 Array& edge_counters_array_; |
| 849 | 842 |
| 850 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 843 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
| 851 }; | 844 }; |
| 852 | 845 |
| 853 } // namespace dart | 846 } // namespace dart |
| 854 | 847 |
| 855 #endif // RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ | 848 #endif // RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ |
| OLD | NEW |