diff options
author | Sam Clegg <sbc@chromium.org> | 2017-06-07 10:30:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 10:30:29 -0700 |
commit | 7ecfe0be4037139224a44bca854c7e0ecb9aec8c (patch) | |
tree | c31437572957dce465894207ac9a5c5b53f7133d | |
parent | b7b892e7514c188c90bbb8681e157a01f5c8e2d6 (diff) | |
download | wabt-7ecfe0be4037139224a44bca854c7e0ecb9aec8c.tar.gz wabt-7ecfe0be4037139224a44bca854c7e0ecb9aec8c.tar.bz2 wabt-7ecfe0be4037139224a44bca854c7e0ecb9aec8c.zip |
[objdump] Be more explict about type and element indexes (#481)
-rw-r--r-- | src/binary-reader-ir.cc | 6 | ||||
-rw-r--r-- | src/binary-reader-objdump.cc | 14 | ||||
-rw-r--r-- | src/binary-reader.h | 3 | ||||
-rw-r--r-- | test/dump/debug-import-names.txt | 2 | ||||
-rw-r--r-- | test/dump/debug-names.txt | 4 | ||||
-rw-r--r-- | test/dump/import.txt | 4 | ||||
-rw-r--r-- | test/dump/start.txt | 2 | ||||
-rw-r--r-- | test/dump/table.txt | 14 | ||||
-rw-r--r-- | test/link/export.txt | 4 | ||||
-rw-r--r-- | test/link/function_calls.txt | 8 | ||||
-rw-r--r-- | test/link/function_calls_incremental.txt | 12 | ||||
-rw-r--r-- | test/link/globals.txt | 4 | ||||
-rw-r--r-- | test/link/incremental.txt | 26 | ||||
-rw-r--r-- | test/link/interp.txt | 10 | ||||
-rw-r--r-- | test/link/large_code_section.txt | 2 | ||||
-rw-r--r-- | test/link/names.txt | 8 | ||||
-rw-r--r-- | test/link/names_import_only.txt | 2 | ||||
-rw-r--r-- | test/link/names_import_only_module_env.txt | 2 | ||||
-rw-r--r-- | test/link/table.txt | 18 |
19 files changed, 75 insertions, 70 deletions
diff --git a/src/binary-reader-ir.cc b/src/binary-reader-ir.cc index 3c547dbe..b741244d 100644 --- a/src/binary-reader-ir.cc +++ b/src/binary-reader-ir.cc @@ -756,10 +756,10 @@ Result BinaryReaderIR::OnElemSegmentFunctionIndexCount(Index index, return Result::Ok; } -Result BinaryReaderIR::OnElemSegmentFunctionIndex(Index index, +Result BinaryReaderIR::OnElemSegmentFunctionIndex(Index segment_index, Index func_index) { - assert(index == module->elem_segments.size() - 1); - ElemSegment* segment = module->elem_segments[index]; + assert(segment_index == module->elem_segments.size() - 1); + ElemSegment* segment = module->elem_segments[segment_index]; segment->vars.emplace_back(); Var* var = &segment->vars.back(); var->type = VarType::Index; diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 71c42961..f80248ba 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -463,8 +463,8 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase { Result OnElemSegmentCount(Index count) override; Result BeginElemSegment(Index index, Index table_index) override; - Result OnElemSegmentFunctionIndex(Index index, - Index func_index) override; + Result OnElemSegmentFunctionIndex(Index segment_index, + Index func_index) override; Result OnDataSegmentCount(Index count) override; Result BeginDataSegment(Index index, Index memory_index) override; @@ -498,6 +498,7 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase { Result OnCount(Index count); std::unique_ptr<FileStream> out_stream_; + Index elem_index_ = 0; }; BinaryReaderObjdump::BinaryReaderObjdump(const uint8_t* data, @@ -601,7 +602,7 @@ Result BinaryReaderObjdump::OnType(Index index, Type* result_types) { if (!ShouldPrintDetails()) return Result::Ok; - printf(" - [%" PRIindex "] (", index); + printf(" - type[%" PRIindex "] (", index); for (Index i = 0; i < param_count; i++) { if (i != 0) { printf(", "); @@ -747,12 +748,14 @@ Result BinaryReaderObjdump::OnExport(Index index, return Result::Ok; } -Result BinaryReaderObjdump::OnElemSegmentFunctionIndex(Index index, +Result BinaryReaderObjdump::OnElemSegmentFunctionIndex(Index segment_index, Index func_index) { - PrintDetails(" - func[%" PRIindex "]", func_index); + PrintDetails(" - elem[%" PRIindex "] = func[%" PRIindex "]", elem_index_, + func_index); if (const char* name = GetFunctionName(func_index)) PrintDetails(" <%s>", name); PrintDetails("\n"); + elem_index_++; return Result::Ok; } @@ -763,6 +766,7 @@ Result BinaryReaderObjdump::OnElemSegmentCount(Index count) { Result BinaryReaderObjdump::BeginElemSegment(Index index, Index table_index) { PrintDetails(" - segment[%" PRIindex "] table=%" PRIindex "\n", index, table_index); + elem_index_ = 0; return Result::Ok; } diff --git a/src/binary-reader.h b/src/binary-reader.h index 63eb7153..2c72f6d8 100644 --- a/src/binary-reader.h +++ b/src/binary-reader.h @@ -212,7 +212,8 @@ class BinaryReaderDelegate { virtual Result BeginElemSegmentInitExpr(Index index) = 0; virtual Result EndElemSegmentInitExpr(Index index) = 0; virtual Result OnElemSegmentFunctionIndexCount(Index index, Index count) = 0; - virtual Result OnElemSegmentFunctionIndex(Index index, Index func_index) = 0; + virtual Result OnElemSegmentFunctionIndex(Index segment_index, + Index func_index) = 0; virtual Result EndElemSegment(Index index) = 0; virtual Result EndElemSection() = 0; diff --git a/test/dump/debug-import-names.txt b/test/dump/debug-import-names.txt index 850b62bf..26d952f8 100644 --- a/test/dump/debug-import-names.txt +++ b/test/dump/debug-import-names.txt @@ -57,7 +57,7 @@ Sections: Section Details: Type: - - [0] () -> nil + - type[0] () -> nil Import: - func[0] sig=0 <foo> <- bar.foo Custom: diff --git a/test/dump/debug-names.txt b/test/dump/debug-names.txt index c2554811..949d3f9f 100644 --- a/test/dump/debug-names.txt +++ b/test/dump/debug-names.txt @@ -124,8 +124,8 @@ debug-names.wasm: file format wasm 0x1 Section Details: Type: - - [0] (i32) -> nil - - [1] (f32) -> nil + - type[0] (i32) -> nil + - type[1] (f32) -> nil Function: - func[0] sig=0 <F1> - func[1] sig=1 diff --git a/test/dump/import.txt b/test/dump/import.txt index 9de3be00..1b025590 100644 --- a/test/dump/import.txt +++ b/test/dump/import.txt @@ -50,8 +50,8 @@ import.wasm: file format wasm 0x1 Section Details: Type: - - [0] (i32, i64, f32, f64) -> nil - - [1] (i32) -> i32 + - type[0] (i32, i64, f32, f64) -> nil + - type[1] (i32) -> i32 Import: - func[0] sig=0 <- ignored.test - func[1] sig=1 <- ignored.test2 diff --git a/test/dump/start.txt b/test/dump/start.txt index db2fa79f..dd34ac06 100644 --- a/test/dump/start.txt +++ b/test/dump/start.txt @@ -63,7 +63,7 @@ Sections: Section Details: Type: - - [0] () -> nil + - type[0] () -> nil Function: - func[0] sig=0 - func[1] sig=0 diff --git a/test/dump/table.txt b/test/dump/table.txt index 9ce1bb72..2fe4d9f9 100644 --- a/test/dump/table.txt +++ b/test/dump/table.txt @@ -92,9 +92,9 @@ table.wasm: file format wasm 0x1 Section Details: Type: - - [0] (i32) -> nil - - [1] (i32, i64) -> nil - - [2] () -> f64 + - type[0] (i32) -> nil + - type[1] (i32, i64) -> nil + - type[2] () -> f64 Function: - func[0] sig=0 - func[1] sig=1 @@ -104,10 +104,10 @@ Table: Elem: - segment[0] table=0 - init i32=0 - - func[0] - - func[0] - - func[1] - - func[2] + - elem[0] = func[0] + - elem[1] = func[0] + - elem[2] = func[1] + - elem[3] = func[2] Code Disassembly: diff --git a/test/link/export.txt b/test/link/export.txt index fd5bca28..a41fc426 100644 --- a/test/link/export.txt +++ b/test/link/export.txt @@ -27,8 +27,8 @@ Sections: Section Details: Type: - - [0] (i32) -> nil - - [1] (i32) -> nil + - type[0] (i32) -> nil + - type[1] (i32) -> nil Function: - func[0] sig=0 - func[1] sig=1 diff --git a/test/link/function_calls.txt b/test/link/function_calls.txt index e6993c27..d1f75359 100644 --- a/test/link/function_calls.txt +++ b/test/link/function_calls.txt @@ -35,10 +35,10 @@ Sections: Section Details: Type: - - [0] (i32) -> i32 - - [1] (i32) -> nil - - [2] (f64) -> nil - - [3] (i64) -> nil + - type[0] (i32) -> i32 + - type[1] (i32) -> nil + - type[2] (f64) -> nil + - type[3] (i64) -> nil Import: - func[0] sig=0 <import1> <- __extern.bar - func[1] sig=2 <m2_import0> <- __extern.baz diff --git a/test/link/function_calls_incremental.txt b/test/link/function_calls_incremental.txt index b7825a6a..47bda37a 100644 --- a/test/link/function_calls_incremental.txt +++ b/test/link/function_calls_incremental.txt @@ -38,12 +38,12 @@ Sections: Section Details: Type: - - [0] (i32) -> i32 - - [1] (i32) -> nil - - [2] (f64) -> nil - - [3] (i64) -> nil - - [4] (f32) -> nil - - [5] (i32) -> nil + - type[0] (i32) -> i32 + - type[1] (i32) -> nil + - type[2] (f64) -> nil + - type[3] (i64) -> nil + - type[4] (f32) -> nil + - type[5] (i32) -> nil Import: - func[0] sig=0 <- __extern.bar - func[1] sig=2 <- __extern.does_nothing diff --git a/test/link/globals.txt b/test/link/globals.txt index b0676cbb..3c468c95 100644 --- a/test/link/globals.txt +++ b/test/link/globals.txt @@ -36,8 +36,8 @@ Sections: Section Details: Type: - - [0] (i32) -> nil - - [1] (i64, i64) -> nil + - type[0] (i32) -> nil + - type[1] (i64, i64) -> nil Import: - global[0] i32 mutable=0 <- __extern.bar - global[1] i64 mutable=0 <- __extern.baz diff --git a/test/link/incremental.txt b/test/link/incremental.txt index 7bc8ff6d..bca82d07 100644 --- a/test/link/incremental.txt +++ b/test/link/incremental.txt @@ -45,12 +45,12 @@ Sections: Section Details: Type: - - [0] (i32) -> i32 - - [1] (i32) -> nil - - [2] (f64) -> nil - - [3] (i64) -> nil - - [4] (f32) -> nil - - [5] (i32) -> nil + - type[0] (i32) -> i32 + - type[1] (i32) -> nil + - type[2] (f64) -> nil + - type[3] (i64) -> nil + - type[4] (f32) -> nil + - type[5] (i32) -> nil Import: - func[0] sig=0 <- __extern.bar - func[1] sig=2 <- __extern.does_nothing @@ -64,13 +64,13 @@ Table: Elem: - segment[0] table=0 - init i32=0 - - func[3] <func1> - - func[3] <func1> - - func[3] <func1> - - func[4] <func2> - - func[4] <func2> - - func[5] <func3> - - func[5] <func3> + - elem[0] = func[3] <func1> + - elem[1] = func[3] <func1> + - elem[2] = func[3] <func1> + - elem[3] = func[4] <func2> + - elem[4] = func[4] <func2> + - elem[5] = func[5] <func3> + - elem[6] = func[5] <func3> Custom: - name: "name" - func[3] func1 diff --git a/test/link/interp.txt b/test/link/interp.txt index 7cbe87c4..ab850b40 100644 --- a/test/link/interp.txt +++ b/test/link/interp.txt @@ -57,11 +57,11 @@ Sections: Section Details: Type: - - [0] () -> i32 - - [1] () -> i64 - - [2] () -> f32 - - [3] () -> i32 - - [4] () -> i64 + - type[0] () -> i32 + - type[1] () -> i64 + - type[2] () -> f32 + - type[3] () -> i32 + - type[4] () -> i64 Import: Function: - func[0] sig=2 <export1> diff --git a/test/link/large_code_section.txt b/test/link/large_code_section.txt index 01d31844..c35a8a51 100644 --- a/test/link/large_code_section.txt +++ b/test/link/large_code_section.txt @@ -84,7 +84,7 @@ Sections: Section Details: Type: - - [0] (i32) -> nil + - type[0] (i32) -> nil Function: - func[0] sig=0 <local_func> Custom: diff --git a/test/link/names.txt b/test/link/names.txt index 37f22682..cb4979d6 100644 --- a/test/link/names.txt +++ b/test/link/names.txt @@ -37,10 +37,10 @@ Sections: Section Details: Type: - - [0] () -> nil - - [1] (i32) -> nil - - [2] (i64) -> nil - - [3] (i32) -> nil + - type[0] () -> nil + - type[1] (i32) -> nil + - type[2] (i64) -> nil + - type[3] (i32) -> nil Import: - func[0] sig=0 <import_func0> <- __extern.missing0 - func[1] sig=0 <- _extern1.missing1 diff --git a/test/link/names_import_only.txt b/test/link/names_import_only.txt index 0648d171..bcd13aea 100644 --- a/test/link/names_import_only.txt +++ b/test/link/names_import_only.txt @@ -16,7 +16,7 @@ Sections: Section Details: Type: - - [0] () -> nil + - type[0] () -> nil Import: - func[0] sig=0 <import_func1> <- __extern.baz Custom: diff --git a/test/link/names_import_only_module_env.txt b/test/link/names_import_only_module_env.txt index a2f9166c..a84ae96c 100644 --- a/test/link/names_import_only_module_env.txt +++ b/test/link/names_import_only_module_env.txt @@ -16,7 +16,7 @@ Sections: Section Details: Type: - - [0] () -> nil + - type[0] () -> nil Import: - func[0] sig=0 <import_func1> <- env.baz Custom: diff --git a/test/link/table.txt b/test/link/table.txt index 0d99a850..38340962 100644 --- a/test/link/table.txt +++ b/test/link/table.txt @@ -32,10 +32,10 @@ Sections: Section Details: Type: - - [0] (i32) -> nil - - [1] (i64) -> nil - - [2] (f64) -> nil - - [3] () -> nil + - type[0] (i32) -> nil + - type[1] (i64) -> nil + - type[2] (f64) -> nil + - type[3] () -> nil Function: - func[0] sig=0 <func1> - func[1] sig=1 <func2> @@ -46,11 +46,11 @@ Table: Elem: - segment[0] table=0 - init i32=0 - - func[0] <func1> - - func[0] <func1> - - func[2] <func3> - - func[1] <func2> - - func[1] <func2> + - elem[0] = func[0] <func1> + - elem[1] = func[0] <func1> + - elem[2] = func[2] <func3> + - elem[3] = func[1] <func2> + - elem[4] = func[1] <func2> Custom: - name: "name" - func[0] func1 |