8257189: Handle concurrent updates of MH.form better

Reviewed-by: redestad, psandoz
This commit is contained in:
Vladimir Ivanov 2020-12-02 17:35:41 +00:00
parent 670426646d
commit 692b273ec5
5 changed files with 69 additions and 53 deletions

View file

@ -596,21 +596,17 @@ class Invokers {
@ForceInline
/*non-public*/
static void checkCustomized(MethodHandle mh) {
if (MethodHandleImpl.isCompileConstant(mh)) return;
if (mh.form.customized == null) {
maybeCustomize(mh);
if (MethodHandleImpl.isCompileConstant(mh)) {
return; // no need to customize a MH when the instance is known to JIT
}
if (mh.form.customized == null) { // fast approximate check that the underlying form is already customized
maybeCustomize(mh); // marked w/ @DontInline
}
}
@DontInline
/*non-public*/
static void maybeCustomize(MethodHandle mh) {
byte count = mh.customizationCount;
if (count >= CUSTOMIZE_THRESHOLD) {
mh.customize();
} else {
mh.customizationCount = (byte)(count+1);
}
mh.maybeCustomize();
}
// Local constant functions: