From: <fwi...@us...> - 2009-10-25 02:34:12
|
Revision: 6900 http://jython.svn.sourceforge.net/jython/?rev=6900&view=rev Author: fwierzbicki Date: 2009-10-25 02:34:06 +0000 (Sun, 25 Oct 2009) Log Message: ----------- switch MethodHandle creation to Codegen style. Modified Paths: -------------- branches/indy/src/org/python/compiler/Module.java Modified: branches/indy/src/org/python/compiler/Module.java =================================================================== --- branches/indy/src/org/python/compiler/Module.java 2009-10-24 07:19:01 UTC (rev 6899) +++ branches/indy/src/org/python/compiler/Module.java 2009-10-25 02:34:06 UTC (rev 6900) @@ -2,6 +2,9 @@ package org.python.compiler; import java.dyn.MethodHandle; +import java.dyn.MethodHandles; +import java.dyn.MethodHandles.Lookup; +import java.dyn.MethodType; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; @@ -358,19 +361,21 @@ } private void makeMethodHandle(Code c) { - c.visitMethodInsn(INVOKESTATIC, "java/dyn/MethodHandles", "lookup", "()Ljava/dyn/MethodHandles$Lookup;"); - c.visitLdcInsn(Type.getType("L"+module.classfile.name+";")); - c.visitLdcInsn(fname); - c.visitLdcInsn(Type.getType("Lorg/python/core/PyObject;")); - c.visitLdcInsn(Type.getType("Lorg/python/core/PyFrame;")); - c.visitInsn(ICONST_1); - c.visitTypeInsn(ANEWARRAY, "java/lang/Class"); - c.visitInsn(DUP); - c.visitInsn(ICONST_0); - c.visitLdcInsn(Type.getType("Lorg/python/core/ThreadState;")); - c.visitInsn(AASTORE); - c.visitMethodInsn(INVOKESTATIC, "java/dyn/MethodType", "make", "(Ljava/lang/Class;Ljava/lang/Class;[Ljava/lang/Class;)Ljava/dyn/MethodType;"); - c.visitMethodInsn(INVOKEVIRTUAL, "java/dyn/MethodHandles$Lookup", "findVirtual", "(Ljava/lang/Class;Ljava/lang/String;Ljava/dyn/MethodType;)Ljava/dyn/MethodHandle;"); + c.invokestatic(p(MethodHandles.class), "lookup", sig(Lookup.class)); + c.ldc(Type.getType("L"+module.classfile.name+";")); + c.ldc(fname); + c.ldc(Type.getType(ci(PyObject.class))); + c.ldc(Type.getType(ci(PyFrame.class))); + c.iconst_1(); + c.anewarray(p(Class.class)); + c.dup(); + c.iconst_0(); + c.ldc(Type.getType(ci(ThreadState.class))); + c.aastore(); + c.invokestatic(p(MethodType.class), "make", + sig(MethodType.class, Class.class, Class.class, Class[].class)); + c.invokevirtual(p(Lookup.class), "findVirtual", + sig(MethodHandle.class, Class.class, String.class, MethodType.class)); } void put(Code c) throws IOException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |