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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 private: | 225 private: |
226 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; | 226 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; |
227 | 227 |
228 Label entry_label_; | 228 Label entry_label_; |
229 Label exit_label_; | 229 Label exit_label_; |
230 | 230 |
231 DISALLOW_COPY_AND_ASSIGN(SlowPathCode); | 231 DISALLOW_COPY_AND_ASSIGN(SlowPathCode); |
232 }; | 232 }; |
233 | 233 |
234 | 234 |
235 struct CidTarget { | 235 struct CidRangeTarget { |
236 intptr_t cid; | 236 intptr_t cid_start; |
237 intptr_t cid_end; | |
237 Function* target; | 238 Function* target; |
238 intptr_t count; | 239 intptr_t count; |
239 CidTarget(intptr_t cid_arg, Function* target_arg, intptr_t count_arg) | 240 CidRangeTarget(intptr_t cid_start_arg, |
240 : cid(cid_arg), target(target_arg), count(count_arg) {} | 241 intptr_t cid_end_arg, |
242 Function* target_arg, | |
243 intptr_t count_arg) | |
244 : cid_start(cid_start_arg), | |
245 cid_end(cid_end_arg), | |
246 target(target_arg), | |
247 count(count_arg) {} | |
241 }; | 248 }; |
242 | 249 |
243 | 250 |
244 class FlowGraphCompiler : public ValueObject { | 251 class FlowGraphCompiler : public ValueObject { |
245 private: | 252 private: |
246 class BlockInfo : public ZoneAllocated { | 253 class BlockInfo : public ZoneAllocated { |
247 public: | 254 public: |
248 BlockInfo() | 255 BlockInfo() |
249 : block_label_(), | 256 : block_label_(), |
250 jump_label_(&block_label_), | 257 jump_label_(&block_label_), |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 intptr_t deopt_id, | 427 intptr_t deopt_id, |
421 TokenPosition token_pos, | 428 TokenPosition token_pos, |
422 LocationSummary* locs); | 429 LocationSummary* locs); |
423 | 430 |
424 void EmitPolymorphicInstanceCall(const ICData& ic_data, | 431 void EmitPolymorphicInstanceCall(const ICData& ic_data, |
425 intptr_t argument_count, | 432 intptr_t argument_count, |
426 const Array& argument_names, | 433 const Array& argument_names, |
427 intptr_t deopt_id, | 434 intptr_t deopt_id, |
428 TokenPosition token_pos, | 435 TokenPosition token_pos, |
429 LocationSummary* locs, | 436 LocationSummary* locs, |
430 bool complete); | 437 bool complete, |
438 intptr_t total_ic_count); | |
431 | 439 |
432 // Pass a value for try-index where block is not available (e.g. slow path). | 440 // Pass a value for try-index where block is not available (e.g. slow path). |
433 void EmitMegamorphicInstanceCall(const ICData& ic_data, | 441 void EmitMegamorphicInstanceCall(const ICData& ic_data, |
434 intptr_t argument_count, | 442 intptr_t argument_count, |
435 intptr_t deopt_id, | 443 intptr_t deopt_id, |
436 TokenPosition token_pos, | 444 TokenPosition token_pos, |
437 LocationSummary* locs, | 445 LocationSummary* locs, |
438 intptr_t try_index, | 446 intptr_t try_index, |
439 intptr_t slow_path_argument_count = 0); | 447 intptr_t slow_path_argument_count = 0); |
440 | 448 |
441 void EmitSwitchableInstanceCall(const ICData& ic_data, | 449 void EmitSwitchableInstanceCall(const ICData& ic_data, |
442 intptr_t argument_count, | 450 intptr_t argument_count, |
443 intptr_t deopt_id, | 451 intptr_t deopt_id, |
444 TokenPosition token_pos, | 452 TokenPosition token_pos, |
445 LocationSummary* locs); | 453 LocationSummary* locs); |
446 | 454 |
447 void EmitTestAndCall(const ICData& ic_data, | 455 void EmitTestAndCall(const ICData& ic_data, |
448 intptr_t arg_count, | 456 intptr_t arg_count, |
449 const Array& arg_names, | 457 const Array& arg_names, |
450 Label* failed, | 458 Label* failed, |
451 Label* match_found, | 459 Label* match_found, |
452 intptr_t deopt_id, | 460 intptr_t deopt_id, |
453 TokenPosition token_index, | 461 TokenPosition token_index, |
454 LocationSummary* locs, | 462 LocationSummary* locs, |
455 bool complete); | 463 bool complete, |
464 intptr_t total_ic_calls); | |
456 | 465 |
457 Condition EmitEqualityRegConstCompare(Register reg, | 466 Condition EmitEqualityRegConstCompare(Register reg, |
458 const Object& obj, | 467 const Object& obj, |
459 bool needs_number_check, | 468 bool needs_number_check, |
460 TokenPosition token_pos); | 469 TokenPosition token_pos); |
461 Condition EmitEqualityRegRegCompare(Register left, | 470 Condition EmitEqualityRegRegCompare(Register left, |
462 Register right, | 471 Register right, |
463 bool needs_number_check, | 472 bool needs_number_check, |
464 TokenPosition token_pos); | 473 TokenPosition token_pos); |
465 | 474 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 if (current_block_ == NULL) { | 562 if (current_block_ == NULL) { |
554 return CatchClauseNode::kInvalidTryIndex; | 563 return CatchClauseNode::kInvalidTryIndex; |
555 } | 564 } |
556 return current_block_->try_index(); | 565 return current_block_->try_index(); |
557 } | 566 } |
558 | 567 |
559 bool may_reoptimize() const { return may_reoptimize_; } | 568 bool may_reoptimize() const { return may_reoptimize_; } |
560 | 569 |
561 // Returns 'sorted' array in decreasing count order. | 570 // Returns 'sorted' array in decreasing count order. |
562 static void SortICDataByCount(const ICData& ic_data, | 571 static void SortICDataByCount(const ICData& ic_data, |
563 GrowableArray<CidTarget>* sorted, | 572 GrowableArray<CidRangeTarget>* sorted, |
564 bool drop_smi); | 573 bool drop_smi); |
565 | 574 |
566 // Use in unoptimized compilation to preserve/reuse ICData. | 575 // Use in unoptimized compilation to preserve/reuse ICData. |
567 const ICData* GetOrAddInstanceCallICData(intptr_t deopt_id, | 576 const ICData* GetOrAddInstanceCallICData(intptr_t deopt_id, |
568 const String& target_name, | 577 const String& target_name, |
569 const Array& arguments_descriptor, | 578 const Array& arguments_descriptor, |
570 intptr_t num_args_tested); | 579 intptr_t num_args_tested); |
571 | 580 |
572 const ICData* GetOrAddStaticCallICData(intptr_t deopt_id, | 581 const ICData* GetOrAddStaticCallICData(intptr_t deopt_id, |
573 const Function& target, | 582 const Function& target, |
(...skipping 29 matching lines...) Expand all Loading... | |
603 intptr_t deopt_id, | 612 intptr_t deopt_id, |
604 intptr_t argument_count, | 613 intptr_t argument_count, |
605 CallResult result, | 614 CallResult result, |
606 LocationSummary* locs); | 615 LocationSummary* locs); |
607 void RecordAfterCall(Instruction* instr, CallResult result); | 616 void RecordAfterCall(Instruction* instr, CallResult result); |
608 #endif | 617 #endif |
609 | 618 |
610 private: | 619 private: |
611 friend class CheckStackOverflowSlowPath; // For pending_deoptimization_env_. | 620 friend class CheckStackOverflowSlowPath; // For pending_deoptimization_env_. |
612 | 621 |
613 static bool ShouldInlineSmiStringHashCode(const ICData& ic_data); | |
614 | |
615 void EmitFrameEntry(); | 622 void EmitFrameEntry(); |
616 | 623 |
617 void AddStaticCallTarget(const Function& function); | 624 void AddStaticCallTarget(const Function& function); |
618 | 625 |
619 void GenerateDeferredCode(); | 626 void GenerateDeferredCode(); |
620 | 627 |
621 void EmitInstructionPrologue(Instruction* instr); | 628 void EmitInstructionPrologue(Instruction* instr); |
622 void EmitInstructionEpilogue(Instruction* instr); | 629 void EmitInstructionEpilogue(Instruction* instr); |
623 | 630 |
624 // Emit code to load a Value into register 'dst'. | 631 // Emit code to load a Value into register 'dst'. |
625 void LoadValue(Register dst, Value* value); | 632 void LoadValue(Register dst, Value* value); |
626 | 633 |
627 void EmitOptimizedStaticCall(const Function& function, | 634 void EmitOptimizedStaticCall(const Function& function, |
628 const Array& arguments_descriptor, | 635 const Array& arguments_descriptor, |
629 intptr_t argument_count, | 636 intptr_t argument_count, |
630 intptr_t deopt_id, | 637 intptr_t deopt_id, |
631 TokenPosition token_pos, | 638 TokenPosition token_pos, |
632 LocationSummary* locs); | 639 LocationSummary* locs); |
633 | 640 |
634 void EmitUnoptimizedStaticCall(intptr_t argument_count, | 641 void EmitUnoptimizedStaticCall(intptr_t argument_count, |
635 intptr_t deopt_id, | 642 intptr_t deopt_id, |
636 TokenPosition token_pos, | 643 TokenPosition token_pos, |
637 LocationSummary* locs, | 644 LocationSummary* locs, |
638 const ICData& ic_data); | 645 const ICData& ic_data); |
639 | 646 |
647 // Helper for TestAndCall that calculates a good bias that | |
648 // allows more compact instructions to be emitted. | |
649 intptr_t GetGoodBias(const GrowableArray<CidRangeTarget>& sorted, | |
Vyacheslav Egorov (Google)
2017/03/10 10:31:30
ComputeGoodBiasForCidComparison(...)?
erikcorry
2017/03/10 13:30:01
Done.
| |
650 intptr_t max_immediate); | |
651 | |
640 // DBC handles type tests differently from all other architectures due | 652 // DBC handles type tests differently from all other architectures due |
641 // to its interpreted nature. | 653 // to its interpreted nature. |
642 #if !defined(TARGET_ARCH_DBC) | 654 #if !defined(TARGET_ARCH_DBC) |
643 // Type checking helper methods. | 655 // Type checking helper methods. |
644 void CheckClassIds(Register class_id_reg, | 656 void CheckClassIds(Register class_id_reg, |
645 const GrowableArray<intptr_t>& class_ids, | 657 const GrowableArray<intptr_t>& class_ids, |
646 Label* is_instance_lbl, | 658 Label* is_instance_lbl, |
647 Label* is_not_instance_lbl); | 659 Label* is_not_instance_lbl); |
648 | 660 |
649 RawSubtypeTestCache* GenerateInlineInstanceof(TokenPosition token_pos, | 661 RawSubtypeTestCache* GenerateInlineInstanceof(TokenPosition token_pos, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data_; | 815 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data_; |
804 | 816 |
805 Array& edge_counters_array_; | 817 Array& edge_counters_array_; |
806 | 818 |
807 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 819 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
808 }; | 820 }; |
809 | 821 |
810 } // namespace dart | 822 } // namespace dart |
811 | 823 |
812 #endif // RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ | 824 #endif // RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ |
OLD | NEW |