Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 14215006: Re-apply r20377. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 Instruction* RemoveFromGraph(bool return_previous = true); 616 Instruction* RemoveFromGraph(bool return_previous = true);
617 617
618 // Normal instructions can have 0 (inside a block) or 1 (last instruction in 618 // Normal instructions can have 0 (inside a block) or 1 (last instruction in
619 // a block) successors. Branch instruction with >1 successors override this 619 // a block) successors. Branch instruction with >1 successors override this
620 // function. 620 // function.
621 virtual intptr_t SuccessorCount() const; 621 virtual intptr_t SuccessorCount() const;
622 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 622 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
623 623
624 void Goto(JoinEntryInstr* entry); 624 void Goto(JoinEntryInstr* entry);
625 625
626 // Mutate assigned_vars to add the local variable index for all
627 // frame-allocated locals assigned to by the instruction.
628 virtual void RecordAssignedVars(BitVector* assigned_vars,
629 intptr_t fixed_parameter_count);
630
631 virtual const char* DebugName() const = 0; 626 virtual const char* DebugName() const = 0;
632 627
633 // Printing support. 628 // Printing support.
634 virtual void PrintTo(BufferFormatter* f) const; 629 virtual void PrintTo(BufferFormatter* f) const;
635 virtual void PrintOperandsTo(BufferFormatter* f) const; 630 virtual void PrintOperandsTo(BufferFormatter* f) const;
636 631
637 #define INSTRUCTION_TYPE_CHECK(type) \ 632 #define INSTRUCTION_TYPE_CHECK(type) \
638 bool Is##type() { return (As##type() != NULL); } \ 633 bool Is##type() { return (As##type() != NULL); } \
639 virtual type##Instr* As##type() { return NULL; } 634 virtual type##Instr* As##type() { return NULL; }
640 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) 635 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK)
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 // The array 'assigned_vars' maps preorder block numbers to the set of 979 // The array 'assigned_vars' maps preorder block numbers to the set of
985 // assigned frame-allocated local variables in the block. As a side 980 // assigned frame-allocated local variables in the block. As a side
986 // effect of this function, the set of basic block predecessors (e.g., 981 // effect of this function, the set of basic block predecessors (e.g.,
987 // block entry instructions of predecessor blocks) and also the last 982 // block entry instructions of predecessor blocks) and also the last
988 // instruction in the block is recorded in each entry instruction. 983 // instruction in the block is recorded in each entry instruction.
989 void DiscoverBlocks( 984 void DiscoverBlocks(
990 BlockEntryInstr* predecessor, 985 BlockEntryInstr* predecessor,
991 GrowableArray<BlockEntryInstr*>* preorder, 986 GrowableArray<BlockEntryInstr*>* preorder,
992 GrowableArray<BlockEntryInstr*>* postorder, 987 GrowableArray<BlockEntryInstr*>* postorder,
993 GrowableArray<intptr_t>* parent, 988 GrowableArray<intptr_t>* parent,
994 GrowableArray<BitVector*>* assigned_vars,
995 intptr_t variable_count, 989 intptr_t variable_count,
996 intptr_t fixed_parameter_count); 990 intptr_t fixed_parameter_count);
997 991
998 virtual intptr_t InputCount() const { return 0; } 992 virtual intptr_t InputCount() const { return 0; }
999 virtual Value* InputAt(intptr_t i) const { 993 virtual Value* InputAt(intptr_t i) const {
1000 UNREACHABLE(); 994 UNREACHABLE();
1001 return NULL; 995 return NULL;
1002 } 996 }
1003 997
1004 virtual intptr_t ArgumentCount() const { return 0; } 998 virtual intptr_t ArgumentCount() const { return 0; }
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 // Precondition: use lists must be properly calculated. 1407 // Precondition: use lists must be properly calculated.
1414 // Postcondition: use lists and use values are still valid. 1408 // Postcondition: use lists and use values are still valid.
1415 void ReplaceUsesWith(Definition* other); 1409 void ReplaceUsesWith(Definition* other);
1416 1410
1417 // Replace this definition and all uses with another definition. If 1411 // Replace this definition and all uses with another definition. If
1418 // replacing during iteration, pass the iterator so that the instruction 1412 // replacing during iteration, pass the iterator so that the instruction
1419 // can be replaced without affecting iteration order, otherwise pass a 1413 // can be replaced without affecting iteration order, otherwise pass a
1420 // NULL iterator. 1414 // NULL iterator.
1421 void ReplaceWith(Definition* other, ForwardInstructionIterator* iterator); 1415 void ReplaceWith(Definition* other, ForwardInstructionIterator* iterator);
1422 1416
1423 virtual void RecordAssignedVars(BitVector* assigned_vars,
1424 intptr_t fixed_parameter_count);
1425
1426 // Printing support. These functions are sometimes overridden for custom 1417 // Printing support. These functions are sometimes overridden for custom
1427 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". 1418 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)".
1428 virtual void PrintTo(BufferFormatter* f) const; 1419 virtual void PrintTo(BufferFormatter* f) const;
1429 virtual void PrintOperandsTo(BufferFormatter* f) const; 1420 virtual void PrintOperandsTo(BufferFormatter* f) const;
1430 1421
1431 // A value in the constant propagation lattice. 1422 // A value in the constant propagation lattice.
1432 // - non-constant sentinel 1423 // - non-constant sentinel
1433 // - a constant (any non-sentinel value) 1424 // - a constant (any non-sentinel value)
1434 // - unknown sentinel 1425 // - unknown sentinel
1435 Object& constant_value() const { return constant_value_; } 1426 Object& constant_value() const { return constant_value_; }
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 2839
2849 // 'True' for recognized list constructors. 2840 // 'True' for recognized list constructors.
2850 bool is_known_list_constructor_; 2841 bool is_known_list_constructor_;
2851 2842
2852 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); 2843 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr);
2853 }; 2844 };
2854 2845
2855 2846
2856 class LoadLocalInstr : public TemplateDefinition<0> { 2847 class LoadLocalInstr : public TemplateDefinition<0> {
2857 public: 2848 public:
2858 explicit LoadLocalInstr(const LocalVariable& local) : local_(local) { } 2849 explicit LoadLocalInstr(const LocalVariable& local)
2850 : local_(local), is_last_(false) { }
2859 2851
2860 DECLARE_INSTRUCTION(LoadLocal) 2852 DECLARE_INSTRUCTION(LoadLocal)
2861 virtual CompileType ComputeType() const; 2853 virtual CompileType ComputeType() const;
2862 2854
2863 const LocalVariable& local() const { return local_; } 2855 const LocalVariable& local() const { return local_; }
2864 2856
2865 virtual void PrintOperandsTo(BufferFormatter* f) const; 2857 virtual void PrintOperandsTo(BufferFormatter* f) const;
2866 2858
2867 virtual bool CanDeoptimize() const { return false; } 2859 virtual bool CanDeoptimize() const { return false; }
2868 2860
2869 virtual bool HasSideEffect() const { 2861 virtual bool HasSideEffect() const {
2870 UNREACHABLE(); 2862 UNREACHABLE();
2871 return false; 2863 return false;
2872 } 2864 }
2873 2865
2866 void mark_last() { is_last_ = true; }
2867 bool is_last() const { return is_last_; }
2868
2874 private: 2869 private:
2875 const LocalVariable& local_; 2870 const LocalVariable& local_;
2871 bool is_last_;
2876 2872
2877 DISALLOW_COPY_AND_ASSIGN(LoadLocalInstr); 2873 DISALLOW_COPY_AND_ASSIGN(LoadLocalInstr);
2878 }; 2874 };
2879 2875
2880 2876
2881 class StoreLocalInstr : public TemplateDefinition<1> { 2877 class StoreLocalInstr : public TemplateDefinition<1> {
2882 public: 2878 public:
2883 StoreLocalInstr(const LocalVariable& local, Value* value) : local_(local) { 2879 StoreLocalInstr(const LocalVariable& local, Value* value)
2880 : local_(local), is_dead_(false), is_last_(false) {
2884 SetInputAt(0, value); 2881 SetInputAt(0, value);
2885 } 2882 }
2886 2883
2887 DECLARE_INSTRUCTION(StoreLocal) 2884 DECLARE_INSTRUCTION(StoreLocal)
2888 virtual CompileType* ComputeInitialType() const; 2885 virtual CompileType* ComputeInitialType() const;
2889 2886
2890 const LocalVariable& local() const { return local_; } 2887 const LocalVariable& local() const { return local_; }
2891 Value* value() const { return inputs_[0]; } 2888 Value* value() const { return inputs_[0]; }
2892 2889
2893 virtual void RecordAssignedVars(BitVector* assigned_vars,
2894 intptr_t fixed_parameter_count);
2895
2896 virtual void PrintOperandsTo(BufferFormatter* f) const; 2890 virtual void PrintOperandsTo(BufferFormatter* f) const;
2897 2891
2898 virtual bool CanDeoptimize() const { return false; } 2892 virtual bool CanDeoptimize() const { return false; }
2899 2893
2900 virtual bool HasSideEffect() const { 2894 virtual bool HasSideEffect() const {
2901 UNREACHABLE(); 2895 UNREACHABLE();
2902 return false; 2896 return false;
2903 } 2897 }
2904 2898
2899 void mark_dead() { is_dead_ = true; }
2900 bool is_dead() const { return is_dead_; }
2901
2902 void mark_last() { is_last_ = true; }
2903 bool is_last() const { return is_last_; }
2904
2905 private: 2905 private:
2906 const LocalVariable& local_; 2906 const LocalVariable& local_;
2907 bool is_dead_;
2908 bool is_last_;
2907 2909
2908 DISALLOW_COPY_AND_ASSIGN(StoreLocalInstr); 2910 DISALLOW_COPY_AND_ASSIGN(StoreLocalInstr);
2909 }; 2911 };
2910 2912
2911 2913
2912 class NativeCallInstr : public TemplateDefinition<0> { 2914 class NativeCallInstr : public TemplateDefinition<0> {
2913 public: 2915 public:
2914 explicit NativeCallInstr(NativeBodyNode* node) 2916 explicit NativeCallInstr(NativeBodyNode* node)
2915 : ast_node_(*node) {} 2917 : ast_node_(*node) {}
2916 2918
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after
4879 ForwardInstructionIterator* current_iterator_; 4881 ForwardInstructionIterator* current_iterator_;
4880 4882
4881 private: 4883 private:
4882 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4884 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4883 }; 4885 };
4884 4886
4885 4887
4886 } // namespace dart 4888 } // namespace dart
4887 4889
4888 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4890 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698