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

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

Issue 2532433003: [inspector] Split V8DebuggerScript implementation for wasm (Closed)
Patch Set: Fix 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 | « src/inspector/v8-debugger-script.cc ('k') | 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 String16 GetFakeScriptId(const TransLocation *loc) { 153 String16 GetFakeScriptId(const TransLocation *loc) {
154 return GetFakeScriptId(loc->script_id, loc->line); 154 return GetFakeScriptId(loc->script_id, loc->line);
155 } 155 }
156 156
157 void AddFakeScript(v8::Isolate *isolate, const String16 &underlyingScriptId, 157 void AddFakeScript(v8::Isolate *isolate, const String16 &underlyingScriptId,
158 int func_idx, WasmTranslation *translation, 158 int func_idx, WasmTranslation *translation,
159 V8DebuggerAgentImpl *agent) { 159 V8DebuggerAgentImpl *agent) {
160 String16 fake_script_id = GetFakeScriptId(underlyingScriptId, func_idx); 160 String16 fake_script_id = GetFakeScriptId(underlyingScriptId, func_idx);
161 String16 fake_script_url = GetFakeScriptUrl(isolate, func_idx); 161 String16 fake_script_url = GetFakeScriptUrl(isolate, func_idx);
162 162
163 v8::Local<debug::WasmScript> script = script_.Get(isolate);
163 // TODO(clemensh): Generate disassembly lazily when queried by the frontend. 164 // TODO(clemensh): Generate disassembly lazily when queried by the frontend.
164 debug::WasmDisassembly disassembly = 165 debug::WasmDisassembly disassembly = script->DisassembleFunction(func_idx);
165 script_.Get(isolate)->DisassembleFunction(func_idx);
166 166
167 DCHECK_EQ(0, offset_tables_.count(func_idx)); 167 DCHECK_EQ(0, offset_tables_.count(func_idx));
168 offset_tables_.insert( 168 offset_tables_.insert(
169 std::make_pair(func_idx, std::move(disassembly.offset_table))); 169 std::make_pair(func_idx, std::move(disassembly.offset_table)));
170 String16 source(disassembly.disassembly.data(), 170 String16 source(disassembly.disassembly.data(),
171 disassembly.disassembly.length()); 171 disassembly.disassembly.length());
172 std::unique_ptr<V8DebuggerScript> fake_script(new V8DebuggerScript( 172 std::unique_ptr<V8DebuggerScript> fake_script =
173 fake_script_id, std::move(fake_script_url), source)); 173 V8DebuggerScript::CreateWasm(isolate, script, fake_script_id,
174 std::move(fake_script_url), source);
174 175
175 translation->AddFakeScript(fake_script->scriptId(), this); 176 translation->AddFakeScript(fake_script->scriptId(), this);
176 agent->didParseSource(std::move(fake_script), true); 177 agent->didParseSource(std::move(fake_script), true);
177 } 178 }
178 179
179 int GetFunctionIndexFromFakeScriptId(const String16 &fake_script_id) { 180 int GetFunctionIndexFromFakeScriptId(const String16 &fake_script_id) {
180 size_t last_dash_pos = fake_script_id.reverseFind('-'); 181 size_t last_dash_pos = fake_script_id.reverseFind('-');
181 DCHECK_GT(fake_script_id.length(), last_dash_pos); 182 DCHECK_GT(fake_script_id.length(), last_dash_pos);
182 bool ok = true; 183 bool ok = true;
183 int func_index = fake_script_id.substring(last_dash_pos + 1).toInteger(&ok); 184 int func_index = fake_script_id.substring(last_dash_pos + 1).toInteger(&ok);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 *column_number = trans_loc.column; 293 *column_number = trans_loc.column;
293 294
294 return true; 295 return true;
295 } 296 }
296 297
297 void WasmTranslation::AddFakeScript(const String16 &scriptId, 298 void WasmTranslation::AddFakeScript(const String16 &scriptId,
298 TranslatorImpl *translator) { 299 TranslatorImpl *translator) {
299 DCHECK_EQ(0, fake_scripts_.count(scriptId)); 300 DCHECK_EQ(0, fake_scripts_.count(scriptId));
300 fake_scripts_.insert(std::make_pair(scriptId, translator)); 301 fake_scripts_.insert(std::make_pair(scriptId, translator));
301 } 302 }
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger-script.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698