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 | |
zra
2016/04/14 18:27:48
I'd leave these in and put UNREACHABLE() or simila
Florian Schneider
2016/04/15 01:17:28
I disagree. If we want to avoid the #ifdef here, o
Vyacheslav Egorov (Google)
2016/04/18 15:56:41
I am with Florian on this one. I think making them
| |
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 | |
zra
2016/04/14 18:27:48
add // !defined(TARGET_ARCH_DBC)
Vyacheslav Egorov (Google)
2016/04/18 15:56:41
Done.
| |
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 | |
496 | |
zra
2016/04/14 18:27:48
Extra space.
Vyacheslav Egorov (Google)
2016/04/18 15:56:41
Done.
| |
492 intptr_t StackSize() const; | 497 intptr_t StackSize() const; |
493 | 498 |
494 // Returns assembler label associated with the given block entry. | 499 // Returns assembler label associated with the given block entry. |
495 Label* GetJumpLabel(BlockEntryInstr* block_entry) const; | 500 Label* GetJumpLabel(BlockEntryInstr* block_entry) const; |
496 bool WasCompacted(BlockEntryInstr* block_entry) const; | 501 bool WasCompacted(BlockEntryInstr* block_entry) const; |
497 | 502 |
498 // Returns the label of the fall-through of the current block. | 503 // Returns the label of the fall-through of the current block. |
499 Label* NextNonEmptyLabel() const; | 504 Label* NextNonEmptyLabel() const; |
500 | 505 |
501 // Returns true if there is a next block after the current one in | 506 // 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, | 633 intptr_t deopt_id, |
629 TokenPosition token_pos, | 634 TokenPosition token_pos, |
630 LocationSummary* locs); | 635 LocationSummary* locs); |
631 | 636 |
632 void EmitUnoptimizedStaticCall(intptr_t argument_count, | 637 void EmitUnoptimizedStaticCall(intptr_t argument_count, |
633 intptr_t deopt_id, | 638 intptr_t deopt_id, |
634 TokenPosition token_pos, | 639 TokenPosition token_pos, |
635 LocationSummary* locs, | 640 LocationSummary* locs, |
636 const ICData& ic_data); | 641 const ICData& ic_data); |
637 | 642 |
643 // DBC handles type tests differently from all other architectures due | |
zra
2016/04/14 18:27:48
ditto.
Vyacheslav Egorov (Google)
2016/04/18 15:56:41
Acknowledged.
| |
644 // to its interpreted nature. | |
645 #if !defined(TARGET_ARCH_DBC) | |
638 // Type checking helper methods. | 646 // Type checking helper methods. |
639 void CheckClassIds(Register class_id_reg, | 647 void CheckClassIds(Register class_id_reg, |
640 const GrowableArray<intptr_t>& class_ids, | 648 const GrowableArray<intptr_t>& class_ids, |
641 Label* is_instance_lbl, | 649 Label* is_instance_lbl, |
642 Label* is_not_instance_lbl); | 650 Label* is_not_instance_lbl); |
643 | 651 |
644 RawSubtypeTestCache* GenerateInlineInstanceof(TokenPosition token_pos, | 652 RawSubtypeTestCache* GenerateInlineInstanceof(TokenPosition token_pos, |
645 const AbstractType& type, | 653 const AbstractType& type, |
646 Label* is_instance_lbl, | 654 Label* is_instance_lbl, |
647 Label* is_not_instance_lbl); | 655 Label* is_not_instance_lbl); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 Register temp_reg, | 689 Register temp_reg, |
682 Label* is_instance_lbl, | 690 Label* is_instance_lbl, |
683 Label* is_not_instance_lbl); | 691 Label* is_not_instance_lbl); |
684 | 692 |
685 // Returns true if checking against this type is a direct class id comparison. | 693 // Returns true if checking against this type is a direct class id comparison. |
686 bool TypeCheckAsClassEquality(const AbstractType& type); | 694 bool TypeCheckAsClassEquality(const AbstractType& type); |
687 | 695 |
688 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); | 696 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); |
689 | 697 |
690 void CopyParameters(); | 698 void CopyParameters(); |
699 #endif | |
zra
2016/04/14 18:27:48
add // !defined(TARGET_ARCH_DBC)
Vyacheslav Egorov (Google)
2016/04/18 15:56:41
Done.
| |
691 | 700 |
692 void GenerateInlinedGetter(intptr_t offset); | 701 void GenerateInlinedGetter(intptr_t offset); |
693 void GenerateInlinedSetter(intptr_t offset); | 702 void GenerateInlinedSetter(intptr_t offset); |
694 | 703 |
695 // Perform a greedy local register allocation. Consider all registers free. | 704 // Perform a greedy local register allocation. Consider all registers free. |
696 void AllocateRegistersLocally(Instruction* instr); | 705 void AllocateRegistersLocally(Instruction* instr); |
697 | 706 |
698 // Map a block number in a forward iteration into the block number in the | 707 // Map a block number in a forward iteration into the block number in the |
699 // corresponding reverse iteration. Used to obtain an index into | 708 // corresponding reverse iteration. Used to obtain an index into |
700 // block_order for reverse iterations. | 709 // block_order for reverse iterations. |
(...skipping 12 matching lines...) Expand all Loading... | |
713 | 722 |
714 intptr_t GetOptimizationThreshold() const; | 723 intptr_t GetOptimizationThreshold() const; |
715 | 724 |
716 StackmapTableBuilder* stackmap_table_builder() { | 725 StackmapTableBuilder* stackmap_table_builder() { |
717 if (stackmap_table_builder_ == NULL) { | 726 if (stackmap_table_builder_ == NULL) { |
718 stackmap_table_builder_ = new StackmapTableBuilder(); | 727 stackmap_table_builder_ = new StackmapTableBuilder(); |
719 } | 728 } |
720 return stackmap_table_builder_; | 729 return stackmap_table_builder_; |
721 } | 730 } |
722 | 731 |
723 #if defined(DEBUG) | 732 #if defined(DEBUG) && !defined(TARGET_ARCH_DBC) |
zra
2016/04/14 18:27:48
ditto or add comment.
Vyacheslav Egorov (Google)
2016/04/18 15:56:41
There is a comment in the CC code. Duplicated it h
| |
724 void FrameStateUpdateWith(Instruction* instr); | 733 void FrameStateUpdateWith(Instruction* instr); |
725 void FrameStatePush(Definition* defn); | 734 void FrameStatePush(Definition* defn); |
726 void FrameStatePop(intptr_t count); | 735 void FrameStatePop(intptr_t count); |
727 bool FrameStateIsSafeToCall(); | 736 bool FrameStateIsSafeToCall(); |
728 void FrameStateClear(); | 737 void FrameStateClear(); |
729 #endif | 738 #endif |
730 | 739 |
731 // This struct contains either function or code, the other one being NULL. | 740 // This struct contains either function or code, the other one being NULL. |
732 class StaticCallsStruct : public ZoneAllocated { | 741 class StaticCallsStruct : public ZoneAllocated { |
733 public: | 742 public: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 const GrowableArray<const Function*>& inline_id_to_function_; | 814 const GrowableArray<const Function*>& inline_id_to_function_; |
806 const GrowableArray<TokenPosition>& inline_id_to_token_pos_; | 815 const GrowableArray<TokenPosition>& inline_id_to_token_pos_; |
807 const GrowableArray<intptr_t>& caller_inline_id_; | 816 const GrowableArray<intptr_t>& caller_inline_id_; |
808 | 817 |
809 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 818 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
810 }; | 819 }; |
811 | 820 |
812 } // namespace dart | 821 } // namespace dart |
813 | 822 |
814 #endif // VM_FLOW_GRAPH_COMPILER_H_ | 823 #endif // VM_FLOW_GRAPH_COMPILER_H_ |
OLD | NEW |