0N/A/*
1879N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_ASM_ASSEMBLER_INLINE_HPP
1879N/A#define SHARE_VM_ASM_ASSEMBLER_INLINE_HPP
1879N/A
1879N/A#include "asm/assembler.hpp"
1879N/A#include "asm/codeBuffer.hpp"
1879N/A#include "compiler/disassembler.hpp"
1879N/A#include "runtime/threadLocalStorage.hpp"
1879N/A
0N/Ainline void AbstractAssembler::sync() {
0N/A CodeSection* cs = code_section();
0N/A guarantee(cs->start() == _code_begin, "must not shift code buffer");
0N/A cs->set_end(_code_pos);
0N/A}
0N/A
0N/Ainline void AbstractAssembler::emit_byte(int x) {
0N/A assert(isByte(x), "not a byte");
0N/A *(unsigned char*)_code_pos = (unsigned char)x;
0N/A _code_pos += sizeof(unsigned char);
0N/A sync();
0N/A}
0N/A
0N/A
0N/Ainline void AbstractAssembler::emit_word(int x) {
0N/A *(short*)_code_pos = (short)x;
0N/A _code_pos += sizeof(short);
0N/A sync();
0N/A}
0N/A
0N/A
0N/Ainline void AbstractAssembler::emit_long(jint x) {
0N/A *(jint*)_code_pos = x;
0N/A _code_pos += sizeof(jint);
0N/A sync();
0N/A}
0N/A
0N/Ainline void AbstractAssembler::emit_address(address x) {
0N/A *(address*)_code_pos = x;
0N/A _code_pos += sizeof(address);
0N/A sync();
0N/A}
0N/A
0N/Ainline address AbstractAssembler::inst_mark() const {
0N/A return code_section()->mark();
0N/A}
0N/A
0N/A
0N/Ainline void AbstractAssembler::set_inst_mark() {
0N/A code_section()->set_mark();
0N/A}
0N/A
0N/A
0N/Ainline void AbstractAssembler::clear_inst_mark() {
0N/A code_section()->clear_mark();
0N/A}
0N/A
0N/A
0N/Ainline void AbstractAssembler::relocate(RelocationHolder const& rspec, int format) {
0N/A assert(!pd_check_instruction_mark()
0N/A || inst_mark() == NULL || inst_mark() == _code_pos,
0N/A "call relocate() between instructions");
0N/A code_section()->relocate(_code_pos, rspec, format);
0N/A}
0N/A
0N/A
0N/Ainline CodeBuffer* AbstractAssembler::code() const {
0N/A return code_section()->outer();
0N/A}
0N/A
0N/Ainline int AbstractAssembler::sect() const {
0N/A return code_section()->index();
0N/A}
0N/A
0N/Ainline int AbstractAssembler::locator() const {
0N/A return CodeBuffer::locator(offset(), sect());
0N/A}
0N/A
0N/Ainline address AbstractAssembler::target(Label& L) {
0N/A return code_section()->target(L, pc());
0N/A}
0N/A
0N/Ainline int Label::loc_pos() const {
0N/A return CodeBuffer::locator_pos(loc());
0N/A}
0N/A
0N/Ainline int Label::loc_sect() const {
0N/A return CodeBuffer::locator_sect(loc());
0N/A}
0N/A
0N/Ainline void Label::bind_loc(int pos, int sect) {
0N/A bind_loc(CodeBuffer::locator(pos, sect));
0N/A}
0N/A
1879N/A#endif // SHARE_VM_ASM_ASSEMBLER_INLINE_HPP