hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java
author never
Wed, 22 Jun 2016 22:39:32 +0000
changeset 39441 7464b1552bf7
parent 39423 0f8dc3693499
child 39443 ca6dfb34e46c
permissions -rw-r--r--
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations Reviewed-by: kvn
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
/*
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
35137
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
38027
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
    24
package jdk.vm.ci.code.test.sparc;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    25
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    26
import jdk.vm.ci.code.CodeCacheProvider;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    27
import jdk.vm.ci.code.DebugInfo;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    28
import jdk.vm.ci.code.Register;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    29
import jdk.vm.ci.code.StackSlot;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    30
import jdk.vm.ci.code.site.ConstantReference;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    31
import jdk.vm.ci.code.site.DataSectionReference;
38027
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
    32
import jdk.vm.ci.code.test.TestAssembler;
39423
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 38692
diff changeset
    33
import jdk.vm.ci.code.test.TestHotSpotVMConfig;
35595
4308ac6d1b16 8148101: [JVMCI] Make CallingConvention.Type extensible
never
parents: 35591
diff changeset
    34
import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    35
import jdk.vm.ci.hotspot.HotSpotCompiledCode;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    36
import jdk.vm.ci.hotspot.HotSpotConstant;
35844
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    37
import jdk.vm.ci.hotspot.HotSpotForeignCallTarget;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    38
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
35144
f2381983e98e 8146100: compiler/jvmci/code/SimpleCodeInstallationTest.java JUnit Failure: expected:<12> but was:<109710641>
twisti
parents: 35137
diff changeset
    39
import jdk.vm.ci.meta.JavaKind;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    40
import jdk.vm.ci.meta.VMConstant;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    41
import jdk.vm.ci.sparc.SPARC;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    42
import jdk.vm.ci.sparc.SPARCKind;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    43
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    44
public class SPARCTestAssembler extends TestAssembler {
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
    private static final int MASK13 = (1 << 13) - 1;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    47
39423
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 38692
diff changeset
    48
    public SPARCTestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config) {
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 38692
diff changeset
    49
        super(codeCache, config, 0, 16, SPARCKind.WORD, SPARC.l0, SPARC.l1, SPARC.l2, SPARC.l3, SPARC.l4, SPARC.l5, SPARC.l6, SPARC.l7);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    50
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    51
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    52
    private void emitOp2(Register rd, int op2, int imm22) {
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    53
        assert isSimm(imm22, 22);
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    54
        code.emitInt((0b00 << 30) | (rd.encoding << 25) | (op2 << 22) | imm22);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    55
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    56
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    57
    private void emitOp3(int op, Register rd, int op3, Register rs1, Register rs2) {
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    58
        code.emitInt((op << 30) | (rd.encoding << 25) | (op3 << 19) | (rs1.encoding << 14) | rs2.encoding);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    59
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    60
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    61
    private void emitOp3(int op, Register rd, int op3, Register rs1, int simm13) {
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    62
        assert isSimm(simm13, 13);
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    63
        code.emitInt((op << 30) | (rd.encoding << 25) | (op3 << 19) | (rs1.encoding << 14) | (1 << 13) | (simm13 & MASK13));
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    64
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    65
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    66
    private void emitNop() {
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    67
        code.emitInt(1 << 24);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    68
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    69
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    70
    /**
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    71
     * Minimum value for signed immediate ranges.
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    72
     */
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    73
    public static long minSimm(long nbits) {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    74
        return -(1L << (nbits - 1));
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    75
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    76
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    77
    /**
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    78
     * Maximum value for signed immediate ranges.
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    79
     */
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    80
    public static long maxSimm(long nbits) {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    81
        return (1L << (nbits - 1)) - 1;
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    82
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    83
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    84
    /**
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    85
     * Test if imm is within signed immediate range for nbits.
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    86
     */
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    87
    public static boolean isSimm(long imm, int nbits) {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    88
        return minSimm(nbits) <= imm && imm <= maxSimm(nbits);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    89
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
    90
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
    91
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    92
    public void emitPrologue() {
38027
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
    93
        // SAVE sp, -128, sp
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
    94
        emitOp3(0b10, SPARC.sp, 0b111100, SPARC.sp, -SPARC.REGISTER_SAFE_AREA_SIZE);
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
    95
        setDeoptRescueSlot(newStackSlot(SPARCKind.XWORD));
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    96
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    97
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    98
    @Override
35844
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    99
    public void emitEpilogue() {
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   100
        recordMark(config.MARKID_DEOPT_HANDLER_ENTRY);
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   101
        recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 4, true, null);
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   102
        code.emitInt(1 << 30); // CALL
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   103
    }
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   104
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   105
    @Override
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   106
    public HotSpotCompiledCode finish(HotSpotResolvedJavaMethod method) {
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   107
        frameSize += SPARC.REGISTER_SAFE_AREA_SIZE;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   108
        return super.finish(method);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   109
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   110
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   111
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   112
    public void emitGrowStack(int size) {
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   113
        frameSize += size;
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   114
        if (isSimm(size, 13)) {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   115
            emitOp3(0b10, SPARC.sp, 0b000100, SPARC.sp, size); // SUB sp, size, sp
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   116
        } else {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   117
            Register r = emitLoadInt(size);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   118
            emitOp3(0b10, SPARC.sp, 0b000100, SPARC.sp, r); // SUB sp, size, sp
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   119
        }
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   120
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   121
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   122
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   123
    public Register emitIntArg0() {
35595
4308ac6d1b16 8148101: [JVMCI] Make CallingConvention.Type extensible
never
parents: 35591
diff changeset
   124
        return codeCache.getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCallee, JavaKind.Int)[0];
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   125
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   126
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   127
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   128
    public Register emitIntArg1() {
35595
4308ac6d1b16 8148101: [JVMCI] Make CallingConvention.Type extensible
never
parents: 35591
diff changeset
   129
        return codeCache.getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCallee, JavaKind.Int)[1];
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   130
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   131
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   132
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   133
    public Register emitLoadInt(int c) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   134
        Register ret = newRegister();
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   135
        loadIntToRegister(c, ret);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   136
        return ret;
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   137
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   138
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   139
    private void loadIntToRegister(int c, Register ret) {
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   140
        int hi = c >>> 10;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   141
        int lo = c & ((1 << 10) - 1);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   142
        if (hi == 0) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   143
            emitOp3(0b10, ret, 0b000010, SPARC.g0, lo); // OR g0, lo, ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   144
        } else {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   145
            emitOp2(ret, 0b100, hi);                    // SETHI hi, ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   146
            if (lo != 0) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   147
                emitOp3(0b10, ret, 0b000010, ret, lo);  // OR ret, lo, ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   148
            }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   149
        }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   150
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   151
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   152
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   153
    public Register emitLoadLong(long c) {
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   154
        Register ret = newRegister();
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   155
        emitLoadLongToRegister(c, ret);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   156
        return ret;
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   157
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   158
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   159
    private void loadLongToRegister(long c, Register ret) {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   160
        DataSectionReference ref = new DataSectionReference();
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   161
        data.align(8);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   162
        ref.setOffset(data.position());
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   163
        data.emitLong(c);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   164
        emitLoadPointerToRegister(ref, ret);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   165
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   166
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   167
    public void emitLoadLongToRegister(long c, Register r) {
35591
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   168
        if ((c & 0xFFFF_FFFFL) == c) {
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   169
            loadIntToRegister((int) c, r);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   170
        } else {
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   171
            loadLongToRegister(c, r);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   172
        }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   173
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   174
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   175
    private void emitPatchableSethi(Register ret, boolean wide) {
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   176
        int startPos = code.position();
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   177
        emitOp2(ret, 0b100, 0);              // SETHI 0, ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   178
        if (wide) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   179
            // pad for later patching
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   180
            while (code.position() < (startPos + 28)) {
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   181
                emitNop();
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   182
            }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   183
        }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   184
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   185
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   186
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   187
    public Register emitLoadFloat(float c) {
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   188
        DataSectionReference ref = new DataSectionReference();
35591
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   189
        data.align(4);
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   190
        ref.setOffset(data.position());
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   191
        data.emitFloat(c);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   192
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   193
        Register ptr = newRegister();
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   194
        recordDataPatchInCode(ref);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   195
        emitPatchableSethi(ptr, true);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   196
        emitOp3(0b11, SPARC.f0, 0b100000, ptr, 0); // LDF [ptr+0], f0
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   197
        return SPARC.f0;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   198
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   199
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   200
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   201
    public Register emitLoadPointer(HotSpotConstant c) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   202
        Register ret = newRegister();
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   203
        recordDataPatchInCode(new ConstantReference((VMConstant) c));
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   204
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   205
        emitPatchableSethi(ret, !c.isCompressed());
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   206
        emitOp3(0b10, ret, 0b000010, ret, 0); // OR ret, 0, ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   207
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   208
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   209
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   210
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   211
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   212
    public Register emitLoadPointer(DataSectionReference ref) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   213
        Register ret = newRegister();
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   214
        emitLoadPointerToRegister(ref, ret);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   215
        return ret;
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   216
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   217
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   218
    private void emitLoadPointerToRegister(DataSectionReference ref, Register ret) {
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   219
        recordDataPatchInCode(ref);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   220
        emitPatchableSethi(ret, true);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   221
        emitOp3(0b11, ret, 0b001011, ret, 0); // LDX [ret+0], ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   222
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   223
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   224
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   225
    public Register emitLoadNarrowPointer(DataSectionReference ref) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   226
        Register ret = newRegister();
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   227
        recordDataPatchInCode(ref);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   228
        emitPatchableSethi(ret, true);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   229
        emitOp3(0b11, ret, 0b000000, ret, 0); // LDUW [ret+0], ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   230
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   231
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   232
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   233
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   234
    public Register emitLoadPointer(Register b, int offset) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   235
        Register ret = newRegister();
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   236
        emitOp3(0b11, ret, 0b001011, b, offset); // LDX [b+offset], ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   237
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   238
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   239
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   240
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   241
    public StackSlot emitIntToStack(Register a) {
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   242
        StackSlot ret = newStackSlot(SPARCKind.WORD);
38027
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
   243
        // STW a, [fp+offset]
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   244
        emitStore(0b000100, a, ret);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   245
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   246
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   247
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   248
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   249
    public StackSlot emitLongToStack(Register a) {
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   250
        StackSlot ret = newStackSlot(SPARCKind.XWORD);
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   251
        // STX a, [sp+offset]
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   252
        emitStore(0b001110, a, ret);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   253
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   254
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   255
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   256
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   257
    public StackSlot emitFloatToStack(Register a) {
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   258
        StackSlot ret = newStackSlot(SPARCKind.SINGLE);
38027
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
   259
        // STF a, [fp+offset]
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   260
        emitStore(0b100100, a, ret);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   261
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   262
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   263
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   264
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   265
    public StackSlot emitPointerToStack(Register a) {
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   266
        StackSlot ret = newStackSlot(SPARCKind.XWORD);
38027
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
   267
        // STX a, [fp+offset]
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   268
        emitStore(0b001110, a, ret);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   269
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   270
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   271
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   272
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   273
    public StackSlot emitNarrowPointerToStack(Register a) {
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   274
        StackSlot ret = newStackSlot(SPARCKind.WORD);
38027
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
   275
        // STW a, [fp+offset]
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   276
        emitStore(0b000100, a, ret);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   277
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   278
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   279
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   280
    private void emitStore(int op3, Register a, StackSlot ret) {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   281
        int offset = ret.getRawOffset() + SPARC.STACK_BIAS;
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   282
        if (isSimm(offset, 13)) {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   283
            // op3 a, [sp+offset]
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   284
            emitOp3(0b11, a, op3, SPARC.fp, offset);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   285
        } else {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   286
            assert a != SPARC.g3;
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   287
            Register r = SPARC.g3;
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   288
            loadLongToRegister(offset, r);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   289
            // op3 a, [sp+g3]
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   290
            emitOp3(0b11, a, op3, SPARC.fp, r);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   291
        }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   292
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   293
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   294
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   295
    public Register emitUncompressPointer(Register compressed, long base, int shift) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   296
        Register ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   297
        if (shift > 0) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   298
            ret = newRegister();
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   299
            emitOp3(0b10, ret, 0b100101, compressed, shift); // SLL compressed, shift, ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   300
        } else {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   301
            ret = compressed;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   302
        }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   303
        if (base == 0) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   304
            return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   305
        } else {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   306
            Register b = emitLoadLong(base);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   307
            emitOp3(0b10, b, 0b00000, ret, b); // ADD b, ret, b
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   308
            return b;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   309
        }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   310
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   311
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   312
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   313
    public Register emitIntAdd(Register a, Register b) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   314
        Register ret = newRegister();
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   315
        emitOp3(0b10, ret, 0b00000, a, b); // ADD a, b, ret
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   316
        return ret;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   317
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   318
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   319
    private void emitMove(Register to, Register from) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   320
        if (to != from) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   321
            emitOp3(0b10, to, 0b000010, from, SPARC.g0); // OR from, g0, to
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   322
        }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   323
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   324
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   325
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   326
    public void emitIntRet(Register a) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   327
        emitPointerRet(a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   328
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   329
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   330
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   331
    public void emitPointerRet(Register a) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   332
        emitMove(SPARC.i0, a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   333
        emitOp3(0b10, SPARC.g0, 0b111000, SPARC.i7, 8);        // JMPL [i7+8], g0
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   334
        emitOp3(0b10, SPARC.g0, 0b111101, SPARC.g0, SPARC.g0); // RESTORE g0, g0, g0
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   335
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   336
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   337
    @Override
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   338
    public void emitTrap(DebugInfo info) {
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35144
diff changeset
   339
        recordImplicitException(info);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   340
        emitOp3(0b11, SPARC.g0, 0b001011, SPARC.g0, 0); // LDX [g0+0], g0
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   341
    }
35591
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   342
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   343
    @Override
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   344
    public DataSectionReference emitDataItem(HotSpotConstant c) {
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   345
        if (c.isCompressed()) {
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   346
            data.align(4);
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   347
        } else {
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   348
            data.align(8);
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   349
        }
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   350
        return super.emitDataItem(c);
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   351
    }
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   352
}