Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: runtime/observatory/lib/src/repositories/sample_profile.dart

Issue 2778463002: Fixed missing method referenced when MallocHooks is unsupported. (Closed)
Patch Set: Fixed missing method referenced when MallocHooks is unsupported. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file 3 // BSD-style license that can be found in the LICENSE file
4 4
5 part of repositories; 5 part of repositories;
6 6
7 String _tagToString(M.SampleProfileTag tag) { 7 String _tagToString(M.SampleProfileTag tag) {
8 switch (tag) { 8 switch (tag) {
9 case M.SampleProfileTag.userVM: 9 case M.SampleProfileTag.userVM:
10 return 'UserVM'; 10 return 'UserVM';
(...skipping 14 matching lines...) Expand all
25 final SampleProfileLoadingProgress progress; 25 final SampleProfileLoadingProgress progress;
26 SampleProfileLoadingProgressEvent(this.progress); 26 SampleProfileLoadingProgressEvent(this.progress);
27 } 27 }
28 28
29 class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress { 29 class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress {
30 StreamController<SampleProfileLoadingProgressEvent> _onProgress = 30 StreamController<SampleProfileLoadingProgressEvent> _onProgress =
31 new StreamController<SampleProfileLoadingProgressEvent>.broadcast(); 31 new StreamController<SampleProfileLoadingProgressEvent>.broadcast();
32 Stream<SampleProfileLoadingProgressEvent> get onProgress => 32 Stream<SampleProfileLoadingProgressEvent> get onProgress =>
33 _onProgress.stream; 33 _onProgress.stream;
34 34
35 final S.Isolate isolate; 35 final ServiceObjectOwner owner;
36 final S.Class cls; 36 final S.Class cls;
37 final M.SampleProfileTag tag; 37 final M.SampleProfileTag tag;
38 final bool clear; 38 final bool clear;
39 final M.SampleProfileType type;
39 40
40 M.SampleProfileLoadingStatus _status = M.SampleProfileLoadingStatus.fetching; 41 M.SampleProfileLoadingStatus _status = M.SampleProfileLoadingStatus.fetching;
41 double _progress = 0.0; 42 double _progress = 0.0;
42 final Stopwatch _fetchingTime = new Stopwatch(); 43 final Stopwatch _fetchingTime = new Stopwatch();
43 final Stopwatch _loadingTime = new Stopwatch(); 44 final Stopwatch _loadingTime = new Stopwatch();
44 CpuProfile _profile; 45 CpuProfile _profile;
45 46
46 M.SampleProfileLoadingStatus get status => _status; 47 M.SampleProfileLoadingStatus get status => _status;
47 double get progress => _progress; 48 double get progress => _progress;
48 Duration get fetchingTime => _fetchingTime.elapsed; 49 Duration get fetchingTime => _fetchingTime.elapsed;
49 Duration get loadingTime => _loadingTime.elapsed; 50 Duration get loadingTime => _loadingTime.elapsed;
50 CpuProfile get profile => _profile; 51 CpuProfile get profile => _profile;
51 52
52 SampleProfileLoadingProgress(this.isolate, this.tag, this.clear, {this.cls}) { 53 SampleProfileLoadingProgress(this.owner, this.tag, this.clear,
54 {this.type: M.SampleProfileType.cpu, this.cls}) {
53 _run(); 55 _run();
54 } 56 }
55 57
56 Future _run() async { 58 Future _run() async {
57 _fetchingTime.start(); 59 _fetchingTime.start();
58 try { 60 try {
59 if (clear) { 61 if (clear && (type == M.SampleProfileType.cpu)) {
60 await isolate.invokeRpc('_clearCpuProfile', {}); 62 await owner.invokeRpc('_clearCpuProfile', {});
61 } 63 }
62 64
63 final response = cls != null 65 var response;
64 ? await cls.getAllocationSamples(_tagToString(tag)) 66 if (type == M.SampleProfileType.cpu) {
65 : await isolate 67 response = cls != null
66 .invokeRpc('_getCpuProfile', {'tags': _tagToString(tag)}); 68 ? await cls.getAllocationSamples(_tagToString(tag))
69 : await owner
70 .invokeRpc('_getCpuProfile', {'tags': _tagToString(tag)});
71 } else if (type == M.SampleProfileType.memory) {
72 assert(owner is M.VM);
73 M.VM vm = owner as M.VM;
74 response = await owner.invokeRpc(
75 '_getNativeAllocationSamples', {'tags': _tagToString(tag)});
76 } else {
77 throw new Exception('Unknown M.SampleProfileType: $type');
78 }
67 79
68 _fetchingTime.stop(); 80 _fetchingTime.stop();
69 _loadingTime.start(); 81 _loadingTime.start();
70 _status = M.SampleProfileLoadingStatus.loading; 82 _status = M.SampleProfileLoadingStatus.loading;
71 _triggerOnProgress(); 83 _triggerOnProgress();
72 84
73 CpuProfile profile = new CpuProfile(); 85 CpuProfile profile = new CpuProfile();
74 86
75 Stream<double> progress = profile.loadProgress(isolate, response); 87 Stream<double> progress = profile.loadProgress(owner, response);
76 progress.listen((value) { 88 progress.listen((value) {
77 _progress = value; 89 _progress = value;
78 _triggerOnProgress(); 90 _triggerOnProgress();
79 }); 91 });
80 92
81 await progress.drain(); 93 await progress.drain();
82 94
83 profile.buildFunctionCallerAndCallees(); 95 profile.buildFunctionCallerAndCallees();
84 _profile = profile; 96 _profile = profile;
85 97
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 implements M.IsolateSampleProfileRepository { 129 implements M.IsolateSampleProfileRepository {
118 SampleProfileLoadingProgress _last; 130 SampleProfileLoadingProgress _last;
119 131
120 Stream<SampleProfileLoadingProgressEvent> get( 132 Stream<SampleProfileLoadingProgressEvent> get(
121 M.IsolateRef i, M.SampleProfileTag t, 133 M.IsolateRef i, M.SampleProfileTag t,
122 {bool clear: false, bool forceFetch: false}) { 134 {bool clear: false, bool forceFetch: false}) {
123 assert(clear != null); 135 assert(clear != null);
124 assert(forceFetch != null); 136 assert(forceFetch != null);
125 S.Isolate isolate = i as S.Isolate; 137 S.Isolate isolate = i as S.Isolate;
126 assert(isolate != null); 138 assert(isolate != null);
127 if (_last != null && !clear && !forceFetch && _last.isolate == isolate) { 139 if ((_last != null) && !clear && !forceFetch && (_last.owner == isolate)) {
128 _last.reuse(); 140 _last.reuse();
129 } else { 141 } else {
130 _last = new SampleProfileLoadingProgress(isolate, t, clear); 142 _last = new SampleProfileLoadingProgress(isolate, t, clear);
131 } 143 }
132 return _last.onProgress; 144 return _last.onProgress;
133 } 145 }
134 } 146 }
135 147
136 class ClassSampleProfileRepository implements M.ClassSampleProfileRepository { 148 class ClassSampleProfileRepository implements M.ClassSampleProfileRepository {
137 Stream<SampleProfileLoadingProgressEvent> get( 149 Stream<SampleProfileLoadingProgressEvent> get(
(...skipping 11 matching lines...) Expand all
149 assert(cls != null); 161 assert(cls != null);
150 return cls.setTraceAllocations(true); 162 return cls.setTraceAllocations(true);
151 } 163 }
152 164
153 Future disable(M.IsolateRef i, M.ClassRef c) { 165 Future disable(M.IsolateRef i, M.ClassRef c) {
154 S.Class cls = c as S.Class; 166 S.Class cls = c as S.Class;
155 assert(cls != null); 167 assert(cls != null);
156 return cls.setTraceAllocations(false); 168 return cls.setTraceAllocations(false);
157 } 169 }
158 } 170 }
171
172 class NativeMemorySampleProfileRepository
173 implements M.NativeMemorySampleProfileRepository {
174 SampleProfileLoadingProgress _last;
175
176 Stream<SampleProfileLoadingProgressEvent> get(M.VM vm, M.SampleProfileTag t,
177 {bool forceFetch: false}) {
178 assert(forceFetch != null);
179 if ((_last != null) && !forceFetch) {
180 _last.reuse();
181 } else {
182 _last = new SampleProfileLoadingProgress(vm, t, false,
183 type: M.SampleProfileType.memory);
184 }
185 return _last.onProgress;
186 }
187 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/models/repositories/sample_profile.dart ('k') | runtime/observatory/lib/src/service/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698