8071368: Use more concrete types for NamedFunction constants in the code

Reviewed-by: psandoz, vlivanov, mhaupt
This commit is contained in:
Shilpi Rastogi 2016-02-10 11:04:13 +01:00
parent 3e45966cd3
commit ff97659a79

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -305,9 +305,7 @@ class Invokers {
/** Static definition of MethodHandle.invokeExact checking code. */ /** Static definition of MethodHandle.invokeExact checking code. */
/*non-public*/ static /*non-public*/ static
@ForceInline @ForceInline
void checkExactType(Object mhObj, Object expectedObj) { void checkExactType(MethodHandle mh, MethodType expected) {
MethodHandle mh = (MethodHandle) mhObj;
MethodType expected = (MethodType) expectedObj;
MethodType actual = mh.type(); MethodType actual = mh.type();
if (actual != expected) if (actual != expected)
throw newWrongMethodTypeException(expected, actual); throw newWrongMethodTypeException(expected, actual);
@ -319,9 +317,7 @@ class Invokers {
*/ */
/*non-public*/ static /*non-public*/ static
@ForceInline @ForceInline
Object checkGenericType(Object mhObj, Object expectedObj) { MethodHandle checkGenericType(MethodHandle mh, MethodType expected) {
MethodHandle mh = (MethodHandle) mhObj;
MethodType expected = (MethodType) expectedObj;
return mh.asType(expected); return mh.asType(expected);
/* Maybe add more paths here. Possible optimizations: /* Maybe add more paths here. Possible optimizations:
* for (R)MH.invoke(a*), * for (R)MH.invoke(a*),
@ -390,14 +386,13 @@ class Invokers {
/** Static definition of MethodHandle.invokeGeneric checking code. */ /** Static definition of MethodHandle.invokeGeneric checking code. */
/*non-public*/ static /*non-public*/ static
@ForceInline @ForceInline
Object getCallSiteTarget(Object site) { MethodHandle getCallSiteTarget(CallSite site) {
return ((CallSite)site).getTarget(); return site.getTarget();
} }
/*non-public*/ static /*non-public*/ static
@ForceInline @ForceInline
void checkCustomized(Object o) { void checkCustomized(MethodHandle mh) {
MethodHandle mh = (MethodHandle)o;
if (MethodHandleImpl.isCompileConstant(mh)) return; if (MethodHandleImpl.isCompileConstant(mh)) return;
if (mh.form.customized == null) { if (mh.form.customized == null) {
maybeCustomize(mh); maybeCustomize(mh);
@ -425,13 +420,13 @@ class Invokers {
try { try {
NamedFunction nfs[] = { NamedFunction nfs[] = {
NF_checkExactType = new NamedFunction(Invokers.class NF_checkExactType = new NamedFunction(Invokers.class
.getDeclaredMethod("checkExactType", Object.class, Object.class)), .getDeclaredMethod("checkExactType", MethodHandle.class, MethodType.class)),
NF_checkGenericType = new NamedFunction(Invokers.class NF_checkGenericType = new NamedFunction(Invokers.class
.getDeclaredMethod("checkGenericType", Object.class, Object.class)), .getDeclaredMethod("checkGenericType", MethodHandle.class, MethodType.class)),
NF_getCallSiteTarget = new NamedFunction(Invokers.class NF_getCallSiteTarget = new NamedFunction(Invokers.class
.getDeclaredMethod("getCallSiteTarget", Object.class)), .getDeclaredMethod("getCallSiteTarget", CallSite.class)),
NF_checkCustomized = new NamedFunction(Invokers.class NF_checkCustomized = new NamedFunction(Invokers.class
.getDeclaredMethod("checkCustomized", Object.class)) .getDeclaredMethod("checkCustomized", MethodHandle.class))
}; };
// Each nf must be statically invocable or we get tied up in our bootstraps. // Each nf must be statically invocable or we get tied up in our bootstraps.
assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs)); assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));