| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 void StubCode::GenerateAllocationStubForClosure(Assembler* assembler, | 1251 void StubCode::GenerateAllocationStubForClosure(Assembler* assembler, |
| 1252 const Function& func) { | 1252 const Function& func) { |
| 1253 const Immediate raw_null = | 1253 const Immediate raw_null = |
| 1254 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1254 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1255 ASSERT(func.IsClosureFunction()); | 1255 ASSERT(func.IsClosureFunction()); |
| 1256 const bool is_implicit_static_closure = | 1256 const bool is_implicit_static_closure = |
| 1257 func.IsImplicitStaticClosureFunction(); | 1257 func.IsImplicitStaticClosureFunction(); |
| 1258 const bool is_implicit_instance_closure = | 1258 const bool is_implicit_instance_closure = |
| 1259 func.IsImplicitInstanceClosureFunction(); | 1259 func.IsImplicitInstanceClosureFunction(); |
| 1260 const Class& cls = Class::ZoneHandle(func.signature_class()); | 1260 const Class& cls = Class::ZoneHandle(func.signature_class()); |
| 1261 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; | 1261 const bool has_type_arguments = cls.HasTypeArguments(); |
| 1262 const intptr_t kTypeArgumentsOffset = 1 * kWordSize; | 1262 const intptr_t kTypeArgumentsOffset = 1 * kWordSize; |
| 1263 const intptr_t kReceiverOffset = (is_cls_parameterized ? 2 : 1) * kWordSize; | 1263 const intptr_t kReceiverOffset = (has_type_arguments ? 2 : 1) * kWordSize; |
| 1264 const intptr_t closure_size = Closure::InstanceSize(); | 1264 const intptr_t closure_size = Closure::InstanceSize(); |
| 1265 const intptr_t context_size = Context::InstanceSize(1); // Captured receiver. | 1265 const intptr_t context_size = Context::InstanceSize(1); // Captured receiver. |
| 1266 if (FLAG_inline_alloc && | 1266 if (FLAG_inline_alloc && |
| 1267 PageSpace::IsPageAllocatableSize(closure_size + context_size)) { | 1267 PageSpace::IsPageAllocatableSize(closure_size + context_size)) { |
| 1268 Label slow_case; | 1268 Label slow_case; |
| 1269 Heap* heap = Isolate::Current()->heap(); | 1269 Heap* heap = Isolate::Current()->heap(); |
| 1270 __ movl(EAX, Address::Absolute(heap->TopAddress())); | 1270 __ movl(EAX, Address::Absolute(heap->TopAddress())); |
| 1271 __ leal(EBX, Address(EAX, closure_size)); | 1271 __ leal(EBX, Address(EAX, closure_size)); |
| 1272 if (is_implicit_instance_closure) { | 1272 if (is_implicit_instance_closure) { |
| 1273 __ movl(ECX, EBX); // ECX: new context address. | 1273 __ movl(ECX, EBX); // ECX: new context address. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 __ movl(Address(ECX, Context::variable_offset(0)), EDX); | 1327 __ movl(Address(ECX, Context::variable_offset(0)), EDX); |
| 1328 | 1328 |
| 1329 // Set the newly allocated context in the newly allocated closure. | 1329 // Set the newly allocated context in the newly allocated closure. |
| 1330 __ addl(ECX, Immediate(kHeapObjectTag)); | 1330 __ addl(ECX, Immediate(kHeapObjectTag)); |
| 1331 __ movl(Address(EAX, Closure::context_offset()), ECX); | 1331 __ movl(Address(EAX, Closure::context_offset()), ECX); |
| 1332 } else { | 1332 } else { |
| 1333 __ movl(Address(EAX, Closure::context_offset()), CTX); | 1333 __ movl(Address(EAX, Closure::context_offset()), CTX); |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 // Set the type arguments field in the newly allocated closure. | 1336 // Set the type arguments field in the newly allocated closure. |
| 1337 if (is_cls_parameterized) { | 1337 if (has_type_arguments) { |
| 1338 ASSERT(!is_implicit_static_closure); | 1338 ASSERT(!is_implicit_static_closure); |
| 1339 // Use the passed-in type arguments. | 1339 // Use the passed-in type arguments. |
| 1340 __ movl(EDX, Address(ESP, kTypeArgumentsOffset)); | 1340 __ movl(EDX, Address(ESP, kTypeArgumentsOffset)); |
| 1341 __ movl(Address(EAX, Closure::type_arguments_offset()), EDX); | 1341 __ movl(Address(EAX, Closure::type_arguments_offset()), EDX); |
| 1342 } else { | 1342 } else { |
| 1343 // Set to null. | 1343 // Set to null. |
| 1344 __ movl(Address(EAX, Closure::type_arguments_offset()), raw_null); | 1344 __ movl(Address(EAX, Closure::type_arguments_offset()), raw_null); |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 __ movl(Address(EAX, Closure::smrck_offset()), raw_null); | 1347 __ movl(Address(EAX, Closure::smrck_offset()), raw_null); |
| 1348 | 1348 |
| 1349 // Done allocating and initializing the instance. | 1349 // Done allocating and initializing the instance. |
| 1350 // EAX: new object. | 1350 // EAX: new object. |
| 1351 __ addl(EAX, Immediate(kHeapObjectTag)); | 1351 __ addl(EAX, Immediate(kHeapObjectTag)); |
| 1352 __ ret(); | 1352 __ ret(); |
| 1353 | 1353 |
| 1354 __ Bind(&slow_case); | 1354 __ Bind(&slow_case); |
| 1355 } | 1355 } |
| 1356 if (is_cls_parameterized) { | 1356 if (has_type_arguments) { |
| 1357 __ movl(ECX, Address(ESP, kTypeArgumentsOffset)); | 1357 __ movl(ECX, Address(ESP, kTypeArgumentsOffset)); |
| 1358 } | 1358 } |
| 1359 if (is_implicit_instance_closure) { | 1359 if (is_implicit_instance_closure) { |
| 1360 __ movl(EAX, Address(ESP, kReceiverOffset)); | 1360 __ movl(EAX, Address(ESP, kReceiverOffset)); |
| 1361 } | 1361 } |
| 1362 // Create a stub frame. | 1362 // Create a stub frame. |
| 1363 __ EnterFrame(0); | 1363 __ EnterFrame(0); |
| 1364 const Closure& new_closure = Closure::ZoneHandle(); | 1364 const Closure& new_closure = Closure::ZoneHandle(); |
| 1365 __ PushObject(new_closure); // Push Null closure for return value. | 1365 __ PushObject(new_closure); // Push Null closure for return value. |
| 1366 __ PushObject(func); | 1366 __ PushObject(func); |
| 1367 if (is_cls_parameterized) { | 1367 if (has_type_arguments) { |
| 1368 __ pushl(ECX); // Push type arguments of closure to be allocated. | 1368 __ pushl(ECX); // Push type arguments of closure to be allocated. |
| 1369 } else { | 1369 } else { |
| 1370 __ pushl(raw_null); // Push null type arguments. | 1370 __ pushl(raw_null); // Push null type arguments. |
| 1371 } | 1371 } |
| 1372 if (is_implicit_static_closure) { | 1372 if (is_implicit_static_closure) { |
| 1373 __ CallRuntimeFromStub(kAllocateImplicitStaticClosureRuntimeEntry); | 1373 __ CallRuntimeFromStub(kAllocateImplicitStaticClosureRuntimeEntry); |
| 1374 } else if (is_implicit_instance_closure) { | 1374 } else if (is_implicit_instance_closure) { |
| 1375 __ pushl(EAX); // Receiver. | 1375 __ pushl(EAX); // Receiver. |
| 1376 __ CallRuntimeFromStub(kAllocateImplicitInstanceClosureRuntimeEntry); | 1376 __ CallRuntimeFromStub(kAllocateImplicitInstanceClosureRuntimeEntry); |
| 1377 __ popl(EAX); // Pop receiver. | 1377 __ popl(EAX); // Pop receiver. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 __ popl(EAX); // Get result into EAX. | 1445 __ popl(EAX); // Get result into EAX. |
| 1446 | 1446 |
| 1447 // Remove the stub frame as we are about to return. | 1447 // Remove the stub frame as we are about to return. |
| 1448 __ LeaveFrame(); | 1448 __ LeaveFrame(); |
| 1449 __ ret(); | 1449 __ ret(); |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 } // namespace dart | 1452 } // namespace dart |
| 1453 | 1453 |
| 1454 #endif // defined TARGET_ARCH_IA32 | 1454 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |