| 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" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 auto& entry = (*reverse_table)[mid]; | 116 auto& entry = (*reverse_table)[mid]; |
| 117 if (entry.line < loc->line || | 117 if (entry.line < loc->line || |
| 118 (entry.line == loc->line && entry.column <= loc->column)) { | 118 (entry.line == loc->line && entry.column <= loc->column)) { |
| 119 left = mid; | 119 left = mid; |
| 120 } else { | 120 } else { |
| 121 right = mid; | 121 right = mid; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 int found_byte_offset = 0; | 125 int found_byte_offset = 0; |
| 126 // If we found an exact match, use it. Otherwise check whether the next | 126 // [left] is <= <line,column>, or left==0 and [0] > <line,column>. |
| 127 // bigger entry is still in the same line. Report that one then. | 127 // We are searching for the smallest entry >= <line,column> which is still |
| 128 // Otherwise we might have hit the special case of pointing after the last | 128 // on the same line. This must be either [left] or [left + 1]. |
| 129 // line, which is translated to the end of the function (one byte after the | 129 // If we don't find such an entry, we might have hit the special case of |
| 130 // last function byte). | 130 // pointing after the last line, which is translated to the end of the |
| 131 // function (one byte after the last function byte). |
| 131 if ((*reverse_table)[left].line == loc->line && | 132 if ((*reverse_table)[left].line == loc->line && |
| 132 (*reverse_table)[left].column == loc->column) { | 133 (*reverse_table)[left].column >= loc->column) { |
| 133 found_byte_offset = (*reverse_table)[left].byte_offset; | 134 found_byte_offset = (*reverse_table)[left].byte_offset; |
| 134 } else if (left + 1 < reverse_table->size() && | 135 } else if (left + 1 < reverse_table->size() && |
| 135 (*reverse_table)[left + 1].line == loc->line) { | 136 (*reverse_table)[left + 1].line == loc->line && |
| 137 (*reverse_table)[left + 1].column >= loc->column) { |
| 136 found_byte_offset = (*reverse_table)[left + 1].byte_offset; | 138 found_byte_offset = (*reverse_table)[left + 1].byte_offset; |
| 137 } else if (left == reverse_table->size() - 1 && | 139 } else if (left == reverse_table->size() - 1 && |
| 138 (*reverse_table)[left].line == loc->line - 1 && | 140 (*reverse_table)[left].line == loc->line - 1 && |
| 139 loc->column == 0) { | 141 loc->column == 0) { |
| 140 std::pair<int, int> func_range = | 142 std::pair<int, int> func_range = |
| 141 script_.Get(isolate)->GetFunctionRange(func_index); | 143 script_.Get(isolate)->GetFunctionRange(func_index); |
| 142 DCHECK_LE(func_range.first, func_range.second); | 144 DCHECK_LE(func_range.first, func_range.second); |
| 143 found_byte_offset = func_range.second - func_range.first; | 145 found_byte_offset = func_range.second - func_range.first; |
| 144 } | 146 } |
| 145 | 147 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 *column_number = trans_loc.column; | 320 *column_number = trans_loc.column; |
| 319 | 321 |
| 320 return true; | 322 return true; |
| 321 } | 323 } |
| 322 | 324 |
| 323 void WasmTranslation::AddFakeScript(const String16& scriptId, | 325 void WasmTranslation::AddFakeScript(const String16& scriptId, |
| 324 TranslatorImpl* translator) { | 326 TranslatorImpl* translator) { |
| 325 DCHECK_EQ(0, fake_scripts_.count(scriptId)); | 327 DCHECK_EQ(0, fake_scripts_.count(scriptId)); |
| 326 fake_scripts_.insert(std::make_pair(scriptId, translator)); | 328 fake_scripts_.insert(std::make_pair(scriptId, translator)); |
| 327 } | 329 } |
| OLD | NEW |