Skip to content

Commit 5421297

Browse files
perksCommit Queue
authored and
Commit Queue
committed
Change relative_offset and size to 0 when PayloadStart() is 0
TEST=ci Change-Id: Ie379dba90398000635c13d89576cc1bfd67d5e7d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283322 Reviewed-by: Slava Egorov <[email protected]> Commit-Queue: Chris Evans <[email protected]>
1 parent e3661b7 commit 5421297

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

runtime/vm/analyze_snapshot_api_impl.cc

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,27 @@ void DumpFunctionJSON(Dart_SnapshotAnalyzerInformation* info,
2525

2626
const auto isolate_instructions_base =
2727
reinterpret_cast<uint64_t>(info->vm_isolate_instructions);
28-
const auto vm_instructions_base =
29-
reinterpret_cast<uint64_t>(info->vm_snapshot_instructions);
3028
uint64_t relative_offset;
29+
uint64_t size;
3130
const char* section;
3231

3332
js->OpenObject();
3433
js->PrintProperty("name", function.ToCString());
3534
js->PrintProperty("signature", signature.ToCString());
36-
// Should not have code that is located in
37-
// _kDartVmSnapshotInstructions, but check in case.
38-
if (code_addr < isolate_instructions_base) {
39-
relative_offset = code_addr - vm_instructions_base;
35+
// Invoking code.PayloadStart() for _kDartVmSnapshotInstructions
36+
// when the tree has been shaken always returns 0
37+
if (code_addr == 0) {
38+
relative_offset = 0;
39+
size = 0;
4040
section = "_kDartVmSnapshotInstructions";
4141
} else {
4242
relative_offset = code_addr - isolate_instructions_base;
43+
size = static_cast<uint64_t>(code.Size());
4344
section = "_kDartIsolateSnapshotInstructions";
4445
}
45-
js->PrintProperty("offset", static_cast<intptr_t>(relative_offset));
4646
js->PrintProperty("section", section);
47-
js->PrintProperty("size", static_cast<intptr_t>(code.Size()));
47+
js->PrintProperty64("offset", relative_offset);
48+
js->PrintProperty64("size", size);
4849
js->CloseObject();
4950
}
5051
void DumpClassTableJSON(Thread* thread,
@@ -256,31 +257,24 @@ void DumpFunctionPP(Dart_SnapshotAnalyzerInformation* info,
256257

257258
const auto isolate_instructions_base =
258259
reinterpret_cast<uint64_t>(info->vm_isolate_instructions);
259-
const auto vm_instructions_base =
260-
reinterpret_cast<uint64_t>(info->vm_snapshot_instructions);
261260
uint64_t relative_offset;
262261
const char* section;
263262

264263
ss << "\t" << function.ToCString() << " " << signature.ToCString()
265264
<< " {\n\n";
266265
char offset_buff[100] = "";
267-
// Should not have code that is located in
268-
// _kDartVmSnapshotInstructions, but check in case.
269-
if (code_addr < isolate_instructions_base) {
270-
relative_offset = code_addr - vm_instructions_base;
266+
// Invoking code.PayloadStart() for _kDartVmSnapshotInstructions
267+
// when the tree has been shaken always returns 0
268+
if (code_addr == 0) {
271269
section = "_kDartVmSnapshotInstructions";
270+
snprintf(offset_buff, sizeof(offset_buff), "Offset: <Could not read>");
272271
} else {
273272
relative_offset = code_addr - isolate_instructions_base;
274273
section = "_kDartIsolateSnapshotInstructions";
275-
}
276-
277-
// Can not calculate for function without payload start
278-
if (code_addr == 0) {
279-
snprintf(offset_buff, sizeof(offset_buff), "Offset: <Could not read>");
280-
} else {
281274
snprintf(offset_buff, sizeof(offset_buff), "Offset: %s + 0x%" PRIx64 "",
282275
section, relative_offset);
283276
}
277+
284278
ss << "\t\t" << offset_buff << "\n\n\t}\n";
285279
}
286280
// TODO(#47924): Refactor and reduce code duplication.

0 commit comments

Comments
 (0)