comparison src/cpu/sparc/vm/graalCodeInstaller_sparc.cpp @ 15123:7ccd2a1df0fa

made SPARC compile again; moved graalCodeInstaller_<arch>.hpp to .cpp files
author twisti
date Tue, 15 Apr 2014 12:01:51 -1000
parents src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp@6bab029d6e3a
children 063ec2920d21
comparison
equal deleted inserted replaced
15122:11a591a99515 15123:7ccd2a1df0fa
1 /*
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "graal/graalCodeInstaller.hpp"
25 #include "graal/graalCompiler.hpp"
26 #include "graal/graalCompilerToVM.hpp"
27 #include "graal/graalJavaAccess.hpp"
28
29 jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) {
30 if (inst->is_call() || inst->is_jump()) {
31 return pc_offset + NativeCall::instruction_size;
32 } else if (inst->is_call_reg()) {
33 return pc_offset + NativeCallReg::instruction_size;
34 } else if (inst->is_sethi()) {
35 return pc_offset + NativeFarCall::instruction_size;
36 } else {
37 fatal("unsupported type of instruction for call site");
38 return 0;
39 }
40 }
41
42 void CodeInstaller::pd_patch_OopData(int pc_offset, oop data) {
43 address pc = _instructions->start() + pc_offset;
44 Handle obj = OopData::object(data);
45 jobject value = JNIHandles::make_local(obj());
46 if (OopData::compressed(data)) {
47 fatal("unimplemented: narrow oop relocation");
48 } else {
49 NativeMovConstReg* move = nativeMovConstReg_at(pc);
50 move->set_data((intptr_t) value);
51
52 // We need two relocations: one on the sethi and one on the add.
53 int oop_index = _oop_recorder->find_index(value);
54 RelocationHolder rspec = oop_Relocation::spec(oop_index);
55 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec);
56 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec);
57 }
58 }
59
60 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, oop data) {
61 address pc = _instructions->start() + pc_offset;
62 jint offset = DataSectionReference::offset(data);
63
64 NativeMovRegMem* load = nativeMovRegMem_at(pc);
65 int disp = _constants_size + pc_offset - offset - BytesPerInstWord;
66 load->set_offset(-disp);
67 }
68
69 void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
70 fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp");
71 }
72
73 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
74 address pc = (address) inst;
75 if (inst->is_call()) {
76 NativeCall* call = nativeCall_at(pc);
77 call->set_destination((address) foreign_call_destination);
78 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
79 } else if (inst->is_sethi()) {
80 NativeJump* jump = nativeJump_at(pc);
81 jump->set_jump_destination((address) foreign_call_destination);
82 _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
83 } else {
84 fatal(err_msg("unknown call or jump instruction at %p", pc));
85 }
86 TRACE_graal_3("relocating (foreign call) at %p", inst);
87 }
88
89 void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
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) {
98 case INLINE_INVOKE:
99 break;
100 case INVOKEVIRTUAL:
101 case INVOKEINTERFACE: {
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());
105 _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc));
106 break;
107 }
108 case INVOKESTATIC: {
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());
112 _instructions->relocate(call->instruction_address(), relocInfo::static_call_type);
113 break;
114 }
115 case INVOKESPECIAL: {
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());
119 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type);
120 break;
121 }
122 default:
123 fatal("invalid _next_call_type value");
124 break;
125 }
126 }
127
128 void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
129 switch (mark) {
130 case POLL_NEAR:
131 fatal("unimplemented");
132 break;
133 case POLL_FAR:
134 _instructions->relocate(pc, relocInfo::poll_type);
135 break;
136 case POLL_RETURN_NEAR:
137 fatal("unimplemented");
138 break;
139 case POLL_RETURN_FAR:
140 _instructions->relocate(pc, relocInfo::poll_return_type);
141 break;
142 default:
143 fatal("invalid mark value");
144 break;
145 }
146 }