Mercurial > hg > truffle
comparison test/runtime/8003720/Asmator.java @ 7179:d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
Summary: Pass down a closure during root scanning to keep the class of the method alive.
Reviewed-by: coleenp, jcoomes
author | stefank |
---|---|
date | Tue, 27 Nov 2012 10:13:20 +0100 |
parents | |
children | dad48145e775 |
comparison
equal
deleted
inserted
replaced
7178:19c1bd641922 | 7179:d0aa87f04bd5 |
---|---|
1 import com.sun.xml.internal.ws.org.objectweb.asm.*; | |
2 | |
3 class Asmator { | |
4 static byte[] fixup(byte[] buf) throws java.io.IOException { | |
5 ClassReader cr = new ClassReader(buf); | |
6 ClassWriter cw = new ClassWriter(0) { | |
7 public MethodVisitor visitMethod( | |
8 final int access, | |
9 final String name, | |
10 final String desc, | |
11 final String signature, | |
12 final String[] exceptions) | |
13 { | |
14 MethodVisitor mv = super.visitMethod(access, | |
15 name, | |
16 desc, | |
17 signature, | |
18 exceptions); | |
19 if (mv == null) return null; | |
20 if (name.equals("callme")) { | |
21 // make receiver go dead! | |
22 mv.visitInsn(Opcodes.ACONST_NULL); | |
23 mv.visitVarInsn(Opcodes.ASTORE, 0); | |
24 } | |
25 return mv; | |
26 } | |
27 }; | |
28 cr.accept(cw, 0); | |
29 return cw.toByteArray(); | |
30 } | |
31 } |