Skip to content

Commit

Permalink
[vm/concurrency] Move all information except for the class pointers o…
Browse files Browse the repository at this point in the history
…ut of [ClassTable] into [SharedClassTable]

This CL moves heap related information (namely instance sizes and
allocation stats) out of the [ClassTable] into a [SharedClassTable].
Both classes are always in sync (i.e. they have the same number of entries).

This CL also changes GC related code to start using the size information
from the new [SharedClassTable].

In a futher step we will move the heap as well as this shared class
table out of the [Isolate] and into [IsolateGroup].

Issue dart-lang/sdk#36097

Change-Id: Id54a89c9251ad3bbc13e60d32dc4f7bcc7f1d805
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116064
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
  • Loading branch information
mkustermann authored and commit-bot@chromium.org committed Sep 10, 2019
1 parent 9a2e280 commit ef9d699
Show file tree
Hide file tree
Showing 23 changed files with 621 additions and 354 deletions.
374 changes: 240 additions & 134 deletions runtime/vm/class_table.cc

Large diffs are not rendered by default.

291 changes: 191 additions & 100 deletions runtime/vm/class_table.h

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion runtime/vm/clustered_snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,6 @@ class FullSnapshotWriter {
ReAlloc alloc_;
intptr_t vm_isolate_snapshot_size_;
intptr_t isolate_snapshot_size_;
ForwardList* forward_list_;
ImageWriter* vm_image_writer_;
ImageWriter* isolate_image_writer_;

Expand Down
21 changes: 14 additions & 7 deletions runtime/vm/compiler/assembler/assembler_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1984,12 +1984,13 @@ void Assembler::LoadClassId(Register result, Register object, Condition cond) {

void Assembler::LoadClassById(Register result, Register class_id) {
ASSERT(result != class_id);

const intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::table_offset();

LoadIsolate(result);
const intptr_t offset = target::Isolate::class_table_offset() +
target::ClassTable::table_offset();
LoadFromOffset(kWord, result, result, offset);
ldr(result,
Address(result, class_id, LSL, target::ClassTable::kSizeOfClassPairLog2));
LoadFromOffset(kWord, result, result, table_offset);
ldr(result, Address(result, class_id, LSL, kWordSizeLog2);
}

void Assembler::CompareClassId(Register object,
Expand Down Expand Up @@ -3511,10 +3512,16 @@ void Assembler::LoadAllocationStatsAddress(Register dest, intptr_t cid) {
ASSERT(dest != kNoRegister);
ASSERT(dest != TMP);
ASSERT(cid > 0);

const intptr_t shared_table_offset =
target::Isolate::class_table_offset() +
target::ClassTable::shared_class_table_offset();
const intptr_t table_offset =
target::SharedClassTable::class_heap_stats_table_offset();
const intptr_t class_offset = target::ClassTable::ClassOffsetFor(cid);

LoadIsolate(dest);
intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::class_heap_stats_table_offset();
ldr(dest, Address(dest, shared_table_offset));
ldr(dest, Address(dest, table_offset));
AddImmediate(dest, class_offset);
}
Expand Down
46 changes: 33 additions & 13 deletions runtime/vm/compiler/assembler/assembler_arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1116,12 +1116,12 @@ void Assembler::LoadClassId(Register result, Register object) {

void Assembler::LoadClassById(Register result, Register class_id) {
ASSERT(result != class_id);

const intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::table_offset();

LoadIsolate(result);
const intptr_t offset = target::Isolate::class_table_offset() +
target::ClassTable::table_offset();
LoadFromOffset(result, result, offset);
ASSERT(target::ClassTable::kSizeOfClassPairLog2 == 4);
add(class_id, class_id, Operand(class_id));
LoadFromOffset(result, result, table_offset);
ldr(result, Address(result, class_id, UXTX, Address::Scaled));
}

Expand Down Expand Up @@ -1553,10 +1553,16 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
Register temp_reg,
Label* trace) {
ASSERT(cid > 0);
intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);

const intptr_t shared_table_offset =
target::Isolate::class_table_offset() +
target::ClassTable::shared_class_table_offset();
const intptr_t table_offset =
target::SharedClassTable::class_heap_stats_table_offset();
const intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);

LoadIsolate(temp_reg);
intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::class_heap_stats_table_offset();
ldr(temp_reg, Address(temp_reg, shared_table_offset));
ldr(temp_reg, Address(temp_reg, table_offset));
AddImmediate(temp_reg, state_offset);
ldr(temp_reg, Address(temp_reg, 0));
Expand All @@ -1566,10 +1572,17 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,

void Assembler::UpdateAllocationStats(intptr_t cid) {
ASSERT(cid > 0);
intptr_t counter_offset = target::ClassTable::NewSpaceCounterOffsetFor(cid);

const intptr_t shared_table_offset =
target::Isolate::class_table_offset() +
target::ClassTable::shared_class_table_offset();
const intptr_t table_offset =
target::SharedClassTable::class_heap_stats_table_offset();
const intptr_t counter_offset =
target::ClassTable::NewSpaceCounterOffsetFor(cid);

LoadIsolate(TMP2);
intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::class_heap_stats_table_offset();
ldr(TMP2, Address(TMP2, shared_table_offset));
ldr(TMP, Address(TMP2, table_offset));
AddImmediate(TMP2, TMP, counter_offset);
ldr(TMP, Address(TMP2, 0));
Expand All @@ -1579,14 +1592,21 @@ void Assembler::UpdateAllocationStats(intptr_t cid) {

void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, Register size_reg) {
ASSERT(cid > 0);

const intptr_t shared_table_offset =
target::Isolate::class_table_offset() +
target::ClassTable::shared_class_table_offset();
const intptr_t table_offset =
target::SharedClassTable::class_heap_stats_table_offset();

const uword class_offset = target::ClassTable::ClassOffsetFor(cid);
const uword count_field_offset =
target::ClassHeapStats::allocated_since_gc_new_space_offset();
const uword size_field_offset =
target::ClassHeapStats::allocated_size_since_gc_new_space_offset();

LoadIsolate(TMP2);
intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::class_heap_stats_table_offset();
ldr(TMP2, Address(TMP2, shared_table_offset));
ldr(TMP, Address(TMP2, table_offset));
AddImmediate(TMP2, TMP, class_offset);
ldr(TMP, Address(TMP2, count_field_offset));
Expand Down
34 changes: 23 additions & 11 deletions runtime/vm/compiler/assembler/assembler_ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2362,11 +2362,17 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
bool near_jump) {
ASSERT(cid > 0);
Address state_address(kNoRegister, 0);
intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);

const intptr_t shared_table_offset =
target::Isolate::class_table_offset() +
target::ClassTable::shared_class_table_offset();
const intptr_t table_offset =
target::SharedClassTable::class_heap_stats_table_offset();
const intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);

ASSERT(temp_reg != kNoRegister);
LoadIsolate(temp_reg);
intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::class_heap_stats_table_offset();
movl(temp_reg, Address(temp_reg, shared_table_offset));
movl(temp_reg, Address(temp_reg, table_offset));
state_address = Address(temp_reg, state_offset);
testb(state_address,
Expand All @@ -2378,11 +2384,17 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,

void Assembler::UpdateAllocationStats(intptr_t cid, Register temp_reg) {
ASSERT(cid > 0);
intptr_t counter_offset = target::ClassTable::NewSpaceCounterOffsetFor(cid);
const intptr_t shared_table_offset =
target::Isolate::class_table_offset() +
target::ClassTable::shared_class_table_offset();
const intptr_t table_offset =
target::SharedClassTable::class_heap_stats_table_offset();
const intptr_t counter_offset =
target::ClassTable::NewSpaceCounterOffsetFor(cid);

ASSERT(temp_reg != kNoRegister);
LoadIsolate(temp_reg);
intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::class_heap_stats_table_offset();
movl(temp_reg, Address(temp_reg, shared_table_offset));
movl(temp_reg, Address(temp_reg, table_offset));
incl(Address(temp_reg, counter_offset));
}
Expand Down Expand Up @@ -2617,12 +2629,12 @@ void Assembler::LoadClassId(Register result, Register object) {

void Assembler::LoadClassById(Register result, Register class_id) {
ASSERT(result != class_id);

const intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::table_offset();
LoadIsolate(result);
const intptr_t offset = target::Isolate::class_table_offset() +
target::ClassTable::table_offset();
movl(result, Address(result, offset));
ASSERT(target::ClassTable::kSizeOfClassPairLog2 == 3);
movl(result, Address(result, class_id, TIMES_8, 0));
movl(result, Address(result, table_offset));
movl(result, Address(result, class_id, TIMES_4, 0));
}

void Assembler::CompareClassId(Register object,
Expand Down
34 changes: 21 additions & 13 deletions runtime/vm/compiler/assembler/assembler_x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1851,11 +1851,16 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
Label* trace,
bool near_jump) {
ASSERT(cid > 0);
intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);
const intptr_t shared_table_offset =
target::Isolate::class_table_offset() +
target::ClassTable::shared_class_table_offset();
const intptr_t table_offset =
target::SharedClassTable::class_heap_stats_table_offset();
const intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);

Register temp_reg = TMP;
LoadIsolate(temp_reg);
intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::class_heap_stats_table_offset();
movq(temp_reg, Address(temp_reg, shared_table_offset));
movq(temp_reg, Address(temp_reg, table_offset));
testb(Address(temp_reg, state_offset),
Immediate(target::ClassHeapStats::TraceAllocationMask()));
Expand All @@ -1866,11 +1871,17 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,

void Assembler::UpdateAllocationStats(intptr_t cid) {
ASSERT(cid > 0);
intptr_t counter_offset = target::ClassTable::NewSpaceCounterOffsetFor(cid);
const intptr_t shared_table_offset =
target::Isolate::class_table_offset() +
target::ClassTable::shared_class_table_offset();
const intptr_t table_offset =
target::SharedClassTable::class_heap_stats_table_offset();
const intptr_t counter_offset =
target::ClassTable::NewSpaceCounterOffsetFor(cid);

Register temp_reg = TMP;
LoadIsolate(temp_reg);
intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::class_heap_stats_table_offset();
movq(temp_reg, Address(temp_reg, shared_table_offset));
movq(temp_reg, Address(temp_reg, table_offset));
incq(Address(temp_reg, counter_offset));
}
Expand Down Expand Up @@ -2125,14 +2136,11 @@ void Assembler::LoadClassId(Register result, Register object) {

void Assembler::LoadClassById(Register result, Register class_id) {
ASSERT(result != class_id);
const intptr_t table_offset = target::Isolate::class_table_offset() +
target::ClassTable::table_offset();

LoadIsolate(result);
const intptr_t offset = target::Isolate::class_table_offset() +
target::ClassTable::table_offset();
movq(result, Address(result, offset));
ASSERT(target::ClassTable::kSizeOfClassPairLog2 == 4);
// TIMES_16 is not a real scale factor on x64, so we double the class id
// and use TIMES_8.
addq(class_id, class_id);
movq(result, Address(result, table_offset));
movq(result, Address(result, class_id, TIMES_8, 0));
}

Expand Down
1 change: 0 additions & 1 deletion runtime/vm/compiler/assembler/assembler_x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,6 @@ class Assembler : public AssemblerBase {
// Loading and comparing classes of objects.
void LoadClassId(Register result, Register object);

// Overwrites class_id register (it will be tagged afterwards).
void LoadClassById(Register result, Register class_id);

void CompareClassId(Register object,
Expand Down
9 changes: 8 additions & 1 deletion runtime/vm/compiler/runtime_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,15 +755,22 @@ class Isolate : public AllStatic {
#endif // !defined(PRODUCT)
};

class SharedClassTable : public AllStatic {
public:
static word class_heap_stats_table_offset();
};

class ClassTable : public AllStatic {
public:
static word table_offset();
static word shared_class_table_offset();
#if !defined(PRODUCT)
static word ClassOffsetFor(intptr_t cid);
static word StateOffsetFor(intptr_t cid);
static word class_heap_stats_table_offset();
static word NewSpaceCounterOffsetFor(intptr_t cid);
static word NewSpaceSizeOffsetFor(intptr_t cid);
static word SharedTableOffsetFor();
static word SizeOffsetFor(intptr_t cid, bool is_new);
#endif // !defined(PRODUCT)
static const word kSizeOfClassPairLog2;
};
Expand Down
Loading

0 comments on commit ef9d699

Please sign in to comment.