| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 { | 199 { |
| 200 JSONArray misses(&cov, "misses"); | 200 JSONArray misses(&cov, "misses"); |
| 201 for (int i = 0; i < func_length; i++) { | 201 for (int i = 0; i < func_length; i++) { |
| 202 if (coverage[i] == kCoverageMiss) { | 202 if (coverage[i] == kCoverageMiss) { |
| 203 misses.AddValue(begin_pos + i); // Add the token position of the miss. | 203 misses.AddValue(begin_pos + i); // Add the token position of the miss. |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 void SourceReport::PrintPossibleBreakpointsData(JSONObject* jsobj, |
| 210 const Function& func, |
| 211 const Code& code) { |
| 212 const uint8_t kSafepointKind = (RawPcDescriptors::kIcCall | |
| 213 RawPcDescriptors::kUnoptStaticCall | |
| 214 RawPcDescriptors::kRuntimeCall); |
| 215 const intptr_t begin_pos = func.token_pos(); |
| 216 const intptr_t end_pos = func.end_token_pos(); |
| 217 |
| 218 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 219 zone(), code.pc_descriptors()); |
| 220 |
| 221 intptr_t func_length = (end_pos - begin_pos) + 1; |
| 222 GrowableArray<char> possible(func_length); |
| 223 possible.SetLength(func_length); |
| 224 for (int i = 0; i < func_length; i++) { |
| 225 possible[i] = false; |
| 226 } |
| 227 |
| 228 PcDescriptors::Iterator iter(descriptors, kSafepointKind); |
| 229 while (iter.MoveNext()) { |
| 230 const intptr_t token_pos = iter.TokenPos(); |
| 231 if ((token_pos < begin_pos) || (token_pos > end_pos)) { |
| 232 // Does not correspond to a valid source position. |
| 233 continue; |
| 234 } |
| 235 intptr_t token_offset = token_pos - begin_pos; |
| 236 possible[token_offset] = true; |
| 237 } |
| 238 |
| 239 JSONArray bpts(jsobj, "possibleBreakpoints"); |
| 240 for (int i = 0; i < func_length; i++) { |
| 241 if (possible[i]) { |
| 242 bpts.AddValue(begin_pos + i); // Add the token position. |
| 243 } |
| 244 } |
| 245 } |
| 246 |
| 209 | 247 |
| 210 void SourceReport::PrintScriptTable(JSONArray* scripts) { | 248 void SourceReport::PrintScriptTable(JSONArray* scripts) { |
| 211 for (int i = 0; i < script_table_entries_.length(); i++) { | 249 for (int i = 0; i < script_table_entries_.length(); i++) { |
| 212 const Script* script = script_table_entries_[i].script; | 250 const Script* script = script_table_entries_[i].script; |
| 213 scripts->AddValue(*script); | 251 scripts->AddValue(*script); |
| 214 } | 252 } |
| 215 } | 253 } |
| 216 | 254 |
| 217 | 255 |
| 218 void SourceReport::VisitFunction(JSONArray* jsarr, const Function& func) { | 256 void SourceReport::VisitFunction(JSONArray* jsarr, const Function& func) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 range.AddProperty("startPos", begin_pos); | 296 range.AddProperty("startPos", begin_pos); |
| 259 range.AddProperty("endPos", end_pos); | 297 range.AddProperty("endPos", end_pos); |
| 260 range.AddProperty("compiled", true); | 298 range.AddProperty("compiled", true); |
| 261 | 299 |
| 262 if (IsReportRequested(kCallSites)) { | 300 if (IsReportRequested(kCallSites)) { |
| 263 PrintCallSitesData(&range, func, code); | 301 PrintCallSitesData(&range, func, code); |
| 264 } | 302 } |
| 265 if (IsReportRequested(kCoverage)) { | 303 if (IsReportRequested(kCoverage)) { |
| 266 PrintCoverageData(&range, func, code); | 304 PrintCoverageData(&range, func, code); |
| 267 } | 305 } |
| 306 if (IsReportRequested(kPossibleBreakpoints)) { |
| 307 PrintPossibleBreakpointsData(&range, func, code); |
| 308 } |
| 268 } | 309 } |
| 269 | 310 |
| 270 | 311 |
| 271 void SourceReport::VisitLibrary(JSONArray* jsarr, const Library& lib) { | 312 void SourceReport::VisitLibrary(JSONArray* jsarr, const Library& lib) { |
| 272 Class& cls = Class::Handle(zone()); | 313 Class& cls = Class::Handle(zone()); |
| 273 Array& functions = Array::Handle(zone()); | 314 Array& functions = Array::Handle(zone()); |
| 274 Function& func = Function::Handle(zone()); | 315 Function& func = Function::Handle(zone()); |
| 275 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); | 316 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); |
| 276 while (it.HasNext()) { | 317 while (it.HasNext()) { |
| 277 cls = it.GetNextClass(); | 318 cls = it.GetNextClass(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 VisitClosures(&ranges); | 365 VisitClosures(&ranges); |
| 325 } | 366 } |
| 326 | 367 |
| 327 // Print the script table. | 368 // Print the script table. |
| 328 JSONArray scripts(&report, "scripts"); | 369 JSONArray scripts(&report, "scripts"); |
| 329 PrintScriptTable(&scripts); | 370 PrintScriptTable(&scripts); |
| 330 } | 371 } |
| 331 | 372 |
| 332 | 373 |
| 333 } // namespace dart | 374 } // namespace dart |
| OLD | NEW |