Hi all, I am compiling WebAssembly modules that perform computations and produce results. These results (tuples of values of various types) I would like to print to stdout. My current approach is importing a callback function to the WebAssembly module instance that performs the printing:
void print(const v8::FunctionCallbackInfo<v8::Value> &info) { for (int i = 0; i != info.Length(); ++i) { v8::HandleScope handle_scope(info.GetIsolate()); if (i != 0) std::cout << ','; std::cout << *v8::String::Utf8Value(info.GetIsolate(), info[i]); } std::cout << '\n'; } This callback prints an entire tuple in CSV format. While this works, it has some drawbacks for me. The biggest drawback is performance! The callbacks from the VM to the host seem horribly slow compared to native function calls. Is there something I can do about this? Is there a way to speed up these callbacks from VM to the host? I tried an alternative solution, where the WebAssembly module writes the results to its linear memory and the host reads them back from the memory, interprets them, and prints them. This seems to be faster, actually. However, it requires additional memory and the host must "interpret" the values. This is in my scenario also a performance issue, because I don't know the types of the result when compiling the host code. I only know the types when compiling the WebAssembly module. Hence, in this approach there is some interpretation overhead involved. Is there maybe a way to directly write to stdout from WebAssembly? Thanks & regards, Immanuel -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/b8840b18-820d-406d-a24b-b99545fbf09a%40googlegroups.com.