• Home
Name Date Size #Lines LOC

..--

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

ecmascript/12-May-2024-153,493119,260

test/12-May-2024-1,5171,038

.gitignoreD12-May-2024150 1514

BUILD.gnD12-May-202412.3 KiB413378

LICENSED12-May-202410.1 KiB177150

OAT.xmlD12-May-20244.9 KiB7622

README.mdD12-May-20243.7 KiB8360

README_zh.mdD12-May-20243.6 KiB8360

bundle.jsonD12-May-20241.3 KiB5858

js_runtime_config.gniD12-May-2024828 2017

ohos.buildD12-May-2024375 2019

run_test262.shD12-May-20241.7 KiB4827

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│   ├─ hprof              # Memory analysis utility class
32│   ├─ ic                 # Inline cache module
33│   ├─ interpreter        # JS interpreter
34│   ├─ jobs               # Queue of jobs
35│   ├─ js_vm              # ARK command line tool
36│   ├─ mem                # Memory management module
37│   ├─ napi               # External native interface
38│   ├─ regexp             # Regular expression engine module
39│   ├─ snapshot/mem       # Snapshot module
40│   ├─ tests              # Unit test cases
41│   ├─ thread             # Thread pool
42│   ├─ tooling            # JS debugger
43│   └─ vmstat             # Runtime status utility classes
44└─ test                   # Module test cases
45```
46
47## Constraints<a name="section119744591305"></a>
48
49* Only the bytecode file generated by the ARK JS frontend can be run.
50* Only support ES2015 standard and strict mode ("use strict").
51* Don't support dynamically create functions via string (e.g., new Function("console.log(1))).
52
53## Build<a name="section137768191623"></a>
54
55```
56./build.sh --product-name Hi3516DV300 --build-target ark_js_runtime
57```
58
59### Available APIs<a name="section175841548124517"></a>
60
61For details, see  [NAPI](https://gitee.com/openharmony/ace_napi/blob/master/README.md).
62
63### Usage Guidelines<a name="section129654513264"></a>
64
65For details about how to generate JS bytecodes, see  [Using the Toolchain](docs/using-the-toolchain.md).
66
67To run bytecodes:
68```
69$ cd out/release
70$ 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/
71$ ./clang_x64/ark/ark_js_runtime/ark_js_vm helloworld.abc
72```
73
74For more infomation, please see: [ARK-Runtime-Usage-Guide](https://gitee.com/openharmony/ark_js_runtime/blob/master/docs/ARK-Runtime-Usage-Guide.md).
75
76## Repositories Involved<a name="section1371113476307"></a>
77
78[ark\_runtime\_core](https://gitee.com/openharmony/ark_runtime_core)
79
80**[ark\_js\_runtime](https://gitee.com/openharmony/ark_js_runtime)**
81
82[ark\_ts2abc](https://gitee.com/openharmony/ark_ts2abc)
83

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│   ├─ hprof              # 内存分析工具
32│   ├─ ic                 # 内联缓存模块
33│   ├─ interpreter        # JS解释器
34│   ├─ jobs               # 微任务队列
35│   ├─ js_vm              # 命令行工具
36│   ├─ mem                # 内存管理模块
37│   ├─ napi               # C++接口模块
38│   ├─ regexp             # 正则引擎模块
39│   ├─ snapshot           # 快照模块
40│   ├─ tests              # 单元测试用例
41│   ├─ thread             # 线程池
42│   ├─ tooling            # JS调试器
43│   └─ vmstat             # 运行时profiling工具
44└─ test                   # 模块测试用例
45```
46
47## 约束<a name="section119744591305"></a>
48
49* 仅支持运行方舟JS前端工具链\(ts2abc\)生成的方舟字节码文件
50* 只支持ES2015标准和严格模式(use strict)
51* 不支持通过字符串动态创建函数(比如new Function("console.log(1);"))
52
53## 编译构建<a name="section137768191623"></a>
54
55```
56$ ./build.sh --product-name Hi3516DV300 --build-target ark_js_runtime
57```
58
59### 接口说明<a name="section175841548124517"></a>
60
61NAPI接口说明参考[NAPI组件](https://gitee.com/openharmony/ace_napi/blob/master/README_zh.md)
62
63### 使用说明<a name="section129654513264"></a>
64
65JS生成字节码参考[工具链使用](docs/using-the-toolchain-zh.md)
66
67字节码执行:
68```
69$ cd out/release
70$ 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/
71$ ./clang_x64/ark/ark_js_runtime/ark_js_vm helloworld.abc
72```
73
74更多使用说明请参考:[方舟运行时使用指南](https://gitee.com/openharmony/ark_js_runtime/blob/master/docs/ARK-Runtime-Usage-Guide-zh.md)
75
76## 相关仓<a name="section1371113476307"></a>
77
78[ark\_runtime\_core](https://gitee.com/openharmony/ark_runtime_core)
79
80**[ark\_js\_runtime](https://gitee.com/openharmony/ark_js_runtime)**
81
82[ark\_ts2abc](https://gitee.com/openharmony/ark_ts2abc)
83