Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: runtime/vm/coverage.cc

Issue 1644793002: Replace intptr_t with TokenDescriptor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/compiler_stats.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 static void ComputeTokenPosToLineNumberMap(const Script& script, 34 static void ComputeTokenPosToLineNumberMap(const Script& script,
35 GrowableArray<intptr_t>* map) { 35 GrowableArray<intptr_t>* map) {
36 const TokenStream& tkns = TokenStream::Handle(script.tokens()); 36 const TokenStream& tkns = TokenStream::Handle(script.tokens());
37 const intptr_t len = ExternalTypedData::Handle(tkns.GetStream()).Length(); 37 const intptr_t len = ExternalTypedData::Handle(tkns.GetStream()).Length();
38 map->SetLength(len); 38 map->SetLength(len);
39 #if defined(DEBUG) 39 #if defined(DEBUG)
40 for (intptr_t i = 0; i < len; i++) { 40 for (intptr_t i = 0; i < len; i++) {
41 (*map)[i] = -1; 41 (*map)[i] = -1;
42 } 42 }
43 #endif 43 #endif
44 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); 44 TokenStream::Iterator tkit(tkns,
45 TokenPosition::kMinSource,
46 TokenStream::Iterator::kAllTokens);
45 intptr_t cur_line = script.line_offset() + 1; 47 intptr_t cur_line = script.line_offset() + 1;
46 while (tkit.CurrentTokenKind() != Token::kEOS) { 48 while (tkit.CurrentTokenKind() != Token::kEOS) {
47 (*map)[tkit.CurrentPosition()] = cur_line; 49 const intptr_t position = tkit.CurrentPosition().Pos();
50 (*map)[position] = cur_line;
48 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { 51 if (tkit.CurrentTokenKind() == Token::kNEWLINE) {
49 cur_line++; 52 cur_line++;
50 } 53 }
51 tkit.Advance(); 54 tkit.Advance();
52 } 55 }
53 } 56 }
54 57
55 58
56 void CodeCoverage::CompileAndAdd(const Function& function, 59 void CodeCoverage::CompileAndAdd(const Function& function,
57 const JSONArray& hits_or_sites, 60 const JSONArray& hits_or_sites,
(...skipping 22 matching lines...) Expand all
80 const Code& code = Code::Handle(zone, function.unoptimized_code()); 83 const Code& code = Code::Handle(zone, function.unoptimized_code());
81 ASSERT(!code.IsNull()); 84 ASSERT(!code.IsNull());
82 85
83 // Print the hit counts for all IC datas. 86 // Print the hit counts for all IC datas.
84 ZoneGrowableArray<const ICData*>* ic_data_array = 87 ZoneGrowableArray<const ICData*>* ic_data_array =
85 new(zone) ZoneGrowableArray<const ICData*>(); 88 new(zone) ZoneGrowableArray<const ICData*>();
86 function.RestoreICDataMap(ic_data_array, false /* clone descriptors */); 89 function.RestoreICDataMap(ic_data_array, false /* clone descriptors */);
87 const PcDescriptors& descriptors = PcDescriptors::Handle( 90 const PcDescriptors& descriptors = PcDescriptors::Handle(
88 zone, code.pc_descriptors()); 91 zone, code.pc_descriptors());
89 92
90 const intptr_t begin_pos = function.token_pos(); 93 const TokenPosition begin_pos = function.token_pos();
91 const intptr_t end_pos = function.end_token_pos(); 94 const TokenPosition end_pos = function.end_token_pos();
92 intptr_t last_line = -1; 95 intptr_t last_line = -1;
93 intptr_t last_count = 0; 96 intptr_t last_count = 0;
94 // Only IC based calls have counting. 97 // Only IC based calls have counting.
95 PcDescriptors::Iterator iter(descriptors, 98 PcDescriptors::Iterator iter(descriptors,
96 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall); 99 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall);
97 while (iter.MoveNext()) { 100 while (iter.MoveNext()) {
98 HANDLESCOPE(thread); 101 HANDLESCOPE(thread);
99 const ICData* ic_data = (*ic_data_array)[iter.DeoptId()]; 102 const ICData* ic_data = (*ic_data_array)[iter.DeoptId()];
100 if (!ic_data->IsNull()) { 103 if (!ic_data->IsNull()) {
101 const intptr_t token_pos = iter.TokenPos(); 104 const TokenPosition token_pos = iter.TokenPos();
102 // Filter out descriptors that do not map to tokens in the source code. 105 // Filter out descriptors that do not map to tokens in the source code.
103 if ((token_pos < begin_pos) || (token_pos > end_pos)) { 106 if ((token_pos < begin_pos) || (token_pos > end_pos)) {
104 continue; 107 continue;
105 } 108 }
106 if (as_call_sites) { 109 if (as_call_sites) {
107 bool is_static_call = iter.Kind() == RawPcDescriptors::kUnoptStaticCall; 110 bool is_static_call = iter.Kind() == RawPcDescriptors::kUnoptStaticCall;
108 ic_data->PrintToJSONArray(hits_or_sites, token_pos, is_static_call); 111 ic_data->PrintToJSONArray(hits_or_sites,
112 token_pos,
113 is_static_call);
109 } else { 114 } else {
110 intptr_t line = pos_to_line[token_pos]; 115 intptr_t line = pos_to_line[token_pos.Pos()];
111 #if defined(DEBUG) 116 #if defined(DEBUG)
112 const Script& script = Script::Handle(zone, function.script()); 117 const Script& script = Script::Handle(zone, function.script());
113 intptr_t test_line = -1; 118 intptr_t test_line = -1;
114 script.GetTokenLocation(token_pos, &test_line, NULL); 119 script.GetTokenLocation(token_pos, &test_line, NULL);
115 ASSERT(test_line == line); 120 ASSERT(test_line == line);
116 #endif 121 #endif
117 // Merge hit data where possible. 122 // Merge hit data where possible.
118 if (last_line == line) { 123 if (last_line == line) {
119 last_count += ic_data->AggregateCount(); 124 last_count += ic_data->AggregateCount();
120 } else { 125 } else {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 cls = it.GetNextClass(); 292 cls = it.GetNextClass();
288 ASSERT(!cls.IsNull()); 293 ASSERT(!cls.IsNull());
289 PrintClass(lib, cls, jsarr, filter, as_call_sites); 294 PrintClass(lib, cls, jsarr, filter, as_call_sites);
290 } 295 }
291 } 296 }
292 } 297 }
293 } 298 }
294 299
295 300
296 } // namespace dart 301 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler_stats.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698