1 /*
2 * Copyright (c) 1998, 2012, 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 *
38 assert(which == Assembler::disp32_operand ||
39 which == Assembler::narrow_oop_operand ||
40 which == Assembler::imm_operand, "format unpacks ok");
41 if (which == Assembler::imm_operand) {
42 if (verify_only) {
43 assert(*pd_address_in_code() == x, "instructions must match");
44 } else {
45 *pd_address_in_code() = x;
46 }
47 } else if (which == Assembler::narrow_oop_operand) {
48 address disp = Assembler::locate_operand(addr(), which);
49 // both compressed oops and compressed classes look the same
50 if (Universe::heap()->is_in_reserved((oop)x)) {
51 if (verify_only) {
52 assert(*(uint32_t*) disp == oopDesc::encode_heap_oop((oop)x), "instructions must match");
53 } else {
54 *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
55 }
56 } else {
57 if (verify_only) {
58 assert(*(uint32_t*) disp == oopDesc::encode_klass((Klass*)x), "instructions must match");
59 } else {
60 *(int32_t*) disp = oopDesc::encode_klass((Klass*)x);
61 }
62 }
63 } else {
64 // Note: Use runtime_call_type relocations for call32_operand.
65 address ip = addr();
66 address disp = Assembler::locate_operand(ip, which);
67 address next_ip = Assembler::locate_next_instruction(ip);
68 if (verify_only) {
69 assert(*(int32_t*) disp == (x - next_ip), "instructions must match");
70 } else {
71 *(int32_t*) disp = x - next_ip;
72 }
73 }
74 #else
75 if (verify_only) {
76 assert(*pd_address_in_code() == (x + o), "instructions must match");
77 } else {
78 *pd_address_in_code() = x + o;
79 }
80 #endif // AMD64
|
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 *
38 assert(which == Assembler::disp32_operand ||
39 which == Assembler::narrow_oop_operand ||
40 which == Assembler::imm_operand, "format unpacks ok");
41 if (which == Assembler::imm_operand) {
42 if (verify_only) {
43 assert(*pd_address_in_code() == x, "instructions must match");
44 } else {
45 *pd_address_in_code() = x;
46 }
47 } else if (which == Assembler::narrow_oop_operand) {
48 address disp = Assembler::locate_operand(addr(), which);
49 // both compressed oops and compressed classes look the same
50 if (Universe::heap()->is_in_reserved((oop)x)) {
51 if (verify_only) {
52 assert(*(uint32_t*) disp == oopDesc::encode_heap_oop((oop)x), "instructions must match");
53 } else {
54 *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
55 }
56 } else {
57 if (verify_only) {
58 assert(*(uint32_t*) disp == Klass::encode_klass((Klass*)x), "instructions must match");
59 } else {
60 *(int32_t*) disp = Klass::encode_klass((Klass*)x);
61 }
62 }
63 } else {
64 // Note: Use runtime_call_type relocations for call32_operand.
65 address ip = addr();
66 address disp = Assembler::locate_operand(ip, which);
67 address next_ip = Assembler::locate_next_instruction(ip);
68 if (verify_only) {
69 assert(*(int32_t*) disp == (x - next_ip), "instructions must match");
70 } else {
71 *(int32_t*) disp = x - next_ip;
72 }
73 }
74 #else
75 if (verify_only) {
76 assert(*pd_address_in_code() == (x + o), "instructions must match");
77 } else {
78 *pd_address_in_code() = x + o;
79 }
80 #endif // AMD64
|