Skip to content

Commit

Permalink
read volatile method handle field once
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Dec 11, 2016
1 parent 6a6383c commit 8451dba
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/runtime/BlockBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ public boolean canCallDirect() {
}

public MethodHandle getTestBlockBody() {
final MethodHandle testBlockBody = this.testBlockBody;
if (testBlockBody != null) return testBlockBody;

return testBlockBody = Binder.from(boolean.class, ThreadContext.class, Block.class).drop(0).append(this).invoke(TEST_BLOCK_BODY);
return this.testBlockBody = Binder.from(boolean.class, ThreadContext.class, Block.class).drop(0).append(this).invoke(TEST_BLOCK_BODY);
}

private static final MethodHandle TEST_BLOCK_BODY = Binder.from(boolean.class, Block.class, BlockBody.class).invokeStaticQuiet(MethodHandles.lookup(), BlockBody.class, "testBlockBody");
Expand Down

0 comments on commit 8451dba

Please sign in to comment.