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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
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 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 locs->set_out(Location::RegisterLocation(T0)); | 2132 locs->set_out(Location::RegisterLocation(T0)); |
2133 return locs; | 2133 return locs; |
2134 } | 2134 } |
2135 | 2135 |
2136 | 2136 |
2137 void InstantiateTypeArgumentsInstr::EmitNativeCode( | 2137 void InstantiateTypeArgumentsInstr::EmitNativeCode( |
2138 FlowGraphCompiler* compiler) { | 2138 FlowGraphCompiler* compiler) { |
2139 __ TraceSimMsg("InstantiateTypeArgumentsInstr"); | 2139 __ TraceSimMsg("InstantiateTypeArgumentsInstr"); |
2140 Register instantiator_reg = locs()->in(0).reg(); | 2140 Register instantiator_reg = locs()->in(0).reg(); |
2141 Register result_reg = locs()->out().reg(); | 2141 Register result_reg = locs()->out().reg(); |
| 2142 ASSERT(instantiator_reg == T0); |
| 2143 ASSERT(instantiator_reg == result_reg); |
2142 | 2144 |
2143 // 'instantiator_reg' is the instantiator TypeArguments object (or null). | 2145 // 'instantiator_reg' is the instantiator TypeArguments object (or null). |
2144 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | 2146 ASSERT(!type_arguments().IsUninstantiatedIdentity() && |
2145 !type_arguments().CanShareInstantiatorTypeArguments( | 2147 !type_arguments().CanShareInstantiatorTypeArguments( |
2146 instantiator_class())); | 2148 instantiator_class())); |
2147 // If the instantiator is null and if the type argument vector | 2149 // If the instantiator is null and if the type argument vector |
2148 // instantiated from null becomes a vector of dynamic, then use null as | 2150 // instantiated from null becomes a vector of dynamic, then use null as |
2149 // the type arguments. | 2151 // the type arguments. |
2150 Label type_arguments_instantiated; | 2152 Label type_arguments_instantiated; |
2151 const intptr_t len = type_arguments().Length(); | 2153 const intptr_t len = type_arguments().Length(); |
2152 if (type_arguments().IsRawInstantiatedRaw(len)) { | 2154 if (type_arguments().IsRawInstantiatedRaw(len)) { |
2153 __ BranchEqual(instantiator_reg, reinterpret_cast<int32_t>(Object::null()), | 2155 __ BranchEqual(instantiator_reg, reinterpret_cast<int32_t>(Object::null()), |
2154 &type_arguments_instantiated); | 2156 &type_arguments_instantiated); |
2155 } | 2157 } |
| 2158 |
| 2159 __ LoadObject(T2, type_arguments()); |
| 2160 __ lw(T2, FieldAddress(T2, TypeArguments::instantiations_offset())); |
| 2161 __ lw(T3, FieldAddress(T2, Array::length_offset())); |
| 2162 __ AddImmediate(T2, Array::data_offset() - kHeapObjectTag); |
| 2163 __ sll(TMP, T3, 1); // T3 is Smi. |
| 2164 __ addu(T3, T2, TMP); |
| 2165 Label loop, found, slow_case; |
| 2166 __ Bind(&loop); |
| 2167 __ BranchUnsignedGreaterEqual(T2, T3, &slow_case); |
| 2168 __ lw(T1, Address(T2, 0 * kWordSize)); // Cached instantiator. |
| 2169 __ beq(T1, T0, &found); |
| 2170 __ BranchEqual(T1, Smi::RawValue(StubCode::kNoInstantiator), &slow_case); |
| 2171 __ b(&loop); |
| 2172 __ delay_slot()->addiu(T2, T2, Immediate(2 * kWordSize)); |
| 2173 __ Bind(&found); |
| 2174 __ lw(T0, Address(T2, 1 * kWordSize)); // Cached instantiated args. |
| 2175 __ b(&type_arguments_instantiated); |
| 2176 |
| 2177 __ Bind(&slow_case); |
2156 // Instantiate non-null type arguments. | 2178 // Instantiate non-null type arguments. |
2157 // A runtime call to instantiate the type arguments is required. | 2179 // A runtime call to instantiate the type arguments is required. |
2158 __ addiu(SP, SP, Immediate(-3 * kWordSize)); | 2180 __ addiu(SP, SP, Immediate(-3 * kWordSize)); |
2159 __ LoadObject(TMP, Object::ZoneHandle()); | 2181 __ LoadObject(TMP, Object::ZoneHandle()); |
2160 __ sw(TMP, Address(SP, 2 * kWordSize)); // Make room for the result. | 2182 __ sw(TMP, Address(SP, 2 * kWordSize)); // Make room for the result. |
2161 __ LoadObject(TMP, type_arguments()); | 2183 __ LoadObject(TMP, type_arguments()); |
2162 __ sw(TMP, Address(SP, 1 * kWordSize)); | 2184 __ sw(TMP, Address(SP, 1 * kWordSize)); |
2163 // Push instantiator type arguments. | 2185 // Push instantiator type arguments. |
2164 __ sw(instantiator_reg, Address(SP, 0 * kWordSize)); | 2186 __ sw(instantiator_reg, Address(SP, 0 * kWordSize)); |
2165 | 2187 |
2166 compiler->GenerateRuntimeCall(token_pos(), | 2188 compiler->GenerateRuntimeCall(token_pos(), |
2167 deopt_id(), | 2189 deopt_id(), |
2168 kInstantiateTypeArgumentsRuntimeEntry, | 2190 kInstantiateTypeArgumentsRuntimeEntry, |
2169 2, | 2191 2, |
2170 locs()); | 2192 locs()); |
2171 // Pop instantiated type arguments. | 2193 // Pop instantiated type arguments. |
2172 __ lw(result_reg, Address(SP, 2 * kWordSize)); | 2194 __ lw(result_reg, Address(SP, 2 * kWordSize)); |
2173 // Drop instantiator and uninstantiated type arguments. | 2195 // Drop instantiator and uninstantiated type arguments. |
2174 __ addiu(SP, SP, Immediate(3 * kWordSize)); | 2196 __ addiu(SP, SP, Immediate(3 * kWordSize)); |
2175 __ Bind(&type_arguments_instantiated); | 2197 __ Bind(&type_arguments_instantiated); |
2176 ASSERT(instantiator_reg == result_reg); | |
2177 } | |
2178 | |
2179 | |
2180 LocationSummary* | |
2181 ExtractConstructorTypeArgumentsInstr::MakeLocationSummary(bool opt) const { | |
2182 const intptr_t kNumInputs = 1; | |
2183 const intptr_t kNumTemps = 0; | |
2184 LocationSummary* locs = | |
2185 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
2186 locs->set_in(0, Location::RequiresRegister()); | |
2187 locs->set_out(Location::SameAsFirstInput()); | |
2188 return locs; | |
2189 } | |
2190 | |
2191 | |
2192 void ExtractConstructorTypeArgumentsInstr::EmitNativeCode( | |
2193 FlowGraphCompiler* compiler) { | |
2194 Register instantiator_reg = locs()->in(0).reg(); | |
2195 Register result_reg = locs()->out().reg(); | |
2196 ASSERT(instantiator_reg == result_reg); | |
2197 | |
2198 // instantiator_reg is the instantiator type argument vector, | |
2199 // i.e. a TypeArguments object (or null). | |
2200 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | |
2201 !type_arguments().CanShareInstantiatorTypeArguments( | |
2202 instantiator_class())); | |
2203 // If the instantiator is null and if the type argument vector | |
2204 // instantiated from null becomes a vector of dynamic, then use null as | |
2205 // the type arguments. | |
2206 Label type_arguments_instantiated; | |
2207 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); | |
2208 __ BranchEqual(instantiator_reg, reinterpret_cast<int32_t>(Object::null()), | |
2209 &type_arguments_instantiated); | |
2210 // Instantiate non-null type arguments. | |
2211 // In the non-factory case, we rely on the allocation stub to | |
2212 // instantiate the type arguments. | |
2213 __ LoadObject(result_reg, type_arguments()); | |
2214 // result_reg: uninstantiated type arguments. | |
2215 __ Bind(&type_arguments_instantiated); | |
2216 | |
2217 // result_reg: uninstantiated or instantiated type arguments. | |
2218 } | |
2219 | |
2220 | |
2221 LocationSummary* | |
2222 ExtractConstructorInstantiatorInstr::MakeLocationSummary(bool opt) const { | |
2223 const intptr_t kNumInputs = 1; | |
2224 const intptr_t kNumTemps = 0; | |
2225 LocationSummary* locs = | |
2226 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
2227 locs->set_in(0, Location::RequiresRegister()); | |
2228 locs->set_out(Location::SameAsFirstInput()); | |
2229 return locs; | |
2230 } | |
2231 | |
2232 | |
2233 void ExtractConstructorInstantiatorInstr::EmitNativeCode( | |
2234 FlowGraphCompiler* compiler) { | |
2235 Register instantiator_reg = locs()->in(0).reg(); | |
2236 ASSERT(locs()->out().reg() == instantiator_reg); | |
2237 | |
2238 // instantiator_reg is the instantiator TypeArguments object (or null). | |
2239 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | |
2240 !type_arguments().CanShareInstantiatorTypeArguments( | |
2241 instantiator_class())); | |
2242 | |
2243 // If the instantiator is null and if the type argument vector | |
2244 // instantiated from null becomes a vector of dynamic, then use null as | |
2245 // the type arguments and do not pass the instantiator. | |
2246 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); | |
2247 Label instantiator_not_null; | |
2248 __ BranchNotEqual(instantiator_reg, reinterpret_cast<int32_t>(Object::null()), | |
2249 &instantiator_not_null); | |
2250 // Null was used in VisitExtractConstructorTypeArguments as the | |
2251 // instantiated type arguments, no proper instantiator needed. | |
2252 __ LoadImmediate(instantiator_reg, | |
2253 Smi::RawValue(StubCode::kNoInstantiator)); | |
2254 __ Bind(&instantiator_not_null); | |
2255 // instantiator_reg: instantiator or kNoInstantiator. | |
2256 } | 2198 } |
2257 | 2199 |
2258 | 2200 |
2259 LocationSummary* AllocateContextInstr::MakeLocationSummary(bool opt) const { | 2201 LocationSummary* AllocateContextInstr::MakeLocationSummary(bool opt) const { |
2260 const intptr_t kNumInputs = 0; | 2202 const intptr_t kNumInputs = 0; |
2261 const intptr_t kNumTemps = 1; | 2203 const intptr_t kNumTemps = 1; |
2262 LocationSummary* locs = | 2204 LocationSummary* locs = |
2263 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 2205 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
2264 locs->set_temp(0, Location::RegisterLocation(T1)); | 2206 locs->set_temp(0, Location::RegisterLocation(T1)); |
2265 locs->set_out(Location::RegisterLocation(V0)); | 2207 locs->set_out(Location::RegisterLocation(V0)); |
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4230 compiler->GenerateCall(token_pos(), | 4172 compiler->GenerateCall(token_pos(), |
4231 &label, | 4173 &label, |
4232 PcDescriptors::kOther, | 4174 PcDescriptors::kOther, |
4233 locs()); | 4175 locs()); |
4234 __ Drop(2); // Discard type arguments and receiver. | 4176 __ Drop(2); // Discard type arguments and receiver. |
4235 } | 4177 } |
4236 | 4178 |
4237 } // namespace dart | 4179 } // namespace dart |
4238 | 4180 |
4239 #endif // defined TARGET_ARCH_MIPS | 4181 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |