1135 resolvedHandle = DirectMethodHandle.make(member);
1136 }
1137 }
1138
1139 @Override
1140 public boolean equals(Object other) {
1141 if (this == other) return true;
1142 if (other == null) return false;
1143 return (other instanceof NamedFunction that)
1144 && this.member != null
1145 && this.member.equals(that.member);
1146 }
1147
1148 @Override
1149 public int hashCode() {
1150 if (member != null)
1151 return member.hashCode();
1152 return super.hashCode();
1153 }
1154
1155 static final MethodType INVOKER_METHOD_TYPE =
1156 MethodType.methodType(Object.class, MethodHandle.class, Object[].class);
1157
1158 private static MethodHandle computeInvoker(MethodTypeForm typeForm) {
1159 typeForm = typeForm.basicType().form(); // normalize to basic type
1160 MethodHandle mh = typeForm.cachedMethodHandle(MethodTypeForm.MH_NF_INV);
1161 if (mh != null) return mh;
1162 MemberName invoker = InvokerBytecodeGenerator.generateNamedFunctionInvoker(typeForm); // this could take a while
1163 mh = DirectMethodHandle.make(invoker);
1164 MethodHandle mh2 = typeForm.cachedMethodHandle(MethodTypeForm.MH_NF_INV);
1165 if (mh2 != null) return mh2; // benign race
1166 if (!mh.type().equals(INVOKER_METHOD_TYPE))
1167 throw newInternalError(mh.debugString());
1168 return typeForm.setCachedMethodHandle(MethodTypeForm.MH_NF_INV, mh);
1169 }
1170
1171 @Hidden
1172 Object invokeWithArguments(Object... arguments) throws Throwable {
1173 // If we have a cached invoker, call it right away.
1174 // NOTE: The invoker always returns a reference value.
1175 if (TRACE_INTERPRETER) return invokeWithArgumentsTracing(arguments);
1176 return invoker().invokeBasic(resolvedHandle(), arguments);
1177 }
1178
1179 @Hidden
1180 Object invokeWithArgumentsTracing(Object[] arguments) throws Throwable {
1181 Object rval;
1182 try {
1183 traceInterpreter("[ call", this, arguments);
1184 // resolvedHandle might be uninitialized, ok for tracing
1185 if (resolvedHandle == null) {
1186 traceInterpreter("| resolve", this);
|
1135 resolvedHandle = DirectMethodHandle.make(member);
1136 }
1137 }
1138
1139 @Override
1140 public boolean equals(Object other) {
1141 if (this == other) return true;
1142 if (other == null) return false;
1143 return (other instanceof NamedFunction that)
1144 && this.member != null
1145 && this.member.equals(that.member);
1146 }
1147
1148 @Override
1149 public int hashCode() {
1150 if (member != null)
1151 return member.hashCode();
1152 return super.hashCode();
1153 }
1154
1155 static class AOTHolder {
1156 static final MethodType INVOKER_METHOD_TYPE =
1157 MethodType.methodType(Object.class, MethodHandle.class, Object[].class);
1158 }
1159
1160 private static MethodHandle computeInvoker(MethodTypeForm typeForm) {
1161 typeForm = typeForm.basicType().form(); // normalize to basic type
1162 MethodHandle mh = typeForm.cachedMethodHandle(MethodTypeForm.MH_NF_INV);
1163 if (mh != null) return mh;
1164 MemberName invoker = InvokerBytecodeGenerator.generateNamedFunctionInvoker(typeForm); // this could take a while
1165 mh = DirectMethodHandle.make(invoker);
1166 MethodHandle mh2 = typeForm.cachedMethodHandle(MethodTypeForm.MH_NF_INV);
1167 if (mh2 != null) return mh2; // benign race
1168 if (!mh.type().equals(AOTHolder.INVOKER_METHOD_TYPE))
1169 throw newInternalError(mh.debugString());
1170 return typeForm.setCachedMethodHandle(MethodTypeForm.MH_NF_INV, mh);
1171 }
1172
1173 @Hidden
1174 Object invokeWithArguments(Object... arguments) throws Throwable {
1175 // If we have a cached invoker, call it right away.
1176 // NOTE: The invoker always returns a reference value.
1177 if (TRACE_INTERPRETER) return invokeWithArgumentsTracing(arguments);
1178 return invoker().invokeBasic(resolvedHandle(), arguments);
1179 }
1180
1181 @Hidden
1182 Object invokeWithArgumentsTracing(Object[] arguments) throws Throwable {
1183 Object rval;
1184 try {
1185 traceInterpreter("[ call", this, arguments);
1186 // resolvedHandle might be uninitialized, ok for tracing
1187 if (resolvedHandle == null) {
1188 traceInterpreter("| resolve", this);
|