arkcompiler_ets_runtime/README.md

78 lines
3.2 KiB
Markdown
Raw Normal View History

# ArkCompiler JS Runtime
2021-09-01 06:28:24 +00:00
### Introduction
2021-09-01 06:28:24 +00:00
ArkCompiler 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.
2021-09-01 06:28:24 +00:00
For more information, see [ArkCompiler JS Runtime](https://gitee.com/openharmony/docs/blob/master/en/readme/ARK-Runtime-Subsystem.md).
2021-09-01 06:28:24 +00:00
**ArkCompiler JS Runtime architecture**
![](/docs/figures/en-us_image_ark-js-arch.png)
2021-09-01 06:28:24 +00:00
## Directory Structure
2021-09-01 06:28:24 +00:00
```
/arkcompiler/ets_runtime
├─ ecmascript # Implementation of ArkCompiler JS Runtime, including the ECMAScript library, interpreter, and memory management
│ ├─ base # Base helper class
│ ├─ builtins # ECMAScript libraries
│ ├─ compiler # JS compiler
│ ├─ containers # Non-ECMAScript containers
│ ├─ dfx # Memory and profiling tool
│ ├─ ic # Inline cache module
│ ├─ interpreter # JS interpreter
│ ├─ jobs # Queue of jobs
│ ├─ js_vm # Command line tool
│ ├─ jspandafile # abc file management module
│ ├─ mem # Memory management module
│ ├─ module # ECMAScript module
│ ├─ napi # C++ API module
│ ├─ taskpool # Task pool
│ ├─ regexp # Regular expression engine module
│ ├─ snapshot # Snapshot module
│ ├─ stubs # Runtime stub functions
│ ├─ tests # Unit test cases
│ ├─ debugger # JS debugger
│ ├─ trampoline # Trampoline function
│ ├─ ts_type # TS type management module
└─ test # Module test cases
```
2021-09-01 06:28:24 +00:00
## Constraints
2021-09-01 06:28:24 +00:00
* Only the ArkCompiler bytecode files generated by ts2abc, which is the ArkCompiler JS frontend toolchain, can be run.
* Only the ES2021 standard and strict modes are supported.
* Functions cannot be dynamically created using strings, such as new Function("console.log(1);")).
2021-09-01 06:28:24 +00:00
## Building
```
$./build.sh --product-name hispark_taurus_standard --build-target ark_js_host_linux_tools_packages
```
### Available APIs
See [NAPI](https://gitee.com/openharmony/ace_napi/blob/master/README.md).
### Usage
For details about how to generate JS bytecodes, see [Using the Toolchain](docs/using-the-toolchain.md).
To run bytecodes:
```
LD_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
```
For more information, see [ARK Runtime Usage Guide](https://gitee.com/openharmony/arkcompiler_ets_runtime/blob/master/
docs/ARK-Runtime-Usage-Guide.md).
## Repositories Involved
[arkcompiler\_runtime\_core](https://gitee.com/openharmony/arkcompiler_runtime_core)
**[arkcompiler\_ets\_runtime](https://gitee.com/openharmony/arkcompiler_ets_runtime)**
2021-09-01 06:28:24 +00:00
[arkcompiler\_ets\_frontend](https://gitee.com/openharmony/arkcompiler_ets_frontend)