ARK Runtime Subsystem

Introduction

ARK is a unified programming platform developed by Huawei. Its key components include a compiler, toolchain, and runtime. ARK supports compilation and execution of high-level programming languages on the multiple hardware platform and accelerates the execution of the OpenHarmony operating system and its applications and services on mobile phones, PCs, tablets, TVs, automobiles, and smart wearables. The ARK-JS open sourced this time provides the capability of compiling and running the JavaScript (JS) language on the standard system of OpenHarmony.

The ARK-JS consists of two parts: JS compiler toolchain and JS runtime. The JS compiler toolchain compiles JS source code into ARK bytecodes. The JS runtime executes the generated ARK bytecodes. Unless otherwise specified, bytecodes refer to ARK bytecodes in this document.

The following figure shows the architecture of the JS compiler toolchain.

The JS front-end compiler parses the JS source code into an abstract syntax tree (AST), which is processed by the AST transformer, bytecode generator, and register allocator. The native emiter generates the ARK bytecode file (.abc).

The following figure shows the JS runtime architecture.

ARK-JS Runtime runs ARK bytecode files to implement JS semantic logic.

ARK-JS Runtime consists of the following:

  • Core Runtime

    Core Runtime consists of basic language-irrelevant runtime libraries, including ARK File, Tooling, and ARK Base. ARK File provides bytecodes. Tooling supports Debugger. ARK Base is responsible for implementing system calls.

  • Execution Engine

    The Execution Engine consists of an interpreter that executes bytecodes, Inline Caches that store hidden classes, and Profiler that analyzes and records runtime types.

  • ECMAScript Runtime

    ECMAScript Runtime consists of the JS object allocator, garbage collector (GC), and an internal library that supports ECMAScript specifications.

  • ARK Foreign Function Interface (AFFI)

    The AFFI provides a C++ function interface for ARK-JS runtime.

Directory Structure

/ark
├── js_runtime       # JS runtime module
├── runtime_core     # Runtime common module
└── ts2abc           # JS front-end tool

Usage Guide

ARK-Runtime-Usage-Guide

Repositories Involved

ark_runtime_core

ark_js_runtime

ark_ts2abc