Skip to content

Commit c981f7f

Browse files
committed
src: guess Symbol.name offset
PR-URL: #330 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent b30cf41 commit c981f7f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/llv8-constants.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,24 @@ void Frame::Load() {
550550

551551

552552
void Symbol::Load() {
553-
kNameOffset = LoadConstant({"class_Symbol__name__Object"});
553+
// map is the last field of HeapObject
554+
Constant<int64_t> maybe_name_offset =
555+
LoadConstant({"class_HeapObject__map__Map"});
556+
common_->Load();
557+
if (maybe_name_offset.Check()) {
558+
int name_offset = *maybe_name_offset;
559+
560+
name_offset += common_->kPointerSize;
561+
// class Name extends HeapObject and has only one uint32 field
562+
name_offset += sizeof(uint32_t);
563+
// class Symbol extends Name and has one int32 field before name
564+
name_offset += sizeof(int32_t);
565+
566+
kNameOffset =
567+
LoadOptionalConstant({"class_Symbol__name__Object"}, name_offset);
568+
} else {
569+
kNameOffset = LoadConstant({"class_Symbol__name__Object"});
570+
}
554571
}
555572

556573

0 commit comments

Comments
 (0)