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

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

Issue 1241863002: VM: Refactor allocation stats code and remove duplicate code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: make context allocation isolate-independent Created 5 years, 5 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
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 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 void Assembler::LeaveStubFrame() { 1223 void Assembler::LeaveStubFrame() {
1224 // Restore and untag PP. 1224 // Restore and untag PP.
1225 LoadFromOffset(PP, FP, kSavedCallerPpSlotFromFp * kWordSize, kNoPP); 1225 LoadFromOffset(PP, FP, kSavedCallerPpSlotFromFp * kWordSize, kNoPP);
1226 sub(PP, PP, Operand(kHeapObjectTag)); 1226 sub(PP, PP, Operand(kHeapObjectTag));
1227 LeaveFrame(); 1227 LeaveFrame();
1228 } 1228 }
1229 1229
1230 1230
1231 void Assembler::UpdateAllocationStats(intptr_t cid, 1231 void Assembler::UpdateAllocationStats(intptr_t cid,
1232 Register pp, 1232 Register pp,
1233 Heap::Space space) { 1233 Heap::Space space,
1234 bool inline_isolate) {
1234 ASSERT(cid > 0); 1235 ASSERT(cid > 0);
1235 Isolate* isolate = Isolate::Current(); 1236 intptr_t counter_offset;
1236 ClassTable* class_table = isolate->class_table(); 1237 ClassTable* class_table = Isolate::Current()->class_table();
1237 if (cid < kNumPredefinedCids) { 1238 ClassHeapStats** table_ptr = class_table->CountAddressFor(
1238 const uword class_heap_stats_table_address = 1239 cid, space == Heap::kNew, &counter_offset);
1239 class_table->PredefinedClassHeapStatsTableAddress(); 1240 const Address& count_address = Address(TMP2, 0);
1240 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1241 if (cid < kNumPredefinedCids && inline_isolate) {
1241 const uword count_field_offset = (space == Heap::kNew) ? 1242 LoadImmediate(
1242 ClassHeapStats::allocated_since_gc_new_space_offset() : 1243 TMP2, reinterpret_cast<uword>(*table_ptr) + counter_offset, pp);
1243 ClassHeapStats::allocated_since_gc_old_space_offset();
1244 LoadImmediate(TMP2, class_heap_stats_table_address + class_offset, pp);
1245 const Address& count_address = Address(TMP2, count_field_offset);
1246 ldr(TMP, count_address); 1244 ldr(TMP, count_address);
1247 AddImmediate(TMP, TMP, 1, pp); 1245 AddImmediate(TMP, TMP, 1, pp);
1248 str(TMP, count_address); 1246 str(TMP, count_address);
1249 } else { 1247 } else {
1250 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1248 if (inline_isolate) {
1251 const uword count_field_offset = (space == Heap::kNew) ? 1249 LoadImmediate(TMP2, reinterpret_cast<uword>(table_ptr), pp);
1252 ClassHeapStats::allocated_since_gc_new_space_offset() : 1250 ldr(TMP, Address(TMP2));
1253 ClassHeapStats::allocated_since_gc_old_space_offset(); 1251 } else {
1254 LoadImmediate(TMP2, class_table->ClassStatsTableAddress(), pp); 1252 LoadIsolate(TMP2);
1255 ldr(TMP, Address(TMP2)); 1253 intptr_t table_offset =
1256 AddImmediate(TMP2, TMP, class_offset, pp); 1254 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1257 ldr(TMP, Address(TMP2, count_field_offset)); 1255 ldr(TMP, Address(TMP2, table_offset));
1256 }
1257 AddImmediate(TMP2, TMP, counter_offset, pp);
1258 ldr(TMP, Address(TMP2, 0));
1258 AddImmediate(TMP, TMP, 1, pp); 1259 AddImmediate(TMP, TMP, 1, pp);
1259 str(TMP, Address(TMP2, count_field_offset)); 1260 str(TMP, Address(TMP2, 0));
1260 } 1261 }
1261 } 1262 }
1262 1263
1263 1264
1264 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, 1265 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
1265 Register size_reg, 1266 Register size_reg,
1266 Register pp, 1267 Register pp,
1267 Heap::Space space) { 1268 Heap::Space space,
1269 bool inline_isolate) {
1268 ASSERT(cid > 0); 1270 ASSERT(cid > 0);
1269 Isolate* isolate = Isolate::Current(); 1271 ClassTable* class_table = Isolate::Current()->class_table();
1270 ClassTable* class_table = isolate->class_table(); 1272 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid);
1271 if (cid < kNumPredefinedCids) { 1273 const uword class_offset = ClassTable::ClassOffsetFor(cid);
1272 const uword class_heap_stats_table_address = 1274 const uword count_field_offset = (space == Heap::kNew) ?
1273 class_table->PredefinedClassHeapStatsTableAddress(); 1275 ClassHeapStats::allocated_since_gc_new_space_offset() :
1274 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1276 ClassHeapStats::allocated_since_gc_old_space_offset();
1275 const uword count_field_offset = (space == Heap::kNew) ? 1277 const uword size_field_offset = (space == Heap::kNew) ?
1276 ClassHeapStats::allocated_since_gc_new_space_offset() : 1278 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
1277 ClassHeapStats::allocated_since_gc_old_space_offset(); 1279 ClassHeapStats::allocated_size_since_gc_old_space_offset();
1278 const uword size_field_offset = (space == Heap::kNew) ? 1280 if (cid < kNumPredefinedCids && inline_isolate) {
1279 ClassHeapStats::allocated_size_since_gc_new_space_offset() : 1281 LoadImmediate(TMP2, reinterpret_cast<uword>(*table_ptr) + class_offset, pp);
1280 ClassHeapStats::allocated_size_since_gc_old_space_offset();
1281 LoadImmediate(TMP2, class_heap_stats_table_address + class_offset, pp);
1282 const Address& count_address = Address(TMP2, count_field_offset); 1282 const Address& count_address = Address(TMP2, count_field_offset);
1283 const Address& size_address = Address(TMP2, size_field_offset); 1283 const Address& size_address = Address(TMP2, size_field_offset);
1284 ldr(TMP, count_address); 1284 ldr(TMP, count_address);
1285 AddImmediate(TMP, TMP, 1, pp); 1285 AddImmediate(TMP, TMP, 1, pp);
1286 str(TMP, count_address); 1286 str(TMP, count_address);
1287 ldr(TMP, size_address); 1287 ldr(TMP, size_address);
1288 add(TMP, TMP, Operand(size_reg)); 1288 add(TMP, TMP, Operand(size_reg));
1289 str(TMP, size_address); 1289 str(TMP, size_address);
1290 } else { 1290 } else {
1291 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1291 if (inline_isolate) {
1292 const uword count_field_offset = (space == Heap::kNew) ? 1292 LoadImmediate(TMP2, reinterpret_cast<uword>(table_ptr), pp);
1293 ClassHeapStats::allocated_since_gc_new_space_offset() : 1293 ldr(TMP, Address(TMP2));
1294 ClassHeapStats::allocated_since_gc_old_space_offset(); 1294 } else {
1295 const uword size_field_offset = (space == Heap::kNew) ? 1295 LoadIsolate(TMP2);
1296 ClassHeapStats::allocated_size_since_gc_new_space_offset() : 1296 intptr_t table_offset =
1297 ClassHeapStats::allocated_size_since_gc_old_space_offset(); 1297 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1298 LoadImmediate(TMP2, class_table->ClassStatsTableAddress(), pp); 1298 ldr(TMP, Address(TMP2, table_offset));
1299 ldr(TMP, Address(TMP2)); 1299 }
1300 AddImmediate(TMP2, TMP, class_offset, pp); 1300 AddImmediate(TMP2, TMP, class_offset, pp);
1301 ldr(TMP, Address(TMP2, count_field_offset)); 1301 ldr(TMP, Address(TMP2, count_field_offset));
1302 AddImmediate(TMP, TMP, 1, pp); 1302 AddImmediate(TMP, TMP, 1, pp);
1303 str(TMP, Address(TMP2, count_field_offset)); 1303 str(TMP, Address(TMP2, count_field_offset));
1304 ldr(TMP, Address(TMP2, size_field_offset)); 1304 ldr(TMP, Address(TMP2, size_field_offset));
1305 add(TMP, TMP, Operand(size_reg)); 1305 add(TMP, TMP, Operand(size_reg));
1306 str(TMP, Address(TMP2, size_field_offset)); 1306 str(TMP, Address(TMP2, size_field_offset));
1307 } 1307 }
1308 } 1308 }
1309 1309
1310 1310
1311 void Assembler::MaybeTraceAllocation(intptr_t cid, 1311 void Assembler::MaybeTraceAllocation(intptr_t cid,
1312 Register temp_reg, 1312 Register temp_reg,
1313 Register pp, 1313 Register pp,
1314 Label* trace) { 1314 Label* trace) {
1315 ASSERT(cid > 0); 1315 ASSERT(cid > 0);
1316 Isolate* isolate = Isolate::Current(); 1316 intptr_t state_offset;
1317 ClassTable* class_table = isolate->class_table(); 1317 ClassTable* class_table = Isolate::Current()->class_table();
1318 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1318 ClassHeapStats** table_ptr =
1319 class_table->StateAddressFor(cid, &state_offset);
1320
1319 if (cid < kNumPredefinedCids) { 1321 if (cid < kNumPredefinedCids) {
1320 const uword class_heap_stats_table_address = 1322 LoadImmediate(
1321 class_table->PredefinedClassHeapStatsTableAddress(); 1323 temp_reg, reinterpret_cast<uword>(*table_ptr) + state_offset, pp);
1322 LoadImmediate(temp_reg, class_heap_stats_table_address + class_offset, pp);
1323 } else { 1324 } else {
1324 LoadImmediate(temp_reg, class_table->ClassStatsTableAddress(), pp); 1325 LoadImmediate(temp_reg, reinterpret_cast<uword>(table_ptr), pp);
1325 ldr(temp_reg, Address(temp_reg, 0)); 1326 ldr(temp_reg, Address(temp_reg, 0));
1326 AddImmediate(temp_reg, temp_reg, class_offset, pp); 1327 AddImmediate(temp_reg, temp_reg, state_offset, pp);
1327 } 1328 }
1328 const uword state_offset = ClassHeapStats::state_offset(); 1329 ldr(temp_reg, Address(temp_reg, 0));
1329 const Address& state_address = Address(temp_reg, state_offset);
1330 ldr(temp_reg, state_address);
1331 tsti(temp_reg, Immediate(ClassHeapStats::TraceAllocationMask())); 1330 tsti(temp_reg, Immediate(ClassHeapStats::TraceAllocationMask()));
1332 b(trace, NE); 1331 b(trace, NE);
1333 } 1332 }
1334 1333
1335 1334
1336 void Assembler::TryAllocate(const Class& cls, 1335 void Assembler::TryAllocate(const Class& cls,
1337 Label* failure, 1336 Label* failure,
1338 Register instance_reg, 1337 Register instance_reg,
1339 Register temp_reg, 1338 Register temp_reg,
1340 Register pp) { 1339 Register pp) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 add(base, array, Operand(index, LSL, shift)); 1466 add(base, array, Operand(index, LSL, shift));
1468 } 1467 }
1469 const OperandSize size = Address::OperandSizeFor(cid); 1468 const OperandSize size = Address::OperandSizeFor(cid);
1470 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); 1469 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size));
1471 return Address(base, offset, Address::Offset, size); 1470 return Address(base, offset, Address::Offset, size);
1472 } 1471 }
1473 1472
1474 } // namespace dart 1473 } // namespace dart
1475 1474
1476 #endif // defined TARGET_ARCH_ARM64 1475 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698