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