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

Unified Diff: src/wasm/function-body-decoder.cc

Issue 2657443003: [wasm] Fix the --wasm_code_fuzzer_gen_test again. (Closed)
Patch Set: Created 3 years, 11 months 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
« no previous file with comments | « src/wasm/function-body-decoder.h ('k') | test/fuzzer/wasm-code.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/function-body-decoder.cc
diff --git a/src/wasm/function-body-decoder.cc b/src/wasm/function-body-decoder.cc
index 00612b8fde5ef0ccce3eb1b072a18e2f9ef0b2cb..6f8e24ca370a4419b3492ddbeece57359a0405db 100644
--- a/src/wasm/function-body-decoder.cc
+++ b/src/wasm/function-body-decoder.cc
@@ -1881,14 +1881,25 @@ unsigned OpcodeLength(const byte* pc, const byte* end) {
void PrintWasmCodeForDebugging(const byte* start, const byte* end) {
AccountingAllocator allocator;
- OFStream os(stdout);
- PrintWasmCode(&allocator, FunctionBodyForTesting(start, end), nullptr, os,
- nullptr);
+ PrintWasmCode(&allocator, FunctionBodyForTesting(start, end), nullptr, true);
+}
+
+const char* OpcodeNameForDebugging(WasmOpcode opcode) {
titzer 2017/01/25 10:31:06 RawOpcodeName?
ahaas 2017/01/25 13:12:10 Done.
+ switch (opcode) {
+#define DECLARE_NAME_CASE(name, opcode, sig) \
+ case kExpr##name: \
+ return "kExpr" #name;
+ FOREACH_OPCODE(DECLARE_NAME_CASE)
+#undef DECLARE_NAME_CASE
+ default:
+ break;
+ }
+ return "Unknown";
}
bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
titzer 2017/01/25 10:31:06 I'd be OK with just renaming this method to PrintR
ahaas 2017/01/25 13:12:10 Done.
- const wasm::WasmModule* module, std::ostream& os,
- std::vector<std::tuple<uint32_t, int, int>>* offset_table) {
+ const wasm::WasmModule* module, bool for_debugging) {
+ OFStream os(stdout);
Zone zone(allocator, ZONE_NAME);
WasmFullDecoder decoder(&zone, module, body);
int line_nr = 0;
@@ -1937,16 +1948,17 @@ bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
if (opcode == kExprElse) control_depth--;
int num_whitespaces = control_depth < 32 ? 2 * control_depth : 64;
- if (offset_table) {
- offset_table->push_back(
- std::make_tuple(i.pc_offset(), line_nr, num_whitespaces));
- }
// 64 whitespaces
const char* padding =
" ";
os.write(padding, num_whitespaces);
- os << "k" << WasmOpcodes::OpcodeName(opcode) << ",";
+
+ if (for_debugging) {
+ os << OpcodeNameForDebugging(opcode) << ",";
+ } else {
+ os << "k" << WasmOpcodes::OpcodeName(opcode) << ",";
Clemens Hammacher 2017/01/24 18:51:02 Why is this outputting a "k" in front of the new o
titzer 2017/01/25 10:31:06 Right, the k shouldn't be necessary.
ahaas 2017/01/25 13:12:10 As suggested I changed the output to os << Raw
+ }
for (size_t j = 1; j < length; ++j) {
os << " 0x" << AsHex(i.pc()[j], 2) << ",";
« no previous file with comments | « src/wasm/function-body-decoder.h ('k') | test/fuzzer/wasm-code.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698