Skip to content

Commit 52dc797

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm] Fix truncation of slot offsets during heap snapshots.
Truncation caused sorting to place the field at offset 2^16 before the field at offset 8, etc. TEST=iso-stress Bug: #60717 Change-Id: Ie75c9fa74b830bc08b386533b16e8b01127b0f26 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428565 Commit-Queue: Alexander Aprelev <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent 1f4707a commit 52dc797

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

runtime/vm/object_graph.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ static bool IsUserClass(intptr_t cid) {
3232
// This may be a regulard dart field, a unboxed dart field or
3333
// a slot of any type in a predefined layout.
3434
struct ObjectSlot {
35-
uint16_t offset;
35+
uint32_t offset;
3636
bool is_compressed_pointer;
3737
const char* name;
38-
ObjectSlot(uint16_t offset, bool is_compressed_pointer, const char* name)
38+
ObjectSlot(uint32_t offset, bool is_compressed_pointer, const char* name)
3939
: offset(offset),
4040
is_compressed_pointer(is_compressed_pointer),
4141
name(name) {}
@@ -113,7 +113,9 @@ class ObjectSlots {
113113

114114
// We sort the slots, so we'll visit the slots in memory order.
115115
slots->Sort([](const ObjectSlot* a, const ObjectSlot* b) {
116-
return a->offset - b->offset;
116+
if (a->offset < b->offset) return -1;
117+
if (a->offset > b->offset) return 1;
118+
return 0;
117119
});
118120

119121
// As optimization as well as to support variable-length data, we remember

0 commit comments

Comments
 (0)