skip to main content
10.1145/3546918.3546924acmotherconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Porting a JIT Compiler to RISC-V: Challenges and Opportunities

Published:30 November 2022Publication History

ABSTRACT

The RISC-V Instruction Set Architecture (ISA) is an open-source, modular and extensible ISA. The ability to add new instructions into a dedicated core opens up perspectives to accelerate VM components or provide dedicated hardware IPs to applications running on top. However, the RISC-V ISA design is clashing on several aspects with other ISAs and therefore software historically built around them. Among them, the lack of condition codes and instruction expansion through simple instruction combination. In this paper we present the challenges of porting Cogit, the Pharo’s JIT compiler tightly linked to the x86 ISA, on RISC-V. We present concrete examples of them and the rationale behind their inclusion in the RISC-V ISA. We show how those mismatches are solved through design choices of the compilation process or through tools helping development: a VM simulation framework to keep the development in a high-level environment for the most part, an ISA-agnostic test harness covering main VM functionalities and a machine code debugger to explore and execute generated machine code. We also present a way to prototype custom instructions and execute them in the Pharo environment.

References

  1. Andrew P Black, Oscar Nierstrasz, Stéphane Ducasse, and Damien Pollet. 2010. Pharo by example. Lulu. com.Google ScholarGoogle Scholar
  2. M Anton Ertl and David Gregg. 2003. The structure and performance of efficient interpreters. Journal of Instruction-Level Parallelism 5 (2003), 1–25.Google ScholarGoogle Scholar
  3. GCC. 2022. GCC li pseudoinstruction cost functions implementation. https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/riscv/riscv.c;h=a545dbf66f734855090568ce1a253b373345eec0;hb=HEAD#l395Google ScholarGoogle Scholar
  4. Garth Gillespie. 2018. LuaJIT SSA IR 2.0. http://wiki.luajit.org/SSA-IR-2.0#introduction_example-ir-dumpGoogle ScholarGoogle Scholar
  5. Urs Hölzle, Craig Chambers, and David Ungar. 1991. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In ECOOP’91 European Conference on Object-Oriented Programming, Pierre America (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 21–38. https://doi.org/10.1007/BFb0057013Google ScholarGoogle ScholarCross RefCross Ref
  6. Dan Ingalls, Ted Kaehler, John Maloney, Scott Wallace, and Alan Kay. 1997. Back to the Future: The Story of Squeak, a Practical Smalltalk Written in Itself. SIGPLAN Not. 32, 10, 318–326. https://doi.org/10.1145/263700.263754Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Haeyoung Kim, Jinjae Lee, Derry Pratama, Asep Muhamad Awaludin, Howon Kim, and Donghyun Kwon. 2020. RIMI: instruction-level memory isolation for embedded systems on RISC-V. In Proceedings of the 39th International Conference on Computer-Aided Design. 1–9. https://doi.org/10.1145/3400302.3415727Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. LLVM. 2022. LLVM li pseudoinstruction recursive function implementation. https://github.com/llvm/llvm-project/blob/4c3d916c4bd2a392101c74dd270bd1e6a4fec15b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cppGoogle ScholarGoogle Scholar
  9. Eliot Miranda. 2011. The Cog Smalltalk virtual machine. In VMIL’11: Proceedings of the 5th workshop on Virtual machines and intermediate languages for emerging modularization mechanisms.Google ScholarGoogle Scholar
  10. David Patterson and Andrew Waterman. 2015. The RISC-V Reader: An Open Architecture Atlas. Technical Report. Strawberry Canyon.Google ScholarGoogle Scholar
  11. Guillermo Polito, Pablo Tesone, Stéphane Ducasse, Luc Fabresse, Théo Rogliano, Pierre Misse-Chanabier, and Carolina Hernandez Phillips. 2021. Cross-ISA testing of the Pharo VM: lessons learned while porting to ARMv8. In Proceedings of the 18th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes. 16–25. https://doi.org/10.1145/3475738.3480715Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Ben L. Titzer. 2015. TurboFan JIT Design. https://docs.google.com/presentation/d/1sOEF4MlF7LeO7uq-uThJSulJlTh–wgLeaVibsbb3tcGoogle ScholarGoogle Scholar
  13. Adam Zabrocki, Martin Maas, and Stephano Cetola. 2021. Working Draft of the RISC-V J Extension Specification. https://github.com/riscv/riscv-j-extensionGoogle ScholarGoogle Scholar

Index Terms

  1. Porting a JIT Compiler to RISC-V: Challenges and Opportunities

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in
        • Published in

          cover image ACM Other conferences
          MPLR '22: Proceedings of the 19th International Conference on Managed Programming Languages and Runtimes
          September 2022
          161 pages
          ISBN:9781450396967
          DOI:10.1145/3546918

          Copyright © 2022 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 30 November 2022

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Author Tags

          Qualifiers

          • research-article
          • Research
          • Refereed limited

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader

        HTML Format

        View this article in HTML Format .

        View HTML Format