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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/inspector/wasm-translation.cc
diff --git a/src/inspector/wasm-translation.cc b/src/inspector/wasm-translation.cc
index 22b81e5c9378477ad3cb47b74b3303c536ba12fb..cc6314d4e552e76d887f97fa4865f63ff55cf126 100644
--- a/src/inspector/wasm-translation.cc
+++ b/src/inspector/wasm-translation.cc
@@ -136,17 +136,35 @@ class WasmTranslation::TranslatorImpl::DisassemblingTranslator
}
private:
- String16 GetScriptName(v8::Isolate *isolate) {
- return toProtocolString(script_.Get(isolate)->Name().ToLocalChecked());
+ int getNumDigits(int number) {
+ DCHECK_LE(0, number);
+ static const int limits[] = {0, 10, 100, 1000,
+ 10000, 100000, 1000000, 10000000,
+ 100000000, 1000000000};
+ for (int i = 0; i < static_cast<int>(arraysize(limits)); ++i)
+ if (number < limits[i]) return i;
+ UNREACHABLE();
+ 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
}
String16 GetFakeScriptUrl(v8::Isolate *isolate, int func_index) {
- String16 script_name = GetScriptName(isolate);
- return String16::concat("wasm://wasm/", script_name, '/', script_name, '-',
- String16::fromInteger(func_index));
- }
- String16 GetFakeScriptUrl(const TransLocation *loc) {
- return GetFakeScriptUrl(loc->translation->isolate_, loc->line);
+ Local<DebugInterface::WasmScript> script = script_.Get(isolate);
+ String16 script_name = toProtocolString(script->Name().ToLocalChecked());
+ int numFunctions = script->NumFunctions();
+ int numImported = script->NumImportedFunctions();
+ String16Builder builder;
+ builder.appendAll("wasm://wasm/", script_name, '/');
+ if (numFunctions - numImported > 300) {
+ int digits = getNumDigits(numFunctions - 1);
+ String16 thisCategory = String16::fromInteger((func_index / 100) * 100);
+ DCHECK_LE(thisCategory.length(), digits);
+ for (int i = static_cast<int>(thisCategory.length()); i < digits; ++i)
+ builder.append('0');
+ builder.appendAll(thisCategory, '/');
+ }
+ builder.appendAll(script_name, '-');
+ builder.appendNumber(func_index);
+ return builder.toString();
}
String16 GetFakeScriptId(const String16 script_id, int func_index) {
« 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