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 #include "vm/flow_graph_inliner.h" | 5 #include "vm/flow_graph_inliner.h" |
6 | 6 |
7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
8 #include "vm/block_scheduler.h" | 8 #include "vm/block_scheduler.h" |
9 #include "vm/branch_optimizer.h" | 9 #include "vm/branch_optimizer.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 *cursor = flow_graph->AppendTo(*cursor, | 2095 *cursor = flow_graph->AppendTo(*cursor, |
2096 elements, | 2096 elements, |
2097 NULL, | 2097 NULL, |
2098 FlowGraph::kValue); | 2098 FlowGraph::kValue); |
2099 *array = elements; | 2099 *array = elements; |
2100 } | 2100 } |
2101 return array_cid; | 2101 return array_cid; |
2102 } | 2102 } |
2103 | 2103 |
2104 | 2104 |
2105 static intptr_t MethodKindToCid(MethodRecognizer::Kind kind) { | |
2106 switch (kind) { | |
2107 case MethodRecognizer::kImmutableArrayGetIndexed: | |
2108 return kImmutableArrayCid; | |
2109 | |
2110 case MethodRecognizer::kObjectArrayGetIndexed: | |
2111 case MethodRecognizer::kObjectArraySetIndexed: | |
2112 return kArrayCid; | |
2113 | |
2114 case MethodRecognizer::kGrowableArrayGetIndexed: | |
2115 case MethodRecognizer::kGrowableArraySetIndexed: | |
2116 return kGrowableObjectArrayCid; | |
2117 | |
2118 case MethodRecognizer::kFloat32ArrayGetIndexed: | |
2119 case MethodRecognizer::kFloat32ArraySetIndexed: | |
2120 return kTypedDataFloat32ArrayCid; | |
2121 | |
2122 case MethodRecognizer::kFloat64ArrayGetIndexed: | |
2123 case MethodRecognizer::kFloat64ArraySetIndexed: | |
2124 return kTypedDataFloat64ArrayCid; | |
2125 | |
2126 case MethodRecognizer::kInt8ArrayGetIndexed: | |
2127 case MethodRecognizer::kInt8ArraySetIndexed: | |
2128 return kTypedDataInt8ArrayCid; | |
2129 | |
2130 case MethodRecognizer::kUint8ArrayGetIndexed: | |
2131 case MethodRecognizer::kUint8ArraySetIndexed: | |
2132 return kTypedDataUint8ArrayCid; | |
2133 | |
2134 case MethodRecognizer::kUint8ClampedArrayGetIndexed: | |
2135 case MethodRecognizer::kUint8ClampedArraySetIndexed: | |
2136 return kTypedDataUint8ClampedArrayCid; | |
2137 | |
2138 case MethodRecognizer::kExternalUint8ArrayGetIndexed: | |
2139 case MethodRecognizer::kExternalUint8ArraySetIndexed: | |
2140 return kExternalTypedDataUint8ArrayCid; | |
2141 | |
2142 case MethodRecognizer::kExternalUint8ClampedArrayGetIndexed: | |
2143 case MethodRecognizer::kExternalUint8ClampedArraySetIndexed: | |
2144 return kExternalTypedDataUint8ClampedArrayCid; | |
2145 | |
2146 case MethodRecognizer::kInt16ArrayGetIndexed: | |
2147 case MethodRecognizer::kInt16ArraySetIndexed: | |
2148 return kTypedDataInt16ArrayCid; | |
2149 | |
2150 case MethodRecognizer::kUint16ArrayGetIndexed: | |
2151 case MethodRecognizer::kUint16ArraySetIndexed: | |
2152 return kTypedDataUint16ArrayCid; | |
2153 | |
2154 case MethodRecognizer::kInt32ArrayGetIndexed: | |
2155 case MethodRecognizer::kInt32ArraySetIndexed: | |
2156 return kTypedDataInt32ArrayCid; | |
2157 | |
2158 case MethodRecognizer::kUint32ArrayGetIndexed: | |
2159 case MethodRecognizer::kUint32ArraySetIndexed: | |
2160 return kTypedDataUint32ArrayCid; | |
2161 | |
2162 case MethodRecognizer::kInt64ArrayGetIndexed: | |
2163 case MethodRecognizer::kInt64ArraySetIndexed: | |
2164 return kTypedDataInt64ArrayCid; | |
2165 | |
2166 case MethodRecognizer::kFloat32x4ArrayGetIndexed: | |
2167 case MethodRecognizer::kFloat32x4ArraySetIndexed: | |
2168 return kTypedDataFloat32x4ArrayCid; | |
2169 | |
2170 case MethodRecognizer::kInt32x4ArrayGetIndexed: | |
2171 case MethodRecognizer::kInt32x4ArraySetIndexed: | |
2172 return kTypedDataInt32x4ArrayCid; | |
2173 | |
2174 case MethodRecognizer::kFloat64x2ArrayGetIndexed: | |
2175 case MethodRecognizer::kFloat64x2ArraySetIndexed: | |
2176 return kTypedDataFloat64x2ArrayCid; | |
2177 | |
2178 default: | |
2179 break; | |
2180 } | |
2181 return kIllegalCid; | |
2182 } | |
2183 | |
2184 | |
2185 static Instruction* GetCheckClass(FlowGraph* flow_graph, | 2105 static Instruction* GetCheckClass(FlowGraph* flow_graph, |
2186 Definition* to_check, | 2106 Definition* to_check, |
2187 const ICData& unary_checks, | 2107 const ICData& unary_checks, |
2188 intptr_t deopt_id, | 2108 intptr_t deopt_id, |
2189 TokenPosition token_pos) { | 2109 TokenPosition token_pos) { |
2190 if ((unary_checks.NumberOfUsedChecks() == 1) && | 2110 if ((unary_checks.NumberOfUsedChecks() == 1) && |
2191 unary_checks.HasReceiverClassId(kSmiCid)) { | 2111 unary_checks.HasReceiverClassId(kSmiCid)) { |
2192 return new(Z) CheckSmiInstr(new(Z) Value(to_check), | 2112 return new(Z) CheckSmiInstr(new(Z) Value(to_check), |
2193 deopt_id, | 2113 deopt_id, |
2194 token_pos); | 2114 token_pos); |
2195 } | 2115 } |
2196 return new(Z) CheckClassInstr( | 2116 return new(Z) CheckClassInstr( |
2197 new(Z) Value(to_check), deopt_id, unary_checks, token_pos); | 2117 new(Z) Value(to_check), deopt_id, unary_checks, token_pos); |
2198 } | 2118 } |
2199 | 2119 |
2200 | 2120 |
2201 static bool InlineGetIndexed(FlowGraph* flow_graph, | 2121 static bool InlineGetIndexed(FlowGraph* flow_graph, |
2202 MethodRecognizer::Kind kind, | 2122 MethodRecognizer::Kind kind, |
2203 Instruction* call, | 2123 Instruction* call, |
2204 Definition* receiver, | 2124 Definition* receiver, |
2205 TargetEntryInstr** entry, | 2125 TargetEntryInstr** entry, |
2206 Definition** last) { | 2126 Definition** last) { |
2207 intptr_t array_cid = MethodKindToCid(kind); | 2127 intptr_t array_cid = MethodRecognizer::MethodKindToReceiverCid(kind); |
2208 ASSERT(array_cid != kIllegalCid); | |
2209 | 2128 |
2210 Definition* array = receiver; | 2129 Definition* array = receiver; |
2211 Definition* index = call->ArgumentAt(1); | 2130 Definition* index = call->ArgumentAt(1); |
2212 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), | 2131 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), |
2213 call->GetBlock()->try_index()); | 2132 call->GetBlock()->try_index()); |
2214 (*entry)->InheritDeoptTarget(Z, call); | 2133 (*entry)->InheritDeoptTarget(Z, call); |
2215 Instruction* cursor = *entry; | 2134 Instruction* cursor = *entry; |
2216 | 2135 |
2217 array_cid = PrepareInlineIndexedOp(flow_graph, | 2136 array_cid = PrepareInlineIndexedOp(flow_graph, |
2218 call, | 2137 call, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 | 2174 |
2256 static bool InlineSetIndexed(FlowGraph* flow_graph, | 2175 static bool InlineSetIndexed(FlowGraph* flow_graph, |
2257 MethodRecognizer::Kind kind, | 2176 MethodRecognizer::Kind kind, |
2258 const Function& target, | 2177 const Function& target, |
2259 Instruction* call, | 2178 Instruction* call, |
2260 Definition* receiver, | 2179 Definition* receiver, |
2261 TokenPosition token_pos, | 2180 TokenPosition token_pos, |
2262 const ICData& value_check, | 2181 const ICData& value_check, |
2263 TargetEntryInstr** entry, | 2182 TargetEntryInstr** entry, |
2264 Definition** last) { | 2183 Definition** last) { |
2265 intptr_t array_cid = MethodKindToCid(kind); | 2184 intptr_t array_cid = MethodRecognizer::MethodKindToReceiverCid(kind); |
2266 ASSERT(array_cid != kIllegalCid); | |
2267 | 2185 |
2268 Definition* array = receiver; | 2186 Definition* array = receiver; |
2269 Definition* index = call->ArgumentAt(1); | 2187 Definition* index = call->ArgumentAt(1); |
2270 Definition* stored_value = call->ArgumentAt(2); | 2188 Definition* stored_value = call->ArgumentAt(2); |
2271 | 2189 |
2272 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), | 2190 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), |
2273 call->GetBlock()->try_index()); | 2191 call->GetBlock()->try_index()); |
2274 (*entry)->InheritDeoptTarget(Z, call); | 2192 (*entry)->InheritDeoptTarget(Z, call); |
2275 Instruction* cursor = *entry; | 2193 Instruction* cursor = *entry; |
2276 if (flow_graph->isolate()->type_checks()) { | 2194 if (flow_graph->isolate()->type_checks()) { |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3227 call, entry, last); | 3145 call, entry, last); |
3228 case MethodRecognizer::kSmi_bitAndFromSmi: | 3146 case MethodRecognizer::kSmi_bitAndFromSmi: |
3229 return InlineSmiBitAndFromSmi(flow_graph, call, entry, last); | 3147 return InlineSmiBitAndFromSmi(flow_graph, call, entry, last); |
3230 default: | 3148 default: |
3231 return false; | 3149 return false; |
3232 } | 3150 } |
3233 } | 3151 } |
3234 | 3152 |
3235 | 3153 |
3236 } // namespace dart | 3154 } // namespace dart |
OLD | NEW |