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 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 Label* failure, | 1336 Label* failure, |
1337 Register instance_reg, | 1337 Register instance_reg, |
1338 Register temp_reg) { | 1338 Register temp_reg) { |
1339 ASSERT(failure != NULL); | 1339 ASSERT(failure != NULL); |
1340 if (FLAG_inline_alloc) { | 1340 if (FLAG_inline_alloc) { |
1341 // If this allocation is traced, program will jump to failure path | 1341 // If this allocation is traced, program will jump to failure path |
1342 // (i.e. the allocation stub) which will allocate the object and trace the | 1342 // (i.e. the allocation stub) which will allocate the object and trace the |
1343 // allocation call site. | 1343 // allocation call site. |
1344 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), temp_reg, failure)); | 1344 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), temp_reg, failure)); |
1345 const intptr_t instance_size = cls.instance_size(); | 1345 const intptr_t instance_size = cls.instance_size(); |
1346 Heap::Space space = Heap::kNew; | 1346 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
1347 ldr(temp_reg, Address(THR, Thread::heap_offset())); | 1347 ldr(instance_reg, Address(THR, Thread::top_offset())); |
1348 ldr(instance_reg, Address(temp_reg, Heap::TopOffset(space))); | |
1349 // TODO(koda): Protect against unsigned overflow here. | 1348 // TODO(koda): Protect against unsigned overflow here. |
1350 AddImmediateSetFlags(instance_reg, instance_reg, instance_size); | 1349 AddImmediateSetFlags(instance_reg, instance_reg, instance_size); |
1351 | 1350 |
1352 // instance_reg: potential next object start. | 1351 // instance_reg: potential next object start. |
1353 ldr(TMP, Address(temp_reg, Heap::EndOffset(space))); | 1352 ldr(TMP, Address(THR, Thread::end_offset())); |
1354 CompareRegisters(TMP, instance_reg); | 1353 CompareRegisters(TMP, instance_reg); |
1355 // fail if heap end unsigned less than or equal to instance_reg. | 1354 // fail if heap end unsigned less than or equal to instance_reg. |
1356 b(failure, LS); | 1355 b(failure, LS); |
1357 | 1356 |
1358 // Successfully allocated the object, now update top to point to | 1357 // Successfully allocated the object, now update top to point to |
1359 // next object start and store the class in the class field of object. | 1358 // next object start and store the class in the class field of object. |
1360 str(instance_reg, Address(temp_reg, Heap::TopOffset(space))); | 1359 str(instance_reg, Address(THR, Thread::top_offset())); |
1361 | 1360 |
1362 ASSERT(instance_size >= kHeapObjectTag); | 1361 ASSERT(instance_size >= kHeapObjectTag); |
1363 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); | 1362 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); |
1364 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); | 1363 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); |
1365 | 1364 |
1366 uint32_t tags = 0; | 1365 uint32_t tags = 0; |
1367 tags = RawObject::SizeTag::update(instance_size, tags); | 1366 tags = RawObject::SizeTag::update(instance_size, tags); |
1368 ASSERT(cls.id() != kIllegalCid); | 1367 ASSERT(cls.id() != kIllegalCid); |
1369 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1368 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
1370 // Extends the 32 bit tags with zeros, which is the uninitialized | 1369 // Extends the 32 bit tags with zeros, which is the uninitialized |
(...skipping 11 matching lines...) Expand all Loading... |
1382 Label* failure, | 1381 Label* failure, |
1383 Register instance, | 1382 Register instance, |
1384 Register end_address, | 1383 Register end_address, |
1385 Register temp1, | 1384 Register temp1, |
1386 Register temp2) { | 1385 Register temp2) { |
1387 if (FLAG_inline_alloc) { | 1386 if (FLAG_inline_alloc) { |
1388 // If this allocation is traced, program will jump to failure path | 1387 // If this allocation is traced, program will jump to failure path |
1389 // (i.e. the allocation stub) which will allocate the object and trace the | 1388 // (i.e. the allocation stub) which will allocate the object and trace the |
1390 // allocation call site. | 1389 // allocation call site. |
1391 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, temp1, failure)); | 1390 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, temp1, failure)); |
1392 Heap::Space space = Heap::kNew; | 1391 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
1393 ldr(temp1, Address(THR, Thread::heap_offset())); | |
1394 // Potential new object start. | 1392 // Potential new object start. |
1395 ldr(instance, Address(temp1, Heap::TopOffset(space))); | 1393 ldr(instance, Address(THR, Thread::top_offset())); |
1396 AddImmediateSetFlags(end_address, instance, instance_size); | 1394 AddImmediateSetFlags(end_address, instance, instance_size); |
1397 b(failure, CS); // Fail on unsigned overflow. | 1395 b(failure, CS); // Fail on unsigned overflow. |
1398 | 1396 |
1399 // Check if the allocation fits into the remaining space. | 1397 // Check if the allocation fits into the remaining space. |
1400 // instance: potential new object start. | 1398 // instance: potential new object start. |
1401 // end_address: potential next object start. | 1399 // end_address: potential next object start. |
1402 ldr(temp2, Address(temp1, Heap::EndOffset(space))); | 1400 ldr(temp2, Address(THR, Thread::end_offset())); |
1403 cmp(end_address, Operand(temp2)); | 1401 cmp(end_address, Operand(temp2)); |
1404 b(failure, CS); | 1402 b(failure, CS); |
1405 | 1403 |
1406 // Successfully allocated the object(s), now update top to point to | 1404 // Successfully allocated the object(s), now update top to point to |
1407 // next object start and initialize the object. | 1405 // next object start and initialize the object. |
1408 str(end_address, Address(temp1, Heap::TopOffset(space))); | 1406 str(end_address, Address(THR, Thread::top_offset())); |
1409 add(instance, instance, Operand(kHeapObjectTag)); | 1407 add(instance, instance, Operand(kHeapObjectTag)); |
1410 LoadImmediate(temp2, instance_size); | 1408 LoadImmediate(temp2, instance_size); |
1411 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, temp2, space)); | 1409 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, temp2, space)); |
1412 | 1410 |
1413 // Initialize the tags. | 1411 // Initialize the tags. |
1414 // instance: new object start as a tagged pointer. | 1412 // instance: new object start as a tagged pointer. |
1415 uint32_t tags = 0; | 1413 uint32_t tags = 0; |
1416 tags = RawObject::ClassIdTag::update(cid, tags); | 1414 tags = RawObject::ClassIdTag::update(cid, tags); |
1417 tags = RawObject::SizeTag::update(instance_size, tags); | 1415 tags = RawObject::SizeTag::update(instance_size, tags); |
1418 // Extends the 32 bit tags with zeros, which is the uninitialized | 1416 // Extends the 32 bit tags with zeros, which is the uninitialized |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 str(tmp, Address(addr, 7), kUnsignedByte); | 1573 str(tmp, Address(addr, 7), kUnsignedByte); |
1576 if (sz == kDoubleWord) { | 1574 if (sz == kDoubleWord) { |
1577 return; | 1575 return; |
1578 } | 1576 } |
1579 UNIMPLEMENTED(); | 1577 UNIMPLEMENTED(); |
1580 } | 1578 } |
1581 | 1579 |
1582 } // namespace dart | 1580 } // namespace dart |
1583 | 1581 |
1584 #endif // defined TARGET_ARCH_ARM64 | 1582 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |