Skip to content

Commit

Permalink
[PEA] mark monitor inputs as escaped (openjdk#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
caojoshua authored Jul 28, 2023
1 parent 6fc9549 commit b8e8eb2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions PEA/MatInMonitor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class MatInMonitor {
private Object _cache;
public void test() {
Object x = new Object();
synchronized (x) {
_cache = x;
}
}

public static void main(String[] args) {
MatInMonitor kase = new MatInMonitor();

for (int i = 0; i < 2; ++i) {
kase.test();
}
}
}
2 changes: 2 additions & 0 deletions PEA/run_mat_in_monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/bash
java -Xcomp -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:-UseOnStackReplacement -XX:+StressRecompilation -XX:+UseTLAB -XX:CompileCommand='compileOnly,MatInMonitor.test*' $* MatInMonitor
10 changes: 10 additions & 0 deletions src/hotspot/share/opto/locknode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ void Parse::do_monitor_enter() {
// the monitor object is not part of debug info expression stack
pop();

if (DoPartialEscapeAnalysis) {
// TODO: PEA can support monitors
PartialEscapeAnalysis* pea = PEA();
PEAState& state = jvms()->alloc_state();

if (state.as_virtual(pea, obj) != nullptr) {
state.escape(pea->is_alias(obj), obj, false);
}
}

// Insert a FastLockNode which takes as arguments the current thread pointer,
// the obj pointer & the address of the stack slot pair used for the lock.
shared_lock(obj);
Expand Down

0 comments on commit b8e8eb2

Please sign in to comment.