-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support WebAssembly #5
Comments
V8 now support calling Promise in WebAssembly (behind feature flag) |
TBD import { Attribute, Bind, ColonFor } from "../query.ts";
import bind from "./common.ts";
const cache: Record<string, Module> = {};
let count = 0;
export default (attrs: Attribute[]) => async (path: string) => {
let linkCount = count;
(await source).url;
const module = await WebAssembly.instantiateStreaming(source, {
env: { lc: () => linkCount },
});
count++;
};
/** WebAssembly module **instance** */
interface Module {
/** instantiate module */
["constructor"](): void;
/** instance accessor for accessing instance value */
[key: `get ${string}`]: () => unknown;
/** instance accessor for mutating instance value */
[key: `set ${string}`]: (value: unknown) => unknown;
/** instance method that might access/mutate instance and/or global value */
[key: string]: (...args: unknown[]) => unknown;
/** static block which run only once */
// ["static"](): void; // wasm $startFunction serve the same purpose
/** static accessor for accessing global value */
[key: `static get ${string}`]: () => unknown;
/** static accessor for mutating global value */
[key: `static set ${string}`]: (value: unknown) => unknown;
/** static method that can't access/mutate instance value */
[key: `static ${string}`]: (...args: unknown[]) => unknown;
} |
Some references
|
Data Type compatibility across languagesI'm thinking to use Apache Arrow format to solve this. Also, ecmascript data type still fully supported and may automatically inferred when the module is in JavaScript, but only partially (and no infer value) when in WebAssembly. In javascript it might look like import { Map, Set, Date, ... } from "nusa/std/type"
import { Utf8, Float16, Date64, ... } from "nusa/arrow/type" Another approach is to use objectbuffer by Bnaya Peretz I'm in favor of Apache Arrow because the interoperability between languages are more consistent. For example, objectbuffer use ES string which is UTF-16 while most programming languages use UTF-8. |
15x Faster TypedArrays: Vector Addition in WebAssembly @ 154GB/s |
Arquero, a JavaScript library for query processing and transformation of Apache Arrow columns |
Based on wasm component model and the output of wit-bindgen, the size of So which language should be used for implementing that? C23
Rust
OdinTBD most likely same limitation as Rust 🤔Zig
AssemblyScript
|
I've written some of What the heck is frankenstein Rust?It's Rust without Cargo that use voodoo technique like manually linking to hand-knitted assembly code and using bunch compiler flags or tools other than Seems I will continue to go on this path 🧟♂️ |
Since not all wasm language can import a function with multi-value return, I've added a fallback function with (import "nusa" "accessor" (func $a (result i32 i32))) the fallback would be (import "nusa" "cABIaccessor" (func $a (result i64))) The language binding must use |
prototype (stalled)
constructor
,extern instance
)static
property #2abstract class Scope
#27Unlike Javascript module that export class, setter in WebAssembly doesn't automatically update html attribute. You need to specify which bounded property to update.
The text was updated successfully, but these errors were encountered: