OLD | NEW |
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" |
11 #include "src/inspector/script-breakpoint.h" | 11 #include "src/inspector/script-breakpoint.h" |
12 #include "src/inspector/string-util.h" | 12 #include "src/inspector/string-util.h" |
13 #include "src/inspector/v8-debugger-agent-impl.h" | 13 #include "src/inspector/v8-debugger-agent-impl.h" |
14 #include "src/inspector/v8-debugger-script.h" | 14 #include "src/inspector/v8-debugger-script.h" |
15 #include "src/inspector/v8-debugger.h" | 15 #include "src/inspector/v8-debugger.h" |
16 #include "src/inspector/v8-inspector-impl.h" | 16 #include "src/inspector/v8-inspector-impl.h" |
17 | 17 |
18 using namespace v8_inspector; | 18 using namespace v8_inspector; |
19 using namespace v8; | 19 using namespace v8; |
20 | 20 |
21 class WasmTranslation::TranslatorImpl { | 21 class WasmTranslation::TranslatorImpl { |
22 public: | 22 public: |
23 struct TransLocation { | 23 struct TransLocation { |
24 WasmTranslation *translation; | 24 WasmTranslation* translation; |
25 String16 script_id; | 25 String16 script_id; |
26 int line; | 26 int line; |
27 int column; | 27 int column; |
28 TransLocation(WasmTranslation *translation, String16 script_id, int line, | 28 TransLocation(WasmTranslation* translation, String16 script_id, int line, |
29 int column) | 29 int column) |
30 : translation(translation), | 30 : translation(translation), |
31 script_id(script_id), | 31 script_id(script_id), |
32 line(line), | 32 line(line), |
33 column(column) {} | 33 column(column) {} |
34 }; | 34 }; |
35 | 35 |
36 virtual void Translate(TransLocation *loc) = 0; | 36 virtual void Init(Isolate*, WasmTranslation*, V8DebuggerAgentImpl*) = 0; |
37 virtual void TranslateBack(TransLocation *loc) = 0; | 37 virtual void Translate(TransLocation*) = 0; |
| 38 virtual void TranslateBack(TransLocation*) = 0; |
38 | 39 |
39 class RawTranslator; | 40 class RawTranslator; |
40 class DisassemblingTranslator; | 41 class DisassemblingTranslator; |
41 }; | 42 }; |
42 | 43 |
43 class WasmTranslation::TranslatorImpl::RawTranslator | 44 class WasmTranslation::TranslatorImpl::RawTranslator |
44 : public WasmTranslation::TranslatorImpl { | 45 : public WasmTranslation::TranslatorImpl { |
45 public: | 46 public: |
46 void Translate(TransLocation *loc) {} | 47 void Init(Isolate*, WasmTranslation*, V8DebuggerAgentImpl*) {} |
47 void TranslateBack(TransLocation *loc) {} | 48 void Translate(TransLocation*) {} |
| 49 void TranslateBack(TransLocation*) {} |
48 }; | 50 }; |
49 | 51 |
50 class WasmTranslation::TranslatorImpl::DisassemblingTranslator | 52 class WasmTranslation::TranslatorImpl::DisassemblingTranslator |
51 : public WasmTranslation::TranslatorImpl { | 53 : public WasmTranslation::TranslatorImpl { |
52 using OffsetTable = debug::WasmDisassembly::OffsetTable; | 54 using OffsetTable = debug::WasmDisassembly::OffsetTable; |
53 | 55 |
54 public: | 56 public: |
55 DisassemblingTranslator(Isolate *isolate, Local<debug::WasmScript> script, | 57 DisassemblingTranslator(Isolate* isolate, Local<debug::WasmScript> script) |
56 WasmTranslation *translation, | 58 : script_(isolate, script) {} |
57 V8DebuggerAgentImpl *agent) | 59 |
58 : script_(isolate, script) { | 60 void Init(Isolate* isolate, WasmTranslation* translation, |
| 61 V8DebuggerAgentImpl* agent) override { |
59 // Register fake scripts for each function in this wasm module/script. | 62 // Register fake scripts for each function in this wasm module/script. |
| 63 Handle<debug::WasmScript> script = script_.Get(isolate); |
60 int num_functions = script->NumFunctions(); | 64 int num_functions = script->NumFunctions(); |
61 int num_imported_functions = script->NumImportedFunctions(); | 65 int num_imported_functions = script->NumImportedFunctions(); |
62 DCHECK_LE(0, num_imported_functions); | 66 DCHECK_LE(0, num_imported_functions); |
63 DCHECK_LE(0, num_functions); | 67 DCHECK_LE(0, num_functions); |
64 DCHECK_GE(num_functions, num_imported_functions); | 68 DCHECK_GE(num_functions, num_imported_functions); |
65 String16 script_id = String16::fromInteger(script->Id()); | 69 String16 script_id = String16::fromInteger(script->Id()); |
66 for (int func_idx = num_imported_functions; func_idx < num_functions; | 70 for (int func_idx = num_imported_functions; func_idx < num_functions; |
67 ++func_idx) { | 71 ++func_idx) { |
68 AddFakeScript(isolate, script_id, func_idx, translation, agent); | 72 AddFakeScript(isolate, script_id, func_idx, translation, agent); |
69 } | 73 } |
70 } | 74 } |
71 | 75 |
72 void Translate(TransLocation *loc) { | 76 void Translate(TransLocation* loc) override { |
73 const OffsetTable &offset_table = GetOffsetTable(loc); | 77 const OffsetTable& offset_table = GetOffsetTable(loc); |
74 DCHECK(!offset_table.empty()); | 78 DCHECK(!offset_table.empty()); |
75 uint32_t byte_offset = static_cast<uint32_t>(loc->column); | 79 uint32_t byte_offset = static_cast<uint32_t>(loc->column); |
76 | 80 |
77 // Binary search for the given offset. | 81 // Binary search for the given offset. |
78 unsigned left = 0; // inclusive | 82 unsigned left = 0; // inclusive |
79 unsigned right = static_cast<unsigned>(offset_table.size()); // exclusive | 83 unsigned right = static_cast<unsigned>(offset_table.size()); // exclusive |
80 while (right - left > 1) { | 84 while (right - left > 1) { |
81 unsigned mid = (left + right) / 2; | 85 unsigned mid = (left + right) / 2; |
82 if (offset_table[mid].byte_offset <= byte_offset) { | 86 if (offset_table[mid].byte_offset <= byte_offset) { |
83 left = mid; | 87 left = mid; |
84 } else { | 88 } else { |
85 right = mid; | 89 right = mid; |
86 } | 90 } |
87 } | 91 } |
88 | 92 |
89 loc->script_id = GetFakeScriptId(loc); | 93 loc->script_id = GetFakeScriptId(loc); |
90 if (offset_table[left].byte_offset == byte_offset) { | 94 if (offset_table[left].byte_offset == byte_offset) { |
91 loc->line = offset_table[left].line; | 95 loc->line = offset_table[left].line; |
92 loc->column = offset_table[left].column; | 96 loc->column = offset_table[left].column; |
93 } else { | 97 } else { |
94 loc->line = 0; | 98 loc->line = 0; |
95 loc->column = 0; | 99 loc->column = 0; |
96 } | 100 } |
97 } | 101 } |
98 | 102 |
99 void TranslateBack(TransLocation *loc) { | 103 void TranslateBack(TransLocation* loc) override { |
100 int func_index = GetFunctionIndexFromFakeScriptId(loc->script_id); | 104 int func_index = GetFunctionIndexFromFakeScriptId(loc->script_id); |
101 const OffsetTable *reverse_table = GetReverseTable(func_index); | 105 const OffsetTable* reverse_table = GetReverseTable(func_index); |
102 if (!reverse_table) return; | 106 if (!reverse_table) return; |
103 DCHECK(!reverse_table->empty()); | 107 DCHECK(!reverse_table->empty()); |
| 108 v8::Isolate* isolate = loc->translation->isolate_; |
104 | 109 |
105 // Binary search for the given line and column. | 110 // Binary search for the given line and column. |
106 unsigned left = 0; // inclusive | 111 unsigned left = 0; // inclusive |
107 unsigned right = static_cast<unsigned>(reverse_table->size()); // exclusive | 112 unsigned right = static_cast<unsigned>(reverse_table->size()); // exclusive |
108 while (right - left > 1) { | 113 while (right - left > 1) { |
109 unsigned mid = (left + right) / 2; | 114 unsigned mid = (left + right) / 2; |
110 auto &entry = (*reverse_table)[mid]; | 115 auto& entry = (*reverse_table)[mid]; |
111 if (entry.line < loc->line || | 116 if (entry.line < loc->line || |
112 (entry.line == loc->line && entry.column <= loc->column)) { | 117 (entry.line == loc->line && entry.column <= loc->column)) { |
113 left = mid; | 118 left = mid; |
114 } else { | 119 } else { |
115 right = mid; | 120 right = mid; |
116 } | 121 } |
117 } | 122 } |
118 | 123 |
119 int found_byte_offset = 0; | 124 int found_byte_offset = 0; |
120 // If we found an exact match, use it. Otherwise check whether the next | 125 // If we found an exact match, use it. Otherwise check whether the next |
121 // bigger entry is still in the same line. Report that one then. | 126 // bigger entry is still in the same line. Report that one then. |
| 127 // Otherwise we might have hit the special case of pointing after the last |
| 128 // line, which is translated to the end of the function (one byte after the |
| 129 // last function byte). |
122 if ((*reverse_table)[left].line == loc->line && | 130 if ((*reverse_table)[left].line == loc->line && |
123 (*reverse_table)[left].column == loc->column) { | 131 (*reverse_table)[left].column == loc->column) { |
124 found_byte_offset = (*reverse_table)[left].byte_offset; | 132 found_byte_offset = (*reverse_table)[left].byte_offset; |
125 } else if (left + 1 < reverse_table->size() && | 133 } else if (left + 1 < reverse_table->size() && |
126 (*reverse_table)[left + 1].line == loc->line) { | 134 (*reverse_table)[left + 1].line == loc->line) { |
127 found_byte_offset = (*reverse_table)[left + 1].byte_offset; | 135 found_byte_offset = (*reverse_table)[left + 1].byte_offset; |
| 136 } else if (left == reverse_table->size() - 1 && |
| 137 (*reverse_table)[left].line == loc->line - 1 && |
| 138 loc->column == 0) { |
| 139 std::pair<int, int> func_range = |
| 140 script_.Get(isolate)->GetFunctionRange(func_index); |
| 141 DCHECK_LE(func_range.first, func_range.second); |
| 142 found_byte_offset = func_range.second - func_range.first; |
128 } | 143 } |
129 | 144 |
130 v8::Isolate *isolate = loc->translation->isolate_; | |
131 loc->script_id = String16::fromInteger(script_.Get(isolate)->Id()); | 145 loc->script_id = String16::fromInteger(script_.Get(isolate)->Id()); |
132 loc->line = func_index; | 146 loc->line = func_index; |
133 loc->column = found_byte_offset; | 147 loc->column = found_byte_offset; |
134 } | 148 } |
135 | 149 |
136 private: | 150 private: |
137 String16 GetFakeScriptUrl(v8::Isolate *isolate, int func_index) { | 151 String16 GetFakeScriptUrl(v8::Isolate* isolate, int func_index) { |
138 Local<debug::WasmScript> script = script_.Get(isolate); | 152 Local<debug::WasmScript> script = script_.Get(isolate); |
139 String16 script_name = toProtocolString(script->Name().ToLocalChecked()); | 153 String16 script_name = toProtocolString(script->Name().ToLocalChecked()); |
140 int numFunctions = script->NumFunctions(); | 154 int numFunctions = script->NumFunctions(); |
141 int numImported = script->NumImportedFunctions(); | 155 int numImported = script->NumImportedFunctions(); |
142 String16Builder builder; | 156 String16Builder builder; |
143 builder.appendAll("wasm://wasm/", script_name, '/'); | 157 builder.appendAll("wasm://wasm/", script_name, '/'); |
144 if (numFunctions - numImported > 300) { | 158 if (numFunctions - numImported > 300) { |
145 size_t digits = String16::fromInteger(numFunctions - 1).length(); | 159 size_t digits = String16::fromInteger(numFunctions - 1).length(); |
146 String16 thisCategory = String16::fromInteger((func_index / 100) * 100); | 160 String16 thisCategory = String16::fromInteger((func_index / 100) * 100); |
147 DCHECK_LE(thisCategory.length(), digits); | 161 DCHECK_LE(thisCategory.length(), digits); |
148 for (size_t i = thisCategory.length(); i < digits; ++i) | 162 for (size_t i = thisCategory.length(); i < digits; ++i) |
149 builder.append('0'); | 163 builder.append('0'); |
150 builder.appendAll(thisCategory, '/'); | 164 builder.appendAll(thisCategory, '/'); |
151 } | 165 } |
152 builder.appendAll(script_name, '-'); | 166 builder.appendAll(script_name, '-'); |
153 builder.appendNumber(func_index); | 167 builder.appendNumber(func_index); |
154 return builder.toString(); | 168 return builder.toString(); |
155 } | 169 } |
156 | 170 |
157 String16 GetFakeScriptId(const String16 script_id, int func_index) { | 171 String16 GetFakeScriptId(const String16 script_id, int func_index) { |
158 return String16::concat(script_id, '-', String16::fromInteger(func_index)); | 172 return String16::concat(script_id, '-', String16::fromInteger(func_index)); |
159 } | 173 } |
160 String16 GetFakeScriptId(const TransLocation *loc) { | 174 String16 GetFakeScriptId(const TransLocation* loc) { |
161 return GetFakeScriptId(loc->script_id, loc->line); | 175 return GetFakeScriptId(loc->script_id, loc->line); |
162 } | 176 } |
163 | 177 |
164 void AddFakeScript(v8::Isolate *isolate, const String16 &underlyingScriptId, | 178 void AddFakeScript(v8::Isolate* isolate, const String16& underlyingScriptId, |
165 int func_idx, WasmTranslation *translation, | 179 int func_idx, WasmTranslation* translation, |
166 V8DebuggerAgentImpl *agent) { | 180 V8DebuggerAgentImpl* agent) { |
167 String16 fake_script_id = GetFakeScriptId(underlyingScriptId, func_idx); | 181 String16 fake_script_id = GetFakeScriptId(underlyingScriptId, func_idx); |
168 String16 fake_script_url = GetFakeScriptUrl(isolate, func_idx); | 182 String16 fake_script_url = GetFakeScriptUrl(isolate, func_idx); |
169 | 183 |
170 v8::Local<debug::WasmScript> script = script_.Get(isolate); | 184 v8::Local<debug::WasmScript> script = script_.Get(isolate); |
171 // TODO(clemensh): Generate disassembly lazily when queried by the frontend. | 185 // TODO(clemensh): Generate disassembly lazily when queried by the frontend. |
172 debug::WasmDisassembly disassembly = script->DisassembleFunction(func_idx); | 186 debug::WasmDisassembly disassembly = script->DisassembleFunction(func_idx); |
173 | 187 |
174 DCHECK_EQ(0, offset_tables_.count(func_idx)); | 188 DCHECK_EQ(0, offset_tables_.count(func_idx)); |
175 offset_tables_.insert( | 189 offset_tables_.insert( |
176 std::make_pair(func_idx, std::move(disassembly.offset_table))); | 190 std::make_pair(func_idx, std::move(disassembly.offset_table))); |
177 String16 source(disassembly.disassembly.data(), | 191 String16 source(disassembly.disassembly.data(), |
178 disassembly.disassembly.length()); | 192 disassembly.disassembly.length()); |
179 std::unique_ptr<V8DebuggerScript> fake_script = | 193 std::unique_ptr<V8DebuggerScript> fake_script = |
180 V8DebuggerScript::CreateWasm(isolate, script, fake_script_id, | 194 V8DebuggerScript::CreateWasm(isolate, translation, script, |
181 std::move(fake_script_url), source); | 195 fake_script_id, std::move(fake_script_url), |
| 196 source); |
182 | 197 |
183 translation->AddFakeScript(fake_script->scriptId(), this); | 198 translation->AddFakeScript(fake_script->scriptId(), this); |
184 agent->didParseSource(std::move(fake_script), true); | 199 agent->didParseSource(std::move(fake_script), true); |
185 } | 200 } |
186 | 201 |
187 int GetFunctionIndexFromFakeScriptId(const String16 &fake_script_id) { | 202 int GetFunctionIndexFromFakeScriptId(const String16& fake_script_id) { |
188 size_t last_dash_pos = fake_script_id.reverseFind('-'); | 203 size_t last_dash_pos = fake_script_id.reverseFind('-'); |
189 DCHECK_GT(fake_script_id.length(), last_dash_pos); | 204 DCHECK_GT(fake_script_id.length(), last_dash_pos); |
190 bool ok = true; | 205 bool ok = true; |
191 int func_index = fake_script_id.substring(last_dash_pos + 1).toInteger(&ok); | 206 int func_index = fake_script_id.substring(last_dash_pos + 1).toInteger(&ok); |
192 DCHECK(ok); | 207 DCHECK(ok); |
193 return func_index; | 208 return func_index; |
194 } | 209 } |
195 | 210 |
196 const OffsetTable &GetOffsetTable(const TransLocation *loc) { | 211 const OffsetTable& GetOffsetTable(const TransLocation* loc) { |
197 int func_index = loc->line; | 212 int func_index = loc->line; |
198 auto it = offset_tables_.find(func_index); | 213 auto it = offset_tables_.find(func_index); |
199 // TODO(clemensh): Once we load disassembly lazily, the offset table | 214 // TODO(clemensh): Once we load disassembly lazily, the offset table |
200 // might not be there yet. Load it lazily then. | 215 // might not be there yet. Load it lazily then. |
201 DCHECK(it != offset_tables_.end()); | 216 DCHECK(it != offset_tables_.end()); |
202 return it->second; | 217 return it->second; |
203 } | 218 } |
204 | 219 |
205 const OffsetTable *GetReverseTable(int func_index) { | 220 const OffsetTable* GetReverseTable(int func_index) { |
206 auto it = reverse_tables_.find(func_index); | 221 auto it = reverse_tables_.find(func_index); |
207 if (it != reverse_tables_.end()) return &it->second; | 222 if (it != reverse_tables_.end()) return &it->second; |
208 | 223 |
209 // Find offset table, copy and sort it to get reverse table. | 224 // Find offset table, copy and sort it to get reverse table. |
210 it = offset_tables_.find(func_index); | 225 it = offset_tables_.find(func_index); |
211 if (it == offset_tables_.end()) return nullptr; | 226 if (it == offset_tables_.end()) return nullptr; |
212 | 227 |
213 OffsetTable reverse_table = it->second; | 228 OffsetTable reverse_table = it->second; |
214 // Order by line, column, then byte offset. | 229 // Order by line, column, then byte offset. |
215 auto cmp = [](OffsetTable::value_type el1, OffsetTable::value_type el2) { | 230 auto cmp = [](OffsetTable::value_type el1, OffsetTable::value_type el2) { |
(...skipping 10 matching lines...) Expand all Loading... |
226 } | 241 } |
227 | 242 |
228 Global<debug::WasmScript> script_; | 243 Global<debug::WasmScript> script_; |
229 | 244 |
230 // We assume to only disassemble a subset of the functions, so store them in a | 245 // We assume to only disassemble a subset of the functions, so store them in a |
231 // map instead of an array. | 246 // map instead of an array. |
232 std::unordered_map<int, const OffsetTable> offset_tables_; | 247 std::unordered_map<int, const OffsetTable> offset_tables_; |
233 std::unordered_map<int, const OffsetTable> reverse_tables_; | 248 std::unordered_map<int, const OffsetTable> reverse_tables_; |
234 }; | 249 }; |
235 | 250 |
236 WasmTranslation::WasmTranslation(v8::Isolate *isolate) | 251 WasmTranslation::WasmTranslation(v8::Isolate* isolate) |
237 : isolate_(isolate), mode_(Disassemble) {} | 252 : isolate_(isolate), mode_(Disassemble) {} |
238 | 253 |
239 WasmTranslation::~WasmTranslation() { Clear(); } | 254 WasmTranslation::~WasmTranslation() { Clear(); } |
240 | 255 |
241 void WasmTranslation::AddScript(Local<debug::WasmScript> script, | 256 void WasmTranslation::AddScript(Local<debug::WasmScript> script, |
242 V8DebuggerAgentImpl *agent) { | 257 V8DebuggerAgentImpl* agent) { |
243 int script_id = script->Id(); | |
244 DCHECK_EQ(0, wasm_translators_.count(script_id)); | |
245 std::unique_ptr<TranslatorImpl> impl; | 258 std::unique_ptr<TranslatorImpl> impl; |
246 switch (mode_) { | 259 switch (mode_) { |
247 case Raw: | 260 case Raw: |
248 impl.reset(new TranslatorImpl::RawTranslator()); | 261 impl.reset(new TranslatorImpl::RawTranslator()); |
249 break; | 262 break; |
250 case Disassemble: | 263 case Disassemble: |
251 impl.reset(new TranslatorImpl::DisassemblingTranslator(isolate_, script, | 264 impl.reset(new TranslatorImpl::DisassemblingTranslator(isolate_, script)); |
252 this, agent)); | |
253 break; | 265 break; |
254 } | 266 } |
255 DCHECK(impl); | 267 DCHECK(impl); |
256 wasm_translators_.insert(std::make_pair(script_id, std::move(impl))); | 268 auto inserted = |
| 269 wasm_translators_.insert(std::make_pair(script->Id(), std::move(impl))); |
| 270 // Check that no mapping for this script id existed before. |
| 271 DCHECK(inserted.second); |
| 272 // impl has been moved, use the returned iterator to call Init. |
| 273 inserted.first->second->Init(isolate_, this, agent); |
257 } | 274 } |
258 | 275 |
259 void WasmTranslation::Clear() { | 276 void WasmTranslation::Clear() { |
260 wasm_translators_.clear(); | 277 wasm_translators_.clear(); |
261 fake_scripts_.clear(); | 278 fake_scripts_.clear(); |
262 } | 279 } |
263 | 280 |
264 // Translation "forward" (to artificial scripts). | 281 // Translation "forward" (to artificial scripts). |
265 bool WasmTranslation::TranslateWasmScriptLocationToProtocolLocation( | 282 bool WasmTranslation::TranslateWasmScriptLocationToProtocolLocation( |
266 String16 *script_id, int *line_number, int *column_number) { | 283 String16* script_id, int* line_number, int* column_number) { |
267 DCHECK(script_id && line_number && column_number); | 284 DCHECK(script_id && line_number && column_number); |
268 bool ok = true; | 285 bool ok = true; |
269 int script_id_int = script_id->toInteger(&ok); | 286 int script_id_int = script_id->toInteger(&ok); |
270 if (!ok) return false; | 287 if (!ok) return false; |
271 | 288 |
272 auto it = wasm_translators_.find(script_id_int); | 289 auto it = wasm_translators_.find(script_id_int); |
273 if (it == wasm_translators_.end()) return false; | 290 if (it == wasm_translators_.end()) return false; |
274 TranslatorImpl *translator = it->second.get(); | 291 TranslatorImpl* translator = it->second.get(); |
275 | 292 |
276 TranslatorImpl::TransLocation trans_loc(this, std::move(*script_id), | 293 TranslatorImpl::TransLocation trans_loc(this, std::move(*script_id), |
277 *line_number, *column_number); | 294 *line_number, *column_number); |
278 translator->Translate(&trans_loc); | 295 translator->Translate(&trans_loc); |
279 | 296 |
280 *script_id = std::move(trans_loc.script_id); | 297 *script_id = std::move(trans_loc.script_id); |
281 *line_number = trans_loc.line; | 298 *line_number = trans_loc.line; |
282 *column_number = trans_loc.column; | 299 *column_number = trans_loc.column; |
283 | 300 |
284 return true; | 301 return true; |
285 } | 302 } |
286 | 303 |
287 // Translation "backward" (from artificial to real scripts). | 304 // Translation "backward" (from artificial to real scripts). |
288 bool WasmTranslation::TranslateProtocolLocationToWasmScriptLocation( | 305 bool WasmTranslation::TranslateProtocolLocationToWasmScriptLocation( |
289 String16 *script_id, int *line_number, int *column_number) { | 306 String16* script_id, int* line_number, int* column_number) { |
290 auto it = fake_scripts_.find(*script_id); | 307 auto it = fake_scripts_.find(*script_id); |
291 if (it == fake_scripts_.end()) return false; | 308 if (it == fake_scripts_.end()) return false; |
292 TranslatorImpl *translator = it->second; | 309 TranslatorImpl* translator = it->second; |
293 | 310 |
294 TranslatorImpl::TransLocation trans_loc(this, std::move(*script_id), | 311 TranslatorImpl::TransLocation trans_loc(this, std::move(*script_id), |
295 *line_number, *column_number); | 312 *line_number, *column_number); |
296 translator->TranslateBack(&trans_loc); | 313 translator->TranslateBack(&trans_loc); |
297 | 314 |
298 *script_id = std::move(trans_loc.script_id); | 315 *script_id = std::move(trans_loc.script_id); |
299 *line_number = trans_loc.line; | 316 *line_number = trans_loc.line; |
300 *column_number = trans_loc.column; | 317 *column_number = trans_loc.column; |
301 | 318 |
302 return true; | 319 return true; |
303 } | 320 } |
304 | 321 |
305 void WasmTranslation::AddFakeScript(const String16 &scriptId, | 322 void WasmTranslation::AddFakeScript(const String16& scriptId, |
306 TranslatorImpl *translator) { | 323 TranslatorImpl* translator) { |
307 DCHECK_EQ(0, fake_scripts_.count(scriptId)); | 324 DCHECK_EQ(0, fake_scripts_.count(scriptId)); |
308 fake_scripts_.insert(std::make_pair(scriptId, translator)); | 325 fake_scripts_.insert(std::make_pair(scriptId, translator)); |
309 } | 326 } |
OLD | NEW |