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) { |