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

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

Issue 2526783002: [base] Define CHECK comparison for signed vs. unsigned (Closed)
Patch Set: Rebase & refactor for windows 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
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/assert-scope.h" 5 #include "src/assert-scope.h"
6 #include "src/debug/debug.h" 6 #include "src/debug/debug.h"
7 #include "src/factory.h" 7 #include "src/factory.h"
8 #include "src/isolate.h" 8 #include "src/isolate.h"
9 #include "src/wasm/module-decoder.h" 9 #include "src/wasm/module-decoder.h"
10 #include "src/wasm/wasm-module.h" 10 #include "src/wasm/wasm-module.h"
(...skipping 29 matching lines...) Expand all
40 { 40 {
41 Handle<ByteArray> asm_offset_tables = 41 Handle<ByteArray> asm_offset_tables =
42 compiled_module->asm_js_offset_tables(); 42 compiled_module->asm_js_offset_tables();
43 DisallowHeapAllocation no_gc; 43 DisallowHeapAllocation no_gc;
44 const byte *bytes_start = asm_offset_tables->GetDataStartAddress(); 44 const byte *bytes_start = asm_offset_tables->GetDataStartAddress();
45 const byte *bytes_end = bytes_start + asm_offset_tables->length(); 45 const byte *bytes_end = bytes_start + asm_offset_tables->length();
46 asm_offsets = wasm::DecodeAsmJsOffsets(bytes_start, bytes_end); 46 asm_offsets = wasm::DecodeAsmJsOffsets(bytes_start, bytes_end);
47 } 47 }
48 // Wasm bytes must be valid and must contain asm.js offset table. 48 // Wasm bytes must be valid and must contain asm.js offset table.
49 DCHECK(asm_offsets.ok()); 49 DCHECK(asm_offsets.ok());
50 DCHECK_GE(static_cast<size_t>(kMaxInt), asm_offsets.val.size()); 50 DCHECK_GE(kMaxInt, asm_offsets.val.size());
51 int num_functions = static_cast<int>(asm_offsets.val.size()); 51 int num_functions = static_cast<int>(asm_offsets.val.size());
52 DCHECK_EQ( 52 DCHECK_EQ(wasm::GetNumberOfFunctions(handle(debug_info->wasm_instance())),
53 wasm::GetNumberOfFunctions(handle(debug_info->wasm_instance())), 53 num_functions + compiled_module->module()->num_imported_functions);
54 static_cast<int>(num_functions +
55 compiled_module->module()->num_imported_functions));
56 Handle<FixedArray> all_tables = 54 Handle<FixedArray> all_tables =
57 isolate->factory()->NewFixedArray(num_functions); 55 isolate->factory()->NewFixedArray(num_functions);
58 debug_info->set(kWasmDebugInfoAsmJsOffsets, *all_tables); 56 debug_info->set(kWasmDebugInfoAsmJsOffsets, *all_tables);
59 for (int func = 0; func < num_functions; ++func) { 57 for (int func = 0; func < num_functions; ++func) {
60 std::vector<std::pair<int, int>> &func_asm_offsets = asm_offsets.val[func]; 58 std::vector<std::pair<int, int>> &func_asm_offsets = asm_offsets.val[func];
61 if (func_asm_offsets.empty()) continue; 59 if (func_asm_offsets.empty()) continue;
62 size_t array_size = 2 * kIntSize * func_asm_offsets.size(); 60 size_t array_size = 2 * kIntSize * func_asm_offsets.size();
63 CHECK_LE(array_size, static_cast<size_t>(kMaxInt)); 61 CHECK_LE(array_size, kMaxInt);
64 ByteArray *arr = 62 ByteArray *arr =
65 *isolate->factory()->NewByteArray(static_cast<int>(array_size)); 63 *isolate->factory()->NewByteArray(static_cast<int>(array_size));
66 all_tables->set(func, arr); 64 all_tables->set(func, arr);
67 int idx = 0; 65 int idx = 0;
68 for (std::pair<int, int> p : func_asm_offsets) { 66 for (std::pair<int, int> p : func_asm_offsets) {
69 // Byte offsets must be strictly monotonously increasing: 67 // Byte offsets must be strictly monotonously increasing:
70 DCHECK(idx == 0 || p.first > arr->get_int(idx - 2)); 68 DCHECK(idx == 0 || p.first > arr->get_int(idx - 2));
71 arr->set_int(idx++, p.first); 69 arr->set_int(idx++, p.first);
72 arr->set_int(idx++, p.second); 70 arr->set_int(idx++, p.second);
73 } 71 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 left = mid; 136 left = mid;
139 } else { 137 } else {
140 right = mid; 138 right = mid;
141 } 139 }
142 } 140 }
143 // There should be an entry for each position that could show up on the stack 141 // There should be an entry for each position that could show up on the stack
144 // trace: 142 // trace:
145 DCHECK_EQ(byte_offset, offset_table->get_int(2 * left)); 143 DCHECK_EQ(byte_offset, offset_table->get_int(2 * left));
146 return offset_table->get_int(2 * left + 1); 144 return offset_table->get_int(2 * left + 1);
147 } 145 }
OLDNEW
« src/base/logging.h ('K') | « src/wasm/ast-decoder.cc ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698