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

Unified Diff: src/wasm/wasm-objects.cc

Issue 2555243002: [wasm] Fix location for error in asm.js ToNumber conversion (Closed)
Patch Set: No need to store parent in VisitCall 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 side-by-side diff with in-line comments
Download patch
Index: src/wasm/wasm-objects.cc
diff --git a/src/wasm/wasm-objects.cc b/src/wasm/wasm-objects.cc
index feddfaf2d27b7498a347646b221d157e9307149d..3cc5a2acdea21e3a0537bf4b0dc1c1d236fd9a29 100644
--- a/src/wasm/wasm-objects.cc
+++ b/src/wasm/wasm-objects.cc
@@ -488,13 +488,15 @@ Handle<ByteArray> GetDecodedAsmJsOffsetTable(
static_cast<int>(compiled_module->module()->num_imported_functions);
DCHECK_EQ(compiled_module->module()->functions.size(),
static_cast<size_t>(num_functions) + num_imported_functions);
- // One byte to encode that this is a decoded table.
- int total_size = 1;
+ int num_entries = 0;
for (int func = 0; func < num_functions; ++func) {
- size_t new_size = asm_offsets.val[func].size() * 2 * kIntSize;
- DCHECK_LE(new_size, static_cast<size_t>(kMaxInt) - total_size);
- total_size += static_cast<int>(new_size);
+ size_t new_size = asm_offsets.val[func].size();
+ DCHECK_LE(new_size, static_cast<size_t>(kMaxInt) - num_entries);
+ num_entries += static_cast<int>(new_size);
}
+ // One byte to encode that this is a decoded table.
+ DCHECK_GE(kMaxInt, 1 + static_cast<uint64_t>(num_entries) * 3 * kIntSize);
+ int total_size = 1 + num_entries * 3 * kIntSize;
Handle<ByteArray> decoded_table =
isolate->factory()->NewByteArray(total_size, TENURED);
decoded_table->set(total_size - 1, AsmJsTableType::Decoded);
@@ -503,16 +505,17 @@ Handle<ByteArray> GetDecodedAsmJsOffsetTable(
int idx = 0;
std::vector<WasmFunction>& wasm_funs = compiled_module->module()->functions;
for (int func = 0; func < num_functions; ++func) {
- std::vector<std::pair<int, int>>& func_asm_offsets = asm_offsets.val[func];
+ std::vector<AsmJsOffsetEntry>& func_asm_offsets = asm_offsets.val[func];
if (func_asm_offsets.empty()) continue;
int func_offset =
wasm_funs[num_imported_functions + func].code_start_offset;
- for (std::pair<int, int> p : func_asm_offsets) {
+ for (AsmJsOffsetEntry& e : func_asm_offsets) {
// Byte offsets must be strictly monotonously increasing:
DCHECK(idx == 0 ||
- func_offset + p.first > decoded_table->get_int(idx - 2));
- decoded_table->set_int(idx++, func_offset + p.first);
- decoded_table->set_int(idx++, p.second);
+ func_offset + e.byte_offset > decoded_table->get_int(idx - 3));
+ decoded_table->set_int(idx++, func_offset + e.byte_offset);
+ decoded_table->set_int(idx++, e.source_position_call);
+ decoded_table->set_int(idx++, e.source_position_number_conversion);
}
}
DCHECK_EQ(total_size, idx * kIntSize + 1);
@@ -522,7 +525,7 @@ Handle<ByteArray> GetDecodedAsmJsOffsetTable(
int WasmCompiledModule::GetAsmJsSourcePosition(
Handle<WasmCompiledModule> compiled_module, uint32_t func_index,
- uint32_t byte_offset) {
+ uint32_t byte_offset, bool is_at_number_conversion) {
Isolate* isolate = compiled_module->GetIsolate();
Handle<ByteArray> offset_table =
GetDecodedAsmJsOffsetTable(compiled_module, isolate);
@@ -534,11 +537,11 @@ int WasmCompiledModule::GetAsmJsSourcePosition(
// Binary search for the total byte offset.
int left = 0; // inclusive
- int right = offset_table->length() / kIntSize / 2; // exclusive
+ int right = offset_table->length() / kIntSize / 3; // exclusive
bradnelson 2016/12/07 19:19:06 At the point you've got 3 fields, maybe have an en
Clemens Hammacher 2016/12/08 10:50:23 Cool idea, done!
DCHECK_LT(left, right);
while (right - left > 1) {
int mid = left + (right - left) / 2;
- int mid_entry = offset_table->get_int(2 * mid);
+ int mid_entry = offset_table->get_int(3 * mid);
DCHECK_GE(kMaxInt, mid_entry);
if (static_cast<uint32_t>(mid_entry) <= total_offset) {
left = mid;
@@ -549,8 +552,8 @@ int WasmCompiledModule::GetAsmJsSourcePosition(
// There should be an entry for each position that could show up on the stack
// trace:
DCHECK_EQ(total_offset,
- static_cast<uint32_t>(offset_table->get_int(2 * left)));
- return offset_table->get_int(2 * left + 1);
+ static_cast<uint32_t>(offset_table->get_int(3 * left)));
+ return offset_table->get_int(3 * left + (is_at_number_conversion ? 2 : 1));
}
v8::debug::WasmDisassembly WasmCompiledModule::DisassembleFunction(

Powered by Google App Engine
This is Rietveld 408576698