@@ -25,26 +25,27 @@ void DumpFunctionJSON(Dart_SnapshotAnalyzerInformation* info,
25
25
26
26
const auto isolate_instructions_base =
27
27
reinterpret_cast <uint64_t >(info->vm_isolate_instructions );
28
- const auto vm_instructions_base =
29
- reinterpret_cast <uint64_t >(info->vm_snapshot_instructions );
30
28
uint64_t relative_offset;
29
+ uint64_t size;
31
30
const char * section;
32
31
33
32
js->OpenObject ();
34
33
js->PrintProperty (" name" , function.ToCString ());
35
34
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 ;
40
40
section = " _kDartVmSnapshotInstructions" ;
41
41
} else {
42
42
relative_offset = code_addr - isolate_instructions_base;
43
+ size = static_cast <uint64_t >(code.Size ());
43
44
section = " _kDartIsolateSnapshotInstructions" ;
44
45
}
45
- js->PrintProperty (" offset" , static_cast <intptr_t >(relative_offset));
46
46
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);
48
49
js->CloseObject ();
49
50
}
50
51
void DumpClassTableJSON (Thread* thread,
@@ -256,31 +257,24 @@ void DumpFunctionPP(Dart_SnapshotAnalyzerInformation* info,
256
257
257
258
const auto isolate_instructions_base =
258
259
reinterpret_cast <uint64_t >(info->vm_isolate_instructions );
259
- const auto vm_instructions_base =
260
- reinterpret_cast <uint64_t >(info->vm_snapshot_instructions );
261
260
uint64_t relative_offset;
262
261
const char * section;
263
262
264
263
ss << " \t " << function.ToCString () << " " << signature.ToCString ()
265
264
<< " {\n\n " ;
266
265
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 ) {
271
269
section = " _kDartVmSnapshotInstructions" ;
270
+ snprintf (offset_buff, sizeof (offset_buff), " Offset: <Could not read>" );
272
271
} else {
273
272
relative_offset = code_addr - isolate_instructions_base;
274
273
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 {
281
274
snprintf (offset_buff, sizeof (offset_buff), " Offset: %s + 0x%" PRIx64 " " ,
282
275
section, relative_offset);
283
276
}
277
+
284
278
ss << " \t\t " << offset_buff << " \n\n\t }\n " ;
285
279
}
286
280
// TODO(#47924): Refactor and reduce code duplication.
0 commit comments