[Improvement]: Properly distinguish between type descriptor and type in runtime #43356
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
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,For each invocation of
foo
we must resolve type descriptor ofT
separately since things like default values could change from invocation to invocation. However type ofT
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
The text was updated successfully, but these errors were encountered: