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

Side by Side Diff: src/inspector/wasm-translation.cc

Issue 2555433002: [inspector] [wasm] Add folder structure to wasm urls (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project 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 #include "src/inspector/wasm-translation.h" 5 #include "src/inspector/wasm-translation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/debug/debug-interface.h" 9 #include "src/debug/debug-interface.h"
10 #include "src/inspector/protocol/Debugger.h" 10 #include "src/inspector/protocol/Debugger.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 found_byte_offset = std::get<0>((*reverse_table)[left + 1]); 129 found_byte_offset = std::get<0>((*reverse_table)[left + 1]);
130 } 130 }
131 131
132 v8::Isolate *isolate = loc->translation->isolate_; 132 v8::Isolate *isolate = loc->translation->isolate_;
133 loc->script_id = String16::fromInteger(script_.Get(isolate)->Id()); 133 loc->script_id = String16::fromInteger(script_.Get(isolate)->Id());
134 loc->line = func_index; 134 loc->line = func_index;
135 loc->column = found_byte_offset; 135 loc->column = found_byte_offset;
136 } 136 }
137 137
138 private: 138 private:
139 String16 GetScriptName(v8::Isolate *isolate) { 139 int getNumDigits(int number) {
140 return toProtocolString(script_.Get(isolate)->Name().ToLocalChecked()); 140 DCHECK_LE(0, number);
141 static const int limits[] = {0, 10, 100, 1000,
142 10000, 100000, 1000000, 10000000,
143 100000000, 1000000000};
144 for (int i = 0; i < static_cast<int>(arraysize(limits)); ++i)
145 if (number < limits[i]) return i;
146 UNREACHABLE();
147 return 0;
Yang 2016/12/05 15:16:42 This seems just to left-pad the folder name to the
Clemens Hammacher 2016/12/05 18:15:29 Yes, this is just for aesthetics. We can either ju
141 } 148 }
142 149
143 String16 GetFakeScriptUrl(v8::Isolate *isolate, int func_index) { 150 String16 GetFakeScriptUrl(v8::Isolate *isolate, int func_index) {
144 String16 script_name = GetScriptName(isolate); 151 Local<DebugInterface::WasmScript> script = script_.Get(isolate);
145 return String16::concat("wasm://wasm/", script_name, '/', script_name, '-', 152 String16 script_name = toProtocolString(script->Name().ToLocalChecked());
146 String16::fromInteger(func_index)); 153 int numFunctions = script->NumFunctions();
147 } 154 int numImported = script->NumImportedFunctions();
148 String16 GetFakeScriptUrl(const TransLocation *loc) { 155 String16Builder builder;
149 return GetFakeScriptUrl(loc->translation->isolate_, loc->line); 156 builder.appendAll("wasm://wasm/", script_name, '/');
157 if (numFunctions - numImported > 300) {
158 int digits = getNumDigits(numFunctions - 1);
159 String16 thisCategory = String16::fromInteger((func_index / 100) * 100);
160 DCHECK_LE(thisCategory.length(), digits);
161 for (int i = static_cast<int>(thisCategory.length()); i < digits; ++i)
162 builder.append('0');
163 builder.appendAll(thisCategory, '/');
164 }
165 builder.appendAll(script_name, '-');
166 builder.appendNumber(func_index);
167 return builder.toString();
150 } 168 }
151 169
152 String16 GetFakeScriptId(const String16 script_id, int func_index) { 170 String16 GetFakeScriptId(const String16 script_id, int func_index) {
153 return String16::concat(script_id, '-', String16::fromInteger(func_index)); 171 return String16::concat(script_id, '-', String16::fromInteger(func_index));
154 } 172 }
155 String16 GetFakeScriptId(const TransLocation *loc) { 173 String16 GetFakeScriptId(const TransLocation *loc) {
156 return GetFakeScriptId(loc->script_id, loc->line); 174 return GetFakeScriptId(loc->script_id, loc->line);
157 } 175 }
158 176
159 void AddFakeScript(v8::Isolate *isolate, const String16 &underlyingScriptId, 177 void AddFakeScript(v8::Isolate *isolate, const String16 &underlyingScriptId,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 *column_number = trans_loc.column; 315 *column_number = trans_loc.column;
298 316
299 return true; 317 return true;
300 } 318 }
301 319
302 void WasmTranslation::AddFakeScript(const String16 &scriptId, 320 void WasmTranslation::AddFakeScript(const String16 &scriptId,
303 TranslatorImpl *translator) { 321 TranslatorImpl *translator) {
304 DCHECK_EQ(0, fake_scripts_.count(scriptId)); 322 DCHECK_EQ(0, fake_scripts_.count(scriptId));
305 fake_scripts_.insert(std::make_pair(scriptId, translator)); 323 fake_scripts_.insert(std::make_pair(scriptId, translator));
306 } 324 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698