< prev index next >

src/hotspot/share/oops/symbol.cpp

Print this page

        

*** 29,39 **** #include "gc/shared/collectedHeap.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" - #include "memory/universe.hpp" #include "oops/symbol.hpp" #include "runtime/atomic.hpp" #include "runtime/os.hpp" #include "utilities/utf8.hpp" --- 29,38 ----
*** 55,88 **** for (int i = 0; i < length; i++) { byte_at_put(i, name[i]); } } ! void* Symbol::operator new(size_t sz, int len) throw() { int alloc_size = size(len)*wordSize; address res = (address) AllocateHeap(alloc_size, mtSymbol); return res; } ! void* Symbol::operator new(size_t sz, int len, Arena* arena) throw() { int alloc_size = size(len)*wordSize; address res = (address)arena->Amalloc_4(alloc_size); return res; } void Symbol::operator delete(void *p) { assert(((Symbol*)p)->refcount() == 0, "should not call this"); FreeHeap(p); } - void Symbol::set_permanent() { - // This is called at a safepoint during dumping of a dynamic CDS archive. - assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); - _length_and_refcount = pack_length_and_refcount(length(), PERM_REFCOUNT); - } - - // ------------------------------------------------------------------ // Symbol::starts_with // // Tests if the symbol starts with the specified prefix of the given // length. --- 54,80 ---- for (int i = 0; i < length; i++) { byte_at_put(i, name[i]); } } ! void* Symbol::operator new(size_t sz, int len, TRAPS) throw() { int alloc_size = size(len)*wordSize; address res = (address) AllocateHeap(alloc_size, mtSymbol); return res; } ! void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) throw() { int alloc_size = size(len)*wordSize; address res = (address)arena->Amalloc_4(alloc_size); return res; } void Symbol::operator delete(void *p) { assert(((Symbol*)p)->refcount() == 0, "should not call this"); FreeHeap(p); } // ------------------------------------------------------------------ // Symbol::starts_with // // Tests if the symbol starts with the specified prefix of the given // length.
*** 206,275 **** } } return str; } - static void print_class(outputStream *os, char *class_str, int len) { - for (int i = 0; i < len; ++i) { - if (class_str[i] == '/') { - os->put('.'); - } else { - os->put(class_str[i]); - } - } - } - - static void print_array(outputStream *os, char *array_str, int len) { - int dimensions = 0; - for (int i = 0; i < len; ++i) { - if (array_str[i] == '[') { - dimensions++; - } else if (array_str[i] == 'L') { - // Expected format: L<type name>;. Skip 'L' and ';' delimiting the type name. - print_class(os, array_str+i+1, len-i-2); - break; - } else { - os->print("%s", type2name(char2type(array_str[i]))); - } - } - for (int i = 0; i < dimensions; ++i) { - os->print("[]"); - } - } - - void Symbol::print_as_signature_external_return_type(outputStream *os) { - for (SignatureStream ss(this); !ss.is_done(); ss.next()) { - if (ss.at_return_type()) { - if (ss.is_array()) { - print_array(os, (char*)ss.raw_bytes(), (int)ss.raw_length()); - } else if (ss.is_object()) { - // Expected format: L<type name>;. Skip 'L' and ';' delimiting the class name. - print_class(os, (char*)ss.raw_bytes()+1, (int)ss.raw_length()-2); - } else { - os->print("%s", type2name(ss.type())); - } - } - } - } - - void Symbol::print_as_signature_external_parameters(outputStream *os) { - bool first = true; - for (SignatureStream ss(this); !ss.is_done(); ss.next()) { - if (ss.at_return_type()) break; - if (!first) { os->print(", "); } - if (ss.is_array()) { - print_array(os, (char*)ss.raw_bytes(), (int)ss.raw_length()); - } else if (ss.is_object()) { - // Skip 'L' and ';'. - print_class(os, (char*)ss.raw_bytes()+1, (int)ss.raw_length()-2); - } else { - os->print("%s", type2name(ss.type())); - } - first = false; - } - } - // Increment refcount while checking for zero. If the Symbol's refcount becomes zero // a thread could be concurrently removing the Symbol. This is used during SymbolTable // lookup to avoid reviving a dead Symbol. bool Symbol::try_increment_refcount() { uint32_t found = _length_and_refcount; --- 198,207 ----
*** 371,394 **** print_symbol_on(st); st->print("'"); st->print(" count %d", refcount()); } - void Symbol::print() const { print_on(tty); } - // The print_value functions are present in all builds, to support the // disassembler and error reporting. void Symbol::print_value_on(outputStream* st) const { st->print("'"); for (int i = 0; i < utf8_length(); i++) { st->print("%c", char_at(i)); } st->print("'"); } - void Symbol::print_value() const { print_value_on(tty); } - bool Symbol::is_valid(Symbol* s) { if (!is_aligned(s, sizeof(MetaWord))) return false; if ((size_t)s < os::min_page_size()) return false; if (!os::is_readable_range(s, s + 1)) return false; --- 303,322 ----
< prev index next >