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

[Master] Generate new typedesc instruction for record and tuple when type descriptor resolving #43596

Open
wants to merge 99 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
ba768a7
Reorder top level nodes
chiranSachintha Jan 7, 2024
5dc8900
Access annotations from `typedesc`
chiranSachintha Jan 7, 2024
a6906f0
Update tuple equality check
chiranSachintha Jan 7, 2024
f76ac3e
Add service variables to top level nodes
chiranSachintha Jan 7, 2024
54c478e
Generate `newTypedesc` instruction
chiranSachintha Jan 7, 2024
962d8f9
Remove closure field and update `TypedescValueImpl` constructors
chiranSachintha Jan 7, 2024
2df1bbc
Skip generating `typedesc` within `Type` class
chiranSachintha Jan 7, 2024
e0e0131
Desugar top-level nodes to align with the order specified in the top-…
chiranSachintha Jan 7, 2024
935f960
Create variable definitions for typedesc in record and tuple type nodes
chiranSachintha Jan 7, 2024
8d561b6
Add closures into the top-level node list
chiranSachintha Jan 7, 2024
4317260
Update `toString` logic
chiranSachintha Jan 7, 2024
604fb13
Add type to `newStructure` instruction
chiranSachintha Jan 7, 2024
84d4d65
Create a `typedesc` when traversing the type node of the tuple and re…
chiranSachintha Jan 7, 2024
2947f76
Refactor logic
chiranSachintha Jan 8, 2024
b14ec39
Get implied type of `typedesc`
chiranSachintha Jan 8, 2024
d470345
Revert "Remove closure field and update `TypedescValueImpl` construct…
rdulmina Aug 20, 2024
77d0b24
Revert "Revert "Remove closure field and update `TypedescValueImpl` c…
rdulmina Aug 21, 2024
71d37a2
Remove unused imports
rdulmina Aug 21, 2024
1207d10
Use generated typedesc class for record values
rdulmina Aug 21, 2024
bb14e26
Add missing `TypeUtils.getImpliedType`
rdulmina Aug 21, 2024
e7ff5d2
Remove passing closures to TypeDescValuImpl constructor
rdulmina Aug 21, 2024
b2a7e21
Refactor `BIRGen` changes
rdulmina Aug 22, 2024
deeac52
Add closures before the dependent node in the top-level node list
rdulmina Aug 23, 2024
f6f591c
Use user defined type name on typedesc variable
rdulmina Aug 23, 2024
e0bb977
Exclude field generation for typedesc
rdulmina Aug 23, 2024
0cde6eb
Get typedesc variables from different packages
rdulmina Aug 23, 2024
aaa3a9b
Rewrite constants and variables at `desugarTopLevelNodes`
rdulmina Aug 28, 2024
28b3012
Remove `visitTypeDesc` method
rdulmina Aug 28, 2024
5e40d0d
Add typedesc statement before the var declaration
rdulmina Sep 3, 2024
0924038
Fix the pkdId and owner of the typedesc statement
rdulmina Sep 5, 2024
11c0ffe
Preserve element typedesc variableDecl in `NewArray`
rdulmina Sep 6, 2024
3e12916
Order typedefinitions with toplevel nodes
rdulmina Sep 10, 2024
077313b
Fix issue in getting the typedesc var ref from different packages
rdulmina Sep 11, 2024
5d22ed6
Undo test removal commit
rdulmina Sep 13, 2024
7f545f9
Fix issue in different module var ref names
rdulmina Sep 19, 2024
e2b2b3b
Refactor code
rdulmina Sep 20, 2024
2a9f99f
Use the original type when creating the typedesc statements
rdulmina Sep 24, 2024
1d66ee2
Fix failing `BIROptimizer` tests
rdulmina Sep 30, 2024
1f88965
Fix failing set of annotation tests
rdulmina Oct 10, 2024
ba08a23
Generate typedesc for const literal type and intersection type
rdulmina Oct 10, 2024
eb32a05
Rewrite globalVar and constants after `annotationDesugar`
rdulmina Oct 14, 2024
b80968c
Fix issue in `ClosureGenerator`
rdulmina Oct 14, 2024
f1ebb95
Fix set of failing test due to type mismatch
rdulmina Oct 15, 2024
f831aa0
Fix annotation not processed correctly for record typedef
rdulmina Oct 15, 2024
7eaa889
Generate type desc variable for map type
rdulmina Oct 16, 2024
5a97157
Fix failing typedesc test
rdulmina Oct 16, 2024
5876754
Fix issue where record default values are not being populated correctly
rdulmina Oct 16, 2024
68246cf
Add missing `getImpliedType` Usage
rdulmina Oct 16, 2024
2aed9d2
Refactor `BIRGen` code
rdulmina Oct 18, 2024
f412eb0
Add extra diagnostic
rdulmina Oct 18, 2024
64caa3e
Update failing `BIROptimizer` tests
rdulmina Oct 19, 2024
ec8cc50
Fix failing test due to incorrect error msg
rdulmina Oct 19, 2024
a1c03fd
Create New typedesc for type if the typedesc var is not created in th…
rdulmina Oct 23, 2024
544c3e7
Fix set of failing tests
rdulmina Oct 23, 2024
71dc4a9
Merge remote-tracking branch 'upstream/master' into typeDesc-stmt
rdulmina Oct 23, 2024
a89be92
Remove unwanted reference type creation in `ReadOnlyUtils`
rdulmina Oct 24, 2024
1b5e0c9
Update failing test
rdulmina Oct 24, 2024
8f9056d
Fix issue in loading record default values
rdulmina Oct 29, 2024
955e842
Create typedesc for parent type before generating for nested types
rdulmina Oct 31, 2024
f843a88
Fix LargeMethodOptimizer after typedesc change
rdulmina Nov 5, 2024
79cb805
Add missing visitor method updates for new `elementTypedescOp`
rdulmina Nov 12, 2024
6611e11
Update `getRhsOperands` of `NEWARRAY` instruction
rdulmina Nov 12, 2024
810bcc6
Compress arguments into a tuple if the split method contains large nu…
rdulmina Nov 15, 2024
4051715
Fix checkstyle
rdulmina Nov 15, 2024
cf13824
Reduce `MAX_SPLIT_FUNCTION_ARG_COUNT` to `93`
rdulmina Nov 16, 2024
0f12202
Fix checkstyle
rdulmina Nov 16, 2024
eaf64f9
Undo unwanted changes
rdulmina Nov 17, 2024
b969e8a
Merge remote-tracking branch 'upstream/master' into typeDesc-stmt
rdulmina Nov 18, 2024
4a72178
Use `getFirst()` fot `ArrayLists`
rdulmina Nov 18, 2024
eec5836
Merge remote-tracking branch 'upstream/master' into typeDesc-stmt
rdulmina Nov 18, 2024
3ff9914
Remove unused methods
rdulmina Nov 18, 2024
e7ec6cc
Merge pull request #43588 from rdulmina/typeDesc-stmt
rdulmina Nov 18, 2024
27b62a6
Checkout Java21 branch in full build pipeline
rdulmina Nov 18, 2024
f1748e6
Merge pull request #43597 from rdulmina/typeDesc-stmt
rdulmina Nov 18, 2024
9fe124d
Checkout typeDesc-stmt branch in full build pipeline
rdulmina Nov 18, 2024
a75206d
Merge branch 'typeDesc-stmt' into typeDesc-stmt
rdulmina Nov 18, 2024
25c8c6c
Merge pull request #43599 from rdulmina/typeDesc-stmt
rdulmina Nov 18, 2024
2c75b6c
Fix usage of incorrect branch in full build pipeline
rdulmina Nov 18, 2024
0cb6c1a
Merge pull request #43604 from rdulmina/typeDesc-stmt
rdulmina Nov 19, 2024
f065eb5
Fix incorrect checkout branch name
rdulmina Nov 19, 2024
358d07e
Merge remote-tracking branch 'upstream/typeDesc-stmt' into typeDesc-stmt
rdulmina Nov 19, 2024
7e6125c
Fix branch checkout command
rdulmina Nov 19, 2024
f9da8b6
Address review suggestions
rdulmina Nov 19, 2024
e5f1afc
Set annotation for the referred type if it is record
rdulmina Nov 19, 2024
7535598
Fix checkstyle issue
rdulmina Nov 19, 2024
38e2267
Merge remote-tracking branch 'upstream/master' into typeDesc-stmt
rdulmina Nov 20, 2024
27bafe0
Merge branch 'master' into typeDesc-stmt
rdulmina Nov 20, 2024
2884daf
Fix import order
rdulmina Nov 20, 2024
fb628eb
Add a test case for issue `#43633`
rdulmina Nov 21, 2024
35555f3
Revert "Fix set of failing test due to type mismatch"
rdulmina Nov 21, 2024
dd0d8f5
Use referred type when creating typedesc for records
rdulmina Nov 21, 2024
31c6b6b
Comment Checkout non-default branch in full build
rdulmina Nov 21, 2024
b189a55
Merge remote-tracking branch 'upstream/master' into typeDesc-stmt
rdulmina Nov 21, 2024
bc42da5
Use referred type when creating typedesc for maps
rdulmina Nov 21, 2024
7e04bf7
Revert "Use referred type when creating typedesc for maps"
rdulmina Nov 21, 2024
c0fa12d
Fix duplicate typedesc creation for each type desc expression
rdulmina Nov 25, 2024
103fc70
Refactor code
rdulmina Nov 26, 2024
6fedbfa
Update `setRhsOperands` for `NewArray` inst
rdulmina Nov 26, 2024
ff7605e
Remove referred type matching to getTypeDescVar
rdulmina Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_full_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
- name: Checkout non-default branch
run: |
for module_name in $(jq -r '.standard_library| .[] | select(.level==${{ matrix.level }}) | .name' extensions.json); do \
cd $module_name && git fetch origin && git checkout -t origin/java21 && cd ..; \
cd $module_name && git fetch origin && git checkout -b typeDesc-stmt && cd ..; \
done

