| 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/globals.h" // Needed here to get TARGET_ARCH_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 locs->set_in(0, Location::RegisterLocation(R0)); | 2170 locs->set_in(0, Location::RegisterLocation(R0)); |
| 2171 locs->set_out(Location::RegisterLocation(R0)); | 2171 locs->set_out(Location::RegisterLocation(R0)); |
| 2172 return locs; | 2172 return locs; |
| 2173 } | 2173 } |
| 2174 | 2174 |
| 2175 | 2175 |
| 2176 void InstantiateTypeArgumentsInstr::EmitNativeCode( | 2176 void InstantiateTypeArgumentsInstr::EmitNativeCode( |
| 2177 FlowGraphCompiler* compiler) { | 2177 FlowGraphCompiler* compiler) { |
| 2178 Register instantiator_reg = locs()->in(0).reg(); | 2178 Register instantiator_reg = locs()->in(0).reg(); |
| 2179 Register result_reg = locs()->out().reg(); | 2179 Register result_reg = locs()->out().reg(); |
| 2180 ASSERT(instantiator_reg == R0); |
| 2181 ASSERT(instantiator_reg == result_reg); |
| 2180 | 2182 |
| 2181 // 'instantiator_reg' is the instantiator TypeArguments object (or null). | 2183 // 'instantiator_reg' is the instantiator TypeArguments object (or null). |
| 2182 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | 2184 ASSERT(!type_arguments().IsUninstantiatedIdentity() && |
| 2183 !type_arguments().CanShareInstantiatorTypeArguments( | 2185 !type_arguments().CanShareInstantiatorTypeArguments( |
| 2184 instantiator_class())); | 2186 instantiator_class())); |
| 2185 // If the instantiator is null and if the type argument vector | 2187 // If the instantiator is null and if the type argument vector |
| 2186 // instantiated from null becomes a vector of dynamic, then use null as | 2188 // instantiated from null becomes a vector of dynamic, then use null as |
| 2187 // the type arguments. | 2189 // the type arguments. |
| 2188 Label type_arguments_instantiated; | 2190 Label type_arguments_instantiated; |
| 2189 const intptr_t len = type_arguments().Length(); | 2191 const intptr_t len = type_arguments().Length(); |
| 2190 if (type_arguments().IsRawInstantiatedRaw(len)) { | 2192 if (type_arguments().IsRawInstantiatedRaw(len)) { |
| 2191 __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null())); | 2193 __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null())); |
| 2192 __ cmp(instantiator_reg, ShifterOperand(IP)); | 2194 __ cmp(instantiator_reg, ShifterOperand(IP)); |
| 2193 __ b(&type_arguments_instantiated, EQ); | 2195 __ b(&type_arguments_instantiated, EQ); |
| 2194 } | 2196 } |
| 2197 |
| 2198 __ LoadObject(R2, type_arguments()); |
| 2199 __ ldr(R2, FieldAddress(R2, TypeArguments::instantiations_offset())); |
| 2200 __ ldr(R3, FieldAddress(R2, Array::length_offset())); |
| 2201 __ AddImmediate(R2, Array::data_offset() - kHeapObjectTag); |
| 2202 __ add(R3, R2, ShifterOperand(R3, LSL, 1)); // R3 is Smi. |
| 2203 Label loop, found, slow_case; |
| 2204 __ Bind(&loop); |
| 2205 __ cmp(R2, ShifterOperand(R3)); |
| 2206 __ b(&slow_case, CS); // Unsigned higher or equal. |
| 2207 __ ldr(R1, Address(R2, 0 * kWordSize)); // Cached instantiator. |
| 2208 __ cmp(R1, ShifterOperand(R0)); |
| 2209 __ b(&found, EQ); |
| 2210 __ CompareImmediate(R1, Smi::RawValue(StubCode::kNoInstantiator)); |
| 2211 __ b(&slow_case, EQ); |
| 2212 __ AddImmediate(R2, 2 * kWordSize); |
| 2213 __ b(&loop); |
| 2214 __ Bind(&found); |
| 2215 __ ldr(R0, Address(R2, 1 * kWordSize)); // Cached instantiated args. |
| 2216 __ b(&type_arguments_instantiated); |
| 2217 |
| 2218 __ Bind(&slow_case); |
| 2195 // Instantiate non-null type arguments. | 2219 // Instantiate non-null type arguments. |
| 2196 // A runtime call to instantiate the type arguments is required. | 2220 // A runtime call to instantiate the type arguments is required. |
| 2197 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 2221 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 2198 __ PushObject(type_arguments()); | 2222 __ PushObject(type_arguments()); |
| 2199 __ Push(instantiator_reg); // Push instantiator type arguments. | 2223 __ Push(instantiator_reg); // Push instantiator type arguments. |
| 2200 compiler->GenerateRuntimeCall(token_pos(), | 2224 compiler->GenerateRuntimeCall(token_pos(), |
| 2201 deopt_id(), | 2225 deopt_id(), |
| 2202 kInstantiateTypeArgumentsRuntimeEntry, | 2226 kInstantiateTypeArgumentsRuntimeEntry, |
| 2203 2, | 2227 2, |
| 2204 locs()); | 2228 locs()); |
| 2205 __ Drop(2); // Drop instantiator and uninstantiated type arguments. | 2229 __ Drop(2); // Drop instantiator and uninstantiated type arguments. |
| 2206 __ Pop(result_reg); // Pop instantiated type arguments. | 2230 __ Pop(result_reg); // Pop instantiated type arguments. |
| 2207 __ Bind(&type_arguments_instantiated); | 2231 __ Bind(&type_arguments_instantiated); |
| 2208 ASSERT(instantiator_reg == result_reg); | |
| 2209 } | |
| 2210 | |
| 2211 | |
| 2212 LocationSummary* | |
| 2213 ExtractConstructorTypeArgumentsInstr::MakeLocationSummary(bool opt) const { | |
| 2214 const intptr_t kNumInputs = 1; | |
| 2215 const intptr_t kNumTemps = 0; | |
| 2216 LocationSummary* locs = | |
| 2217 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
| 2218 locs->set_in(0, Location::RequiresRegister()); | |
| 2219 locs->set_out(Location::SameAsFirstInput()); | |
| 2220 return locs; | |
| 2221 } | |
| 2222 | |
| 2223 | |
| 2224 void ExtractConstructorTypeArgumentsInstr::EmitNativeCode( | |
| 2225 FlowGraphCompiler* compiler) { | |
| 2226 Register instantiator_reg = locs()->in(0).reg(); | |
| 2227 Register result_reg = locs()->out().reg(); | |
| 2228 ASSERT(instantiator_reg == result_reg); | |
| 2229 | |
| 2230 // instantiator_reg is the instantiator type argument vector, | |
| 2231 // i.e. a TypeArguments object (or null). | |
| 2232 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | |
| 2233 !type_arguments().CanShareInstantiatorTypeArguments( | |
| 2234 instantiator_class())); | |
| 2235 // If the instantiator is null and if the type argument vector | |
| 2236 // instantiated from null becomes a vector of dynamic, then use null as | |
| 2237 // the type arguments. | |
| 2238 Label type_arguments_instantiated; | |
| 2239 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); | |
| 2240 __ CompareImmediate(instantiator_reg, | |
| 2241 reinterpret_cast<intptr_t>(Object::null())); | |
| 2242 __ b(&type_arguments_instantiated, EQ); | |
| 2243 // Instantiate non-null type arguments. | |
| 2244 // In the non-factory case, we rely on the allocation stub to | |
| 2245 // instantiate the type arguments. | |
| 2246 __ LoadObject(result_reg, type_arguments()); | |
| 2247 // result_reg: uninstantiated type arguments. | |
| 2248 __ Bind(&type_arguments_instantiated); | |
| 2249 | |
| 2250 // result_reg: uninstantiated or instantiated type arguments. | |
| 2251 } | |
| 2252 | |
| 2253 | |
| 2254 LocationSummary* | |
| 2255 ExtractConstructorInstantiatorInstr::MakeLocationSummary(bool opt) const { | |
| 2256 const intptr_t kNumInputs = 1; | |
| 2257 const intptr_t kNumTemps = 0; | |
| 2258 LocationSummary* locs = | |
| 2259 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
| 2260 locs->set_in(0, Location::RequiresRegister()); | |
| 2261 locs->set_out(Location::SameAsFirstInput()); | |
| 2262 return locs; | |
| 2263 } | |
| 2264 | |
| 2265 | |
| 2266 void ExtractConstructorInstantiatorInstr::EmitNativeCode( | |
| 2267 FlowGraphCompiler* compiler) { | |
| 2268 Register instantiator_reg = locs()->in(0).reg(); | |
| 2269 ASSERT(locs()->out().reg() == instantiator_reg); | |
| 2270 | |
| 2271 // instantiator_reg is the instantiator TypeArguments object (or null). | |
| 2272 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | |
| 2273 !type_arguments().CanShareInstantiatorTypeArguments( | |
| 2274 instantiator_class())); | |
| 2275 | |
| 2276 // If the instantiator is null and if the type argument vector | |
| 2277 // instantiated from null becomes a vector of dynamic, then use null as | |
| 2278 // the type arguments and do not pass the instantiator. | |
| 2279 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); | |
| 2280 Label instantiator_not_null; | |
| 2281 __ CompareImmediate(instantiator_reg, | |
| 2282 reinterpret_cast<intptr_t>(Object::null())); | |
| 2283 __ b(&instantiator_not_null, NE); | |
| 2284 // Null was used in VisitExtractConstructorTypeArguments as the | |
| 2285 // instantiated type arguments, no proper instantiator needed. | |
| 2286 __ LoadImmediate(instantiator_reg, | |
| 2287 Smi::RawValue(StubCode::kNoInstantiator)); | |
| 2288 __ Bind(&instantiator_not_null); | |
| 2289 // instantiator_reg: instantiator or kNoInstantiator. | |
| 2290 } | 2232 } |
| 2291 | 2233 |
| 2292 | 2234 |
| 2293 LocationSummary* AllocateContextInstr::MakeLocationSummary(bool opt) const { | 2235 LocationSummary* AllocateContextInstr::MakeLocationSummary(bool opt) const { |
| 2294 const intptr_t kNumInputs = 0; | 2236 const intptr_t kNumInputs = 0; |
| 2295 const intptr_t kNumTemps = 1; | 2237 const intptr_t kNumTemps = 1; |
| 2296 LocationSummary* locs = | 2238 LocationSummary* locs = |
| 2297 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 2239 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 2298 locs->set_temp(0, Location::RegisterLocation(R1)); | 2240 locs->set_temp(0, Location::RegisterLocation(R1)); |
| 2299 locs->set_out(Location::RegisterLocation(R0)); | 2241 locs->set_out(Location::RegisterLocation(R0)); |
| (...skipping 2656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4956 compiler->GenerateCall(token_pos(), | 4898 compiler->GenerateCall(token_pos(), |
| 4957 &label, | 4899 &label, |
| 4958 PcDescriptors::kOther, | 4900 PcDescriptors::kOther, |
| 4959 locs()); | 4901 locs()); |
| 4960 __ Drop(2); // Discard type arguments and receiver. | 4902 __ Drop(2); // Discard type arguments and receiver. |
| 4961 } | 4903 } |
| 4962 | 4904 |
| 4963 } // namespace dart | 4905 } // namespace dart |
| 4964 | 4906 |
| 4965 #endif // defined TARGET_ARCH_ARM | 4907 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |