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]: Properly distinguish between type descriptor and type in runtime #43356

Closed
heshanpadmasiri opened this issue Sep 4, 2024 · 1 comment
Assignees
Labels
Area/SemtypeIntegration Issue related to integrating semtype engine Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Improvement

Comments

@heshanpadmasiri
Copy link
Member

Description

In current implementation both type descriptor as well as type is represented by BTypes/Types. However as far the spec is concerned these are separate concepts.

Describe your problem(s)

Combining type descritptor with type introduce several performance problems. For instance consider the fallowing where T is any ballerina type,

function foo() {
       T val = intiValue();
}

For each invocation of foo we must resolve type descriptor of T separately since things like default values could change from invocation to invocation. However type of T does not. But by combining type descritptor and type of T together we anyway initialise "both" type and type descriptor for each invocation.

This limits the potential to reuse type check results from previous invocations and add extra overhead in having to resolve the type for each invocation.

Describe your solution(s)

With 40511 we can treat the semtype part as the "type" and "BType" part as the type descriptor. Each type descriptor will have a semtype (which may be shared between instances, and lazily initialised). Initially we can handle this enitirely at runtime (which will add runtime overhead of canonicalization of types). Later we can do the canonicalization at compile time

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@heshanpadmasiri heshanpadmasiri added Type/Improvement Area/SemtypeIntegration Issue related to integrating semtype engine labels Sep 4, 2024
@heshanpadmasiri heshanpadmasiri self-assigned this Sep 4, 2024
@ballerina-bot ballerina-bot added the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label Sep 4, 2024
@heshanpadmasiri
Copy link
Member Author

Most of the offending new typedesc creations should be fixed with #38844. Will reopen this if issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/SemtypeIntegration Issue related to integrating semtype engine Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Improvement
Projects
Archived in project
Development

No branches or pull requests

2 participants