OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 } | 1389 } |
1390 | 1390 |
1391 | 1391 |
1392 void Assembler::TryAllocate(const Class& cls, | 1392 void Assembler::TryAllocate(const Class& cls, |
1393 Label* failure, | 1393 Label* failure, |
1394 Register instance_reg, | 1394 Register instance_reg, |
1395 Register temp_reg, | 1395 Register temp_reg, |
1396 Register pp) { | 1396 Register pp) { |
1397 ASSERT(failure != NULL); | 1397 ASSERT(failure != NULL); |
1398 if (FLAG_inline_alloc) { | 1398 if (FLAG_inline_alloc) { |
| 1399 const intptr_t instance_size = cls.instance_size(); |
1399 Heap* heap = Isolate::Current()->heap(); | 1400 Heap* heap = Isolate::Current()->heap(); |
1400 const intptr_t instance_size = cls.instance_size(); | 1401 Heap::Space space = heap->SpaceForAllocation(cls.id()); |
1401 LoadImmediate(temp_reg, heap->NewSpaceAddress(), pp); | 1402 const uword top_address = heap->TopAddress(space); |
1402 ldr(instance_reg, Address(temp_reg, Scavenger::top_offset())); | 1403 LoadImmediate(temp_reg, top_address, pp); |
| 1404 ldr(instance_reg, Address(temp_reg)); |
1403 AddImmediate(instance_reg, instance_reg, instance_size, pp); | 1405 AddImmediate(instance_reg, instance_reg, instance_size, pp); |
1404 | 1406 |
1405 // instance_reg: potential next object start. | 1407 // instance_reg: potential next object start. |
1406 ldr(TMP, Address(temp_reg, Scavenger::end_offset())); | 1408 const uword end_address = heap->EndAddress(space); |
| 1409 ASSERT(top_address < end_address); |
| 1410 // Could use ldm to load (top, end), but no benefit seen experimentally. |
| 1411 ldr(TMP, Address(temp_reg, end_address - top_address)); |
1407 CompareRegisters(TMP, instance_reg); | 1412 CompareRegisters(TMP, instance_reg); |
1408 // fail if heap end unsigned less than or equal to instance_reg. | 1413 // fail if heap end unsigned less than or equal to instance_reg. |
1409 b(failure, LS); | 1414 b(failure, LS); |
1410 | 1415 |
1411 // Successfully allocated the object, now update top to point to | 1416 // Successfully allocated the object, now update top to point to |
1412 // next object start and store the class in the class field of object. | 1417 // next object start and store the class in the class field of object. |
1413 str(instance_reg, Address(temp_reg, Scavenger::top_offset())); | 1418 str(instance_reg, Address(temp_reg)); |
1414 | 1419 |
1415 ASSERT(instance_size >= kHeapObjectTag); | 1420 ASSERT(instance_size >= kHeapObjectTag); |
1416 AddImmediate( | 1421 AddImmediate( |
1417 instance_reg, instance_reg, -instance_size + kHeapObjectTag, pp); | 1422 instance_reg, instance_reg, -instance_size + kHeapObjectTag, pp); |
1418 UpdateAllocationStats(cls.id(), pp); | 1423 UpdateAllocationStats(cls.id(), pp, space); |
1419 | 1424 |
1420 uword tags = 0; | 1425 uword tags = 0; |
1421 tags = RawObject::SizeTag::update(instance_size, tags); | 1426 tags = RawObject::SizeTag::update(instance_size, tags); |
1422 ASSERT(cls.id() != kIllegalCid); | 1427 ASSERT(cls.id() != kIllegalCid); |
1423 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1428 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
1424 LoadImmediate(TMP, tags, pp); | 1429 LoadImmediate(TMP, tags, pp); |
1425 StoreFieldToOffset(TMP, instance_reg, Object::tags_offset(), pp); | 1430 StoreFieldToOffset(TMP, instance_reg, Object::tags_offset(), pp); |
1426 } else { | 1431 } else { |
1427 b(failure); | 1432 b(failure); |
1428 } | 1433 } |
1429 } | 1434 } |
1430 | 1435 |
1431 | 1436 |
1432 void Assembler::TryAllocateArray(intptr_t cid, | 1437 void Assembler::TryAllocateArray(intptr_t cid, |
1433 intptr_t instance_size, | 1438 intptr_t instance_size, |
1434 Label* failure, | 1439 Label* failure, |
1435 Register instance, | 1440 Register instance, |
1436 Register end_address, | 1441 Register end_address, |
1437 Register temp1, | 1442 Register temp1, |
1438 Register temp2) { | 1443 Register temp2) { |
1439 if (FLAG_inline_alloc) { | 1444 if (FLAG_inline_alloc) { |
1440 Isolate* isolate = Isolate::Current(); | 1445 Isolate* isolate = Isolate::Current(); |
1441 Heap* heap = isolate->heap(); | 1446 Heap* heap = isolate->heap(); |
1442 LoadImmediate(temp1, heap->TopAddress(), PP); | 1447 Heap::Space space = heap->SpaceForAllocation(cid); |
| 1448 LoadImmediate(temp1, heap->TopAddress(space), PP); |
1443 ldr(instance, Address(temp1, 0)); // Potential new object start. | 1449 ldr(instance, Address(temp1, 0)); // Potential new object start. |
1444 AddImmediate(end_address, instance, instance_size, PP); | 1450 AddImmediate(end_address, instance, instance_size, PP); |
1445 b(failure, VS); | 1451 b(failure, VS); |
1446 | 1452 |
1447 // Check if the allocation fits into the remaining space. | 1453 // Check if the allocation fits into the remaining space. |
1448 // instance: potential new object start. | 1454 // instance: potential new object start. |
1449 // end_address: potential next object start. | 1455 // end_address: potential next object start. |
1450 LoadImmediate(temp2, heap->EndAddress(), PP); | 1456 LoadImmediate(temp2, heap->EndAddress(space), PP); |
1451 ldr(temp2, Address(temp2, 0)); | 1457 ldr(temp2, Address(temp2, 0)); |
1452 cmp(end_address, Operand(temp2)); | 1458 cmp(end_address, Operand(temp2)); |
1453 b(failure, CS); | 1459 b(failure, CS); |
1454 | 1460 |
1455 // Successfully allocated the object(s), now update top to point to | 1461 // Successfully allocated the object(s), now update top to point to |
1456 // next object start and initialize the object. | 1462 // next object start and initialize the object. |
1457 str(end_address, Address(temp1, 0)); | 1463 str(end_address, Address(temp1, 0)); |
1458 add(instance, instance, Operand(kHeapObjectTag)); | 1464 add(instance, instance, Operand(kHeapObjectTag)); |
1459 LoadImmediate(temp2, instance_size, PP); | 1465 LoadImmediate(temp2, instance_size, PP); |
1460 UpdateAllocationStatsWithSize(cid, temp2, PP); | 1466 UpdateAllocationStatsWithSize(cid, temp2, PP, space); |
1461 | 1467 |
1462 // Initialize the tags. | 1468 // Initialize the tags. |
1463 // instance: new object start as a tagged pointer. | 1469 // instance: new object start as a tagged pointer. |
1464 uword tags = 0; | 1470 uword tags = 0; |
1465 tags = RawObject::ClassIdTag::update(cid, tags); | 1471 tags = RawObject::ClassIdTag::update(cid, tags); |
1466 tags = RawObject::SizeTag::update(instance_size, tags); | 1472 tags = RawObject::SizeTag::update(instance_size, tags); |
1467 LoadImmediate(temp2, tags, PP); | 1473 LoadImmediate(temp2, tags, PP); |
1468 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags. | 1474 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags. |
1469 } else { | 1475 } else { |
1470 b(failure); | 1476 b(failure); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 add(base, array, Operand(index, LSL, shift)); | 1514 add(base, array, Operand(index, LSL, shift)); |
1509 } | 1515 } |
1510 const OperandSize size = Address::OperandSizeFor(cid); | 1516 const OperandSize size = Address::OperandSizeFor(cid); |
1511 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); | 1517 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); |
1512 return Address(base, offset, Address::Offset, size); | 1518 return Address(base, offset, Address::Offset, size); |
1513 } | 1519 } |
1514 | 1520 |
1515 } // namespace dart | 1521 } // namespace dart |
1516 | 1522 |
1517 #endif // defined TARGET_ARCH_ARM64 | 1523 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |