1 /*
2 * Copyright (c) 1997, 2009, 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 *
253 static int code_fill_byte(); // used to pad out odd-sized code buffers
254
255 // Associate a comment with the current offset. It will be printed
256 // along with the disassembly when printing nmethods. Currently
257 // only supported in the instruction section of the code buffer.
258 void block_comment(const char* comment);
259
260 // Label functions
261 void bind(Label& L); // binds an unbound label L to the current code position
262
263 // Move to a different section in the same code buffer.
264 void set_code_section(CodeSection* cs);
265
266 // Inform assembler when generating stub code and relocation info
267 address start_a_stub(int required_space);
268 void end_a_stub();
269 // Ditto for constants.
270 address start_a_const(int required_space, int required_align = sizeof(double));
271 void end_a_const();
272
273 // fp constants support
274 address double_constant(jdouble c) {
275 address ptr = start_a_const(sizeof(c), sizeof(c));
276 if (ptr != NULL) {
277 *(jdouble*)ptr = c;
278 _code_pos = ptr + sizeof(c);
279 end_a_const();
280 }
281 return ptr;
282 }
283 address float_constant(jfloat c) {
284 address ptr = start_a_const(sizeof(c), sizeof(c));
285 if (ptr != NULL) {
286 *(jfloat*)ptr = c;
287 _code_pos = ptr + sizeof(c);
288 end_a_const();
289 }
290 return ptr;
291 }
292 address address_constant(address c, RelocationHolder const& rspec) {
293 address ptr = start_a_const(sizeof(c), sizeof(c));
294 if (ptr != NULL) {
295 relocate(rspec);
296 *(address*)ptr = c;
297 _code_pos = ptr + sizeof(c);
298 end_a_const();
299 }
300 return ptr;
301 }
302 inline address address_constant(Label& L);
303 inline address address_table_constant(GrowableArray<Label*> label);
304
305 // Bootstrapping aid to cope with delayed determination of constants.
306 // Returns a static address which will eventually contain the constant.
307 // The value zero (NULL) stands instead of a constant which is still uncomputed.
308 // Thus, the eventual value of the constant must not be zero.
309 // This is fine, since this is designed for embedding object field
310 // offsets in code which must be generated before the object class is loaded.
311 // Field offsets are never zero, since an object's header (mark word)
312 // is located at offset zero.
313 RegisterOrConstant delayed_value(int(*value_fn)(), Register tmp, int offset = 0) {
314 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset);
315 }
316 RegisterOrConstant delayed_value(address(*value_fn)(), Register tmp, int offset = 0) {
317 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset);
318 }
319 virtual RegisterOrConstant delayed_value_impl(intptr_t* delayed_value_addr, Register tmp, int offset) = 0;
320 // Last overloading is platform-dependent; look in assembler_<arch>.cpp.
321 static intptr_t* delayed_value_addr(int(*constant_fn)());
322 static intptr_t* delayed_value_addr(address(*constant_fn)());
323 static void update_delayed_values();
|
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 *
253 static int code_fill_byte(); // used to pad out odd-sized code buffers
254
255 // Associate a comment with the current offset. It will be printed
256 // along with the disassembly when printing nmethods. Currently
257 // only supported in the instruction section of the code buffer.
258 void block_comment(const char* comment);
259
260 // Label functions
261 void bind(Label& L); // binds an unbound label L to the current code position
262
263 // Move to a different section in the same code buffer.
264 void set_code_section(CodeSection* cs);
265
266 // Inform assembler when generating stub code and relocation info
267 address start_a_stub(int required_space);
268 void end_a_stub();
269 // Ditto for constants.
270 address start_a_const(int required_space, int required_align = sizeof(double));
271 void end_a_const();
272
273 // constants support
274 address long_constant(jlong c) {
275 address ptr = start_a_const(sizeof(c), sizeof(c));
276 if (ptr != NULL) {
277 *(jlong*)ptr = c;
278 _code_pos = ptr + sizeof(c);
279 end_a_const();
280 }
281 return ptr;
282 }
283 address double_constant(jdouble c) {
284 address ptr = start_a_const(sizeof(c), sizeof(c));
285 if (ptr != NULL) {
286 *(jdouble*)ptr = c;
287 _code_pos = ptr + sizeof(c);
288 end_a_const();
289 }
290 return ptr;
291 }
292 address float_constant(jfloat c) {
293 address ptr = start_a_const(sizeof(c), sizeof(c));
294 if (ptr != NULL) {
295 *(jfloat*)ptr = c;
296 _code_pos = ptr + sizeof(c);
297 end_a_const();
298 }
299 return ptr;
300 }
301 address address_constant(address c) {
302 address ptr = start_a_const(sizeof(c), sizeof(c));
303 if (ptr != NULL) {
304 *(address*)ptr = c;
305 _code_pos = ptr + sizeof(c);
306 end_a_const();
307 }
308 return ptr;
309 }
310 address address_constant(address c, RelocationHolder const& rspec) {
311 address ptr = start_a_const(sizeof(c), sizeof(c));
312 if (ptr != NULL) {
313 relocate(rspec);
314 *(address*)ptr = c;
315 _code_pos = ptr + sizeof(c);
316 end_a_const();
317 }
318 return ptr;
319 }
320
321 // Bootstrapping aid to cope with delayed determination of constants.
322 // Returns a static address which will eventually contain the constant.
323 // The value zero (NULL) stands instead of a constant which is still uncomputed.
324 // Thus, the eventual value of the constant must not be zero.
325 // This is fine, since this is designed for embedding object field
326 // offsets in code which must be generated before the object class is loaded.
327 // Field offsets are never zero, since an object's header (mark word)
328 // is located at offset zero.
329 RegisterOrConstant delayed_value(int(*value_fn)(), Register tmp, int offset = 0) {
330 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset);
331 }
332 RegisterOrConstant delayed_value(address(*value_fn)(), Register tmp, int offset = 0) {
333 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset);
334 }
335 virtual RegisterOrConstant delayed_value_impl(intptr_t* delayed_value_addr, Register tmp, int offset) = 0;
336 // Last overloading is platform-dependent; look in assembler_<arch>.cpp.
337 static intptr_t* delayed_value_addr(int(*constant_fn)());
338 static intptr_t* delayed_value_addr(address(*constant_fn)());
339 static void update_delayed_values();
|