ballerina-platform / nballerina

Ballerina compiler that generates native executables.
https://ballerina.io/
Apache License 2.0
138 stars 46 forks source link

Use indexed get/set with open records when reference is exact #762

Open jclark opened 2 years ago

jclark commented 2 years ago

At the moment we use an indexed get/set (bypassing hash table lookup) when we have a closed record.

We can also do it for an open record when the exact bit of the tagged pointer is set.

This builds on #736

KavinduZoysa commented 2 years ago

Summary of the discussion: In the existing code first, we check whether the type is closed or not. If it is closed, the indexed_get function is called. If it is opened, we have to check whether the tagged pointer is exact or not, If it is exact we can call the indexed_get function otherwise, we should call the get function

The function mappingFieldIndex returns the index of the field for close records only. But we have to change/add function to return the index for open record if possible.

jclark commented 2 years ago

Please make clearer distinction between compile-time and runtime. Also need to be clearer about atomic vs non-atomic types.

We should only generate different code for the case where at compile time, static type is an atomic type and the atomic type is open. The code that is generated should check whether at runtime the type is exact, and call get or indexed_get accordingly.

jclark commented 2 years ago

836 was an attempt at this.