Unable to compile wasm bytes in a isolate associated with v8::SnapshotCreator

134 views
Skip to first unread message

Yulan Wang

unread,
Oct 26, 2022, 2:07:03 AM10/26/22
to v8-users
I'm trying to use snapshot to cache the context with compiled code (JS source code and wasm bytes code) inside. I can go througth with JS code.

But for wasm, I can compile the wasm code in regular isolate, but once I declare SnapshotCreator in the code like follow line:

`Isolate::CreateParams create_params;
create_params.array_buffer_allocator =
v8::ArrayBuffer::Allocator::NewDefaultAllocator();
auto isolate = Isolate::New(create_params);
SnapshotCreator creator(isolate);`

WasmModuleObject::Compile doesn't work and return a non-WasmModuleObject. 

I also tried with v8::Script::Compile, and I got the same issue. The code works without SnapshotCreator declare, but doesn't work with SnapshotCreator. 

Is there any compiler restraint in SnapshotCreator that cannot compile wasm code, or I miss any configs?  Thanks!

Clemens Backes

unread,
Oct 27, 2022, 7:30:04 AM10/27/22
to v8-u...@googlegroups.com
Wasm support in snapshots was never added (see issue 8176). Supporting it would be a non-trivial amount of work, as we have to make sure to serialize the compiled Wasm code (living outside the JS heap) on snapshot creation, and properly reconstruct all involved functions and objects from that when deserializing.

Please go ahead and open an issue on http://crbug.com/v8/new and describe your use case, so we can include this in our planning for the upcoming quarters.

Cheers,
Clemens

--
--
v8-users mailing list
v8-u...@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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/267acde6-1eb1-447b-b2f4-d0c8d2407992n%40googlegroups.com.


--

Clemens Backes

Software Engineer

clem...@google.com

Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Liana Sebastian   

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.


This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.


Yulan Wang

unread,
Oct 27, 2022, 5:11:35 PM10/27/22
to v8-users
Thanks for your reply, Clemens.  I opened the issue 13430. Thanks!

Best,
Yulan

Tudor Bosman

unread,
Mar 17, 2023, 6:12:15 PM3/17/23
to v8-users
Is there any chance that this can be resurrected / implemented?

I'd love to be able to snapshot large Emscripten apps (such as apps that use Pyodide).

Failing that, is there a way to detect if a Context has any WebAssembly hanging off of it anywhere, so I know to not even try to serialize it?

Thanks,
-Tudor.

Reply all
Reply to author
Forward
0 new messages