Современные информационные технологии и IT-образование (Dec 2021)

Automatic Generation of Interpreter for Multilingual Virtual Machine

  • Mark Gonopolskiy

DOI
https://doi.org/10.25559/SITITO.17.202104.988-997
Journal volume & issue
Vol. 17, no. 4
pp. 988 – 997

Abstract

Read online

The article says about existing implementations of interpreter generators and proposes an approach for generating interpreters in assembly for several architectures by describing a set of instructions (BISA - Bytecode Instruction Set Architecture) of a multilingual stack virtual machine (VM - Virtual Machine) with an interpreter, compiler and garbage collector. Each instruction from BISA has a unique BISA handler. For each BISA handler, there are a specified number that defines its position, a frequency of usage of the corresponding instruction in the set of target applications (STA), and a set of pseudo-language instructions that characterizes the logic of handling the corresponding BISA instruction by the virtual machine. STA consists of applications designed to be run on the given virtual machine. An interpreter is a sequential set of BISA handlers. According to the approach chosen by the author, to obtain interpreters in assembly using BISA, it is necessary to do three consecutive steps. During the first step, the BISA handlers are converted into an intermediate representation of the interpreter. In the second step, machine-independent optimizations of the intermediate code of the interpreter are performed. At the third step, the intermediate representation of the interpreter is converted into representations of the selected architectures and machine-dependent optimizations are performed. A C ++ tool was developed that implements a simplified, non-optimized version of the given approach for two instructions. An experimental study was carried out, during which the proposed generator was compared with the clang ++ compiler in terms of the number of generated instructions of the target machine for each BISA processor. Experimental research has shown that the selected approaches are equivalent, even when using a simplified algorithm for generating interpreters. In the longer run, it is planned to optimize the proposed approach, which will allow surpassing the known approaches in performance.

Keywords