author | rschatz |
Tue, 15 Dec 2015 16:55:24 +0100 | |
changeset 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; |
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 java.nio.ByteBuffer; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
27 |
import java.nio.ByteOrder; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
28 |
import java.util.Arrays; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
29 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
30 |
import jdk.vm.ci.code.CodeCacheProvider; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
31 |
import jdk.vm.ci.code.CompilationResult; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
32 |
import jdk.vm.ci.code.CompilationResult.DataSectionReference; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
33 |
import jdk.vm.ci.code.DebugInfo; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
34 |
import jdk.vm.ci.code.Register; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
35 |
import jdk.vm.ci.code.StackSlot; |
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.LIRKind; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
38 |
import jdk.vm.ci.meta.PlatformKind; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
39 |
|
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 |
* Simple assembler used by the code installation tests. |
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 |
public abstract class TestAssembler { |
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 |
* Emit the method prologue code (e.g. building the new stack frame). |
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 |
public abstract void emitPrologue(); |
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 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
51 |
* Emit code to grow the stack frame. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
52 |
* @param size the size in bytes that the stack should grow |
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 |
public abstract void emitGrowStack(int size); |
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 |
* Get the register containing the first 32-bit integer argument. |
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 |
public abstract Register emitIntArg0(); |
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 |
* Get the register containing the second 32-bit integer argument. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
63 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
64 |
public abstract Register emitIntArg1(); |
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 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
67 |
* Emit code to add two 32-bit integer registers. May reuse one of the argument registers. |
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 |
public abstract Register emitIntAdd(Register a, Register b); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
70 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
71 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
72 |
* Emit code to load a constant 32-bit integer to a register. |
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 |
public abstract Register emitLoadInt(int value); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
75 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
76 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
77 |
* Emit code to load a constant 64-bit integer to a register. |
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 |
public abstract Register emitLoadLong(long value); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
80 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
81 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
82 |
* Emit code to load a constant single-precision float to a register. |
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 abstract Register emitLoadFloat(float value); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
85 |
|
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 |
* Emit code to load a constant oop or metaspace pointer to a register. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
88 |
* The pointer may be wide or narrow, depending on {@link HotSpotConstant#isCompressed() c.isCompressed()}. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
89 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
90 |
public abstract Register emitLoadPointer(HotSpotConstant c); |
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 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
93 |
* Emit code to load a wide pointer from the {@link DataSection} to a register. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
94 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
95 |
public abstract Register emitLoadPointer(DataSectionReference ref); |
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 |
* Emit code to load a narrow pointer from the {@link DataSection} to a register. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
99 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
100 |
public abstract Register emitLoadNarrowPointer(DataSectionReference ref); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
101 |
|
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 |
* Emit code to load a (wide) pointer from a memory location to a register. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
104 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
105 |
public abstract Register emitLoadPointer(Register base, int offset); |
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 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
108 |
* Emit code to store a 32-bit integer from a register to a new stack slot. |
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 |
public abstract StackSlot emitIntToStack(Register a); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
111 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
112 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
113 |
* Emit code to store a 64-bit integer from a register to a new stack slot. |
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 |
public abstract StackSlot emitLongToStack(Register a); |
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 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
118 |
* Emit code to store a single-precision float from a register to a new stack slot. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
119 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
120 |
public abstract StackSlot emitFloatToStack(Register a); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
121 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
122 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
123 |
* Emit code to store a wide pointer from a register to a new stack slot. |
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 |
public abstract StackSlot emitPointerToStack(Register a); |
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 |
* Emit code to store a narrow pointer from a register to a new stack slot. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
129 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
130 |
public abstract StackSlot emitNarrowPointerToStack(Register a); |
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 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
133 |
* Emit code to uncompress a narrow pointer. The input pointer is guaranteed to be non-null. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
134 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
135 |
public abstract Register emitUncompressPointer(Register compressed, long base, int shift); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
136 |
|
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 |
* Emit code to return from a function, returning a 32-bit integer. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
139 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
140 |
public abstract void emitIntRet(Register a); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
141 |
|
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 |
* Emit code to return from a function, returning a wide oop pointer. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
144 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
145 |
public abstract void emitPointerRet(Register a); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
146 |
|
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 |
* Emit code that traps, forcing a deoptimization. |
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 |
public abstract void emitTrap(DebugInfo info); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
151 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
152 |
protected int position() { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
153 |
return data.position(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
154 |
} |
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 |
public final CompilationResult result; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
157 |
public final LIRKind narrowOopKind; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
158 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
159 |
private ByteBuffer data; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
160 |
protected final CodeCacheProvider codeCache; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
161 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
162 |
private final Register[] registers; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
163 |
private int nextRegister; |
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 |
protected int frameSize; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
166 |
private int stackAlignment; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
167 |
private int curStackSlot; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
168 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
169 |
protected TestAssembler(CompilationResult result, CodeCacheProvider codeCache, int initialFrameSize, int stackAlignment, PlatformKind narrowOopKind, Register... registers) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
170 |
this.result = result; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
171 |
this.narrowOopKind = LIRKind.reference(narrowOopKind); |
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 |
this.data = ByteBuffer.allocate(32).order(ByteOrder.nativeOrder()); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
174 |
this.codeCache = codeCache; |
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 |
this.registers = registers; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
177 |
this.nextRegister = 0; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
178 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
179 |
this.frameSize = initialFrameSize; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
180 |
this.stackAlignment = stackAlignment; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
181 |
this.curStackSlot = initialFrameSize; |
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 |
protected Register newRegister() { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
185 |
return registers[nextRegister++]; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
186 |
} |
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 |
protected StackSlot newStackSlot(LIRKind kind) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
189 |
curStackSlot += kind.getPlatformKind().getSizeInBytes(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
190 |
if (curStackSlot > frameSize) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
191 |
int newFrameSize = curStackSlot; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
192 |
if (newFrameSize % stackAlignment != 0) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
193 |
newFrameSize += stackAlignment - (newFrameSize % stackAlignment); |
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 |
emitGrowStack(newFrameSize - frameSize); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
196 |
frameSize = newFrameSize; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
197 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
198 |
return StackSlot.get(kind, -curStackSlot, true); |
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 void finish() { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
202 |
result.setTotalFrameSize(frameSize); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
203 |
result.setTargetCode(data.array(), data.position()); |
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 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
206 |
private void ensureSize(int length) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
207 |
if (length >= data.limit()) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
208 |
byte[] newBuf = Arrays.copyOf(data.array(), length * 4); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
209 |
ByteBuffer newData = ByteBuffer.wrap(newBuf); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
210 |
newData.order(data.order()); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
211 |
newData.position(data.position()); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
212 |
data = newData; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
213 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
214 |
} |
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 |
protected void emitByte(int b) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
217 |
ensureSize(data.position() + 1); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
218 |
data.put((byte) (b & 0xFF)); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
219 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
220 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
221 |
protected void emitShort(int b) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
222 |
ensureSize(data.position() + 2); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
223 |
data.putShort((short) b); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
224 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
225 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
226 |
protected void emitInt(int b) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
227 |
ensureSize(data.position() + 4); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
228 |
data.putInt(b); |
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 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
231 |
protected void emitLong(long b) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
232 |
ensureSize(data.position() + 8); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
233 |
data.putLong(b); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
234 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
235 |
} |