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/wasm/wasm-debug.h" | 5 #include "src/wasm/wasm-debug.h" |
6 | 6 |
7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 296 |
297 DCHECK_LT(func_index, offset_tables->length()); | 297 DCHECK_LT(func_index, offset_tables->length()); |
298 ByteArray *offset_table = ByteArray::cast(offset_tables->get(func_index)); | 298 ByteArray *offset_table = ByteArray::cast(offset_tables->get(func_index)); |
299 | 299 |
300 // Binary search for the current byte offset. | 300 // Binary search for the current byte offset. |
301 int left = 0; // inclusive | 301 int left = 0; // inclusive |
302 int right = offset_table->length() / kIntSize / 2; // exclusive | 302 int right = offset_table->length() / kIntSize / 2; // exclusive |
303 DCHECK_LT(left, right); | 303 DCHECK_LT(left, right); |
304 while (right - left > 1) { | 304 while (right - left > 1) { |
305 int mid = left + (right - left) / 2; | 305 int mid = left + (right - left) / 2; |
306 if (offset_table->get_int(2 * mid) < byte_offset) { | 306 if (offset_table->get_int(2 * mid) <= byte_offset) { |
307 left = mid; | 307 left = mid; |
308 } else { | 308 } else { |
309 right = mid; | 309 right = mid; |
310 } | 310 } |
311 } | 311 } |
312 // There should be an entry for each position that could show up on the stack | 312 // There should be an entry for each position that could show up on the stack |
313 // trace: | 313 // trace: |
314 DCHECK_EQ(byte_offset, offset_table->get_int(2 * left)); | 314 DCHECK_EQ(byte_offset, offset_table->get_int(2 * left)); |
315 return offset_table->get_int(2 * left + 1); | 315 return offset_table->get_int(2 * left + 1); |
316 } | 316 } |
OLD | NEW |