这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@asgerf
Copy link
Contributor

@asgerf asgerf commented Sep 12, 2025

Adds overlay annotations to make the AST, CFG, SSA, and DataFlow::Node layers local, along with a lot of other predicates spread across the codebase that also needed to become local.

Evaluations compared to baseline, both sides with overlay and diff-informed. This shows the effects of this PR.

Evaluations of incremental versus non-incremental, both at the head of this PR. This shows the effects of incremental in general, including contributions from prior work.

Couple notes about the evaluations:

  • The failures are due to some PRs that did not have any code in the base commit. This is expected behaviour but DCA duly reports it as a failure. I have an internal PR open for removing them from the source suite.
  • The result count accuracy is 100%, but the tuple count accuracy is less in a few cases, due to some missing discarding of JSON elements. Currently re-running with updated discard predicates.. Fixed now.

@asgerf asgerf added the no-change-note-required This PR does not need a change note label Sep 12, 2025
@github-actions github-actions bot added the JS label Sep 12, 2025
@asgerf asgerf force-pushed the js/overlay-manual-v4 branch 2 times, most recently from 0f6a98c to 831b225 Compare October 15, 2025 09:05
@asgerf asgerf force-pushed the js/overlay-manual-v4 branch 6 times, most recently from a3235f5 to 5d28d57 Compare October 27, 2025 13:03
@asgerf asgerf force-pushed the js/overlay-manual-v4 branch 3 times, most recently from 3070570 to 84e7101 Compare October 31, 2025 09:18
@asgerf asgerf force-pushed the js/overlay-manual-v4 branch from 25f4afb to c7341f2 Compare November 13, 2025 08:51
@asgerf asgerf marked this pull request as ready for review November 18, 2025 13:17
@asgerf asgerf requested a review from a team as a code owner November 18, 2025 13:17
Copilot AI review requested due to automatic review settings November 18, 2025 13:17
@asgerf asgerf requested review from a team as code owners November 18, 2025 13:17
Copilot finished reviewing on behalf of asgerf November 18, 2025 13:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds overlay annotations to make the AST, CFG, SSA, and DataFlow::Node layers local in the JavaScript CodeQL library, improving incremental evaluation performance by 21% while maintaining 100% accuracy.

Key changes:

  • Addition of overlay[local] and overlay[global] annotations throughout the codebase
  • Refactoring of several predicates for better performance
  • Introduction of helper predicates to optimize evaluation

Reviewed Changes

Copilot reviewed 110 out of 110 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Multiple .qll files Added overlay[local] module; annotations to make modules local
Multiple .qll files Added overlay[global], overlay[caller], and overlay[caller?] annotations to specific predicates
DuplicateProperty.ql Refactored duplicate detection logic with new helper predicates
ForOfLoops.qll Extracted array index content sets into helper predicates
BarrierGuards.qll Refactored logical operator handling into unified predicate
CallGraphs.qll Extracted object usage check into separate predicate
LazyCache.qll Changed from .flow() to DataFlow::valueNode()
Regexp.qll Added helper predicates for type checking
Expr.qll Refactored enclosing statement logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 527 to 539
/**
* Holds if there is a step from `pred` to `succ` through a call to an identity function.
*/
overlay[local]
cached
predicate identityFunctionStep(DataFlow::Node pred, DataFlow::CallNode succ) {
exists(DataFlow::GlobalVarRefNode global |
global.getName() = "Object" and
succ.(DataFlow::MethodCallNode).calls(global, ["freeze", "seal"]) and
pred = succ.getArgument(0)
)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: why was this predicate moved out of the CachedSteps module?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. It doesn't seem to make a difference anymore.

or
exists(any(DataFlow::ClassNode cls))
or
// exists(any(DataFlow::ClassNode cls)) // Depends on AnalyzedNode
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the "DON'T USE!" comment on this predicate, I assume it's a deliberate choice to leave this commented-out, but just mentioning it in case you had intended to come back and fix/uncomment it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just an oversight. I'll remove the out-commented code.

or
yaml_locations(node, loc)
or
xmllocations(node, loc)
Copy link
Contributor

Choose a reason for hiding this comment

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

@kaspersv wrote the XML discard predicate for Java such that:

  • it could cope both with the current non-overlay-aware XML extraction, which re-extracts all XML files, and a future version that is overlay-aware.
  • it doesn't discard (XML) @files or @xmlnamespaces.

I suspect we need something similar here, for XML, YAML, and JSON.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting.

The set of JSON, YAML, and HTML files to extract are picked out by the JS auto builder, so they respect overlay-changes. HTML reuses the XML dbscheme.

The JS auto-builder doesn't call the XML extractor unless some LGTM_ environment variables are explicitly set, but it seems worth fixing just in case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the amount of code duplication needed to make that work is bothering me. Would you mind if we do this in a follow-up PR? I'd like to share the discard predicates via synchronized-files, but it's a bit much to roll into this PR.

@asgerf asgerf merged commit 613895e into github:main Nov 20, 2025
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JS no-change-note-required This PR does not need a change note Python Ruby

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants