| 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" // NOLINT | 5 #include "vm/globals.h" // NOLINT |
| 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 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 | 1347 |
| 1348 void Assembler::TryAllocate(const Class& cls, | 1348 void Assembler::TryAllocate(const Class& cls, |
| 1349 Label* failure, | 1349 Label* failure, |
| 1350 Register instance_reg, | 1350 Register instance_reg, |
| 1351 Register temp_reg) { | 1351 Register temp_reg) { |
| 1352 ASSERT(failure != NULL); | 1352 ASSERT(failure != NULL); |
| 1353 if (FLAG_inline_alloc) { | 1353 if (FLAG_inline_alloc) { |
| 1354 // If this allocation is traced, program will jump to failure path | 1354 // If this allocation is traced, program will jump to failure path |
| 1355 // (i.e. the allocation stub) which will allocate the object and trace the | 1355 // (i.e. the allocation stub) which will allocate the object and trace the |
| 1356 // allocation call site. | 1356 // allocation call site. |
| 1357 MaybeTraceAllocation(cls.id(), temp_reg, failure); | 1357 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), temp_reg, failure)); |
| 1358 const intptr_t instance_size = cls.instance_size(); | 1358 const intptr_t instance_size = cls.instance_size(); |
| 1359 Heap::Space space = Heap::SpaceForAllocation(cls.id()); | 1359 Heap::Space space = Heap::SpaceForAllocation(cls.id()); |
| 1360 ldr(temp_reg, Address(THR, Thread::heap_offset())); | 1360 ldr(temp_reg, Address(THR, Thread::heap_offset())); |
| 1361 ldr(instance_reg, Address(temp_reg, Heap::TopOffset(space))); | 1361 ldr(instance_reg, Address(temp_reg, Heap::TopOffset(space))); |
| 1362 // TODO(koda): Protect against unsigned overflow here. | 1362 // TODO(koda): Protect against unsigned overflow here. |
| 1363 AddImmediateSetFlags(instance_reg, instance_reg, instance_size); | 1363 AddImmediateSetFlags(instance_reg, instance_reg, instance_size); |
| 1364 | 1364 |
| 1365 // instance_reg: potential next object start. | 1365 // instance_reg: potential next object start. |
| 1366 ldr(TMP, Address(temp_reg, Heap::EndOffset(space))); | 1366 ldr(TMP, Address(temp_reg, Heap::EndOffset(space))); |
| 1367 CompareRegisters(TMP, instance_reg); | 1367 CompareRegisters(TMP, instance_reg); |
| 1368 // fail if heap end unsigned less than or equal to instance_reg. | 1368 // fail if heap end unsigned less than or equal to instance_reg. |
| 1369 b(failure, LS); | 1369 b(failure, LS); |
| 1370 | 1370 |
| 1371 // Successfully allocated the object, now update top to point to | 1371 // Successfully allocated the object, now update top to point to |
| 1372 // next object start and store the class in the class field of object. | 1372 // next object start and store the class in the class field of object. |
| 1373 str(instance_reg, Address(temp_reg, Heap::TopOffset(space))); | 1373 str(instance_reg, Address(temp_reg, Heap::TopOffset(space))); |
| 1374 | 1374 |
| 1375 ASSERT(instance_size >= kHeapObjectTag); | 1375 ASSERT(instance_size >= kHeapObjectTag); |
| 1376 AddImmediate( | 1376 AddImmediate( |
| 1377 instance_reg, instance_reg, -instance_size + kHeapObjectTag); | 1377 instance_reg, instance_reg, -instance_size + kHeapObjectTag); |
| 1378 UpdateAllocationStats(cls.id(), space); | 1378 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); |
| 1379 | 1379 |
| 1380 uword tags = 0; | 1380 uword tags = 0; |
| 1381 tags = RawObject::SizeTag::update(instance_size, tags); | 1381 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1382 ASSERT(cls.id() != kIllegalCid); | 1382 ASSERT(cls.id() != kIllegalCid); |
| 1383 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1383 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1384 LoadImmediate(TMP, tags); | 1384 LoadImmediate(TMP, tags); |
| 1385 StoreFieldToOffset(TMP, instance_reg, Object::tags_offset()); | 1385 StoreFieldToOffset(TMP, instance_reg, Object::tags_offset()); |
| 1386 } else { | 1386 } else { |
| 1387 b(failure); | 1387 b(failure); |
| 1388 } | 1388 } |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 | 1391 |
| 1392 void Assembler::TryAllocateArray(intptr_t cid, | 1392 void Assembler::TryAllocateArray(intptr_t cid, |
| 1393 intptr_t instance_size, | 1393 intptr_t instance_size, |
| 1394 Label* failure, | 1394 Label* failure, |
| 1395 Register instance, | 1395 Register instance, |
| 1396 Register end_address, | 1396 Register end_address, |
| 1397 Register temp1, | 1397 Register temp1, |
| 1398 Register temp2) { | 1398 Register temp2) { |
| 1399 if (FLAG_inline_alloc) { | 1399 if (FLAG_inline_alloc) { |
| 1400 // If this allocation is traced, program will jump to failure path | 1400 // If this allocation is traced, program will jump to failure path |
| 1401 // (i.e. the allocation stub) which will allocate the object and trace the | 1401 // (i.e. the allocation stub) which will allocate the object and trace the |
| 1402 // allocation call site. | 1402 // allocation call site. |
| 1403 MaybeTraceAllocation(cid, temp1, failure); | 1403 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, temp1, failure)); |
| 1404 Heap::Space space = Heap::SpaceForAllocation(cid); | 1404 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 1405 ldr(temp1, Address(THR, Thread::heap_offset())); | 1405 ldr(temp1, Address(THR, Thread::heap_offset())); |
| 1406 // Potential new object start. | 1406 // Potential new object start. |
| 1407 ldr(instance, Address(temp1, Heap::TopOffset(space))); | 1407 ldr(instance, Address(temp1, Heap::TopOffset(space))); |
| 1408 AddImmediateSetFlags(end_address, instance, instance_size); | 1408 AddImmediateSetFlags(end_address, instance, instance_size); |
| 1409 b(failure, CS); // Fail on unsigned overflow. | 1409 b(failure, CS); // Fail on unsigned overflow. |
| 1410 | 1410 |
| 1411 // Check if the allocation fits into the remaining space. | 1411 // Check if the allocation fits into the remaining space. |
| 1412 // instance: potential new object start. | 1412 // instance: potential new object start. |
| 1413 // end_address: potential next object start. | 1413 // end_address: potential next object start. |
| 1414 ldr(temp2, Address(temp1, Heap::EndOffset(space))); | 1414 ldr(temp2, Address(temp1, Heap::EndOffset(space))); |
| 1415 cmp(end_address, Operand(temp2)); | 1415 cmp(end_address, Operand(temp2)); |
| 1416 b(failure, CS); | 1416 b(failure, CS); |
| 1417 | 1417 |
| 1418 // Successfully allocated the object(s), now update top to point to | 1418 // Successfully allocated the object(s), now update top to point to |
| 1419 // next object start and initialize the object. | 1419 // next object start and initialize the object. |
| 1420 str(end_address, Address(temp1, Heap::TopOffset(space))); | 1420 str(end_address, Address(temp1, Heap::TopOffset(space))); |
| 1421 add(instance, instance, Operand(kHeapObjectTag)); | 1421 add(instance, instance, Operand(kHeapObjectTag)); |
| 1422 LoadImmediate(temp2, instance_size); | 1422 LoadImmediate(temp2, instance_size); |
| 1423 UpdateAllocationStatsWithSize(cid, temp2, space); | 1423 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, temp2, space)); |
| 1424 | 1424 |
| 1425 // Initialize the tags. | 1425 // Initialize the tags. |
| 1426 // instance: new object start as a tagged pointer. | 1426 // instance: new object start as a tagged pointer. |
| 1427 uword tags = 0; | 1427 uword tags = 0; |
| 1428 tags = RawObject::ClassIdTag::update(cid, tags); | 1428 tags = RawObject::ClassIdTag::update(cid, tags); |
| 1429 tags = RawObject::SizeTag::update(instance_size, tags); | 1429 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1430 LoadImmediate(temp2, tags); | 1430 LoadImmediate(temp2, tags); |
| 1431 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags. | 1431 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags. |
| 1432 } else { | 1432 } else { |
| 1433 b(failure); | 1433 b(failure); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 add(base, array, Operand(index, LSL, shift)); | 1471 add(base, array, Operand(index, LSL, shift)); |
| 1472 } | 1472 } |
| 1473 const OperandSize size = Address::OperandSizeFor(cid); | 1473 const OperandSize size = Address::OperandSizeFor(cid); |
| 1474 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); | 1474 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); |
| 1475 return Address(base, offset, Address::Offset, size); | 1475 return Address(base, offset, Address::Offset, size); |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 } // namespace dart | 1478 } // namespace dart |
| 1479 | 1479 |
| 1480 #endif // defined TARGET_ARCH_ARM64 | 1480 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |