Index: src/wasm/wasm-objects.cc |
diff --git a/src/wasm/wasm-objects.cc b/src/wasm/wasm-objects.cc |
index 0b3748b64c4f59aeb0ac6239e4051ea7d293cda3..f51fae3bd1187d054f70e93d302b4277a00c2805 100644 |
--- a/src/wasm/wasm-objects.cc |
+++ b/src/wasm/wasm-objects.cc |
@@ -6,6 +6,7 @@ |
#include "src/wasm/module-decoder.h" |
#include "src/wasm/wasm-module.h" |
+#include "src/wasm/wasm-text.h" |
#define TRACE(...) \ |
do { \ |
@@ -539,6 +540,27 @@ int WasmCompiledModule::GetAsmJsSourcePosition( |
return offset_table->get_int(2 * left + 1); |
} |
+std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>> |
+WasmCompiledModule::DisassembleFunction(int func_index) { |
+ DisallowHeapAllocation no_gc; |
+ |
+ if (func_index < 0 || |
+ static_cast<uint32_t>(func_index) >= module()->functions.size()) |
+ return {}; |
+ |
+ SeqOneByteString* module_bytes_str = ptr_to_module_bytes(); |
+ Vector<const byte> module_bytes(module_bytes_str->GetChars(), |
+ module_bytes_str->length()); |
+ |
+ std::ostringstream disassembly_os; |
+ std::vector<std::tuple<uint32_t, int, int>> offset_table; |
+ |
+ PrintWasmText(module(), module_bytes, static_cast<uint32_t>(func_index), |
+ disassembly_os, &offset_table); |
+ |
+ return {disassembly_os.str(), std::move(offset_table)}; |
+} |
+ |
Handle<WasmInstanceWrapper> WasmInstanceWrapper::New( |
Isolate* isolate, Handle<WasmInstanceObject> instance) { |
Handle<FixedArray> array = |