1 /*
2 * Copyright (c) 1998, 2013, 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 *
76 ShouldNotReachHere();
77 }
78 do_non_sethi:;
79 #endif
80 {
81 guarantee(Assembler::inv_immed(inst), "must have a simm13 field");
82 int simm13 = Assembler::low10((intptr_t)x) + o;
83 guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13");
84 inst &= ~Assembler::simm( -1, 13);
85 inst |= Assembler::simm(simm13, 13);
86 if (verify_only) {
87 guarantee(ip->long_at(0) == inst, "instructions must match");
88 } else {
89 ip->set_long_at(0, inst);
90 }
91 }
92 break;
93
94 case Assembler::branch_op:
95 {
96 #ifdef _LP64
97 jint inst2;
98 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
99 if (format() != 0) {
100 assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type, "only narrow oops or klasses case");
101 jint np = type() == relocInfo::oop_type ? oopDesc::encode_heap_oop((oop)x) : Klass::encode_klass((Klass*)x);
102 inst &= ~Assembler::hi22(-1);
103 inst |= Assembler::hi22((intptr_t)np);
104 if (verify_only) {
105 guarantee(ip->long_at(0) == inst, "instructions must match");
106 } else {
107 ip->set_long_at(0, inst);
108 }
109 inst2 = ip->long_at( NativeInstruction::nop_instruction_size );
110 guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op");
111 if (verify_only) {
112 guarantee(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np),
113 "instructions must match");
114 } else {
115 ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np));
116 }
117 break;
118 }
119 if (verify_only) {
120 ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x );
121 } else {
122 ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
123 }
124 #else
125 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
126 inst &= ~Assembler::hi22( -1);
127 inst |= Assembler::hi22((intptr_t)x);
128 // (ignore offset; it doesn't play into the sethi)
129 if (verify_only) {
130 guarantee(ip->long_at(0) == inst, "instructions must match");
131 } else {
132 ip->set_long_at(0, inst);
133 }
134 #endif
135 }
136 break;
137
138 default:
139 guarantee(false, "instruction must perform arithmetic or memory access");
140 }
141 }
142
143
144 address Relocation::pd_call_destination(address orig_addr) {
145 intptr_t adj = 0;
146 if (orig_addr != NULL) {
147 // We just moved this call instruction from orig_addr to addr().
148 // This means its target will appear to have grown by addr() - orig_addr.
149 adj = -( addr() - orig_addr );
150 }
151 if (NativeCall::is_call_at(addr())) {
152 NativeCall* call = nativeCall_at(addr());
153 return call->destination() + adj;
154 }
|
1 /*
2 * Copyright (c) 1998, 2017, 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 *
76 ShouldNotReachHere();
77 }
78 do_non_sethi:;
79 #endif
80 {
81 guarantee(Assembler::inv_immed(inst), "must have a simm13 field");
82 int simm13 = Assembler::low10((intptr_t)x) + o;
83 guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13");
84 inst &= ~Assembler::simm( -1, 13);
85 inst |= Assembler::simm(simm13, 13);
86 if (verify_only) {
87 guarantee(ip->long_at(0) == inst, "instructions must match");
88 } else {
89 ip->set_long_at(0, inst);
90 }
91 }
92 break;
93
94 case Assembler::branch_op:
95 {
96 jint inst2;
97 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
98 if (format() != 0) {
99 assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type, "only narrow oops or klasses case");
100 jint np = type() == relocInfo::oop_type ? oopDesc::encode_heap_oop((oop)x) : Klass::encode_klass((Klass*)x);
101 inst &= ~Assembler::hi22(-1);
102 inst |= Assembler::hi22((intptr_t)np);
103 if (verify_only) {
104 guarantee(ip->long_at(0) == inst, "instructions must match");
105 } else {
106 ip->set_long_at(0, inst);
107 }
108 inst2 = ip->long_at( NativeInstruction::nop_instruction_size );
109 guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op");
110 if (verify_only) {
111 guarantee(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np),
112 "instructions must match");
113 } else {
114 ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np));
115 }
116 break;
117 }
118 if (verify_only) {
119 ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x );
120 } else {
121 ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
122 }
123 }
124 break;
125
126 default:
127 guarantee(false, "instruction must perform arithmetic or memory access");
128 }
129 }
130
131
132 address Relocation::pd_call_destination(address orig_addr) {
133 intptr_t adj = 0;
134 if (orig_addr != NULL) {
135 // We just moved this call instruction from orig_addr to addr().
136 // This means its target will appear to have grown by addr() - orig_addr.
137 adj = -( addr() - orig_addr );
138 }
139 if (NativeCall::is_call_at(addr())) {
140 NativeCall* call = nativeCall_at(addr());
141 return call->destination() + adj;
142 }
|