author | twisti |
Wed, 23 Dec 2015 11:36:46 -1000 | |
changeset 35144 | f2381983e98e |
parent 35137 | c8f8f6de68a7 |
child 35582 | c32a0cc19877 |
permissions | -rw-r--r-- |
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 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
24 |
package compiler.jvmci.code.sparc; |
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.CompilationResult; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
28 |
import jdk.vm.ci.code.CompilationResult.ConstantReference; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
29 |
import jdk.vm.ci.code.CompilationResult.DataSectionReference; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
30 |
import jdk.vm.ci.code.DataSection.Data; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
31 |
import jdk.vm.ci.code.DebugInfo; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
32 |
import jdk.vm.ci.code.InfopointReason; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
33 |
import jdk.vm.ci.code.Register; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
34 |
import jdk.vm.ci.code.StackSlot; |
35144
f2381983e98e
8146100: compiler/jvmci/code/SimpleCodeInstallationTest.java JUnit Failure: expected:<12> but was:<109710641>
twisti
parents:
35137
diff
changeset
|
35 |
import jdk.vm.ci.code.CallingConvention.Type; |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
36 |
import jdk.vm.ci.hotspot.HotSpotConstant; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
37 |
import jdk.vm.ci.meta.JavaConstant; |
35144
f2381983e98e
8146100: compiler/jvmci/code/SimpleCodeInstallationTest.java JUnit Failure: expected:<12> but was:<109710641>
twisti
parents:
35137
diff
changeset
|
38 |
import jdk.vm.ci.meta.JavaKind; |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
39 |
import jdk.vm.ci.meta.LIRKind; |
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 |
import compiler.jvmci.code.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 |
public class SPARCTestAssembler extends TestAssembler { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
47 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
48 |
private static final int MASK13 = (1 << 13) - 1; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
49 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
50 |
public SPARCTestAssembler(CompilationResult result, CodeCacheProvider codeCache) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
51 |
super(result, codeCache, 0, 16, SPARCKind.WORD, SPARC.l0, SPARC.l1, SPARC.l2, SPARC.l3, SPARC.l4, SPARC.l5, SPARC.l6, SPARC.l7); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
52 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
53 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
54 |
private void emitOp2(Register rd, int op2, int imm22) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
55 |
emitInt((0b00 << 30) | (rd.encoding << 25) | (op2 << 22) | imm22); |
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 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
58 |
private void emitOp3(int op, Register rd, int op3, Register rs1, Register rs2) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
59 |
emitInt((op << 30) | (rd.encoding << 25) | (op3 << 19) | (rs1.encoding << 14) | rs2.encoding); |
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 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
62 |
private void emitOp3(int op, Register rd, int op3, Register rs1, int simm13) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
63 |
emitInt((op << 30) | (rd.encoding << 25) | (op3 << 19) | (rs1.encoding << 14) | (1 << 13) | (simm13 & MASK13)); |
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() { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
67 |
emitInt(1 << 24); |
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 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
70 |
public void emitPrologue() { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
71 |
emitOp3(0b10, SPARC.sp, 0b111100, SPARC.sp, -SPARC.REGISTER_SAFE_AREA_SIZE); // SAVE sp, -128, sp |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
72 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
73 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
74 |
@Override |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
75 |
public void finish() { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
76 |
frameSize += SPARC.REGISTER_SAFE_AREA_SIZE; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
77 |
super.finish(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
78 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
79 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
80 |
public void emitGrowStack(int size) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
81 |
emitOp3(0b10, SPARC.sp, 0b000100, SPARC.sp, size); // SUB sp, size, sp |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
82 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
83 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
84 |
public Register emitIntArg0() { |
35144
f2381983e98e
8146100: compiler/jvmci/code/SimpleCodeInstallationTest.java JUnit Failure: expected:<12> but was:<109710641>
twisti
parents:
35137
diff
changeset
|
85 |
return codeCache.getRegisterConfig().getCallingConventionRegisters(Type.JavaCallee, JavaKind.Int)[0]; |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
86 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
87 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
88 |
public Register emitIntArg1() { |
35144
f2381983e98e
8146100: compiler/jvmci/code/SimpleCodeInstallationTest.java JUnit Failure: expected:<12> but was:<109710641>
twisti
parents:
35137
diff
changeset
|
89 |
return codeCache.getRegisterConfig().getCallingConventionRegisters(Type.JavaCallee, JavaKind.Int)[1]; |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
90 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
91 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
92 |
public Register emitLoadInt(int c) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
93 |
Register ret = newRegister(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
94 |
int hi = c >>> 10; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
95 |
int lo = c & ((1 << 10) - 1); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
96 |
if (hi == 0) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
97 |
emitOp3(0b10, ret, 0b000010, SPARC.g0, lo); // OR g0, lo, ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
98 |
} else { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
99 |
emitOp2(ret, 0b100, hi); // SETHI hi, ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
100 |
if (lo != 0) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
101 |
emitOp3(0b10, ret, 0b000010, ret, lo); // OR ret, lo, ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
102 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
103 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
104 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
105 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
106 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
107 |
public Register emitLoadLong(long c) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
108 |
if ((c & 0xFFFFFFFF) == c) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
109 |
return emitLoadInt((int) c); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
110 |
} else { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
111 |
Data data = codeCache.createDataItem(JavaConstant.forLong(c)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
112 |
DataSectionReference ref = result.getDataSection().insertData(data); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
113 |
return emitLoadPointer(ref); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
114 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
115 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
116 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
117 |
private void emitPatchableSethi(Register ret, boolean wide) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
118 |
int startPos = position(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
119 |
emitOp2(ret, 0b100, 0); // SETHI 0, ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
120 |
if (wide) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
121 |
// pad for later patching |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
122 |
while (position() < (startPos + 28)) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
123 |
emitNop(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
124 |
} |
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 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
127 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
128 |
public Register emitLoadFloat(float c) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
129 |
Data data = codeCache.createDataItem(JavaConstant.forFloat(c)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
130 |
DataSectionReference ref = result.getDataSection().insertData(data); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
131 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
132 |
Register ptr = newRegister(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
133 |
result.recordDataPatch(position(), ref); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
134 |
emitPatchableSethi(ptr, true); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
135 |
emitOp3(0b11, SPARC.f0, 0b100000, ptr, 0); // LDF [ptr+0], f0 |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
136 |
return SPARC.f0; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
137 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
138 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
139 |
public Register emitLoadPointer(HotSpotConstant c) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
140 |
Register ret = newRegister(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
141 |
result.recordDataPatch(position(), new ConstantReference((VMConstant) c)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
142 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
143 |
emitPatchableSethi(ret, !c.isCompressed()); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
144 |
emitOp3(0b10, ret, 0b000010, ret, 0); // OR ret, 0, ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
145 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
146 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
147 |
} |
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 |
public Register emitLoadPointer(DataSectionReference ref) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
150 |
Register ret = newRegister(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
151 |
result.recordDataPatch(position(), ref); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
152 |
emitPatchableSethi(ret, true); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
153 |
emitOp3(0b11, ret, 0b001011, ret, 0); // LDX [ret+0], ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
154 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
155 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
156 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
157 |
public Register emitLoadNarrowPointer(DataSectionReference ref) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
158 |
Register ret = newRegister(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
159 |
result.recordDataPatch(position(), ref); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
160 |
emitPatchableSethi(ret, true); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
161 |
emitOp3(0b11, ret, 0b000000, ret, 0); // LDUW [ret+0], ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
162 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
163 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
164 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
165 |
public Register emitLoadPointer(Register b, int offset) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
166 |
Register ret = newRegister(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
167 |
emitOp3(0b11, ret, 0b001011, b, offset); // LDX [b+offset], ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
168 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
169 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
170 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
171 |
public StackSlot emitIntToStack(Register a) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
172 |
StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.WORD)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
173 |
emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STW a, [fp+offset] |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
174 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
175 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
176 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
177 |
public StackSlot emitLongToStack(Register a) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
178 |
StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.XWORD)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
179 |
emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STX a, [fp+offset] |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
180 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
181 |
} |
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 |
public StackSlot emitFloatToStack(Register a) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
184 |
StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.SINGLE)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
185 |
emitOp3(0b11, a, 0b100100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STF a, [fp+offset] |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
186 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
187 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
188 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
189 |
public StackSlot emitPointerToStack(Register a) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
190 |
StackSlot ret = newStackSlot(LIRKind.reference(SPARCKind.XWORD)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
191 |
emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STX a, [fp+offset] |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
192 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
193 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
194 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
195 |
public StackSlot emitNarrowPointerToStack(Register a) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
196 |
StackSlot ret = newStackSlot(LIRKind.reference(SPARCKind.WORD)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
197 |
emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STW a, [fp+offset] |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
198 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
199 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
200 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
201 |
public Register emitUncompressPointer(Register compressed, long base, int shift) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
202 |
Register ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
203 |
if (shift > 0) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
204 |
ret = newRegister(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
205 |
emitOp3(0b10, ret, 0b100101, compressed, shift); // SLL compressed, shift, ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
206 |
} else { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
207 |
ret = compressed; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
208 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
209 |
if (base == 0) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
210 |
return ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
211 |
} else { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
212 |
Register b = emitLoadLong(base); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
213 |
emitOp3(0b10, b, 0b00000, ret, b); // ADD b, ret, b |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
214 |
return b; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
215 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
216 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
217 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
218 |
public Register emitIntAdd(Register a, Register b) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
219 |
Register ret = newRegister(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
220 |
emitOp3(0b10, ret, 0b00000, a, b); // ADD a, b, ret |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
221 |
return 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 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
224 |
private void emitMove(Register to, Register from) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
225 |
if (to != from) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
226 |
emitOp3(0b10, to, 0b000010, from, SPARC.g0); // OR from, g0, to |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
227 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
228 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
229 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
230 |
public void emitIntRet(Register a) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
231 |
emitPointerRet(a); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
232 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
233 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
234 |
public void emitPointerRet(Register a) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
235 |
emitMove(SPARC.i0, a); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
236 |
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
|
237 |
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
|
238 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
239 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
240 |
public void emitTrap(DebugInfo info) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
241 |
result.recordInfopoint(position(), info, InfopointReason.IMPLICIT_EXCEPTION); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
242 |
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
|
243 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
244 |
} |