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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 locs->set_in(0, Location::RegisterLocation(EAX)); | 2156 locs->set_in(0, Location::RegisterLocation(EAX)); |
2157 locs->set_out(Location::RegisterLocation(EAX)); | 2157 locs->set_out(Location::RegisterLocation(EAX)); |
2158 return locs; | 2158 return locs; |
2159 } | 2159 } |
2160 | 2160 |
2161 | 2161 |
2162 void InstantiateTypeArgumentsInstr::EmitNativeCode( | 2162 void InstantiateTypeArgumentsInstr::EmitNativeCode( |
2163 FlowGraphCompiler* compiler) { | 2163 FlowGraphCompiler* compiler) { |
2164 Register instantiator_reg = locs()->in(0).reg(); | 2164 Register instantiator_reg = locs()->in(0).reg(); |
2165 Register result_reg = locs()->out().reg(); | 2165 Register result_reg = locs()->out().reg(); |
| 2166 ASSERT(instantiator_reg == EAX); |
| 2167 ASSERT(instantiator_reg == result_reg); |
2166 | 2168 |
2167 // 'instantiator_reg' is the instantiator TypeArguments object (or null). | 2169 // 'instantiator_reg' is the instantiator TypeArguments object (or null). |
2168 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | 2170 ASSERT(!type_arguments().IsUninstantiatedIdentity() && |
2169 !type_arguments().CanShareInstantiatorTypeArguments( | 2171 !type_arguments().CanShareInstantiatorTypeArguments( |
2170 instantiator_class())); | 2172 instantiator_class())); |
2171 // If the instantiator is null and if the type argument vector | 2173 // If the instantiator is null and if the type argument vector |
2172 // instantiated from null becomes a vector of dynamic, then use null as | 2174 // instantiated from null becomes a vector of dynamic, then use null as |
2173 // the type arguments. | 2175 // the type arguments. |
2174 Label type_arguments_instantiated; | 2176 Label type_arguments_instantiated; |
2175 const intptr_t len = type_arguments().Length(); | 2177 const intptr_t len = type_arguments().Length(); |
2176 if (type_arguments().IsRawInstantiatedRaw(len)) { | 2178 if (type_arguments().IsRawInstantiatedRaw(len)) { |
2177 const Immediate& raw_null = | 2179 const Immediate& raw_null = |
2178 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 2180 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
2179 __ cmpl(instantiator_reg, raw_null); | 2181 __ cmpl(instantiator_reg, raw_null); |
2180 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | 2182 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
2181 } | 2183 } |
| 2184 // Lookup cache before calling runtime. |
| 2185 // TODO(fschneider): Consider moving this into a shared stub to reduce |
| 2186 // generated code size. |
| 2187 __ LoadObject(EDI, type_arguments()); |
| 2188 __ movl(EDI, FieldAddress(EDI, TypeArguments::instantiations_offset())); |
| 2189 __ movl(EBX, FieldAddress(EDI, Array::length_offset())); |
| 2190 __ leal(EDI, FieldAddress(EDI, Array::data_offset())); |
| 2191 __ leal(EBX, Address(EDI, EBX, TIMES_2, 0)); // EBX is smi. |
| 2192 Label loop, found, slow_case; |
| 2193 __ Bind(&loop); |
| 2194 __ cmpl(EDI, EBX); |
| 2195 __ j(ABOVE_EQUAL, &slow_case); |
| 2196 __ movl(EDX, Address(EDI, 0 * kWordSize)); // Cached instantiator. |
| 2197 __ cmpl(EDX, EAX); |
| 2198 __ j(EQUAL, &found, Assembler::kNearJump); |
| 2199 __ cmpl(EDX, Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
| 2200 __ j(EQUAL, &slow_case); |
| 2201 __ addl(EDI, Immediate(2 * kWordSize)); |
| 2202 __ jmp(&loop, Assembler::kNearJump); |
| 2203 __ Bind(&found); |
| 2204 __ movl(EAX, Address(EDI, 1 * kWordSize)); // Cached instantiated args. |
| 2205 __ jmp(&type_arguments_instantiated); |
| 2206 |
| 2207 __ Bind(&slow_case); |
2182 // Instantiate non-null type arguments. | 2208 // Instantiate non-null type arguments. |
2183 // A runtime call to instantiate the type arguments is required. | 2209 // A runtime call to instantiate the type arguments is required. |
2184 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 2210 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
2185 __ PushObject(type_arguments()); | 2211 __ PushObject(type_arguments()); |
2186 __ pushl(instantiator_reg); // Push instantiator type arguments. | 2212 __ pushl(instantiator_reg); // Push instantiator type arguments. |
2187 compiler->GenerateRuntimeCall(token_pos(), | 2213 compiler->GenerateRuntimeCall(token_pos(), |
2188 deopt_id(), | 2214 deopt_id(), |
2189 kInstantiateTypeArgumentsRuntimeEntry, | 2215 kInstantiateTypeArgumentsRuntimeEntry, |
2190 2, | 2216 2, |
2191 locs()); | 2217 locs()); |
2192 __ Drop(2); // Drop instantiator and uninstantiated type arguments. | 2218 __ Drop(2); // Drop instantiator and uninstantiated type arguments. |
2193 __ popl(result_reg); // Pop instantiated type arguments. | 2219 __ popl(result_reg); // Pop instantiated type arguments. |
2194 __ Bind(&type_arguments_instantiated); | 2220 __ Bind(&type_arguments_instantiated); |
2195 ASSERT(instantiator_reg == result_reg); | |
2196 } | |
2197 | |
2198 | |
2199 LocationSummary* | |
2200 ExtractConstructorTypeArgumentsInstr::MakeLocationSummary(bool opt) const { | |
2201 const intptr_t kNumInputs = 1; | |
2202 const intptr_t kNumTemps = 0; | |
2203 LocationSummary* locs = | |
2204 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
2205 locs->set_in(0, Location::RequiresRegister()); | |
2206 locs->set_out(Location::SameAsFirstInput()); | |
2207 return locs; | |
2208 } | |
2209 | |
2210 | |
2211 void ExtractConstructorTypeArgumentsInstr::EmitNativeCode( | |
2212 FlowGraphCompiler* compiler) { | |
2213 Register instantiator_reg = locs()->in(0).reg(); | |
2214 Register result_reg = locs()->out().reg(); | |
2215 ASSERT(instantiator_reg == result_reg); | |
2216 | |
2217 // instantiator_reg is the instantiator type argument vector, | |
2218 // i.e. a TypeArguments object (or null). | |
2219 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | |
2220 !type_arguments().CanShareInstantiatorTypeArguments( | |
2221 instantiator_class())); | |
2222 // If the instantiator is null and if the type argument vector | |
2223 // instantiated from null becomes a vector of dynamic, then use null as | |
2224 // the type arguments. | |
2225 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); | |
2226 Label type_arguments_instantiated; | |
2227 const Immediate& raw_null = | |
2228 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
2229 __ cmpl(instantiator_reg, raw_null); | |
2230 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
2231 // Instantiate non-null type arguments. | |
2232 // In the non-factory case, we rely on the allocation stub to | |
2233 // instantiate the type arguments. | |
2234 __ LoadObject(result_reg, type_arguments()); | |
2235 // result_reg: uninstantiated type arguments. | |
2236 | |
2237 __ Bind(&type_arguments_instantiated); | |
2238 // result_reg: uninstantiated or instantiated type arguments. | |
2239 } | |
2240 | |
2241 | |
2242 LocationSummary* | |
2243 ExtractConstructorInstantiatorInstr::MakeLocationSummary(bool opt) const { | |
2244 const intptr_t kNumInputs = 1; | |
2245 const intptr_t kNumTemps = 0; | |
2246 LocationSummary* locs = | |
2247 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
2248 locs->set_in(0, Location::RequiresRegister()); | |
2249 locs->set_out(Location::SameAsFirstInput()); | |
2250 return locs; | |
2251 } | |
2252 | |
2253 | |
2254 void ExtractConstructorInstantiatorInstr::EmitNativeCode( | |
2255 FlowGraphCompiler* compiler) { | |
2256 Register instantiator_reg = locs()->in(0).reg(); | |
2257 ASSERT(locs()->out().reg() == instantiator_reg); | |
2258 | |
2259 // instantiator_reg is the instantiator TypeArguments object (or null). | |
2260 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | |
2261 !type_arguments().CanShareInstantiatorTypeArguments( | |
2262 instantiator_class())); | |
2263 | |
2264 // If the instantiator is null and if the type argument vector | |
2265 // instantiated from null becomes a vector of dynamic, then use null as | |
2266 // the type arguments and do not pass the instantiator. | |
2267 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); | |
2268 const Immediate& raw_null = | |
2269 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
2270 Label instantiator_not_null; | |
2271 __ cmpl(instantiator_reg, raw_null); | |
2272 __ j(NOT_EQUAL, &instantiator_not_null, Assembler::kNearJump); | |
2273 // Null was used in VisitExtractConstructorTypeArguments as the | |
2274 // instantiated type arguments, no proper instantiator needed. | |
2275 __ movl(instantiator_reg, | |
2276 Immediate(Smi::RawValue(StubCode::kNoInstantiator))); | |
2277 __ Bind(&instantiator_not_null); | |
2278 // instantiator_reg: instantiator or kNoInstantiator. | |
2279 } | 2221 } |
2280 | 2222 |
2281 | 2223 |
2282 LocationSummary* AllocateContextInstr::MakeLocationSummary(bool opt) const { | 2224 LocationSummary* AllocateContextInstr::MakeLocationSummary(bool opt) const { |
2283 const intptr_t kNumInputs = 0; | 2225 const intptr_t kNumInputs = 0; |
2284 const intptr_t kNumTemps = 1; | 2226 const intptr_t kNumTemps = 1; |
2285 LocationSummary* locs = | 2227 LocationSummary* locs = |
2286 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 2228 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
2287 locs->set_temp(0, Location::RegisterLocation(EDX)); | 2229 locs->set_temp(0, Location::RegisterLocation(EDX)); |
2288 locs->set_out(Location::RegisterLocation(EAX)); | 2230 locs->set_out(Location::RegisterLocation(EAX)); |
(...skipping 3046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5335 PcDescriptors::kOther, | 5277 PcDescriptors::kOther, |
5336 locs()); | 5278 locs()); |
5337 __ Drop(2); // Discard type arguments and receiver. | 5279 __ Drop(2); // Discard type arguments and receiver. |
5338 } | 5280 } |
5339 | 5281 |
5340 } // namespace dart | 5282 } // namespace dart |
5341 | 5283 |
5342 #undef __ | 5284 #undef __ |
5343 | 5285 |
5344 #endif // defined TARGET_ARCH_IA32 | 5286 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |