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

[typeDesc-stmt] Generate new typedesc instruction for record and tuple when type descriptor resolving #43588

Merged
merged 71 commits into from
Nov 18, 2024

Conversation

rdulmina
Copy link
Contributor

@rdulmina rdulmina commented Nov 17, 2024

Purpose

In this PR, I have generated a new 'typedesc' (type descriptor) only once for the tuple and record.
For example:

type Foo record {||};
public function main() {
    Foo f = {};
    record {|int a;|} r = {a: 1};
}

We have desugared the above program as follows:

type Foo record {||};
typedesc<Foo> $typedesc$Foo = Foo;
public function main() {
    Foo f = {};
    typedesc<record {| int a; |}> $typedesc$$anonType$_0 = record {| int a; |}
    record {|int a;|} r = {a: 1};
}

We then use the generated 'typedesc' when creating a map value using that type.

Fixes #38844, #41946, #43311

chiranSachintha and others added 30 commits August 16, 2024 17:05
Add closures before the dependent node in the top-level node list in `ClosureGenerator.java`
Exclude field generation for typedesc when generating fields for user defined types since those fields will be generated when visiting global variables
Add typedesc statement before the var declaration in the init function body
# Conflicts:
#	bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java
#	compiler/ballerina-lang/spotbugs-exclude.xml
#	compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java
#	compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java
#	compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/optimizer/LargeMethodOptimizer.java
#	compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmRecordTypeGen.java
#	tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/record/ClosedRecordOptionalFieldsTest.java
#	tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/record/OpenRecordOptionalFieldsTest.java
#	tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/anydata/AnydataTernaryConvTest.java
#	tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/typedesc/TypedescTests.java
@rdulmina rdulmina changed the base branch from master to typeDesc-stmt November 18, 2024 09:02
@rdulmina rdulmina merged commit e7ec6cc into ballerina-platform:typeDesc-stmt Nov 18, 2024
4 of 6 checks passed
@rdulmina rdulmina changed the title Generate new typedesc instruction for record and tuple when type descriptor resolving [typeDesc-stmt] Generate new typedesc instruction for record and tuple when type descriptor resolving Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Generate new typedesc instruction for record and tuple when type descriptor resolving
2 participants