- name: Update Lang Version in Module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,11 @@ public static Object getAnnotValue(TypedescValue typedescValue, BString annotTag
if (!(describingType instanceof BAnnotatableType annotatableType)) {
return null;
}
MapValue annotations = ((TypedescValueImpl) typedescValue).annotations;
rdulmina marked this conversation as resolved.
Show resolved Hide resolved
if (annotations != null) {
// ATM only field annotations will reach here
return annotations.get(annotTag);
}
return annotatableType.getAnnotation(annotTag);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ private void computeStringRepresentation() {
if (cachedToString != null) {
return;
}
if (typeName != null && !typeName.isEmpty()) {
cachedToString = typeName;
return;
}
StringBuilder stringRep =
new StringBuilder("[").append(tupleTypes.stream().map(Type::toString).collect(Collectors.joining(",")));
if (restType != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private MapUtils() {
}

public static void handleMapStore(MapValue<BString, Object> mapValue, BString fieldName, Object value) {
updateMapValue(TypeUtils.getImpliedType(mapValue.getType()), mapValue, fieldName, value);
updateMapValue(mapValue.getType(), mapValue, fieldName, value);
}

public static void handleInherentTypeViolatingMapUpdate(Object value, BMapType mapType) {
Expand Down Expand Up @@ -149,7 +149,7 @@ public static void checkIsMapOnlyOperation(Type mapType, String op) {

private static void updateMapValue(Type mapType, MapValue<BString, Object> mapValue, BString fieldName,
Object value) {

mapType = TypeUtils.getImpliedType(mapType);
switch (mapType.getTag()) {
case TypeTags.MAP_TAG:
handleInherentTypeViolatingMapUpdate(value, (BMapType) mapType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BFunctionPointer;
Expand Down Expand Up @@ -314,8 +315,9 @@ public void setTypeForcefully(Type type) {

protected void populateInitialValues(BMapInitialValueEntry[] initialValues) {
Map<String, BFunctionPointer> defaultValues = new HashMap<>();
if (type.getTag() == TypeTags.RECORD_TYPE_TAG) {
defaultValues.putAll(((BRecordType) type).getDefaultValues());
Type impliedType = TypeUtils.getImpliedType(type);
if (impliedType.getTag() == TypeTags.RECORD_TYPE_TAG) {
defaultValues.putAll(((BRecordType) impliedType).getDefaultValues());
}

for (BMapInitialValueEntry initialValue : initialValues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,8 @@ private static BIntersectionType setImmutableIntersectionType(Type type, Set<Typ
}
return objectIntersectionType;
case TypeTags.TYPE_REFERENCED_TYPE_TAG:
BTypeReferenceType bType = (BTypeReferenceType) type;
BTypeReferenceType refType = new BTypeReferenceType(bType.getName(), bType.getPkg(),
bType.getTypeFlags(), true);
refType.setReferredType(getImmutableType(bType.getReferredType(), unresolvedTypes));
return createAndSetImmutableIntersectionType(bType, refType);
return createAndSetImmutableIntersectionType(type,
getImmutableType(((BTypeReferenceType) type).getReferredType(), unresolvedTypes));
case TypeTags.ANY_TAG:
case TypeTags.ANYDATA_TAG:
case TypeTags.JSON_TAG:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class TypedescValueImpl implements TypedescValue {

final Type type;
final Type describingType; // Type of the value describe by this typedesc.
public MapValue<?, ?>[] closures;
public MapValue<?, ?> annotations;
private BTypedesc typedesc;

Expand All @@ -63,14 +62,8 @@ public TypedescValueImpl(Type describingType) {
this.describingType = describingType;
}

public TypedescValueImpl(Type describingType, MapValue<?, ?>[] closures) {
this.type = new BTypedescType(describingType);
this.describingType = describingType;
this.closures = closures;
}

public TypedescValueImpl(Type describingType, MapValue<?, ?>[] closures, MapValue<BString, Object> annotations) {
this(describingType, closures);
public TypedescValueImpl(Type describingType, MapValue<BString, Object> annotations) {
this(describingType);
this.annotations = annotations;
((BAnnotatableType) describingType).setAnnotations(annotations);
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/ballerina-lang/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -500,4 +500,9 @@
<Method name="performCodeGen"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
</Match>
<Match>
<Class name="org.wso2.ballerinalang.compiler.bir.codegen.optimizer.LargeMethodOptimizer" />
<Method name="restoreOriginalArgsFromTuple" />
<Bug pattern="BC_UNCONFIRMED_CAST" />
</Match>
</FindBugsFilter>
Loading
Loading