| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| README.md | 2026-11-09 | 8.7 kB | |
| v0.1.0 source code.tar.gz | 2026-11-09 | 8.7 MB | |
| v0.1.0 source code.zip | 2026-11-09 | 9.1 MB | |
| Totals: 3 Items | 17.8 MB | 1 | |
- On the V8 benchmark suite v7, moejs scores 1,429, 1.35 times C QuickJS's 1,058 on the same machine, and has the highest score on each of the eight programs. A fixed run of the eight programs takes 14.29 s, where v0.1.0-alpha.11 takes 41.55 s.
- On new-api's plugin workloads at 8 workers, moejs with
ParseJSONStringserves 2.9 times as many 100k-token agent requests per second as C QuickJS and 8.6 times as many 8 MiB image requests, and it leads Sobek, modernc and quickjs-go in every scenario. C QuickJS still serves small requests about 7 % faster at 8 and 32 workers. - The interpreter caches property access on more code, makes object and array literals in one step, passes arguments without copying them, reads locals in place and takes fewer instructions for common operators. BigInts that fit an int64 compute in it.
- A runtime takes less memory and gives the collector less to trace. On 64-bit systems an object header is 48 bytes (96 before), a closure 160 or 144 (192) and a bound function 176 (208).
- Regular expressions that Go's regexp can express run on a native matcher over the string's own code units, in JavaScript's order and in O(n·m) steps. Past 1 MiB of matcher state they run on Go's regexp as before. A search first looks for a literal every match contains and fails at once without it.
- Strings Go passes in and JSON strings keep their UTF-8 text until JavaScript first reads them, then decode once. (#3, thanks @reitowo)
MaxCallDepthis 4096 (512 before), which React's server renderer needs for deep trees.MemoryLimitcounts the interpreter's register stack and frame table, andatobcharges the string it returns.atob,btoa, theUint8Arraybase64 methods andBuffer's base64 go through moego: AVX2 on amd64, NEON on arm64, pure Go on other architectures or with-tags purego. moejs's own code stays pure Go, with no assembly and no cgo, and moego is its one dependency.nodeandwebapibuild for every Go target withCGO_ENABLED=0, including 32-bit systems, js/wasm, wasip1 and plan9. Three bugs on 32-bit systems are fixed.node:fsworks on Windows: drive, share and rooted paths, and libuv's error codes and errno numbers.eventloop.Options.OnIdleruns right before the loop blocks andOnWakeafter it wakes, so a host can pause a CPU-time watchdog or give up an execution slot while the loop waits.- A function with more bindings than its 256 registers hold, such as a bundle's outer function, compiles. It was a SyntaxError.
- Fixes: after
Error.foowas read throughTypeErrorand deleted, the next read panicked.Object.entriesandvaluesinclude a property a getter makes enumerable before its turn. A computed key before a rest element is converted once.concaton huge arrays grows as it writes, within a memory limit, and throws a RangeError past 2^27 elements, where it could ask Go for 64 GB at once. A function that eval ornew Functionmade in another runtime isErrForeign, where it could read or write the wrong property. A string shared by runtimes on several goroutines no longer races on its hash. On Linux,node:fsretries an open that a rename elsewhere raced (EAGAIN). UnmarshalandToGoIntoleave struct tags that Go 1.27 reads differently toencoding/json. (#8, thanks @yuluo-yx)bench/cmd/pluginbenchandbench/cmd/v8benchreproduce the plugin and V8 suite figures, andbench/scenarios/gen.pywrites the plugin inputs and checks them against the hashes of the published runs.
To upgrade, run go get github.com/MoeForge/moejs@v0.1.0. The root package, node and webapi have no API changes, and eventloop adds Options.OnIdle and Options.OnWake. In package engine, MaxCallDepth is 4096, FromHostString, ICEntry.Near and ICEntry.HolderNear are new, FunctionData.SetNative and SetConstructor are unexported, ArrayData is gone, and FuncKind's constants start at 1. Package bytecode has new ops and a new op order. The full list is in v0.1.0-alpha.11...v0.1.0.
- 在 V8 benchmark suite v7 上,moejs 得 1,429 分,是同一台机器上 C QuickJS(1,058 分)的 1.35 倍,8 个程序每一个都是最高分。固定运行这 8 个程序耗时 14.29 秒,v0.1.0-alpha.11 要 41.55 秒。
- 在 new-api 的插件负载上(8 个 worker),用
ParseJSONString的 moejs 每秒处理的 10 万 token agent 请求是 C QuickJS 的 2.9 倍,8 MiB 图片请求是 8.6 倍,在所有场景里都领先 Sobek、modernc 和 quickjs-go。8 和 32 个 worker 时,C QuickJS 处理小请求仍快约 7%。 - 解释器在更多代码上缓存属性访问,对象和数组字面量一步建好,传参不再复制,局部变量原地读取,常见运算符用的指令更少。能放进 int64 的 BigInt 直接用 int64 计算。
- 运行时占用的内存更少,垃圾回收要扫描的也更少。在 64 位系统上,对象头是 48 字节(之前 96),闭包 160 或 144 字节(之前 192),绑定函数 176 字节(之前 208)。
- Go 的 regexp 能表达的正则表达式,改由原生匹配器直接在字符串自身的码元上运行,按 JavaScript 的顺序匹配,步数为 O(n·m);匹配器状态超过 1 MiB 时,和以前一样交给 Go 的 regexp。如果每个匹配都必须包含某个字面量,搜索会先找这个字面量,找不到就立即返回。
- Go 传入的字符串和 JSON 字符串保留 UTF-8 原文,等 JavaScript 第一次读取时才解码,并且只解码一次。(#3,感谢 @reitowo)
MaxCallDepth改为 4096(之前 512),React 的服务端渲染处理深层组件树时需要这么深。MemoryLimit计入解释器的寄存器栈和帧表,atob返回的字符串也计入。atob、btoa、Uint8Array的 base64 方法和Buffer的 base64 改由 moego 实现:amd64 上用 AVX2,arm64 上用 NEON,其他架构或加-tags purego时是纯 Go。moejs 自己的代码仍然是纯 Go,没有汇编,也不用 cgo,moego 是它唯一的依赖。node和webapi在CGO_ENABLED=0下能为所有 Go 目标平台编译,包括 32 位系统、js/wasm、wasip1 和 plan9,并修复了 32 位系统上的三个问题。node:fs支持 Windows:盘符路径、共享路径和根路径都能用,错误码和 errno 与 libuv 一致。eventloop.Options.OnIdle在事件循环阻塞前运行,OnWake在它醒来后运行。宿主可以借此在循环等待时暂停 CPU 时间看门狗,或让出执行槽位。- 绑定数超过 256 个寄存器的函数(比如打包产物的最外层函数)现在能编译,之前会报 SyntaxError。
- 修复:通过
TypeError读取Error.foo并删除后,下一次读取会 panic。Object.entries和values现在会包含被前面的 getter 改成可枚举的属性。rest 元素前的计算属性键只转换一次。对超大数组调用concat时,结果边写边扩容并受内存上限约束,超过 2^27 个元素时抛出 RangeError,之前可能一次向 Go 申请 64 GB。在另一个运行时里由 eval 或new Function创建的函数会报ErrForeign,之前可能读写到错误的属性。多个 goroutine 上的运行时共享同一个字符串时,不再在它的哈希上发生数据竞争。在 Linux 上,被别处的 rename 打断的 open(EAGAIN)会由node:fs重试。 Unmarshal和ToGoInto遇到 Go 1.27 与旧版encoding/json解读不同的结构体标签时,交给json.Unmarshal处理。(#8,感谢 @yuluo-yx)bench/cmd/pluginbench和bench/cmd/v8bench可以复现插件和 V8 suite 的数据,bench/scenarios/gen.py生成插件的输入,并按公开数据所用文件的哈希核对。
升级时执行 go get github.com/MoeForge/moejs@v0.1.0。根包、node 和 webapi 的 API 没有变化,eventloop 新增 Options.OnIdle 和 Options.OnWake。engine 包里,MaxCallDepth 改为 4096,新增 FromHostString、ICEntry.Near 和 ICEntry.HolderNear,FunctionData.SetNative 和 SetConstructor 不再导出,ArrayData 已删除,FuncKind 的常量从 1 开始。bytecode 包新增了指令,指令顺序也变了。完整改动见 v0.1.0-alpha.11...v0.1.0。

