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

Side by Side Diff: runtime/vm/service.cc

Issue 2795473003: [vm service] Collect garbage before getting native allocation samples (Closed)
Patch Set: Add test Created 3 years, 8 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
« no previous file with comments | « runtime/observatory/tests/service/collect_all_garbage_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "vm/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 }; 3258 };
3259 3259
3260 3260
3261 static bool GetNativeAllocationSamples(Thread* thread, JSONStream* js) { 3261 static bool GetNativeAllocationSamples(Thread* thread, JSONStream* js) {
3262 Profile::TagOrder tag_order = 3262 Profile::TagOrder tag_order =
3263 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values); 3263 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values);
3264 int64_t time_origin_micros = 3264 int64_t time_origin_micros =
3265 Int64Parameter::Parse(js->LookupParam("timeOriginMicros")); 3265 Int64Parameter::Parse(js->LookupParam("timeOriginMicros"));
3266 int64_t time_extent_micros = 3266 int64_t time_extent_micros =
3267 Int64Parameter::Parse(js->LookupParam("timeExtentMicros")); 3267 Int64Parameter::Parse(js->LookupParam("timeExtentMicros"));
3268 #if defined(DEBUG)
3269 Isolate::Current()->heap()->CollectAllGarbage();
3270 #endif
3268 ProfilerService::PrintNativeAllocationJSON(js, tag_order, time_origin_micros, 3271 ProfilerService::PrintNativeAllocationJSON(js, tag_order, time_origin_micros,
3269 time_extent_micros); 3272 time_extent_micros);
3270 return true; 3273 return true;
3271 } 3274 }
3272 3275
3273 3276
3274 static const MethodParameter* clear_cpu_profile_params[] = { 3277 static const MethodParameter* clear_cpu_profile_params[] = {
3275 RUNNABLE_ISOLATE_PARAMETER, NULL, 3278 RUNNABLE_ISOLATE_PARAMETER, NULL,
3276 }; 3279 };
3277 3280
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 } 3317 }
3315 if (should_collect) { 3318 if (should_collect) {
3316 isolate->UpdateLastAllocationProfileGCTimestamp(); 3319 isolate->UpdateLastAllocationProfileGCTimestamp();
3317 isolate->heap()->CollectAllGarbage(); 3320 isolate->heap()->CollectAllGarbage();
3318 } 3321 }
3319 isolate->class_table()->AllocationProfilePrintJSON(js); 3322 isolate->class_table()->AllocationProfilePrintJSON(js);
3320 return true; 3323 return true;
3321 } 3324 }
3322 3325
3323 3326
3327 static const MethodParameter* collect_all_garbage_params[] = {
3328 RUNNABLE_ISOLATE_PARAMETER, NULL,
3329 };
3330
3331 #if defined(DEBUG)
3332 static bool CollectAllGarbage(Thread* thread, JSONStream* js) {
3333 Isolate* isolate = thread->isolate();
3334 isolate->heap()->CollectAllGarbage();
3335 PrintSuccess(js);
3336 return true;
3337 }
3338 #else
3339 static bool CollectAllGarbage(Thread* thread, JSONStream* js) {
3340 PrintSuccess(js);
3341 return true;
3342 }
3343 #endif // defined(DEBUG)
3344
3345
3324 static const MethodParameter* get_heap_map_params[] = { 3346 static const MethodParameter* get_heap_map_params[] = {
3325 RUNNABLE_ISOLATE_PARAMETER, NULL, 3347 RUNNABLE_ISOLATE_PARAMETER, NULL,
3326 }; 3348 };
3327 3349
3328 3350
3329 static bool GetHeapMap(Thread* thread, JSONStream* js) { 3351 static bool GetHeapMap(Thread* thread, JSONStream* js) {
3330 Isolate* isolate = thread->isolate(); 3352 Isolate* isolate = thread->isolate();
3331 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); 3353 isolate->heap()->PrintHeapMapToJSONStream(isolate, js);
3332 return true; 3354 return true;
3333 } 3355 }
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
4163 { "setLibraryDebuggable", SetLibraryDebuggable, 4185 { "setLibraryDebuggable", SetLibraryDebuggable,
4164 set_library_debuggable_params }, 4186 set_library_debuggable_params },
4165 { "setName", SetName, 4187 { "setName", SetName,
4166 set_name_params }, 4188 set_name_params },
4167 { "_setTraceClassAllocation", SetTraceClassAllocation, 4189 { "_setTraceClassAllocation", SetTraceClassAllocation,
4168 set_trace_class_allocation_params }, 4190 set_trace_class_allocation_params },
4169 { "setVMName", SetVMName, 4191 { "setVMName", SetVMName,
4170 set_vm_name_params }, 4192 set_vm_name_params },
4171 { "_setVMTimelineFlags", SetVMTimelineFlags, 4193 { "_setVMTimelineFlags", SetVMTimelineFlags,
4172 set_vm_timeline_flags_params }, 4194 set_vm_timeline_flags_params },
4195 { "_collectAllGarbage", CollectAllGarbage,
4196 collect_all_garbage_params },
4173 }; 4197 };
4174 // clang-format on 4198 // clang-format on
4175 4199
4176 const ServiceMethodDescriptor* FindMethod(const char* method_name) { 4200 const ServiceMethodDescriptor* FindMethod(const char* method_name) {
4177 intptr_t num_methods = sizeof(service_methods_) / sizeof(service_methods_[0]); 4201 intptr_t num_methods = sizeof(service_methods_) / sizeof(service_methods_[0]);
4178 for (intptr_t i = 0; i < num_methods; i++) { 4202 for (intptr_t i = 0; i < num_methods; i++) {
4179 const ServiceMethodDescriptor& method = service_methods_[i]; 4203 const ServiceMethodDescriptor& method = service_methods_[i];
4180 if (strcmp(method_name, method.name) == 0) { 4204 if (strcmp(method_name, method.name) == 0) {
4181 return &method; 4205 return &method;
4182 } 4206 }
4183 } 4207 }
4184 return NULL; 4208 return NULL;
4185 } 4209 }
4186 4210
4187 #endif // !PRODUCT 4211 #endif // !PRODUCT
4188 4212
4189 } // namespace dart 4213 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/collect_all_garbage_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698