• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ArkCompiler JS Runtime
2
3- [ArkCompiler JS Runtime](#ArkCompiler_JS_Runtime)
4    - [Introduction](#Introduction)
5  - [Directory Structure](#Directory_Structure)
6  - [Constraints](#Constraints)
7  - [Building](#Building)
8    - [Available APIs](#Available_APIs)
9    - [Usage](#Usage)
10  - [Repositories Involved](#Repositories_Involved)
11
12### Introduction
13
14ArkCompiler JS Runtime is the default JS runtime on OpenHarmony. It supports ECMAScript libraries and efficient container libraries. It also provides a set of native APIs for C++ and JS interaction and a variety of garbage collectors that features high performance.
15
16For more information, see [ArkCompiler JS Runtime](https://gitee.com/openharmony/docs/blob/master/en/readme/ARK-Runtime-Subsystem.md).
17
18**ArkCompiler JS Runtime architecture**
19
20![](/docs/figures/en-us_image_ark-js-arch.png)
21
22## Directory Structure
23
24```
25/arkcompiler/ets_runtime
26├─ ecmascript             # Implementation of ArkCompiler JS Runtime, including the ECMAScript library, interpreter, and memory management
27│   ├─ base               # Base helper class
28│   ├─ builtins           # ECMAScript libraries
29│   ├─ checkpoint         # Virtual machine safepoint
30│   ├─ compiler           # JS compiler
31│   ├─ containers         # Non-ECMAScript containers
32│   ├─ daemon             # Shared GC concurrent thread
33│   ├─ debugger           # JS debugger
34│   ├─ deoptimizer        # Compiler deoptimization
35│   ├─ dfx                # Memory and profiling tool
36│   ├─ extractortool      # Sourcemap parsing
37│   ├─ ic                 # Inline cache module
38│   ├─ interpreter        # JS interpreter
39│   ├─ intl               # Internationalization
40│   ├─ jit                # Jit compiler
41│   ├─ jobs               # Queue of jobs
42│   ├─ js_api             # Non-ecma standard object model
43│   ├─ js_type_metadata   # Object layout file
44│   ├─ js_vm              # Command line tool
45│   ├─ jspandafile        # abc file management module
46│   ├─ mem                # Memory management module
47│   ├─ module             # ECMAScript module
48│   ├─ napi               # C++ API module
49│   ├─ ohos               # System-related logic
50│   ├─ patch              # Cold patch, hot patch
51│   ├─ pgo_profiler       # A performance analyzer based on profile-guided optimization (pgo), used for performance analysis and optimization
52│   ├─ platform           # Cross-platform processing
53│   ├─ quick_fix          # Quickly fix the command-line tool
54│   ├─ regexp             # Regular expression engine module
55│   ├─ require            # Commonjs module specification
56│   ├─ sdk                # Integration of sdk tools
57│   ├─ serializer         # Serialization
58│   ├─ shared_mm          # Shared memory management module
59│   ├─ shared_objects     # Implementation of shared objects
60│   ├─ snapshot           # Snapshot module
61│   ├─ stackmap           # Location information of active variables
62│   ├─ stubs              # Runtime stub functions
63│   ├─ taskpool           # Task pool
64│   ├─ tests              # Unit test cases
65│   ├─ ts_types           # TS type management module
66└─ test                   # Module test cases
67```
68
69## Constraints
70
71* Only the ArkCompiler bytecode files generated by ts2abc, which is the ArkCompiler JS frontend toolchain, can be run.
72* Only the ES2021 standard and strict modes are supported.
73* Functions cannot be dynamically created using strings, such as new Function("console.log(1);")).
74
75## Building
76
77```
78$./build.sh --product-name hispark_taurus_standard --build-target ark_js_host_linux_tools_packages
79```
80
81### Available APIs
82
83See [NAPI](https://gitee.com/openharmony/arkui_napi/blob/master/README.md).
84
85### Usage
86
87For details about how to generate JS bytecodes, see [Using the Toolchain](docs/using-the-toolchain.md).
88
89To run bytecodes:
90```
91LD_LIBRARY_PATH=out/hispark_taurus/clang_x64/arkcompiler/ets_runtime:out/hispark_taurus/clang_x64/thirdparty/icu:prebuilts/clang/ohos/linux-x86_64/llvm/lib ./out/hispark_taurus/clang_x64/arkcompiler/ets_runtime/ark_js_vm helloworld.abc
92
93```
94
95For more information, see [ARK Runtime Usage Guide](https://gitee.com/openharmony/arkcompiler_ets_runtime/blob/master/
96docs/ARK-Runtime-Usage-Guide.md).
97
98## Repositories Involved
99
100[arkcompiler\_runtime\_core](https://gitee.com/openharmony/arkcompiler_runtime_core)
101
102**[arkcompiler\_ets\_runtime](https://gitee.com/openharmony/arkcompiler_ets_runtime)**
103
104[arkcompiler\_ets\_frontend](https://gitee.com/openharmony/arkcompiler_ets_frontend)
105