src/share/vm/shark/sharkContext.hpp

Sat, 01 Sep 2012 13:25:18 -0400

author
coleenp
date
Sat, 01 Sep 2012 13:25:18 -0400
changeset 4037
da91efe96a93
parent 3045
a3142bdb6707
child 4314
2cd5e15048e6
permissions
-rw-r--r--

6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>

twisti@2047 1 /*
coleenp@4037 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
twisti@2047 3 * Copyright 2009, 2010 Red Hat, Inc.
twisti@2047 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
twisti@2047 5 *
twisti@2047 6 * This code is free software; you can redistribute it and/or modify it
twisti@2047 7 * under the terms of the GNU General Public License version 2 only, as
twisti@2047 8 * published by the Free Software Foundation.
twisti@2047 9 *
twisti@2047 10 * This code is distributed in the hope that it will be useful, but WITHOUT
twisti@2047 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
twisti@2047 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
twisti@2047 13 * version 2 for more details (a copy is included in the LICENSE file that
twisti@2047 14 * accompanied this code).
twisti@2047 15 *
twisti@2047 16 * You should have received a copy of the GNU General Public License version
twisti@2047 17 * 2 along with this work; if not, write to the Free Software Foundation,
twisti@2047 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
twisti@2047 19 *
twisti@2047 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
twisti@2047 21 * or visit www.oracle.com if you need additional information or have any
twisti@2047 22 * questions.
twisti@2047 23 *
twisti@2047 24 */
twisti@2047 25
stefank@2314 26 #ifndef SHARE_VM_SHARK_SHARKCONTEXT_HPP
stefank@2314 27 #define SHARE_VM_SHARK_SHARKCONTEXT_HPP
stefank@2314 28
stefank@2314 29 #include "shark/llvmHeaders.hpp"
stefank@2314 30 #include "shark/sharkCompiler.hpp"
stefank@2314 31
twisti@2047 32 // The LLVMContext class allows multiple instances of LLVM to operate
twisti@2047 33 // independently of each other in a multithreaded context. We extend
twisti@2047 34 // this here to store things in Shark that are LLVMContext-specific.
twisti@2047 35
twisti@2047 36 class SharkFreeQueueItem;
twisti@2047 37
twisti@2047 38 class SharkContext : public llvm::LLVMContext {
twisti@2047 39 public:
twisti@2047 40 SharkContext(const char* name);
twisti@2047 41
twisti@2047 42 private:
twisti@2047 43 llvm::Module* _module;
twisti@2047 44
twisti@2047 45 #if SHARK_LLVM_VERSION >= 27
twisti@2047 46 public:
twisti@2047 47 #else
twisti@2047 48 private:
twisti@2047 49 #endif
twisti@2047 50 llvm::Module* module() const {
twisti@2047 51 return _module;
twisti@2047 52 }
twisti@2047 53
twisti@2047 54 // Get this thread's SharkContext
twisti@2047 55 public:
twisti@2047 56 static SharkContext& current() {
twisti@2047 57 return *SharkCompiler::compiler()->context();
twisti@2047 58 }
twisti@2047 59
twisti@2047 60 // Module accessors
twisti@2047 61 public:
twisti@2047 62 #if SHARK_LLVM_VERSION < 27
twisti@2047 63 llvm::ModuleProvider* module_provider() const {
twisti@2047 64 return new llvm::ExistingModuleProvider(module());
twisti@2047 65 }
twisti@2047 66 #endif
twisti@2047 67 void add_function(llvm::Function* function) const {
twisti@2047 68 module()->getFunctionList().push_back(function);
twisti@2047 69 }
twisti@2047 70 llvm::Constant* get_external(const char* name,
twisti@2047 71 const llvm::FunctionType* sig) {
twisti@2047 72 return module()->getOrInsertFunction(name, sig);
twisti@2047 73 }
twisti@2047 74
twisti@2047 75 // Basic types
twisti@2047 76 private:
twisti@2047 77 const llvm::Type* _void_type;
twisti@2047 78 const llvm::IntegerType* _bit_type;
twisti@2047 79 const llvm::IntegerType* _jbyte_type;
twisti@2047 80 const llvm::IntegerType* _jshort_type;
twisti@2047 81 const llvm::IntegerType* _jint_type;
twisti@2047 82 const llvm::IntegerType* _jlong_type;
twisti@2047 83 const llvm::Type* _jfloat_type;
twisti@2047 84 const llvm::Type* _jdouble_type;
twisti@2047 85
twisti@2047 86 public:
twisti@2047 87 const llvm::Type* void_type() const {
twisti@2047 88 return _void_type;
twisti@2047 89 }
twisti@2047 90 const llvm::IntegerType* bit_type() const {
twisti@2047 91 return _bit_type;
twisti@2047 92 }
twisti@2047 93 const llvm::IntegerType* jbyte_type() const {
twisti@2047 94 return _jbyte_type;
twisti@2047 95 }
twisti@2047 96 const llvm::IntegerType* jshort_type() const {
twisti@2047 97 return _jshort_type;
twisti@2047 98 }
twisti@2047 99 const llvm::IntegerType* jint_type() const {
twisti@2047 100 return _jint_type;
twisti@2047 101 }
twisti@2047 102 const llvm::IntegerType* jlong_type() const {
twisti@2047 103 return _jlong_type;
twisti@2047 104 }
twisti@2047 105 const llvm::Type* jfloat_type() const {
twisti@2047 106 return _jfloat_type;
twisti@2047 107 }
twisti@2047 108 const llvm::Type* jdouble_type() const {
twisti@2047 109 return _jdouble_type;
twisti@2047 110 }
twisti@2047 111 const llvm::IntegerType* intptr_type() const {
twisti@2047 112 return LP64_ONLY(jlong_type()) NOT_LP64(jint_type());
twisti@2047 113 }
twisti@2047 114
twisti@2047 115 // Compound types
twisti@2047 116 private:
twisti@2047 117 const llvm::PointerType* _itableOffsetEntry_type;
twisti@2047 118 const llvm::PointerType* _jniEnv_type;
twisti@2047 119 const llvm::PointerType* _jniHandleBlock_type;
twisti@2047 120 const llvm::PointerType* _klass_type;
coleenp@4037 121 const llvm::PointerType* _Method*_type;
twisti@2047 122 const llvm::ArrayType* _monitor_type;
twisti@2047 123 const llvm::PointerType* _oop_type;
twisti@2047 124 const llvm::PointerType* _thread_type;
twisti@2047 125 const llvm::PointerType* _zeroStack_type;
twisti@2047 126 const llvm::FunctionType* _entry_point_type;
twisti@2047 127 const llvm::FunctionType* _osr_entry_point_type;
twisti@2047 128
twisti@2047 129 public:
twisti@2047 130 const llvm::PointerType* itableOffsetEntry_type() const {
twisti@2047 131 return _itableOffsetEntry_type;
twisti@2047 132 }
twisti@2047 133 const llvm::PointerType* jniEnv_type() const {
twisti@2047 134 return _jniEnv_type;
twisti@2047 135 }
twisti@2047 136 const llvm::PointerType* jniHandleBlock_type() const {
twisti@2047 137 return _jniHandleBlock_type;
twisti@2047 138 }
twisti@2047 139 const llvm::PointerType* klass_type() const {
twisti@2047 140 return _klass_type;
twisti@2047 141 }
coleenp@4037 142 const llvm::PointerType* Method*_type() const {
coleenp@4037 143 return _Method*_type;
twisti@2047 144 }
twisti@2047 145 const llvm::ArrayType* monitor_type() const {
twisti@2047 146 return _monitor_type;
twisti@2047 147 }
twisti@2047 148 const llvm::PointerType* oop_type() const {
twisti@2047 149 return _oop_type;
twisti@2047 150 }
twisti@2047 151 const llvm::PointerType* thread_type() const {
twisti@2047 152 return _thread_type;
twisti@2047 153 }
twisti@2047 154 const llvm::PointerType* zeroStack_type() const {
twisti@2047 155 return _zeroStack_type;
twisti@2047 156 }
twisti@2047 157 const llvm::FunctionType* entry_point_type() const {
twisti@2047 158 return _entry_point_type;
twisti@2047 159 }
twisti@2047 160 const llvm::FunctionType* osr_entry_point_type() const {
twisti@2047 161 return _osr_entry_point_type;
twisti@2047 162 }
twisti@2047 163
twisti@2047 164 // Mappings
twisti@2047 165 private:
twisti@2047 166 const llvm::Type* _to_stackType[T_CONFLICT];
twisti@2047 167 const llvm::Type* _to_arrayType[T_CONFLICT];
twisti@2047 168
twisti@2047 169 private:
twisti@2047 170 const llvm::Type* map_type(const llvm::Type* const* table,
twisti@2047 171 BasicType type) const {
twisti@2047 172 assert(type >= 0 && type < T_CONFLICT, "unhandled type");
twisti@2047 173 const llvm::Type* result = table[type];
twisti@3045 174 assert(result != NULL, "unhandled type");
twisti@2047 175 return result;
twisti@2047 176 }
twisti@2047 177
twisti@2047 178 public:
twisti@2047 179 const llvm::Type* to_stackType(BasicType type) const {
twisti@2047 180 return map_type(_to_stackType, type);
twisti@2047 181 }
twisti@2047 182 const llvm::Type* to_arrayType(BasicType type) const {
twisti@2047 183 return map_type(_to_arrayType, type);
twisti@2047 184 }
twisti@2047 185
twisti@2047 186 // Functions queued for freeing
twisti@2047 187 private:
twisti@2047 188 SharkFreeQueueItem* _free_queue;
twisti@2047 189
twisti@2047 190 public:
twisti@2047 191 void push_to_free_queue(llvm::Function* function);
twisti@2047 192 llvm::Function* pop_from_free_queue();
twisti@2047 193 };
stefank@2314 194
stefank@2314 195 #endif // SHARE_VM_SHARK_SHARKCONTEXT_HPP

mercurial