| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/profiler_service.h" | 5 #include "vm/profiler_service.h" |
| 6 | 6 |
| 7 #include "vm/growable_array.h" | 7 #include "vm/growable_array.h" |
| 8 #include "vm/native_symbol.h" | 8 #include "vm/native_symbol.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| 11 #include "vm/profiler.h" | 11 #include "vm/profiler.h" |
| 12 #include "vm/reusable_handles.h" | 12 #include "vm/reusable_handles.h" |
| 13 #include "vm/scope_timer.h" | 13 #include "vm/scope_timer.h" |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 DECLARE_FLAG(int, profile_depth); | 17 DECLARE_FLAG(int, max_profile_depth); |
| 18 DECLARE_FLAG(int, profile_period); | 18 DECLARE_FLAG(int, profile_period); |
| 19 | 19 |
| 20 DEFINE_FLAG(bool, trace_profiler, false, "Trace profiler."); | 20 DEFINE_FLAG(bool, trace_profiler, false, "Trace profiler."); |
| 21 | 21 |
| 22 class DeoptimizedCodeSet : public ZoneAllocated { | 22 class DeoptimizedCodeSet : public ZoneAllocated { |
| 23 public: | 23 public: |
| 24 explicit DeoptimizedCodeSet(Isolate* isolate) | 24 explicit DeoptimizedCodeSet(Isolate* isolate) |
| 25 : previous_( | 25 : previous_( |
| 26 GrowableObjectArray::ZoneHandle(isolate->deoptimized_code_array())), | 26 GrowableObjectArray::ZoneHandle(isolate->deoptimized_code_array())), |
| 27 current_(GrowableObjectArray::ZoneHandle( | 27 current_(GrowableObjectArray::ZoneHandle( |
| (...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 | 2038 |
| 2039 void Profile::PrintJSON(JSONStream* stream) { | 2039 void Profile::PrintJSON(JSONStream* stream) { |
| 2040 ScopeTimer sw("Profile::PrintJSON", FLAG_trace_profiler); | 2040 ScopeTimer sw("Profile::PrintJSON", FLAG_trace_profiler); |
| 2041 JSONObject obj(stream); | 2041 JSONObject obj(stream); |
| 2042 obj.AddProperty("type", "_CpuProfile"); | 2042 obj.AddProperty("type", "_CpuProfile"); |
| 2043 obj.AddProperty("samplePeriod", | 2043 obj.AddProperty("samplePeriod", |
| 2044 static_cast<intptr_t>(FLAG_profile_period)); | 2044 static_cast<intptr_t>(FLAG_profile_period)); |
| 2045 obj.AddProperty("stackDepth", | 2045 obj.AddProperty("stackDepth", |
| 2046 static_cast<intptr_t>(FLAG_profile_depth)); | 2046 static_cast<intptr_t>(FLAG_max_profile_depth)); |
| 2047 obj.AddProperty("sampleCount", sample_count()); | 2047 obj.AddProperty("sampleCount", sample_count()); |
| 2048 obj.AddProperty("timeSpan", MicrosecondsToSeconds(GetTimeSpan())); | 2048 obj.AddProperty("timeSpan", MicrosecondsToSeconds(GetTimeSpan())); |
| 2049 { | 2049 { |
| 2050 JSONArray codes(&obj, "codes"); | 2050 JSONArray codes(&obj, "codes"); |
| 2051 for (intptr_t i = 0; i < live_code_->length(); i++) { | 2051 for (intptr_t i = 0; i < live_code_->length(); i++) { |
| 2052 ProfileCode* code = live_code_->At(i); | 2052 ProfileCode* code = live_code_->At(i); |
| 2053 ASSERT(code != NULL); | 2053 ASSERT(code != NULL); |
| 2054 code->PrintToJSONArray(&codes); | 2054 code->PrintToJSONArray(&codes); |
| 2055 } | 2055 } |
| 2056 for (intptr_t i = 0; i < dead_code_->length(); i++) { | 2056 for (intptr_t i = 0; i < dead_code_->length(); i++) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2287 ASSERT(sample_buffer != NULL); | 2287 ASSERT(sample_buffer != NULL); |
| 2288 | 2288 |
| 2289 ClearProfileVisitor clear_profile(isolate); | 2289 ClearProfileVisitor clear_profile(isolate); |
| 2290 sample_buffer->VisitSamples(&clear_profile); | 2290 sample_buffer->VisitSamples(&clear_profile); |
| 2291 | 2291 |
| 2292 // Enable profile interrupts. | 2292 // Enable profile interrupts. |
| 2293 Profiler::BeginExecution(isolate); | 2293 Profiler::BeginExecution(isolate); |
| 2294 } | 2294 } |
| 2295 | 2295 |
| 2296 } // namespace dart | 2296 } // namespace dart |
| OLD | NEW |