Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkContext.hpp
32285 views
/*1* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.2* Copyright 2009, 2010 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_SHARKCONTEXT_HPP26#define SHARE_VM_SHARK_SHARKCONTEXT_HPP2728#include "shark/llvmHeaders.hpp"29#include "shark/sharkCompiler.hpp"3031// The LLVMContext class allows multiple instances of LLVM to operate32// independently of each other in a multithreaded context. We extend33// this here to store things in Shark that are LLVMContext-specific.3435class SharkFreeQueueItem;3637class SharkContext : public llvm::LLVMContext {38public:39SharkContext(const char* name);4041private:42llvm::Module* _module;4344public:45llvm::Module* module() const {46return _module;47}4849// Get this thread's SharkContext50public:51static SharkContext& current() {52return *SharkCompiler::compiler()->context();53}5455// Module accessors56public:57void add_function(llvm::Function* function) const {58module()->getFunctionList().push_back(function);59}60llvm::Constant* get_external(const char* name,61llvm::FunctionType* sig) {62return module()->getOrInsertFunction(name, sig);63}6465// Basic types66private:67llvm::Type* _void_type;68llvm::IntegerType* _bit_type;69llvm::IntegerType* _jbyte_type;70llvm::IntegerType* _jshort_type;71llvm::IntegerType* _jint_type;72llvm::IntegerType* _jlong_type;73llvm::Type* _jfloat_type;74llvm::Type* _jdouble_type;7576public:77llvm::Type* void_type() const {78return _void_type;79}80llvm::IntegerType* bit_type() const {81return _bit_type;82}83llvm::IntegerType* jbyte_type() const {84return _jbyte_type;85}86llvm::IntegerType* jshort_type() const {87return _jshort_type;88}89llvm::IntegerType* jint_type() const {90return _jint_type;91}92llvm::IntegerType* jlong_type() const {93return _jlong_type;94}95llvm::Type* jfloat_type() const {96return _jfloat_type;97}98llvm::Type* jdouble_type() const {99return _jdouble_type;100}101llvm::IntegerType* intptr_type() const {102return LP64_ONLY(jlong_type()) NOT_LP64(jint_type());103}104105// Compound types106private:107llvm::PointerType* _itableOffsetEntry_type;108llvm::PointerType* _jniEnv_type;109llvm::PointerType* _jniHandleBlock_type;110llvm::PointerType* _Metadata_type;111llvm::PointerType* _klass_type;112llvm::PointerType* _Method_type;113llvm::ArrayType* _monitor_type;114llvm::PointerType* _oop_type;115llvm::PointerType* _thread_type;116llvm::PointerType* _zeroStack_type;117llvm::FunctionType* _entry_point_type;118llvm::FunctionType* _osr_entry_point_type;119120public:121llvm::PointerType* itableOffsetEntry_type() const {122return _itableOffsetEntry_type;123}124llvm::PointerType* jniEnv_type() const {125return _jniEnv_type;126}127llvm::PointerType* jniHandleBlock_type() const {128return _jniHandleBlock_type;129}130llvm::PointerType* Metadata_type() const {131return _Metadata_type;132}133llvm::PointerType* klass_type() const {134return _klass_type;135}136llvm::PointerType* Method_type() const {137return _Method_type;138}139llvm::ArrayType* monitor_type() const {140return _monitor_type;141}142llvm::PointerType* oop_type() const {143return _oop_type;144}145llvm::PointerType* thread_type() const {146return _thread_type;147}148llvm::PointerType* zeroStack_type() const {149return _zeroStack_type;150}151llvm::FunctionType* entry_point_type() const {152return _entry_point_type;153}154llvm::FunctionType* osr_entry_point_type() const {155return _osr_entry_point_type;156}157158// Mappings159private:160llvm::Type* _to_stackType[T_CONFLICT];161llvm::Type* _to_arrayType[T_CONFLICT];162163private:164llvm::Type* map_type(llvm::Type* const* table,165BasicType type) const {166assert(type >= 0 && type < T_CONFLICT, "unhandled type");167llvm::Type* result = table[type];168assert(result != NULL, "unhandled type");169return result;170}171172public:173llvm::Type* to_stackType(BasicType type) const {174return map_type(_to_stackType, type);175}176llvm::Type* to_arrayType(BasicType type) const {177return map_type(_to_arrayType, type);178}179180// Functions queued for freeing181private:182SharkFreeQueueItem* _free_queue;183184public:185void push_to_free_queue(llvm::Function* function);186llvm::Function* pop_from_free_queue();187};188189#endif // SHARE_VM_SHARK_SHARKCONTEXT_HPP190191192