3930eb8fce
Fixes https://github.com/dart-lang/sdk/issues/45385 TEST=Fixes service/allocation_test in obfuscation mode. Change-Id: I80ac204866c5224cf88d2f5f2079655e224691c8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192143 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com>
35 lines
1.1 KiB
Dart
35 lines
1.1 KiB
Dart
// Copyright (c) 2014, 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.
|
|
|
|
library allocations_test;
|
|
|
|
import 'package:observatory/service_io.dart';
|
|
import 'package:test/test.dart';
|
|
import 'test_helper.dart';
|
|
|
|
@pragma('vm:entry-point')
|
|
class Foo {}
|
|
|
|
// Prevent TFA from removing this static field to ensure the objects are kept
|
|
// alive, so the allocation stats will report them via the service api.
|
|
@pragma('vm:entry-point')
|
|
List<Foo>? foos;
|
|
|
|
void script() {
|
|
foos = [new Foo(), new Foo(), new Foo()];
|
|
}
|
|
|
|
var tests = <IsolateTest>[
|
|
(Isolate isolate) async {
|
|
var profile = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', {});
|
|
var classHeapStats = profile['members'].singleWhere((stats) {
|
|
return stats['class']['name'] == 'Foo';
|
|
});
|
|
expect(classHeapStats['instancesCurrent'], equals(3));
|
|
expect(classHeapStats['instancesAccumulated'], equals(3));
|
|
},
|
|
];
|
|
|
|
main(args) => runIsolateTests(args, tests, testeeBefore: script);
|