Mercurial > hg > graal-compiler
annotate 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 |
rev | line source |
---|---|
7179
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
1 import com.sun.xml.internal.ws.org.objectweb.asm.*; |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
2 |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
3 class Asmator { |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
4 static byte[] fixup(byte[] buf) throws java.io.IOException { |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
5 ClassReader cr = new ClassReader(buf); |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
6 ClassWriter cw = new ClassWriter(0) { |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
7 public MethodVisitor visitMethod( |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
8 final int access, |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
9 final String name, |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
10 final String desc, |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
11 final String signature, |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
12 final String[] exceptions) |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
13 { |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
14 MethodVisitor mv = super.visitMethod(access, |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
15 name, |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
16 desc, |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
17 signature, |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
18 exceptions); |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
19 if (mv == null) return null; |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
20 if (name.equals("callme")) { |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
21 // make receiver go dead! |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
22 mv.visitInsn(Opcodes.ACONST_NULL); |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
23 mv.visitVarInsn(Opcodes.ASTORE, 0); |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
24 } |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
25 return mv; |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
26 } |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
27 }; |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
28 cr.accept(cw, 0); |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
29 return cw.toByteArray(); |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
30 } |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff
changeset
|
31 } |