Mercurial > hg > truffle
annotate src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp @ 13806:0a20f43a4a78
Merge fixes.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 28 Jan 2014 13:36:16 +0100 |
parents | 4e679d50ba9a |
children | e14198669e5c |
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) { |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
45 oop inlineData = CompilationResult_DataPatch::inlineData(site); |
10684 | 46 address pc = _instructions->start() + pc_offset; |
47 | |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
48 if (inlineData != NULL) { |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
49 oop kind = Constant::kind(inlineData); |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
50 char typeChar = Kind::typeChar(kind); |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
51 |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
52 switch (typeChar) { |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
53 case 'z': |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
54 case 'b': |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
55 case 's': |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
56 case 'c': |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
57 case 'i': |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
58 fatal("int-sized values not expected in DataPatch"); |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
59 break; |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
60 case 'f': |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
61 case 'j': |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
62 case 'd': { |
10792 | 63 NativeMovConstReg* move = nativeMovConstReg_at(pc); |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
64 uint64_t value = Constant::primitive(inlineData); |
10792 | 65 move->set_data(value); |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
66 break; |
10684 | 67 } |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
68 case 'a': { |
11233 | 69 NativeMovConstReg* move = nativeMovConstReg_at(pc); |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
70 Handle obj = Constant::object(inlineData); |
11233 | 71 jobject value = JNIHandles::make_local(obj()); |
72 move->set_data((intptr_t) value); | |
73 | |
74 // We need two relocations: one on the sethi and one on the add. | |
75 int oop_index = _oop_recorder->find_index(value); | |
76 RelocationHolder rspec = oop_Relocation::spec(oop_index); | |
77 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); | |
78 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); | |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
79 break; |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
80 } |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
81 default: |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
82 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar)); |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
83 break; |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
84 } |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
85 } else { |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
86 oop dataRef = CompilationResult_DataPatch::externalData(site); |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
87 jint offset = HotSpotCompiledCode_HotSpotData::offset(dataRef); |
11233 | 88 |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
89 NativeMovRegMem* load = nativeMovRegMem_at(pc); |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
90 int disp = _constants_size + pc_offset - offset - BytesPerInstWord; |
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
91 load->set_offset(-disp); |
10684 | 92 } |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
93 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
94 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
95 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
|
96 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
|
97 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
98 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
99 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
|
100 address pc = (address) inst; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
101 if (inst->is_call()) { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
102 NativeCall* call = nativeCall_at(pc); |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
103 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
|
104 _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
|
105 } else if (inst->is_sethi()) { |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
106 NativeJump* jump = nativeJump_at(pc); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
107 jump->set_jump_destination((address) foreign_call_destination); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
108 _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
|
109 } else { |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
110 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
|
111 } |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
112 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
|
113 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
114 |
10684 | 115 inline void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { |
116 #ifdef ASSERT | |
117 Method* method = NULL; | |
118 // we need to check, this might also be an unresolved method | |
119 if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) { | |
120 method = getMethodFromHotSpotMethod(hotspot_method); | |
121 } | |
122 #endif | |
123 switch (_next_call_type) { | |
124 case MARK_INLINE_INVOKE: | |
125 break; | |
126 case MARK_INVOKEVIRTUAL: | |
127 case MARK_INVOKEINTERFACE: { | |
128 assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); | |
129 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
130 call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); | |
10792 | 131 _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); |
10684 | 132 break; |
133 } | |
134 case MARK_INVOKESTATIC: { | |
135 assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); | |
136 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
137 call->set_destination(SharedRuntime::get_resolve_static_call_stub()); | |
10792 | 138 _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); |
10684 | 139 break; |
140 } | |
141 case MARK_INVOKESPECIAL: { | |
142 assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); | |
143 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
144 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
|
145 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); |
10684 | 146 break; |
147 } | |
148 default: | |
149 fatal("invalid _next_call_type value"); | |
150 break; | |
151 } | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
152 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
153 |
11799 | 154 inline void CodeInstaller::pd_relocate_poll(address pc, jint mark) { |
155 switch (mark) { | |
156 case MARK_POLL_NEAR: { | |
157 fatal("unimplemented"); | |
158 } | |
159 case MARK_POLL_FAR: | |
13553
d49f00604347
removed poll_Relocation::pollingForm type and associated data field and rely solely on format field of safepoint relocation entries when deciding whether or not to relocate the operand of a safepoint poll instruction
Doug Simon <doug.simon@oracle.com>
parents:
13515
diff
changeset
|
160 _instructions->relocate(pc, relocInfo::poll_type); |
11799 | 161 break; |
162 case MARK_POLL_RETURN_NEAR: { | |
163 fatal("unimplemented"); | |
164 } | |
165 case MARK_POLL_RETURN_FAR: | |
13553
d49f00604347
removed poll_Relocation::pollingForm type and associated data field and rely solely on format field of safepoint relocation entries when deciding whether or not to relocate the operand of a safepoint poll instruction
Doug Simon <doug.simon@oracle.com>
parents:
13515
diff
changeset
|
166 _instructions->relocate(pc, relocInfo::poll_return_type); |
11799 | 167 break; |
168 default: | |
169 fatal("invalid mark value"); | |
170 break; | |
171 } | |
172 } | |
173 | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
174 #endif // CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP |