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 102 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 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
454355e
Add unit tests to validate typedesc creation
rdulmina Nov 29, 2024
77725a3
Update comment
rdulmina Nov 29, 2024
66a8c8e
Prevent top level node reordering for typedef annotations
rdulmina Dec 3, 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
6 changes: 6 additions & 0 deletions .github/workflows/pull_request_full_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ jobs:
do git clone https://github.com/ballerina-platform/${module_name}.git; \
done

# - 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/typeDesc-stmt || : && cd ..; \
# done

- name: Update Lang Version in Module
run: |
for module_name in $(jq -r '.standard_library| .[] | select(.level==${{ matrix.level }}) | .name' extensions.json); do \
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 @@ -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>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public final class JvmConstants {
public static final String XML_QNAME = "io/ballerina/runtime/internal/values/XmlQName";
public static final String FUTURE_VALUE = "io/ballerina/runtime/internal/values/FutureValue";
public static final String TYPEDESC_VALUE_IMPL = "io/ballerina/runtime/internal/values/TypedescValueImpl";
public static final String TYPEDESC_VALUE_IMPL_CLOSURES = "closures";
public static final String TYPEDESC_VALUE = "io/ballerina/runtime/internal/values/TypedescValue";
public static final String HANDLE_VALUE = "io/ballerina/runtime/internal/values/HandleValue";
public static final String LOCK_STORE = "io/ballerina/runtime/internal/lock/BLockStore";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.wso2.ballerinalang.compiler.semantics.model.types.BObjectType;
import org.wso2.ballerinalang.compiler.semantics.model.types.BRecordType;
import org.wso2.ballerinalang.compiler.semantics.model.types.BType;
import org.wso2.ballerinalang.compiler.semantics.model.types.BTypeReferenceType;
import org.wso2.ballerinalang.compiler.util.TypeTags;
import org.wso2.ballerinalang.util.Flags;

Expand All @@ -66,7 +65,6 @@
import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.ANEWARRAY;
import static org.objectweb.asm.Opcodes.ASTORE;
import static org.objectweb.asm.Opcodes.BIPUSH;
import static org.objectweb.asm.Opcodes.CHECKCAST;
import static org.objectweb.asm.Opcodes.DADD;
import static org.objectweb.asm.Opcodes.DCMPL;
Expand Down Expand Up @@ -223,7 +221,6 @@
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_MODULE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_STRING_AT;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_STRING_FROM_ARRAY;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TYPEDESC;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TYPEDESC_OF_OBJECT;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.HANDLE_MAP_STORE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.HANDLE_TABLE_STORE;
Expand Down Expand Up @@ -502,9 +499,8 @@ private void generateJLargeArrayIns(int localVarOffset, JLargeArrayInstruction i
jvmTypeGen.loadType(this.mv, inst.type);
loadListInitialValues(inst);
BType elementType = JvmCodeGenUtil.getImpliedType(((BArrayType) instType).eType);
if (elementType.tag == TypeTags.RECORD || (elementType.tag == TypeTags.INTERSECTION &&
((BIntersectionType) elementType).effectiveType.tag == TypeTags.RECORD)) {
visitNewRecordArray(elementType);
if (elementType.tag == TypeTags.RECORD) {
visitNewRecordArray(inst.elementTypedescOp.variableDcl);
} else {
this.mv.visitMethodInsn(INVOKESPECIAL, ARRAY_VALUE_IMPL, JVM_INIT_METHOD,
INIT_ARRAY, false);
Expand Down Expand Up @@ -1421,7 +1417,7 @@ void generateArrayNewIns(BIRNonTerminator.NewArray inst, int localVarOffset) {
BType elementType = JvmCodeGenUtil.getImpliedType(((BArrayType) instType).eType);

if (elementType.tag == TypeTags.RECORD) {
visitNewRecordArray(elementType);
visitNewRecordArray(inst.elementTypedescOp.variableDcl);
} else {
this.mv.visitMethodInsn(INVOKESPECIAL, ARRAY_VALUE_IMPL, JVM_INIT_METHOD,
INIT_ARRAY, false);
Expand All @@ -1437,12 +1433,8 @@ void generateArrayNewIns(BIRNonTerminator.NewArray inst, int localVarOffset) {
}
}

private void visitNewRecordArray(BType type) {
BType elementType = JvmCodeGenUtil.getImpliedType(type);
String typeOwner = JvmCodeGenUtil.getPackageName(type.tsymbol.pkgID) + MODULE_INIT_CLASS_NAME;
String typedescFieldName =
jvmTypeGen.getTypedescFieldName(toNameString(elementType));
this.mv.visitFieldInsn(GETSTATIC, typeOwner, typedescFieldName, "L" + TYPEDESC_VALUE + ";");
private void visitNewRecordArray(BIRNode.BIRVariableDcl elementTypeDesc) {
this.loadVar(elementTypeDesc);
this.mv.visitMethodInsn(INVOKESPECIAL, ARRAY_VALUE_IMPL, JVM_INIT_METHOD,
INIT_ARRAY_WITH_INITIAL_VALUES, false);
}
Expand Down Expand Up @@ -2000,54 +1992,23 @@ void generateNegateIns(BIRNonTerminator.UnaryOP unaryOp) {
}

void generateNewTypedescIns(BIRNonTerminator.NewTypeDesc newTypeDesc) {
List<BIROperand> closureVars = newTypeDesc.closureVars;
if (isNonReferredRecord(newTypeDesc.type)) {
BType type = JvmCodeGenUtil.getImpliedType(newTypeDesc.type);
PackageID packageID = type.tsymbol.pkgID;
String typeOwner = JvmCodeGenUtil.getPackageName(packageID) + MODULE_INIT_CLASS_NAME;
String fieldName = jvmTypeGen.getTypedescFieldName(toNameString(type));
mv.visitFieldInsn(GETSTATIC, typeOwner, fieldName, GET_TYPEDESC);
} else {
generateNewTypedescCreate(newTypeDesc.type, closureVars, newTypeDesc.annotations);
}
this.storeToVar(newTypeDesc.lhsOp.variableDcl);
}

private boolean isNonReferredRecord(BType type) {
if (type.tag != TypeTags.TYPEREFDESC) {
return false;
}
BType referredType = ((BTypeReferenceType) type).referredType;
return referredType.tag == TypeTags.RECORD &&
type.getQualifiedTypeName().equals(referredType.getQualifiedTypeName());
}

private void generateNewTypedescCreate(BType btype, List<BIROperand> closureVars, BIROperand annotations) {
BType type = JvmCodeGenUtil.getImpliedType(btype);
String className = TYPEDESC_VALUE_IMPL;
BType type = JvmCodeGenUtil.getImpliedType(newTypeDesc.type);
if (type.tag == TypeTags.RECORD) {
className = getTypeDescClassName(JvmCodeGenUtil.getPackageName(type.tsymbol.pkgID), toNameString(type));
}
this.mv.visitTypeInsn(NEW, className);
this.mv.visitInsn(DUP);
jvmTypeGen.loadType(this.mv, btype);

mv.visitIntInsn(BIPUSH, closureVars.size());
mv.visitTypeInsn(ANEWARRAY, MAP_VALUE);
for (int i = 0; i < closureVars.size(); i++) {
BIROperand closureVar = closureVars.get(i);
mv.visitInsn(DUP);
mv.visitIntInsn(BIPUSH, i);
this.loadVar(closureVar.variableDcl);
mv.visitInsn(AASTORE);
}
jvmTypeGen.loadType(this.mv, newTypeDesc.type);
BIROperand annotations = newTypeDesc.annotations;
if (annotations != null) {
this.loadVar(annotations.variableDcl);
this.mv.visitMethodInsn(INVOKESPECIAL, className, JVM_INIT_METHOD, TYPE_DESC_CONSTRUCTOR_WITH_ANNOTATIONS,
false);
false);
} else {
this.mv.visitMethodInsn(INVOKESPECIAL, className, JVM_INIT_METHOD, TYPE_DESC_CONSTRUCTOR, false);
}
this.storeToVar(newTypeDesc.lhsOp.variableDcl);
}

void loadVar(BIRNode.BIRVariableDcl varDcl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ public final class JvmSignatures {
public static final String TO_STRING_RETURN = "()L" + STRING_VALUE + ";";
public static final String TUPLE_SET_MEMBERS_METHOD = "(L" + LIST + ";L" + TYPE + ";)V";
public static final String TWO_OBJECTS_ARGS = "(L" + OBJECT + ";L" + OBJECT + ";)V";
public static final String TYPE_DESC_CONSTRUCTOR = "(L" + TYPE + ";[L" + MAP_VALUE + ";)V";
public static final String TYPE_DESC_CONSTRUCTOR_WITH_ANNOTATIONS = "(L" + TYPE + ";[L" + MAP_VALUE + ";L" +
public static final String TYPE_DESC_CONSTRUCTOR = "(L" + TYPE + ";)V";
public static final String TYPE_DESC_CONSTRUCTOR_WITH_ANNOTATIONS = "(L" + TYPE + ";L" +
MAP_VALUE + ";)V";
public static final String TYPE_PARAMETER = "(L" + TYPE + ";)V";
public static final String VALUE_OF_JSTRING = "(L" + OBJECT + ";)L" + STRING_VALUE + ";";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ void generateUserDefinedTypeFields(ClassWriter cw, List<BIRTypeDefinition> typeD
}
String name = typeDef.internalName.value;
generateTypeField(cw, name);
generateTypedescField(cw, name);
// Exclude field generation for typedesc when generating fields for user defined types since
// those fields will be generated when visiting global variables
if (bTypeTag != TypeTags.RECORD && bTypeTag != TypeTags.TUPLE) {
generateTypedescField(cw, name);
}
}
}

Expand Down Expand Up @@ -847,7 +851,7 @@ public static String getTypeFieldName(String typeName) {
}

public String getTypedescFieldName(String name) {
return "$typedesce$" + name;
return "$typedesc$" + name;
}

private void loadFutureType(MethodVisitor mv, BFutureType bType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@
import static org.objectweb.asm.Opcodes.IRETURN;
import static org.objectweb.asm.Opcodes.ISTORE;
import static org.objectweb.asm.Opcodes.NEW;
import static org.objectweb.asm.Opcodes.POP;
import static org.objectweb.asm.Opcodes.PUTFIELD;
import static org.objectweb.asm.Opcodes.RETURN;
import static org.objectweb.asm.Opcodes.SWAP;
import static org.objectweb.asm.Opcodes.V21;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmCodeGenUtil.toNameString;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ABSTRACT_OBJECT_VALUE;
Expand All @@ -87,13 +85,11 @@
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPEDESC_CLASS_PREFIX;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPEDESC_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPEDESC_VALUE_IMPL;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPEDESC_VALUE_IMPL_CLOSURES;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPE_IMPL;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.UNSUPPORTED_OPERATION_EXCEPTION;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.VALUE_CLASS_PREFIX;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmDesugarPhase.addDefaultableBooleanVarsToSignature;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.CAST_B_MAPPING_INITIAL_VALUE_ENTRY;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_MAP_ARRAY;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_MAP_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INIT_TYPEDESC;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INSTANTIATE;
Expand Down Expand Up @@ -257,14 +253,6 @@ private void createInstantiateMethodWithInitialValues(ClassWriter cw, BRecordTyp
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, className, JVM_INIT_METHOD, INIT_TYPEDESC, false);

// Invoke the init-function of this type.
mv.visitVarInsn(ALOAD, 1);
mv.visitInsn(SWAP);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, TYPEDESC_VALUE_IMPL, TYPEDESC_VALUE_IMPL_CLOSURES,
GET_MAP_ARRAY);
mv.visitInsn(POP);

// Invoke the init-function of this type.
String valueClassName;
List<BIRFunction> attachedFuncs = typeDef.attachedFuncs;
Expand Down Expand Up @@ -336,7 +324,6 @@ private void createTypeDescConstructor(ClassWriter cw, String className) {
// load type
mv.visitVarInsn(ALOAD, 1);

mv.visitVarInsn(ALOAD, 2);
// invoke `super(type)`;
mv.visitMethodInsn(INVOKESPECIAL, TYPEDESC_VALUE_IMPL, JVM_INIT_METHOD, descriptor, false);

Expand All @@ -351,16 +338,14 @@ private void createTypeDescConstructorWithAnnotations(ClassWriter cw, String nam
mv.visitCode();

mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 3);
mv.visitVarInsn(ALOAD, 2);
mv.visitFieldInsn(PUTFIELD, name, ANNOTATIONS_FIELD, GET_MAP_VALUE);
// load super
mv.visitVarInsn(ALOAD, 0);
// load type
mv.visitVarInsn(ALOAD, 1);
// load closures
mv.visitVarInsn(ALOAD, 2);
// load annotations
mv.visitVarInsn(ALOAD, 3);
mv.visitVarInsn(ALOAD, 2);
// invoke `super(type)`;
mv.visitMethodInsn(INVOKESPECIAL, TYPEDESC_VALUE_IMPL, JVM_INIT_METHOD, TYPE_DESC_CONSTRUCTOR_WITH_ANNOTATIONS,
false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
public class JLargeArrayInstruction extends JInstruction {

public BIROperand typedescOp;
public BIROperand elementTypedescOp;
public BIROperand sizeOp;
public BType type;
public BIROperand values;
Expand All @@ -46,9 +47,10 @@ public JLargeArrayInstruction(Location location, BType type, BIROperand lhsOp, B
}

public JLargeArrayInstruction(Location location, BType type, BIROperand lhsOp, BIROperand typedescOp,
BIROperand sizeOp, BIROperand values) {
BIROperand elementTypedescOp, BIROperand sizeOp, BIROperand values) {
this(location, type, lhsOp, sizeOp, values);
this.typedescOp = typedescOp;
this.elementTypedescOp = elementTypedescOp;
}

@Override
Expand Down
Loading
Loading