Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Some Assembly Required by Aaron Patterson Let's write a JIT for Ruby, in Ruby! We're going to learn how a JIT works from the ground up by building TenderJIT, a pure Ruby JIT compiler. First, we'll learn how Ruby's virtual machine works, then we'll learn how to plug a JIT in to the virtual machine. Finally, we'll generate machine code from our Ruby programs. By the end of the presentation we'll have a working JIT that converts Ruby code in to machine code all written in pure Ruby! But don't forget: some assembly is required!
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In the presentation titled "Some Assembly Required," Aaron Patterson, an engineer at Shopify and a prominent figure in the Ruby community, dives into the process of creating a Just-In-Time (JIT) compiler named TenderJIT purely in Ruby. The talk, delivered at RubyConf 2021, outlines not just the theoretical aspects of JIT compilation, but also practical steps involved in building one from scratch. Key points discussed in the video include: - **Overview of JIT Compilation**: Aaron explains the concept of JIT compilation, which involves generating machine code at runtime. He emphasizes that any language capable of assembling byte sequences can eventually build a JIT compiler. - **Goals of TenderJIT**: The project aims to be fun, purely written in Ruby, potentially installable as a gem, and to enhance performance. It primarily acted as a learning tool for Aaron to deepen his understanding of compiler design. - **Understanding Ruby's Virtual Machine (YARV)**: The talk provides insights into YARV, Ruby’s stack-based virtual machine, comparing it with actual CPUs that are register-based. He highlights the differences in how these machines handle operations such as addition. - **Machine Code Generation**: An essential aspect of building a JIT is generating and executing machine code. Aaron introduces Fisk, an x86 assembler in Ruby, and demonstrates how to assemble code and execute it dynamically. - **Automating Code Translation**: Aaron discusses the requirement for converting Ruby code into machine code automatically. He introduces a mini interpreter, showcasing how it can execute basic operations by translating Ruby bytecode into machine code via a virtual stack that maps stack-based values to CPU registers. - **Performance Optimizations**: Toward the presentation's conclusion, Aaron elaborates on some optimizations that can be made in the compiled code, including reducing unnecessary instructions and directly returning computed values. The culmination of the talk reveals that with the right components—a method for accessing Ruby bytecode, an assembler for x86, and the ability to write directly to memory—one can successfully implement a pure Ruby JIT. The key takeaway is an openness for attendees to contribute to TenderJIT or develop their JIT compilers using the methodologies presented. Aaron closes the talk by encouraging community engagement in both TenderJIT and related projects, highlighting the collaborative spirit within the Ruby community.
Suggest modifications
Cancel