Mercurial > hg > graal-jvmci-8
annotate src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp @ 10792:7a8d6ba83a04
SPARC: fixes and more stuff works
author | twisti |
---|---|
date | Tue, 16 Jul 2013 17:41:21 -0700 |
parents | 6ff467cdb105 |
children | e1fcdda22831 |
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) { |
10684 | 32 assert(inst->is_call() || inst->is_jump(), "sanity"); |
33 return pc_offset + NativeCall::instruction_size; | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
34 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
35 |
10684 | 36 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) { |
37 oop constant = CompilationResult_DataPatch::constant(site); | |
38 int alignment = CompilationResult_DataPatch::alignment(site); | |
39 bool inlined = CompilationResult_DataPatch::inlined(site) == JNI_TRUE; | |
40 | |
41 oop kind = Constant::kind(constant); | |
42 char typeChar = Kind::typeChar(kind); | |
43 | |
44 address pc = _instructions->start() + pc_offset; | |
45 | |
46 switch (typeChar) { | |
47 case 'z': | |
48 case 'b': | |
49 case 's': | |
50 case 'c': | |
51 case 'i': | |
52 fatal("int-sized values not expected in DataPatch"); | |
53 break; | |
54 case 'f': | |
55 case 'j': | |
56 case 'd': { | |
57 if (inlined) { | |
10792 | 58 NativeMovConstReg* move = nativeMovConstReg_at(pc); |
59 uint64_t value = Constant::primitive(constant); | |
60 move->set_data(value); | |
10684 | 61 } else { |
62 int size = _constants->size(); | |
63 if (alignment > 0) { | |
64 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); | |
65 size = align_size_up(size, alignment); | |
66 } | |
67 // we don't care if this is a long/double/etc., the primitive field contains the right bits | |
68 address dest = _constants->start() + size; | |
69 _constants->set_end(dest); | |
70 uint64_t value = Constant::primitive(constant); | |
71 _constants->emit_int64(value); | |
72 | |
73 NativeMovRegMem* load = nativeMovRegMem_at(pc); | |
74 int disp = _constants_size + pc_offset - size - BytesPerInstWord; | |
75 load->set_offset(-disp); | |
76 } | |
77 break; | |
78 } | |
79 case 'a': { | |
10792 | 80 int size = _constants->size(); |
81 if (alignment > 0) { | |
82 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); | |
83 size = align_size_up(size, alignment); | |
84 } | |
85 address dest = _constants->start() + size; | |
86 _constants->set_end(dest); | |
87 Handle obj = Constant::object(constant); | |
88 jobject value = JNIHandles::make_local(obj()); | |
89 _constants->emit_address((address) value); | |
90 | |
91 NativeMovRegMem* load = nativeMovRegMem_at(pc); | |
92 int disp = _constants_size + pc_offset - size - BytesPerInstWord; | |
93 load->set_offset(-disp); | |
94 | |
95 int oop_index = _oop_recorder->find_index(value); | |
96 _constants->relocate(dest, oop_Relocation::spec(oop_index)); | |
10684 | 97 break; |
98 } | |
99 default: | |
100 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar)); | |
101 break; | |
102 } | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
103 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
104 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
105 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
|
106 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
|
107 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
108 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
109 inline void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
110 fatal("CodeInstaller::pd_relocate_ForeignCall - sparc unimp"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
111 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
112 |
10684 | 113 inline void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { |
114 #ifdef ASSERT | |
115 Method* method = NULL; | |
116 // we need to check, this might also be an unresolved method | |
117 if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) { | |
118 method = getMethodFromHotSpotMethod(hotspot_method); | |
119 } | |
120 #endif | |
121 switch (_next_call_type) { | |
122 case MARK_INLINE_INVOKE: | |
123 break; | |
124 case MARK_INVOKEVIRTUAL: | |
125 case MARK_INVOKEINTERFACE: { | |
126 assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); | |
127 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
128 call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); | |
10792 | 129 _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); |
130 /*, Assembler::call32_operand); */ | |
10684 | 131 break; |
132 } | |
133 case MARK_INVOKESTATIC: { | |
134 assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); | |
135 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | |
136 call->set_destination(SharedRuntime::get_resolve_static_call_stub()); | |
10792 | 137 _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); |
138 /*, Assembler::call32_operand); */ | |
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()); | |
145 // _instructions->relocate(call->instruction_address(), | |
146 // relocInfo::opt_virtual_call_type, Assembler::call32_operand); | |
147 fatal("NYI"); | |
148 break; | |
149 } | |
150 default: | |
151 fatal("invalid _next_call_type value"); | |
152 break; | |
153 } | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
154 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
155 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
156 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
|
157 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
|
158 return (int32_t*)0; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
159 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
160 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
161 #endif // CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP |