Skip to content

Fix TrapTightener #1251

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

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open

Fix TrapTightener #1251

wants to merge 14 commits into from

Conversation

wangzun66
Copy link
Collaborator

@wangzun66 wangzun66 commented Mar 26, 2025

  • TrapTightener
  • Test for TrapTightener
  • Example Graph
  • update interceptor section in the documentation

Copy link
Contributor

Documentation Preview.

@wangzun66 wangzun66 linked an issue Mar 26, 2025 that may be closed by this pull request
1 task
@wangzun66 wangzun66 requested a review from kadirayk March 26, 2025 15:27
Comment on lines +66 to +67
for (Stmt stmt : builder.getStmts()) {
Map<ClassType, Stmt> exceptionalMap = blockGraph.exceptionalSuccessors(stmt);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is slower than before

Comment on lines +93 to +97
mutatedBlocks.stream().forEach(block -> blockGraph.tryMergeIntoSurroundingBlocks(block));

// FIXME: check if there are traphandlers that have no predecessor

// delete the unused traps
UnreachableCodeEliminator codeEliminator = new UnreachableCodeEliminator();
codeEliminator.interceptBody(builder, view);
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets refactor this into a method / simplify

Comment on lines +85 to +90
blockGraph.splitAndExcludeStmtFromBlock(stmt, block);
for (ClassType classType : entry.getValue()) {
graph.removeExceptionalEdge(entry.getKey(), classType);
MutableBasicBlock blockWithUnthrowableException =
(MutableBasicBlock) blockGraph.getBlockOf(entry.getKey());
blockWithUnthrowableException.removeExceptionalSuccessorBlock(classType);
mutatedBlocks.add(blockWithUnthrowableException);
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems like functionality that should only be done in mutablestmtgraph

Comment on lines +119 to +122
if (!monitored.containsKey(currStmt)) {
monitored.put(currStmt, new HashSet<>());
}
hasChanged = monitored.get(currStmt).add(monitoredValue);
Copy link
Collaborator

Choose a reason for hiding this comment

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

performance: reuse get() ---> != null

Comment on lines +127 to +128
if (monitored.containsKey(pred)) {
for (Value value : monitored.get(pred)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

.

Comment on lines +131 to +133
monitored.put(currStmt, new HashSet<>());
}
hasChanged = monitored.get(currStmt).add(value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BodyInterceptor: fix TrapTightener
2 participants