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

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: addressed comments 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
« no previous file with comments | « runtime/vm/assembler_arm64.h ('k') | runtime/vm/assembler_ia32.h » ('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 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::CounterOffsetFor(cid, space == Heap::kNew);
1237 if (cid < kNumPredefinedCids) { 1238 if (inline_isolate) {
1238 const uword class_heap_stats_table_address = 1239 ClassTable* class_table = Isolate::Current()->class_table();
1239 class_table->PredefinedClassHeapStatsTableAddress(); 1240 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid);
1240 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1241 if (cid < kNumPredefinedCids) {
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 } else {
1244 LoadImmediate(TMP2, class_heap_stats_table_address + class_offset, pp); 1245 LoadImmediate(TMP2, reinterpret_cast<uword>(table_ptr), pp);
1245 const Address& count_address = Address(TMP2, count_field_offset); 1246 ldr(TMP, Address(TMP2));
1246 ldr(TMP, count_address); 1247 AddImmediate(TMP2, TMP, counter_offset, pp);
1247 AddImmediate(TMP, TMP, 1, pp); 1248 }
1248 str(TMP, count_address);
1249 } else { 1249 } else {
1250 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1250 LoadIsolate(TMP2);
1251 const uword count_field_offset = (space == Heap::kNew) ? 1251 intptr_t table_offset =
1252 ClassHeapStats::allocated_since_gc_new_space_offset() : 1252 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1253 ClassHeapStats::allocated_since_gc_old_space_offset(); 1253 ldr(TMP, Address(TMP2, table_offset));
1254 LoadImmediate(TMP2, class_table->ClassStatsTableAddress(), pp); 1254 AddImmediate(TMP2, TMP, counter_offset, pp);
1255 ldr(TMP, Address(TMP2));
1256 AddImmediate(TMP2, TMP, class_offset, pp);
1257 ldr(TMP, Address(TMP2, count_field_offset));
1258 AddImmediate(TMP, TMP, 1, pp);
1259 str(TMP, Address(TMP2, count_field_offset));
1260 } 1255 }
1256 ldr(TMP, Address(TMP2, 0));
1257 AddImmediate(TMP, TMP, 1, pp);
1258 str(TMP, Address(TMP2, 0));
1261 } 1259 }
1262 1260
1263 1261
1264 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, 1262 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
1265 Register size_reg, 1263 Register size_reg,
1266 Register pp, 1264 Register pp,
1267 Heap::Space space) { 1265 Heap::Space space,
1266 bool inline_isolate) {
1268 ASSERT(cid > 0); 1267 ASSERT(cid > 0);
1269 Isolate* isolate = Isolate::Current(); 1268 const uword class_offset = ClassTable::ClassOffsetFor(cid);
1270 ClassTable* class_table = isolate->class_table(); 1269 const uword count_field_offset = (space == Heap::kNew) ?
1271 if (cid < kNumPredefinedCids) { 1270 ClassHeapStats::allocated_since_gc_new_space_offset() :
1272 const uword class_heap_stats_table_address = 1271 ClassHeapStats::allocated_since_gc_old_space_offset();
1273 class_table->PredefinedClassHeapStatsTableAddress(); 1272 const uword size_field_offset = (space == Heap::kNew) ?
1274 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1273 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
1275 const uword count_field_offset = (space == Heap::kNew) ? 1274 ClassHeapStats::allocated_size_since_gc_old_space_offset();
1276 ClassHeapStats::allocated_since_gc_new_space_offset() : 1275 if (inline_isolate) {
1277 ClassHeapStats::allocated_since_gc_old_space_offset(); 1276 ClassTable* class_table = Isolate::Current()->class_table();
1278 const uword size_field_offset = (space == Heap::kNew) ? 1277 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid);
1279 ClassHeapStats::allocated_size_since_gc_new_space_offset() : 1278 if (cid < kNumPredefinedCids) {
1280 ClassHeapStats::allocated_size_since_gc_old_space_offset(); 1279 LoadImmediate(TMP2,
1281 LoadImmediate(TMP2, class_heap_stats_table_address + class_offset, pp); 1280 reinterpret_cast<uword>(*table_ptr) + class_offset, pp);
1282 const Address& count_address = Address(TMP2, count_field_offset); 1281 } else {
1283 const Address& size_address = Address(TMP2, size_field_offset); 1282 LoadImmediate(TMP2, reinterpret_cast<uword>(table_ptr), pp);
1284 ldr(TMP, count_address); 1283 ldr(TMP, Address(TMP2));
1285 AddImmediate(TMP, TMP, 1, pp); 1284 AddImmediate(TMP2, TMP, class_offset, pp);
1286 str(TMP, count_address); 1285 }
1287 ldr(TMP, size_address);
1288 add(TMP, TMP, Operand(size_reg));
1289 str(TMP, size_address);
1290 } else { 1286 } else {
1291 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1287 LoadIsolate(TMP2);
1292 const uword count_field_offset = (space == Heap::kNew) ? 1288 intptr_t table_offset =
1293 ClassHeapStats::allocated_since_gc_new_space_offset() : 1289 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
1294 ClassHeapStats::allocated_since_gc_old_space_offset(); 1290 ldr(TMP, Address(TMP2, table_offset));
1295 const uword size_field_offset = (space == Heap::kNew) ?
1296 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
1297 ClassHeapStats::allocated_size_since_gc_old_space_offset();
1298 LoadImmediate(TMP2, class_table->ClassStatsTableAddress(), pp);
1299 ldr(TMP, Address(TMP2));
1300 AddImmediate(TMP2, TMP, class_offset, pp); 1291 AddImmediate(TMP2, TMP, class_offset, pp);
1301 ldr(TMP, Address(TMP2, count_field_offset));
1302 AddImmediate(TMP, TMP, 1, pp);
1303 str(TMP, Address(TMP2, count_field_offset));
1304 ldr(TMP, Address(TMP2, size_field_offset));
1305 add(TMP, TMP, Operand(size_reg));
1306 str(TMP, Address(TMP2, size_field_offset));
1307 } 1292 }
1293 ldr(TMP, Address(TMP2, count_field_offset));
1294 AddImmediate(TMP, TMP, 1, pp);
1295 str(TMP, Address(TMP2, count_field_offset));
1296 ldr(TMP, Address(TMP2, size_field_offset));
1297 add(TMP, TMP, Operand(size_reg));
1298 str(TMP, Address(TMP2, size_field_offset));
1308 } 1299 }
1309 1300
1310 1301
1311 void Assembler::MaybeTraceAllocation(intptr_t cid, 1302 void Assembler::MaybeTraceAllocation(intptr_t cid,
1312 Register temp_reg, 1303 Register temp_reg,
1313 Register pp, 1304 Register pp,
1314 Label* trace) { 1305 Label* trace) {
1315 ASSERT(cid > 0); 1306 ASSERT(cid > 0);
1316 Isolate* isolate = Isolate::Current(); 1307 intptr_t state_offset;
1317 ClassTable* class_table = isolate->class_table(); 1308 ClassTable* class_table = Isolate::Current()->class_table();
1318 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 1309 ClassHeapStats** table_ptr =
1310 class_table->StateAddressFor(cid, &state_offset);
1311
1319 if (cid < kNumPredefinedCids) { 1312 if (cid < kNumPredefinedCids) {
1320 const uword class_heap_stats_table_address = 1313 LoadImmediate(
1321 class_table->PredefinedClassHeapStatsTableAddress(); 1314 temp_reg, reinterpret_cast<uword>(*table_ptr) + state_offset, pp);
1322 LoadImmediate(temp_reg, class_heap_stats_table_address + class_offset, pp);
1323 } else { 1315 } else {
1324 LoadImmediate(temp_reg, class_table->ClassStatsTableAddress(), pp); 1316 LoadImmediate(temp_reg, reinterpret_cast<uword>(table_ptr), pp);
1325 ldr(temp_reg, Address(temp_reg, 0)); 1317 ldr(temp_reg, Address(temp_reg, 0));
1326 AddImmediate(temp_reg, temp_reg, class_offset, pp); 1318 AddImmediate(temp_reg, temp_reg, state_offset, pp);
1327 } 1319 }
1328 const uword state_offset = ClassHeapStats::state_offset(); 1320 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())); 1321 tsti(temp_reg, Immediate(ClassHeapStats::TraceAllocationMask()));
1332 b(trace, NE); 1322 b(trace, NE);
1333 } 1323 }
1334 1324
1335 1325
1336 void Assembler::TryAllocate(const Class& cls, 1326 void Assembler::TryAllocate(const Class& cls,
1337 Label* failure, 1327 Label* failure,
1338 Register instance_reg, 1328 Register instance_reg,
1339 Register temp_reg, 1329 Register temp_reg,
1340 Register pp) { 1330 Register pp) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 add(base, array, Operand(index, LSL, shift)); 1457 add(base, array, Operand(index, LSL, shift));
1468 } 1458 }
1469 const OperandSize size = Address::OperandSizeFor(cid); 1459 const OperandSize size = Address::OperandSizeFor(cid);
1470 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); 1460 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size));
1471 return Address(base, offset, Address::Offset, size); 1461 return Address(base, offset, Address::Offset, size);
1472 } 1462 }
1473 1463
1474 } // namespace dart 1464 } // namespace dart
1475 1465
1476 #endif // defined TARGET_ARCH_ARM64 1466 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm64.h ('k') | runtime/vm/assembler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698