review request (URGENT): 7051206: JSR 292 method name SwitchPoint.isValid is misleading to unwary users; should be hasBeenInvalidated
john.r.rose at oracle.com
Fri Jun 3 11:02:37 PDT 2011
On Jun 3, 2011, at 9:04 AM, Charles Oliver Nutter wrote:
> If this is the recommended way and it's not expensive, why doesn't
> hasBeenInvalidated simply do this under the covers and avoid the
> drama? I'm confused why one way is expensive and the other is not,
> when they produce the same result with the same threading effects and
> the same instability/stability of true/false results.
Actually, both are potentially expensive. It's not likely that hasBeenInvalidated (on a valid SP) will be cheaper than creating throwaway a gWT node and calling it.
To build a SP.gWT node, the JVM potentially has to register it somewhere (depending on what the SP state is and how underlying safepointing stuff works). We think it's better to emphasize the node creation at the surface of the API.
The mistake we are trying to guide users away from is using bit1 instead of bit2:
SwitchPoint sp = ...;
MethodHandle bit1 = sp.bindTo(#hasBeenInvalidated);
MethodHandle bit2 = sp.guardWithTest(constant(boolean.class, false), constant(boolean.class, true))
Note that bit1 is likely (in simple implementations) to create a throwaway node on every use, while bit2 creates a reusable node for all uses.
More information about the hotspot-compiler-dev