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

Side by Side Diff: tools/codemap.js

Issue 2696903002: [profiler] Graphical front-end for tick processor. (Closed)
Patch Set: Fix test Created 3 years, 9 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 | « test/mjsunit/tools/tickprocessor.js ('k') | tools/mac-nm » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) { 168 CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) {
169 return addr >= node.key && addr < (node.key + node.value.size); 169 return addr >= node.key && addr < (node.key + node.value.size);
170 }; 170 };
171 171
172 172
173 /** 173 /**
174 * @private 174 * @private
175 */ 175 */
176 CodeMap.prototype.findInTree_ = function(tree, addr) { 176 CodeMap.prototype.findInTree_ = function(tree, addr) {
177 var node = tree.findGreatestLessThan(addr); 177 var node = tree.findGreatestLessThan(addr);
178 return node && this.isAddressBelongsTo_(addr, node) ? node.value : null; 178 return node && this.isAddressBelongsTo_(addr, node) ? node : null;
179 }; 179 };
180 180
181 181
182 /** 182 /**
183 * Finds a code entry that contains the specified address. Both static and 183 * Finds a code entry that contains the specified address. Both static and
184 * dynamic code entries are considered. 184 * dynamic code entries are considered. Returns the code entry and the offset
185 * within the entry.
185 * 186 *
186 * @param {number} addr Address. 187 * @param {number} addr Address.
187 */ 188 */
188 CodeMap.prototype.findEntry = function(addr) { 189 CodeMap.prototype.findAddress = function(addr) {
189 var pageAddr = addr >>> CodeMap.PAGE_ALIGNMENT; 190 var pageAddr = addr >>> CodeMap.PAGE_ALIGNMENT;
190 if (pageAddr in this.pages_) { 191 if (pageAddr in this.pages_) {
191 // Static code entries can contain "holes" of unnamed code. 192 // Static code entries can contain "holes" of unnamed code.
192 // In this case, the whole library is assigned to this address. 193 // In this case, the whole library is assigned to this address.
193 return this.findInTree_(this.statics_, addr) || 194 var result = this.findInTree_(this.statics_, addr);
194 this.findInTree_(this.libraries_, addr); 195 if (!result) {
196 result = this.findInTree_(this.libraries_, addr);
197 if (!result) return null;
198 }
199 return { entry : result.value, offset : addr - result.key };
195 } 200 }
196 var min = this.dynamics_.findMin(); 201 var min = this.dynamics_.findMin();
197 var max = this.dynamics_.findMax(); 202 var max = this.dynamics_.findMax();
198 if (max != null && addr < (max.key + max.value.size) && addr >= min.key) { 203 if (max != null && addr < (max.key + max.value.size) && addr >= min.key) {
199 var dynaEntry = this.findInTree_(this.dynamics_, addr); 204 var dynaEntry = this.findInTree_(this.dynamics_, addr);
200 if (dynaEntry == null) return null; 205 if (dynaEntry == null) return null;
201 // Dedupe entry name. 206 // Dedupe entry name.
202 if (!dynaEntry.nameUpdated_) { 207 var entry = dynaEntry.value;
203 dynaEntry.name = this.dynamicsNameGen_.getName(dynaEntry.name); 208 if (!entry.nameUpdated_) {
204 dynaEntry.nameUpdated_ = true; 209 entry.name = this.dynamicsNameGen_.getName(entry.name);
210 entry.nameUpdated_ = true;
205 } 211 }
206 return dynaEntry; 212 return { entry : entry, offset : addr - dynaEntry.key };
207 } 213 }
208 return null; 214 return null;
209 }; 215 };
210 216
211 217
212 /** 218 /**
219 * Finds a code entry that contains the specified address. Both static and
220 * dynamic code entries are considered.
221 *
222 * @param {number} addr Address.
223 */
224 CodeMap.prototype.findEntry = function(addr) {
225 var result = this.findAddress(addr);
226 return result ? result.entry : null;
227 };
228
229
230 /**
213 * Returns a dynamic code entry using its starting address. 231 * Returns a dynamic code entry using its starting address.
214 * 232 *
215 * @param {number} addr Address. 233 * @param {number} addr Address.
216 */ 234 */
217 CodeMap.prototype.findDynamicEntryByStartAddress = 235 CodeMap.prototype.findDynamicEntryByStartAddress =
218 function(addr) { 236 function(addr) {
219 var node = this.dynamics_.find(addr); 237 var node = this.dynamics_.find(addr);
220 return node ? node.value : null; 238 return node ? node.value : null;
221 }; 239 };
222 240
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 311
294 312
295 CodeMap.NameGenerator.prototype.getName = function(name) { 313 CodeMap.NameGenerator.prototype.getName = function(name) {
296 if (!(name in this.knownNames_)) { 314 if (!(name in this.knownNames_)) {
297 this.knownNames_[name] = 0; 315 this.knownNames_[name] = 0;
298 return name; 316 return name;
299 } 317 }
300 var count = ++this.knownNames_[name]; 318 var count = ++this.knownNames_[name];
301 return name + ' {' + count + '}'; 319 return name + ' {' + count + '}';
302 }; 320 };
OLDNEW
« no previous file with comments | « test/mjsunit/tools/tickprocessor.js ('k') | tools/mac-nm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698