Ark Compiler Explained

Ark Compiler
Developer:Huawei
Programming Language:ArkTS, Cangjie, JS, C, C++
Operating System:EMUI (HMS Apk apps), HarmonyOS, OpenHarmony, Oniro OS
Platform:ARM, RISC-V, x86, x64, LoongArch, Lingxi[1]
Genre:Compiler, Runtime environment, Compiler front end, Toolchain
License:Mixed: Proprietary (HarmonyOS), Apache License (OpenHarmony, Oniro OS, Android ArkCompiler)

Ark Compiler, also known as ArkCompiler, is a unified compilation and runtime platform that supports joint compilation and running across programming languages and chip platforms, also operating systems of open-source OpenHarmony, Oniro OS, alongside proprietary HarmonyOS with single core system HarmonyOS NEXT included on native APP in Event-driven programming in a unified development environment and formerly built for Android-based EMUI for Huawei smartphones and tablets with HMS-enabled apk apps on AppGallery that improves app performance.[2] It supports a variety of dynamic and static programming languages such as JS, TS, and ArkTS. It is the compilation and runtime base that enables OpenHarmony, Oniro OS alongside HarmonyOS NEXT to run on multiple device forms such as smart devices, mobile phones, PCs, tablets, TVs, automobiles, and wearables. ArkCompiler consists of two parts, compiler toolchain and runtime.[3]

Huawei initially open sourced Ark Compiler for Android platform on GitHub, on September 9, 2019, as they were transitioning away from the operating system via US sanctions.[4] Then the company, open sourced Ark Compiler with OpenArkCompiler as part of the Huawei Ark Compiler open source project (HACOSP) in early February 2022 [5] and ArkJS_runtime, in the previous year in September 2021 after two years of inception in August 2019.[6]

Overview

ArkCompiler has a built-in componentized and configurable multi-language compilation and runtime platform of OpenHarmony and HarmonyOS with HarmonyOS NEXT. It contains the core components such as the compiler, toolchain, and runtime. It supports compilation and running of high-level programming languages on the multi-chip platform. ArkCompiler JS Runtime provides the capability of compiling and running the JavaScript (JS) language on the OpenHarmony operating system side.

ArkCompiler JS Runtime consists of two parts such as the JS compiler toolchain and JS runtime. The JS compiler toolchain compiles JS source code into ArkCompiler bytecodes. The JS runtime executes the generated ArkCompiler bytecodes.[7]

ArkCompiler Runtime Core

HarmonyOS Runtime
Developer:Huawei
Programming Language:ArkTS, Cangjie, C, C++, JS
Operating System:HarmonyOS
Platform:ARM, RISC-V, x86, x64, LoongArch, Lingxi[8]
Genre:Runtime environment
License:Proprietary
Ark Runtime
Developer:Huawei
Programming Language:ArkTS
Operating System:HarmonyOS (HarmonyOS NEXT), OpenHarmony, Oniro OS
Platform:ARM, RISC-V, x86, x64, LoongArch, Lingxi[9]
Genre:Runtime environment, Compiler front end, Toolchain
License:Proprietary, Apache License (OpenHarmony ArkCompiler Runtime Core), Eclipse Public License (Oniro OS)

The common module of language runtime in OpenHarmony operating system called ArkCompiler Runtime Core also created as Ark Runtime on top of HarmonyOS Runtime base on current dual-framework, alongside single framework OpenHarmony-based HarmonyOS NEXT which consists of language-independent basic runtime libraries, including ArkCompiler File, Tooling, Base and ISA. The ArkCompiler File provides bytecodes and information required for executing the bytecodes. Tooling supports the runtime debugger. The Base is responsible for implementing platform related utilities. ISA function provides common instruction set architecture that is language-independent that allows to run HarmonyOS applications regardless of different instruction set and chipsets in hardware with great compatibility of diverse set of hardware and interoperability between HarmonyOS, Oniro and OpenHarmony software and hardware ecosystems.[10]

ArkCompiler JS Runtime

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.[11]

ArkCompiler eTS Runtime

ArkCompiler eTS Runtime is a runtime used in ArkTS applications derived from former HarmonyOS 3.0/OpenHarmony 3.1 API 8 eTS (extendedTypeScript) on OpenHarmony as well as HarmonyOS apps taking advantage of custom OpenHarmony-based HarmonyOS NEXT core operating system. It contains an allocator and garbage collector (GC) for ArkTS/JS objects, a standard library that conforms to the ECMAScript specification, an interpreter for running the ARK Bytecode (abc) generated by ARK front-end components, an inline cache for acceleration, a statically typed compiler, a C++/C function interface for Native API (NAPI) application development at runtime, and other modules in Ahead-of-time compilation via DevEco Studio since version 3.1.1 on both HarmonyOS 3.1 SDK and OpenHarmony 3.2 SDK API 9.[12]

ets_frontend

The ets_frontend is a front-end tool in the ARK Runtime Subsystem which combines the ace-ets2bundle component that supports converting ETS programming language files into ARK bytecode files. They correspond with ArkTS app development in OpenHarmony and HarmonyOS development under HarmonyOS NEXT system.[13]

ArkCompiler Toolchain

The ArkCompiler Toolchain provides developers with debugging tools for ArkTS application development, such as the Debugger, CPUProfiler, and HeapProfiler. The debugging and tuning capabilities provided by the Ark Toolchain is used through DevEco Studio IDE that relies on the ArkCompiler Runtime to provide runtime-related information to developers.[14]

Notes and References

  1. Web site: OpenHarmony 3.0 successfully adapted Loongson 1C300B chip . Huawei Update . 15 December 2021 . December 15, 2021.
  2. Web site: Siddiqui . Aamir . Ark Compiler Explained: How Huawei's App Compiler May Improve Android App Performance . XDA Developers . June 22, 2019 . 12 February 2024.
  3. Web site: ArkCompiler Runtime . OpenAtom Gitee . 12 February 2024.
  4. Web site: Amit . Huawei Ark compiler officially open source from GitHub for self-hosting . Huawei Update . September 9, 2019 . 12 February 2024.
  5. Web site: Sarkar . Amy . OpenArkCompiler 1.0 launched, Huawei Ark Compiler open source project (HACOSP). HC Newsroom . February 9, 2022 . 12 February 2024.
  6. Web site: Mishra . Yash . Ark Compiler JS runtime became open source in Huawei HarmonyOS . HC Newsroom . September 7, 2021 . 12 February 2024.
  7. Web site: Overview . OpenAtom Gitee . 12 February 2024.
  8. Web site: OpenHarmony 3.0 successfully adapted Loongson 1C300B chip . Huawei Update . 15 December 2021 . December 15, 2021.
  9. Web site: OpenHarmony 3.0 successfully adapted Loongson 1C300B chip . Huawei Update . 15 December 2021 . December 15, 2021.
  10. Web site: Runtime Core . OpenAtom Gitee . 12 February 2024.
  11. Web site: ArkCompiler JS Runtime . OpenAtom Gitee . 12 February 2024.
  12. Web site: ArkCompiler JS Runtime - ets Runtime . OpenAtom Gitee . 12 February 2024.
  13. Web site: ets_frontend . OpenAtom Gitee . 12 February 2024.
  14. Web site: Ark toolchain components . OpenAtom Gitee . 12 February 2024.