• Home
Name Date Size #Lines LOC

..--

docs/12-May-2024-1,3231,037

ecmascript/12-May-2024-221,556175,007

test/12-May-2024-2,6961,967

.gitignoreD12-May-2024156 1615

BUILD.gnD12-May-202417.3 KiB569521

LICENSED12-May-202410.1 KiB177150

OAT.xmlD12-May-20244.9 KiB7622

README.mdD12-May-20243.8 KiB8562

README_zh.mdD12-May-20243.7 KiB8562

bundle.jsonD12-May-2024968 3837

js_runtime_config.gniD12-May-20242.3 KiB7162

run_test262.shD12-May-20241.9 KiB5131

README.md

1# ARK JS Runtime Module<a name="EN-US_TOPIC_0000001183610495"></a>
2
3- [ARK JS Runtime Module<a name="EN-US_TOPIC_0000001183610495"></a>](#ark-js-runtime-module)
4    - [Introduction<a name="section190813718209"></a>](#introduction)
5  - [Directory Structure<a name="section161941989596"></a>](#directory-structure)
6  - [Constraints<a name="section119744591305"></a>](#constraints)
7  - [Build<a name="section137768191623"></a>](#build)
8    - [Available APIs<a name="section175841548124517"></a>](#available-apis)
9    - [Usage Guidelines<a name="section129654513264"></a>](#usage-guidelines)
10  - [Repositories Involved<a name="section1371113476307"></a>](#repositories-involved)
11
12### Introduction<a name="section190813718209"></a>
13
14ARK JS Runtime is the runtime used by JavaScript \(JS\) applications on OpenHarmony. It consists of the JS object allocator, garbage collector \(GC\), a standard library compliant with ECMAScript specifications, ARK bytecode interpreter, inline caches that store hidden classes, and the ARK Foreign Function Interface \(AFFI\).
15
16For more infomation, see: [ARK Runtime Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/ARK-Runtime-Subsystem.md).
17
18**ARK JS runtime architecture**
19
20![](docs/figures/en-us_image_0000001149439242.png)
21
22## Directory Structure<a name="section161941989596"></a>
23
24```
25/ark/js_runtime
26├─ ecmascript             # JS object definition
27│   ├─ base               # Base helper class
28│   ├─ builtins           # ECMAScript library
29│   ├─ class_linker       # Bytecode pre-processing module
30│   ├─ compiler           # JS compiler
31│   ├─ containers         # Non-ECMAScript container library
32│   ├─ cpu_profiler       # CPU Performance Analyzer
33│   ├─ hprof              # Memory analysis utility class
34│   ├─ ic                 # Inline cache module
35│   ├─ interpreter        # JS interpreter
36│   ├─ jobs               # Queue of jobs
37│   ├─ js_vm              # ARK command line tool
38│   ├─ mem                # Memory management module
39│   ├─ napi               # External native interface
40│   ├─ regexp             # Regular expression engine module
41│   ├─ snapshot/mem       # Snapshot module
42│   ├─ tests              # Unit test cases
43│   ├─ thread             # Thread pool
44│   ├─ tooling            # JS debugger
45│   └─ vmstat             # Runtime status utility classes
46└─ test                   # Module test cases
47```
48
49## Constraints<a name="section119744591305"></a>
50
51* Only the bytecode file generated by the ARK JS frontend can be run.
52* Only support ES2015 standard and strict mode ("use strict").
53* Don't support dynamically create functions via string (e.g., new Function("console.log(1))).
54
55## Build<a name="section137768191623"></a>
56
57```
58./build.sh --product-name Hi3516DV300 --build-target ark_js_runtime
59```
60
61### Available APIs<a name="section175841548124517"></a>
62
63For details, see  [NAPI](https://gitee.com/openharmony/ace_napi/blob/master/README.md).
64
65### Usage Guidelines<a name="section129654513264"></a>
66
67For details about how to generate JS bytecodes, see  [Using the Toolchain](docs/using-the-toolchain.md).
68
69To run bytecodes:
70```
71$ cd out/release
72$ export LD_LIBRARY_PATH=clang_x64/ark/ark_js_runtime:clang_x64/ark/ark:clang_x64/global/i18n:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/
73$ ./clang_x64/ark/ark_js_runtime/ark_js_vm helloworld.abc
74```
75
76For more infomation, please see: [ARK-Runtime-Usage-Guide](https://gitee.com/openharmony/ark_js_runtime/blob/master/docs/ARK-Runtime-Usage-Guide.md).
77
78## Repositories Involved<a name="section1371113476307"></a>
79
80[ark\_runtime\_core](https://gitee.com/openharmony/ark_runtime_core)
81
82**[ark\_js\_runtime](https://gitee.com/openharmony/ark_js_runtime)**
83
84[ark\_ts2abc](https://gitee.com/openharmony/ark_ts2abc)
85

README_zh.md

1# 方舟JS运行时组件<a name="ZH-CN_TOPIC_0000001183610495"></a>
2
3- [方舟JS运行时组件<a name="ZH-CN_TOPIC_0000001183610495"></a>](#方舟js运行时组件)
4    - [简介<a name="section190813718209"></a>](#简介)
5  - [目录<a name="section161941989596"></a>](#目录)
6  - [约束<a name="section119744591305"></a>](#约束)
7  - [编译构建<a name="section137768191623"></a>](#编译构建)
8    - [接口说明<a name="section175841548124517"></a>](#接口说明)
9    - [使用说明<a name="section129654513264"></a>](#使用说明)
10  - [相关仓<a name="section1371113476307"></a>](#相关仓)
11
12### 简介<a name="section190813718209"></a>
13
14方舟JS运行时(ARK JavaScript Runtime)是OpenHarmony上JS应用使用的运行时。包含JS对象的分配器以及垃圾回收器(GC)、符合ECMAScript规范的标准库、用于运行ARK前端组件生成的方舟字节码(ARK Bytecode,abc)的解释器、用于存储隐藏类的内联缓存、方舟JS运行时对外的函数接口(AFFI)等模块。
15
16更多信息请参考:[方舟运行时子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/ARK-Runtime-Subsystem-zh.md)
17
18**方舟JS运行时组件架构图:**
19
20![](docs/figures/zh-cn_image_0000001196712959.png)
21
22## 目录<a name="section161941989596"></a>
23
24```
25/ark/js_runtime
26├─ ecmascript             # 方舟JS运行时实现,包括ECMAScript标准库、解释器、内存管理等
27│   ├─ base               # 基础帮助类
28│   ├─ builtins           # ECMAScript标准库
29│   ├─ class_linker       # 字节码预处理模块
30│   ├─ compiler           # JS编译器
31│   ├─ containers         # 非ECMAScript标准容器类库
32│   ├─ cpu_profiler       # CPU性能分析器
33│   ├─ hprof              # 内存分析工具
34│   ├─ ic                 # 内联缓存模块
35│   ├─ interpreter        # JS解释器
36│   ├─ jobs               # 微任务队列
37│   ├─ js_vm              # 命令行工具
38│   ├─ mem                # 内存管理模块
39│   ├─ napi               # C++接口模块
40│   ├─ regexp             # 正则引擎模块
41│   ├─ snapshot           # 快照模块
42│   ├─ tests              # 单元测试用例
43│   ├─ thread             # 线程池
44│   ├─ tooling            # JS调试器
45│   └─ vmstat             # 运行时profiling工具
46└─ test                   # 模块测试用例
47```
48
49## 约束<a name="section119744591305"></a>
50
51* 仅支持运行方舟JS前端工具链\(ts2abc\)生成的方舟字节码文件
52* 只支持ES2015标准和严格模式(use strict)
53* 不支持通过字符串动态创建函数(比如new Function("console.log(1);"))
54
55## 编译构建<a name="section137768191623"></a>
56
57```
58$ ./build.sh --product-name Hi3516DV300 --build-target ark_js_runtime
59```
60
61### 接口说明<a name="section175841548124517"></a>
62
63NAPI接口说明参考[NAPI组件](https://gitee.com/openharmony/ace_napi/blob/master/README_zh.md)
64
65### 使用说明<a name="section129654513264"></a>
66
67JS生成字节码参考[工具链使用](docs/using-the-toolchain-zh.md)
68
69字节码执行:
70```
71$ cd out/release
72$ export LD_LIBRARY_PATH=clang_x64/ark/ark_js_runtime:clang_x64/ark/ark:clang_x64/global/i18n:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/
73$ ./clang_x64/ark/ark_js_runtime/ark_js_vm helloworld.abc
74```
75
76更多使用说明请参考:[方舟运行时使用指南](https://gitee.com/openharmony/ark_js_runtime/blob/master/docs/ARK-Runtime-Usage-Guide-zh.md)
77
78## 相关仓<a name="section1371113476307"></a>
79
80[ark\_runtime\_core](https://gitee.com/openharmony/ark_runtime_core)
81
82**[ark\_js\_runtime](https://gitee.com/openharmony/ark_js_runtime)**
83
84[ark\_ts2abc](https://gitee.com/openharmony/ark_ts2abc)
85