< prev index next >

src/hotspot/share/runtime/signature.cpp

Print this page
rev 54022 : 8220366: Optimize Symbol handling in ClassVerifier and SignatureStream
Reviewed-by: TBD

*** 121,139 **** tty->print_cr(" @ %d", _index); } } - void SignatureIterator::dispatch_field() { - // no '(', just one (field) type - _index = 0; - _parameter_index = 0; - parse_type(); - check_signature_end(); - } - - void SignatureIterator::iterate_parameters() { // Parse parameters _index = 0; _parameter_index = 0; expect('('); --- 121,130 ----
*** 194,213 **** do_double(); _parameter_index += T_DOUBLE_size; break; case done_parm: return; - break; default: tty->print_cr("*** parameter is " UINT64_FORMAT, fingerprint & parameter_feature_mask); tty->print_cr("*** fingerprint is " PTR64_FORMAT, saved_fingerprint); ShouldNotReachHere(); break; } fingerprint >>= parameter_feature_size; } - _parameter_index = 0; } void SignatureIterator::iterate_returntype() { // Ignore parameters --- 185,202 ----
*** 237,250 **** while (sig->char_at(_index++) != ';') ; } break; case '[': { ! int begin = ++_index; ! while (sig->char_at(_index) == '[') { ! _index++; ! } if (sig->char_at(_index) == 'L') { while (sig->char_at(_index++) != ';') ; } else { _index++; } --- 226,236 ---- while (sig->char_at(_index++) != ';') ; } break; case '[': { ! while (sig->char_at(++_index) == '[') ; if (sig->char_at(_index) == 'L') { while (sig->char_at(_index++) != ';') ; } else { _index++; }
*** 279,299 **** } // Implementation of SignatureStream SignatureStream::SignatureStream(Symbol* signature, bool is_method) : ! _signature(signature), _at_return_type(false) { _begin = _end = (is_method ? 1 : 0); // skip first '(' in method signatures - _names = new GrowableArray<Symbol*>(10); next(); } SignatureStream::~SignatureStream() { // decrement refcount for names created during signature parsing for (int i = 0; i < _names->length(); i++) { _names->at(i)->decrement_refcount(); } } bool SignatureStream::is_done() const { return _end > _signature->utf8_length(); } --- 265,286 ---- } // Implementation of SignatureStream SignatureStream::SignatureStream(Symbol* signature, bool is_method) : ! _signature(signature), _at_return_type(false), _previous_name(NULL), _names(NULL) { _begin = _end = (is_method ? 1 : 0); // skip first '(' in method signatures next(); } SignatureStream::~SignatureStream() { // decrement refcount for names created during signature parsing + if (_names != NULL) { for (int i = 0; i < _names->length(); i++) { _names->at(i)->decrement_refcount(); } + } } bool SignatureStream::is_done() const { return _end > _signature->utf8_length(); }
*** 357,370 **** && _signature->char_at(_end-1) == ';') { begin++; end--; } // Save names for cleaning up reference count at the end of // SignatureStream scope. ! Symbol* name = SymbolTable::new_symbol(_signature, begin, end, CHECK_NULL); _names->push(name); // save new symbol for decrementing later return name; } Klass* SignatureStream::as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS) { --- 344,382 ---- && _signature->char_at(_end-1) == ';') { begin++; end--; } + const char* symbol_chars = (const char*)_signature->base() + begin; + int len = end - begin; + + // Quick check for common symbols in signatures + assert((vmSymbols::java_lang_String()->utf8_length() == 16 && vmSymbols::java_lang_Object()->utf8_length() == 16), "sanity"); + if (len == 16 && + strncmp(symbol_chars, "java/lang/", 10) == 0) { + if (strncmp("String", symbol_chars + 10, 6) == 0) { + return vmSymbols::java_lang_String(); + } else if (strncmp("Object", symbol_chars + 10, 6) == 0) { + return vmSymbols::java_lang_Object(); + } + } + + Symbol* name = _previous_name; + if (name != NULL && name->equals(symbol_chars, len)) { + return name; + } + // Save names for cleaning up reference count at the end of // SignatureStream scope. ! name = SymbolTable::new_symbol(symbol_chars, len, CHECK_NULL); ! if (!name->is_permanent()) { ! if (_names == NULL) { ! _names = new GrowableArray<Symbol*>(10); ! } _names->push(name); // save new symbol for decrementing later + } + _previous_name = name; return name; } Klass* SignatureStream::as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS) {
*** 479,501 **** for (index = index + 1; index < limit; ++index) { char c = type[index]; if (c == ';') { return index + 1; } ! if (invalid_name_char(c)) { return -1; } } // fall through default: ; // fall through } return -1; } - - bool SignatureVerifier::invalid_name_char(char c) { - switch (c) { - case '\0': case '.': case ';': case '[': - return true; - default: - return false; - } - } --- 491,506 ---- for (index = index + 1; index < limit; ++index) { char c = type[index]; if (c == ';') { return index + 1; } ! switch (c) { ! case '\0': case '.': case '[': return -1; + default: ; // fall through } } // fall through default: ; // fall through } return -1; }
< prev index next >