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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/assembler_arm64.cc
diff --git a/runtime/vm/assembler_arm64.cc b/runtime/vm/assembler_arm64.cc
index 6d315e61a228fa539f397e1a43f49f1f291535d7..ba5fcccdfca71be2ab720edcc2be5e77529a28df 100644
--- a/runtime/vm/assembler_arm64.cc
+++ b/runtime/vm/assembler_arm64.cc
@@ -1230,33 +1230,34 @@ void Assembler::LeaveStubFrame() {
void Assembler::UpdateAllocationStats(intptr_t cid,
Register pp,
- Heap::Space space) {
+ Heap::Space space,
+ bool inline_isolate) {
ASSERT(cid > 0);
- Isolate* isolate = Isolate::Current();
- ClassTable* class_table = isolate->class_table();
- if (cid < kNumPredefinedCids) {
- const uword class_heap_stats_table_address =
- class_table->PredefinedClassHeapStatsTableAddress();
- const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
- const uword count_field_offset = (space == Heap::kNew) ?
- ClassHeapStats::allocated_since_gc_new_space_offset() :
- ClassHeapStats::allocated_since_gc_old_space_offset();
- LoadImmediate(TMP2, class_heap_stats_table_address + class_offset, pp);
- const Address& count_address = Address(TMP2, count_field_offset);
+ intptr_t counter_offset;
+ ClassTable* class_table = Isolate::Current()->class_table();
+ ClassHeapStats** table_ptr = class_table->CountAddressFor(
+ cid, space == Heap::kNew, &counter_offset);
+ const Address& count_address = Address(TMP2, 0);
+ if (cid < kNumPredefinedCids && inline_isolate) {
+ LoadImmediate(
+ TMP2, reinterpret_cast<uword>(*table_ptr) + counter_offset, pp);
ldr(TMP, count_address);
AddImmediate(TMP, TMP, 1, pp);
str(TMP, count_address);
} else {
- const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
- const uword count_field_offset = (space == Heap::kNew) ?
- ClassHeapStats::allocated_since_gc_new_space_offset() :
- ClassHeapStats::allocated_since_gc_old_space_offset();
- LoadImmediate(TMP2, class_table->ClassStatsTableAddress(), pp);
- ldr(TMP, Address(TMP2));
- AddImmediate(TMP2, TMP, class_offset, pp);
- ldr(TMP, Address(TMP2, count_field_offset));
+ if (inline_isolate) {
+ LoadImmediate(TMP2, reinterpret_cast<uword>(table_ptr), pp);
+ ldr(TMP, Address(TMP2));
+ } else {
+ LoadIsolate(TMP2);
+ intptr_t table_offset =
+ Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
+ ldr(TMP, Address(TMP2, table_offset));
+ }
+ AddImmediate(TMP2, TMP, counter_offset, pp);
+ ldr(TMP, Address(TMP2, 0));
AddImmediate(TMP, TMP, 1, pp);
- str(TMP, Address(TMP2, count_field_offset));
+ str(TMP, Address(TMP2, 0));
}
}
@@ -1264,21 +1265,20 @@ void Assembler::UpdateAllocationStats(intptr_t cid,
void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
Register size_reg,
Register pp,
- Heap::Space space) {
+ Heap::Space space,
+ bool inline_isolate) {
ASSERT(cid > 0);
- Isolate* isolate = Isolate::Current();
- ClassTable* class_table = isolate->class_table();
- if (cid < kNumPredefinedCids) {
- const uword class_heap_stats_table_address =
- class_table->PredefinedClassHeapStatsTableAddress();
- const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
- const uword count_field_offset = (space == Heap::kNew) ?
- ClassHeapStats::allocated_since_gc_new_space_offset() :
- ClassHeapStats::allocated_since_gc_old_space_offset();
- const uword size_field_offset = (space == Heap::kNew) ?
- ClassHeapStats::allocated_size_since_gc_new_space_offset() :
- ClassHeapStats::allocated_size_since_gc_old_space_offset();
- LoadImmediate(TMP2, class_heap_stats_table_address + class_offset, pp);
+ ClassTable* class_table = Isolate::Current()->class_table();
+ ClassHeapStats** table_ptr = class_table->TableAddressFor(cid);
+ const uword class_offset = ClassTable::ClassOffsetFor(cid);
+ const uword count_field_offset = (space == Heap::kNew) ?
+ ClassHeapStats::allocated_since_gc_new_space_offset() :
+ ClassHeapStats::allocated_since_gc_old_space_offset();
+ const uword size_field_offset = (space == Heap::kNew) ?
+ ClassHeapStats::allocated_size_since_gc_new_space_offset() :
+ ClassHeapStats::allocated_size_since_gc_old_space_offset();
+ if (cid < kNumPredefinedCids && inline_isolate) {
+ LoadImmediate(TMP2, reinterpret_cast<uword>(*table_ptr) + class_offset, pp);
const Address& count_address = Address(TMP2, count_field_offset);
const Address& size_address = Address(TMP2, size_field_offset);
ldr(TMP, count_address);
@@ -1288,15 +1288,15 @@ void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
add(TMP, TMP, Operand(size_reg));
str(TMP, size_address);
} else {
- const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
- const uword count_field_offset = (space == Heap::kNew) ?
- ClassHeapStats::allocated_since_gc_new_space_offset() :
- ClassHeapStats::allocated_since_gc_old_space_offset();
- const uword size_field_offset = (space == Heap::kNew) ?
- ClassHeapStats::allocated_size_since_gc_new_space_offset() :
- ClassHeapStats::allocated_size_since_gc_old_space_offset();
- LoadImmediate(TMP2, class_table->ClassStatsTableAddress(), pp);
- ldr(TMP, Address(TMP2));
+ if (inline_isolate) {
+ LoadImmediate(TMP2, reinterpret_cast<uword>(table_ptr), pp);
+ ldr(TMP, Address(TMP2));
+ } else {
+ LoadIsolate(TMP2);
+ intptr_t table_offset =
+ Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
+ ldr(TMP, Address(TMP2, table_offset));
+ }
AddImmediate(TMP2, TMP, class_offset, pp);
ldr(TMP, Address(TMP2, count_field_offset));
AddImmediate(TMP, TMP, 1, pp);
@@ -1313,21 +1313,20 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
Register pp,
Label* trace) {
ASSERT(cid > 0);
- Isolate* isolate = Isolate::Current();
- ClassTable* class_table = isolate->class_table();
- const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
+ intptr_t state_offset;
+ ClassTable* class_table = Isolate::Current()->class_table();
+ ClassHeapStats** table_ptr =
+ class_table->StateAddressFor(cid, &state_offset);
+
if (cid < kNumPredefinedCids) {
- const uword class_heap_stats_table_address =
- class_table->PredefinedClassHeapStatsTableAddress();
- LoadImmediate(temp_reg, class_heap_stats_table_address + class_offset, pp);
+ LoadImmediate(
+ temp_reg, reinterpret_cast<uword>(*table_ptr) + state_offset, pp);
} else {
- LoadImmediate(temp_reg, class_table->ClassStatsTableAddress(), pp);
+ LoadImmediate(temp_reg, reinterpret_cast<uword>(table_ptr), pp);
ldr(temp_reg, Address(temp_reg, 0));
- AddImmediate(temp_reg, temp_reg, class_offset, pp);
+ AddImmediate(temp_reg, temp_reg, state_offset, pp);
}
- const uword state_offset = ClassHeapStats::state_offset();
- const Address& state_address = Address(temp_reg, state_offset);
- ldr(temp_reg, state_address);
+ ldr(temp_reg, Address(temp_reg, 0));
tsti(temp_reg, Immediate(ClassHeapStats::TraceAllocationMask()));
b(trace, NE);
}

Powered by Google App Engine
This is Rietveld 408576698