Register Transfer Language (RTL) for CRuby

Register Transfer Language (RTL) for CRuby
Average rating: 0
(0 votes)

Thanks! You’ve rated this material!

You will never obtain all the knowledge in the world. But you can absorb several small portions of it. In this article, we are describing how to register Transfer Language (RTL) for CRuby. Introducing a Register Transfer Language (RTL) to the CRuby VM turned out to be an even harder task than introducing the initial JIT compiler. The required changes to the VM are far more invasive than the ones needed for the JIT compiler. 

First of all, what is RTL? The current CRuby VM uses stack instructions. Here is an example of stack instructions for the Ruby code a = b + c, where ab, and c are local variables.

Instructions in RTL are longer but there are fewer of them for the same code. Usually, RTL is interpreted faster because a smaller number of executed instructions results in less instruction-dispatching overhead and less memory traffic for operand values, which is more important for modern computers with a bigger gap in speeds of CPU and memory.

CRuby has a generational garbage collector, and every time we assign a value to a (non-temporary) variable, we should inform the garbage collector about this. So for the result of the RTL instruction, we should check that the result is not a temporary variable and call the garbage collector after that.

Although the check is small, it might considerably decrease RTL interpretation speed. I found that in most cases, the faster code can be generated for the interpreter if we use only temporaries as RTL instruction results and generate an additional move instruction if we need the final result to be stored in a local variable.

Feel free to explore more examples here.

And here we collected for you a summary of why you can be confident using Ruby in 2019. In case, you are already quite confident in Ruby, here’s where you can hire the best Ruby developers!

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

*By submitting this form you agree with our Privacy Policy.

Mailing & Legal Address

Syndicode Inc. 340 S Lemon Ave #3299, Walnut CA, 91789, USA

Visiting & Headquarters address
Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
Email info@syndicode.com
Phone (+1) 9035021111