1 /*
2 * Copyright (c) 2015, 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 */
54 int oop_index = _oop_recorder->find_index(value);
55 RelocationHolder rspec = oop_Relocation::spec(oop_index);
56 _instructions->relocate(pc, rspec);
57 }
58 }
59
60 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
61 address pc = _instructions->start() + pc_offset;
62 if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
63 narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK);
64 TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
65 Unimplemented();
66 } else {
67 NativeMovConstReg* move = nativeMovConstReg_at(pc);
68 Metadata* reference = record_metadata_reference(constant, CHECK);
69 move->set_data((intptr_t) reference);
70 TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
71 }
72 }
73
74 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) {
75 address pc = _instructions->start() + pc_offset;
76 NativeInstruction* inst = nativeInstruction_at(pc);
77 if (inst->is_adr_aligned()) {
78 address dest = _constants->start() + data_offset;
79 _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS));
80 TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
81 } else {
82 JVMCI_ERROR("unknown load or move instruction at " PTR_FORMAT, p2i(pc));
83 }
84 }
85
86 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) {
87 address pc = (address) inst;
88 if (inst->is_call()) {
89 NativeCall* call = nativeCall_at(pc);
90 call->set_destination((address) foreign_call_destination);
91 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
92 } else if (inst->is_jump()) {
93 NativeJump* jump = nativeJump_at(pc);
94 jump->set_jump_destination((address) foreign_call_destination);
|
1 /*
2 * Copyright (c) 2015, 2016, 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 */
54 int oop_index = _oop_recorder->find_index(value);
55 RelocationHolder rspec = oop_Relocation::spec(oop_index);
56 _instructions->relocate(pc, rspec);
57 }
58 }
59
60 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
61 address pc = _instructions->start() + pc_offset;
62 if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
63 narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK);
64 TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
65 Unimplemented();
66 } else {
67 NativeMovConstReg* move = nativeMovConstReg_at(pc);
68 Metadata* reference = record_metadata_reference(constant, CHECK);
69 move->set_data((intptr_t) reference);
70 TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
71 }
72 }
73
74 void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) {
75 address pc = _instructions->start() + pc_offset;
76 NativeInstruction* inst = nativeInstruction_at(pc);
77 if (inst->is_adr_aligned()) {
78 address dest = _constants->start() + data_offset;
79 _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS));
80 TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset);
81 } else {
82 JVMCI_ERROR("unknown load or move instruction at " PTR_FORMAT, p2i(pc));
83 }
84 }
85
86 void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) {
87 address pc = (address) inst;
88 if (inst->is_call()) {
89 NativeCall* call = nativeCall_at(pc);
90 call->set_destination((address) foreign_call_destination);
91 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
92 } else if (inst->is_jump()) {
93 NativeJump* jump = nativeJump_at(pc);
94 jump->set_jump_destination((address) foreign_call_destination);
|