Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 new(isolate) ZoneGrowableArray<const ICData*>(); | 83 new(isolate) ZoneGrowableArray<const ICData*>(); |
| 84 function.RestoreICDataMap(ic_data_array); | 84 function.RestoreICDataMap(ic_data_array); |
| 85 const Code& code = Code::Handle(function.unoptimized_code()); | 85 const Code& code = Code::Handle(function.unoptimized_code()); |
| 86 const PcDescriptors& descriptors = PcDescriptors::Handle( | 86 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 87 code.pc_descriptors()); | 87 code.pc_descriptors()); |
| 88 | 88 |
| 89 const intptr_t begin_pos = function.token_pos(); | 89 const intptr_t begin_pos = function.token_pos(); |
| 90 const intptr_t end_pos = function.end_token_pos(); | 90 const intptr_t end_pos = function.end_token_pos(); |
| 91 intptr_t last_line = -1; | 91 intptr_t last_line = -1; |
| 92 intptr_t last_count = 0; | 92 intptr_t last_count = 0; |
| 93 PcDescriptors::Iterator iter(descriptors); | 93 // Only IC based calls have counting. |
| 94 PcDescriptors::Iterator iter(descriptors, | |
| 95 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall); | |
| 94 while (iter.HasNext()) { | 96 while (iter.HasNext()) { |
| 95 HANDLESCOPE(isolate); | 97 HANDLESCOPE(isolate); |
| 96 const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); | 98 const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); |
| 97 RawPcDescriptors::Kind kind = rec.kind(); | 99 intptr_t deopt_id = rec.deopt_id; |
| 98 // Only IC based calls have counting. | 100 const ICData* ic_data= (*ic_data_array)[deopt_id]; |
|
siva
2014/07/10 18:21:21
ic_data =
srdjan
2014/07/10 18:24:48
Done.
| |
| 99 if ((kind == RawPcDescriptors::kIcCall) || | 101 if (!ic_data->IsNull()) { |
| 100 (kind == RawPcDescriptors::kUnoptStaticCall)) { | 102 intptr_t token_pos = rec.token_pos; |
| 101 intptr_t deopt_id = rec.deopt_id; | 103 // Filter out descriptors that do not map to tokens in the source code. |
| 102 const ICData* ic_data= (*ic_data_array)[deopt_id]; | 104 if ((token_pos < begin_pos) || (token_pos > end_pos)) { |
| 103 if (!ic_data->IsNull()) { | 105 continue; |
| 104 intptr_t token_pos = rec.token_pos; | 106 } |
| 105 // Filter out descriptors that do not map to tokens in the source code. | 107 intptr_t line = pos_to_line[token_pos]; |
| 106 if (token_pos < begin_pos || | 108 #if defined(DEBUG) |
| 107 token_pos > end_pos) { | 109 const Script& script = Script::Handle(function.script()); |
| 108 continue; | 110 intptr_t test_line = -1; |
| 111 script.GetTokenLocation(token_pos, &test_line, NULL); | |
| 112 ASSERT(test_line == line); | |
| 113 #endif | |
| 114 // Merge hit data where possible. | |
| 115 if (last_line == line) { | |
| 116 last_count += ic_data->AggregateCount(); | |
| 117 } else { | |
| 118 if (last_line != -1) { | |
| 119 hits_arr.AddValue(last_line); | |
| 120 hits_arr.AddValue(last_count); | |
| 109 } | 121 } |
| 110 intptr_t line = pos_to_line[token_pos]; | 122 last_count = ic_data->AggregateCount(); |
| 111 #if defined(DEBUG) | 123 last_line = line; |
| 112 const Script& script = Script::Handle(function.script()); | |
| 113 intptr_t test_line = -1; | |
| 114 script.GetTokenLocation(token_pos, &test_line, NULL); | |
| 115 ASSERT(test_line == line); | |
| 116 #endif | |
| 117 // Merge hit data where possible. | |
| 118 if (last_line == line) { | |
| 119 last_count += ic_data->AggregateCount(); | |
| 120 } else { | |
| 121 if (last_line != -1) { | |
| 122 hits_arr.AddValue(last_line); | |
| 123 hits_arr.AddValue(last_count); | |
| 124 } | |
| 125 last_count = ic_data->AggregateCount(); | |
| 126 last_line = line; | |
| 127 } | |
| 128 } | 124 } |
| 129 } | 125 } |
| 130 } | 126 } |
| 131 // Write last hit value if needed. | 127 // Write last hit value if needed. |
| 132 if (last_line != -1) { | 128 if (last_line != -1) { |
| 133 hits_arr.AddValue(last_line); | 129 hits_arr.AddValue(last_line); |
| 134 hits_arr.AddValue(last_count); | 130 hits_arr.AddValue(last_count); |
| 135 } | 131 } |
| 136 } | 132 } |
| 137 | 133 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 cls = it.GetNextClass(); | 279 cls = it.GetNextClass(); |
| 284 ASSERT(!cls.IsNull()); | 280 ASSERT(!cls.IsNull()); |
| 285 PrintClass(lib, cls, jsarr, filter); | 281 PrintClass(lib, cls, jsarr, filter); |
| 286 } | 282 } |
| 287 } | 283 } |
| 288 } | 284 } |
| 289 } | 285 } |
| 290 | 286 |
| 291 | 287 |
| 292 } // namespace dart | 288 } // namespace dart |
| OLD | NEW |