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 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_SHARKSTATE_HPP |
stefank@2314 | 27 | #define SHARE_VM_SHARK_SHARKSTATE_HPP |
stefank@2314 | 28 | |
stefank@2314 | 29 | #include "ci/ciMethod.hpp" |
stefank@2314 | 30 | #include "memory/allocation.hpp" |
stefank@2314 | 31 | #include "shark/llvmHeaders.hpp" |
stefank@2314 | 32 | #include "shark/sharkBuilder.hpp" |
stefank@2314 | 33 | #include "shark/sharkInvariants.hpp" |
stefank@2314 | 34 | #include "shark/sharkValue.hpp" |
stefank@2314 | 35 | |
twisti@2047 | 36 | class SharkState : public SharkTargetInvariants { |
twisti@2047 | 37 | public: |
twisti@2047 | 38 | SharkState(const SharkTargetInvariants* parent) |
twisti@2047 | 39 | : SharkTargetInvariants(parent), |
twisti@2047 | 40 | _method(NULL), |
twisti@2047 | 41 | _oop_tmp(NULL), |
twisti@2047 | 42 | _has_safepointed(false) { initialize(NULL); } |
twisti@2047 | 43 | |
twisti@2047 | 44 | SharkState(const SharkState* state) |
twisti@2047 | 45 | : SharkTargetInvariants(state), |
twisti@2047 | 46 | _method(state->_method), |
twisti@2047 | 47 | _oop_tmp(state->_oop_tmp), |
twisti@2047 | 48 | _has_safepointed(state->_has_safepointed) { initialize(state); } |
twisti@2047 | 49 | |
twisti@2047 | 50 | private: |
twisti@2047 | 51 | void initialize(const SharkState* state); |
twisti@2047 | 52 | |
twisti@2047 | 53 | private: |
twisti@2047 | 54 | llvm::Value* _method; |
twisti@2047 | 55 | SharkValue** _locals; |
twisti@2047 | 56 | SharkValue** _stack; |
twisti@2047 | 57 | SharkValue** _sp; |
twisti@2047 | 58 | int _num_monitors; |
twisti@2047 | 59 | llvm::Value* _oop_tmp; |
twisti@2047 | 60 | bool _has_safepointed; |
twisti@2047 | 61 | |
twisti@2047 | 62 | // Method |
twisti@2047 | 63 | public: |
twisti@2047 | 64 | llvm::Value** method_addr() { |
twisti@2047 | 65 | return &_method; |
twisti@2047 | 66 | } |
twisti@2047 | 67 | llvm::Value* method() const { |
twisti@2047 | 68 | return _method; |
twisti@2047 | 69 | } |
twisti@2047 | 70 | protected: |
twisti@2047 | 71 | void set_method(llvm::Value* method) { |
twisti@2047 | 72 | _method = method; |
twisti@2047 | 73 | } |
twisti@2047 | 74 | |
twisti@2047 | 75 | // Local variables |
twisti@2047 | 76 | public: |
twisti@2047 | 77 | SharkValue** local_addr(int index) const { |
twisti@2047 | 78 | assert(index >= 0 && index < max_locals(), "bad local variable index"); |
twisti@2047 | 79 | return &_locals[index]; |
twisti@2047 | 80 | } |
twisti@2047 | 81 | SharkValue* local(int index) const { |
twisti@2047 | 82 | return *local_addr(index); |
twisti@2047 | 83 | } |
twisti@2047 | 84 | void set_local(int index, SharkValue* value) { |
twisti@2047 | 85 | *local_addr(index) = value; |
twisti@2047 | 86 | } |
twisti@2047 | 87 | |
twisti@2047 | 88 | // Expression stack |
twisti@2047 | 89 | public: |
twisti@2047 | 90 | SharkValue** stack_addr(int slot) const { |
twisti@2047 | 91 | assert(slot >= 0 && slot < stack_depth(), "bad stack slot"); |
twisti@2047 | 92 | return &_sp[-(slot + 1)]; |
twisti@2047 | 93 | } |
twisti@2047 | 94 | SharkValue* stack(int slot) const { |
twisti@2047 | 95 | return *stack_addr(slot); |
twisti@2047 | 96 | } |
twisti@2047 | 97 | protected: |
twisti@2047 | 98 | void set_stack(int slot, SharkValue* value) { |
twisti@2047 | 99 | *stack_addr(slot) = value; |
twisti@2047 | 100 | } |
twisti@2047 | 101 | public: |
twisti@2047 | 102 | int stack_depth() const { |
twisti@2047 | 103 | return _sp - _stack; |
twisti@2047 | 104 | } |
twisti@2047 | 105 | void push(SharkValue* value) { |
twisti@2047 | 106 | assert(stack_depth() < max_stack(), "stack overrun"); |
twisti@2047 | 107 | *(_sp++) = value; |
twisti@2047 | 108 | } |
twisti@2047 | 109 | SharkValue* pop() { |
twisti@2047 | 110 | assert(stack_depth() > 0, "stack underrun"); |
twisti@2047 | 111 | return *(--_sp); |
twisti@2047 | 112 | } |
twisti@2047 | 113 | |
twisti@2047 | 114 | // Monitors |
twisti@2047 | 115 | public: |
twisti@2047 | 116 | int num_monitors() const { |
twisti@2047 | 117 | return _num_monitors; |
twisti@2047 | 118 | } |
twisti@2047 | 119 | void set_num_monitors(int num_monitors) { |
twisti@2047 | 120 | _num_monitors = num_monitors; |
twisti@2047 | 121 | } |
twisti@2047 | 122 | |
twisti@2047 | 123 | // Temporary oop slot |
twisti@2047 | 124 | public: |
twisti@2047 | 125 | llvm::Value** oop_tmp_addr() { |
twisti@2047 | 126 | return &_oop_tmp; |
twisti@2047 | 127 | } |
twisti@2047 | 128 | llvm::Value* oop_tmp() const { |
twisti@2047 | 129 | return _oop_tmp; |
twisti@2047 | 130 | } |
twisti@2047 | 131 | void set_oop_tmp(llvm::Value* oop_tmp) { |
twisti@2047 | 132 | _oop_tmp = oop_tmp; |
twisti@2047 | 133 | } |
twisti@2047 | 134 | |
twisti@2047 | 135 | // Safepointed status |
twisti@2047 | 136 | public: |
twisti@2047 | 137 | bool has_safepointed() const { |
twisti@2047 | 138 | return _has_safepointed; |
twisti@2047 | 139 | } |
twisti@2047 | 140 | void set_has_safepointed(bool has_safepointed) { |
twisti@2047 | 141 | _has_safepointed = has_safepointed; |
twisti@2047 | 142 | } |
twisti@2047 | 143 | |
twisti@2047 | 144 | // Comparison |
twisti@2047 | 145 | public: |
twisti@2047 | 146 | bool equal_to(SharkState* other); |
twisti@2047 | 147 | |
twisti@2047 | 148 | // Copy and merge |
twisti@2047 | 149 | public: |
twisti@2047 | 150 | SharkState* copy() const { |
twisti@2047 | 151 | return new SharkState(this); |
twisti@2047 | 152 | } |
twisti@2047 | 153 | void merge(SharkState* other, |
twisti@2047 | 154 | llvm::BasicBlock* other_block, |
twisti@2047 | 155 | llvm::BasicBlock* this_block); |
twisti@2047 | 156 | |
twisti@2047 | 157 | // Value replacement |
twisti@2047 | 158 | public: |
twisti@2047 | 159 | void replace_all(SharkValue* old_value, SharkValue* new_value); |
twisti@2047 | 160 | }; |
twisti@2047 | 161 | |
twisti@2047 | 162 | class SharkTopLevelBlock; |
twisti@2047 | 163 | |
twisti@2047 | 164 | // SharkNormalEntryState objects are used to create the state |
twisti@2047 | 165 | // that the method will be entered with for a normal invocation. |
twisti@2047 | 166 | class SharkNormalEntryState : public SharkState { |
twisti@2047 | 167 | public: |
twisti@2047 | 168 | SharkNormalEntryState(SharkTopLevelBlock* block, |
twisti@2047 | 169 | llvm::Value* method); |
twisti@2047 | 170 | }; |
twisti@2047 | 171 | |
twisti@2047 | 172 | // SharkOSREntryState objects are used to create the state |
twisti@2047 | 173 | // that the method will be entered with for an OSR invocation. |
twisti@2047 | 174 | class SharkOSREntryState : public SharkState { |
twisti@2047 | 175 | public: |
twisti@2047 | 176 | SharkOSREntryState(SharkTopLevelBlock* block, |
twisti@2047 | 177 | llvm::Value* method, |
twisti@2047 | 178 | llvm::Value* osr_buf); |
twisti@2047 | 179 | }; |
twisti@2047 | 180 | |
twisti@2047 | 181 | // SharkPHIState objects are used to manage the entry state |
twisti@2047 | 182 | // for blocks with more than one entry path or for blocks |
twisti@2047 | 183 | // entered from blocks that will be compiled later. |
twisti@2047 | 184 | class SharkPHIState : public SharkState { |
twisti@2047 | 185 | public: |
twisti@2047 | 186 | SharkPHIState(SharkTopLevelBlock* block); |
twisti@2047 | 187 | |
twisti@2047 | 188 | private: |
twisti@2047 | 189 | SharkTopLevelBlock* _block; |
twisti@2047 | 190 | |
twisti@2047 | 191 | private: |
twisti@2047 | 192 | SharkTopLevelBlock* block() const { |
twisti@2047 | 193 | return _block; |
twisti@2047 | 194 | } |
twisti@2047 | 195 | |
twisti@2047 | 196 | public: |
twisti@2047 | 197 | void add_incoming(SharkState* incoming_state); |
twisti@2047 | 198 | }; |
stefank@2314 | 199 | |
stefank@2314 | 200 | #endif // SHARE_VM_SHARK_SHARKSTATE_HPP |