Skip to content

Commit 81f0959

Browse files
alexmarkovCommit Queue
authored and
Commit Queue
committed
[vm] Fix record instance layout with compressed pointers
After record shape representation changed in https://dart-review.googlesource.com/c/sdk/+/276201, clang started to insert an extra alignment padding between 'shape' and 'data' fields in record instances in compressed pointers mode. This padding is not initialized in the allocation stubs, but GC scans it as it falls between 'from' (shape) and 'to' (end of data). This change adjusts layout of UntaggedRecord in compressed pointers mode to avoid the implicit padding and GC visiting garbage. TEST=Manual run of language/records/simple tests and RecordCollections benchmark on x64c and simarm64c architectures. Issue: #49719 Change-Id: I4b8a5b36c3ff757ccbbdb46c20d9ed8d12c53f96 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276775 Commit-Queue: Alexander Markov <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent ae4ee87 commit 81f0959

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

runtime/vm/compiler/runtime_offsets_extracted.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,7 +2985,7 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
29852985
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
29862986
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
29872987
16;
2988-
static constexpr dart::compiler::target::word Record_shape_offset = 8;
2988+
static constexpr dart::compiler::target::word Record_shape_offset = 12;
29892989
static constexpr dart::compiler::target::word
29902990
SingleTargetCache_entry_point_offset = 16;
29912991
static constexpr dart::compiler::target::word
@@ -3667,7 +3667,7 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
36673667
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
36683668
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
36693669
16;
3670-
static constexpr dart::compiler::target::word Record_shape_offset = 8;
3670+
static constexpr dart::compiler::target::word Record_shape_offset = 12;
36713671
static constexpr dart::compiler::target::word
36723672
SingleTargetCache_entry_point_offset = 16;
36733673
static constexpr dart::compiler::target::word
@@ -8387,7 +8387,7 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
83878387
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
83888388
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
83898389
16;
8390-
static constexpr dart::compiler::target::word Record_shape_offset = 8;
8390+
static constexpr dart::compiler::target::word Record_shape_offset = 12;
83918391
static constexpr dart::compiler::target::word
83928392
SingleTargetCache_entry_point_offset = 16;
83938393
static constexpr dart::compiler::target::word
@@ -9061,7 +9061,7 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
90619061
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
90629062
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
90639063
16;
9064-
static constexpr dart::compiler::target::word Record_shape_offset = 8;
9064+
static constexpr dart::compiler::target::word Record_shape_offset = 12;
90659065
static constexpr dart::compiler::target::word
90669066
SingleTargetCache_entry_point_offset = 16;
90679067
static constexpr dart::compiler::target::word
@@ -13376,7 +13376,7 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
1337613376
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
1337713377
static constexpr dart::compiler::target::word
1337813378
AOT_Pointer_type_arguments_offset = 16;
13379-
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
13379+
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 12;
1338013380
static constexpr dart::compiler::target::word
1338113381
AOT_SingleTargetCache_entry_point_offset = 16;
1338213382
static constexpr dart::compiler::target::word
@@ -14131,7 +14131,7 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
1413114131
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
1413214132
static constexpr dart::compiler::target::word
1413314133
AOT_Pointer_type_arguments_offset = 16;
14134-
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
14134+
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 12;
1413514135
static constexpr dart::compiler::target::word
1413614136
AOT_SingleTargetCache_entry_point_offset = 16;
1413714137
static constexpr dart::compiler::target::word
@@ -18620,7 +18620,7 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
1862018620
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
1862118621
static constexpr dart::compiler::target::word
1862218622
AOT_Pointer_type_arguments_offset = 16;
18623-
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
18623+
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 12;
1862418624
static constexpr dart::compiler::target::word
1862518625
AOT_SingleTargetCache_entry_point_offset = 16;
1862618626
static constexpr dart::compiler::target::word
@@ -19366,7 +19366,7 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
1936619366
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
1936719367
static constexpr dart::compiler::target::word
1936819368
AOT_Pointer_type_arguments_offset = 16;
19369-
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
19369+
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 12;
1937019370
static constexpr dart::compiler::target::word
1937119371
AOT_SingleTargetCache_entry_point_offset = 16;
1937219372
static constexpr dart::compiler::target::word

runtime/vm/raw_object.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3224,6 +3224,13 @@ COMPILE_ASSERT(sizeof(UntaggedFloat64x2) == 24);
32243224
class UntaggedRecord : public UntaggedInstance {
32253225
RAW_HEAP_OBJECT_IMPLEMENTATION(Record);
32263226

3227+
#if defined(DART_COMPRESSED_POINTERS)
3228+
// This explicit padding avoids implict padding between [shape] and [data].
3229+
// Record allocation doesn't initialize the implicit padding but GC scans
3230+
// everything between 'from' (shape) and 'to' (end of data),
3231+
// so it would see garbage if implicit padding is inserted.
3232+
uint32_t padding_;
3233+
#endif
32273234
COMPRESSED_SMI_FIELD(SmiPtr, shape)
32283235
VISIT_FROM(shape)
32293236
// Variable length data follows here.

0 commit comments

Comments
 (0)