Currently all types are boxed inside a class called BaseType. This is super inefficient as it allocates a lot of memory for a single Float64, Bool, String etc.
At the beginning the justification of that was the ease of development, but now it's just a burden on performance.
The interpreter should use the native crystal types for calculations, values etc.
The only exceptions will be the TObject, TArray and the TFunction, as they need more information to work.
Here is the (unoptimized) LLVM-IR generated by the crystal compiler to create a single TNumeric value for charly:
Currently all types are boxed inside a class called
BaseType
. This is super inefficient as it allocates a lot of memory for a singleFloat64
,Bool
,String
etc.At the beginning the justification of that was the ease of development, but now it's just a burden on performance.
The interpreter should use the native crystal types for calculations, values etc.
The only exceptions will be the
TObject
,TArray
and theTFunction
, as they need more information to work.Here is the (unoptimized) LLVM-IR generated by the crystal compiler to create a single TNumeric value for charly: