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_SHARKBLOCK_HPP |
stefank@2314 | 27 | #define SHARE_VM_SHARK_SHARKBLOCK_HPP |
stefank@2314 | 28 | |
stefank@2314 | 29 | #include "ci/ciMethod.hpp" |
stefank@2314 | 30 | #include "ci/ciStreams.hpp" |
stefank@2314 | 31 | #include "memory/allocation.hpp" |
stefank@2314 | 32 | #include "shark/llvmHeaders.hpp" |
stefank@2314 | 33 | #include "shark/sharkBuilder.hpp" |
stefank@2314 | 34 | #include "shark/sharkConstant.hpp" |
stefank@2314 | 35 | #include "shark/sharkInvariants.hpp" |
stefank@2314 | 36 | #include "shark/sharkState.hpp" |
stefank@2314 | 37 | #include "shark/sharkValue.hpp" |
stefank@2314 | 38 | #include "utilities/debug.hpp" |
stefank@2314 | 39 | |
twisti@2047 | 40 | class SharkState; |
twisti@2047 | 41 | |
twisti@2047 | 42 | class SharkBlock : public SharkTargetInvariants { |
twisti@2047 | 43 | protected: |
twisti@2047 | 44 | SharkBlock(const SharkTargetInvariants* parent) |
twisti@2047 | 45 | : SharkTargetInvariants(parent), |
twisti@2047 | 46 | _iter(target()), |
twisti@2047 | 47 | _current_state(NULL) {} |
twisti@2047 | 48 | |
twisti@2047 | 49 | SharkBlock(const SharkCompileInvariants* parent, ciMethod* target) |
twisti@2047 | 50 | : SharkTargetInvariants(parent, target), |
twisti@2047 | 51 | _iter(target), |
twisti@2047 | 52 | _current_state(NULL) {} |
twisti@2047 | 53 | |
twisti@2047 | 54 | private: |
twisti@2047 | 55 | ciBytecodeStream _iter; |
twisti@2047 | 56 | SharkState* _current_state; |
twisti@2047 | 57 | |
twisti@2047 | 58 | public: |
twisti@2047 | 59 | ciBytecodeStream* iter() { |
twisti@2047 | 60 | return &_iter; |
twisti@2047 | 61 | } |
twisti@2047 | 62 | Bytecodes::Code bc() { |
twisti@2047 | 63 | return iter()->cur_bc(); |
twisti@2047 | 64 | } |
twisti@2047 | 65 | int bci() { |
twisti@2047 | 66 | return iter()->cur_bci(); |
twisti@2047 | 67 | } |
twisti@2047 | 68 | |
twisti@2047 | 69 | // Entry state |
twisti@2047 | 70 | protected: |
twisti@2047 | 71 | virtual SharkState* entry_state(); |
twisti@2047 | 72 | |
twisti@2047 | 73 | // Current state |
twisti@2047 | 74 | private: |
twisti@2047 | 75 | SharkState* initial_current_state(); |
twisti@2047 | 76 | |
twisti@2047 | 77 | public: |
twisti@2047 | 78 | SharkState* current_state() { |
twisti@2047 | 79 | if (_current_state == NULL) |
twisti@2047 | 80 | set_current_state(initial_current_state()); |
twisti@2047 | 81 | return _current_state; |
twisti@2047 | 82 | } |
twisti@2047 | 83 | |
twisti@2047 | 84 | protected: |
twisti@2047 | 85 | void set_current_state(SharkState* current_state) { |
twisti@2047 | 86 | _current_state = current_state; |
twisti@2047 | 87 | } |
twisti@2047 | 88 | |
twisti@2047 | 89 | // Local variables |
twisti@2047 | 90 | protected: |
twisti@2047 | 91 | SharkValue* local(int index) { |
twisti@2047 | 92 | SharkValue *value = current_state()->local(index); |
twisti@2047 | 93 | assert(value != NULL, "shouldn't be"); |
twisti@2047 | 94 | assert(value->is_one_word() || |
twisti@2047 | 95 | (index + 1 < max_locals() && |
twisti@2047 | 96 | current_state()->local(index + 1) == NULL), "should be"); |
twisti@2047 | 97 | return value; |
twisti@2047 | 98 | } |
twisti@2047 | 99 | void set_local(int index, SharkValue* value) { |
twisti@2047 | 100 | assert(value != NULL, "shouldn't be"); |
twisti@2047 | 101 | current_state()->set_local(index, value); |
twisti@2047 | 102 | if (value->is_two_word()) |
twisti@2047 | 103 | current_state()->set_local(index + 1, NULL); |
twisti@2047 | 104 | } |
twisti@2047 | 105 | |
twisti@2047 | 106 | // Expression stack (raw) |
twisti@2047 | 107 | protected: |
twisti@2047 | 108 | void xpush(SharkValue* value) { |
twisti@2047 | 109 | current_state()->push(value); |
twisti@2047 | 110 | } |
twisti@2047 | 111 | SharkValue* xpop() { |
twisti@2047 | 112 | return current_state()->pop(); |
twisti@2047 | 113 | } |
twisti@2047 | 114 | SharkValue* xstack(int slot) { |
twisti@2047 | 115 | SharkValue *value = current_state()->stack(slot); |
twisti@2047 | 116 | assert(value != NULL, "shouldn't be"); |
twisti@2047 | 117 | assert(value->is_one_word() || |
twisti@2047 | 118 | (slot > 0 && |
twisti@2047 | 119 | current_state()->stack(slot - 1) == NULL), "should be"); |
twisti@2047 | 120 | return value; |
twisti@2047 | 121 | } |
twisti@2047 | 122 | int xstack_depth() { |
twisti@2047 | 123 | return current_state()->stack_depth(); |
twisti@2047 | 124 | } |
twisti@2047 | 125 | |
twisti@2047 | 126 | // Expression stack (cooked) |
twisti@2047 | 127 | protected: |
twisti@2047 | 128 | void push(SharkValue* value) { |
twisti@2047 | 129 | assert(value != NULL, "shouldn't be"); |
twisti@2047 | 130 | xpush(value); |
twisti@2047 | 131 | if (value->is_two_word()) |
twisti@2047 | 132 | xpush(NULL); |
twisti@2047 | 133 | } |
twisti@2047 | 134 | SharkValue* pop() { |
twisti@2047 | 135 | int size = current_state()->stack(0) == NULL ? 2 : 1; |
twisti@2047 | 136 | if (size == 2) |
twisti@2047 | 137 | xpop(); |
twisti@2047 | 138 | SharkValue *value = xpop(); |
twisti@2047 | 139 | assert(value && value->size() == size, "should be"); |
twisti@2047 | 140 | return value; |
twisti@2047 | 141 | } |
twisti@2047 | 142 | SharkValue* pop_result(BasicType type) { |
twisti@2047 | 143 | SharkValue *result = pop(); |
twisti@2047 | 144 | |
twisti@2047 | 145 | #ifdef ASSERT |
twisti@2047 | 146 | switch (result->basic_type()) { |
twisti@2047 | 147 | case T_BOOLEAN: |
twisti@2047 | 148 | case T_BYTE: |
twisti@2047 | 149 | case T_CHAR: |
twisti@2047 | 150 | case T_SHORT: |
twisti@2047 | 151 | assert(type == T_INT, "type mismatch"); |
twisti@2047 | 152 | break; |
twisti@2047 | 153 | |
twisti@2047 | 154 | case T_ARRAY: |
twisti@2047 | 155 | assert(type == T_OBJECT, "type mismatch"); |
twisti@2047 | 156 | break; |
twisti@2047 | 157 | |
twisti@2047 | 158 | default: |
twisti@2047 | 159 | assert(result->basic_type() == type, "type mismatch"); |
twisti@2047 | 160 | } |
twisti@2047 | 161 | #endif // ASSERT |
twisti@2047 | 162 | |
twisti@2047 | 163 | return result; |
twisti@2047 | 164 | } |
twisti@2047 | 165 | |
twisti@2047 | 166 | // Code generation |
twisti@2047 | 167 | public: |
twisti@2047 | 168 | virtual void emit_IR(); |
twisti@2047 | 169 | |
twisti@2047 | 170 | protected: |
twisti@2047 | 171 | void parse_bytecode(int start, int limit); |
twisti@2047 | 172 | |
twisti@2047 | 173 | // Helpers |
twisti@2047 | 174 | protected: |
twisti@2047 | 175 | virtual void do_zero_check(SharkValue* value); |
twisti@2047 | 176 | |
twisti@2047 | 177 | // Zero checking |
twisti@2047 | 178 | protected: |
twisti@2047 | 179 | void check_null(SharkValue* object) { |
twisti@2047 | 180 | zero_check(object); |
twisti@2047 | 181 | } |
twisti@2047 | 182 | void check_divide_by_zero(SharkValue* value) { |
twisti@2047 | 183 | zero_check(value); |
twisti@2047 | 184 | } |
twisti@2047 | 185 | private: |
twisti@2047 | 186 | void zero_check(SharkValue* value) { |
twisti@2047 | 187 | if (!value->zero_checked()) |
twisti@2047 | 188 | do_zero_check(value); |
twisti@2047 | 189 | } |
twisti@2047 | 190 | |
twisti@2047 | 191 | // Safepoints |
twisti@2047 | 192 | protected: |
twisti@2047 | 193 | virtual void maybe_add_backedge_safepoint(); |
twisti@2047 | 194 | |
twisti@2047 | 195 | // Traps |
twisti@2047 | 196 | protected: |
twisti@2047 | 197 | virtual bool has_trap(); |
twisti@2047 | 198 | virtual int trap_request(); |
twisti@2047 | 199 | virtual int trap_bci(); |
twisti@2047 | 200 | virtual void do_trap(int trap_request); |
twisti@2047 | 201 | |
twisti@2047 | 202 | // arraylength |
twisti@2047 | 203 | protected: |
twisti@2047 | 204 | virtual void do_arraylength(); |
twisti@2047 | 205 | |
twisti@2047 | 206 | // *aload and *astore |
twisti@2047 | 207 | protected: |
twisti@2047 | 208 | virtual void do_aload(BasicType basic_type); |
twisti@2047 | 209 | virtual void do_astore(BasicType basic_type); |
twisti@2047 | 210 | |
twisti@2047 | 211 | // *div and *rem |
twisti@2047 | 212 | private: |
twisti@2047 | 213 | void do_idiv() { |
twisti@2047 | 214 | do_div_or_rem(false, false); |
twisti@2047 | 215 | } |
twisti@2047 | 216 | void do_irem() { |
twisti@2047 | 217 | do_div_or_rem(false, true); |
twisti@2047 | 218 | } |
twisti@2047 | 219 | void do_ldiv() { |
twisti@2047 | 220 | do_div_or_rem(true, false); |
twisti@2047 | 221 | } |
twisti@2047 | 222 | void do_lrem() { |
twisti@2047 | 223 | do_div_or_rem(true, true); |
twisti@2047 | 224 | } |
twisti@2047 | 225 | void do_div_or_rem(bool is_long, bool is_rem); |
twisti@2047 | 226 | |
twisti@2047 | 227 | // get* and put* |
twisti@2047 | 228 | private: |
twisti@2047 | 229 | void do_getstatic() { |
twisti@2047 | 230 | do_field_access(true, false); |
twisti@2047 | 231 | } |
twisti@2047 | 232 | void do_getfield() { |
twisti@2047 | 233 | do_field_access(true, true); |
twisti@2047 | 234 | } |
twisti@2047 | 235 | void do_putstatic() { |
twisti@2047 | 236 | do_field_access(false, false); |
twisti@2047 | 237 | } |
twisti@2047 | 238 | void do_putfield() { |
twisti@2047 | 239 | do_field_access(false, true); |
twisti@2047 | 240 | } |
twisti@2047 | 241 | void do_field_access(bool is_get, bool is_field); |
twisti@2047 | 242 | |
twisti@2047 | 243 | // lcmp and [fd]cmp[lg] |
twisti@2047 | 244 | private: |
twisti@2047 | 245 | void do_lcmp(); |
twisti@2047 | 246 | void do_fcmp(bool is_double, bool unordered_is_greater); |
twisti@2047 | 247 | |
twisti@2047 | 248 | // *return and athrow |
twisti@2047 | 249 | protected: |
twisti@2047 | 250 | virtual void do_return(BasicType type); |
twisti@2047 | 251 | virtual void do_athrow(); |
twisti@2047 | 252 | |
twisti@2047 | 253 | // goto* |
twisti@2047 | 254 | protected: |
twisti@2047 | 255 | virtual void do_goto(); |
twisti@2047 | 256 | |
twisti@2047 | 257 | // jsr* and ret |
twisti@2047 | 258 | protected: |
twisti@2047 | 259 | virtual void do_jsr(); |
twisti@2047 | 260 | virtual void do_ret(); |
twisti@2047 | 261 | |
twisti@2047 | 262 | // if* |
twisti@2047 | 263 | protected: |
twisti@2047 | 264 | virtual void do_if(llvm::ICmpInst::Predicate p, SharkValue* b, SharkValue* a); |
twisti@2047 | 265 | |
twisti@2047 | 266 | // *switch |
twisti@2047 | 267 | protected: |
twisti@2047 | 268 | int switch_default_dest(); |
twisti@2047 | 269 | int switch_table_length(); |
twisti@2047 | 270 | int switch_key(int i); |
twisti@2047 | 271 | int switch_dest(int i); |
twisti@2047 | 272 | |
twisti@2047 | 273 | virtual void do_switch(); |
twisti@2047 | 274 | |
twisti@2047 | 275 | // invoke* |
twisti@2047 | 276 | protected: |
twisti@2047 | 277 | virtual void do_call(); |
twisti@2047 | 278 | |
twisti@2047 | 279 | // checkcast and instanceof |
twisti@2047 | 280 | protected: |
twisti@2047 | 281 | virtual void do_instance_check(); |
twisti@2047 | 282 | virtual bool maybe_do_instanceof_if(); |
twisti@2047 | 283 | |
twisti@2047 | 284 | // new and *newarray |
twisti@2047 | 285 | protected: |
twisti@2047 | 286 | virtual void do_new(); |
twisti@2047 | 287 | virtual void do_newarray(); |
twisti@2047 | 288 | virtual void do_anewarray(); |
twisti@2047 | 289 | virtual void do_multianewarray(); |
twisti@2047 | 290 | |
twisti@2047 | 291 | // monitorenter and monitorexit |
twisti@2047 | 292 | protected: |
twisti@2047 | 293 | virtual void do_monitorenter(); |
twisti@2047 | 294 | virtual void do_monitorexit(); |
twisti@2047 | 295 | }; |
stefank@2314 | 296 | |
stefank@2314 | 297 | #endif // SHARE_VM_SHARK_SHARKBLOCK_HPP |