Fri, 30 Nov 2012 11:44:05 -0800
8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
Reviewed-by: twisti, kvn
Contributed-by: Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_ASM_ASSEMBLER_INLINE_HPP |
stefank@2314 | 26 | #define SHARE_VM_ASM_ASSEMBLER_INLINE_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "asm/assembler.hpp" |
stefank@2314 | 29 | #include "asm/codeBuffer.hpp" |
stefank@2314 | 30 | #include "compiler/disassembler.hpp" |
stefank@2314 | 31 | #include "runtime/threadLocalStorage.hpp" |
stefank@2314 | 32 | |
twisti@4317 | 33 | inline address AbstractAssembler::addr_at(int pos) const { |
twisti@4317 | 34 | return code_section()->start() + pos; |
duke@435 | 35 | } |
duke@435 | 36 | |
twisti@4317 | 37 | void AbstractAssembler::emit_int8(int8_t x) { code_section()->emit_int8 (x); } |
twisti@4317 | 38 | void AbstractAssembler::emit_int16(int16_t x) { code_section()->emit_int16(x); } |
twisti@4317 | 39 | void AbstractAssembler::emit_int32(int32_t x) { code_section()->emit_int32(x); } |
twisti@4317 | 40 | void AbstractAssembler::emit_int64(int64_t x) { code_section()->emit_int64(x); } |
duke@435 | 41 | |
twisti@4317 | 42 | void AbstractAssembler::emit_float(jfloat x) { code_section()->emit_float(x); } |
twisti@4317 | 43 | void AbstractAssembler::emit_double(jdouble x) { code_section()->emit_double(x); } |
twisti@4317 | 44 | void AbstractAssembler::emit_address(address x) { code_section()->emit_address(x); } |
duke@435 | 45 | |
duke@435 | 46 | inline address AbstractAssembler::inst_mark() const { |
duke@435 | 47 | return code_section()->mark(); |
duke@435 | 48 | } |
duke@435 | 49 | |
duke@435 | 50 | inline void AbstractAssembler::set_inst_mark() { |
duke@435 | 51 | code_section()->set_mark(); |
duke@435 | 52 | } |
duke@435 | 53 | |
duke@435 | 54 | inline void AbstractAssembler::clear_inst_mark() { |
duke@435 | 55 | code_section()->clear_mark(); |
duke@435 | 56 | } |
duke@435 | 57 | |
duke@435 | 58 | |
duke@435 | 59 | inline void AbstractAssembler::relocate(RelocationHolder const& rspec, int format) { |
duke@435 | 60 | assert(!pd_check_instruction_mark() |
twisti@4317 | 61 | || inst_mark() == NULL || inst_mark() == code_section()->end(), |
duke@435 | 62 | "call relocate() between instructions"); |
twisti@4317 | 63 | code_section()->relocate(code_section()->end(), rspec, format); |
duke@435 | 64 | } |
duke@435 | 65 | |
duke@435 | 66 | |
duke@435 | 67 | inline CodeBuffer* AbstractAssembler::code() const { |
duke@435 | 68 | return code_section()->outer(); |
duke@435 | 69 | } |
duke@435 | 70 | |
duke@435 | 71 | inline int AbstractAssembler::sect() const { |
duke@435 | 72 | return code_section()->index(); |
duke@435 | 73 | } |
duke@435 | 74 | |
twisti@4317 | 75 | inline address AbstractAssembler::pc() const { |
twisti@4317 | 76 | return code_section()->end(); |
twisti@4317 | 77 | } |
twisti@4317 | 78 | |
twisti@4317 | 79 | inline int AbstractAssembler::offset() const { |
twisti@4317 | 80 | return code_section()->size(); |
twisti@4317 | 81 | } |
twisti@4317 | 82 | |
duke@435 | 83 | inline int AbstractAssembler::locator() const { |
duke@435 | 84 | return CodeBuffer::locator(offset(), sect()); |
duke@435 | 85 | } |
duke@435 | 86 | |
duke@435 | 87 | inline address AbstractAssembler::target(Label& L) { |
duke@435 | 88 | return code_section()->target(L, pc()); |
duke@435 | 89 | } |
duke@435 | 90 | |
duke@435 | 91 | inline int Label::loc_pos() const { |
duke@435 | 92 | return CodeBuffer::locator_pos(loc()); |
duke@435 | 93 | } |
duke@435 | 94 | |
duke@435 | 95 | inline int Label::loc_sect() const { |
duke@435 | 96 | return CodeBuffer::locator_sect(loc()); |
duke@435 | 97 | } |
duke@435 | 98 | |
duke@435 | 99 | inline void Label::bind_loc(int pos, int sect) { |
duke@435 | 100 | bind_loc(CodeBuffer::locator(pos, sect)); |
duke@435 | 101 | } |
duke@435 | 102 | |
stefank@2314 | 103 | #endif // SHARE_VM_ASM_ASSEMBLER_INLINE_HPP |