You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 3, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 3, 2020. It is now read-only.
V8 has support for WebAssembly, and supposedly has near-native speeds. Could we make use of this in runtime? Also, Wasm is hidden behind a flag, so is there any way to enable flags for V8 in runtime?
Yes, we should be able to enable Wasm, I'm going to update V8 to the latest version and see if Wasm works. With Wasm runtime.js will no longer be limited to JavaScript, and things like crypto (libsodium) can be loaded as Wasm modules instead.
Reacted by Ariel Abreu, Tristan Ross and austinfrey
Yes, we should be able to enable Wasm, I'm going to update V8 to the
latest version and see if Wasm works. With Wasm runtime.js will no longer
be limited to JavaScript, and things like crypto (libsodium) can be loaded
as Wasm modules instead.
Got WebAssembly working using updated V8 (it still needs --expose-wasm which is disabled by default).
I'm trying to figure out a nice way to pass V8 flags. I'm thinking maybe read flags from v8.flags file in the root directory of the project. This will make it easy for each project to specify v8 flags it needs.
@iefserge Nice, I've got a little system built to test out runtime.js features and I've included a kernel with the flags enabled. One thing I've noticed is that emscripten-compiled WebAssembly takes a bit to load code with C headers, but at least twice as long to load C++ headers.
I like the idea of having custom flags in each project, but I wonder how this would be implemented? If they're set by the library after V8 is started, then it's dangerous. One way it could be done safely is for runtime-cli to read it from the package.json and embed it into the initrd header, then the kernel could read them and set them before initializing V8.
@facekapow it would read file from initrd once during the startup. Shouldn't be an issue since initrd code is C++. package.json solution is interesting too, but yeah it requires updating initrd format. How would this config look like in package.json?
I see you patched runtime to enable wasm, pretty cool :)
Edit: Actually runtime-cli can include any metadata as special files, so no initrd format updates are necessary.
How does including metadata work? I quickly skimmed over the code to pack an initrd and to read it from the kernel and didn't see anything. Would it just be included as a regular file and read by the kernel?
Also, we could just parse the root package.json in the kernel using this little C++ JSON parser (or this other parser, focused on memory limited systems) and fetch the flags like that.
Anyway, you're right it might be easier to just parse JSON in C++, since we may have runtime.js flags there too at some point. Makes sense to group those?
And the corresponding code would need to be modified in js/__loader.js, but... it would have to wait until #120 merges (or doesn't), because again, would want to avoid any future merge conflicts.
What is the state of using WASM in runtime.js? and why there is no place for an independent unikernel (not runtime.js) that only runs WASM?
It could be feasable, there's already wasm VMs written in plain C, so it would be plainly trivial (but without a JIT compiler, fairly slow). There has been similar approachs in the past, for example Inferno OS with the dis assembler specification.
Activity
iefserge commentedon Jul 4, 2016
Yes, we should be able to enable Wasm, I'm going to update V8 to the latest version and see if Wasm works. With Wasm runtime.js will no longer be limited to JavaScript, and things like crypto (libsodium) can be loaded as Wasm modules instead.
piranna commentedon Jul 4, 2016
That would be cool! :-D
RossComputerGuy commentedon Jul 6, 2016
That would be cool for BasicOS. Update on BasicOS: new homepage and I had to restart the project. There was too many errors.
iefserge commentedon Jul 22, 2016
Got WebAssembly working using updated V8 (it still needs
--expose-wasmwhich is disabled by default).I'm trying to figure out a nice way to pass V8 flags. I'm thinking maybe read flags from
v8.flagsfile in the root directory of the project. This will make it easy for each project to specify v8 flags it needs.Wasm example looks like this
asm.js -> wasm works too
facekapow commentedon Jul 22, 2016
@iefserge Nice, I've got a little system built to test out runtime.js features and I've included a kernel with the flags enabled. One thing I've noticed is that emscripten-compiled WebAssembly takes a bit to load code with C headers, but at least twice as long to load C++ headers.
I like the idea of having custom flags in each project, but I wonder how this would be implemented? If they're set by the library after V8 is started, then it's dangerous. One way it could be done safely is for
runtime-clito read it from thepackage.jsonand embed it into the initrd header, then the kernel could read them and set them before initializing V8.iefserge commentedon Jul 22, 2016
@facekapow it would read file from initrd once during the startup. Shouldn't be an issue since initrd code is C++.
package.jsonsolution is interesting too, but yeah it requires updating initrd format. How would this config look like inpackage.json?I see you patched runtime to enable wasm, pretty cool :)
Edit: Actually
runtime-clican include any metadata as special files, so no initrd format updates are necessary.facekapow commentedon Jul 22, 2016
I think it'd be something like:
{ "name": "my-pkg", "version": "1.0.0", "v8": { "flags": "--expose_wasm --harmony_async_await --other_flags" } }How does including metadata work? I quickly skimmed over the code to pack an initrd and to read it from the kernel and didn't see anything. Would it just be included as a regular file and read by the kernel?
Also, we could just parse the root
package.jsonin the kernel using this little C++ JSON parser (or this other parser, focused on memory limited systems) and fetch the flags like that.iefserge commentedon Jul 22, 2016
There is a file type id, can use another id to include any metadata. https://github.com/runtimejs/runtime/blob/master/src/kernel/initrd.cc#L96
Anyway, you're right it might be easier to just parse JSON in C++, since we may have runtime.js flags there too at some point. Makes sense to group those?
{ "runtime": { "enableProfiler": true, "enableWebWrokers": true, "v8flags": "--expose_wasm" } }facekapow commentedon Jul 22, 2016
If we go the JSON route, in order to allow the field to be an object,
runtime-module-loaderwould have to modified at line 129 and add something like:And the corresponding code would need to be modified in
js/__loader.js, but... it would have to wait until #120 merges (or doesn't), because again, would want to avoid any future merge conflicts.Edit: and yes it makes sense group the options.
iefserge commentedon Jul 24, 2016
Yeah sure, let's merge #120 first.
kumavis commentedon Sep 5, 2016
i hunger for webassembly unikernels!
yshemesh commentedon Sep 19, 2017
What is the state of using WASM in runtime.js? and why there is no place for an independent unikernel (not runtime.js) that only runs WASM?
piranna commentedon Sep 19, 2017
It could be feasable, there's already wasm VMs written in plain C, so it would be plainly trivial (but without a JIT compiler, fairly slow). There has been similar approachs in the past, for example Inferno OS with the
disassembler specification.RossComputerGuy commentedon Sep 23, 2017
Can a WebAssembly vm work?
piranna commentedon Sep 23, 2017
It depends what do you want to achieve with it...
RossComputerGuy commentedon Sep 23, 2017
If I were wanting to use it for adding numbers, it would work.
piranna commentedon Sep 23, 2017
What do you mean by "adding numbers"?
RossComputerGuy commentedon Sep 23, 2017
Just some WebAssembly tests and examples