hotspot/test/compiler/jvmci/code/DebugInfoTest.java
author rschatz
Tue, 15 Dec 2015 16:55:24 +0100
changeset 35137 c8f8f6de68a7
permissions -rw-r--r--
8144704: [JVMCI] add tests for simple code installation Reviewed-by: twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     1
/*
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     4
 *
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     8
 *
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    13
 * accompanied this code).
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    14
 *
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    18
 *
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    21
 * questions.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    22
 */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    23
package compiler.jvmci.code;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    24
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    25
import java.lang.reflect.Method;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    26
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    27
import jdk.vm.ci.code.BytecodeFrame;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    28
import jdk.vm.ci.code.DebugInfo;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    29
import jdk.vm.ci.code.Location;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    30
import jdk.vm.ci.code.VirtualObject;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    31
import jdk.vm.ci.hotspot.HotSpotReferenceMap;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    32
import jdk.vm.ci.meta.JavaKind;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    33
import jdk.vm.ci.meta.JavaValue;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    34
import jdk.vm.ci.meta.ResolvedJavaMethod;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    35
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    36
/**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    37
 * Test code installation with debug information.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    38
 */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    39
public class DebugInfoTest extends CodeInstallationTest {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    40
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    41
    protected interface DebugInfoCompiler {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    42
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    43
        VirtualObject[] compile(TestAssembler asm, JavaValue[] frameValues);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    44
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    45
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    46
    protected void test(DebugInfoCompiler compiler, Method method, int bci, JavaKind... slotKinds) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    47
        ResolvedJavaMethod resolvedMethod = metaAccess.lookupJavaMethod(method);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    48
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    49
        int numLocals = resolvedMethod.getMaxLocals();
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    50
        int numStack = slotKinds.length - numLocals;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    51
        JavaValue[] values = new JavaValue[slotKinds.length];
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    52
        test(asm -> {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    53
            VirtualObject[] vobjs = compiler.compile(asm, values);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    54
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    55
            BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, bci, false, false, values, slotKinds, numLocals, numStack, 0);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    56
            DebugInfo info = new DebugInfo(frame, vobjs);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    57
            info.setReferenceMap(new HotSpotReferenceMap(new Location[0], new Location[0], new int[0], 8));
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    58
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    59
            asm.emitTrap(info);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    60
        }, method);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    61
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    62
}