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
duke@435 | 1 | /* |
mikael@4153 | 2 | * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "ci/ciSymbol.hpp" |
stefank@2314 | 27 | #include "ci/ciUtilities.hpp" |
stefank@2314 | 28 | #include "memory/oopFactory.hpp" |
duke@435 | 29 | |
duke@435 | 30 | // ------------------------------------------------------------------ |
duke@435 | 31 | // ciSymbol::ciSymbol |
duke@435 | 32 | // |
coleenp@2497 | 33 | // Preallocated symbol variant. Used with symbols from vmSymbols. |
coleenp@2497 | 34 | ciSymbol::ciSymbol(Symbol* s, vmSymbols::SID sid) |
coleenp@2497 | 35 | : _symbol(s), _sid(sid) |
jrose@1862 | 36 | { |
coleenp@2497 | 37 | assert(_symbol != NULL, "adding null symbol"); |
coleenp@2497 | 38 | _symbol->increment_refcount(); // increment ref count |
jrose@1862 | 39 | assert(sid_ok(), "must be in vmSymbols"); |
jrose@1862 | 40 | } |
jrose@1862 | 41 | |
jrose@1862 | 42 | // Normal case for non-famous symbols. |
coleenp@2497 | 43 | ciSymbol::ciSymbol(Symbol* s) |
coleenp@2497 | 44 | : _symbol(s), _sid(vmSymbols::NO_SID) |
jrose@1862 | 45 | { |
coleenp@2497 | 46 | assert(_symbol != NULL, "adding null symbol"); |
coleenp@2497 | 47 | _symbol->increment_refcount(); // increment ref count |
jrose@1862 | 48 | assert(sid_ok(), "must not be in vmSymbols"); |
duke@435 | 49 | } |
duke@435 | 50 | |
duke@435 | 51 | // ciSymbol |
duke@435 | 52 | // |
coleenp@2497 | 53 | // This class represents a Symbol* in the HotSpot virtual |
duke@435 | 54 | // machine. |
duke@435 | 55 | |
duke@435 | 56 | // ------------------------------------------------------------------ |
duke@435 | 57 | // ciSymbol::as_utf8 |
duke@435 | 58 | // |
duke@435 | 59 | // The text of the symbol as a null-terminated C string. |
duke@435 | 60 | const char* ciSymbol::as_utf8() { |
duke@435 | 61 | VM_QUICK_ENTRY_MARK; |
coleenp@2497 | 62 | Symbol* s = get_symbol(); |
duke@435 | 63 | return s->as_utf8(); |
duke@435 | 64 | } |
duke@435 | 65 | |
minqi@4267 | 66 | // The text of the symbol as a null-terminated C string. |
minqi@4267 | 67 | const char* ciSymbol::as_quoted_ascii() { |
minqi@4267 | 68 | GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_quoted_ascii();) |
minqi@4267 | 69 | } |
minqi@4267 | 70 | |
duke@435 | 71 | // ------------------------------------------------------------------ |
duke@435 | 72 | // ciSymbol::base |
coleenp@2497 | 73 | const jbyte* ciSymbol::base() { |
coleenp@2497 | 74 | GUARDED_VM_ENTRY(return get_symbol()->base();) |
duke@435 | 75 | } |
duke@435 | 76 | |
duke@435 | 77 | // ------------------------------------------------------------------ |
duke@435 | 78 | // ciSymbol::byte_at |
duke@435 | 79 | int ciSymbol::byte_at(int i) { |
coleenp@2497 | 80 | GUARDED_VM_ENTRY(return get_symbol()->byte_at(i);) |
duke@435 | 81 | } |
duke@435 | 82 | |
duke@435 | 83 | // ------------------------------------------------------------------ |
twisti@1573 | 84 | // ciSymbol::starts_with |
twisti@1573 | 85 | // |
twisti@1573 | 86 | // Tests if the symbol starts with the given prefix. |
twisti@1573 | 87 | bool ciSymbol::starts_with(const char* prefix, int len) const { |
coleenp@2497 | 88 | GUARDED_VM_ENTRY(return get_symbol()->starts_with(prefix, len);) |
twisti@1573 | 89 | } |
twisti@1573 | 90 | |
twisti@3969 | 91 | bool ciSymbol::is_signature_polymorphic_name() const { |
twisti@3969 | 92 | GUARDED_VM_ENTRY(return MethodHandles::is_signature_polymorphic_name(get_symbol());) |
twisti@3969 | 93 | } |
twisti@3969 | 94 | |
twisti@1573 | 95 | // ------------------------------------------------------------------ |
twisti@1573 | 96 | // ciSymbol::index_of |
twisti@1573 | 97 | // |
twisti@1573 | 98 | // Determines where the symbol contains the given substring. |
twisti@1573 | 99 | int ciSymbol::index_of_at(int i, const char* str, int len) const { |
coleenp@2497 | 100 | GUARDED_VM_ENTRY(return get_symbol()->index_of_at(i, str, len);) |
twisti@1573 | 101 | } |
twisti@1573 | 102 | |
twisti@1573 | 103 | // ------------------------------------------------------------------ |
duke@435 | 104 | // ciSymbol::utf8_length |
duke@435 | 105 | int ciSymbol::utf8_length() { |
coleenp@2497 | 106 | GUARDED_VM_ENTRY(return get_symbol()->utf8_length();) |
duke@435 | 107 | } |
duke@435 | 108 | |
duke@435 | 109 | // ------------------------------------------------------------------ |
duke@435 | 110 | // ciSymbol::print_impl |
duke@435 | 111 | // |
duke@435 | 112 | // Implementation of the print method |
duke@435 | 113 | void ciSymbol::print_impl(outputStream* st) { |
duke@435 | 114 | st->print(" value="); |
duke@435 | 115 | print_symbol_on(st); |
duke@435 | 116 | } |
duke@435 | 117 | |
duke@435 | 118 | // ------------------------------------------------------------------ |
duke@435 | 119 | // ciSymbol::print_symbol_on |
duke@435 | 120 | // |
duke@435 | 121 | // Print the value of this symbol on an outputStream |
duke@435 | 122 | void ciSymbol::print_symbol_on(outputStream *st) { |
coleenp@2497 | 123 | GUARDED_VM_ENTRY(get_symbol()->print_symbol_on(st);) |
duke@435 | 124 | } |
duke@435 | 125 | |
duke@435 | 126 | // ------------------------------------------------------------------ |
duke@435 | 127 | // ciSymbol::make_impl |
duke@435 | 128 | // |
duke@435 | 129 | // Make a ciSymbol from a C string (implementation). |
duke@435 | 130 | ciSymbol* ciSymbol::make_impl(const char* s) { |
duke@435 | 131 | EXCEPTION_CONTEXT; |
coleenp@2497 | 132 | TempNewSymbol sym = SymbolTable::new_symbol(s, THREAD); |
duke@435 | 133 | if (HAS_PENDING_EXCEPTION) { |
duke@435 | 134 | CLEAR_PENDING_EXCEPTION; |
duke@435 | 135 | CURRENT_THREAD_ENV->record_out_of_memory_failure(); |
duke@435 | 136 | return ciEnv::_unloaded_cisymbol; |
duke@435 | 137 | } |
coleenp@2497 | 138 | return CURRENT_THREAD_ENV->get_symbol(sym); |
duke@435 | 139 | } |
duke@435 | 140 | |
duke@435 | 141 | // ------------------------------------------------------------------ |
duke@435 | 142 | // ciSymbol::make |
duke@435 | 143 | // |
duke@435 | 144 | // Make a ciSymbol from a C string. |
duke@435 | 145 | ciSymbol* ciSymbol::make(const char* s) { |
duke@435 | 146 | GUARDED_VM_ENTRY(return make_impl(s);) |
duke@435 | 147 | } |