| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO: | 5 // TODO: |
| 6 // 1. Visibility functions: base on boxPadding.t, not 15 | 6 // 1. Visibility functions: base on boxPadding.t, not 15 |
| 7 // 2. Track a maxDisplayDepth that is user-settable: | 7 // 2. Track a maxDisplayDepth that is user-settable: |
| 8 // maxDepth == currentRoot.depth + maxDisplayDepth | 8 // maxDepth == currentRoot.depth + maxDisplayDepth |
| 9 function D3SymbolTreeMap(mapWidth, mapHeight, levelsToShow) { | 9 function D3SymbolTreeMap(mapWidth, mapHeight, levelsToShow) { |
| 10 this._mapContainer = undefined; | 10 this._mapContainer = undefined; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } else if (num >= 1024) { | 64 } else if (num >= 1024) { |
| 65 suffix = 'KiB' | 65 suffix = 'KiB' |
| 66 num = num / 1024; | 66 num = num / 1024; |
| 67 } | 67 } |
| 68 return num.toFixed(2) + ' ' + suffix; | 68 return num.toFixed(2) + ' ' + suffix; |
| 69 } | 69 } |
| 70 return num + ' B'; | 70 return num + ' B'; |
| 71 } | 71 } |
| 72 | 72 |
| 73 D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS = { | 73 D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS = { |
| 74 // Definitions concisely derived from the nm 'man' page | 74 'b': '.bss', |
| 75 'A': 'Global absolute (A)', | 75 'd': '.data and .data.*', |
| 76 'B': 'Global uninitialized data (B)', | 76 'r': '.rodata', |
| 77 'b': 'Local uninitialized data (b)', | 77 't': '.text', |
| 78 'C': 'Global uninitialized common (C)', | 78 'v': 'Vtable entry', |
| 79 'D': 'Global initialized data (D)', | 79 '!': 'Generated Symbols (typeinfo, thunks, etc)', |
| 80 'd': 'Local initialized data (d)', | |
| 81 'G': 'Global small initialized data (G)', | |
| 82 'g': 'Local small initialized data (g)', | |
| 83 'i': 'Indirect function (i)', | |
| 84 'N': 'Debugging (N)', | |
| 85 'p': 'Stack unwind (p)', | |
| 86 'R': 'Global read-only data (R)', | |
| 87 'r': 'Local read-only data (r)', | |
| 88 'S': 'Global small uninitialized data (S)', | |
| 89 's': 'Local small uninitialized data (s)', | |
| 90 'T': 'Global code (T)', | |
| 91 't': 'Local code (t)', | |
| 92 'U': 'Undefined (U)', | |
| 93 'u': 'Unique (u)', | |
| 94 'V': 'Global weak object (V)', | |
| 95 'v': 'Local weak object (v)', | |
| 96 'W': 'Global weak symbol (W)', | |
| 97 'w': 'Local weak symbol (w)', | |
| 98 '@': 'Vtable entry (@)', // non-standard, hack. | |
| 99 '-': 'STABS debugging (-)', | |
| 100 '?': 'Unrecognized (?)', | |
| 101 }; | 80 }; |
| 102 D3SymbolTreeMap._NM_SYMBOL_TYPES = ''; | 81 D3SymbolTreeMap._NM_SYMBOL_TYPES = ''; |
| 103 for (var symbol_type in D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS) { | 82 for (var symbol_type in D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS) { |
| 104 D3SymbolTreeMap._NM_SYMBOL_TYPES += symbol_type; | 83 D3SymbolTreeMap._NM_SYMBOL_TYPES += symbol_type; |
| 105 } | 84 } |
| 106 | 85 |
| 107 /** | 86 /** |
| 108 * Given a symbol type code, look up and return a human-readable description | 87 * Given a symbol type code, look up and return a human-readable description |
| 109 * of that symbol type. If the symbol type does not match one of the known | 88 * of that symbol type. If the symbol type does not match one of the known |
| 110 * types, the unrecognized description (corresponding to symbol type '?') is | 89 * types, the unrecognized description (corresponding to symbol type '?') is |
| 111 * returned instead of null or undefined. | 90 * returned instead of null or undefined. |
| 112 */ | 91 */ |
| 113 D3SymbolTreeMap._getSymbolDescription = function(type) { | 92 D3SymbolTreeMap._getSymbolDescription = function(type) { |
| 114 var result = D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS[type]; | 93 var result = D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS[type]; |
| 115 if (result === undefined) { | 94 if (result === undefined) { |
| 116 result = D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS['?']; | 95 result = D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS['?']; |
| 117 } | 96 } |
| 118 return result; | 97 return result; |
| 119 } | 98 } |
| 120 | 99 |
| 121 // Qualitative 12-value pastel Brewer palette. | |
| 122 D3SymbolTreeMap._colorArray = [ | 100 D3SymbolTreeMap._colorArray = [ |
| 101 'rgb(190,186,218)', |
| 102 'rgb(253,180,98)', |
| 123 'rgb(141,211,199)', | 103 'rgb(141,211,199)', |
| 124 'rgb(255,255,179)', | |
| 125 'rgb(190,186,218)', | |
| 126 'rgb(251,128,114)', | |
| 127 'rgb(128,177,211)', | 104 'rgb(128,177,211)', |
| 128 'rgb(253,180,98)', | 105 'rgb(255,237,111)', |
| 129 'rgb(179,222,105)', | |
| 130 'rgb(252,205,229)', | |
| 131 'rgb(217,217,217)', | |
| 132 'rgb(188,128,189)', | |
| 133 'rgb(204,235,197)', | 106 'rgb(204,235,197)', |
| 134 'rgb(255,237,111)']; | 107 ] |
| 135 | 108 |
| 136 D3SymbolTreeMap._initColorMap = function() { | 109 D3SymbolTreeMap._initColorMap = function() { |
| 137 var map = {}; | 110 var map = {}; |
| 138 var numColors = D3SymbolTreeMap._colorArray.length; | 111 var numColors = D3SymbolTreeMap._colorArray.length; |
| 139 var count = 0; | 112 var count = 0; |
| 140 for (var key in D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS) { | 113 for (var key in D3SymbolTreeMap._NM_SYMBOL_TYPE_DESCRIPTIONS) { |
| 141 var index = count++ % numColors; | 114 var index = count++ % numColors; |
| 142 map[key] = d3.rgb(D3SymbolTreeMap._colorArray[index]); | 115 map[key] = d3.rgb(D3SymbolTreeMap._colorArray[index]); |
| 143 } | 116 } |
| 144 D3SymbolTreeMap._colorMap = map; | 117 D3SymbolTreeMap._colorMap = map; |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 if (datum.value > smallest) { // array is already full | 902 if (datum.value > smallest) { // array is already full |
| 930 result.push(datum); | 903 result.push(datum); |
| 931 result.sort(sortFunction); | 904 result.sort(sortFunction); |
| 932 result.pop(); // get rid of smallest element | 905 result.pop(); // get rid of smallest element |
| 933 smallest = result[maxRecords - 1].value; // new threshold for entry | 906 smallest = result[maxRecords - 1].value; // new threshold for entry |
| 934 } | 907 } |
| 935 }); | 908 }); |
| 936 result.sort(sortFunction); | 909 result.sort(sortFunction); |
| 937 return result; | 910 return result; |
| 938 } | 911 } |
| OLD | NEW |