Tue, 18 Jun 2013 12:31:07 -0700
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 | /* |
stefank@2314 | 2 | * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
twisti@2047 | 3 | * Copyright 2008, 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_SHARKBUILDER_HPP |
stefank@2314 | 27 | #define SHARE_VM_SHARK_SHARKBUILDER_HPP |
stefank@2314 | 28 | |
stefank@2314 | 29 | #include "ci/ciType.hpp" |
stefank@2314 | 30 | #include "memory/barrierSet.hpp" |
stefank@2314 | 31 | #include "memory/cardTableModRefBS.hpp" |
stefank@2314 | 32 | #include "shark/llvmHeaders.hpp" |
stefank@2314 | 33 | #include "shark/llvmValue.hpp" |
stefank@2314 | 34 | #include "shark/sharkCodeBuffer.hpp" |
stefank@2314 | 35 | #include "shark/sharkEntry.hpp" |
stefank@2314 | 36 | #include "shark/sharkType.hpp" |
stefank@2314 | 37 | #include "shark/sharkValue.hpp" |
stefank@2314 | 38 | #include "utilities/debug.hpp" |
stefank@2314 | 39 | #include "utilities/sizes.hpp" |
stefank@2314 | 40 | |
twisti@2047 | 41 | class SharkBuilder : public llvm::IRBuilder<> { |
twisti@2047 | 42 | friend class SharkCompileInvariants; |
twisti@2047 | 43 | |
twisti@2047 | 44 | public: |
twisti@2047 | 45 | SharkBuilder(SharkCodeBuffer* code_buffer); |
twisti@2047 | 46 | |
twisti@2047 | 47 | // The code buffer we are building into. |
twisti@2047 | 48 | private: |
twisti@2047 | 49 | SharkCodeBuffer* _code_buffer; |
twisti@2047 | 50 | |
twisti@2047 | 51 | protected: |
twisti@2047 | 52 | SharkCodeBuffer* code_buffer() const { |
twisti@2047 | 53 | return _code_buffer; |
twisti@2047 | 54 | } |
twisti@2047 | 55 | |
twisti@4314 | 56 | public: |
twisti@4314 | 57 | llvm::LoadInst* CreateAtomicLoad(llvm::Value* ptr, |
twisti@4314 | 58 | unsigned align = HeapWordSize, |
twisti@4314 | 59 | llvm::AtomicOrdering ordering = llvm::SequentiallyConsistent, |
twisti@4314 | 60 | llvm::SynchronizationScope synchScope = llvm::CrossThread, |
twisti@4314 | 61 | bool isVolatile = true, |
twisti@4314 | 62 | const char *name = ""); |
twisti@4314 | 63 | llvm::StoreInst* CreateAtomicStore(llvm::Value *val, |
twisti@4314 | 64 | llvm::Value *ptr, |
twisti@4314 | 65 | unsigned align = HeapWordSize, |
twisti@4314 | 66 | llvm::AtomicOrdering ordering = llvm::SequentiallyConsistent, |
twisti@4314 | 67 | llvm::SynchronizationScope SynchScope = llvm::CrossThread, |
twisti@4314 | 68 | bool isVolatile = true, |
twisti@4314 | 69 | const char *name = ""); |
twisti@4314 | 70 | |
twisti@2047 | 71 | // Helpers for accessing structures. |
twisti@2047 | 72 | public: |
twisti@2047 | 73 | llvm::Value* CreateAddressOfStructEntry(llvm::Value* base, |
twisti@2047 | 74 | ByteSize offset, |
twisti@4314 | 75 | llvm::Type* type, |
twisti@2047 | 76 | const char *name = ""); |
twisti@2047 | 77 | llvm::LoadInst* CreateValueOfStructEntry(llvm::Value* base, |
twisti@2047 | 78 | ByteSize offset, |
twisti@4314 | 79 | llvm::Type* type, |
twisti@2047 | 80 | const char *name = ""); |
twisti@2047 | 81 | |
twisti@2047 | 82 | // Helpers for accessing arrays. |
twisti@2047 | 83 | public: |
twisti@2047 | 84 | llvm::LoadInst* CreateArrayLength(llvm::Value* arrayoop); |
twisti@2047 | 85 | llvm::Value* CreateArrayAddress(llvm::Value* arrayoop, |
twisti@4314 | 86 | llvm::Type* element_type, |
twisti@2047 | 87 | int element_bytes, |
twisti@2047 | 88 | ByteSize base_offset, |
twisti@2047 | 89 | llvm::Value* index, |
twisti@2047 | 90 | const char* name = ""); |
twisti@2047 | 91 | llvm::Value* CreateArrayAddress(llvm::Value* arrayoop, |
twisti@2047 | 92 | BasicType basic_type, |
twisti@2047 | 93 | ByteSize base_offset, |
twisti@2047 | 94 | llvm::Value* index, |
twisti@2047 | 95 | const char* name = ""); |
twisti@2047 | 96 | llvm::Value* CreateArrayAddress(llvm::Value* arrayoop, |
twisti@2047 | 97 | BasicType basic_type, |
twisti@2047 | 98 | llvm::Value* index, |
twisti@2047 | 99 | const char* name = ""); |
twisti@2047 | 100 | |
twisti@2047 | 101 | // Helpers for creating intrinsics and external functions. |
twisti@2047 | 102 | private: |
twisti@4314 | 103 | static llvm::Type* make_type(char type, bool void_ok); |
twisti@4314 | 104 | static llvm::FunctionType* make_ftype(const char* params, |
twisti@2047 | 105 | const char* ret); |
twisti@2047 | 106 | llvm::Value* make_function(const char* name, |
twisti@2047 | 107 | const char* params, |
twisti@2047 | 108 | const char* ret); |
twisti@2047 | 109 | llvm::Value* make_function(address func, |
twisti@2047 | 110 | const char* params, |
twisti@2047 | 111 | const char* ret); |
twisti@2047 | 112 | |
twisti@2047 | 113 | // Intrinsics and external functions, part 1: VM calls. |
twisti@2047 | 114 | // These are functions declared with JRT_ENTRY and JRT_EXIT, |
twisti@2047 | 115 | // macros which flip the thread from _thread_in_Java to |
twisti@2047 | 116 | // _thread_in_vm and back. VM calls always safepoint, and can |
twisti@2047 | 117 | // therefore throw exceptions. VM calls require of setup and |
twisti@2047 | 118 | // teardown, and must be called with SharkTopLevelBlock::call_vm. |
twisti@2047 | 119 | public: |
twisti@2047 | 120 | llvm::Value* find_exception_handler(); |
twisti@2047 | 121 | llvm::Value* monitorenter(); |
twisti@2047 | 122 | llvm::Value* monitorexit(); |
twisti@2047 | 123 | llvm::Value* new_instance(); |
twisti@2047 | 124 | llvm::Value* newarray(); |
twisti@2047 | 125 | llvm::Value* anewarray(); |
twisti@2047 | 126 | llvm::Value* multianewarray(); |
twisti@2047 | 127 | llvm::Value* register_finalizer(); |
twisti@2047 | 128 | llvm::Value* safepoint(); |
twisti@2047 | 129 | llvm::Value* throw_ArithmeticException(); |
twisti@2047 | 130 | llvm::Value* throw_ArrayIndexOutOfBoundsException(); |
twisti@2047 | 131 | llvm::Value* throw_ClassCastException(); |
twisti@2047 | 132 | llvm::Value* throw_NullPointerException(); |
twisti@2047 | 133 | |
twisti@2047 | 134 | // Intrinsics and external functions, part 2: High-level non-VM calls. |
twisti@2047 | 135 | // These are called like normal functions. The stack is not set |
twisti@2047 | 136 | // up for walking so they must not safepoint or throw exceptions, |
twisti@2047 | 137 | // or call anything that might. |
twisti@2047 | 138 | public: |
twisti@2047 | 139 | llvm::Value* f2i(); |
twisti@2047 | 140 | llvm::Value* f2l(); |
twisti@2047 | 141 | llvm::Value* d2i(); |
twisti@2047 | 142 | llvm::Value* d2l(); |
twisti@2047 | 143 | llvm::Value* is_subtype_of(); |
twisti@2047 | 144 | llvm::Value* current_time_millis(); |
twisti@2047 | 145 | llvm::Value* sin(); |
twisti@2047 | 146 | llvm::Value* cos(); |
twisti@2047 | 147 | llvm::Value* tan(); |
twisti@2047 | 148 | llvm::Value* atan2(); |
twisti@2047 | 149 | llvm::Value* sqrt(); |
twisti@2047 | 150 | llvm::Value* log(); |
twisti@2047 | 151 | llvm::Value* log10(); |
twisti@2047 | 152 | llvm::Value* pow(); |
twisti@2047 | 153 | llvm::Value* exp(); |
twisti@2047 | 154 | llvm::Value* fabs(); |
twisti@2047 | 155 | llvm::Value* unsafe_field_offset_to_byte_offset(); |
twisti@2047 | 156 | llvm::Value* osr_migration_end(); |
twisti@2047 | 157 | |
twisti@2047 | 158 | // Intrinsics and external functions, part 3: semi-VM calls. |
twisti@2047 | 159 | // These are special cases that do VM call stuff but are invoked |
twisti@2047 | 160 | // as though they were normal calls. This is acceptable so long |
twisti@2047 | 161 | // as the method that calls them returns to its immediately that |
twisti@2047 | 162 | // the semi VM call returns. |
twisti@2047 | 163 | public: |
twisti@2047 | 164 | llvm::Value* throw_StackOverflowError(); |
twisti@2047 | 165 | llvm::Value* uncommon_trap(); |
twisti@2047 | 166 | llvm::Value* deoptimized_entry_point(); |
twisti@2047 | 167 | |
twisti@2047 | 168 | // Intrinsics and external functions, part 4: Native-Java transition. |
twisti@2047 | 169 | // This is a special case in that it is invoked during a thread |
twisti@2047 | 170 | // state transition. The stack must be set up for walking, and it |
twisti@2047 | 171 | // may throw exceptions, but the state is _thread_in_native_trans. |
twisti@2047 | 172 | public: |
twisti@2047 | 173 | llvm::Value* check_special_condition_for_native_trans(); |
twisti@2047 | 174 | |
twisti@2047 | 175 | // Intrinsics and external functions, part 5: Low-level non-VM calls. |
twisti@2047 | 176 | // These have the same caveats as the high-level non-VM calls |
twisti@2047 | 177 | // above. They are not accessed directly; rather, you should |
twisti@2047 | 178 | // access them via the various Create* methods below. |
twisti@2047 | 179 | private: |
twisti@2047 | 180 | llvm::Value* cmpxchg_int(); |
twisti@2047 | 181 | llvm::Value* cmpxchg_ptr(); |
twisti@2047 | 182 | llvm::Value* frame_address(); |
twisti@2047 | 183 | llvm::Value* memset(); |
twisti@2047 | 184 | llvm::Value* unimplemented(); |
twisti@2047 | 185 | llvm::Value* should_not_reach_here(); |
twisti@2047 | 186 | llvm::Value* dump(); |
twisti@2047 | 187 | |
twisti@2047 | 188 | // Public interface to low-level non-VM calls. |
twisti@2047 | 189 | public: |
twisti@2047 | 190 | llvm::CallInst* CreateGetFrameAddress(); |
twisti@2047 | 191 | llvm::CallInst* CreateMemset(llvm::Value* dst, |
twisti@2047 | 192 | llvm::Value* value, |
twisti@2047 | 193 | llvm::Value* len, |
twisti@2047 | 194 | llvm::Value* align); |
twisti@2047 | 195 | llvm::CallInst* CreateUnimplemented(const char* file, int line); |
twisti@2047 | 196 | llvm::CallInst* CreateShouldNotReachHere(const char* file, int line); |
twisti@2047 | 197 | NOT_PRODUCT(llvm::CallInst* CreateDump(llvm::Value* value)); |
twisti@2047 | 198 | |
twisti@2047 | 199 | // HotSpot memory barriers |
twisti@2047 | 200 | public: |
twisti@2047 | 201 | void CreateUpdateBarrierSet(BarrierSet* bs, llvm::Value* field); |
twisti@2047 | 202 | |
twisti@2047 | 203 | // Helpers for accessing the code buffer. |
twisti@2047 | 204 | public: |
twisti@2047 | 205 | llvm::Value* code_buffer_address(int offset); |
twisti@2047 | 206 | llvm::Value* CreateInlineOop(jobject object, const char* name = ""); |
twisti@2047 | 207 | llvm::Value* CreateInlineOop(ciObject* object, const char* name = "") { |
twisti@2047 | 208 | return CreateInlineOop(object->constant_encoding(), name); |
twisti@2047 | 209 | } |
twisti@4314 | 210 | |
twisti@4314 | 211 | llvm::Value* CreateInlineMetadata(Metadata* metadata, llvm::PointerType* type, const char* name = ""); |
twisti@4314 | 212 | llvm::Value* CreateInlineMetadata(ciMetadata* metadata, llvm::PointerType* type, const char* name = "") { |
twisti@4314 | 213 | return CreateInlineMetadata(metadata->constant_encoding(), type, name); |
twisti@4314 | 214 | } |
twisti@2047 | 215 | llvm::Value* CreateInlineData(void* data, |
twisti@2047 | 216 | size_t size, |
twisti@4314 | 217 | llvm::Type* type, |
twisti@2047 | 218 | const char* name = ""); |
twisti@2047 | 219 | |
twisti@2047 | 220 | // Helpers for creating basic blocks. |
twisti@2047 | 221 | // NB don't use unless SharkFunction::CreateBlock is unavailable. |
twisti@2047 | 222 | // XXX these are hacky and should be removed. |
twisti@2047 | 223 | public: |
twisti@2047 | 224 | llvm::BasicBlock* GetBlockInsertionPoint() const; |
twisti@2047 | 225 | llvm::BasicBlock* CreateBlock(llvm::BasicBlock* ip, |
twisti@2047 | 226 | const char* name="") const; |
twisti@2047 | 227 | }; |
twisti@4314 | 228 | #endif // SHARE_VM_SHARK_SHARKBUILDER_HPP |