Mercurial > hg > truffle
annotate src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp @ 11537:7ce08e264abf
Fixed registers that flow into a block need to be inputs of the LabelOp, otherwise the register allocator can insert spill moves before the definition of a fixed register.
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 05 Sep 2013 16:36:13 -0700 |
parents | 5a9d68c3a7d7 |
children | ce0b00597980 |
rev | line source |
---|---|
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
1 /* |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
4 * |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
8 * |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
14 * |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
18 * |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
22 */ |
10684 | 23 |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
24 #ifndef CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
25 #define CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
26 |
10684 | 27 #include "graal/graalCompiler.hpp" |
28 #include "graal/graalCompilerToVM.hpp" | |
29 #include "graal/graalJavaAccess.hpp" | |
30 | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
31 inline jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
32 if (inst->is_call() || inst->is_jump()) { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
33 return pc_offset + NativeCall::instruction_size; |
11233 | 34 } else if (inst->is_call_reg()) { |
35 return pc_offset + NativeCallReg::instruction_size; | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
36 } else if (inst->is_sethi()) { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
37 return pc_offset + NativeFarCall::instruction_size; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
38 } else { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
39 fatal("unsupported type of instruction for call site"); |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
40 return 0; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
41 } |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
42 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
43 |
10684 | 44 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) { |
45 oop constant = CompilationResult_DataPatch::constant(site); | |
46 int alignment = CompilationResult_DataPatch::alignment(site); | |
47 bool inlined = CompilationResult_DataPatch::inlined(site) == JNI_TRUE; | |
48 | |
49 oop kind = Constant::kind(constant); | |
50 char typeChar = Kind::typeChar(kind); | |
51 | |
52 address pc = _instructions->start() + pc_offset; | |
53 | |
54 switch (typeChar) { | |
55 case 'z': | |
56 case 'b': | |
57 case 's': | |
58 case 'c': | |
59 case 'i': | |
60 fatal("int-sized values not expected in DataPatch"); | |
61 break; | |
62 case 'f': | |
63 case 'j': | |
64 case 'd': { | |
65 if (inlined) { | |
10792 | 66 NativeMovConstReg* move = nativeMovConstReg_at(pc); |
67 uint64_t value = Constant::primitive(constant); | |
68 move->set_data(value); | |
10684 | 69 } else { |
70 int size = _constants->size(); | |
71 if (alignment > 0) { | |
72 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); | |
73 size = align_size_up(size, alignment); | |
74 } | |
75 // we don't care if this is a long/double/etc., the primitive field contains the right bits | |
76 address dest = _constants->start() + size; | |
77 _constants->set_end(dest); | |
78 uint64_t value = Constant::primitive(constant); | |
79 _constants->emit_int64(value); | |
80 | |
81 NativeMovRegMem* load = nativeMovRegMem_at(pc); | |
82 int disp = _constants_size + pc_offset - size - BytesPerInstWord; | |
83 load->set_offset(-disp); | |
84 } | |
85 break; | |
86 } | |
87 case 'a': { | |
11233 | 88 if (inlined) { |
89 NativeMovConstReg* move = nativeMovConstReg_at(pc); | |
90 Handle obj = Constant::object(constant); | |
91 jobject value = JNIHandles::make_local(obj()); | |
92 move->set_data((intptr_t) value); | |
93 | |
94 // We need two relocations: one on the sethi and one on the add. | |
95 int oop_index = _oop_recorder->find_index(value); | |
96 RelocationHolder rspec = oop_Relocation::spec(oop_index); | |
97 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); | |
98 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); | |
99 } else { | |
100 int size = _constants->size(); | |
101 if (alignment > 0) { | |
102 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); | |
103 size = align_size_up(size, alignment); | |
104 } | |
105 address dest = _constants->start() + size; | |
106 _constants->set_end(dest); | |
107 Handle obj = Constant::object(constant); | |
108 jobject value = JNIHandles::make_local(obj()); | |
109 _constants->emit_address((address) value); | |
110 | |
111 NativeMovRegMem* load = nativeMovRegMem_at(pc); | |
112 int disp = _constants_size + pc_offset - size - BytesPerInstWord; | |
113 load->set_offset(-disp); | |
114 | |
115 int oop_index = _oop_recorder->find_index(value); | |
116 _constants->relocate(dest, oop_Relocation::spec(oop_index)); | |
10792 | 117 } |
10684 | 118 break; |
119 } | |
120 default: | |
121 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar)); | |
122 break; | |
123 } | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
124 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
125 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
126 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
127 fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
128 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
129 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
130 inline void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
131 address pc = (address) inst; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
132 if (inst->is_call()) { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
133 NativeCall* call = nativeCall_at(pc); |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
134 call->set_destination((address) foreign_call_destination); |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
135 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec()); |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
136 } else if (inst->is_sethi()) { |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
137 NativeJump* jump = nativeJump_at(pc); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
138 jump->set_jump_destination((address) foreign_call_destination); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
139 _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
140 } else { |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
141 fatal(err_msg("unknown call or jump instruction at %p", pc)); |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
142 } |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
143 TRACE_graal_3("relocating (foreign call) at %p", inst); |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
144 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
145 |
10684 | 146 inline void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { |
147 #ifdef ASSERT | |
148 Method* method = NULL; | |
149 // we need to check, this might also be an unresolved method | |
150 if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) { | |
151 method = getMethodFromHotSpotMethod(hotspot_method); | |
152 } | |
153 #endif | |
154 switch (_next_call_type) { | |
155 case MARK_INLINE_INVOKE: | |
156 break; | |
157 case MARK_INVOKEVIRTUAL: | |
158 case MARK_INVOKEINTERFACE: { | |
159 assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); | |
160 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
161 call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); | |
10792 | 162 _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); |
10684 | 163 break; |
164 } | |
165 case MARK_INVOKESTATIC: { | |
166 assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); | |
167 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
168 call->set_destination(SharedRuntime::get_resolve_static_call_stub()); | |
10792 | 169 _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); |
10684 | 170 break; |
171 } | |
172 case MARK_INVOKESPECIAL: { | |
173 assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); | |
174 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
175 call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
176 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); |
10684 | 177 break; |
178 } | |
179 default: | |
180 fatal("invalid _next_call_type value"); | |
181 break; | |
182 } | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
183 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
184 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
185 inline int32_t* CodeInstaller::pd_locate_operand(address instruction) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
186 fatal("CodeInstaller::pd_locate_operand - sparc unimp"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
187 return (int32_t*)0; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
188 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
189 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
190 #endif // CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP |