• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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