src/share/vm/shark/sharkContext.hpp

Tue, 18 Jun 2013 12:31:07 -0700

author
johnc
date
Tue, 18 Jun 2013 12:31:07 -0700
changeset 5277
01522ca68fc7
parent 4314
2cd5e15048e6
child 6876
710a3c8b516e
permissions
-rw-r--r--

8015237: Parallelize string table scanning during strong root processing
Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>.
Reviewed-by: tschatzl, stefank, twisti

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 public:
twisti@2047 46 llvm::Module* module() const {
twisti@2047 47 return _module;
twisti@2047 48 }
twisti@2047 49
twisti@2047 50 // Get this thread's SharkContext
twisti@2047 51 public:
twisti@2047 52 static SharkContext& current() {
twisti@2047 53 return *SharkCompiler::compiler()->context();
twisti@2047 54 }
twisti@2047 55
twisti@2047 56 // Module accessors
twisti@2047 57 public:
twisti@2047 58 void add_function(llvm::Function* function) const {
twisti@2047 59 module()->getFunctionList().push_back(function);
twisti@2047 60 }
twisti@2047 61 llvm::Constant* get_external(const char* name,
twisti@4314 62 llvm::FunctionType* sig) {
twisti@2047 63 return module()->getOrInsertFunction(name, sig);
twisti@2047 64 }
twisti@2047 65
twisti@2047 66 // Basic types
twisti@2047 67 private:
twisti@4314 68 llvm::Type* _void_type;
twisti@4314 69 llvm::IntegerType* _bit_type;
twisti@4314 70 llvm::IntegerType* _jbyte_type;
twisti@4314 71 llvm::IntegerType* _jshort_type;
twisti@4314 72 llvm::IntegerType* _jint_type;
twisti@4314 73 llvm::IntegerType* _jlong_type;
twisti@4314 74 llvm::Type* _jfloat_type;
twisti@4314 75 llvm::Type* _jdouble_type;
twisti@2047 76
twisti@2047 77 public:
twisti@4314 78 llvm::Type* void_type() const {
twisti@2047 79 return _void_type;
twisti@2047 80 }
twisti@4314 81 llvm::IntegerType* bit_type() const {
twisti@2047 82 return _bit_type;
twisti@2047 83 }
twisti@4314 84 llvm::IntegerType* jbyte_type() const {
twisti@2047 85 return _jbyte_type;
twisti@2047 86 }
twisti@4314 87 llvm::IntegerType* jshort_type() const {
twisti@2047 88 return _jshort_type;
twisti@2047 89 }
twisti@4314 90 llvm::IntegerType* jint_type() const {
twisti@2047 91 return _jint_type;
twisti@2047 92 }
twisti@4314 93 llvm::IntegerType* jlong_type() const {
twisti@2047 94 return _jlong_type;
twisti@2047 95 }
twisti@4314 96 llvm::Type* jfloat_type() const {
twisti@2047 97 return _jfloat_type;
twisti@2047 98 }
twisti@4314 99 llvm::Type* jdouble_type() const {
twisti@2047 100 return _jdouble_type;
twisti@2047 101 }
twisti@4314 102 llvm::IntegerType* intptr_type() const {
twisti@2047 103 return LP64_ONLY(jlong_type()) NOT_LP64(jint_type());
twisti@2047 104 }
twisti@2047 105
twisti@2047 106 // Compound types
twisti@2047 107 private:
twisti@4314 108 llvm::PointerType* _itableOffsetEntry_type;
twisti@4314 109 llvm::PointerType* _jniEnv_type;
twisti@4314 110 llvm::PointerType* _jniHandleBlock_type;
twisti@4314 111 llvm::PointerType* _Metadata_type;
twisti@4314 112 llvm::PointerType* _klass_type;
twisti@4314 113 llvm::PointerType* _Method_type;
twisti@4314 114 llvm::ArrayType* _monitor_type;
twisti@4314 115 llvm::PointerType* _oop_type;
twisti@4314 116 llvm::PointerType* _thread_type;
twisti@4314 117 llvm::PointerType* _zeroStack_type;
twisti@4314 118 llvm::FunctionType* _entry_point_type;
twisti@4314 119 llvm::FunctionType* _osr_entry_point_type;
twisti@2047 120
twisti@2047 121 public:
twisti@4314 122 llvm::PointerType* itableOffsetEntry_type() const {
twisti@2047 123 return _itableOffsetEntry_type;
twisti@2047 124 }
twisti@4314 125 llvm::PointerType* jniEnv_type() const {
twisti@2047 126 return _jniEnv_type;
twisti@2047 127 }
twisti@4314 128 llvm::PointerType* jniHandleBlock_type() const {
twisti@2047 129 return _jniHandleBlock_type;
twisti@2047 130 }
twisti@4314 131 llvm::PointerType* Metadata_type() const {
twisti@4314 132 return _Metadata_type;
twisti@4314 133 }
twisti@4314 134 llvm::PointerType* klass_type() const {
twisti@2047 135 return _klass_type;
twisti@2047 136 }
twisti@4314 137 llvm::PointerType* Method_type() const {
twisti@4314 138 return _Method_type;
twisti@2047 139 }
twisti@4314 140 llvm::ArrayType* monitor_type() const {
twisti@2047 141 return _monitor_type;
twisti@2047 142 }
twisti@4314 143 llvm::PointerType* oop_type() const {
twisti@2047 144 return _oop_type;
twisti@2047 145 }
twisti@4314 146 llvm::PointerType* thread_type() const {
twisti@2047 147 return _thread_type;
twisti@2047 148 }
twisti@4314 149 llvm::PointerType* zeroStack_type() const {
twisti@2047 150 return _zeroStack_type;
twisti@2047 151 }
twisti@4314 152 llvm::FunctionType* entry_point_type() const {
twisti@2047 153 return _entry_point_type;
twisti@2047 154 }
twisti@4314 155 llvm::FunctionType* osr_entry_point_type() const {
twisti@2047 156 return _osr_entry_point_type;
twisti@2047 157 }
twisti@2047 158
twisti@2047 159 // Mappings
twisti@2047 160 private:
twisti@4314 161 llvm::Type* _to_stackType[T_CONFLICT];
twisti@4314 162 llvm::Type* _to_arrayType[T_CONFLICT];
twisti@2047 163
twisti@2047 164 private:
twisti@4314 165 llvm::Type* map_type(llvm::Type* const* table,
twisti@2047 166 BasicType type) const {
twisti@2047 167 assert(type >= 0 && type < T_CONFLICT, "unhandled type");
twisti@4314 168 llvm::Type* result = table[type];
twisti@3045 169 assert(result != NULL, "unhandled type");
twisti@2047 170 return result;
twisti@2047 171 }
twisti@2047 172
twisti@2047 173 public:
twisti@4314 174 llvm::Type* to_stackType(BasicType type) const {
twisti@2047 175 return map_type(_to_stackType, type);
twisti@2047 176 }
twisti@4314 177 llvm::Type* to_arrayType(BasicType type) const {
twisti@2047 178 return map_type(_to_arrayType, type);
twisti@2047 179 }
twisti@2047 180
twisti@2047 181 // Functions queued for freeing
twisti@2047 182 private:
twisti@2047 183 SharkFreeQueueItem* _free_queue;
twisti@2047 184
twisti@2047 185 public:
twisti@2047 186 void push_to_free_queue(llvm::Function* function);
twisti@2047 187 llvm::Function* pop_from_free_queue();
twisti@2047 188 };
stefank@2314 189
stefank@2314 190 #endif // SHARE_VM_SHARK_SHARKCONTEXT_HPP

mercurial