Skip to main content

Command Palette

Search for a command to run...

Architecture adjustment of Aq virtual machine and bytecode

Updated
3 min read

Yesterday, AQ v0.1.0-alpha was released, and the virtual machine design continued the previous architecture without any architecture level adjustments. For current needs, it can meet certain requirements. However, in the recent development process, areas that can be optimized have been identified. The focus is on adjusting the memory architecture.

At present, bytecode directly stores all memory data and types. A large amount of data among them needs to be written by the virtual machine during runtime, so a large amount of data is allocated when not in use, resulting in a lot of memory waste. For the example Hello World (hello world. aq, hello world. aqbc), the AQ v0.1.0-alpha source code only occupies about 50 bytes, but the bytecode memory occupies about 100 bytes. To some extent, the original purpose of bytecode - to save memory - has failed to play a role and has increased the burden.

Therefore, it is extremely necessary to adjust the architecture of AQ virtual machines and bytecode. Refer to current interpreted programming languages. The most common approach is to use a constant pool.

To achieve this goal, the following changes are required:

  1. Modify the relevant code of the compiler.

  2. Modify the relevant code of the virtual machine.

  3. Add new instructions to read data from the constant pool.

  4. Adjust the original type storage method and refer to the bytecode constant pool design methods in Python and JavaScript.

There is still a significant amount of resource waste at present, and this issue should be addressed when AQ v0.11-alpha is released.

Meanwhile, in addition to the issues mentioned here, there are still many unresolved issues in the release of AQ v0.1.0-alpha. One of the more serious issues is the failure to handle the parameters and return values of custom functions.

For this issue, one should also refer to the design ideas of interpreted programming languages such as Python and JavaScript. Optimize function calls to avoid wasting resources during the calling process.

In addition, there is an extremely important issue that has not been resolved in this version release - the design of implementing standard libraries and the calling of third-party libraries. At present, only print function is supported, and third-party libraries cannot call it. Therefore, the resolution should also be accelerated.

In this version, there are still type conversion errors that cannot be automatically converted and should be fixed as soon as possible.

In this version, support for new syntax is still lacking and should be added as soon as possible.

In this version, support for dynamic types is not available and should be added in subsequent compiler and virtual machine adjustments.

Finally, the release of AQ v0.1.1-alpha version will also follow closely, and relevant issues should be resolved as soon as possible.

More from this blog

模块导入功能设计草稿

模块以Java类似的方式实现导入(全限定名实现),删除原有字节码单独的设计内容。 仍然使用绝对或相对路径的字符串作为导入的第一个参数,第二个参数不可省略,为模块别名。 目前已经实现了模块导入的部分功能,但由于部分设计问题,存在较多错误。 from-import延迟实现。 在HandleImport时创建一个新的类,名称为”~导入路径~.!__start”。其它类处理同样参见这个操作,类名均改为”~导入路径~.类”。但是在处理类的创建时(各种HandleVarDecl及类似函数),应当加入类型处理...

Apr 26, 20251 min read3

Aq语言语法设计文档

概览 为满足AQ语言持续发展,提升AQ语言在软件开发的便捷性和高效性,提升AQ语言长期持续有效发展,推进AQ v0.2.0 版本更快面向市场发布,决定对AQ语言的语法进行规范。 其详细的语法参照市面上常见的编程语言,总结其共有特点,对语言语法进行简化,同时完善部分语言的历史性问题,在语法上进行优化,降低学习难度和成本。 注释 注释参照C/C++等C-style语言的设计,采用两种注释方式。 // 单行注释 /*多 行 注 释*/ 运算符 基本采取和主流语言一致(参照C/C++),部...

Mar 20, 20251 min read6
A

AQ Developer Blog

9 posts

AQ Official Developer Blog. Github: https://github.com/aq-org/AQ Official Website: https://www.axa6.com Email: xie.zicong@axa6.com