From: <fwi...@us...> - 2009-10-24 03:17:49
|
Revision: 6895 http://jython.svn.sourceforge.net/jython/?rev=6895&view=rev Author: fwierzbicki Date: 2009-10-24 03:17:41 +0000 (Sat, 24 Oct 2009) Log Message: ----------- move MethodHandle bytecode production into its own method. 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 03:11:46 UTC (rev 6894) +++ branches/indy/src/org/python/compiler/Module.java 2009-10-24 03:17:41 UTC (rev 6895) @@ -357,6 +357,22 @@ c.getstatic(module.classfile.name, name, ci(PyCode.class)); } + 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;"); + } + void put(Code c) throws IOException { module.classfile.addField(name, ci(PyCode.class), access); c.iconst(argcount); @@ -379,23 +395,8 @@ c.getstatic(module.classfile.name, "self", "L" + module.classfile.name + ";"); - //REPLACING WITH METH HANDLE - //c.iconst(id); + makeMethodHandle(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;"); - if (cellvars != null) { int strArray = CodeCompiler.makeStrings(c, cellvars); c.aload(strArray); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |