Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkMemoryManager.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_SHARKMEMORYMANAGER_HPP26#define SHARE_VM_SHARK_SHARKMEMORYMANAGER_HPP2728#include "shark/llvmHeaders.hpp"29#include "shark/sharkEntry.hpp"3031// SharkMemoryManager wraps the LLVM JIT Memory Manager. We could use32// this to run our own memory allocation policies, but for now all we33// use it for is figuring out where the resulting native code ended up.3435class SharkMemoryManager : public llvm::JITMemoryManager {36public:37SharkMemoryManager()38: _mm(llvm::JITMemoryManager::CreateDefaultMemManager()) {}3940private:41llvm::JITMemoryManager* _mm;4243private:44llvm::JITMemoryManager* mm() const {45return _mm;46}4748private:49std::map<const llvm::Function*, SharkEntry*> _entry_map;5051public:52void set_entry_for_function(const llvm::Function* function,53SharkEntry* entry) {54_entry_map[function] = entry;55}56SharkEntry* get_entry_for_function(const llvm::Function* function) {57return _entry_map[function];58}5960public:61void AllocateGOT();62unsigned char* getGOTBase() const;63unsigned char* allocateStub(const llvm::GlobalValue* F,64unsigned StubSize,65unsigned Alignment);66unsigned char* startFunctionBody(const llvm::Function* F,67uintptr_t& ActualSize);68void endFunctionBody(const llvm::Function* F,69unsigned char* FunctionStart,70unsigned char* FunctionEnd);7172void *getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure = true);73void setPoisonMemory(bool);74uint8_t* allocateGlobal(uintptr_t, unsigned int);75void setMemoryWritable();76void setMemoryExecutable();77void deallocateFunctionBody(void *ptr);78unsigned char *allocateSpace(intptr_t Size,79unsigned int Alignment);8081#if SHARK_LLVM_VERSION <= 3282uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID);83uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID);84unsigned char* startExceptionTable(const llvm::Function* F,85uintptr_t& ActualSize);86void deallocateExceptionTable(void *ptr);87void endExceptionTable(const llvm::Function* F,88unsigned char* TableStart,89unsigned char* TableEnd,90unsigned char* FrameRegister);91#else92uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, llvm::StringRef SectionName);93uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, llvm::StringRef SectionName, bool IsReadOnly);94bool finalizeMemory(std::string *ErrMsg = 0);95#endif9697};9899#endif // SHARE_VM_SHARK_SHARKMEMORYMANAGER_HPP100101102