WARDuino: An embedded WebAssembly virtual machine

IF 1.7 3区 计算机科学 Q3 COMPUTER SCIENCE, SOFTWARE ENGINEERING Journal of Computer Languages Pub Date : 2024-02-13 DOI:10.1016/j.cola.2024.101268
Tom Lauwaerts, Robbert Gurdeep Singh , Christophe Scholliers
{"title":"WARDuino: An embedded WebAssembly virtual machine","authors":"Tom Lauwaerts,&nbsp;Robbert Gurdeep Singh ,&nbsp;Christophe Scholliers","doi":"10.1016/j.cola.2024.101268","DOIUrl":null,"url":null,"abstract":"<div><p>Creating IoT programs for resource-constrained microcontrollers differs significantly from conventional computer programming. Microcontrollers are traditionally programmed using low-level programming languages with poor debugging facilities. By contrast, general-purpose systems can be programmed with high-level languages, which make programming easier by providing many useful tools such as advanced debuggers, strong type systems, and/or automatic memory management. Most existing solutions for programming microcontrollers with high-level languages are strongly tied to a specific microcontroller architecture, which makes porting code difficult or impossible. In addition, compiling and flashing software onto a microcontroller is time-consuming, slowing down development.</p><p>To solve these problems we present WARDuino, a WebAssembly virtual machine that runs on microcontrollers and provides WebAssembly primitives to control embedded hardware and IoT functionality. WARDuino runs programs written in a plethora of high-level languages that compile to WebAssembly. We give a general approach for language integration libraries to expose the peripherals and networking capabilities of the device following the idioms of the host language.</p><p>To ease development, we extend WebAssembly with support for remote debugging and over-the-air reprogramming. WARDuino can remotely instruct a microcontroller to pause, to step, or to dump its state, and to replace local variables, functions or even the entire running program. We use the remote debugger of the virtual machine to create a visual debugging environment in VS Code for WARDuino, that can debug WebAssembly and AssemblyScript. Aside from these important tools, we provide a novel mechanism to handle asynchronous interrupts in WebAssembly, a fundamental building block for responsive embedded applications. Our extensions are implemented in the WARDuino virtual machine and presented as formal extensions to the WebAssembly operational semantics. We use the formalization to proof observational equivalence for the core debugger semantics.</p><p>We compared the computational performance and memory size with native C code, Espruino, and WASM3 which compiles WebAssembly ahead-of-time. The comparison shows that WARDuino’s performance is acceptable. Although WARDuino is on average 425.93 times slower than native code and 37.96 times slower than WASM3, it outperforms the popular Espruino runtime by a factor of 11.66. Additionally, we show that WARDuino is fast enough to program traditional IoT applications that handle network and device interrupts with a classic smart lamp application written in AssemblyScript.</p></div>","PeriodicalId":48552,"journal":{"name":"Journal of Computer Languages","volume":"79 ","pages":"Article 101268"},"PeriodicalIF":1.7000,"publicationDate":"2024-02-13","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Journal of Computer Languages","FirstCategoryId":"94","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S259011842400011X","RegionNum":3,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0

Abstract

Creating IoT programs for resource-constrained microcontrollers differs significantly from conventional computer programming. Microcontrollers are traditionally programmed using low-level programming languages with poor debugging facilities. By contrast, general-purpose systems can be programmed with high-level languages, which make programming easier by providing many useful tools such as advanced debuggers, strong type systems, and/or automatic memory management. Most existing solutions for programming microcontrollers with high-level languages are strongly tied to a specific microcontroller architecture, which makes porting code difficult or impossible. In addition, compiling and flashing software onto a microcontroller is time-consuming, slowing down development.

To solve these problems we present WARDuino, a WebAssembly virtual machine that runs on microcontrollers and provides WebAssembly primitives to control embedded hardware and IoT functionality. WARDuino runs programs written in a plethora of high-level languages that compile to WebAssembly. We give a general approach for language integration libraries to expose the peripherals and networking capabilities of the device following the idioms of the host language.

To ease development, we extend WebAssembly with support for remote debugging and over-the-air reprogramming. WARDuino can remotely instruct a microcontroller to pause, to step, or to dump its state, and to replace local variables, functions or even the entire running program. We use the remote debugger of the virtual machine to create a visual debugging environment in VS Code for WARDuino, that can debug WebAssembly and AssemblyScript. Aside from these important tools, we provide a novel mechanism to handle asynchronous interrupts in WebAssembly, a fundamental building block for responsive embedded applications. Our extensions are implemented in the WARDuino virtual machine and presented as formal extensions to the WebAssembly operational semantics. We use the formalization to proof observational equivalence for the core debugger semantics.

We compared the computational performance and memory size with native C code, Espruino, and WASM3 which compiles WebAssembly ahead-of-time. The comparison shows that WARDuino’s performance is acceptable. Although WARDuino is on average 425.93 times slower than native code and 37.96 times slower than WASM3, it outperforms the popular Espruino runtime by a factor of 11.66. Additionally, we show that WARDuino is fast enough to program traditional IoT applications that handle network and device interrupts with a classic smart lamp application written in AssemblyScript.

查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
WARDuino:嵌入式 WebAssembly 虚拟机
为资源有限的微控制器创建物联网程序与传统的计算机编程有很大不同。微控制器传统上使用低级编程语言进行编程,调试功能较差。相比之下,通用系统可以使用高级语言编程,高级语言提供了许多有用的工具,如高级调试器、强大的类型系统和/或自动内存管理,从而使编程变得更加容易。大多数现有的使用高级语言对微控制器进行编程的解决方案都与特定的微控制器架构紧密相关,这使得代码移植变得困难或不可能。为了解决这些问题,我们推出了 WARDuino,它是一个可在微控制器上运行的 WebAssembly 虚拟机,提供了控制嵌入式硬件和物联网功能的 WebAssembly 基元。WARDuino 可运行以大量高级语言编写并编译为 WebAssembly 的程序。为了简化开发,我们扩展了 WebAssembly,支持远程调试和空中重新编程。WARDuino 可以远程指示微控制器暂停、步进或转储其状态,并替换局部变量、函数甚至整个运行程序。我们使用虚拟机的远程调试器在 VS Code 中为 WARDuino 创建了一个可视化调试环境,可以调试 WebAssembly 和 AssemblyScript。除了这些重要工具外,我们还提供了一种新颖的机制来处理 WebAssembly 中的异步中断,这是响应式嵌入式应用程序的基本构件。我们的扩展在 WARDuino 虚拟机中实现,并作为 WebAssembly 操作语义的形式化扩展呈现。我们将计算性能和内存大小与本地 C 代码、Espruino 和提前编译 WebAssembly 的 WASM3 进行了比较。比较结果表明,WARDuino 的性能是可以接受的。虽然 WARDuino 平均比本地代码慢 425.93 倍,比 WASM3 慢 37.96 倍,但比流行的 Espruino 运行时要高出 11.66 倍。此外,我们还展示了 WARDuino 的速度足以对传统的物联网应用进行编程,这些应用通过用 AssemblyScript 编写的经典智能灯应用来处理网络和设备中断。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
Journal of Computer Languages
Journal of Computer Languages Computer Science-Computer Networks and Communications
CiteScore
5.00
自引率
13.60%
发文量
36
期刊最新文献
Debugging in the Domain-Specific Modeling Languages for multi-agent systems GPotion: Embedding GPU programming in Elixir Near-Pruned single assignment transformation of programs MLAPW: A framework to assess the impact of feature selection and sampling techniques on anti-pattern prediction using WSDL metrics Editorial Board
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1