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

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

Issue 2555433002: [inspector] [wasm] Add folder structure to wasm urls (Closed)
Patch Set: Rebase 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 found_byte_offset = (*reverse_table)[left + 1].byte_offset; 127 found_byte_offset = (*reverse_table)[left + 1].byte_offset;
128 } 128 }
129 129
130 v8::Isolate *isolate = loc->translation->isolate_; 130 v8::Isolate *isolate = loc->translation->isolate_;
131 loc->script_id = String16::fromInteger(script_.Get(isolate)->Id()); 131 loc->script_id = String16::fromInteger(script_.Get(isolate)->Id());
132 loc->line = func_index; 132 loc->line = func_index;
133 loc->column = found_byte_offset; 133 loc->column = found_byte_offset;
134 } 134 }
135 135
136 private: 136 private:
137 String16 GetScriptName(v8::Isolate *isolate) {
138 return toProtocolString(script_.Get(isolate)->Name().ToLocalChecked());
139 }
140
141 String16 GetFakeScriptUrl(v8::Isolate *isolate, int func_index) { 137 String16 GetFakeScriptUrl(v8::Isolate *isolate, int func_index) {
142 String16 script_name = GetScriptName(isolate); 138 Local<debug::WasmScript> script = script_.Get(isolate);
143 return String16::concat("wasm://wasm/", script_name, '/', script_name, '-', 139 String16 script_name = toProtocolString(script->Name().ToLocalChecked());
144 String16::fromInteger(func_index)); 140 int numFunctions = script->NumFunctions();
145 } 141 int numImported = script->NumImportedFunctions();
146 String16 GetFakeScriptUrl(const TransLocation *loc) { 142 String16Builder builder;
147 return GetFakeScriptUrl(loc->translation->isolate_, loc->line); 143 builder.appendAll("wasm://wasm/", script_name, '/');
144 if (numFunctions - numImported > 300) {
145 size_t digits = String16::fromInteger(numFunctions - 1).length();
146 String16 thisCategory = String16::fromInteger((func_index / 100) * 100);
147 DCHECK_LE(thisCategory.length(), digits);
148 for (size_t i = thisCategory.length(); i < digits; ++i)
149 builder.append('0');
150 builder.appendAll(thisCategory, '/');
151 }
152 builder.appendAll(script_name, '-');
153 builder.appendNumber(func_index);
154 return builder.toString();
148 } 155 }
149 156
150 String16 GetFakeScriptId(const String16 script_id, int func_index) { 157 String16 GetFakeScriptId(const String16 script_id, int func_index) {
151 return String16::concat(script_id, '-', String16::fromInteger(func_index)); 158 return String16::concat(script_id, '-', String16::fromInteger(func_index));
152 } 159 }
153 String16 GetFakeScriptId(const TransLocation *loc) { 160 String16 GetFakeScriptId(const TransLocation *loc) {
154 return GetFakeScriptId(loc->script_id, loc->line); 161 return GetFakeScriptId(loc->script_id, loc->line);
155 } 162 }
156 163
157 void AddFakeScript(v8::Isolate *isolate, const String16 &underlyingScriptId, 164 void AddFakeScript(v8::Isolate *isolate, const String16 &underlyingScriptId,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 *column_number = trans_loc.column; 299 *column_number = trans_loc.column;
293 300
294 return true; 301 return true;
295 } 302 }
296 303
297 void WasmTranslation::AddFakeScript(const String16 &scriptId, 304 void WasmTranslation::AddFakeScript(const String16 &scriptId,
298 TranslatorImpl *translator) { 305 TranslatorImpl *translator) {
299 DCHECK_EQ(0, fake_scripts_.count(scriptId)); 306 DCHECK_EQ(0, fake_scripts_.count(scriptId));
300 fake_scripts_.insert(std::make_pair(scriptId, translator)); 307 fake_scripts_.insert(std::make_pair(scriptId, translator));
301 } 308 }
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