updated reamde (EN)

Signed-off-by: wusongqing <wusongqing@huawei.com>
This commit is contained in:
wusongqing 2022-07-08 14:04:42 +08:00
parent 63b6a0d631
commit 095d0f72cb

View File

@ -1,79 +1,73 @@
# ARK JS Runtime Module<a name="EN-US_TOPIC_0000001183610495"></a>
# ArkCompiler JS Runtime
- [ARK JS Runtime Module<a name="EN-US_TOPIC_0000001183610495"></a>](#ark-js-runtime-module)
- [Introduction<a name="section190813718209"></a>](#introduction)
- [Directory Structure<a name="section161941989596"></a>](#directory-structure)
- [Constraints<a name="section119744591305"></a>](#constraints)
- [Build<a name="section137768191623"></a>](#build)
- [Available APIs<a name="section175841548124517"></a>](#available-apis)
- [Usage Guidelines<a name="section129654513264"></a>](#usage-guidelines)
- [Repositories Involved<a name="section1371113476307"></a>](#repositories-involved)
### Introduction
### Introduction<a name="section190813718209"></a>
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.
ARK 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\).
For more information, see [ArkCompiler JS Runtime](https://gitee.com/openharmony/docs/blob/master/en/readme/ARK-Runtime-Subsystem.md).
For more information, see: [ARK Runtime Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/ARK-Runtime-Subsystem.md).
**ArkCompiler JS Runtime architecture**
**ARK JS runtime architecture**
![](/docs/figures/en-us_image_ark-js-arch.png)
![](docs/figures/en-us_image_0000001149439242.png)
## Directory Structure<a name="section161941989596"></a>
## Directory Structure
```
/ark/js_runtime
├─ ecmascript # JS object definition
├─ ecmascript # Implementation of ArkCompiler JS Runtime, including the ECMAScript library, interpreter, and memory management
│ ├─ base # Base helper class
│ ├─ builtins # ECMAScript library
│ ├─ class_linker # Bytecode pre-processing module
│ ├─ builtins # ECMAScript libraries
│ ├─ compiler # JS compiler
│ ├─ containers # Non-ECMAScript container library
│ ├─ cpu_profiler # CPU Performance Analyzer
│ ├─ hprof # Memory analysis utility class
│ ├─ containers # Non-ECMAScript containers
│ ├─ dfx # Memory and profiling tool
│ ├─ ic # Inline cache module
│ ├─ interpreter # JS interpreter
│ ├─ jobs # Queue of jobs
│ ├─ js_vm # ARK command line tool
│ ├─ js_vm # Command line tool
│ ├─ jspandafile # abc file management module
│ ├─ mem # Memory management module
│ ├─ napi # External native interface
│ ├─ module # ECMAScript module
│ ├─ napi # C++ API module
│ ├─ taskpool # Task pool
│ ├─ regexp # Regular expression engine module
│ ├─ snapshot/mem # Snapshot module
│ ├─ snapshot # Snapshot module
│ ├─ stubs # Runtime stub functions
│ ├─ tests # Unit test cases
│ ├─ thread # Thread pool
│ ├─ tooling # JS debugger
│ └─ vmstat # Runtime status utility classes
└─ test # Module test cases
│ ├─ trampoline # Trampoline function
│ ├─ ts_type # TS type management module
└─ test # Module test cases
```
## Constraints<a name="section119744591305"></a>
## Constraints
* Only the bytecode file generated by the ARK JS frontend can be run.
* Only support ES2015 standard and strict mode ("use strict").
* Don't support dynamically create functions via string (e.g., new Function("console.log(1))).
* Only the ArkCompiler bytecode files generated by ts2abc, which is the ArkCompiler JS frontend toolchain, can be run.
* Only the ES2015 standard and strict modes are supported.
* Functions cannot be dynamically created using strings, such as new Function("console.log(1);")).
## Build<a name="section137768191623"></a>
## Building
```
./build.sh --product-name hispark_taurus_standard --build-target ark_js_host_linux_tools_packages
$./build.sh --product-name hispark_taurus_standard --build-target ark_js_host_linux_tools_packages
```
### Available APIs<a name="section175841548124517"></a>
### Available APIs
For details, see [NAPI](https://gitee.com/openharmony/ace_napi/blob/master/README.md).
See [NAPI](https://gitee.com/openharmony/ace_napi/blob/master/README.md).
### Usage Guidelines<a name="section129654513264"></a>
### Usage
For details about how to generate JS bytecodes, see [Using the Toolchain](docs/using-the-toolchain.md).
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/ark/ark:out/hispark_taurus/clang_x64/ark/ark_js_runtime:out/hispark_taurus/clang_x64/thirdparty/icu:prebuilts/clang/ohos/linux-x86_64/llvm/lib ./out/hispark_taurus/clang_x64/ark/ark_js_runtime/ark_js_vm helloworld.abc
```
For more information, please see: [ARK-Runtime-Usage-Guide](https://gitee.com/openharmony/ark_js_runtime/blob/master/docs/ARK-Runtime-Usage-Guide.md).
For more information, see [ARK Runtime Usage Guide](https://gitee.com/openharmony/ark_js_runtime/blob/master/docs/ARK-Runtime-Usage-Guide.md).
## Repositories Involved<a name="section1371113476307"></a>
## Repositories Involved
[ark\_runtime\_core](https://gitee.com/openharmony/ark_runtime_core)