OLD | NEW |
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/coverage.h" | 5 #include "vm/coverage.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const Code& code = Code::Handle(zone, function.unoptimized_code()); | 80 const Code& code = Code::Handle(zone, function.unoptimized_code()); |
81 ASSERT(!code.IsNull()); | 81 ASSERT(!code.IsNull()); |
82 | 82 |
83 // Print the hit counts for all IC datas. | 83 // Print the hit counts for all IC datas. |
84 ZoneGrowableArray<const ICData*>* ic_data_array = | 84 ZoneGrowableArray<const ICData*>* ic_data_array = |
85 new(zone) ZoneGrowableArray<const ICData*>(); | 85 new(zone) ZoneGrowableArray<const ICData*>(); |
86 function.RestoreICDataMap(ic_data_array, false /* clone descriptors */); | 86 function.RestoreICDataMap(ic_data_array, false /* clone descriptors */); |
87 const PcDescriptors& descriptors = PcDescriptors::Handle( | 87 const PcDescriptors& descriptors = PcDescriptors::Handle( |
88 zone, code.pc_descriptors()); | 88 zone, code.pc_descriptors()); |
89 | 89 |
90 const intptr_t begin_pos = function.token_pos(); | 90 const TokenDescriptor begin_pos = function.token_pos(); |
91 const intptr_t end_pos = function.end_token_pos(); | 91 const TokenDescriptor end_pos = function.end_token_pos(); |
92 intptr_t last_line = -1; | 92 intptr_t last_line = -1; |
93 intptr_t last_count = 0; | 93 intptr_t last_count = 0; |
94 // Only IC based calls have counting. | 94 // Only IC based calls have counting. |
95 PcDescriptors::Iterator iter(descriptors, | 95 PcDescriptors::Iterator iter(descriptors, |
96 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall); | 96 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall); |
97 while (iter.MoveNext()) { | 97 while (iter.MoveNext()) { |
98 HANDLESCOPE(thread); | 98 HANDLESCOPE(thread); |
99 const ICData* ic_data = (*ic_data_array)[iter.DeoptId()]; | 99 const ICData* ic_data = (*ic_data_array)[iter.DeoptId()]; |
100 if (!ic_data->IsNull()) { | 100 if (!ic_data->IsNull()) { |
101 const intptr_t token_pos = iter.TokenPos(); | 101 const TokenDescriptor token_pos = TokenDescriptor(iter.TokenPos()); |
102 // Filter out descriptors that do not map to tokens in the source code. | 102 // Filter out descriptors that do not map to tokens in the source code. |
103 if ((token_pos < begin_pos) || (token_pos > end_pos)) { | 103 if ((token_pos < begin_pos) || (token_pos > end_pos)) { |
104 continue; | 104 continue; |
105 } | 105 } |
106 if (as_call_sites) { | 106 if (as_call_sites) { |
107 bool is_static_call = iter.Kind() == RawPcDescriptors::kUnoptStaticCall; | 107 bool is_static_call = iter.Kind() == RawPcDescriptors::kUnoptStaticCall; |
108 ic_data->PrintToJSONArray(hits_or_sites, token_pos, is_static_call); | 108 ic_data->PrintToJSONArray(hits_or_sites, |
| 109 token_pos, |
| 110 is_static_call); |
109 } else { | 111 } else { |
110 intptr_t line = pos_to_line[token_pos]; | 112 intptr_t line = pos_to_line[token_pos.value()]; |
111 #if defined(DEBUG) | 113 #if defined(DEBUG) |
112 const Script& script = Script::Handle(zone, function.script()); | 114 const Script& script = Script::Handle(zone, function.script()); |
113 intptr_t test_line = -1; | 115 intptr_t test_line = -1; |
114 script.GetTokenLocation(token_pos, &test_line, NULL); | 116 script.GetTokenLocation(token_pos, &test_line, NULL); |
115 ASSERT(test_line == line); | 117 ASSERT(test_line == line); |
116 #endif | 118 #endif |
117 // Merge hit data where possible. | 119 // Merge hit data where possible. |
118 if (last_line == line) { | 120 if (last_line == line) { |
119 last_count += ic_data->AggregateCount(); | 121 last_count += ic_data->AggregateCount(); |
120 } else { | 122 } else { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 cls = it.GetNextClass(); | 289 cls = it.GetNextClass(); |
288 ASSERT(!cls.IsNull()); | 290 ASSERT(!cls.IsNull()); |
289 PrintClass(lib, cls, jsarr, filter, as_call_sites); | 291 PrintClass(lib, cls, jsarr, filter, as_call_sites); |
290 } | 292 } |
291 } | 293 } |
292 } | 294 } |
293 } | 295 } |
294 | 296 |
295 | 297 |
296 } // namespace dart | 298 } // namespace dart |
OLD | NEW |