Mercurial > hg > truffle
annotate src/cpu/sparc/vm/graalCodeInstaller_sparc.cpp @ 16348:fefb82b01d6f
Make find_method_handle_intrinsic work in Xint mode
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Fri, 27 Jun 2014 11:50:07 +0200 |
parents | 989ab80382c1 |
children | 0e34c7fbd288 |
rev | line source |
---|---|
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
1 /* |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
9934
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 |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
24 #include "graal/graalCodeInstaller.hpp" |
15582
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
15123
diff
changeset
|
25 #include "graal/graalRuntime.hpp" |
10684 | 26 #include "graal/graalCompilerToVM.hpp" |
27 #include "graal/graalJavaAccess.hpp" | |
28 | |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
29 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
|
30 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
|
31 return pc_offset + NativeCall::instruction_size; |
11233 | 32 } else if (inst->is_call_reg()) { |
33 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
|
34 } else if (inst->is_sethi()) { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
35 return pc_offset + NativeFarCall::instruction_size; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
36 } else { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
37 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
|
38 return 0; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
39 } |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
40 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
41 |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
42 void CodeInstaller::pd_patch_OopData(int pc_offset, oop data) { |
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
43 address pc = _instructions->start() + pc_offset; |
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
44 Handle obj = OopData::object(data); |
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
45 jobject value = JNIHandles::make_local(obj()); |
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
46 if (OopData::compressed(data)) { |
14561
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
47 fatal("unimplemented: narrow oop relocation"); |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
48 } else { |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
49 NativeMovConstReg* move = nativeMovConstReg_at(pc); |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
50 move->set_data((intptr_t) value); |
13576
4e679d50ba9a
Move data section building code to Java.
Roland Schatz <roland.schatz@oracle.com>
parents:
13553
diff
changeset
|
51 |
14561
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
52 // We need two relocations: one on the sethi and one on the add. |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
53 int oop_index = _oop_recorder->find_index(value); |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
54 RelocationHolder rspec = oop_Relocation::spec(oop_index); |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
55 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
56 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
57 } |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
58 } |
11233 | 59 |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
60 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, oop data) { |
14561
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
61 address pc = _instructions->start() + pc_offset; |
16316
989ab80382c1
Using absolute addressing instead of pc relative in fixup.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15582
diff
changeset
|
62 address const_start = _constants->start(); |
14561
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
63 jint offset = DataSectionReference::offset(data); |
11233 | 64 |
14561
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13576
diff
changeset
|
65 NativeMovRegMem* load = nativeMovRegMem_at(pc); |
16316
989ab80382c1
Using absolute addressing instead of pc relative in fixup.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15582
diff
changeset
|
66 load->add_offset_in_bytes((long)const_start+offset); |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
67 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
68 |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
69 void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
70 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
|
71 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
72 |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
73 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
|
74 address pc = (address) inst; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
75 if (inst->is_call()) { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
76 NativeCall* call = nativeCall_at(pc); |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
77 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
|
78 _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
|
79 } else if (inst->is_sethi()) { |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
80 NativeJump* jump = nativeJump_at(pc); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
81 jump->set_jump_destination((address) foreign_call_destination); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
82 _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
|
83 } else { |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
84 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
|
85 } |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
86 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
|
87 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
88 |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
89 void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { |
10684 | 90 #ifdef ASSERT |
91 Method* method = NULL; | |
92 // we need to check, this might also be an unresolved method | |
93 if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) { | |
94 method = getMethodFromHotSpotMethod(hotspot_method); | |
95 } | |
96 #endif | |
97 switch (_next_call_type) { | |
14574
6bab029d6e3a
removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents:
14561
diff
changeset
|
98 case INLINE_INVOKE: |
10684 | 99 break; |
14574
6bab029d6e3a
removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents:
14561
diff
changeset
|
100 case INVOKEVIRTUAL: |
6bab029d6e3a
removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents:
14561
diff
changeset
|
101 case INVOKEINTERFACE: { |
10684 | 102 assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); |
103 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
104 call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); | |
10792 | 105 _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); |
10684 | 106 break; |
107 } | |
14574
6bab029d6e3a
removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents:
14561
diff
changeset
|
108 case INVOKESTATIC: { |
10684 | 109 assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); |
110 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
111 call->set_destination(SharedRuntime::get_resolve_static_call_stub()); | |
10792 | 112 _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); |
10684 | 113 break; |
114 } | |
14574
6bab029d6e3a
removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents:
14561
diff
changeset
|
115 case INVOKESPECIAL: { |
10684 | 116 assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); |
117 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
118 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
|
119 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); |
10684 | 120 break; |
121 } | |
122 default: | |
123 fatal("invalid _next_call_type value"); | |
124 break; | |
125 } | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
126 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
127 |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
128 void CodeInstaller::pd_relocate_poll(address pc, jint mark) { |
11799 | 129 switch (mark) { |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
130 case POLL_NEAR: |
11799 | 131 fatal("unimplemented"); |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
132 break; |
14574
6bab029d6e3a
removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents:
14561
diff
changeset
|
133 case 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
|
134 _instructions->relocate(pc, relocInfo::poll_type); |
11799 | 135 break; |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
136 case POLL_RETURN_NEAR: |
11799 | 137 fatal("unimplemented"); |
15123
7ccd2a1df0fa
made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
twisti
parents:
14574
diff
changeset
|
138 break; |
14574
6bab029d6e3a
removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents:
14561
diff
changeset
|
139 case 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
|
140 _instructions->relocate(pc, relocInfo::poll_return_type); |
11799 | 141 break; |
142 default: | |
143 fatal("invalid mark value"); | |
144 break; | |
145 } | |
146 } |