Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: runtime/vm/assembler_arm64.cc

Issue 1911253002: Never include_isolate or allow_embedded_addresses. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/assembler_arm64.h ('k') | runtime/vm/assembler_dbc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); 406 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal());
407 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); 407 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal());
408 if (Thread::CanLoadFromThread(object)) { 408 if (Thread::CanLoadFromThread(object)) {
409 ldr(dst, Address(THR, Thread::OffsetFromThread(object))); 409 ldr(dst, Address(THR, Thread::OffsetFromThread(object)));
410 } else if (CanLoadFromObjectPool(object)) { 410 } else if (CanLoadFromObjectPool(object)) {
411 const int32_t offset = ObjectPool::element_offset( 411 const int32_t offset = ObjectPool::element_offset(
412 is_unique ? object_pool_wrapper_.AddObject(object) 412 is_unique ? object_pool_wrapper_.AddObject(object)
413 : object_pool_wrapper_.FindObject(object)); 413 : object_pool_wrapper_.FindObject(object));
414 LoadWordFromPoolOffset(dst, offset); 414 LoadWordFromPoolOffset(dst, offset);
415 } else { 415 } else {
416 ASSERT(object.IsSmi() || object.InVMHeap()); 416 ASSERT(object.IsSmi());
417 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses);
418 LoadDecodableImmediate(dst, reinterpret_cast<int64_t>(object.raw())); 417 LoadDecodableImmediate(dst, reinterpret_cast<int64_t>(object.raw()));
419 } 418 }
420 } 419 }
421 420
422 421
423 void Assembler::LoadFunctionFromCalleePool(Register dst, 422 void Assembler::LoadFunctionFromCalleePool(Register dst,
424 const Function& function, 423 const Function& function,
425 Register new_pp) { 424 Register new_pp) {
426 ASSERT(!constant_pool_allowed()); 425 ASSERT(!constant_pool_allowed());
427 ASSERT(new_pp != PP); 426 ASSERT(new_pp != PP);
(...skipping 17 matching lines...) Expand all
445 void Assembler::CompareObject(Register reg, const Object& object) { 444 void Assembler::CompareObject(Register reg, const Object& object) {
446 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); 445 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal());
447 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); 446 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal());
448 if (Thread::CanLoadFromThread(object)) { 447 if (Thread::CanLoadFromThread(object)) {
449 ldr(TMP, Address(THR, Thread::OffsetFromThread(object))); 448 ldr(TMP, Address(THR, Thread::OffsetFromThread(object)));
450 CompareRegisters(reg, TMP); 449 CompareRegisters(reg, TMP);
451 } else if (CanLoadFromObjectPool(object)) { 450 } else if (CanLoadFromObjectPool(object)) {
452 LoadObject(TMP, object); 451 LoadObject(TMP, object);
453 CompareRegisters(reg, TMP); 452 CompareRegisters(reg, TMP);
454 } else { 453 } else {
455 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); 454 ASSERT(object.IsSmi());
456 CompareImmediate(reg, reinterpret_cast<int64_t>(object.raw())); 455 CompareImmediate(reg, reinterpret_cast<int64_t>(object.raw()));
457 } 456 }
458 } 457 }
459 458
460 459
461 void Assembler::LoadDecodableImmediate(Register reg, int64_t imm) { 460 void Assembler::LoadDecodableImmediate(Register reg, int64_t imm) {
462 if (constant_pool_allowed()) { 461 if (constant_pool_allowed()) {
463 const int32_t offset = ObjectPool::element_offset(FindImmediate(imm)); 462 const int32_t offset = ObjectPool::element_offset(FindImmediate(imm));
464 LoadWordFromPoolOffset(reg, offset); 463 LoadWordFromPoolOffset(reg, offset);
465 } else { 464 } else {
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 EnterDartFrame(0); 1256 EnterDartFrame(0);
1258 } 1257 }
1259 1258
1260 1259
1261 void Assembler::LeaveStubFrame() { 1260 void Assembler::LeaveStubFrame() {
1262 LeaveDartFrame(); 1261 LeaveDartFrame();
1263 } 1262 }
1264 1263
1265 1264
1266 void Assembler::UpdateAllocationStats(intptr_t cid, 1265 void Assembler::UpdateAllocationStats(intptr_t cid,
1267 Heap::Space space, 1266 Heap::Space space) {
1268 bool inline_isolate) {
1269 ASSERT(cid > 0); 1267 ASSERT(cid > 0);
1270 intptr_t counter_offset = 1268 intptr_t counter_offset =
1271 ClassTable::CounterOffsetFor(cid, space == Heap::kNew); 1269 ClassTable::CounterOffsetFor(cid, space == Heap::kNew);
1272 if (inline_isolate) { 1270 LoadIsolate(TMP2);
1273 ASSERT(FLAG_allow_absolute_addresses); 1271 intptr_t table_offset =
1274 ClassTable* class_table = Isolate::Current()->class_table(); 1272 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1275 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid); 1273 ldr(TMP, Address(TMP2, table_offset));
1276 if (cid < kNumPredefinedCids) { 1274 AddImmediate(TMP2, TMP, counter_offset);
1277 LoadImmediate(
1278 TMP2, reinterpret_cast<uword>(*table_ptr) + counter_offset);
1279 } else {
1280 LoadImmediate(TMP2, reinterpret_cast<uword>(table_ptr));
1281 ldr(TMP, Address(TMP2));
1282 AddImmediate(TMP2, TMP, counter_offset);
1283 }
1284 } else {
1285 LoadIsolate(TMP2);
1286 intptr_t table_offset =
1287 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1288 ldr(TMP, Address(TMP2, table_offset));
1289 AddImmediate(TMP2, TMP, counter_offset);
1290 }
1291 ldr(TMP, Address(TMP2, 0)); 1275 ldr(TMP, Address(TMP2, 0));
1292 AddImmediate(TMP, TMP, 1); 1276 AddImmediate(TMP, TMP, 1);
1293 str(TMP, Address(TMP2, 0)); 1277 str(TMP, Address(TMP2, 0));
1294 } 1278 }
1295 1279
1296 1280
1297 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, 1281 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
1298 Register size_reg, 1282 Register size_reg,
1299 Heap::Space space, 1283 Heap::Space space) {
1300 bool inline_isolate) {
1301 ASSERT(cid > 0); 1284 ASSERT(cid > 0);
1302 const uword class_offset = ClassTable::ClassOffsetFor(cid); 1285 const uword class_offset = ClassTable::ClassOffsetFor(cid);
1303 const uword count_field_offset = (space == Heap::kNew) ? 1286 const uword count_field_offset = (space == Heap::kNew) ?
1304 ClassHeapStats::allocated_since_gc_new_space_offset() : 1287 ClassHeapStats::allocated_since_gc_new_space_offset() :
1305 ClassHeapStats::allocated_since_gc_old_space_offset(); 1288 ClassHeapStats::allocated_since_gc_old_space_offset();
1306 const uword size_field_offset = (space == Heap::kNew) ? 1289 const uword size_field_offset = (space == Heap::kNew) ?
1307 ClassHeapStats::allocated_size_since_gc_new_space_offset() : 1290 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
1308 ClassHeapStats::allocated_size_since_gc_old_space_offset(); 1291 ClassHeapStats::allocated_size_since_gc_old_space_offset();
1309 if (inline_isolate) { 1292 LoadIsolate(TMP2);
1310 ClassTable* class_table = Isolate::Current()->class_table(); 1293 intptr_t table_offset =
1311 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid); 1294 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1312 if (cid < kNumPredefinedCids) { 1295 ldr(TMP, Address(TMP2, table_offset));
1313 LoadImmediate(TMP2, 1296 AddImmediate(TMP2, TMP, class_offset);
1314 reinterpret_cast<uword>(*table_ptr) + class_offset);
1315 } else {
1316 LoadImmediate(TMP2, reinterpret_cast<uword>(table_ptr));
1317 ldr(TMP, Address(TMP2));
1318 AddImmediate(TMP2, TMP, class_offset);
1319 }
1320 } else {
1321 LoadIsolate(TMP2);
1322 intptr_t table_offset =
1323 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1324 ldr(TMP, Address(TMP2, table_offset));
1325 AddImmediate(TMP2, TMP, class_offset);
1326 }
1327 ldr(TMP, Address(TMP2, count_field_offset)); 1297 ldr(TMP, Address(TMP2, count_field_offset));
1328 AddImmediate(TMP, TMP, 1); 1298 AddImmediate(TMP, TMP, 1);
1329 str(TMP, Address(TMP2, count_field_offset)); 1299 str(TMP, Address(TMP2, count_field_offset));
1330 ldr(TMP, Address(TMP2, size_field_offset)); 1300 ldr(TMP, Address(TMP2, size_field_offset));
1331 add(TMP, TMP, Operand(size_reg)); 1301 add(TMP, TMP, Operand(size_reg));
1332 str(TMP, Address(TMP2, size_field_offset)); 1302 str(TMP, Address(TMP2, size_field_offset));
1333 } 1303 }
1334 1304
1335 1305
1336 void Assembler::MaybeTraceAllocation(intptr_t cid, 1306 void Assembler::MaybeTraceAllocation(intptr_t cid,
1337 Register temp_reg, 1307 Register temp_reg,
1338 Label* trace, 1308 Label* trace) {
1339 bool inline_isolate) {
1340 ASSERT(cid > 0); 1309 ASSERT(cid > 0);
1341 intptr_t state_offset = ClassTable::StateOffsetFor(cid); 1310 intptr_t state_offset = ClassTable::StateOffsetFor(cid);
1342 if (inline_isolate) { 1311 LoadIsolate(temp_reg);
1343 ASSERT(FLAG_allow_absolute_addresses); 1312 intptr_t table_offset =
1344 ClassTable* class_table = Isolate::Current()->class_table(); 1313 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1345 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid); 1314 ldr(temp_reg, Address(temp_reg, table_offset));
1346 if (cid < kNumPredefinedCids) { 1315 AddImmediate(temp_reg, temp_reg, state_offset);
1347 LoadImmediate(
1348 temp_reg, reinterpret_cast<uword>(*table_ptr) + state_offset);
1349 } else {
1350 LoadImmediate(temp_reg, reinterpret_cast<uword>(table_ptr));
1351 ldr(temp_reg, Address(temp_reg, 0));
1352 AddImmediate(temp_reg, temp_reg, state_offset);
1353 }
1354 } else {
1355 LoadIsolate(temp_reg);
1356 intptr_t table_offset =
1357 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1358 ldr(temp_reg, Address(temp_reg, table_offset));
1359 AddImmediate(temp_reg, temp_reg, state_offset);
1360 }
1361 ldr(temp_reg, Address(temp_reg, 0)); 1316 ldr(temp_reg, Address(temp_reg, 0));
1362 tsti(temp_reg, Immediate(ClassHeapStats::TraceAllocationMask())); 1317 tsti(temp_reg, Immediate(ClassHeapStats::TraceAllocationMask()));
1363 b(trace, NE); 1318 b(trace, NE);
1364 } 1319 }
1365 1320
1366 1321
1367 void Assembler::TryAllocate(const Class& cls, 1322 void Assembler::TryAllocate(const Class& cls,
1368 Label* failure, 1323 Label* failure,
1369 Register instance_reg, 1324 Register instance_reg,
1370 Register temp_reg) { 1325 Register temp_reg) {
1371 ASSERT(failure != NULL); 1326 ASSERT(failure != NULL);
1372 if (FLAG_inline_alloc) { 1327 if (FLAG_inline_alloc) {
1373 // If this allocation is traced, program will jump to failure path 1328 // If this allocation is traced, program will jump to failure path
1374 // (i.e. the allocation stub) which will allocate the object and trace the 1329 // (i.e. the allocation stub) which will allocate the object and trace the
1375 // allocation call site. 1330 // allocation call site.
1376 MaybeTraceAllocation(cls.id(), temp_reg, failure, 1331 MaybeTraceAllocation(cls.id(), temp_reg, failure);
1377 /* inline_isolate = */ false);
1378 const intptr_t instance_size = cls.instance_size(); 1332 const intptr_t instance_size = cls.instance_size();
1379 Heap::Space space = Heap::SpaceForAllocation(cls.id()); 1333 Heap::Space space = Heap::SpaceForAllocation(cls.id());
1380 ldr(temp_reg, Address(THR, Thread::heap_offset())); 1334 ldr(temp_reg, Address(THR, Thread::heap_offset()));
1381 ldr(instance_reg, Address(temp_reg, Heap::TopOffset(space))); 1335 ldr(instance_reg, Address(temp_reg, Heap::TopOffset(space)));
1382 // TODO(koda): Protect against unsigned overflow here. 1336 // TODO(koda): Protect against unsigned overflow here.
1383 AddImmediateSetFlags(instance_reg, instance_reg, instance_size); 1337 AddImmediateSetFlags(instance_reg, instance_reg, instance_size);
1384 1338
1385 // instance_reg: potential next object start. 1339 // instance_reg: potential next object start.
1386 ldr(TMP, Address(temp_reg, Heap::EndOffset(space))); 1340 ldr(TMP, Address(temp_reg, Heap::EndOffset(space)));
1387 CompareRegisters(TMP, instance_reg); 1341 CompareRegisters(TMP, instance_reg);
1388 // fail if heap end unsigned less than or equal to instance_reg. 1342 // fail if heap end unsigned less than or equal to instance_reg.
1389 b(failure, LS); 1343 b(failure, LS);
1390 1344
1391 // Successfully allocated the object, now update top to point to 1345 // Successfully allocated the object, now update top to point to
1392 // next object start and store the class in the class field of object. 1346 // next object start and store the class in the class field of object.
1393 str(instance_reg, Address(temp_reg, Heap::TopOffset(space))); 1347 str(instance_reg, Address(temp_reg, Heap::TopOffset(space)));
1394 1348
1395 ASSERT(instance_size >= kHeapObjectTag); 1349 ASSERT(instance_size >= kHeapObjectTag);
1396 AddImmediate( 1350 AddImmediate(
1397 instance_reg, instance_reg, -instance_size + kHeapObjectTag); 1351 instance_reg, instance_reg, -instance_size + kHeapObjectTag);
1398 UpdateAllocationStats(cls.id(), space, /* inline_isolate = */ false); 1352 UpdateAllocationStats(cls.id(), space);
1399 1353
1400 uword tags = 0; 1354 uword tags = 0;
1401 tags = RawObject::SizeTag::update(instance_size, tags); 1355 tags = RawObject::SizeTag::update(instance_size, tags);
1402 ASSERT(cls.id() != kIllegalCid); 1356 ASSERT(cls.id() != kIllegalCid);
1403 tags = RawObject::ClassIdTag::update(cls.id(), tags); 1357 tags = RawObject::ClassIdTag::update(cls.id(), tags);
1404 LoadImmediate(TMP, tags); 1358 LoadImmediate(TMP, tags);
1405 StoreFieldToOffset(TMP, instance_reg, Object::tags_offset()); 1359 StoreFieldToOffset(TMP, instance_reg, Object::tags_offset());
1406 } else { 1360 } else {
1407 b(failure); 1361 b(failure);
1408 } 1362 }
1409 } 1363 }
1410 1364
1411 1365
1412 void Assembler::TryAllocateArray(intptr_t cid, 1366 void Assembler::TryAllocateArray(intptr_t cid,
1413 intptr_t instance_size, 1367 intptr_t instance_size,
1414 Label* failure, 1368 Label* failure,
1415 Register instance, 1369 Register instance,
1416 Register end_address, 1370 Register end_address,
1417 Register temp1, 1371 Register temp1,
1418 Register temp2) { 1372 Register temp2) {
1419 if (FLAG_inline_alloc) { 1373 if (FLAG_inline_alloc) {
1420 // If this allocation is traced, program will jump to failure path 1374 // If this allocation is traced, program will jump to failure path
1421 // (i.e. the allocation stub) which will allocate the object and trace the 1375 // (i.e. the allocation stub) which will allocate the object and trace the
1422 // allocation call site. 1376 // allocation call site.
1423 MaybeTraceAllocation(cid, temp1, failure, /* inline_isolate = */ false); 1377 MaybeTraceAllocation(cid, temp1, failure);
1424 Heap::Space space = Heap::SpaceForAllocation(cid); 1378 Heap::Space space = Heap::SpaceForAllocation(cid);
1425 ldr(temp1, Address(THR, Thread::heap_offset())); 1379 ldr(temp1, Address(THR, Thread::heap_offset()));
1426 // Potential new object start. 1380 // Potential new object start.
1427 ldr(instance, Address(temp1, Heap::TopOffset(space))); 1381 ldr(instance, Address(temp1, Heap::TopOffset(space)));
1428 AddImmediateSetFlags(end_address, instance, instance_size); 1382 AddImmediateSetFlags(end_address, instance, instance_size);
1429 b(failure, CS); // Fail on unsigned overflow. 1383 b(failure, CS); // Fail on unsigned overflow.
1430 1384
1431 // Check if the allocation fits into the remaining space. 1385 // Check if the allocation fits into the remaining space.
1432 // instance: potential new object start. 1386 // instance: potential new object start.
1433 // end_address: potential next object start. 1387 // end_address: potential next object start.
1434 ldr(temp2, Address(temp1, Heap::EndOffset(space))); 1388 ldr(temp2, Address(temp1, Heap::EndOffset(space)));
1435 cmp(end_address, Operand(temp2)); 1389 cmp(end_address, Operand(temp2));
1436 b(failure, CS); 1390 b(failure, CS);
1437 1391
1438 // Successfully allocated the object(s), now update top to point to 1392 // Successfully allocated the object(s), now update top to point to
1439 // next object start and initialize the object. 1393 // next object start and initialize the object.
1440 str(end_address, Address(temp1, Heap::TopOffset(space))); 1394 str(end_address, Address(temp1, Heap::TopOffset(space)));
1441 add(instance, instance, Operand(kHeapObjectTag)); 1395 add(instance, instance, Operand(kHeapObjectTag));
1442 LoadImmediate(temp2, instance_size); 1396 LoadImmediate(temp2, instance_size);
1443 UpdateAllocationStatsWithSize(cid, temp2, space, 1397 UpdateAllocationStatsWithSize(cid, temp2, space);
1444 /* inline_isolate = */ false);
1445 1398
1446 // Initialize the tags. 1399 // Initialize the tags.
1447 // instance: new object start as a tagged pointer. 1400 // instance: new object start as a tagged pointer.
1448 uword tags = 0; 1401 uword tags = 0;
1449 tags = RawObject::ClassIdTag::update(cid, tags); 1402 tags = RawObject::ClassIdTag::update(cid, tags);
1450 tags = RawObject::SizeTag::update(instance_size, tags); 1403 tags = RawObject::SizeTag::update(instance_size, tags);
1451 LoadImmediate(temp2, tags); 1404 LoadImmediate(temp2, tags);
1452 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags. 1405 str(temp2, FieldAddress(instance, Array::tags_offset())); // Store tags.
1453 } else { 1406 } else {
1454 b(failure); 1407 b(failure);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 add(base, array, Operand(index, LSL, shift)); 1445 add(base, array, Operand(index, LSL, shift));
1493 } 1446 }
1494 const OperandSize size = Address::OperandSizeFor(cid); 1447 const OperandSize size = Address::OperandSizeFor(cid);
1495 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); 1448 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size));
1496 return Address(base, offset, Address::Offset, size); 1449 return Address(base, offset, Address::Offset, size);
1497 } 1450 }
1498 1451
1499 } // namespace dart 1452 } // namespace dart
1500 1453
1501 #endif // defined TARGET_ARCH_ARM64 1454 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm64.h ('k') | runtime/vm/assembler_dbc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698