comparison src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp @ 10684:6ff467cdb105

Code installer changes for SPARC.
author twisti
date Tue, 09 Jul 2013 14:39:34 -0700
parents 67fa9b3e10ed
children 7a8d6ba83a04
comparison
equal deleted inserted replaced
10683:ae4c79ee71d1 10684:6ff467cdb105
18 * 18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 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 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23
23 #ifndef CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP 24 #ifndef CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP
24 #define CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP 25 #define CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP
25 26
27 #include "graal/graalCompiler.hpp"
28 #include "graal/graalCompilerToVM.hpp"
29 #include "graal/graalJavaAccess.hpp"
30
26 inline jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { 31 inline jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) {
27 fatal("CodeInstaller::pd_next_offset - sparc unimp"); 32 assert(inst->is_call() || inst->is_jump(), "sanity");
28 return 0; 33 return pc_offset + NativeCall::instruction_size;
29 } 34 }
30 35
31 inline void CodeInstaller::pd_site_DataPatch(oop constant, oop kind, bool inlined, 36 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) {
32 address instruction, int alignment, char typeChar) { 37 oop constant = CompilationResult_DataPatch::constant(site);
33 fatal("CodeInstaller::pd_site_DataPatch - sparc unimp"); 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 tty->print_cr("CodeInstaller::pd_site_DataPatch: typeChar=%c, inlined=%d", typeChar, inlined);
47
48 switch (typeChar) {
49 case 'z':
50 case 'b':
51 case 's':
52 case 'c':
53 case 'i':
54 fatal("int-sized values not expected in DataPatch");
55 break;
56 case 'f':
57 case 'j':
58 case 'd': {
59 if (inlined) {
60 fatal(err_msg("inlined: type=%c, constant=%lx", inlined, Constant::primitive(constant)));
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 // assert(disp == (jint) disp, "disp doesn't fit in 32 bits");
78 // *((jint*) operand) = (jint) disp;
79
80 // _instructions->relocate(instruction, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS) /*, Assembler::disp32_operand*/);
81 // TRACE_graal_3("relocating (%c) at %p/%p with destination at %p (%d)", typeChar, instruction, operand, dest, size);
82 }
83 break;
84 }
85 case 'a': {
86 // address operand = Assembler::locate_operand(instruction, Assembler::imm_operand);
87 // Handle obj = Constant::object(constant);
88 //
89 // jobject value = JNIHandles::make_local(obj());
90 // *((jobject*) operand) = value;
91 // _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
92 // TRACE_graal_3("relocating (oop constant) at %p/%p", instruction, operand);
93 break;
94 }
95 default:
96 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar));
97 break;
98 }
34 } 99 }
35 100
36 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { 101 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
37 fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp"); 102 fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp");
38 } 103 }
39 104
40 inline void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { 105 inline void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
41 fatal("CodeInstaller::pd_relocate_ForeignCall - sparc unimp"); 106 fatal("CodeInstaller::pd_relocate_ForeignCall - sparc unimp");
42 } 107 }
43 108
44 inline void CodeInstaller::pd_relocate_JavaMethod(oop method, jint pc_offset) { 109 inline void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
45 fatal("CodeInstaller::pd_relocate_JavaMethod - sparc unimp"); 110 #ifdef ASSERT
111 Method* method = NULL;
112 // we need to check, this might also be an unresolved method
113 if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) {
114 method = getMethodFromHotSpotMethod(hotspot_method);
115 }
116 #endif
117 switch (_next_call_type) {
118 case MARK_INLINE_INVOKE:
119 break;
120 case MARK_INVOKEVIRTUAL:
121 case MARK_INVOKEINTERFACE: {
122 assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
123 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
124 call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
125 // _instructions->relocate(call->instruction_address(),
126 // virtual_call_Relocation::spec(_invoke_mark_pc),
127 // Assembler::call32_operand);
128 fatal("NYI");
129 break;
130 }
131 case MARK_INVOKESTATIC: {
132 assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
133 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
134 call->set_destination(SharedRuntime::get_resolve_static_call_stub());
135 _instructions->relocate(call->instruction_address(),
136 relocInfo::static_call_type /*, Assembler::call32_operand*/);
137 break;
138 }
139 case MARK_INVOKESPECIAL: {
140 assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
141 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
142 call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
143 // _instructions->relocate(call->instruction_address(),
144 // relocInfo::opt_virtual_call_type, Assembler::call32_operand);
145 fatal("NYI");
146 break;
147 }
148 default:
149 fatal("invalid _next_call_type value");
150 break;
151 }
46 } 152 }
47 153
48 inline int32_t* CodeInstaller::pd_locate_operand(address instruction) { 154 inline int32_t* CodeInstaller::pd_locate_operand(address instruction) {
49 fatal("CodeInstaller::pd_locate_operand - sparc unimp"); 155 fatal("CodeInstaller::pd_locate_operand - sparc unimp");
50 return (int32_t*)0; 156 return (int32_t*)0;