97b1423740
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
324 lines
21 KiB
Markdown
324 lines
21 KiB
Markdown
<center>
|
||
<svg width="250" height="250" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<rect width="500" height="500" />
|
||
<path d="M100.393 154.59L76.3681 173.855C73.9557 175.789 72 180.074 72 183.424V216.792C72 220.143 73.9557 221.291 76.3681 219.357L100.393 200.092C102.805 198.157 104.761 193.873 104.761 190.522V157.154C104.761 153.803 102.805 152.655 100.393 154.59Z" fill="url(#paint0_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M135.337 126.568L111.313 145.833C108.9 147.768 106.945 152.052 106.945 155.403V188.771C106.945 192.121 108.9 193.269 111.313 191.335L135.337 172.07C137.75 170.135 139.705 165.851 139.705 162.5V129.132C139.705 125.782 137.75 124.634 135.337 126.568Z" fill="url(#paint1_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M170.282 98.5463L146.258 117.811C143.845 119.746 141.89 124.03 141.89 127.381V160.749C141.89 164.099 143.845 165.248 146.258 163.313L170.282 144.048C172.695 142.114 174.65 137.829 174.65 134.478V101.11C174.65 97.7598 172.695 96.6118 170.282 98.5463Z" fill="url(#paint2_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M205.227 70.5245L181.202 89.7895C178.79 91.724 176.834 96.0085 176.834 99.3591V132.727C176.834 136.078 178.79 137.226 181.202 135.291L205.227 116.026C207.639 114.092 209.595 109.807 209.595 106.457V73.0887C209.595 69.738 207.639 68.59 205.227 70.5245Z" fill="url(#paint3_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M240.172 42.5027L216.147 61.7677C213.735 63.7022 211.779 67.9867 211.779 71.3373V104.705C211.779 108.056 213.735 109.204 216.147 107.269L240.172 88.0044C242.584 86.0699 244.54 81.7855 244.54 78.4348V45.0669C244.54 41.7162 242.584 40.5682 240.172 42.5027Z" fill="url(#paint4_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M205.227 119.06L181.202 138.325C178.79 140.259 176.834 144.544 176.834 147.894V181.262C176.834 184.613 178.79 185.761 181.202 183.826L205.227 164.561C207.639 162.627 209.595 158.342 209.595 154.992V121.624C209.595 118.273 207.639 117.125 205.227 119.06Z" fill="url(#paint5_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M205.227 167.595L181.202 186.86C178.79 188.794 176.834 193.079 176.834 196.429V229.797C176.834 233.148 178.79 234.296 181.202 232.362L205.227 213.097C207.639 211.162 209.595 206.878 209.595 203.527V170.159C209.595 166.808 207.639 165.66 205.227 167.595Z" fill="url(#paint6_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M100.393 300.195L76.3681 319.46C73.9557 321.395 72 325.679 72 329.03V362.398C72 365.749 73.9557 366.897 76.3681 364.962L100.393 345.697C102.805 343.763 104.761 339.478 104.761 336.127V302.76C104.761 299.409 102.805 298.261 100.393 300.195Z" fill="url(#paint7_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M205.227 216.13L181.202 235.395C178.79 237.329 176.834 241.614 176.834 244.965V278.333C176.834 281.683 178.79 282.831 181.202 280.897L205.227 261.632C207.639 259.697 209.595 255.413 209.595 252.062V218.694C209.595 215.344 207.639 214.196 205.227 216.13Z" fill="url(#paint8_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M135.337 320.709L111.313 339.974C108.9 341.908 106.945 346.193 106.945 349.543V382.911C106.945 386.262 108.9 387.41 111.313 385.475L135.337 366.21C137.75 364.276 139.705 359.992 139.705 356.641V323.273C139.705 319.922 137.75 318.774 135.337 320.709Z" fill="url(#paint9_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M170.282 292.687L146.258 311.952C143.845 313.886 141.89 318.171 141.89 321.522V354.89C141.89 358.24 143.845 359.388 146.258 357.454L170.282 338.189C172.695 336.254 174.65 331.97 174.65 328.619V295.251C174.65 291.9 172.695 290.752 170.282 292.687Z" fill="url(#paint10_linear_0_1)" stroke="#FF9D73" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M318.798 89.7895L294.773 70.5245C292.361 68.59 290.405 69.738 290.405 73.0887V106.457C290.405 109.807 292.361 114.092 294.773 116.026L318.798 135.291C321.21 137.226 323.166 136.078 323.166 132.727V99.3591C323.166 96.0085 321.21 91.724 318.798 89.7895Z" fill="url(#paint11_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M353.742 117.811L329.718 98.5463C327.305 96.6118 325.35 97.7598 325.35 101.11V134.478C325.35 137.829 327.305 142.114 329.718 144.048L353.742 163.313C356.155 165.248 358.11 164.099 358.11 160.749V127.381C358.11 124.03 356.155 119.746 353.742 117.811Z" fill="url(#paint12_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M388.687 145.833L364.663 126.568C362.25 124.634 360.294 125.782 360.294 129.132V162.5C360.294 165.851 362.25 170.135 364.663 172.07L388.687 191.335C391.1 193.269 393.055 192.121 393.055 188.771V155.403C393.055 152.052 391.1 147.768 388.687 145.833Z" fill="url(#paint13_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M423.632 173.855L399.607 154.59C397.195 152.655 395.239 153.803 395.239 157.154V190.522C395.239 193.873 397.195 198.157 399.607 200.092L423.632 219.357C426.044 221.291 428 220.143 428 216.792V183.424C428 180.074 426.044 175.789 423.632 173.855Z" fill="url(#paint14_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M283.853 110.303L259.828 91.0379C257.416 89.1034 255.46 90.2514 255.46 93.6021V126.97C255.46 130.321 257.416 134.605 259.828 136.54L283.853 155.805C286.265 157.739 288.221 156.591 288.221 153.24V119.873C288.221 116.522 286.265 112.237 283.853 110.303Z" fill="url(#paint15_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M318.798 186.86L294.773 167.595C292.361 165.66 290.405 166.808 290.405 170.159V203.527C290.405 206.878 292.361 211.162 294.773 213.097L318.798 232.362C321.21 234.296 323.166 233.148 323.166 229.797V196.429C323.166 193.079 321.21 188.794 318.798 186.86Z" fill="url(#paint16_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M353.742 214.882L329.718 195.617C327.305 193.682 325.35 194.83 325.35 198.181V231.549C325.35 234.899 327.305 239.184 329.718 241.118L353.742 260.383C356.155 262.318 358.11 261.17 358.11 257.819V224.451C358.11 221.101 356.155 216.816 353.742 214.882Z" fill="url(#paint17_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M388.687 242.903L364.663 223.638C362.25 221.704 360.294 222.852 360.294 226.203V259.571C360.294 262.921 362.25 267.206 364.663 269.14L388.687 288.405C391.1 290.34 393.055 289.192 393.055 285.841V252.473C393.055 249.122 391.1 244.838 388.687 242.903Z" fill="url(#paint18_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M423.632 319.46L399.607 300.195C397.195 298.261 395.239 299.409 395.239 302.76V336.127C395.239 339.478 397.195 343.763 399.607 345.697L423.632 364.962C426.044 366.897 428 365.749 428 362.398V329.03C428 325.679 426.044 321.395 423.632 319.46Z" fill="url(#paint19_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M283.853 255.908L259.828 236.643C257.416 234.709 255.46 235.857 255.46 239.208V272.575C255.46 275.926 257.416 280.211 259.828 282.145L283.853 301.41C286.265 303.345 288.221 302.197 288.221 298.846V265.478C288.221 262.127 286.265 257.843 283.853 255.908Z" fill="url(#paint20_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M318.798 283.93L294.773 264.665C292.361 262.731 290.405 263.879 290.405 267.229V300.597C290.405 303.948 292.361 308.232 294.773 310.167L318.798 329.432C321.21 331.366 323.166 330.218 323.166 326.868V293.5C323.166 290.149 321.21 285.865 318.798 283.93Z" fill="url(#paint21_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M353.742 311.952L329.718 292.687C327.305 290.752 325.35 291.9 325.35 295.251V328.619C325.35 331.97 327.305 336.254 329.718 338.189L353.742 357.454C356.155 359.388 358.11 358.24 358.11 354.889V321.522C358.11 318.171 356.155 313.886 353.742 311.952Z" fill="url(#paint22_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<path d="M388.687 339.974L364.663 320.709C362.25 318.774 360.294 319.922 360.294 323.273V356.641C360.294 359.991 362.25 364.276 364.663 366.21L388.687 385.475C391.1 387.41 393.055 386.262 393.055 382.911V349.543C393.055 346.193 391.1 341.908 388.687 339.974Z" fill="url(#paint23_linear_0_1)" stroke="#FF6A33" stroke-opacity="0.6" stroke-width="1.61185"/>
|
||
<defs>
|
||
<linearGradient id="paint0_linear_0_1" x1="72" y1="177.358" x2="106.377" y2="193.049" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint1_linear_0_1" x1="106.945" y1="149.336" x2="141.321" y2="165.027" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint2_linear_0_1" x1="141.89" y1="121.314" x2="176.266" y2="137.005" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint3_linear_0_1" x1="176.834" y1="93.2922" x2="211.211" y2="108.984" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint4_linear_0_1" x1="211.779" y1="65.2704" x2="246.156" y2="80.9618" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint5_linear_0_1" x1="176.834" y1="141.827" x2="211.211" y2="157.519" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint6_linear_0_1" x1="176.834" y1="190.363" x2="211.211" y2="206.054" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint7_linear_0_1" x1="72" y1="322.963" x2="106.377" y2="338.654" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint8_linear_0_1" x1="176.834" y1="238.898" x2="211.211" y2="254.589" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint9_linear_0_1" x1="106.945" y1="343.476" x2="141.321" y2="359.168" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint10_linear_0_1" x1="141.89" y1="315.455" x2="176.266" y2="331.146" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#FF7B42"/>
|
||
<stop offset="1" stop-color="#B32100"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint11_linear_0_1" x1="290.405" y1="67.0218" x2="330.135" y2="134.703" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint12_linear_0_1" x1="325.35" y1="95.0436" x2="365.08" y2="162.724" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint13_linear_0_1" x1="360.294" y1="123.065" x2="400.025" y2="190.746" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint14_linear_0_1" x1="395.239" y1="151.087" x2="434.969" y2="218.768" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint15_linear_0_1" x1="255.46" y1="87.5352" x2="295.19" y2="155.216" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint16_linear_0_1" x1="290.405" y1="164.092" x2="330.135" y2="231.773" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint17_linear_0_1" x1="325.35" y1="192.114" x2="365.08" y2="259.795" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint18_linear_0_1" x1="360.294" y1="220.136" x2="400.025" y2="287.817" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint19_linear_0_1" x1="395.239" y1="296.693" x2="434.969" y2="364.374" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint20_linear_0_1" x1="255.46" y1="233.141" x2="295.19" y2="300.822" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint21_linear_0_1" x1="290.405" y1="261.162" x2="330.135" y2="328.843" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint22_linear_0_1" x1="325.35" y1="289.184" x2="365.08" y2="356.865" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
<linearGradient id="paint23_linear_0_1" x1="360.294" y1="317.206" x2="400.025" y2="384.887" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#E64A12"/>
|
||
<stop offset="1" stop-color="#801400"/>
|
||
</linearGradient>
|
||
</defs>
|
||
</svg>
|
||
<h1>OxideJS:面向 AI Agent 的轻量级 JavaScript 执行引擎</h1>
|
||
|
||
<p>
|
||
<img alt="Rust" src="https://img.shields.io/badge/Rust-1.80%2B-orange?style=for-the-badge&logo=rust" />
|
||
<img alt="Platform" src="https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-blue?style=for-the-badge" />
|
||
<img alt="Engine" src="https://img.shields.io/badge/JS%20Engine-Non--Wrapper-success?style=for-the-badge" />
|
||
<img alt="test262" src="https://img.shields.io/badge/test262-Integrated-purple?style=for-the-badge" />
|
||
</p>
|
||
|
||
</center>
|
||
|
||
## 1. 项目简介
|
||
|
||
OxideJS 是一个使用 Rust 编写的轻量级 JavaScript 执行引擎,面向短时、高频、即时执行的脚本运行场景,例如 Agent 工具调用、脚本沙箱、数据转换流水线和嵌入式运行时。
|
||
|
||
OxideJS 不是 V8、QuickJS、JavaScriptCore 或其他现有引擎的封装。项目实现了自己的编译流水线、字节码格式、虚拟机、值表示、对象模型和运行时核心。
|
||
|
||
当前项目聚焦于实用 ECMAScript 子集,并通过 [test262](https://github.com/tc39/test262) 持续验证兼容性。长期目标是提供一个小型、可检查、跨平台、启动成本可预测、benchmark 可复现的 JavaScript runtime。
|
||
|
||
## 2. 特性概览
|
||
|
||
- **Rust 实现**:使用 Cargo workspace 组织 parser、compiler、VM、runtime、CLI 和 test runner。
|
||
- **自研引擎**:自研字节码、寄存器式虚拟机、对象模型和运行时状态管理。
|
||
- **寄存器式 VM**:使用固定寄存器文件执行字节码,减少栈式 VM 中频繁 push/pop 的开销。
|
||
- **NaN-boxing 值表示**:用 64-bit 值统一表示 number、boolean、object、string、null 和 undefined。
|
||
- **Shape 对象布局**:使用隐藏类思想描述对象属性布局,便于缓存属性偏移。
|
||
- **Inline Cache 方向**:围绕 shape/offset 缓存设计属性访问路径。
|
||
- **共享运行时 Kernel**:统一管理字符串驻留、Shape、编译缓存、属性模板和内置对象。
|
||
- **test262 runner**:内置兼容性测试运行器,输出 pass / fail / skip 统计。
|
||
|
||
## 3. 架构
|
||
|
||
OxideJS 采用经典的 parse -> compile -> execute 流水线,同时使用 **单 Kernel、多 VM** 的运行时结构:一个 `OxideKernel` 保存可共享的字符串、Shape、编译缓存、属性模板和内置对象;多个 `oxide_vm` 实例面向不同执行请求独立运行,并共同引用同一个 Kernel。
|
||
|
||
```text
|
||
+----------------------+
|
||
| oxide_kernel |
|
||
|----------------------|
|
||
| StringForge |
|
||
| ShapeForge |
|
||
| CodeForge |
|
||
| PropForge |
|
||
| BuiltinWorld |
|
||
+----------+-----------+
|
||
|
|
||
shared Arc<OxideKernel> | shared Arc<OxideKernel>
|
||
+-----------------+-----------------+
|
||
| | |
|
||
v v v
|
||
+----------------+ +----------------+ +----------------+
|
||
| oxide_vm | | oxide_vm | | oxide_vm |
|
||
|----------------| |----------------| |----------------|
|
||
| registers | | registers | | registers |
|
||
| call frames | | call frames | | call frames |
|
||
| local epoch | | local epoch | | local epoch |
|
||
+-------+--------+ +-------+--------+ +-------+--------+
|
||
| | |
|
||
v v v
|
||
JsValue Result JsValue Result JsValue Result
|
||
|
||
Per request pipeline:
|
||
|
||
JavaScript Source
|
||
|
|
||
v
|
||
+------------------+
|
||
| oxide_parser | 解析源码,生成 AST
|
||
+------------------+
|
||
|
|
||
v
|
||
+------------------+
|
||
| oxide_compiler | AST 编译为寄存器式字节码;可命中 Kernel.CodeForge
|
||
+------------------+
|
||
|
|
||
v
|
||
+------------------+
|
||
| oxide_vm | 从 VM Pool 获取实例并执行字节码
|
||
+------------------+
|
||
```
|
||
|
||
核心组件:
|
||
|
||
1. **Parser 前端**:通过 `oxide_parser` 将源码解析为 AST。
|
||
2. **字节码编译器**:将 AST 降低为 OxideJS 字节码、常量池和寄存器布局。
|
||
3. **寄存器式 VM**:`oxide_vm` 读取字节码并使用固定寄存器文件执行;每个 VM 保持自己的寄存器、调用栈和本地 epoch。
|
||
4. **值系统**:`JsValue` 负责紧凑表示 JavaScript 运行时值。
|
||
5. **对象模型**:对象通过 Shape ID 描述属性布局。
|
||
6. **运行时 Kernel**:`OxideKernel` 保存可跨 VM 复用的共享状态;多个 VM 通过 `Arc<OxideKernel>` 引用同一个 Kernel,避免重复初始化字符串池、Shape 表、内置对象和编译缓存。
|
||
7. **内置对象层**:常用内置对象和方法由 Rust 原生实现。
|
||
8. **兼容性测试层**:`oxide_test262` 运行 test262 用例并输出统计结果。
|
||
|
||
## 4. 仓库结构
|
||
|
||
```text
|
||
project-root/
|
||
├── Cargo.toml
|
||
├── README.md
|
||
├── crates/
|
||
│ ├── oxide_parser/ # JavaScript parser 接入层
|
||
│ ├── oxide_compiler/ # AST -> bytecode 编译器
|
||
│ ├── oxide_types/ # JsValue、JsObject、Shape、内存基础类型
|
||
│ ├── oxide_kernel/ # 共享运行时状态和内置对象注册
|
||
│ ├── oxide_vm/ # 字节码 VM 和运行时执行逻辑
|
||
│ ├── oxide_api/ # 嵌入式 API 预留层
|
||
│ ├── oxide_cli/ # 命令行工具
|
||
│ └── oxide_test262/ # test262 兼容性测试运行器
|
||
└── tests/
|
||
└── test262/ # 本地 test262 测试套件
|
||
```
|
||
|
||
## 5. 构建
|
||
|
||
### 构建全部 crate
|
||
|
||
```bash
|
||
cargo build --release
|
||
```
|
||
|
||
### 运行单元测试
|
||
|
||
```bash
|
||
cargo test
|
||
```
|
||
|
||
## 6. CLI 使用
|
||
|
||
### 执行源码片段
|
||
|
||
```bash
|
||
cargo run --release -p oxide_cli -- eval "1 + 2"
|
||
```
|
||
|
||
### 执行文件
|
||
|
||
```bash
|
||
cargo run --release -p oxide_cli -- run examples/demo.js
|
||
```
|
||
|
||
### 打印编译后的字节码
|
||
|
||
```bash
|
||
cargo run --release -p oxide_cli -- compile -e "1 + 2"
|
||
```
|
||
|
||
### 启动 REPL
|
||
|
||
```bash
|
||
cargo run --release -p oxide_cli
|
||
```
|
||
|
||
## 7. test262 兼容性测试
|
||
|
||
OxideJS 包含独立的 test262 runner:
|
||
|
||
```bash
|
||
cargo run --release -p oxide_test262
|
||
```
|
||
|
||
运行指定子目录:
|
||
|
||
```bash
|
||
cargo run --release -p oxide_test262 -- tests/test262/test language/expressions
|
||
```
|
||
|
||
runner 会输出:
|
||
|
||
- 发现的测试文件总数;
|
||
- pass / fail / skip 数量;
|
||
- 全量通过率;
|
||
- 实际执行样本通过率;
|
||
- 失败类别统计;
|
||
- 按目录拆分的结果(取决于 runner 版本)。
|
||
|
||
兼容性数字属于开发过程指标。发布正式 benchmark 或兼容性结论前,应基于当前 checkout 的 test262 版本重新生成结果。
|
||
|
||
## 8. Benchmark
|
||
|
||
Benchmark 工作围绕可复现脚本和可比较 baseline 展开。
|
||
|
||
计划中的 benchmark 分组:
|
||
|
||
| 分组 | 目的 | 状态 |
|
||
|------|------|------|
|
||
| 表达式 microbenchmark | 算术、比较、逻辑操作 | planned |
|
||
| 对象 / 属性访问 benchmark | 对象创建和属性访问路径 | planned |
|
||
| Array / String benchmark | 常用内置对象操作 | planned |
|
||
| 函数调用 benchmark | 字节码 call/return 与 native call 开销 | planned |
|
||
| Agent 风格 workload | 短时、重复结构脚本和数据转换 | planned |
|
||
| JetStream 2.0 子集 | 依赖兼容性的 JS benchmark 覆盖 | planned |
|
||
|
||
当前研究用 baseline:
|
||
|
||
- QuickJS
|
||
- Boa
|
||
- JerryScript
|
||
|
||
[TODO] 完工时放与其他 baseline 的对比表格
|