1.1 --- a/rt/emul/compact/src/main/java/java/lang/invoke/InvokerBytecodeGenerator.java Sun Aug 10 06:21:50 2014 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,1052 +0,0 @@
1.4 -/*
1.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 - *
1.8 - * This code is free software; you can redistribute it and/or modify it
1.9 - * under the terms of the GNU General Public License version 2 only, as
1.10 - * published by the Free Software Foundation. Oracle designates this
1.11 - * particular file as subject to the "Classpath" exception as provided
1.12 - * by Oracle in the LICENSE file that accompanied this code.
1.13 - *
1.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 - * version 2 for more details (a copy is included in the LICENSE file that
1.18 - * accompanied this code).
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License version
1.21 - * 2 along with this work; if not, write to the Free Software Foundation,
1.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 - *
1.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 - * or visit www.oracle.com if you need additional information or have any
1.26 - * questions.
1.27 - */
1.28 -
1.29 -package java.lang.invoke;
1.30 -
1.31 -import sun.invoke.util.VerifyAccess;
1.32 -import java.lang.invoke.LambdaForm.Name;
1.33 -import java.lang.invoke.MethodHandles.Lookup;
1.34 -
1.35 -import sun.invoke.util.Wrapper;
1.36 -
1.37 -import java.io.*;
1.38 -import java.util.*;
1.39 -
1.40 -import jdk.internal.org.objectweb.asm.*;
1.41 -
1.42 -import java.lang.reflect.*;
1.43 -import static java.lang.invoke.MethodHandleStatics.*;
1.44 -import static java.lang.invoke.MethodHandleNatives.Constants.*;
1.45 -import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
1.46 -import sun.invoke.util.ValueConversions;
1.47 -import sun.invoke.util.VerifyType;
1.48 -
1.49 -/**
1.50 - * Code generation backend for LambdaForm.
1.51 - * <p>
1.52 - * @author John Rose, JSR 292 EG
1.53 - */
1.54 -class InvokerBytecodeGenerator {
1.55 - /** Define class names for convenience. */
1.56 - private static final String MH = "java/lang/invoke/MethodHandle";
1.57 - private static final String BMH = "java/lang/invoke/BoundMethodHandle";
1.58 - private static final String LF = "java/lang/invoke/LambdaForm";
1.59 - private static final String LFN = "java/lang/invoke/LambdaForm$Name";
1.60 - private static final String CLS = "java/lang/Class";
1.61 - private static final String OBJ = "java/lang/Object";
1.62 - private static final String OBJARY = "[Ljava/lang/Object;";
1.63 -
1.64 - private static final String LF_SIG = "L" + LF + ";";
1.65 - private static final String LFN_SIG = "L" + LFN + ";";
1.66 - private static final String LL_SIG = "(L" + OBJ + ";)L" + OBJ + ";";
1.67 -
1.68 - /** Name of its super class*/
1.69 - private static final String superName = LF;
1.70 -
1.71 - /** Name of new class */
1.72 - private final String className;
1.73 -
1.74 - /** Name of the source file (for stack trace printing). */
1.75 - private final String sourceFile;
1.76 -
1.77 - private final LambdaForm lambdaForm;
1.78 - private final String invokerName;
1.79 - private final MethodType invokerType;
1.80 - private final int[] localsMap;
1.81 -
1.82 - /** ASM bytecode generation. */
1.83 - private ClassWriter cw;
1.84 - private MethodVisitor mv;
1.85 -
1.86 - private static final MemberName.Factory MEMBERNAME_FACTORY = MemberName.getFactory();
1.87 - private static final Class<?> HOST_CLASS = LambdaForm.class;
1.88 -
1.89 - private InvokerBytecodeGenerator(LambdaForm lambdaForm, int localsMapSize,
1.90 - String className, String invokerName, MethodType invokerType) {
1.91 - if (invokerName.contains(".")) {
1.92 - int p = invokerName.indexOf(".");
1.93 - className = invokerName.substring(0, p);
1.94 - invokerName = invokerName.substring(p+1);
1.95 - }
1.96 - if (DUMP_CLASS_FILES) {
1.97 - className = makeDumpableClassName(className);
1.98 - }
1.99 - this.className = superName + "$" + className;
1.100 - this.sourceFile = "LambdaForm$" + className;
1.101 - this.lambdaForm = lambdaForm;
1.102 - this.invokerName = invokerName;
1.103 - this.invokerType = invokerType;
1.104 - this.localsMap = new int[localsMapSize];
1.105 - }
1.106 -
1.107 - private InvokerBytecodeGenerator(String className, String invokerName, MethodType invokerType) {
1.108 - this(null, invokerType.parameterCount(),
1.109 - className, invokerName, invokerType);
1.110 - // Create an array to map name indexes to locals indexes.
1.111 - for (int i = 0; i < localsMap.length; i++) {
1.112 - localsMap[i] = invokerType.parameterSlotCount() - invokerType.parameterSlotDepth(i);
1.113 - }
1.114 - }
1.115 -
1.116 - private InvokerBytecodeGenerator(String className, LambdaForm form, MethodType invokerType) {
1.117 - this(form, form.names.length,
1.118 - className, form.debugName, invokerType);
1.119 - // Create an array to map name indexes to locals indexes.
1.120 - Name[] names = form.names;
1.121 - for (int i = 0, index = 0; i < localsMap.length; i++) {
1.122 - localsMap[i] = index;
1.123 - index += Wrapper.forBasicType(names[i].type).stackSlots();
1.124 - }
1.125 - }
1.126 -
1.127 -
1.128 - /** instance counters for dumped classes */
1.129 - private final static HashMap<String,Integer> DUMP_CLASS_FILES_COUNTERS;
1.130 - /** debugging flag for saving generated class files */
1.131 - private final static File DUMP_CLASS_FILES_DIR;
1.132 -
1.133 - static {
1.134 - if (DUMP_CLASS_FILES) {
1.135 - DUMP_CLASS_FILES_COUNTERS = new HashMap<>();
1.136 - try {
1.137 - File dumpDir = new File("DUMP_CLASS_FILES");
1.138 - if (!dumpDir.exists()) {
1.139 - dumpDir.mkdirs();
1.140 - }
1.141 - DUMP_CLASS_FILES_DIR = dumpDir;
1.142 - System.out.println("Dumping class files to "+DUMP_CLASS_FILES_DIR+"/...");
1.143 - } catch (Exception e) {
1.144 - throw newInternalError(e);
1.145 - }
1.146 - } else {
1.147 - DUMP_CLASS_FILES_COUNTERS = null;
1.148 - DUMP_CLASS_FILES_DIR = null;
1.149 - }
1.150 - }
1.151 -
1.152 - static void maybeDump(final String className, final byte[] classFile) {
1.153 - if (DUMP_CLASS_FILES) {
1.154 - System.out.println("dump: " + className);
1.155 - java.security.AccessController.doPrivileged(
1.156 - new java.security.PrivilegedAction<Void>() {
1.157 - public Void run() {
1.158 - try {
1.159 - String dumpName = className;
1.160 - //dumpName = dumpName.replace('/', '-');
1.161 - File dumpFile = new File(DUMP_CLASS_FILES_DIR, dumpName+".class");
1.162 - dumpFile.getParentFile().mkdirs();
1.163 - FileOutputStream file = new FileOutputStream(dumpFile);
1.164 - file.write(classFile);
1.165 - file.close();
1.166 - return null;
1.167 - } catch (IOException ex) {
1.168 - throw newInternalError(ex);
1.169 - }
1.170 - }
1.171 - });
1.172 - }
1.173 -
1.174 - }
1.175 -
1.176 - private static String makeDumpableClassName(String className) {
1.177 - Integer ctr;
1.178 - synchronized (DUMP_CLASS_FILES_COUNTERS) {
1.179 - ctr = DUMP_CLASS_FILES_COUNTERS.get(className);
1.180 - if (ctr == null) ctr = 0;
1.181 - DUMP_CLASS_FILES_COUNTERS.put(className, ctr+1);
1.182 - }
1.183 - String sfx = ctr.toString();
1.184 - while (sfx.length() < 3)
1.185 - sfx = "0"+sfx;
1.186 - className += sfx;
1.187 - return className;
1.188 - }
1.189 -
1.190 - class CpPatch {
1.191 - final int index;
1.192 - final String placeholder;
1.193 - final Object value;
1.194 - CpPatch(int index, String placeholder, Object value) {
1.195 - this.index = index;
1.196 - this.placeholder = placeholder;
1.197 - this.value = value;
1.198 - }
1.199 - public String toString() {
1.200 - return "CpPatch/index="+index+",placeholder="+placeholder+",value="+value;
1.201 - }
1.202 - }
1.203 -
1.204 - Map<Object, CpPatch> cpPatches = new HashMap<>();
1.205 -
1.206 - int cph = 0; // for counting constant placeholders
1.207 -
1.208 - String constantPlaceholder(Object arg) {
1.209 - String cpPlaceholder = "CONSTANT_PLACEHOLDER_" + cph++;
1.210 - if (DUMP_CLASS_FILES) cpPlaceholder += " <<" + arg.toString() + ">>"; // debugging aid
1.211 - if (cpPatches.containsKey(cpPlaceholder)) {
1.212 - throw new InternalError("observed CP placeholder twice: " + cpPlaceholder);
1.213 - }
1.214 - // insert placeholder in CP and remember the patch
1.215 - int index = cw.newConst((Object) cpPlaceholder); // TODO check if aready in the constant pool
1.216 - cpPatches.put(cpPlaceholder, new CpPatch(index, cpPlaceholder, arg));
1.217 - return cpPlaceholder;
1.218 - }
1.219 -
1.220 - Object[] cpPatches(byte[] classFile) {
1.221 - int size = getConstantPoolSize(classFile);
1.222 - Object[] res = new Object[size];
1.223 - for (CpPatch p : cpPatches.values()) {
1.224 - if (p.index >= size)
1.225 - throw new InternalError("in cpool["+size+"]: "+p+"\n"+Arrays.toString(Arrays.copyOf(classFile, 20)));
1.226 - res[p.index] = p.value;
1.227 - }
1.228 - return res;
1.229 - }
1.230 -
1.231 - /**
1.232 - * Extract the number of constant pool entries from a given class file.
1.233 - *
1.234 - * @param classFile the bytes of the class file in question.
1.235 - * @return the number of entries in the constant pool.
1.236 - */
1.237 - private static int getConstantPoolSize(byte[] classFile) {
1.238 - // The first few bytes:
1.239 - // u4 magic;
1.240 - // u2 minor_version;
1.241 - // u2 major_version;
1.242 - // u2 constant_pool_count;
1.243 - return ((classFile[8] & 0xFF) << 8) | (classFile[9] & 0xFF);
1.244 - }
1.245 -
1.246 - /**
1.247 - * Extract the MemberName of a newly-defined method.
1.248 - */
1.249 - private MemberName loadMethod(byte[] classFile) {
1.250 - Class<?> invokerClass = loadAndInitializeInvokerClass(classFile, cpPatches(classFile));
1.251 - return resolveInvokerMember(invokerClass, invokerName, invokerType);
1.252 - }
1.253 -
1.254 - /**
1.255 - * Define a given class as anonymous class in the runtime system.
1.256 - */
1.257 - private static Class<?> loadAndInitializeInvokerClass(byte[] classBytes, Object[] patches) {
1.258 - Class<?> invokerClass = UNSAFE.defineAnonymousClass(HOST_CLASS, classBytes, patches);
1.259 - UNSAFE.ensureClassInitialized(invokerClass); // Make sure the class is initialized; VM might complain.
1.260 - return invokerClass;
1.261 - }
1.262 -
1.263 - private static MemberName resolveInvokerMember(Class<?> invokerClass, String name, MethodType type) {
1.264 - MemberName member = new MemberName(invokerClass, name, type, REF_invokeStatic);
1.265 - //System.out.println("resolveInvokerMember => "+member);
1.266 - //for (Method m : invokerClass.getDeclaredMethods()) System.out.println(" "+m);
1.267 - try {
1.268 - member = MEMBERNAME_FACTORY.resolveOrFail(REF_invokeStatic, member, HOST_CLASS, ReflectiveOperationException.class);
1.269 - } catch (ReflectiveOperationException e) {
1.270 - throw newInternalError(e);
1.271 - }
1.272 - //System.out.println("resolveInvokerMember => "+member);
1.273 - return member;
1.274 - }
1.275 -
1.276 - /**
1.277 - * Set up class file generation.
1.278 - */
1.279 - private void classFilePrologue() {
1.280 - cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
1.281 - cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, superName, null);
1.282 - cw.visitSource(sourceFile, null);
1.283 -
1.284 - String invokerDesc = invokerType.toMethodDescriptorString();
1.285 - mv = cw.visitMethod(Opcodes.ACC_STATIC, invokerName, invokerDesc, null, null);
1.286 - }
1.287 -
1.288 - /**
1.289 - * Tear down class file generation.
1.290 - */
1.291 - private void classFileEpilogue() {
1.292 - mv.visitMaxs(0, 0);
1.293 - mv.visitEnd();
1.294 - }
1.295 -
1.296 - /*
1.297 - * Low-level emit helpers.
1.298 - */
1.299 - private void emitConst(Object con) {
1.300 - if (con == null) {
1.301 - mv.visitInsn(Opcodes.ACONST_NULL);
1.302 - return;
1.303 - }
1.304 - if (con instanceof Integer) {
1.305 - emitIconstInsn((int) con);
1.306 - return;
1.307 - }
1.308 - if (con instanceof Long) {
1.309 - long x = (long) con;
1.310 - if (x == (short) x) {
1.311 - emitIconstInsn((int) x);
1.312 - mv.visitInsn(Opcodes.I2L);
1.313 - return;
1.314 - }
1.315 - }
1.316 - if (con instanceof Float) {
1.317 - float x = (float) con;
1.318 - if (x == (short) x) {
1.319 - emitIconstInsn((int) x);
1.320 - mv.visitInsn(Opcodes.I2F);
1.321 - return;
1.322 - }
1.323 - }
1.324 - if (con instanceof Double) {
1.325 - double x = (double) con;
1.326 - if (x == (short) x) {
1.327 - emitIconstInsn((int) x);
1.328 - mv.visitInsn(Opcodes.I2D);
1.329 - return;
1.330 - }
1.331 - }
1.332 - if (con instanceof Boolean) {
1.333 - emitIconstInsn((boolean) con ? 1 : 0);
1.334 - return;
1.335 - }
1.336 - // fall through:
1.337 - mv.visitLdcInsn(con);
1.338 - }
1.339 -
1.340 - private void emitIconstInsn(int i) {
1.341 - int opcode;
1.342 - switch (i) {
1.343 - case 0: opcode = Opcodes.ICONST_0; break;
1.344 - case 1: opcode = Opcodes.ICONST_1; break;
1.345 - case 2: opcode = Opcodes.ICONST_2; break;
1.346 - case 3: opcode = Opcodes.ICONST_3; break;
1.347 - case 4: opcode = Opcodes.ICONST_4; break;
1.348 - case 5: opcode = Opcodes.ICONST_5; break;
1.349 - default:
1.350 - if (i == (byte) i) {
1.351 - mv.visitIntInsn(Opcodes.BIPUSH, i & 0xFF);
1.352 - } else if (i == (short) i) {
1.353 - mv.visitIntInsn(Opcodes.SIPUSH, (char) i);
1.354 - } else {
1.355 - mv.visitLdcInsn(i);
1.356 - }
1.357 - return;
1.358 - }
1.359 - mv.visitInsn(opcode);
1.360 - }
1.361 -
1.362 - /*
1.363 - * NOTE: These load/store methods use the localsMap to find the correct index!
1.364 - */
1.365 - private void emitLoadInsn(char type, int index) {
1.366 - int opcode;
1.367 - switch (type) {
1.368 - case 'I': opcode = Opcodes.ILOAD; break;
1.369 - case 'J': opcode = Opcodes.LLOAD; break;
1.370 - case 'F': opcode = Opcodes.FLOAD; break;
1.371 - case 'D': opcode = Opcodes.DLOAD; break;
1.372 - case 'L': opcode = Opcodes.ALOAD; break;
1.373 - default:
1.374 - throw new InternalError("unknown type: " + type);
1.375 - }
1.376 - mv.visitVarInsn(opcode, localsMap[index]);
1.377 - }
1.378 - private void emitAloadInsn(int index) {
1.379 - emitLoadInsn('L', index);
1.380 - }
1.381 -
1.382 - private void emitStoreInsn(char type, int index) {
1.383 - int opcode;
1.384 - switch (type) {
1.385 - case 'I': opcode = Opcodes.ISTORE; break;
1.386 - case 'J': opcode = Opcodes.LSTORE; break;
1.387 - case 'F': opcode = Opcodes.FSTORE; break;
1.388 - case 'D': opcode = Opcodes.DSTORE; break;
1.389 - case 'L': opcode = Opcodes.ASTORE; break;
1.390 - default:
1.391 - throw new InternalError("unknown type: " + type);
1.392 - }
1.393 - mv.visitVarInsn(opcode, localsMap[index]);
1.394 - }
1.395 - private void emitAstoreInsn(int index) {
1.396 - emitStoreInsn('L', index);
1.397 - }
1.398 -
1.399 - /**
1.400 - * Emit a boxing call.
1.401 - *
1.402 - * @param type primitive type class to box.
1.403 - */
1.404 - private void emitBoxing(Class<?> type) {
1.405 - Wrapper wrapper = Wrapper.forPrimitiveType(type);
1.406 - String owner = "java/lang/" + wrapper.wrapperType().getSimpleName();
1.407 - String name = "valueOf";
1.408 - String desc = "(" + wrapper.basicTypeChar() + ")L" + owner + ";";
1.409 - mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc);
1.410 - }
1.411 -
1.412 - /**
1.413 - * Emit an unboxing call (plus preceding checkcast).
1.414 - *
1.415 - * @param type wrapper type class to unbox.
1.416 - */
1.417 - private void emitUnboxing(Class<?> type) {
1.418 - Wrapper wrapper = Wrapper.forWrapperType(type);
1.419 - String owner = "java/lang/" + wrapper.wrapperType().getSimpleName();
1.420 - String name = wrapper.primitiveSimpleName() + "Value";
1.421 - String desc = "()" + wrapper.basicTypeChar();
1.422 - mv.visitTypeInsn(Opcodes.CHECKCAST, owner);
1.423 - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc);
1.424 - }
1.425 -
1.426 - /**
1.427 - * Emit an implicit conversion.
1.428 - *
1.429 - * @param ptype type of value present on stack
1.430 - * @param pclass type of value required on stack
1.431 - */
1.432 - private void emitImplicitConversion(char ptype, Class<?> pclass) {
1.433 - switch (ptype) {
1.434 - case 'L':
1.435 - if (VerifyType.isNullConversion(Object.class, pclass))
1.436 - return;
1.437 - if (isStaticallyNameable(pclass)) {
1.438 - mv.visitTypeInsn(Opcodes.CHECKCAST, getInternalName(pclass));
1.439 - } else {
1.440 - mv.visitLdcInsn(constantPlaceholder(pclass));
1.441 - mv.visitTypeInsn(Opcodes.CHECKCAST, CLS);
1.442 - mv.visitInsn(Opcodes.SWAP);
1.443 - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CLS, "cast", LL_SIG);
1.444 - if (pclass.isArray())
1.445 - mv.visitTypeInsn(Opcodes.CHECKCAST, OBJARY);
1.446 - }
1.447 - return;
1.448 - case 'I':
1.449 - if (!VerifyType.isNullConversion(int.class, pclass))
1.450 - emitPrimCast(ptype, Wrapper.basicTypeChar(pclass));
1.451 - return;
1.452 - case 'J':
1.453 - assert(pclass == long.class);
1.454 - return;
1.455 - case 'F':
1.456 - assert(pclass == float.class);
1.457 - return;
1.458 - case 'D':
1.459 - assert(pclass == double.class);
1.460 - return;
1.461 - }
1.462 - throw new InternalError("bad implicit conversion: tc="+ptype+": "+pclass);
1.463 - }
1.464 -
1.465 - /**
1.466 - * Emits an actual return instruction conforming to the given return type.
1.467 - */
1.468 - private void emitReturnInsn(Class<?> type) {
1.469 - int opcode;
1.470 - switch (Wrapper.basicTypeChar(type)) {
1.471 - case 'I': opcode = Opcodes.IRETURN; break;
1.472 - case 'J': opcode = Opcodes.LRETURN; break;
1.473 - case 'F': opcode = Opcodes.FRETURN; break;
1.474 - case 'D': opcode = Opcodes.DRETURN; break;
1.475 - case 'L': opcode = Opcodes.ARETURN; break;
1.476 - case 'V': opcode = Opcodes.RETURN; break;
1.477 - default:
1.478 - throw new InternalError("unknown return type: " + type);
1.479 - }
1.480 - mv.visitInsn(opcode);
1.481 - }
1.482 -
1.483 - private static String getInternalName(Class<?> c) {
1.484 - assert(VerifyAccess.isTypeVisible(c, Object.class));
1.485 - return c.getName().replace('.', '/');
1.486 - }
1.487 -
1.488 - /**
1.489 - * Generate customized bytecode for a given LambdaForm.
1.490 - */
1.491 - static MemberName generateCustomizedCode(LambdaForm form, MethodType invokerType) {
1.492 - InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("MH", form, invokerType);
1.493 - return g.loadMethod(g.generateCustomizedCodeBytes());
1.494 - }
1.495 -
1.496 - /**
1.497 - * Generate an invoker method for the passed {@link LambdaForm}.
1.498 - */
1.499 - private byte[] generateCustomizedCodeBytes() {
1.500 - classFilePrologue();
1.501 -
1.502 - // Suppress this method in backtraces displayed to the user.
1.503 - mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
1.504 -
1.505 - // Mark this method as a compiled LambdaForm
1.506 - mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Compiled;", true);
1.507 -
1.508 - // Force inlining of this invoker method.
1.509 - mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
1.510 -
1.511 - // iterate over the form's names, generating bytecode instructions for each
1.512 - // start iterating at the first name following the arguments
1.513 - for (int i = lambdaForm.arity; i < lambdaForm.names.length; i++) {
1.514 - Name name = lambdaForm.names[i];
1.515 - MemberName member = name.function.member();
1.516 -
1.517 - if (isSelectAlternative(member)) {
1.518 - // selectAlternative idiom
1.519 - // FIXME: make sure this idiom is really present!
1.520 - emitSelectAlternative(name, lambdaForm.names[i + 1]);
1.521 - i++; // skip MH.invokeBasic of the selectAlternative result
1.522 - } else if (isStaticallyInvocable(member)) {
1.523 - emitStaticInvoke(member, name);
1.524 - } else {
1.525 - emitInvoke(name);
1.526 - }
1.527 -
1.528 - // store the result from evaluating to the target name in a local if required
1.529 - // (if this is the last value, i.e., the one that is going to be returned,
1.530 - // avoid store/load/return and just return)
1.531 - if (i == lambdaForm.names.length - 1 && i == lambdaForm.result) {
1.532 - // return value - do nothing
1.533 - } else if (name.type != 'V') {
1.534 - // non-void: actually assign
1.535 - emitStoreInsn(name.type, name.index());
1.536 - }
1.537 - }
1.538 -
1.539 - // return statement
1.540 - emitReturn();
1.541 -
1.542 - classFileEpilogue();
1.543 - bogusMethod(lambdaForm);
1.544 -
1.545 - final byte[] classFile = cw.toByteArray();
1.546 - maybeDump(className, classFile);
1.547 - return classFile;
1.548 - }
1.549 -
1.550 - /**
1.551 - * Emit an invoke for the given name.
1.552 - */
1.553 - void emitInvoke(Name name) {
1.554 - if (true) {
1.555 - // push receiver
1.556 - MethodHandle target = name.function.resolvedHandle;
1.557 - assert(target != null) : name.exprString();
1.558 - mv.visitLdcInsn(constantPlaceholder(target));
1.559 - mv.visitTypeInsn(Opcodes.CHECKCAST, MH);
1.560 - } else {
1.561 - // load receiver
1.562 - emitAloadInsn(0);
1.563 - mv.visitTypeInsn(Opcodes.CHECKCAST, MH);
1.564 - mv.visitFieldInsn(Opcodes.GETFIELD, MH, "form", LF_SIG);
1.565 - mv.visitFieldInsn(Opcodes.GETFIELD, LF, "names", LFN_SIG);
1.566 - // TODO more to come
1.567 - }
1.568 -
1.569 - // push arguments
1.570 - for (int i = 0; i < name.arguments.length; i++) {
1.571 - emitPushArgument(name, i);
1.572 - }
1.573 -
1.574 - // invocation
1.575 - MethodType type = name.function.methodType();
1.576 - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", type.basicType().toMethodDescriptorString());
1.577 - }
1.578 -
1.579 - static private Class<?>[] STATICALLY_INVOCABLE_PACKAGES = {
1.580 - // Sample classes from each package we are willing to bind to statically:
1.581 - java.lang.Object.class,
1.582 - java.util.Arrays.class,
1.583 - sun.misc.Unsafe.class
1.584 - //MethodHandle.class already covered
1.585 - };
1.586 -
1.587 - static boolean isStaticallyInvocable(MemberName member) {
1.588 - if (member == null) return false;
1.589 - if (member.isConstructor()) return false;
1.590 - Class<?> cls = member.getDeclaringClass();
1.591 - if (cls.isArray() || cls.isPrimitive())
1.592 - return false; // FIXME
1.593 - if (cls.isAnonymousClass() || cls.isLocalClass())
1.594 - return false; // inner class of some sort
1.595 - if (cls.getClassLoader() != MethodHandle.class.getClassLoader())
1.596 - return false; // not on BCP
1.597 - MethodType mtype = member.getMethodOrFieldType();
1.598 - if (!isStaticallyNameable(mtype.returnType()))
1.599 - return false;
1.600 - for (Class<?> ptype : mtype.parameterArray())
1.601 - if (!isStaticallyNameable(ptype))
1.602 - return false;
1.603 - if (!member.isPrivate() && VerifyAccess.isSamePackage(MethodHandle.class, cls))
1.604 - return true; // in java.lang.invoke package
1.605 - if (member.isPublic() && isStaticallyNameable(cls))
1.606 - return true;
1.607 - return false;
1.608 - }
1.609 -
1.610 - static boolean isStaticallyNameable(Class<?> cls) {
1.611 - while (cls.isArray())
1.612 - cls = cls.getComponentType();
1.613 - if (cls.isPrimitive())
1.614 - return true; // int[].class, for example
1.615 - // could use VerifyAccess.isClassAccessible but the following is a safe approximation
1.616 - if (cls.getClassLoader() != Object.class.getClassLoader())
1.617 - return false;
1.618 - if (VerifyAccess.isSamePackage(MethodHandle.class, cls))
1.619 - return true;
1.620 - if (!Modifier.isPublic(cls.getModifiers()))
1.621 - return false;
1.622 - for (Class<?> pkgcls : STATICALLY_INVOCABLE_PACKAGES) {
1.623 - if (VerifyAccess.isSamePackage(pkgcls, cls))
1.624 - return true;
1.625 - }
1.626 - return false;
1.627 - }
1.628 -
1.629 - /**
1.630 - * Emit an invoke for the given name, using the MemberName directly.
1.631 - */
1.632 - void emitStaticInvoke(MemberName member, Name name) {
1.633 - assert(member.equals(name.function.member()));
1.634 - String cname = getInternalName(member.getDeclaringClass());
1.635 - String mname = member.getName();
1.636 - String mtype;
1.637 - byte refKind = member.getReferenceKind();
1.638 - if (refKind == REF_invokeSpecial) {
1.639 - // in order to pass the verifier, we need to convert this to invokevirtual in all cases
1.640 - assert(member.canBeStaticallyBound()) : member;
1.641 - refKind = REF_invokeVirtual;
1.642 - }
1.643 -
1.644 - if (member.getDeclaringClass().isInterface() && refKind == REF_invokeVirtual) {
1.645 - // Methods from Object declared in an interface can be resolved by JVM to invokevirtual kind.
1.646 - // Need to convert it back to invokeinterface to pass verification and make the invocation works as expected.
1.647 - refKind = REF_invokeInterface;
1.648 - }
1.649 -
1.650 - // push arguments
1.651 - for (int i = 0; i < name.arguments.length; i++) {
1.652 - emitPushArgument(name, i);
1.653 - }
1.654 -
1.655 - // invocation
1.656 - if (member.isMethod()) {
1.657 - mtype = member.getMethodType().toMethodDescriptorString();
1.658 - mv.visitMethodInsn(refKindOpcode(refKind), cname, mname, mtype,
1.659 - member.getDeclaringClass().isInterface());
1.660 - } else {
1.661 - mtype = MethodType.toFieldDescriptorString(member.getFieldType());
1.662 - mv.visitFieldInsn(refKindOpcode(refKind), cname, mname, mtype);
1.663 - }
1.664 - }
1.665 - int refKindOpcode(byte refKind) {
1.666 - switch (refKind) {
1.667 - case REF_invokeVirtual: return Opcodes.INVOKEVIRTUAL;
1.668 - case REF_invokeStatic: return Opcodes.INVOKESTATIC;
1.669 - case REF_invokeSpecial: return Opcodes.INVOKESPECIAL;
1.670 - case REF_invokeInterface: return Opcodes.INVOKEINTERFACE;
1.671 - case REF_getField: return Opcodes.GETFIELD;
1.672 - case REF_putField: return Opcodes.PUTFIELD;
1.673 - case REF_getStatic: return Opcodes.GETSTATIC;
1.674 - case REF_putStatic: return Opcodes.PUTSTATIC;
1.675 - }
1.676 - throw new InternalError("refKind="+refKind);
1.677 - }
1.678 -
1.679 - /**
1.680 - * Check if MemberName is a call to MethodHandleImpl.selectAlternative.
1.681 - */
1.682 - private boolean isSelectAlternative(MemberName member) {
1.683 - return member != null &&
1.684 - member.getDeclaringClass() == MethodHandleImpl.class &&
1.685 - member.getName().equals("selectAlternative");
1.686 - }
1.687 -
1.688 - /**
1.689 - * Emit bytecode for the selectAlternative idiom.
1.690 - *
1.691 - * The pattern looks like (Cf. MethodHandleImpl.makeGuardWithTest):
1.692 - * <blockquote><pre>{@code
1.693 - * Lambda(a0:L,a1:I)=>{
1.694 - * t2:I=foo.test(a1:I);
1.695 - * t3:L=MethodHandleImpl.selectAlternative(t2:I,(MethodHandle(int)int),(MethodHandle(int)int));
1.696 - * t4:I=MethodHandle.invokeBasic(t3:L,a1:I);t4:I}
1.697 - * }</pre></blockquote>
1.698 - */
1.699 - private void emitSelectAlternative(Name selectAlternativeName, Name invokeBasicName) {
1.700 - MethodType type = selectAlternativeName.function.methodType();
1.701 -
1.702 - Name receiver = (Name) invokeBasicName.arguments[0];
1.703 -
1.704 - Label L_fallback = new Label();
1.705 - Label L_done = new Label();
1.706 -
1.707 - // load test result
1.708 - emitPushArgument(selectAlternativeName, 0);
1.709 - mv.visitInsn(Opcodes.ICONST_1);
1.710 -
1.711 - // if_icmpne L_fallback
1.712 - mv.visitJumpInsn(Opcodes.IF_ICMPNE, L_fallback);
1.713 -
1.714 - // invoke selectAlternativeName.arguments[1]
1.715 - MethodHandle target = (MethodHandle) selectAlternativeName.arguments[1];
1.716 - emitPushArgument(selectAlternativeName, 1); // get 2nd argument of selectAlternative
1.717 - emitAstoreInsn(receiver.index()); // store the MH in the receiver slot
1.718 - emitInvoke(invokeBasicName);
1.719 -
1.720 - // goto L_done
1.721 - mv.visitJumpInsn(Opcodes.GOTO, L_done);
1.722 -
1.723 - // L_fallback:
1.724 - mv.visitLabel(L_fallback);
1.725 -
1.726 - // invoke selectAlternativeName.arguments[2]
1.727 - MethodHandle fallback = (MethodHandle) selectAlternativeName.arguments[2];
1.728 - emitPushArgument(selectAlternativeName, 2); // get 3rd argument of selectAlternative
1.729 - emitAstoreInsn(receiver.index()); // store the MH in the receiver slot
1.730 - emitInvoke(invokeBasicName);
1.731 -
1.732 - // L_done:
1.733 - mv.visitLabel(L_done);
1.734 - }
1.735 -
1.736 - private void emitPushArgument(Name name, int paramIndex) {
1.737 - Object arg = name.arguments[paramIndex];
1.738 - char ptype = name.function.parameterType(paramIndex);
1.739 - MethodType mtype = name.function.methodType();
1.740 - if (arg instanceof Name) {
1.741 - Name n = (Name) arg;
1.742 - emitLoadInsn(n.type, n.index());
1.743 - emitImplicitConversion(n.type, mtype.parameterType(paramIndex));
1.744 - } else if ((arg == null || arg instanceof String) && ptype == 'L') {
1.745 - emitConst(arg);
1.746 - } else {
1.747 - if (Wrapper.isWrapperType(arg.getClass()) && ptype != 'L') {
1.748 - emitConst(arg);
1.749 - } else {
1.750 - mv.visitLdcInsn(constantPlaceholder(arg));
1.751 - emitImplicitConversion('L', mtype.parameterType(paramIndex));
1.752 - }
1.753 - }
1.754 - }
1.755 -
1.756 - /**
1.757 - * Emits a return statement from a LF invoker. If required, the result type is cast to the correct return type.
1.758 - */
1.759 - private void emitReturn() {
1.760 - // return statement
1.761 - if (lambdaForm.result == -1) {
1.762 - // void
1.763 - mv.visitInsn(Opcodes.RETURN);
1.764 - } else {
1.765 - LambdaForm.Name rn = lambdaForm.names[lambdaForm.result];
1.766 - char rtype = Wrapper.basicTypeChar(invokerType.returnType());
1.767 -
1.768 - // put return value on the stack if it is not already there
1.769 - if (lambdaForm.result != lambdaForm.names.length - 1) {
1.770 - emitLoadInsn(rn.type, lambdaForm.result);
1.771 - }
1.772 -
1.773 - // potentially generate cast
1.774 - // rtype is the return type of the invoker - generated code must conform to this
1.775 - // rn.type is the type of the result Name in the LF
1.776 - if (rtype != rn.type) {
1.777 - // need cast
1.778 - if (rtype == 'L') {
1.779 - // possibly cast the primitive to the correct type for boxing
1.780 - char boxedType = Wrapper.forWrapperType(invokerType.returnType()).basicTypeChar();
1.781 - if (boxedType != rn.type) {
1.782 - emitPrimCast(rn.type, boxedType);
1.783 - }
1.784 - // cast primitive to reference ("boxing")
1.785 - emitBoxing(invokerType.returnType());
1.786 - } else {
1.787 - // to-primitive cast
1.788 - if (rn.type != 'L') {
1.789 - // prim-to-prim cast
1.790 - emitPrimCast(rn.type, rtype);
1.791 - } else {
1.792 - // ref-to-prim cast ("unboxing")
1.793 - throw new InternalError("no ref-to-prim (unboxing) casts supported right now");
1.794 - }
1.795 - }
1.796 - }
1.797 -
1.798 - // generate actual return statement
1.799 - emitReturnInsn(invokerType.returnType());
1.800 - }
1.801 - }
1.802 -
1.803 - /**
1.804 - * Emit a type conversion bytecode casting from "from" to "to".
1.805 - */
1.806 - private void emitPrimCast(char from, char to) {
1.807 - // Here's how.
1.808 - // - indicates forbidden
1.809 - // <-> indicates implicit
1.810 - // to ----> boolean byte short char int long float double
1.811 - // from boolean <-> - - - - - - -
1.812 - // byte - <-> i2s i2c <-> i2l i2f i2d
1.813 - // short - i2b <-> i2c <-> i2l i2f i2d
1.814 - // char - i2b i2s <-> <-> i2l i2f i2d
1.815 - // int - i2b i2s i2c <-> i2l i2f i2d
1.816 - // long - l2i,i2b l2i,i2s l2i,i2c l2i <-> l2f l2d
1.817 - // float - f2i,i2b f2i,i2s f2i,i2c f2i f2l <-> f2d
1.818 - // double - d2i,i2b d2i,i2s d2i,i2c d2i d2l d2f <->
1.819 - if (from == to) {
1.820 - // no cast required, should be dead code anyway
1.821 - return;
1.822 - }
1.823 - Wrapper wfrom = Wrapper.forBasicType(from);
1.824 - Wrapper wto = Wrapper.forBasicType(to);
1.825 - if (wfrom.isSubwordOrInt()) {
1.826 - // cast from {byte,short,char,int} to anything
1.827 - emitI2X(to);
1.828 - } else {
1.829 - // cast from {long,float,double} to anything
1.830 - if (wto.isSubwordOrInt()) {
1.831 - // cast to {byte,short,char,int}
1.832 - emitX2I(from);
1.833 - if (wto.bitWidth() < 32) {
1.834 - // targets other than int require another conversion
1.835 - emitI2X(to);
1.836 - }
1.837 - } else {
1.838 - // cast to {long,float,double} - this is verbose
1.839 - boolean error = false;
1.840 - switch (from) {
1.841 - case 'J':
1.842 - if (to == 'F') { mv.visitInsn(Opcodes.L2F); }
1.843 - else if (to == 'D') { mv.visitInsn(Opcodes.L2D); }
1.844 - else error = true;
1.845 - break;
1.846 - case 'F':
1.847 - if (to == 'J') { mv.visitInsn(Opcodes.F2L); }
1.848 - else if (to == 'D') { mv.visitInsn(Opcodes.F2D); }
1.849 - else error = true;
1.850 - break;
1.851 - case 'D':
1.852 - if (to == 'J') { mv.visitInsn(Opcodes.D2L); }
1.853 - else if (to == 'F') { mv.visitInsn(Opcodes.D2F); }
1.854 - else error = true;
1.855 - break;
1.856 - default:
1.857 - error = true;
1.858 - break;
1.859 - }
1.860 - if (error) {
1.861 - throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
1.862 - }
1.863 - }
1.864 - }
1.865 - }
1.866 -
1.867 - private void emitI2X(char type) {
1.868 - switch (type) {
1.869 - case 'B': mv.visitInsn(Opcodes.I2B); break;
1.870 - case 'S': mv.visitInsn(Opcodes.I2S); break;
1.871 - case 'C': mv.visitInsn(Opcodes.I2C); break;
1.872 - case 'I': /* naught */ break;
1.873 - case 'J': mv.visitInsn(Opcodes.I2L); break;
1.874 - case 'F': mv.visitInsn(Opcodes.I2F); break;
1.875 - case 'D': mv.visitInsn(Opcodes.I2D); break;
1.876 - case 'Z':
1.877 - // For compatibility with ValueConversions and explicitCastArguments:
1.878 - mv.visitInsn(Opcodes.ICONST_1);
1.879 - mv.visitInsn(Opcodes.IAND);
1.880 - break;
1.881 - default: throw new InternalError("unknown type: " + type);
1.882 - }
1.883 - }
1.884 -
1.885 - private void emitX2I(char type) {
1.886 - switch (type) {
1.887 - case 'J': mv.visitInsn(Opcodes.L2I); break;
1.888 - case 'F': mv.visitInsn(Opcodes.F2I); break;
1.889 - case 'D': mv.visitInsn(Opcodes.D2I); break;
1.890 - default: throw new InternalError("unknown type: " + type);
1.891 - }
1.892 - }
1.893 -
1.894 - private static String basicTypeCharSignature(String prefix, MethodType type) {
1.895 - StringBuilder buf = new StringBuilder(prefix);
1.896 - for (Class<?> ptype : type.parameterList())
1.897 - buf.append(Wrapper.forBasicType(ptype).basicTypeChar());
1.898 - buf.append('_').append(Wrapper.forBasicType(type.returnType()).basicTypeChar());
1.899 - return buf.toString();
1.900 - }
1.901 -
1.902 - /**
1.903 - * Generate bytecode for a LambdaForm.vmentry which calls interpretWithArguments.
1.904 - */
1.905 - static MemberName generateLambdaFormInterpreterEntryPoint(String sig) {
1.906 - assert(LambdaForm.isValidSignature(sig));
1.907 - //System.out.println("generateExactInvoker "+sig);
1.908 - // compute method type
1.909 - // first parameter and return type
1.910 - char tret = LambdaForm.signatureReturn(sig);
1.911 - MethodType type = MethodType.methodType(LambdaForm.typeClass(tret), MethodHandle.class);
1.912 - // other parameter types
1.913 - int arity = LambdaForm.signatureArity(sig);
1.914 - for (int i = 1; i < arity; i++) {
1.915 - type = type.appendParameterTypes(LambdaForm.typeClass(sig.charAt(i)));
1.916 - }
1.917 - InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("LFI", "interpret_"+tret, type);
1.918 - return g.loadMethod(g.generateLambdaFormInterpreterEntryPointBytes());
1.919 - }
1.920 -
1.921 - private byte[] generateLambdaFormInterpreterEntryPointBytes() {
1.922 - classFilePrologue();
1.923 -
1.924 - // Suppress this method in backtraces displayed to the user.
1.925 - mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
1.926 -
1.927 - // Don't inline the interpreter entry.
1.928 - mv.visitAnnotation("Ljava/lang/invoke/DontInline;", true);
1.929 -
1.930 - // create parameter array
1.931 - emitIconstInsn(invokerType.parameterCount());
1.932 - mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
1.933 -
1.934 - // fill parameter array
1.935 - for (int i = 0; i < invokerType.parameterCount(); i++) {
1.936 - Class<?> ptype = invokerType.parameterType(i);
1.937 - mv.visitInsn(Opcodes.DUP);
1.938 - emitIconstInsn(i);
1.939 - emitLoadInsn(Wrapper.basicTypeChar(ptype), i);
1.940 - // box if primitive type
1.941 - if (ptype.isPrimitive()) {
1.942 - emitBoxing(ptype);
1.943 - }
1.944 - mv.visitInsn(Opcodes.AASTORE);
1.945 - }
1.946 - // invoke
1.947 - emitAloadInsn(0);
1.948 - mv.visitFieldInsn(Opcodes.GETFIELD, MH, "form", "Ljava/lang/invoke/LambdaForm;");
1.949 - mv.visitInsn(Opcodes.SWAP); // swap form and array; avoid local variable
1.950 - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, LF, "interpretWithArguments", "([Ljava/lang/Object;)Ljava/lang/Object;");
1.951 -
1.952 - // maybe unbox
1.953 - Class<?> rtype = invokerType.returnType();
1.954 - if (rtype.isPrimitive() && rtype != void.class) {
1.955 - emitUnboxing(Wrapper.asWrapperType(rtype));
1.956 - }
1.957 -
1.958 - // return statement
1.959 - emitReturnInsn(rtype);
1.960 -
1.961 - classFileEpilogue();
1.962 - bogusMethod(invokerType);
1.963 -
1.964 - final byte[] classFile = cw.toByteArray();
1.965 - maybeDump(className, classFile);
1.966 - return classFile;
1.967 - }
1.968 -
1.969 - /**
1.970 - * Generate bytecode for a NamedFunction invoker.
1.971 - */
1.972 - static MemberName generateNamedFunctionInvoker(MethodTypeForm typeForm) {
1.973 - MethodType invokerType = LambdaForm.NamedFunction.INVOKER_METHOD_TYPE;
1.974 - String invokerName = basicTypeCharSignature("invoke_", typeForm.erasedType());
1.975 - InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("NFI", invokerName, invokerType);
1.976 - return g.loadMethod(g.generateNamedFunctionInvokerImpl(typeForm));
1.977 - }
1.978 -
1.979 - static int nfi = 0;
1.980 -
1.981 - private byte[] generateNamedFunctionInvokerImpl(MethodTypeForm typeForm) {
1.982 - MethodType dstType = typeForm.erasedType();
1.983 - classFilePrologue();
1.984 -
1.985 - // Suppress this method in backtraces displayed to the user.
1.986 - mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
1.987 -
1.988 - // Force inlining of this invoker method.
1.989 - mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
1.990 -
1.991 - // Load receiver
1.992 - emitAloadInsn(0);
1.993 -
1.994 - // Load arguments from array
1.995 - for (int i = 0; i < dstType.parameterCount(); i++) {
1.996 - emitAloadInsn(1);
1.997 - emitIconstInsn(i);
1.998 - mv.visitInsn(Opcodes.AALOAD);
1.999 -
1.1000 - // Maybe unbox
1.1001 - Class<?> dptype = dstType.parameterType(i);
1.1002 - if (dptype.isPrimitive()) {
1.1003 - Class<?> sptype = dstType.basicType().wrap().parameterType(i);
1.1004 - Wrapper dstWrapper = Wrapper.forBasicType(dptype);
1.1005 - Wrapper srcWrapper = dstWrapper.isSubwordOrInt() ? Wrapper.INT : dstWrapper; // narrow subword from int
1.1006 - emitUnboxing(srcWrapper.wrapperType());
1.1007 - emitPrimCast(srcWrapper.basicTypeChar(), dstWrapper.basicTypeChar());
1.1008 - }
1.1009 - }
1.1010 -
1.1011 - // Invoke
1.1012 - String targetDesc = dstType.basicType().toMethodDescriptorString();
1.1013 - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", targetDesc);
1.1014 -
1.1015 - // Box primitive types
1.1016 - Class<?> rtype = dstType.returnType();
1.1017 - if (rtype != void.class && rtype.isPrimitive()) {
1.1018 - Wrapper srcWrapper = Wrapper.forBasicType(rtype);
1.1019 - Wrapper dstWrapper = srcWrapper.isSubwordOrInt() ? Wrapper.INT : srcWrapper; // widen subword to int
1.1020 - // boolean casts not allowed
1.1021 - emitPrimCast(srcWrapper.basicTypeChar(), dstWrapper.basicTypeChar());
1.1022 - emitBoxing(dstWrapper.primitiveType());
1.1023 - }
1.1024 -
1.1025 - // If the return type is void we return a null reference.
1.1026 - if (rtype == void.class) {
1.1027 - mv.visitInsn(Opcodes.ACONST_NULL);
1.1028 - }
1.1029 - emitReturnInsn(Object.class); // NOTE: NamedFunction invokers always return a reference value.
1.1030 -
1.1031 - classFileEpilogue();
1.1032 - bogusMethod(dstType);
1.1033 -
1.1034 - final byte[] classFile = cw.toByteArray();
1.1035 - maybeDump(className, classFile);
1.1036 - return classFile;
1.1037 - }
1.1038 -
1.1039 - /**
1.1040 - * Emit a bogus method that just loads some string constants. This is to get the constants into the constant pool
1.1041 - * for debugging purposes.
1.1042 - */
1.1043 - private void bogusMethod(Object... os) {
1.1044 - if (DUMP_CLASS_FILES) {
1.1045 - mv = cw.visitMethod(Opcodes.ACC_STATIC, "dummy", "()V", null, null);
1.1046 - for (Object o : os) {
1.1047 - mv.visitLdcInsn(o.toString());
1.1048 - mv.visitInsn(Opcodes.POP);
1.1049 - }
1.1050 - mv.visitInsn(Opcodes.RETURN);
1.1051 - mv.visitMaxs(0, 0);
1.1052 - mv.visitEnd();
1.1053 - }
1.1054 - }
1.1055 -}