Skip to content

Use function environment so Java functions show up in profile. - #3017

Open
toinehartman wants to merge 5 commits into
mainfrom
fix/java-functions-in-profile
Open

toinehartman wants to merge 5 commits into
mainfrom
fix/java-functions-in-profile

Conversation

@toinehartman

@toinehartman toinehartman commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Use a function environment for JavaMethod such that they show up properly in the function profile.

Compare with profile in #3016:

rascal>println("a");
a
FRAMES PROFILE: 1 data points, 1 ticks, tick = 1 milliSecs
  Scope   Ticks        %  Source
println       1   100.0%  |file:///C:/Users/toine/swat/projects/Rascal/rascal/src/org/rascalmpl/library/IO.rsc|(16881,766,<472,0>,<503,36>)

ASTS PROFILE: 1 data points, 1 ticks, tick = 1 milliSecs
  Scope   Ticks        %  Source
println       1   100.0%  |file:///C:/Users/toine/swat/projects/Rascal/rascal/src/org/rascalmpl/library/IO.rsc|(16881,766,<472,0>,<503,36>)

Compare with flame graph in #3016:
afbeelding

Closes #3016

Joint work with @sungshik.

Co-authored-by: Sung-Shik Jongmans <sung-shik.jongmans@swat.engineering>
var currentAST = ctx.getCurrentAST();
var env = new Environment(old, old, currentAST != null ? currentAST.getLocation() : null, getAst().getLocation(), name, true);
ctx.setCurrentEnvt(env);
ctx.setCurrentAST(getAst()); // otherwise it becomes the final parameter of the call site

@toinehartman toinehartman Nov 23, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this is what we're doing now; setting the location of the AST as the call site. Why is this a problem?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jurgenvinju do you remember the background of this comment?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

History: ec1ab47

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 46%. Comparing base (4d10ecd) to head (876c2cd).

Files with missing lines Patch % Lines
...c/org/rascalmpl/interpreter/result/JavaMethod.java 75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              main   #3017   +/-   ##
=======================================
  Coverage       46%     46%           
- Complexity    6933    6937    +4     
=======================================
  Files          851     851           
  Lines        69376   69376           
  Branches     10110   10111    +1     
=======================================
+ Hits         32178   32192   +14     
+ Misses       34764   34748   -16     
- Partials      2434    2436    +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@toinehartman
toinehartman marked this pull request as ready for review November 23, 2026 16:08
@toinehartman
toinehartman force-pushed the fix/java-functions-in-profile branch from 846083d to 876c2cd Compare November 24, 2026 14:03
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java-linked functions do not appear in profile/flame graphs

2 participants