591b2bd724
This option dumps offsets of Dart fields and sizes of Dart instances
into the specified file in JSON format.
Could be useful for debugging or memory usage investigations.
Typical output:
{"class":"_JsonUtf8Parser","size":80,"fields":[{"field":"emptyChunk","static":true},{"field":"decoder","offset":56},{"field":"chunk","offset":64},{"field":"chunkEnd","offset":72}]}
TEST=runtime/tests/vm/dart/print_object_layout_test.dart
Fixes https://github.com/dart-lang/sdk/issues/47892
Change-Id: I0b2f7ed9e4991e5fcd18517d5a06aa826c6d7125
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223662
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
26 lines
620 B
Dart
26 lines
620 B
Dart
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Test script for print_object_layout_test.dart
|
|
|
|
class ClassA {
|
|
String fieldA1 = 'a';
|
|
int fieldA2 = 1;
|
|
}
|
|
|
|
class ClassB extends ClassA {
|
|
String fieldB1 = 'b';
|
|
int fieldB2 = 2;
|
|
int unusedB3 = 3;
|
|
static int staticB4 = 4;
|
|
}
|
|
|
|
@pragma('vm:never-inline')
|
|
useFields(ClassB obj) =>
|
|
"${obj.fieldA1}${obj.fieldA2}${obj.fieldB1}${obj.fieldB2}${ClassB.staticB4}";
|
|
|
|
main() {
|
|
useFields(ClassB());
|
|
}
|