hotspot/test/runtime/MirrorFrame/Asmator.java
author coleenp
Mon, 25 Apr 2016 09:51:00 -0400
changeset 38074 8475fdc6dcc3
parent 14589 hotspot/test/runtime/8003720/Asmator.java@a6649fc2f41d
child 41705 332239c052cc
permissions -rw-r--r--
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure Summary: GC walks the mirror using OopClosure rather than using CLDClosure in oops_interpreted_do() Reviewed-by: dlong, twisti, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14589
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     1
/*
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     4
 *
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     7
 * published by the Free Software Foundation.
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     8
 *
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    13
 * accompanied this code).
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    14
 *
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    18
 *
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    21
 * questions.
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    22
 *
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    23
 */
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    24
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    25
import jdk.internal.org.objectweb.asm.*;
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    26
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    27
class Asmator {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    28
    static byte[] fixup(byte[] buf) throws java.io.IOException {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    29
        ClassReader cr = new ClassReader(buf);
14589
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    30
        ClassWriter cw = new ClassWriter(0);
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    31
        ClassVisitor cv = new ClassVisitor(Opcodes.ASM4, cw) {
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    32
            public MethodVisitor visitMethod(
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    33
                final int access,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    34
                final String name,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    35
                final String desc,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    36
                final String signature,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    37
                final String[] exceptions)
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    38
            {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    39
                MethodVisitor mv = super.visitMethod(access,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    40
                        name,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    41
                        desc,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    42
                        signature,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    43
                        exceptions);
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    44
                if (mv == null)  return null;
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    45
                if (name.equals("callme")) {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    46
                    // make receiver go dead!
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    47
                    mv.visitInsn(Opcodes.ACONST_NULL);
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    48
                    mv.visitVarInsn(Opcodes.ASTORE, 0);
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    49
                }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    50
                return mv;
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    51
            }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    52
        };
14589
a6649fc2f41d 8004199: Change the ASM package for Test8003720
stefank
parents: 14582
diff changeset
    53
        cr.accept(cv, 0);
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    54
        return cw.toByteArray();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    55
    }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    56
}