oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3.02k stars 185 forks source link

Implement specialisation for structs with keyword arguments #1795

Open chrisseaton opened 4 years ago

chrisseaton commented 4 years ago

https://github.com/oracle/truffleruby/pull/1789#discussion_r342100201

eregon commented 4 years ago

An idea for this is to use define_method + copy_captured_locals which is basically a way to embed constants (in this case the Symbols of the Struct attributes) in the generated method.

However that doesn't allow to unroll the loop (+ specialize for each attribute) easily. One way is to have the define_method itself in an class_eval, then we can generate code from Strings + reference constants.