| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 Value* next_use() const { return next_use_; } | 88 Value* next_use() const { return next_use_; } |
| 89 void set_next_use(Value* next) { next_use_ = next; } | 89 void set_next_use(Value* next) { next_use_ = next; } |
| 90 | 90 |
| 91 Instruction* instruction() const { return instruction_; } | 91 Instruction* instruction() const { return instruction_; } |
| 92 void set_instruction(Instruction* instruction) { instruction_ = instruction; } | 92 void set_instruction(Instruction* instruction) { instruction_ = instruction; } |
| 93 | 93 |
| 94 intptr_t use_index() const { return use_index_; } | 94 intptr_t use_index() const { return use_index_; } |
| 95 void set_use_index(intptr_t index) { use_index_ = index; } | 95 void set_use_index(intptr_t index) { use_index_ = index; } |
| 96 | 96 |
| 97 void AddToInputUseList(); | 97 static void AddToList(Value* value, Value** list); |
| 98 void AddToEnvUseList(); | 98 static void RemoveFromList(Value* value, Value** list); |
| 99 | |
| 100 void RemoveFromInputUseList(); | |
| 101 | 99 |
| 102 Value* Copy() { return new Value(definition_); } | 100 Value* Copy() { return new Value(definition_); } |
| 103 | 101 |
| 104 RawAbstractType* CompileType() const; | 102 RawAbstractType* CompileType() const; |
| 105 intptr_t ResultCid() const; | 103 intptr_t ResultCid() const; |
| 106 | 104 |
| 107 void PrintTo(BufferFormatter* f) const; | 105 void PrintTo(BufferFormatter* f) const; |
| 108 | 106 |
| 109 const char* DebugName() const { return "Value"; } | 107 const char* DebugName() const { return "Value"; } |
| 110 | 108 |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 bool HasUses() const { | 1100 bool HasUses() const { |
| 1103 return (input_use_list_ != NULL) || (env_use_list_ != NULL); | 1101 return (input_use_list_ != NULL) || (env_use_list_ != NULL); |
| 1104 } | 1102 } |
| 1105 | 1103 |
| 1106 Value* input_use_list() const { return input_use_list_; } | 1104 Value* input_use_list() const { return input_use_list_; } |
| 1107 void set_input_use_list(Value* head) { input_use_list_ = head; } | 1105 void set_input_use_list(Value* head) { input_use_list_ = head; } |
| 1108 | 1106 |
| 1109 Value* env_use_list() const { return env_use_list_; } | 1107 Value* env_use_list() const { return env_use_list_; } |
| 1110 void set_env_use_list(Value* head) { env_use_list_ = head; } | 1108 void set_env_use_list(Value* head) { env_use_list_ = head; } |
| 1111 | 1109 |
| 1110 void AddInputUse(Value* value) { Value::AddToList(value, &input_use_list_); } |
| 1111 void AddEnvUse(Value* value) { Value::AddToList(value, &env_use_list_); } |
| 1112 |
| 1113 void RemoveInputUse(Value* value) { |
| 1114 Value::RemoveFromList(value, &input_use_list_); |
| 1115 } |
| 1116 |
| 1112 // Replace uses of this definition with uses of other definition or value. | 1117 // Replace uses of this definition with uses of other definition or value. |
| 1113 // Precondition: use lists must be properly calculated. | 1118 // Precondition: use lists must be properly calculated. |
| 1114 // Postcondition: use lists and use values are still valid. | 1119 // Postcondition: use lists and use values are still valid. |
| 1115 void ReplaceUsesWith(Definition* other); | 1120 void ReplaceUsesWith(Definition* other); |
| 1116 | 1121 |
| 1117 // Replace this definition and all uses with another definition. If | 1122 // Replace this definition and all uses with another definition. If |
| 1118 // replacing during iteration, pass the iterator so that the instruction | 1123 // replacing during iteration, pass the iterator so that the instruction |
| 1119 // can be replaced without affecting iteration order, otherwise pass a | 1124 // can be replaced without affecting iteration order, otherwise pass a |
| 1120 // NULL iterator. | 1125 // NULL iterator. |
| 1121 void ReplaceWith(Definition* other, ForwardInstructionIterator* iterator); | 1126 void ReplaceWith(Definition* other, ForwardInstructionIterator* iterator); |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 | 1808 |
| 1804 Value* value() const { return inputs_[0]; } | 1809 Value* value() const { return inputs_[0]; } |
| 1805 Range* constraint() const { return constraint_; } | 1810 Range* constraint() const { return constraint_; } |
| 1806 | 1811 |
| 1807 virtual void InferRange(); | 1812 virtual void InferRange(); |
| 1808 | 1813 |
| 1809 void AddDependency(Definition* defn) { | 1814 void AddDependency(Definition* defn) { |
| 1810 Value* val = new Value(defn); | 1815 Value* val = new Value(defn); |
| 1811 val->set_use_index(1); | 1816 val->set_use_index(1); |
| 1812 val->set_instruction(this); | 1817 val->set_instruction(this); |
| 1813 val->AddToInputUseList(); | 1818 defn->AddInputUse(val); |
| 1814 set_dependency(val); | 1819 set_dependency(val); |
| 1815 } | 1820 } |
| 1816 | 1821 |
| 1817 void RemoveDependency() { | 1822 void RemoveDependency() { |
| 1818 if (dependency() != NULL) { | 1823 if (dependency() != NULL) { |
| 1819 dependency()->RemoveFromInputUseList(); | 1824 dependency()->definition()->RemoveInputUse(dependency()); |
| 1820 set_dependency(NULL); | 1825 set_dependency(NULL); |
| 1821 } | 1826 } |
| 1822 } | 1827 } |
| 1823 | 1828 |
| 1824 private: | 1829 private: |
| 1825 Value* dependency() { | 1830 Value* dependency() { |
| 1826 return inputs_[1]; | 1831 return inputs_[1]; |
| 1827 } | 1832 } |
| 1828 | 1833 |
| 1829 void set_dependency(Value* value) { | 1834 void set_dependency(Value* value) { |
| (...skipping 2640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4470 ForwardInstructionIterator* current_iterator_; | 4475 ForwardInstructionIterator* current_iterator_; |
| 4471 | 4476 |
| 4472 private: | 4477 private: |
| 4473 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4478 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4474 }; | 4479 }; |
| 4475 | 4480 |
| 4476 | 4481 |
| 4477 } // namespace dart | 4482 } // namespace dart |
| 4478 | 4483 |
| 4479 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4484 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |