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

Generate a typedesc instruction once for record and tuple types #39101

Closed

Conversation

chiranSachintha
Copy link
Member

@chiranSachintha chiranSachintha commented Dec 17, 2022

Purpose

$title.

Fixes #38844

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@chiranSachintha chiranSachintha added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Dec 17, 2022
}

@Override
public void visit(BLangFunctionTypeNode functionTypeNode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have to visit parameter and return types?

Copy link
Member Author

@chiranSachintha chiranSachintha Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible to assign a value to the parameters of a function node. And also no usage in creating a type descriptor for the return value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

public function main() {
    function (record {| float f; |}) returns record {| string b = "hello"; |} y;
}

Where are the new typedesc instructions generated for these records?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't generate typedesc for this because there is no usage of defining typedescs for these records.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean no usage?

import ballerina/io;

annotation record {| float f = foo(); |} annot on record field;

public function main() {
    function (record {| @annot float f; |}) r;
}

isolated function foo() returns float {
    io:println("foo");
    return 1.0;
}

This should print "foo", but it doesn't atm.

Either way, we shouldn't make assumptions about usage. The spec defines when the typedesc is resolved, and we have to resolve it at that point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we need changes in #38488 for the sample I shared above to work as expected? We need to make sure we have tests for every possible type node scenario.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we add this as a test in the other PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chiranSachintha, any update on this? Doesn't seem to work for me with the other PR also, will recheck.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you send a draft PR with changes from both PRs, resolving conflicts?

if (field.typeNode != null) {
field.typeNode.accept(this);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the param/return types in methods?

Copy link
Member Author

@chiranSachintha chiranSachintha Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When defining an object, the methods of the object are added to a function list and when visiting the function list, type descriptors for the parameters and return type will be created(no need to generate type descriptors here).

@codecov
Copy link

codecov bot commented Jan 3, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (3adfbf0) 76.35% compared to head (1cf271a) 76.83%.
Report is 131 commits behind head on master.

❗ Current head 1cf271a differs from pull request most recent head 2299e82. Consider uploading reports for the commit 2299e82 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #39101      +/-   ##
============================================
+ Coverage     76.35%   76.83%   +0.47%     
- Complexity    52520    53442     +922     
============================================
  Files          2881     3347     +466     
  Lines        198492   199736    +1244     
  Branches      25807    25813       +6     
============================================
+ Hits         151565   153464    +1899     
+ Misses        38563    37680     -883     
- Partials       8364     8592     +228     
Files Coverage Δ
...java/io/ballerina/runtime/api/utils/TypeUtils.java 20.00% <ø> (-5.59%) ⬇️
...ava/io/ballerina/runtime/internal/TypeChecker.java 78.53% <100.00%> (-2.30%) ⬇️
...ina/runtime/internal/types/BTypeReferenceType.java 92.85% <100.00%> (+0.85%) ⬆️
.../ballerina/runtime/internal/util/RuntimeUtils.java 46.87% <100.00%> (+16.76%) ⬆️
...allerina/runtime/internal/values/MapValueImpl.java 90.43% <100.00%> (+1.54%) ⬆️
...org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java 100.00% <100.00%> (ø)
...llerinalang/compiler/bir/codegen/JvmConstants.java 100.00% <ø> (ø)
...nalang/compiler/bir/codegen/JvmInstructionGen.java 89.90% <100.00%> (-0.49%) ⬇️
...ballerinalang/compiler/bir/codegen/JvmTypeGen.java 91.43% <100.00%> (-1.92%) ⬇️
...compiler/bir/codegen/split/JvmMethodsSplitter.java 100.00% <100.00%> (ø)
... and 12 more

... and 1374 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chiranSachintha chiranSachintha changed the title Generate new typedesc instruction for record when typedesc resolving Generate a typedesc instruction once for record and tuple types Jan 9, 2023
@github-actions
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Sep 13, 2023
@github-actions
Copy link

Closed PR due to inactivity for more than 18 days.

@chiranSachintha chiranSachintha marked this pull request as draft October 2, 2023 06:53
@github-actions
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

Copy link

github-actions bot commented Nov 2, 2023

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Nov 2, 2023
Copy link

github-actions bot commented Nov 5, 2023

Closed PR due to inactivity for more than 18 days.

Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@chiranSachintha
Copy link
Member Author

I have opened a new PR for this change as we have modified the logic(#41945)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
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
7 participants