Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement]: Integrate a subset of semtypes into jBallerina runtime #40511

Closed
lochana-chathura opened this issue May 25, 2023 · 4 comments
Closed
Assignees
Labels
Area/RuntimeTypeChecker JBallerina runtime type checking related issues Area/SemtypeIntegration Issue related to integrating semtype engine Points/5 Equivalent to five day effort Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Improvement

Comments

@lochana-chathura
Copy link
Member

lochana-chathura commented May 25, 2023

Description

$subject.

@lochana-chathura lochana-chathura self-assigned this May 25, 2023
@ballerina-bot ballerina-bot added the needTriage The issue has to be inspected and labeled manually label May 25, 2023
@lochana-chathura lochana-chathura moved this to Planned for Sprint in Ballerina Team Main Board May 25, 2023
@lochana-chathura lochana-chathura added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Area/RuntimeTypeChecker JBallerina runtime type checking related issues and removed needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels May 25, 2023
@lochana-chathura lochana-chathura moved this from Planned for Sprint to BackLog in Ballerina Team Main Board May 25, 2023
@lochana-chathura lochana-chathura added the Points/5 Equivalent to five day effort label May 25, 2023
@heshanpadmasiri heshanpadmasiri moved this from BackLog to In Progress in Ballerina Team Main Board Feb 13, 2024
@hasithaa hasithaa moved this from In Progress to Planned for Sprint in Ballerina Team Main Board Mar 1, 2024
@heshanpadmasiri
Copy link
Member

This is to be done similar to #41066 (ie. initially we will support a state where part of the type is still a BType and rest is SemType). For this I have considered 2 approaches,

  1. At runtime split a given BType to a SemType component as well as a BType component and type check them separately.
  2. Make the SemType the "top level" type and make the BType another sub type data.

First approach is not removing any of the BTypes and instead we are creating additional SemTypes (and extra BType for the BType component). This means we have a performance overhead (in nBallerina I measured ~15% slowdown mainly due to extra instance creation). Second approach should not have that weakness since we are replacing BTypes with SemTypes. Currently I am exploring this approach.

@heshanpadmasiri
Copy link
Member

heshanpadmasiri commented Mar 1, 2024

I am planning to convert runtime type representation to SemTypes in fallowing stages

At any stage unions and intersections will represent the parts that are supported under that stage as SemTypes as well. Note that list, map and xml types will require porting the cell types (used to represent mutability) as well. Also note all other types such as table are represented using combinations of above types.

Ballerina Type Underlying SemType
table list + mapping
error, object map
function list

@heshanpadmasiri
Copy link
Member

This is to be done similar to #41066 (ie. initially we will support a state where part of the type is still a BType and rest is SemType). For this I have considered 2 approaches,

1. At runtime split a given `BType` to a `SemType` component as well as a `BType` component and type check them separately.

2. Make the` SemType` the "top level" type and make the `BType` another sub type data.

First approach is not removing any of the BTypes and instead we are creating additional SemTypes (and extra BType for the BType component). This means we have a performance overhead (in nBallerina I measured ~15% slowdown mainly due to extra instance creation). Second approach should not have that weakness since we are replacing BTypes with SemTypes. Currently I am exploring this approach.

Extension of option 2 is to make existing BTypes extends SemType. Basically for each type supported by the runtime API their corresponding implementations will implement both the SemType as well as that interface. Type operations are still immutable and still result in new Semtypes that will only implement the base Type interface. But this will allow things like standard library to continue using (most of) the types as is with minimum modifications. Internally these new types will just become adapters between semtype API and current type APIs

@heshanpadmasiri heshanpadmasiri moved this from In Progress to On Hold in Ballerina Team Main Board May 20, 2024
@heshanpadmasiri heshanpadmasiri moved this from On Hold to In Progress in Ballerina Team Main Board May 22, 2024
@heshanpadmasiri heshanpadmasiri moved this from In Progress to On Hold in Ballerina Team Main Board May 22, 2024
@heshanpadmasiri heshanpadmasiri moved this from On Hold to BackLog in Ballerina Team Main Board May 22, 2024
@lochana-chathura
Copy link
Member Author

Closing with #43279

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/RuntimeTypeChecker JBallerina runtime type checking related issues Area/SemtypeIntegration Issue related to integrating semtype engine Points/5 Equivalent to five day effort Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Improvement
Projects
Status: Done
Development

No branches or pull requests

3 participants