Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkCodeBuffer.hpp
32285 views
/*1* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.2* Copyright 2009 Red Hat, Inc.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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef SHARE_VM_SHARK_SHARKCODEBUFFER_HPP26#define SHARE_VM_SHARK_SHARKCODEBUFFER_HPP2728#include "asm/codeBuffer.hpp"29#include "memory/allocation.hpp"30#include "shark/llvmHeaders.hpp"3132class SharkCodeBuffer : public StackObj {33public:34SharkCodeBuffer(MacroAssembler* masm)35: _masm(masm), _base_pc(NULL) {}3637private:38MacroAssembler* _masm;39llvm::Value* _base_pc;4041private:42MacroAssembler* masm() const {43return _masm;44}4546public:47llvm::Value* base_pc() const {48return _base_pc;49}50void set_base_pc(llvm::Value* base_pc) {51assert(_base_pc == NULL, "only do this once");52_base_pc = base_pc;53}5455// Allocate some space in the buffer and return its address.56// This buffer will have been relocated by the time the method57// is installed, so you can't inline the result in code.58public:59void* malloc(size_t size) const {60masm()->align(BytesPerWord);61void *result = masm()->pc();62masm()->advance(size);63return result;64}6566// Create a unique offset in the buffer.67public:68int create_unique_offset() const {69int offset = masm()->offset();70masm()->advance(1);71return offset;72}7374// Inline an oop into the buffer and return its offset.75public:76int inline_oop(jobject object) const {77masm()->align(BytesPerWord);78int offset = masm()->offset();79masm()->store_oop(object);80return offset;81}8283int inline_Metadata(Metadata* metadata) const {84masm()->align(BytesPerWord);85int offset = masm()->offset();86masm()->store_Metadata(metadata);87return offset;88}8990// Inline a block of non-oop data into the buffer and return its offset.91public:92int inline_data(void *src, size_t size) const {93masm()->align(BytesPerWord);94int offset = masm()->offset();95void *dst = masm()->pc();96masm()->advance(size);97memcpy(dst, src, size);98return offset;99}100};101102#endif // SHARE_VM_SHARK_SHARKCODEBUFFER_HPP103104105