Repository navigation
v0.1.0-alpha.11
·
13 commits
to main
since this release
- The module path is now
github.com/MoeForge/moejs, where the repository moved. To upgrade, change the import path and rungo get github.com/MoeForge/moejs@v0.1.0-alpha.11. v0.1.0-alpha.10 and earlier keepgithub.com/Calcium-Ion/moejs. - The
nodepackage addsnode:fs,node:fs/promisesandnode:bufferto a runtime with an event loop. Every path stays inside one directory the host picks, files are read-only unless the host allows writes, and an allow hook sees each access. - An
awaitno longer allocates, and an async call allocates only its promise until its firstawait. - With the Web APIs installed, reading globals is as fast as in a bare runtime: a loop that reads three of them takes 29 ns an iteration instead of 390 ns.
webapi.Installtakes 1.2 µs instead of 12.6 µs. default.pgois recorded again under the new path. The profile in earlier releases named moejs's functions under an older path, so it never optimized moejs's own code.DecodeOptions.MaxBytescounts invalid UTF-8 in a Go string the wayjson.Marshalwrites it. (#7, thanks @yuluo-yx)
Apart from the module path, every API change is an addition. The full list is in ffea310.
- 模块路径改为
github.com/MoeForge/moejs,也就是仓库的新地址。升级时把 import 路径改成新的,再执行go get github.com/MoeForge/moejs@v0.1.0-alpha.11。v0.1.0-alpha.10 及以前的版本仍然在github.com/Calcium-Ion/moejs。 - 新增
node包,在带事件循环的运行时上提供node:fs、node:fs/promises和node:buffer。所有路径都限制在宿主指定的目录里,文件默认只读,宿主允许后才能写入,每次访问都要经过放行钩子。 await不再分配内存,async 函数调用在第一次await之前只分配它的 promise。- 装了 Web API 后,读全局变量和没装时一样快:读三个全局变量的循环每次迭代从 390 ns 降到 29 ns,
webapi.Install从 12.6 µs 降到 1.2 µs。 default.pgo按新路径重新录制。之前版本的样本里,moejs 的函数用的是更早的路径,所以 moejs 自己的代码一直没被优化到。DecodeOptions.MaxBytes对 Go 字符串里的非法 UTF-8,按json.Marshal实际写出的字节数计算。(#7,感谢 @yuluo-yx)
除了模块路径,所有 API 变化都是新增。完整改动见 ffea310。
