| Index: runtime/vm/assembler_ia32.cc
|
| diff --git a/runtime/vm/assembler_ia32.cc b/runtime/vm/assembler_ia32.cc
|
| index 1059706469aa4b804a569904c0dadda868406682..ad27ed34304c7b321ff3bd8a9d2deea8fe36c55c 100644
|
| --- a/runtime/vm/assembler_ia32.cc
|
| +++ b/runtime/vm/assembler_ia32.cc
|
| @@ -2660,60 +2660,25 @@ void Assembler::Bind(Label* label) {
|
| }
|
|
|
|
|
| -static void ComputeCounterAddressesForCid(intptr_t cid,
|
| - Heap::Space space,
|
| - Address* count_address,
|
| - Address* size_address) {
|
| - ASSERT(cid < kNumPredefinedCids);
|
| - Isolate* isolate = Isolate::Current();
|
| - ClassTable* class_table = isolate->class_table();
|
| - 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();
|
| - *count_address = Address::Absolute(
|
| - class_heap_stats_table_address + class_offset + count_field_offset);
|
| - *size_address = Address::Absolute(
|
| - class_heap_stats_table_address + class_offset + size_field_offset);
|
| -}
|
| -
|
| -
|
| -static void ComputeHeapStatsStateAddressForCid(intptr_t cid,
|
| - Address* state_address) {
|
| - ASSERT(cid < kNumPredefinedCids);
|
| - Isolate* isolate = Isolate::Current();
|
| - ClassTable* class_table = isolate->class_table();
|
| - const uword class_heap_stats_table_address =
|
| - class_table->PredefinedClassHeapStatsTableAddress();
|
| - const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
|
| - const uword state_offset = ClassHeapStats::state_offset();
|
| - *state_address = Address::Absolute(class_heap_stats_table_address +
|
| - class_offset +
|
| - state_offset);
|
| -}
|
| -
|
| -
|
| void Assembler::MaybeTraceAllocation(intptr_t cid,
|
| Register temp_reg,
|
| Label* trace,
|
| bool near_jump) {
|
| ASSERT(cid > 0);
|
| Address state_address(kNoRegister, 0);
|
| + intptr_t state_offset;
|
| + ClassTable* class_table = Isolate::Current()->class_table();
|
| + ClassHeapStats** table_ptr =
|
| + class_table->StateAddressFor(cid, &state_offset);
|
| if (cid < kNumPredefinedCids) {
|
| - ComputeHeapStatsStateAddressForCid(cid, &state_address);
|
| + state_address = Address::Absolute(
|
| + reinterpret_cast<uword>(*table_ptr) + state_offset);
|
| } else {
|
| ASSERT(temp_reg != kNoRegister);
|
| - const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
|
| - const uword state_offset = ClassHeapStats::state_offset();
|
| // temp_reg gets address of class table pointer.
|
| - ClassTable* class_table = Isolate::Current()->class_table();
|
| - movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress()));
|
| - state_address = Address(temp_reg, class_offset + state_offset);
|
| + movl(temp_reg,
|
| + Address::Absolute(reinterpret_cast<uword>(table_ptr)));
|
| + state_address = Address(temp_reg, state_offset);
|
| }
|
| testb(state_address, Immediate(ClassHeapStats::TraceAllocationMask()));
|
| // We are tracing for this class, jump to the trace label which will use
|
| @@ -2722,52 +2687,70 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
|
| }
|
|
|
|
|
| -void Assembler::UpdateAllocationStats(intptr_t cid,
|
| - Register temp_reg,
|
| - Heap::Space space) {
|
| +ClassHeapStats** Assembler::UpdateAllocationStats(intptr_t cid,
|
| + Register temp_reg,
|
| + Heap::Space space,
|
| + bool inline_isolate) {
|
| ASSERT(cid > 0);
|
| - if (cid < kNumPredefinedCids) {
|
| - Address count_address(kNoRegister, 0), size_address(kNoRegister, 0);
|
| - ComputeCounterAddressesForCid(cid, space, &count_address, &size_address);
|
| - incl(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) {
|
| + incl(Address::Absolute(
|
| + reinterpret_cast<uword>(*table_ptr) + counter_offset));
|
| } 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();
|
| - // temp_reg gets address of class table pointer.
|
| - ClassTable* class_table = Isolate::Current()->class_table();
|
| - movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress()));
|
| - // Increment allocation count.
|
| - incl(Address(temp_reg, class_offset + count_field_offset));
|
| + if (inline_isolate) {
|
| + movl(temp_reg,
|
| + Address::Absolute(reinterpret_cast<uword>(table_ptr)));
|
| + } else {
|
| + LoadIsolate(temp_reg);
|
| + intptr_t table_offset =
|
| + Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
|
| + movl(temp_reg, Address(temp_reg, table_offset));
|
| + }
|
| + incl(Address(temp_reg, counter_offset));
|
| }
|
| + return table_ptr;
|
| }
|
|
|
|
|
| void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
|
| Register size_reg,
|
| Register temp_reg,
|
| - Heap::Space space) {
|
| + Heap::Space space,
|
| + bool inline_isolate) {
|
| ASSERT(cid > 0);
|
| ASSERT(cid < kNumPredefinedCids);
|
| - Address count_address(kNoRegister, 0), size_address(kNoRegister, 0);
|
| - ComputeCounterAddressesForCid(cid, space, &count_address, &size_address);
|
| - incl(count_address);
|
| - addl(size_address, size_reg);
|
| + ClassHeapStats** table_ptr =
|
| + UpdateAllocationStats(cid, temp_reg, space, inline_isolate);
|
| + intptr_t size_offset = ClassTable::SizeOffsetFor(cid, space == Heap::kNew);
|
| + if (inline_isolate) {
|
| + addl(Address::Absolute(
|
| + reinterpret_cast<uword>(*table_ptr) + size_offset), size_reg);
|
| + } else {
|
| + addl(Address(temp_reg, size_offset), size_reg);
|
| + }
|
| }
|
|
|
|
|
| void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
|
| intptr_t size_in_bytes,
|
| Register temp_reg,
|
| - Heap::Space space) {
|
| + Heap::Space space,
|
| + bool inline_isolate) {
|
| ASSERT(cid > 0);
|
| ASSERT(cid < kNumPredefinedCids);
|
| - Address count_address(kNoRegister, 0), size_address(kNoRegister, 0);
|
| - ComputeCounterAddressesForCid(cid, space, &count_address, &size_address);
|
| - incl(count_address);
|
| - addl(size_address, Immediate(size_in_bytes));
|
| + ClassHeapStats** table_ptr =
|
| + UpdateAllocationStats(cid, temp_reg, space, inline_isolate);
|
| + intptr_t size_offset = ClassTable::SizeOffsetFor(cid, space == Heap::kNew);
|
| + if (inline_isolate) {
|
| + addl(Address::Absolute(reinterpret_cast<uword>(*table_ptr) + size_offset),
|
| + Immediate(size_in_bytes));
|
| + } else {
|
| + addl(Address(temp_reg, size_offset), Immediate(size_in_bytes));
|
| + }
|
| }
|
|
|
|
|
|
|