/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The flavor of method handle which implements a constant reference
* to a class member.
* @author jrose
*/
// Constructors and factory methods in this class *must* be package scoped or private.
if (!member.isResolved())
throw new InternalError();
// Check for corner case: invokeinterface of Object method
MemberName m = new MemberName(Object.class, member.getName(), member.getMethodType(), member.getReferenceKind());
member = m;
}
}
}
// Factory methods:
}
} else {
} else {
}
}
}
if (member.isConstructor())
return makeAllocator(member);
}
}
}
}
}
}
//// Implementation methods.
return member;
}
// If the member needs dispatching, do so.
}
}
// If the member needs dispatching, do so.
return super.bindReceiver(receiver);
}
switch (member.getReferenceKind()) {
case REF_invokeInterface:
case REF_invokeVirtual:
// Pre-dispatch the member.
MemberName concrete = new MemberName(concreteClass, member.getName(), member.getMethodType(), REF_invokeSpecial);
break;
}
}
return null;
}
/**
* Create a LF which can invoke the given method.
* Cache and share this structure among all methods with
* the same basicType and refKind.
*/
assert(m.isInvocable()) : m; // call preparedFieldLambdaForm instead
int which;
switch (m.getReferenceKind()) {
default: throw new InternalError(m.toString());
}
// precompute the barrier-free version:
}
maybeCompile(lform, m);
return lform;
}
}
switch (which) {
}
if (doesAlloc)
.changeReturnType(void.class); // <init> returns void
try {
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
final int DMH_THIS = 0;
final int ARG_BASE = 1;
int nameCursor = ARG_LIMIT;
final int GET_MEMBER = nameCursor++;
final int LINKER_CALL = nameCursor++;
if (doesAlloc) {
// names = { argx,y,z,... new C, init method }
} else if (needsInit) {
} else {
}
if (doesAlloc) {
}
// This is a tricky bit of code. Don't send it through the LF interpreter.
return lform;
}
// Help along bootstrapping...
}
/** Static wrapper for DirectMethodHandle.internalMemberName. */
}
/** Static wrapper for DirectMethodHandle.internalMemberName.
* This one also forces initialization.
*/
}
/*non-public*/ static
switch (member.getReferenceKind()) {
case REF_invokeStatic:
case REF_getStatic:
case REF_putStatic:
case REF_newInvokeSpecial:
break;
default:
// No need to initialize the class on this kind of member.
return false;
}
if (cls == ValueConversions.class ||
cls == MethodHandleImpl.class ||
// These guys have lots of <clinit> DMH creation but we know
// the MHs will not be used until the system is booted.
return false;
}
// It is a system class. It is probably in the process of
// being initialized, but we will help it along just to be safe.
}
return false;
}
}
// If the previous call didn't block, this can happen.
// We are executing inside <clinit>.
return null;
}
}
private void ensureInitialized() {
if (checkInitialized(member)) {
// The coast is clear. Delete the <clinit> barrier.
else
}
}
return true; // the final state
}
// Somebody may still be running defc.<clinit>.
// If anybody is running defc.<clinit>, it is this thread.
// Yes, we are running it; keep the barrier for now.
return false;
} else {
// We are in a random thread. Block.
}
// put it into the final state
return true;
}
}
/** This subclass handles constructor references. */
this.initMethod = initMethod;
this.instanceClass = instanceClass;
assert(initMethod.isResolved());
}
}
return dmh.initMethod;
}
}
/** This subclass handles non-static field references. */
final int fieldOffset;
int fieldOffset) {
this.fieldOffset = fieldOffset;
}
}
}
// Note: We return a long because that is what Unsafe.getObject likes.
// We store a plain int because it is more compact.
}
// Note that the object's class has already been verified,
// since the parameter type of the Accessor method handle
// is either member.getDeclaringClass or a subclass.
// This was verified in DirectMethodHandle.make.
// Therefore, the only remaining check is for null.
// Since this check is *not* guaranteed by Unsafe.getInt
// and its siblings, we need to make an explicit one here.
return obj;
}
/** This subclass handles static field references. */
final private long staticOffset;
this.staticBase = staticBase;
this.staticOffset = staticOffset;
}
}
}
return obj;
}
}
}
}
}
// Caching machinery for field accessors:
private static byte
// Enumerate the different field kinds using Wrapper,
// with an extra case added for checked references.
private static int
+ ftypeKind);
}
if (ftype.isPrimitive())
return FT_UNCHECKED_REF;
else
return FT_CHECKED_REF;
}
/**
* Create a LF which can access the given field.
* Cache and share this structure among all fields with
* the same basicType and refKind.
*/
boolean isVolatile = m.isVolatile();
byte formOp;
switch (m.getReferenceKind()) {
default: throw new InternalError(m.toString());
}
if (shouldBeInitialized(m)) {
// precompute the barrier-free version:
assert((AF_GETSTATIC_INIT - AF_GETSTATIC) ==
}
maybeCompile(lform, m);
return lform;
}
private static LambdaForm preparedFieldLambdaForm(byte formOp, boolean isVolatile, Class<?> ftype) {
return lform;
}
private static LambdaForm makePreparedFieldLambdaForm(byte formOp, boolean isVolatile, int ftypeKind) {
if (isGetter)
else
try {
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
// What is the external type of the lambda form?
if (isGetter)
else
if (!isStatic)
final int DMH_THIS = 0;
final int ARG_BASE = 1;
// if this is for non-static access, the base pointer is stored at this index:
// if this is for write access, the value to be written is stored at this index:
int nameCursor = ARG_LIMIT;
final int LINKER_CALL = nameCursor++;
if (needsInit)
if (isStatic) {
} else {
}
if (!isGetter) {
}
}
private static final NamedFunction
static {
try {
NamedFunction nfs[] = {
};
// Each nf must be statically invocable or we get tied up in our bootstraps.
}
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
}
}