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

Side by Side Diff: src/wasm/wasm-debug.cc

Issue 2448833004: [wasm] Fix binary search for asm.js offsets (Closed)
Patch Set: Created 4 years, 1 month 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 | test/mjsunit/wasm/asm-wasm-stack.js » ('j') | 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/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
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 }
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/asm-wasm-stack.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698