05-MoonBit 编程语言(WASM 技术)服务端应用展望以及对Kubernetes生态的影响MoonBit 编程语言(WASM 技术) 服务端应用展望 以及对Kubernetes生态的影响 沙渺(MoonBit 语言社区开发者) 本分享包含大量目前尚处在早期开发阶段甚至概念阶段, 尚未获得广泛应用的技术。 仅为前景展望,不推荐用于当前立项开发的实际工程。 敬请注意 内容 • WASM 技术栈现状和 WASM 后端应用的构想 • MoonBit 语言介绍 • MoonBit MoonBit 方案对 WASM 技术栈的作用 • 对 Kubernetes 提出的挑战 分享者 • 沙渺,大连本地独立开发者 • Rust 语言社区早期参与者 The Rust Programming Language(中文纸质版)译者3 • MoonBit 语言社区开发者 官方标准库代码、教程资料编写者 WebAssembly (WASM) WASM 现状 • 1.0 MVP 已稳定(2017)已被 interfaces 或 WASI)上 WASM 后端应用先驱 wasmCloud (CNCF-Sandbox) fermyon/spin WasmEdge (CNCF-Sandbox) • 多数特性已标准化 • 一些特性对后端应用 不可或缺 • 但各个运行时的实现, 成熟度不一 • 使用扩展特性,基本 需要限定运行时 WASM 扩展特性 • 基本接口已在 WASM 1.0 标准化 • 但只能交换简单数据类型0 码力 | 30 页 | 3.41 MB | 9 月前3
MoonBit月兔编程语言 现代编程思想 第十四课 案例:堆栈虚拟机
Const(1), Call("add"), Call("print_int")], 17. }, 18. ], 19. } 15 程序整体架构 输出程序 1. ;; 多个函数 2. ;; WASM本身只定义运算;交互需依赖外部函数 3. (func $print_int (import "spectest" "print_int") (param i32)) 4. 5. (func $add $print_int 12. ) 13. 14. (start $test_add) 16 在线尝试 https://webassembly.github.io/wabt/demo/wat2wasm/ 1. const wasmInstance = new WebAssembly.Instance(wasmModule, {"spectest":{"print_int": console.log}}); 数据结构,⽐字符串拼接更⾼效 1. fn Instruction::to_wasm(self : Instruction, buffer : Buffer) -> Unit 2. fn Function::to_wasm(self : Function, buffer : Buffer) -> Unit 3. fn Program::to_wasm(self : Program, buffer : Buffer)0 码力 | 31 页 | 594.38 KB | 1 年前3
The Zig Programming Language 0.7.1 Documentation@wasmMemorySize(index: u32) u32 This function returns the size of the Wasm memory identified by index as an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size. This function is a low level level intrinsic with no safety mechanisms usually useful for allocator designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use something like @import("std").heap.WasmPageAllocator u32) i32 This function increases the size of the Wasm memory identified by index by delta in units of unsigned number of Wasm pages. Note that each Wasm page is 64KB in size. On success, returns previous0 码力 | 225 页 | 5.74 MB | 1 年前3
The Zig Programming Language 0.8.1 Documentation@wasmMemorySize(index: u32) u32 This function returns the size of the Wasm memory identified by index as an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size. This function is a low level level intrinsic with no safety mechanisms usually useful for allocator designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use something like @import("std").heap.WasmPageAllocator u32) i32 This function increases the size of the Wasm memory identified by index by delta in units of unsigned number of Wasm pages. Note that each Wasm page is 64KB in size. On success, returns previous0 码力 | 234 页 | 6.01 MB | 1 年前3
The Zig Programming Language 0.9.1 Documentationx: u32) u32 This function returns the size of the Wasm memory identified by index as an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size. This function is a low level level intrinsic with no safety mechanisms usually useful for allocator designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use something like @import("std").heap.WasmPageAllocator u32) i32 This function increases the size of the Wasm memory identified by index by delta in units of unsigned number of Wasm pages. Note that each Wasm page is 64KB in size. On success, returns previous0 码力 | 234 页 | 7.90 MB | 1 年前3
The Zig Programming Language 0.11.0 Documentationx: u32) u32 This function returns the size of the Wasm memory identified by index as an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size. This function is a low level level intrinsic with no safety mechanisms usually useful for allocator designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use something like @import("std").heap.WasmPageAllocator u32) i32 This function increases the size of the Wasm memory identified by index by delta in units of unsigned number of Wasm pages. Note that each Wasm page is 64KB in size. On success, returns previous0 码力 | 238 页 | 7.80 MB | 1 年前3
The Zig Programming Language 0.10.1 Documentationx: u32) u32 This function returns the size of the Wasm memory identified by index as an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size. This function is a low level level intrinsic with no safety mechanisms usually useful for allocator designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use something like @import("std").heap.WasmPageAllocator u32) i32 This function increases the size of the Wasm memory identified by index by delta in units of unsigned number of Wasm pages. Note that each Wasm page is 64KB in size. On success, returns previous0 码力 | 239 页 | 8.03 MB | 1 年前3
The Zig Programming Language 0.5.0 Documentationchoice, at least for your main allocator. �. Are you building for WebAssembly? In this case, std.heap.wasm_allocator is likely the right choice for your main allocator as it uses WebAssembly's memory instructions hsail, hsail64, spir, spir64, kalimba: Kalimba, shave, lanai, wasm32, wasm64, renderscript32, renderscript64, pub const Arm32 = enum { v8_5a, simulator, macabi, }; pub const ObjectFormat = enum { unknown, coff, elf, macho, wasm, }; pub const GlobalLinkage = enum { Internal, Strong, Weak, LinkOnce, }; pub const0 码力 | 224 页 | 5.80 MB | 1 年前3
The Zig Programming Language 0.12.0 Documentationx: u32) u32 This function returns the size of the Wasm memory identified by index as an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size. This function is a low level level intrinsic with no safety mechanisms usually useful for allocator designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use something like @import("std").heap.WasmPageAllocator u32) i32 This function increases the size of the Wasm memory identified by index by delta in units of unsigned number of Wasm pages. Note that each Wasm page is 64KB in size. On success, returns previous0 码力 | 241 页 | 7.37 MB | 1 年前3
The Zig Programming Language 0.6.0 Documentationprint(a + b); } $ zig build-lib math.zig -target wasm32-freestanding test.js const fs = require('fs'); const source = fs.readFileSync("./math.wasm"); const typedArray = new Uint8Array(source); WebAssembly warn("{}: {}\n", .{i, arg}); } } $ zig build-exe wasi.zig -target wasm32-wasi $ wasmer run wasi.wasm 123 hello 0: wasi.wasm 1: 123 2: hello Targets Zig supports generating code for all targets v6t2 v5 v5te v4t i386 x86_64 (native) xcore nvptx nvptx64 lanai wasm32 wasm64 Operating Systems: freestanding ananas cloudabi dragonfly freebsd fuchsia ios0 码力 | 214 页 | 5.37 MB | 1 年前3
共 14 条
- 1
- 2













