Skip to content

Commit

Permalink
Intrinsify Unsafe fences
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr-ch committed Feb 28, 2016
1 parent 6a57902 commit 74e817d
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import static jdk.vm.ci.code.MemoryBarriers.JMM_POST_VOLATILE_WRITE;
import static jdk.vm.ci.code.MemoryBarriers.JMM_PRE_VOLATILE_READ;
import static jdk.vm.ci.code.MemoryBarriers.JMM_PRE_VOLATILE_WRITE;
import static jdk.vm.ci.code.MemoryBarriers.LOAD_LOAD;
import static jdk.vm.ci.code.MemoryBarriers.LOAD_STORE;
import static jdk.vm.ci.code.MemoryBarriers.STORE_LOAD;
import static jdk.vm.ci.code.MemoryBarriers.STORE_STORE;

import java.lang.reflect.Array;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -238,6 +242,10 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
return true;
}
});

r.register1("loadFence", Receiver.class, new UnsafeFencePlugin(LOAD_LOAD | LOAD_STORE));
r.register1("storeFence", Receiver.class, new UnsafeFencePlugin(STORE_STORE | LOAD_STORE));
r.register1("fullFence", Receiver.class, new UnsafeFencePlugin(LOAD_LOAD | STORE_STORE | LOAD_STORE | STORE_LOAD));
}

private static void registerIntegerLongPlugins(InvocationPlugins plugins, JavaKind kind) {
Expand Down Expand Up @@ -612,6 +620,22 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
}
}

public static class UnsafeFencePlugin implements InvocationPlugin {

private final int barriers;

public UnsafeFencePlugin(int barriers) {
this.barriers = barriers;
}

public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe) {
// Emits a null-check for the otherwise unused receiver
unsafe.get();
b.add(new MembarNode(barriers));
return true;
}
}

private static void registerGraalDirectivesPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, GraalDirectives.class);
r.register0("deoptimize", new InvocationPlugin() {
Expand Down

0 comments on commit 74e817d

Please sign in to comment.