1 /*
2 * Copyright (c) 1997, 2006, 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 *
23 */
24
25 inline void AbstractAssembler::sync() {
26 CodeSection* cs = code_section();
27 guarantee(cs->start() == _code_begin, "must not shift code buffer");
28 cs->set_end(_code_pos);
29 }
30
31 inline void AbstractAssembler::emit_byte(int x) {
32 assert(isByte(x), "not a byte");
33 *(unsigned char*)_code_pos = (unsigned char)x;
34 _code_pos += sizeof(unsigned char);
35 sync();
36 }
37
38
39 inline void AbstractAssembler::emit_word(int x) {
40 *(short*)_code_pos = (short)x;
41 _code_pos += sizeof(short);
42 sync();
43 }
44
116 end_a_const();
117 }
118 return ptr;
119 }
120
121 address AbstractAssembler::address_table_constant(GrowableArray<Label*> labels) {
122 int addressSize = sizeof(address);
123 int sizeLabel = addressSize * labels.length();
124 address ptr = start_a_const(sizeLabel, addressSize);
125
126 if (ptr != NULL) {
127 address *labelLoc = (address*)ptr;
128 for (int i=0; i < labels.length(); i++) {
129 emit_address(code_section()->target(*labels.at(i), (address)&labelLoc[i]));
130 code_section()->relocate((address)&labelLoc[i], relocInfo::internal_word_type);
131 }
132 end_a_const();
133 }
134 return ptr;
135 }
|
1 /*
2 * Copyright (c) 1997, 2010, 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 *
23 */
24
25 #ifndef SHARE_VM_ASM_ASSEMBLER_INLINE_HPP
26 #define SHARE_VM_ASM_ASSEMBLER_INLINE_HPP
27
28 #include "asm/assembler.hpp"
29 #include "asm/codeBuffer.hpp"
30 #include "compiler/disassembler.hpp"
31 #include "runtime/threadLocalStorage.hpp"
32
33 inline void AbstractAssembler::sync() {
34 CodeSection* cs = code_section();
35 guarantee(cs->start() == _code_begin, "must not shift code buffer");
36 cs->set_end(_code_pos);
37 }
38
39 inline void AbstractAssembler::emit_byte(int x) {
40 assert(isByte(x), "not a byte");
41 *(unsigned char*)_code_pos = (unsigned char)x;
42 _code_pos += sizeof(unsigned char);
43 sync();
44 }
45
46
47 inline void AbstractAssembler::emit_word(int x) {
48 *(short*)_code_pos = (short)x;
49 _code_pos += sizeof(short);
50 sync();
51 }
52
124 end_a_const();
125 }
126 return ptr;
127 }
128
129 address AbstractAssembler::address_table_constant(GrowableArray<Label*> labels) {
130 int addressSize = sizeof(address);
131 int sizeLabel = addressSize * labels.length();
132 address ptr = start_a_const(sizeLabel, addressSize);
133
134 if (ptr != NULL) {
135 address *labelLoc = (address*)ptr;
136 for (int i=0; i < labels.length(); i++) {
137 emit_address(code_section()->target(*labels.at(i), (address)&labelLoc[i]));
138 code_section()->relocate((address)&labelLoc[i], relocInfo::internal_word_type);
139 }
140 end_a_const();
141 }
142 return ptr;
143 }
144
145 #endif // SHARE_VM_ASM_ASSEMBLER_INLINE_HPP
|