| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const Error& err = Error::Handle( | 63 const Error& err = Error::Handle( |
| 64 isolate, Compiler::CompileFunction(isolate, function)); | 64 isolate, Compiler::CompileFunction(isolate, function)); |
| 65 if (!err.IsNull()) { | 65 if (!err.IsNull()) { |
| 66 OS::Print("### Coverage failed compiling:\n%s\n", err.ToErrorCString()); | 66 OS::Print("### Coverage failed compiling:\n%s\n", err.ToErrorCString()); |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 ASSERT(function.HasCode()); | 70 ASSERT(function.HasCode()); |
| 71 | 71 |
| 72 // Print the hit counts for all IC datas. | 72 // Print the hit counts for all IC datas. |
| 73 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 74 new(isolate) ZoneGrowableArray<const ICData*>(); |
| 75 function.RestoreICDataMap(ic_data_array); |
| 73 const Code& code = Code::Handle(function.unoptimized_code()); | 76 const Code& code = Code::Handle(function.unoptimized_code()); |
| 74 const Array& ic_array = Array::Handle(code.ExtractTypeFeedbackArray()); | |
| 75 const PcDescriptors& descriptors = PcDescriptors::Handle( | 77 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 76 code.pc_descriptors()); | 78 code.pc_descriptors()); |
| 77 ICData& ic_data = ICData::Handle(); | |
| 78 | 79 |
| 79 for (int j = 0; j < descriptors.Length(); j++) { | 80 for (int j = 0; j < descriptors.Length(); j++) { |
| 80 HANDLESCOPE(isolate); | 81 HANDLESCOPE(isolate); |
| 81 PcDescriptors::Kind kind = descriptors.DescriptorKind(j); | 82 PcDescriptors::Kind kind = descriptors.DescriptorKind(j); |
| 82 // Only IC based calls have counting. | 83 // Only IC based calls have counting. |
| 83 if ((kind == PcDescriptors::kIcCall) || | 84 if ((kind == PcDescriptors::kIcCall) || |
| 84 (kind == PcDescriptors::kUnoptStaticCall)) { | 85 (kind == PcDescriptors::kUnoptStaticCall)) { |
| 85 intptr_t deopt_id = descriptors.DeoptId(j); | 86 intptr_t deopt_id = descriptors.DeoptId(j); |
| 86 ic_data ^= ic_array.At(deopt_id); | 87 const ICData* ic_data= (*ic_data_array)[deopt_id]; |
| 87 if (!ic_data.IsNull()) { | 88 if (!ic_data->IsNull()) { |
| 88 intptr_t token_pos = descriptors.TokenPos(j); | 89 intptr_t token_pos = descriptors.TokenPos(j); |
| 89 intptr_t line = pos_to_line[token_pos]; | 90 intptr_t line = pos_to_line[token_pos]; |
| 90 #if defined(DEBUG) | 91 #if defined(DEBUG) |
| 91 const Script& script = Script::Handle(function.script()); | 92 const Script& script = Script::Handle(function.script()); |
| 92 intptr_t test_line = -1; | 93 intptr_t test_line = -1; |
| 93 script.GetTokenLocation(token_pos, &test_line, NULL); | 94 script.GetTokenLocation(token_pos, &test_line, NULL); |
| 94 ASSERT(test_line == line); | 95 ASSERT(test_line == line); |
| 95 #endif | 96 #endif |
| 96 hits_arr.AddValue(line); | 97 hits_arr.AddValue(line); |
| 97 hits_arr.AddValue(ic_data.AggregateCount()); | 98 hits_arr.AddValue(ic_data->AggregateCount()); |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 | 103 |
| 103 | 104 |
| 104 void CodeCoverage::PrintClass(const Class& cls, const JSONArray& jsarr) { | 105 void CodeCoverage::PrintClass(const Class& cls, const JSONArray& jsarr) { |
| 105 Isolate* isolate = Isolate::Current(); | 106 Isolate* isolate = Isolate::Current(); |
| 106 Array& functions = Array::Handle(cls.functions()); | 107 Array& functions = Array::Handle(cls.functions()); |
| 107 ASSERT(!functions.IsNull()); | 108 ASSERT(!functions.IsNull()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // functions. | 230 // functions. |
| 230 PrintClass(cls, jsarr); | 231 PrintClass(cls, jsarr); |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 } | 234 } |
| 234 } | 235 } |
| 235 } | 236 } |
| 236 | 237 |
| 237 | 238 |
| 238 } // namespace dart | 239 } // namespace dart |
| OLD | NEW |