Mercurial > hg > truffle
annotate src/cpu/x86/vm/graalCodeInstaller_x86.hpp @ 10872:33a2ca7c3bc8
Support for byte fields in LIR instructions.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 25 Jul 2013 11:50:59 +0200 |
parents | 4e1db4c9d4c5 |
children | ce0b00597980 |
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 */ |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
23 #ifndef CPU_SPARC_VM_CODEINSTALLER_X86_HPP |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
24 #define CPU_SPARC_VM_CODEINSTALLER_X86_HPP |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
25 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
26 #include "compiler/disassembler.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
27 #include "runtime/javaCalls.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
28 #include "graal/graalEnv.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
29 #include "graal/graalCompiler.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
30 #include "graal/graalCodeInstaller.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
31 #include "graal/graalJavaAccess.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
32 #include "graal/graalCompilerToVM.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
33 #include "graal/graalRuntime.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
34 #include "asm/register.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
35 #include "classfile/vmSymbols.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
36 #include "code/vmreg.hpp" |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
37 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
38 inline jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
39 if (inst->is_call() || inst->is_jump()) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
40 assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
41 return (pc_offset + NativeCall::instruction_size); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
42 } else if (inst->is_mov_literal64()) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
43 // mov+call instruction pair |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
44 jint offset = pc_offset + NativeMovConstReg::instruction_size; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
45 u_char* call = (u_char*) (_instructions->start() + offset); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
46 assert((call[0] == 0x40 || call[0] == 0x41) && call[1] == 0xFF, "expected call with rex/rexb prefix byte"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
47 offset += 3; /* prefix byte + opcode byte + modrm byte */ |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
48 return (offset); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
49 } else if (inst->is_call_reg()) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
50 // the inlined vtable stub contains a "call register" instruction |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
51 assert(method != NULL, "only valid for virtual calls"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
52 return (pc_offset + ((NativeCallReg *) inst)->next_instruction_offset()); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
53 } else { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
54 fatal("unsupported type of instruction for call site"); |
9953
60648c97cdd0
Windows build fix: compiler warning "not all control paths return a value" in CodeInstaller::pd_next_offset.
Andreas Woess <andreas.woess@jku.at>
parents:
9934
diff
changeset
|
55 return 0; |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
56 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
57 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
58 |
10684 | 59 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) { |
60 int alignment = CompilationResult_DataPatch::alignment(site); | |
61 bool inlined = CompilationResult_DataPatch::inlined(site) == JNI_TRUE; | |
62 | |
10810
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
63 address pc = _instructions->start() + pc_offset; |
10684 | 64 |
10810
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
65 oop constant = CompilationResult_DataPatch::constant(site); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
66 char typeChar; |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
67 if (constant != NULL) { |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
68 oop kind = Constant::kind(constant); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
69 typeChar = Kind::typeChar(kind); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
70 } else { |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
71 assert(!inlined, "cannot inline raw constants"); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
72 typeChar = '*'; |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
73 } |
10684 | 74 |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
75 switch (typeChar) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
76 case 'z': |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
77 case 'b': |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
78 case 's': |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
79 case 'c': |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
80 case 'i': |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
81 fatal("int-sized values not expected in DataPatch"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
82 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
83 case 'f': |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
84 case 'j': |
10810
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
85 case 'd': |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
86 case '*': { |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
87 if (inlined) { |
10684 | 88 address operand = Assembler::locate_operand(pc, Assembler::imm_operand); |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
89 *((jlong*) operand) = Constant::primitive(constant); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
90 } else { |
10684 | 91 address operand = Assembler::locate_operand(pc, Assembler::disp32_operand); |
92 address next_instruction = Assembler::locate_next_instruction(pc); | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
93 int size = _constants->size(); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
94 if (alignment > 0) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
95 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
96 size = align_size_up(size, alignment); |
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 // we don't care if this is a long/double/etc., the primitive field contains the right bits |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
99 address dest = _constants->start() + size; |
10684 | 100 _constants->set_end(dest); |
10810
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
101 if (constant != NULL) { |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
102 uint64_t value = Constant::primitive(constant); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
103 _constants->emit_int64(value); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
104 } else { |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
105 arrayOop rawConstant = arrayOop(CompilationResult_DataPatch::rawConstant(site)); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
106 int8_t *ptr = (int8_t*) rawConstant->base(T_BYTE); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
107 for (int i = rawConstant->length(); i > 0; i--, ptr++) { |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
108 _constants->emit_int8(*ptr); |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
109 } |
4e1db4c9d4c5
Support data patches for values larger than long.
Roland Schatz <roland.schatz@oracle.com>
parents:
10684
diff
changeset
|
110 } |
9934
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 long disp = dest - next_instruction; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
113 assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
114 *((jint*) operand) = (jint) disp; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
115 |
10684 | 116 _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand); |
117 TRACE_graal_3("relocating (%c) at %p/%p with destination at %p (%d)", typeChar, pc, operand, dest, size); | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
118 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
119 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
120 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
121 case 'a': { |
10684 | 122 address operand = Assembler::locate_operand(pc, Assembler::imm_operand); |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
123 Handle obj = Constant::object(constant); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
124 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
125 jobject value = JNIHandles::make_local(obj()); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
126 *((jobject*) operand) = value; |
10684 | 127 _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); |
128 TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand); | |
9934
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
129 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
130 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
131 default: |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
132 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar)); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
133 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
134 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
135 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
136 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
137 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
|
138 if (cb->is_nmethod()) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
139 nmethod* nm = (nmethod*) cb; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
140 nativeJump_at((address)inst)->set_jump_destination(nm->verified_entry_point()); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
141 } else { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
142 nativeJump_at((address)inst)->set_jump_destination(cb->code_begin()); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
143 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
144 _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
145 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
146 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
147 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
|
148 if (inst->is_call()) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
149 // NOTE: for call without a mov, the offset must fit a 32-bit immediate |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
150 // see also CompilerToVM.getMaxCallTargetOffset() |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
151 NativeCall* call = nativeCall_at((address) (inst)); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
152 call->set_destination((address) foreign_call_destination); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
153 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
154 } else if (inst->is_mov_literal64()) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
155 NativeMovConstReg* mov = nativeMovConstReg_at((address) (inst)); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
156 mov->set_data((intptr_t) foreign_call_destination); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
157 _instructions->relocate(mov->instruction_address(), runtime_call_Relocation::spec(), Assembler::imm_operand); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
158 } else { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
159 NativeJump* jump = nativeJump_at((address) (inst)); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
160 jump->set_jump_destination((address) foreign_call_destination); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
161 _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
162 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
163 TRACE_graal_3("relocating (foreign call) at %p", inst); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
164 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
165 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
166 inline void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
167 #ifdef ASSERT |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
168 Method* method = NULL; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
169 // we need to check, this might also be an unresolved method |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
170 if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
171 method = getMethodFromHotSpotMethod(hotspot_method); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
172 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
173 #endif |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
174 switch (_next_call_type) { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
175 case MARK_INLINE_INVOKE: |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
176 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
177 case MARK_INVOKEVIRTUAL: |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
178 case MARK_INVOKEINTERFACE: { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
179 assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
180 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
181 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
182 call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
183 _instructions->relocate(call->instruction_address(), |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
184 virtual_call_Relocation::spec(_invoke_mark_pc), |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
185 Assembler::call32_operand); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
186 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
187 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
188 case MARK_INVOKESTATIC: { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
189 assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
190 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
191 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
192 call->set_destination(SharedRuntime::get_resolve_static_call_stub()); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
193 _instructions->relocate(call->instruction_address(), |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
194 relocInfo::static_call_type, Assembler::call32_operand); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
195 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
196 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
197 case MARK_INVOKESPECIAL: { |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
198 assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
199 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
200 call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
201 _instructions->relocate(call->instruction_address(), |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
202 relocInfo::opt_virtual_call_type, Assembler::call32_operand); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
203 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
204 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
205 default: |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
206 break; |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
207 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
208 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
209 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
210 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
|
211 return (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand); |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
212 } |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
213 |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
214 #endif // CPU_SPARC_VM_CODEINSTALLER_X86_HPP |
0f7ca53be929
CR-806: Changes to build Graal for SPARC
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
215 |