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
Add safe unsafe methods to TruffleRuntime #2031
Conversation
9e4103a
to
51d1ab5
Compare
Would these methods make more sense as static methods of |
They could go there if you wanted, but I didn't see them as a compiler issue. Unlike other compiler methods, these aren't no-ops in the interpreter. |
Hm... does not fit either CompilerDirectives nor TruffleRuntime. |
We could backport it, but do you mean provide an interface, an adapter for the real API, and a backport implementation? That's a lot of of API faff for what is in this case a couple of static methods. I'm inclined to be much more pragmatic and just put them here. |
What do we think in general about this PR? I was planning to follow it up with access to some more of the unsafe methods, guarded by |
51d1ab5
to
12ab76a
Compare
12ab76a
to
d1afebc
Compare
What are people's thought's on this PR? |
VarHandle has 5 of these fence methods: https://docs.oracle.com/javase/9/docs/api/java/lang/invoke/VarHandle.html#fullFence-- @chumer So how should we name the Truffle VarHandle, Those five methods seem safe, and they are already static methods of VarHandle, so I think we need no permission check here for those, and they should remain static methods. |
A |
Yes I am not quite sure yet how languages should lookup var handles. In order to check permissions the lookup method should be in TruffleLanguage.Env. That makes the lookup pretty awkward to use. But do we actually need permissions? Maybe we should just limit them to be used on classes loaded using the language loader somehow? Ideas? |
Sorry what's an overlay? |
Are we interested in reducing the need for
Unsafe
in Truffle guest languages?Add these safe methods from
Unsafe
toTruffleRuntime
, as a starting point.This reduces the use of
Unsafe
in TruffleRuby, GraalJS (PRs available if this is merged), and Sulong (included in this PR.)Let's cut out the need for direct references to
Unsafe
and make more Truffle interpreters pure Java code without the need for explicit reflection to access internal fields!Shopify/truffleruby#1