| 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 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 prev_instr->set_next(next_instr); | 181 prev_instr->set_next(next_instr); |
| 182 next_instr->set_previous(prev_instr); | 182 next_instr->set_previous(prev_instr); |
| 183 // Reset successor and previous instruction to indicate | 183 // Reset successor and previous instruction to indicate |
| 184 // that the instruction is removed from the graph. | 184 // that the instruction is removed from the graph. |
| 185 set_previous(NULL); | 185 set_previous(NULL); |
| 186 set_next(NULL); | 186 set_next(NULL); |
| 187 return return_previous ? prev_instr : next_instr; | 187 return return_previous ? prev_instr : next_instr; |
| 188 } | 188 } |
| 189 | 189 |
| 190 | 190 |
| 191 void BindInstr::InsertBefore(BindInstr* next) { | 191 void BindInstr::InsertBefore(Instruction* next) { |
| 192 ASSERT(previous_ == NULL); | 192 ASSERT(previous_ == NULL); |
| 193 ASSERT(next_ == NULL); | 193 ASSERT(next_ == NULL); |
| 194 next_ = next; | 194 next_ = next; |
| 195 previous_ = next->previous_; | 195 previous_ = next->previous_; |
| 196 next->previous_ = this; | 196 next->previous_ = this; |
| 197 previous_->next_ = this; | 197 previous_->next_ = this; |
| 198 } | 198 } |
| 199 | 199 |
| 200 | 200 |
| 201 void BindInstr::InsertAfter(Instruction* prev) { |
| 202 ASSERT(previous_ == NULL); |
| 203 ASSERT(next_ == NULL); |
| 204 previous_ = prev; |
| 205 next_ = prev->next_; |
| 206 next_->previous_ = this; |
| 207 previous_->next_ = this; |
| 208 } |
| 209 |
| 210 |
| 201 void ForwardInstructionIterator::RemoveCurrentFromGraph() { | 211 void ForwardInstructionIterator::RemoveCurrentFromGraph() { |
| 202 current_ = current_->RemoveFromGraph(true); // Set current_ to previous. | 212 current_ = current_->RemoveFromGraph(true); // Set current_ to previous. |
| 203 } | 213 } |
| 204 | 214 |
| 205 | 215 |
| 206 // Default implementation of visiting basic blocks. Can be overridden. | 216 // Default implementation of visiting basic blocks. Can be overridden. |
| 207 void FlowGraphVisitor::VisitBlocks() { | 217 void FlowGraphVisitor::VisitBlocks() { |
| 208 ASSERT(current_iterator_ == NULL); | 218 ASSERT(current_iterator_ == NULL); |
| 209 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 219 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 210 BlockEntryInstr* entry = block_order_[i]; | 220 BlockEntryInstr* entry = block_order_[i]; |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 RawAbstractType* BinaryDoubleOpComp::CompileType() const { | 1027 RawAbstractType* BinaryDoubleOpComp::CompileType() const { |
| 1018 return Type::DoubleInterface(); | 1028 return Type::DoubleInterface(); |
| 1019 } | 1029 } |
| 1020 | 1030 |
| 1021 | 1031 |
| 1022 intptr_t BinaryDoubleOpComp::ResultCid() const { | 1032 intptr_t BinaryDoubleOpComp::ResultCid() const { |
| 1023 return kDoubleCid; | 1033 return kDoubleCid; |
| 1024 } | 1034 } |
| 1025 | 1035 |
| 1026 | 1036 |
| 1037 RawAbstractType* UnboxedDoubleBinaryOpComp::CompileType() const { |
| 1038 return Type::DoubleInterface(); |
| 1039 } |
| 1040 |
| 1041 |
| 1042 RawAbstractType* UnboxDoubleComp::CompileType() const { |
| 1043 return Type::null(); |
| 1044 } |
| 1045 |
| 1046 |
| 1047 intptr_t BoxDoubleComp::ResultCid() const { |
| 1048 return kDoubleCid; |
| 1049 } |
| 1050 |
| 1051 |
| 1052 RawAbstractType* BoxDoubleComp::CompileType() const { |
| 1053 return Type::DoubleInterface(); |
| 1054 } |
| 1055 |
| 1056 |
| 1027 RawAbstractType* UnarySmiOpComp::CompileType() const { | 1057 RawAbstractType* UnarySmiOpComp::CompileType() const { |
| 1028 return Type::SmiType(); | 1058 return Type::SmiType(); |
| 1029 } | 1059 } |
| 1030 | 1060 |
| 1031 | 1061 |
| 1032 RawAbstractType* NumberNegateComp::CompileType() const { | 1062 RawAbstractType* NumberNegateComp::CompileType() const { |
| 1033 // Implemented only for doubles. | 1063 // Implemented only for doubles. |
| 1034 return Type::DoubleInterface(); | 1064 return Type::DoubleInterface(); |
| 1035 } | 1065 } |
| 1036 | 1066 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1048 RawAbstractType* CheckClassComp::CompileType() const { | 1078 RawAbstractType* CheckClassComp::CompileType() const { |
| 1049 return AbstractType::null(); | 1079 return AbstractType::null(); |
| 1050 } | 1080 } |
| 1051 | 1081 |
| 1052 | 1082 |
| 1053 RawAbstractType* CheckSmiComp::CompileType() const { | 1083 RawAbstractType* CheckSmiComp::CompileType() const { |
| 1054 return AbstractType::null(); | 1084 return AbstractType::null(); |
| 1055 } | 1085 } |
| 1056 | 1086 |
| 1057 | 1087 |
| 1088 RawAbstractType* CheckEitherNonSmiComp::CompileType() const { |
| 1089 return AbstractType::null(); |
| 1090 } |
| 1091 |
| 1092 |
| 1058 // Optimizations that eliminate or simplify individual computations. | 1093 // Optimizations that eliminate or simplify individual computations. |
| 1059 Definition* Computation::TryReplace(BindInstr* instr) const { | 1094 Definition* Computation::TryReplace(BindInstr* instr) const { |
| 1060 return instr; | 1095 return instr; |
| 1061 } | 1096 } |
| 1062 | 1097 |
| 1063 | 1098 |
| 1064 Definition* StrictCompareComp::TryReplace(BindInstr* instr) const { | 1099 Definition* StrictCompareComp::TryReplace(BindInstr* instr) const { |
| 1065 UseVal* left_use = left()->AsUse(); | 1100 UseVal* left_use = left()->AsUse(); |
| 1066 UseVal* right_use = right()->AsUse(); | 1101 UseVal* right_use = right()->AsUse(); |
| 1067 if ((right_use == NULL) || (left_use == NULL)) return instr; | 1102 if ((right_use == NULL) || (left_use == NULL)) return instr; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1083 } | 1118 } |
| 1084 return instr; | 1119 return instr; |
| 1085 } | 1120 } |
| 1086 | 1121 |
| 1087 | 1122 |
| 1088 Definition* CheckSmiComp::TryReplace(BindInstr* instr) const { | 1123 Definition* CheckSmiComp::TryReplace(BindInstr* instr) const { |
| 1089 return (value()->ResultCid() == kSmiCid) ? NULL : instr; | 1124 return (value()->ResultCid() == kSmiCid) ? NULL : instr; |
| 1090 } | 1125 } |
| 1091 | 1126 |
| 1092 | 1127 |
| 1128 Definition* CheckEitherNonSmiComp::TryReplace(BindInstr* instr) const { |
| 1129 if ((left()->ResultCid() == kDoubleCid) || |
| 1130 (right()->ResultCid() == kDoubleCid)) { |
| 1131 return NULL; // Remove from the graph. |
| 1132 } |
| 1133 return instr; |
| 1134 } |
| 1135 |
| 1136 |
| 1093 // Shared code generation methods (EmitNativeCode, MakeLocationSummary, and | 1137 // Shared code generation methods (EmitNativeCode, MakeLocationSummary, and |
| 1094 // PrepareEntry). Only assembly code that can be shared across all architectures | 1138 // PrepareEntry). Only assembly code that can be shared across all architectures |
| 1095 // can be used. Machine specific register allocation and code generation | 1139 // can be used. Machine specific register allocation and code generation |
| 1096 // is located in intermediate_language_<arch>.cc | 1140 // is located in intermediate_language_<arch>.cc |
| 1097 | 1141 |
| 1098 #define __ compiler->assembler()-> | 1142 #define __ compiler->assembler()-> |
| 1099 | 1143 |
| 1100 void GraphEntryInstr::PrepareEntry(FlowGraphCompiler* compiler) { | 1144 void GraphEntryInstr::PrepareEntry(FlowGraphCompiler* compiler) { |
| 1101 // Nothing to do. | 1145 // Nothing to do. |
| 1102 } | 1146 } |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 ? UseDefinition(values()[i]->AsUse()->definition()) | 1578 ? UseDefinition(values()[i]->AsUse()->definition()) |
| 1535 : val); | 1579 : val); |
| 1536 } | 1580 } |
| 1537 return copy; | 1581 return copy; |
| 1538 } | 1582 } |
| 1539 | 1583 |
| 1540 | 1584 |
| 1541 #undef __ | 1585 #undef __ |
| 1542 | 1586 |
| 1543 } // namespace dart | 1587 } // namespace dart |
| OLD | NEW |