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

Unified Diff: runtime/vm/assembler_mips.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_mips.cc
diff --git a/runtime/vm/assembler_mips.cc b/runtime/vm/assembler_mips.cc
index da5a6dfef9413be67945bc219096ac4040ce0721..dad8b02e5e843affccceeacaac0782549be54f56 100644
--- a/runtime/vm/assembler_mips.cc
+++ b/runtime/vm/assembler_mips.cc
@@ -806,37 +806,37 @@ void Assembler::LeaveStubFrameAndReturn(Register ra) {
void Assembler::UpdateAllocationStats(intptr_t cid,
Register temp_reg,
- Heap::Space space) {
+ Heap::Space space,
+ bool inline_isolate) {
ASSERT(!in_delay_slot_);
ASSERT(temp_reg != kNoRegister);
ASSERT(temp_reg != TMP);
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(temp_reg, class_heap_stats_table_address + class_offset);
- const Address& count_address = Address(temp_reg, count_field_offset);
- lw(TMP, count_address);
+ intptr_t counter_offset;
+ ClassTable* class_table = Isolate::Current()->class_table();
+ ClassHeapStats** table_ptr = class_table->CountAddressFor(
+ cid, space == Heap::kNew, &counter_offset);
+ if (cid < kNumPredefinedCids && inline_isolate) {
+ LoadImmediate(
+ temp_reg, reinterpret_cast<uword>(*table_ptr) + counter_offset);
+ lw(TMP, Address(temp_reg, 0));
AddImmediate(TMP, 1);
- sw(TMP, count_address);
+ sw(TMP, Address(temp_reg, 0));
} else {
ASSERT(temp_reg != kNoRegister);
- 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(temp_reg, class_table->ClassStatsTableAddress());
- lw(temp_reg, Address(temp_reg, 0));
- AddImmediate(temp_reg, class_offset);
- lw(TMP, Address(temp_reg, count_field_offset));
+ if (inline_isolate) {
+ LoadImmediate(temp_reg, reinterpret_cast<uword>(table_ptr));
+ lw(temp_reg, Address(temp_reg, 0));
+ } else {
+ LoadIsolate(temp_reg);
+ intptr_t table_offset =
+ Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
+ lw(temp_reg, Address(temp_reg, table_offset));
+ }
+ AddImmediate(temp_reg, counter_offset);
+ lw(TMP, Address(temp_reg, 0));
AddImmediate(TMP, 1);
- sw(TMP, Address(temp_reg, count_field_offset));
+ sw(TMP, Address(temp_reg, 0));
}
}
@@ -844,24 +844,23 @@ void Assembler::UpdateAllocationStats(intptr_t cid,
void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
Register size_reg,
Register temp_reg,
- Heap::Space space) {
+ Heap::Space space,
+ bool inline_isolate) {
ASSERT(!in_delay_slot_);
ASSERT(temp_reg != kNoRegister);
ASSERT(cid > 0);
ASSERT(temp_reg != TMP);
- 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(temp_reg, class_heap_stats_table_address + class_offset);
+ 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(temp_reg, reinterpret_cast<uword>(*table_ptr) + class_offset);
const Address& count_address = Address(temp_reg, count_field_offset);
const Address& size_address = Address(temp_reg, size_field_offset);
lw(TMP, count_address);
@@ -872,15 +871,15 @@ void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
sw(TMP, size_address);
} else {
ASSERT(temp_reg != kNoRegister);
- 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(temp_reg, class_table->ClassStatsTableAddress());
- lw(temp_reg, Address(temp_reg, 0));
+ if (inline_isolate) {
+ LoadImmediate(temp_reg, reinterpret_cast<uword>(table_ptr));
+ lw(temp_reg, Address(temp_reg, 0));
+ } else {
+ LoadIsolate(temp_reg);
+ intptr_t table_offset =
+ Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
+ lw(temp_reg, Address(temp_reg, table_offset));
+ }
AddImmediate(temp_reg, class_offset);
lw(TMP, Address(temp_reg, count_field_offset));
AddImmediate(TMP, 1);
@@ -899,21 +898,18 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
ASSERT(!in_delay_slot_);
ASSERT(temp_reg != kNoRegister);
ASSERT(temp_reg != TMP);
- 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);
+ LoadImmediate(temp_reg, reinterpret_cast<uword>(*table_ptr) + state_offset);
} else {
- LoadImmediate(temp_reg, class_table->ClassStatsTableAddress());
+ LoadImmediate(temp_reg, reinterpret_cast<uword>(table_ptr));
lw(temp_reg, Address(temp_reg, 0));
- AddImmediate(temp_reg, class_offset);
+ AddImmediate(temp_reg, state_offset);
}
- const uword state_offset = ClassHeapStats::state_offset();
- const Address& state_address = Address(temp_reg, state_offset);
- lw(temp_reg, state_address);
+ lw(temp_reg, Address(temp_reg, 0));
andi(CMPRES1, temp_reg, Immediate(ClassHeapStats::TraceAllocationMask()));
bne(CMPRES1, ZR, trace);
}

Powered by Google App Engine
This is Rietveld 408576698