Skip to content

Commit ef9d699

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[vm/concurrency] Move all information except for the class pointers out 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 #36097 Change-Id: Id54a89c9251ad3bbc13e60d32dc4f7bcc7f1d805 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116064 Commit-Queue: Martin Kustermann <[email protected]> Reviewed-by: Ryan Macnak <[email protected]>
1 parent 9a2e280 commit ef9d699

23 files changed

+621
-354
lines changed

Diff for: runtime/vm/class_table.cc

+240-134
Large diffs are not rendered by default.

Diff for: runtime/vm/class_table.h

+191-100
Large diffs are not rendered by default.

Diff for: runtime/vm/clustered_snapshot.h

-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,6 @@ class FullSnapshotWriter {
635635
ReAlloc alloc_;
636636
intptr_t vm_isolate_snapshot_size_;
637637
intptr_t isolate_snapshot_size_;
638-
ForwardList* forward_list_;
639638
ImageWriter* vm_image_writer_;
640639
ImageWriter* isolate_image_writer_;
641640

Diff for: runtime/vm/compiler/assembler/assembler_arm.cc

+14-7
Original file line numberDiff line numberDiff line change
@@ -1984,12 +1984,13 @@ void Assembler::LoadClassId(Register result, Register object, Condition cond) {
19841984

19851985
void Assembler::LoadClassById(Register result, Register class_id) {
19861986
ASSERT(result != class_id);
1987+
1988+
const intptr_t table_offset = target::Isolate::class_table_offset() +
1989+
target::ClassTable::table_offset();
1990+
19871991
LoadIsolate(result);
1988-
const intptr_t offset = target::Isolate::class_table_offset() +
1989-
target::ClassTable::table_offset();
1990-
LoadFromOffset(kWord, result, result, offset);
1991-
ldr(result,
1992-
Address(result, class_id, LSL, target::ClassTable::kSizeOfClassPairLog2));
1992+
LoadFromOffset(kWord, result, result, table_offset);
1993+
ldr(result, Address(result, class_id, LSL, kWordSizeLog2);
19931994
}
19941995

19951996
void Assembler::CompareClassId(Register object,
@@ -3511,10 +3512,16 @@ void Assembler::LoadAllocationStatsAddress(Register dest, intptr_t cid) {
35113512
ASSERT(dest != kNoRegister);
35123513
ASSERT(dest != TMP);
35133514
ASSERT(cid > 0);
3515+
3516+
const intptr_t shared_table_offset =
3517+
target::Isolate::class_table_offset() +
3518+
target::ClassTable::shared_class_table_offset();
3519+
const intptr_t table_offset =
3520+
target::SharedClassTable::class_heap_stats_table_offset();
35143521
const intptr_t class_offset = target::ClassTable::ClassOffsetFor(cid);
3522+
35153523
LoadIsolate(dest);
3516-
intptr_t table_offset = target::Isolate::class_table_offset() +
3517-
target::ClassTable::class_heap_stats_table_offset();
3524+
ldr(dest, Address(dest, shared_table_offset));
35183525
ldr(dest, Address(dest, table_offset));
35193526
AddImmediate(dest, class_offset);
35203527
}

Diff for: runtime/vm/compiler/assembler/assembler_arm64.cc

+33-13
Original file line numberDiff line numberDiff line change
@@ -1116,12 +1116,12 @@ void Assembler::LoadClassId(Register result, Register object) {
11161116

11171117
void Assembler::LoadClassById(Register result, Register class_id) {
11181118
ASSERT(result != class_id);
1119+
1120+
const intptr_t table_offset = target::Isolate::class_table_offset() +
1121+
target::ClassTable::table_offset();
1122+
11191123
LoadIsolate(result);
1120-
const intptr_t offset = target::Isolate::class_table_offset() +
1121-
target::ClassTable::table_offset();
1122-
LoadFromOffset(result, result, offset);
1123-
ASSERT(target::ClassTable::kSizeOfClassPairLog2 == 4);
1124-
add(class_id, class_id, Operand(class_id));
1124+
LoadFromOffset(result, result, table_offset);
11251125
ldr(result, Address(result, class_id, UXTX, Address::Scaled));
11261126
}
11271127

@@ -1553,10 +1553,16 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
15531553
Register temp_reg,
15541554
Label* trace) {
15551555
ASSERT(cid > 0);
1556-
intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);
1556+
1557+
const intptr_t shared_table_offset =
1558+
target::Isolate::class_table_offset() +
1559+
target::ClassTable::shared_class_table_offset();
1560+
const intptr_t table_offset =
1561+
target::SharedClassTable::class_heap_stats_table_offset();
1562+
const intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);
1563+
15571564
LoadIsolate(temp_reg);
1558-
intptr_t table_offset = target::Isolate::class_table_offset() +
1559-
target::ClassTable::class_heap_stats_table_offset();
1565+
ldr(temp_reg, Address(temp_reg, shared_table_offset));
15601566
ldr(temp_reg, Address(temp_reg, table_offset));
15611567
AddImmediate(temp_reg, state_offset);
15621568
ldr(temp_reg, Address(temp_reg, 0));
@@ -1566,10 +1572,17 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
15661572

15671573
void Assembler::UpdateAllocationStats(intptr_t cid) {
15681574
ASSERT(cid > 0);
1569-
intptr_t counter_offset = target::ClassTable::NewSpaceCounterOffsetFor(cid);
1575+
1576+
const intptr_t shared_table_offset =
1577+
target::Isolate::class_table_offset() +
1578+
target::ClassTable::shared_class_table_offset();
1579+
const intptr_t table_offset =
1580+
target::SharedClassTable::class_heap_stats_table_offset();
1581+
const intptr_t counter_offset =
1582+
target::ClassTable::NewSpaceCounterOffsetFor(cid);
1583+
15701584
LoadIsolate(TMP2);
1571-
intptr_t table_offset = target::Isolate::class_table_offset() +
1572-
target::ClassTable::class_heap_stats_table_offset();
1585+
ldr(TMP2, Address(TMP2, shared_table_offset));
15731586
ldr(TMP, Address(TMP2, table_offset));
15741587
AddImmediate(TMP2, TMP, counter_offset);
15751588
ldr(TMP, Address(TMP2, 0));
@@ -1579,14 +1592,21 @@ void Assembler::UpdateAllocationStats(intptr_t cid) {
15791592

15801593
void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, Register size_reg) {
15811594
ASSERT(cid > 0);
1595+
1596+
const intptr_t shared_table_offset =
1597+
target::Isolate::class_table_offset() +
1598+
target::ClassTable::shared_class_table_offset();
1599+
const intptr_t table_offset =
1600+
target::SharedClassTable::class_heap_stats_table_offset();
1601+
15821602
const uword class_offset = target::ClassTable::ClassOffsetFor(cid);
15831603
const uword count_field_offset =
15841604
target::ClassHeapStats::allocated_since_gc_new_space_offset();
15851605
const uword size_field_offset =
15861606
target::ClassHeapStats::allocated_size_since_gc_new_space_offset();
1607+
15871608
LoadIsolate(TMP2);
1588-
intptr_t table_offset = target::Isolate::class_table_offset() +
1589-
target::ClassTable::class_heap_stats_table_offset();
1609+
ldr(TMP2, Address(TMP2, shared_table_offset));
15901610
ldr(TMP, Address(TMP2, table_offset));
15911611
AddImmediate(TMP2, TMP, class_offset);
15921612
ldr(TMP, Address(TMP2, count_field_offset));

Diff for: runtime/vm/compiler/assembler/assembler_ia32.cc

+23-11
Original file line numberDiff line numberDiff line change
@@ -2362,11 +2362,17 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
23622362
bool near_jump) {
23632363
ASSERT(cid > 0);
23642364
Address state_address(kNoRegister, 0);
2365-
intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);
2365+
2366+
const intptr_t shared_table_offset =
2367+
target::Isolate::class_table_offset() +
2368+
target::ClassTable::shared_class_table_offset();
2369+
const intptr_t table_offset =
2370+
target::SharedClassTable::class_heap_stats_table_offset();
2371+
const intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);
2372+
23662373
ASSERT(temp_reg != kNoRegister);
23672374
LoadIsolate(temp_reg);
2368-
intptr_t table_offset = target::Isolate::class_table_offset() +
2369-
target::ClassTable::class_heap_stats_table_offset();
2375+
movl(temp_reg, Address(temp_reg, shared_table_offset));
23702376
movl(temp_reg, Address(temp_reg, table_offset));
23712377
state_address = Address(temp_reg, state_offset);
23722378
testb(state_address,
@@ -2378,11 +2384,17 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
23782384

23792385
void Assembler::UpdateAllocationStats(intptr_t cid, Register temp_reg) {
23802386
ASSERT(cid > 0);
2381-
intptr_t counter_offset = target::ClassTable::NewSpaceCounterOffsetFor(cid);
2387+
const intptr_t shared_table_offset =
2388+
target::Isolate::class_table_offset() +
2389+
target::ClassTable::shared_class_table_offset();
2390+
const intptr_t table_offset =
2391+
target::SharedClassTable::class_heap_stats_table_offset();
2392+
const intptr_t counter_offset =
2393+
target::ClassTable::NewSpaceCounterOffsetFor(cid);
2394+
23822395
ASSERT(temp_reg != kNoRegister);
23832396
LoadIsolate(temp_reg);
2384-
intptr_t table_offset = target::Isolate::class_table_offset() +
2385-
target::ClassTable::class_heap_stats_table_offset();
2397+
movl(temp_reg, Address(temp_reg, shared_table_offset));
23862398
movl(temp_reg, Address(temp_reg, table_offset));
23872399
incl(Address(temp_reg, counter_offset));
23882400
}
@@ -2617,12 +2629,12 @@ void Assembler::LoadClassId(Register result, Register object) {
26172629

26182630
void Assembler::LoadClassById(Register result, Register class_id) {
26192631
ASSERT(result != class_id);
2632+
2633+
const intptr_t table_offset = target::Isolate::class_table_offset() +
2634+
target::ClassTable::table_offset();
26202635
LoadIsolate(result);
2621-
const intptr_t offset = target::Isolate::class_table_offset() +
2622-
target::ClassTable::table_offset();
2623-
movl(result, Address(result, offset));
2624-
ASSERT(target::ClassTable::kSizeOfClassPairLog2 == 3);
2625-
movl(result, Address(result, class_id, TIMES_8, 0));
2636+
movl(result, Address(result, table_offset));
2637+
movl(result, Address(result, class_id, TIMES_4, 0));
26262638
}
26272639

26282640
void Assembler::CompareClassId(Register object,

Diff for: runtime/vm/compiler/assembler/assembler_x64.cc

+21-13
Original file line numberDiff line numberDiff line change
@@ -1851,11 +1851,16 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
18511851
Label* trace,
18521852
bool near_jump) {
18531853
ASSERT(cid > 0);
1854-
intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);
1854+
const intptr_t shared_table_offset =
1855+
target::Isolate::class_table_offset() +
1856+
target::ClassTable::shared_class_table_offset();
1857+
const intptr_t table_offset =
1858+
target::SharedClassTable::class_heap_stats_table_offset();
1859+
const intptr_t state_offset = target::ClassTable::StateOffsetFor(cid);
1860+
18551861
Register temp_reg = TMP;
18561862
LoadIsolate(temp_reg);
1857-
intptr_t table_offset = target::Isolate::class_table_offset() +
1858-
target::ClassTable::class_heap_stats_table_offset();
1863+
movq(temp_reg, Address(temp_reg, shared_table_offset));
18591864
movq(temp_reg, Address(temp_reg, table_offset));
18601865
testb(Address(temp_reg, state_offset),
18611866
Immediate(target::ClassHeapStats::TraceAllocationMask()));
@@ -1866,11 +1871,17 @@ void Assembler::MaybeTraceAllocation(intptr_t cid,
18661871

18671872
void Assembler::UpdateAllocationStats(intptr_t cid) {
18681873
ASSERT(cid > 0);
1869-
intptr_t counter_offset = target::ClassTable::NewSpaceCounterOffsetFor(cid);
1874+
const intptr_t shared_table_offset =
1875+
target::Isolate::class_table_offset() +
1876+
target::ClassTable::shared_class_table_offset();
1877+
const intptr_t table_offset =
1878+
target::SharedClassTable::class_heap_stats_table_offset();
1879+
const intptr_t counter_offset =
1880+
target::ClassTable::NewSpaceCounterOffsetFor(cid);
1881+
18701882
Register temp_reg = TMP;
18711883
LoadIsolate(temp_reg);
1872-
intptr_t table_offset = target::Isolate::class_table_offset() +
1873-
target::ClassTable::class_heap_stats_table_offset();
1884+
movq(temp_reg, Address(temp_reg, shared_table_offset));
18741885
movq(temp_reg, Address(temp_reg, table_offset));
18751886
incq(Address(temp_reg, counter_offset));
18761887
}
@@ -2125,14 +2136,11 @@ void Assembler::LoadClassId(Register result, Register object) {
21252136

21262137
void Assembler::LoadClassById(Register result, Register class_id) {
21272138
ASSERT(result != class_id);
2139+
const intptr_t table_offset = target::Isolate::class_table_offset() +
2140+
target::ClassTable::table_offset();
2141+
21282142
LoadIsolate(result);
2129-
const intptr_t offset = target::Isolate::class_table_offset() +
2130-
target::ClassTable::table_offset();
2131-
movq(result, Address(result, offset));
2132-
ASSERT(target::ClassTable::kSizeOfClassPairLog2 == 4);
2133-
// TIMES_16 is not a real scale factor on x64, so we double the class id
2134-
// and use TIMES_8.
2135-
addq(class_id, class_id);
2143+
movq(result, Address(result, table_offset));
21362144
movq(result, Address(result, class_id, TIMES_8, 0));
21372145
}
21382146

Diff for: runtime/vm/compiler/assembler/assembler_x64.h

-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ class Assembler : public AssemblerBase {
804804
// Loading and comparing classes of objects.
805805
void LoadClassId(Register result, Register object);
806806

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

810809
void CompareClassId(Register object,

Diff for: runtime/vm/compiler/runtime_api.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -755,15 +755,22 @@ class Isolate : public AllStatic {
755755
#endif // !defined(PRODUCT)
756756
};
757757

758+
class SharedClassTable : public AllStatic {
759+
public:
760+
static word class_heap_stats_table_offset();
761+
};
762+
758763
class ClassTable : public AllStatic {
759764
public:
760765
static word table_offset();
766+
static word shared_class_table_offset();
761767
#if !defined(PRODUCT)
762768
static word ClassOffsetFor(intptr_t cid);
763769
static word StateOffsetFor(intptr_t cid);
764-
static word class_heap_stats_table_offset();
765770
static word NewSpaceCounterOffsetFor(intptr_t cid);
766771
static word NewSpaceSizeOffsetFor(intptr_t cid);
772+
static word SharedTableOffsetFor();
773+
static word SizeOffsetFor(intptr_t cid, bool is_new);
767774
#endif // !defined(PRODUCT)
768775
static const word kSizeOfClassPairLog2;
769776
};

0 commit comments

Comments
 (0)