| 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/source_report.h" | 5 #include "vm/source_report.h" |
| 6 | 6 |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/object.h" | 8 #include "vm/object.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 for (intptr_t j = 0; j < scripts.Length(); j++) { | 104 for (intptr_t j = 0; j < scripts.Length(); j++) { |
| 105 if (scripts.At(j) == script.raw()) { | 105 if (scripts.At(j) == script.raw()) { |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 | 112 |
| 113 void SourceReport::PrintCallSitesData(JSONObject* jsobj, | 113 void SourceReport::PrintCallSitesData(JSONObject* jsobj, |
| 114 const Function& func, | 114 const Function& function, |
| 115 const Code& code) { | 115 const Code& code) { |
| 116 const TokenPosition begin_pos = func.token_pos(); | 116 const TokenPosition begin_pos = function.token_pos(); |
| 117 const TokenPosition end_pos = func.end_token_pos(); | 117 const TokenPosition end_pos = function.end_token_pos(); |
| 118 | 118 |
| 119 ZoneGrowableArray<const ICData*>* ic_data_array = | 119 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 120 new(zone()) ZoneGrowableArray<const ICData*>(); | 120 new(zone()) ZoneGrowableArray<const ICData*>(); |
| 121 func.RestoreICDataMap(ic_data_array, false /* clone descriptors */); | 121 function.RestoreICDataMap(ic_data_array, false /* clone descriptors */); |
| 122 const PcDescriptors& descriptors = PcDescriptors::Handle( | 122 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 123 zone(), code.pc_descriptors()); | 123 zone(), code.pc_descriptors()); |
| 124 | 124 |
| 125 JSONArray sites(jsobj, "callSites"); | 125 JSONArray sites(jsobj, "callSites"); |
| 126 | 126 |
| 127 PcDescriptors::Iterator iter( | 127 PcDescriptors::Iterator iter( |
| 128 descriptors, | 128 descriptors, |
| 129 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall); | 129 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall); |
| 130 while (iter.MoveNext()) { | 130 while (iter.MoveNext()) { |
| 131 HANDLESCOPE(thread()); | 131 HANDLESCOPE(thread()); |
| 132 const ICData* ic_data = (*ic_data_array)[iter.DeoptId()]; | 132 const ICData* ic_data = (*ic_data_array)[iter.DeoptId()]; |
| 133 if (!ic_data->IsNull()) { | 133 if (!ic_data->IsNull()) { |
| 134 const TokenPosition token_pos = iter.TokenPos(); | 134 const TokenPosition token_pos = iter.TokenPos(); |
| 135 if ((token_pos < begin_pos) || (token_pos > end_pos)) { | 135 if ((token_pos < begin_pos) || (token_pos > end_pos)) { |
| 136 // Does not correspond to a valid source position. | 136 // Does not correspond to a valid source position. |
| 137 continue; | 137 continue; |
| 138 } | 138 } |
| 139 bool is_static_call = iter.Kind() == RawPcDescriptors::kUnoptStaticCall; | 139 bool is_static_call = iter.Kind() == RawPcDescriptors::kUnoptStaticCall; |
| 140 ic_data->PrintToJSONArrayNew(sites, token_pos, is_static_call); | 140 ic_data->PrintToJSONArrayNew(sites, token_pos, is_static_call); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 void SourceReport::PrintCoverageData(JSONObject* jsobj, | 145 void SourceReport::PrintCoverageData(JSONObject* jsobj, |
| 146 const Function& func, | 146 const Function& function, |
| 147 const Code& code) { | 147 const Code& code) { |
| 148 const TokenPosition begin_pos = func.token_pos(); | 148 const TokenPosition begin_pos = function.token_pos(); |
| 149 const TokenPosition end_pos = func.end_token_pos(); | 149 const TokenPosition end_pos = function.end_token_pos(); |
| 150 | 150 |
| 151 ZoneGrowableArray<const ICData*>* ic_data_array = | 151 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 152 new(zone()) ZoneGrowableArray<const ICData*>(); | 152 new(zone()) ZoneGrowableArray<const ICData*>(); |
| 153 func.RestoreICDataMap(ic_data_array, false /* clone descriptors */); | 153 function.RestoreICDataMap(ic_data_array, false /* clone descriptors */); |
| 154 const PcDescriptors& descriptors = PcDescriptors::Handle( | 154 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 155 zone(), code.pc_descriptors()); | 155 zone(), code.pc_descriptors()); |
| 156 | 156 |
| 157 const int kCoverageNone = 0; | 157 const int kCoverageNone = 0; |
| 158 const int kCoverageMiss = 1; | 158 const int kCoverageMiss = 1; |
| 159 const int kCoverageHit = 2; | 159 const int kCoverageHit = 2; |
| 160 | 160 |
| 161 intptr_t func_length = (end_pos.Pos() - begin_pos.Pos()) + 1; | 161 intptr_t func_length = (end_pos.Pos() - begin_pos.Pos()) + 1; |
| 162 GrowableArray<char> coverage(func_length); | 162 GrowableArray<char> coverage(func_length); |
| 163 coverage.SetLength(func_length); | 163 coverage.SetLength(func_length); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 VisitClosures(&ranges); | 371 VisitClosures(&ranges); |
| 372 } | 372 } |
| 373 | 373 |
| 374 // Print the script table. | 374 // Print the script table. |
| 375 JSONArray scripts(&report, "scripts"); | 375 JSONArray scripts(&report, "scripts"); |
| 376 PrintScriptTable(&scripts); | 376 PrintScriptTable(&scripts); |
| 377 } | 377 } |
| 378 | 378 |
| 379 | 379 |
| 380 } // namespace dart | 380 } // namespace dart |
| OLD | NEW |