8223657: Remove unused THREAD argument from SymbolTable functions

Also made lookup and lookup_only functions private to SymbolTable.  External callers use new_symbol or probe.

Reviewed-by: dholmes, gziemski
This commit is contained in:
Coleen Phillimore 2019-05-14 11:29:18 -04:00
parent 23278fea38
commit 204059634d
67 changed files with 269 additions and 318 deletions

View file

@ -1413,7 +1413,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
out_sig_bt[argc++] = in_sig_bt[i]; out_sig_bt[argc++] = in_sig_bt[i];
} }
} else { } else {
Thread* THREAD = Thread::current();
in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args); in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args);
SignatureStream ss(method->signature()); SignatureStream ss(method->signature());
for (int i = 0; i < total_in_args ; i++ ) { for (int i = 0; i < total_in_args ; i++ ) {
@ -1421,7 +1420,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
// Arrays are passed as int, elem* pair // Arrays are passed as int, elem* pair
out_sig_bt[argc++] = T_INT; out_sig_bt[argc++] = T_INT;
out_sig_bt[argc++] = T_ADDRESS; out_sig_bt[argc++] = T_ADDRESS;
Symbol* atype = ss.as_symbol(CHECK_NULL); Symbol* atype = ss.as_symbol();
const char* at = atype->as_C_string(); const char* at = atype->as_C_string();
if (strlen(at) == 2) { if (strlen(at) == 2) {
assert(at[0] == '[', "must be"); assert(at[0] == '[', "must be");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018 SAP SE. All rights reserved. * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -1908,14 +1908,13 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
out_sig_bt[argc++] = in_sig_bt[i]; out_sig_bt[argc++] = in_sig_bt[i];
} }
} else { } else {
Thread* THREAD = Thread::current();
in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args); in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
SignatureStream ss(method->signature()); SignatureStream ss(method->signature());
int o = 0; int o = 0;
for (int i = 0; i < total_in_args ; i++, o++) { for (int i = 0; i < total_in_args ; i++, o++) {
if (in_sig_bt[i] == T_ARRAY) { if (in_sig_bt[i] == T_ARRAY) {
// Arrays are passed as int, elem* pair // Arrays are passed as int, elem* pair
Symbol* atype = ss.as_symbol(CHECK_NULL); Symbol* atype = ss.as_symbol();
const char* at = atype->as_C_string(); const char* at = atype->as_C_string();
if (strlen(at) == 2) { if (strlen(at) == 2) {
assert(at[0] == '[', "must be"); assert(at[0] == '[', "must be");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018 SAP SE. All rights reserved. * Copyright (c) 2016, 2018 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -1618,14 +1618,13 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
out_sig_bt[argc++] = in_sig_bt[i]; out_sig_bt[argc++] = in_sig_bt[i];
} }
} else { } else {
Thread* THREAD = Thread::current();
in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args); in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args);
SignatureStream ss(method->signature()); SignatureStream ss(method->signature());
int o = 0; int o = 0;
for (int i = 0; i < total_in_args; i++, o++) { for (int i = 0; i < total_in_args; i++, o++) {
if (in_sig_bt[i] == T_ARRAY) { if (in_sig_bt[i] == T_ARRAY) {
// Arrays are passed as tuples (int, elem*). // Arrays are passed as tuples (int, elem*).
Symbol* atype = ss.as_symbol(CHECK_NULL); Symbol* atype = ss.as_symbol();
const char* at = atype->as_C_string(); const char* at = atype->as_C_string();
if (strlen(at) == 2) { if (strlen(at) == 2) {
assert(at[0] == '[', "must be"); assert(at[0] == '[', "must be");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -1906,7 +1906,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
// Arrays are passed as int, elem* pair // Arrays are passed as int, elem* pair
out_sig_bt[argc++] = T_INT; out_sig_bt[argc++] = T_INT;
out_sig_bt[argc++] = T_ADDRESS; out_sig_bt[argc++] = T_ADDRESS;
Symbol* atype = ss.as_symbol(CHECK_NULL); Symbol* atype = ss.as_symbol();
const char* at = atype->as_C_string(); const char* at = atype->as_C_string();
if (strlen(at) == 2) { if (strlen(at) == 2) {
assert(at[0] == '[', "must be"); assert(at[0] == '[', "must be");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -1593,7 +1593,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
out_sig_bt[argc++] = in_sig_bt[i]; out_sig_bt[argc++] = in_sig_bt[i];
} }
} else { } else {
Thread* THREAD = Thread::current();
in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args); in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args);
SignatureStream ss(method->signature()); SignatureStream ss(method->signature());
for (int i = 0; i < total_in_args ; i++ ) { for (int i = 0; i < total_in_args ; i++ ) {
@ -1601,7 +1600,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
// Arrays are passed as int, elem* pair // Arrays are passed as int, elem* pair
out_sig_bt[argc++] = T_INT; out_sig_bt[argc++] = T_INT;
out_sig_bt[argc++] = T_ADDRESS; out_sig_bt[argc++] = T_ADDRESS;
Symbol* atype = ss.as_symbol(CHECK_NULL); Symbol* atype = ss.as_symbol();
const char* at = atype->as_C_string(); const char* at = atype->as_C_string();
if (strlen(at) == 2) { if (strlen(at) == 2) {
assert(at[0] == '[', "must be"); assert(at[0] == '[', "must be");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -1971,7 +1971,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
out_sig_bt[argc++] = in_sig_bt[i]; out_sig_bt[argc++] = in_sig_bt[i];
} }
} else { } else {
Thread* THREAD = Thread::current();
in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args); in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args);
SignatureStream ss(method->signature()); SignatureStream ss(method->signature());
for (int i = 0; i < total_in_args ; i++ ) { for (int i = 0; i < total_in_args ; i++ ) {
@ -1979,7 +1978,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
// Arrays are passed as int, elem* pair // Arrays are passed as int, elem* pair
out_sig_bt[argc++] = T_INT; out_sig_bt[argc++] = T_INT;
out_sig_bt[argc++] = T_ADDRESS; out_sig_bt[argc++] = T_ADDRESS;
Symbol* atype = ss.as_symbol(CHECK_NULL); Symbol* atype = ss.as_symbol();
const char* at = atype->as_C_string(); const char* at = atype->as_C_string();
if (strlen(at) == 2) { if (strlen(at) == 2) {
assert(at[0] == '[', "must be"); assert(at[0] == '[', "must be");

View file

@ -405,8 +405,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
// This is a name from a signature. Strip off the trimmings. // This is a name from a signature. Strip off the trimmings.
// Call recursive to keep scope of strippedsym. // Call recursive to keep scope of strippedsym.
TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
sym->utf8_length()-2, sym->utf8_length()-2);
KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
ciSymbol* strippedname = get_symbol(strippedsym); ciSymbol* strippedname = get_symbol(strippedsym);
return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local); return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local);
} }
@ -459,8 +458,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
// We have an unloaded array. // We have an unloaded array.
// Build it on the fly if the element class exists. // Build it on the fly if the element class exists.
TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
sym->utf8_length()-1, sym->utf8_length()-1);
KILL_COMPILE_ON_FATAL_(fail_type));
// Get element ciKlass recursively. // Get element ciKlass recursively.
ciKlass* elem_klass = ciKlass* elem_klass =

View file

@ -336,7 +336,7 @@ class CompileReplay : public StackObj {
Symbol* parse_symbol(TRAPS) { Symbol* parse_symbol(TRAPS) {
const char* str = parse_escaped_string(); const char* str = parse_escaped_string();
if (str != NULL) { if (str != NULL) {
Symbol* sym = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL); Symbol* sym = SymbolTable::new_symbol(str);
return sym; return sym;
} }
return NULL; return NULL;
@ -345,7 +345,7 @@ class CompileReplay : public StackObj {
// Parse a valid klass name and look it up // Parse a valid klass name and look it up
Klass* parse_klass(TRAPS) { Klass* parse_klass(TRAPS) {
const char* str = parse_escaped_string(); const char* str = parse_escaped_string();
Symbol* klass_name = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL); Symbol* klass_name = SymbolTable::new_symbol(str);
if (klass_name != NULL) { if (klass_name != NULL) {
Klass* k = NULL; Klass* k = NULL;
if (_iklass != NULL) { if (_iklass != NULL) {
@ -371,7 +371,7 @@ class CompileReplay : public StackObj {
// Lookup a klass // Lookup a klass
Klass* resolve_klass(const char* klass, TRAPS) { Klass* resolve_klass(const char* klass, TRAPS) {
Symbol* klass_name = SymbolTable::lookup(klass, (int)strlen(klass), CHECK_NULL); Symbol* klass_name = SymbolTable::new_symbol(klass);
return SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, THREAD); return SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, THREAD);
} }
@ -800,8 +800,8 @@ class CompileReplay : public StackObj {
const char* field_name = parse_escaped_string(); const char* field_name = parse_escaped_string();
const char* field_signature = parse_string(); const char* field_signature = parse_string();
fieldDescriptor fd; fieldDescriptor fd;
Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK); Symbol* name = SymbolTable::new_symbol(field_name);
Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK); Symbol* sig = SymbolTable::new_symbol(field_signature);
if (!k->find_local_field(name, sig, &fd) || if (!k->find_local_field(name, sig, &fd) ||
!fd.is_static() || !fd.is_static() ||
fd.has_initial_value()) { fd.has_initial_value()) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,17 +58,10 @@ ciSignature::ciSignature(ciKlass* accessing_klass, const constantPoolHandle& cpo
if (!ss.is_object()) { if (!ss.is_object()) {
type = ciType::make(ss.type()); type = ciType::make(ss.type());
} else { } else {
Symbol* name = ss.as_symbol(THREAD); Symbol* name = ss.as_symbol();
if (HAS_PENDING_EXCEPTION) {
type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
: (ciType*)ciEnv::unloaded_ciinstance_klass();
env->record_out_of_memory_failure();
CLEAR_PENDING_EXCEPTION;
} else {
ciSymbol* klass_name = env->get_symbol(name); ciSymbol* klass_name = env->get_symbol(name);
type = env->get_klass_by_name_impl(_accessing_klass, cpool, klass_name, false); type = env->get_klass_by_name_impl(_accessing_klass, cpool, klass_name, false);
} }
}
_types->append(type); _types->append(type);
if (ss.at_return_type()) { if (ss.at_return_type()) {
// Done processing the return type; do not add it into the count. // Done processing the return type; do not add it into the count.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -132,12 +132,7 @@ const char* ciSymbol::as_klass_external_name() const {
// Make a ciSymbol from a C string (implementation). // Make a ciSymbol from a C string (implementation).
ciSymbol* ciSymbol::make_impl(const char* s) { ciSymbol* ciSymbol::make_impl(const char* s) {
EXCEPTION_CONTEXT; EXCEPTION_CONTEXT;
TempNewSymbol sym = SymbolTable::new_symbol(s, THREAD); TempNewSymbol sym = SymbolTable::new_symbol(s);
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
CURRENT_THREAD_ENV->record_out_of_memory_failure();
return ciEnv::_unloaded_cisymbol;
}
return CURRENT_THREAD_ENV->get_symbol(sym); return CURRENT_THREAD_ENV->get_symbol(sym);
} }

View file

@ -335,8 +335,7 @@ void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const s
names, names,
lengths, lengths,
indices, indices,
hashValues, hashValues);
CHECK);
names_count = 0; names_count = 0;
} }
} else { } else {
@ -373,8 +372,7 @@ void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const s
names, names,
lengths, lengths,
indices, indices,
hashValues, hashValues);
CHECK);
} }
// Copy _current pointer of local copy back to stream. // Copy _current pointer of local copy back to stream.
@ -823,7 +821,7 @@ void ClassFileParser::patch_constant_pool(ConstantPool* cp,
guarantee_property(java_lang_String::is_instance(patch()), guarantee_property(java_lang_String::is_instance(patch()),
"Illegal class patch at %d in class file %s", "Illegal class patch at %d in class file %s",
index, CHECK); index, CHECK);
Symbol* const name = java_lang_String::as_symbol(patch(), CHECK); Symbol* const name = java_lang_String::as_symbol(patch());
patch_class(cp, index, NULL, name); patch_class(cp, index, NULL, name);
} }
break; break;
@ -5723,7 +5721,7 @@ void ClassFileParser::prepend_host_package_name(const InstanceKlass* unsafe_anon
// The new class name is created with a refcount of one. When installed into the InstanceKlass, // The new class name is created with a refcount of one. When installed into the InstanceKlass,
// it'll be two and when the ClassFileParser destructor runs, it'll go back to one and get deleted // it'll be two and when the ClassFileParser destructor runs, it'll go back to one and get deleted
// when the class is unloaded. // when the class is unloaded.
_class_name = SymbolTable::new_symbol(new_anon_name, symbol_len, CHECK); _class_name = SymbolTable::new_symbol(new_anon_name, symbol_len);
} }
} }

View file

@ -326,8 +326,7 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS
} }
Klass* ClassListParser::load_current_class(TRAPS) { Klass* ClassListParser::load_current_class(TRAPS) {
TempNewSymbol class_name_symbol = SymbolTable::new_symbol(_class_name, THREAD); TempNewSymbol class_name_symbol = SymbolTable::new_symbol(_class_name);
guarantee(!HAS_PENDING_EXCEPTION, "Exception creating a symbol.");
Klass *klass = NULL; Klass *klass = NULL;
if (!is_loading_from_source()) { if (!is_loading_from_source()) {

View file

@ -244,7 +244,7 @@ PackageEntry* ClassLoader::get_package_entry(const char* class_name, ClassLoader
return NULL; return NULL;
} }
PackageEntryTable* pkgEntryTable = loader_data->packages(); PackageEntryTable* pkgEntryTable = loader_data->packages();
TempNewSymbol pkg_symbol = SymbolTable::new_symbol(pkg_name, CHECK_NULL); TempNewSymbol pkg_symbol = SymbolTable::new_symbol(pkg_name);
return pkgEntryTable->lookup_only(pkg_symbol); return pkgEntryTable->lookup_only(pkg_symbol);
} }
@ -646,7 +646,7 @@ void ClassLoader::setup_patch_mod_entries() {
for (int i = 0; i < num_of_entries; i++) { for (int i = 0; i < num_of_entries; i++) {
const char* module_name = (patch_mod_args->at(i))->module_name(); const char* module_name = (patch_mod_args->at(i))->module_name();
Symbol* const module_sym = SymbolTable::lookup(module_name, (int)strlen(module_name), CHECK); Symbol* const module_sym = SymbolTable::new_symbol(module_name);
assert(module_sym != NULL, "Failed to obtain Symbol for module name"); assert(module_sym != NULL, "Failed to obtain Symbol for module name");
ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym);
@ -1126,7 +1126,7 @@ bool ClassLoader::add_package(const char *fullq_class_name, s2 classpath_index,
const char *cp = package_from_name(fullq_class_name); const char *cp = package_from_name(fullq_class_name);
if (cp != NULL) { if (cp != NULL) {
PackageEntryTable* pkg_entry_tbl = ClassLoaderData::the_null_class_loader_data()->packages(); PackageEntryTable* pkg_entry_tbl = ClassLoaderData::the_null_class_loader_data()->packages();
TempNewSymbol pkg_symbol = SymbolTable::new_symbol(cp, CHECK_false); TempNewSymbol pkg_symbol = SymbolTable::new_symbol(cp);
PackageEntry* pkg_entry = pkg_entry_tbl->lookup_only(pkg_symbol); PackageEntry* pkg_entry = pkg_entry_tbl->lookup_only(pkg_symbol);
if (pkg_entry != NULL) { if (pkg_entry != NULL) {
assert(classpath_index != -1, "Unexpected classpath_index"); assert(classpath_index != -1, "Unexpected classpath_index");
@ -1141,7 +1141,7 @@ bool ClassLoader::add_package(const char *fullq_class_name, s2 classpath_index,
oop ClassLoader::get_system_package(const char* name, TRAPS) { oop ClassLoader::get_system_package(const char* name, TRAPS) {
// Look up the name in the boot loader's package entry table. // Look up the name in the boot loader's package entry table.
if (name != NULL) { if (name != NULL) {
TempNewSymbol package_sym = SymbolTable::new_symbol(name, (int)strlen(name), CHECK_NULL); TempNewSymbol package_sym = SymbolTable::new_symbol(name);
// Look for the package entry in the boot loader's package entry table. // Look for the package entry in the boot loader's package entry table.
PackageEntry* package = PackageEntry* package =
ClassLoaderData::the_null_class_loader_data()->packages()->lookup_only(package_sym); ClassLoaderData::the_null_class_loader_data()->packages()->lookup_only(package_sym);

View file

@ -108,8 +108,7 @@ void ClassLoaderData::initialize_name(Handle class_loader) {
const char* cl_instance_name = java_lang_String::as_utf8_string(cl_name); const char* cl_instance_name = java_lang_String::as_utf8_string(cl_name);
if (cl_instance_name != NULL && cl_instance_name[0] != '\0') { if (cl_instance_name != NULL && cl_instance_name[0] != '\0') {
// Can't throw InternalError and SymbolTable doesn't throw OOM anymore. _name = SymbolTable::new_symbol(cl_instance_name);
_name = SymbolTable::new_symbol(cl_instance_name, CATCH);
} }
} }
@ -125,8 +124,7 @@ void ClassLoaderData::initialize_name(Handle class_loader) {
(cl_name_and_id == NULL) ? _class_loader_klass->external_name() : (cl_name_and_id == NULL) ? _class_loader_klass->external_name() :
java_lang_String::as_utf8_string(cl_name_and_id); java_lang_String::as_utf8_string(cl_name_and_id);
assert(cl_instance_name_and_id != NULL && cl_instance_name_and_id[0] != '\0', "class loader has no name and id"); assert(cl_instance_name_and_id != NULL && cl_instance_name_and_id[0] != '\0', "class loader has no name and id");
// Can't throw InternalError and SymbolTable doesn't throw OOM anymore. _name_and_id = SymbolTable::new_symbol(cl_instance_name_and_id);
_name_and_id = SymbolTable::new_symbol(cl_instance_name_and_id, CATCH);
} }
ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_unsafe_anonymous) : ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_unsafe_anonymous) :

View file

@ -459,7 +459,7 @@ class MethodFamily : public ResourceObj {
}; };
Symbol* MethodFamily::generate_no_defaults_message(TRAPS) const { Symbol* MethodFamily::generate_no_defaults_message(TRAPS) const {
return SymbolTable::new_symbol("No qualifying defaults found", THREAD); return SymbolTable::new_symbol("No qualifying defaults found");
} }
Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method, TRAPS) const { Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method, TRAPS) const {
@ -472,7 +472,7 @@ Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method
ss.write((const char*)name->bytes(), name->utf8_length()); ss.write((const char*)name->bytes(), name->utf8_length());
ss.write((const char*)signature->bytes(), signature->utf8_length()); ss.write((const char*)signature->bytes(), signature->utf8_length());
ss.print(" is abstract"); ss.print(" is abstract");
return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD); return SymbolTable::new_symbol(ss.base(), (int)ss.size());
} }
Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods, TRAPS) const { Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods, TRAPS) const {
@ -487,7 +487,7 @@ Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods
ss.print("."); ss.print(".");
ss.write((const char*)name->bytes(), name->utf8_length()); ss.write((const char*)name->bytes(), name->utf8_length());
} }
return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD); return SymbolTable::new_symbol(ss.base(), (int)ss.size());
} }

View file

@ -569,19 +569,19 @@ char* java_lang_String::as_quoted_ascii(oop java_string) {
return result; return result;
} }
Symbol* java_lang_String::as_symbol(oop java_string, TRAPS) { Symbol* java_lang_String::as_symbol(oop java_string) {
typeArrayOop value = java_lang_String::value(java_string); typeArrayOop value = java_lang_String::value(java_string);
int length = java_lang_String::length(java_string, value); int length = java_lang_String::length(java_string, value);
bool is_latin1 = java_lang_String::is_latin1(java_string); bool is_latin1 = java_lang_String::is_latin1(java_string);
if (!is_latin1) { if (!is_latin1) {
jchar* base = (length == 0) ? NULL : value->char_at_addr(0); jchar* base = (length == 0) ? NULL : value->char_at_addr(0);
Symbol* sym = SymbolTable::lookup_unicode(base, length, THREAD); Symbol* sym = SymbolTable::new_symbol(base, length);
return sym; return sym;
} else { } else {
ResourceMark rm; ResourceMark rm;
jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0); jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0);
const char* base = UNICODE::as_utf8(position, length); const char* base = UNICODE::as_utf8(position, length);
Symbol* sym = SymbolTable::lookup(base, length, THREAD); Symbol* sym = SymbolTable::new_symbol(base, length);
return sym; return sym;
} }
} }
@ -1443,7 +1443,7 @@ void java_lang_Class::print_signature(oop java_class, outputStream* st) {
if (is_instance) st->print(";"); if (is_instance) st->print(";");
} }
Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found, TRAPS) { Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found) {
assert(java_lang_Class::is_instance(java_class), "must be a Class object"); assert(java_lang_Class::is_instance(java_class), "must be a Class object");
Symbol* name; Symbol* name;
if (is_primitive(java_class)) { if (is_primitive(java_class)) {
@ -1464,7 +1464,7 @@ Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found,
if (!intern_if_not_found) { if (!intern_if_not_found) {
name = SymbolTable::probe(sigstr, siglen); name = SymbolTable::probe(sigstr, siglen);
} else { } else {
name = SymbolTable::new_symbol(sigstr, siglen, THREAD); name = SymbolTable::new_symbol(sigstr, siglen);
} }
} }
} }
@ -1895,7 +1895,7 @@ Symbol* java_lang_Throwable::detail_message(oop throwable) {
PRESERVE_EXCEPTION_MARK; // Keep original exception PRESERVE_EXCEPTION_MARK; // Keep original exception
oop detailed_message = java_lang_Throwable::message(throwable); oop detailed_message = java_lang_Throwable::message(throwable);
if (detailed_message != NULL) { if (detailed_message != NULL) {
return java_lang_String::as_symbol(detailed_message, THREAD); return java_lang_String::as_symbol(detailed_message);
} }
return NULL; return NULL;
} }
@ -3703,7 +3703,7 @@ void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) {
java_lang_Class::print_signature(rtype(mt), st); java_lang_Class::print_signature(rtype(mt), st);
} }
Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) { Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_found) {
ResourceMark rm; ResourceMark rm;
stringStream buffer(128); stringStream buffer(128);
print_signature(mt, &buffer); print_signature(mt, &buffer);
@ -3713,7 +3713,7 @@ Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_fou
if (!intern_if_not_found) { if (!intern_if_not_found) {
name = SymbolTable::probe(sigstr, siglen); name = SymbolTable::probe(sigstr, siglen);
} else { } else {
name = SymbolTable::new_symbol(sigstr, siglen, THREAD); name = SymbolTable::new_symbol(sigstr, siglen);
} }
return name; return name;
} }
@ -4375,11 +4375,11 @@ void JavaClasses::serialize_offsets(SerializeClosure* soc) {
bool JavaClasses::check_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) { bool JavaClasses::check_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) {
EXCEPTION_MARK; EXCEPTION_MARK;
fieldDescriptor fd; fieldDescriptor fd;
TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH); TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name);
Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH); Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH);
InstanceKlass* ik = InstanceKlass::cast(k); InstanceKlass* ik = InstanceKlass::cast(k);
TempNewSymbol f_name = SymbolTable::new_symbol(field_name, CATCH); TempNewSymbol f_name = SymbolTable::new_symbol(field_name);
TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig, CATCH); TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig);
if (!ik->find_local_field(f_name, f_sig, &fd)) { if (!ik->find_local_field(f_name, f_sig, &fd)) {
tty->print_cr("Nonstatic field %s.%s not found", klass_name, field_name); tty->print_cr("Nonstatic field %s.%s not found", klass_name, field_name);
return false; return false;

View file

@ -205,7 +205,7 @@ class java_lang_String : AllStatic {
static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); } static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
// Conversion // Conversion
static Symbol* as_symbol(oop java_string, TRAPS); static Symbol* as_symbol(oop java_string);
static Symbol* as_symbol_or_null(oop java_string); static Symbol* as_symbol_or_null(oop java_string);
// Testers // Testers
@ -291,7 +291,7 @@ class java_lang_Class : AllStatic {
static Klass* as_Klass_raw(oop java_class); static Klass* as_Klass_raw(oop java_class);
static void set_klass(oop java_class, Klass* klass); static void set_klass(oop java_class, Klass* klass);
static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL); static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL);
static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS); static Symbol* as_signature(oop java_class, bool intern_if_not_found);
static void print_signature(oop java_class, outputStream *st); static void print_signature(oop java_class, outputStream *st);
static const char* as_external_name(oop java_class); static const char* as_external_name(oop java_class);
// Testing // Testing
@ -1166,7 +1166,7 @@ class java_lang_invoke_MethodType: AllStatic {
static int ptype_slot_count(oop mt); // extra counts for long/double static int ptype_slot_count(oop mt); // extra counts for long/double
static int rtype_slot_count(oop mt); // extra counts for long/double static int rtype_slot_count(oop mt); // extra counts for long/double
static Symbol* as_signature(oop mt, bool intern_if_not_found, TRAPS); static Symbol* as_signature(oop mt, bool intern_if_not_found);
static void print_signature(oop mt, outputStream* st); static void print_signature(oop mt, outputStream* st);
static bool is_instance(oop obj); static bool is_instance(oop obj);

View file

@ -111,7 +111,7 @@ static ModuleEntry* get_module_entry(jobject module, TRAPS) {
static PackageEntry* get_package_entry(ModuleEntry* module_entry, const char* package_name, TRAPS) { static PackageEntry* get_package_entry(ModuleEntry* module_entry, const char* package_name, TRAPS) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
if (package_name == NULL) return NULL; if (package_name == NULL) return NULL;
TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK_NULL); TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name);
PackageEntryTable* package_entry_table = module_entry->loader_data()->packages(); PackageEntryTable* package_entry_table = module_entry->loader_data()->packages();
assert(package_entry_table != NULL, "Unexpected null package entry table"); assert(package_entry_table != NULL, "Unexpected null package entry table");
return package_entry_table->lookup_only(pkg_symbol); return package_entry_table->lookup_only(pkg_symbol);
@ -148,7 +148,7 @@ static void define_javabase_module(jobject module, jstring version,
const char* module_version = get_module_version(version); const char* module_version = get_module_version(version);
TempNewSymbol version_symbol; TempNewSymbol version_symbol;
if (module_version != NULL) { if (module_version != NULL) {
version_symbol = SymbolTable::new_symbol(module_version, CHECK); version_symbol = SymbolTable::new_symbol(module_version);
} else { } else {
version_symbol = NULL; version_symbol = NULL;
} }
@ -160,7 +160,7 @@ static void define_javabase_module(jobject module, jstring version,
module_location = module_location =
java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(location)); java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(location));
if (module_location != NULL) { if (module_location != NULL) {
location_symbol = SymbolTable::new_symbol(module_location, CHECK); location_symbol = SymbolTable::new_symbol(module_location);
} }
} }
@ -173,7 +173,7 @@ static void define_javabase_module(jobject module, jstring version,
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
err_msg("Invalid package name: %s for module: " JAVA_BASE_NAME, package_name)); err_msg("Invalid package name: %s for module: " JAVA_BASE_NAME, package_name));
} }
Symbol* pkg_symbol = SymbolTable::new_symbol(package_name, CHECK); Symbol* pkg_symbol = SymbolTable::new_symbol(package_name);
pkg_list->append(pkg_symbol); pkg_list->append(pkg_symbol);
} }
@ -345,7 +345,7 @@ void Modules::define_module(jobject module, jboolean is_open, jstring version,
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), message); THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), message);
} }
Symbol* pkg_symbol = SymbolTable::new_symbol(package_name, CHECK); Symbol* pkg_symbol = SymbolTable::new_symbol(package_name);
pkg_list->append(pkg_symbol); pkg_list->append(pkg_symbol);
} }
@ -353,14 +353,14 @@ void Modules::define_module(jobject module, jboolean is_open, jstring version,
assert(module_table != NULL, "module entry table shouldn't be null"); assert(module_table != NULL, "module entry table shouldn't be null");
// Create symbol* entry for module name. // Create symbol* entry for module name.
TempNewSymbol module_symbol = SymbolTable::new_symbol(module_name, CHECK); TempNewSymbol module_symbol = SymbolTable::new_symbol(module_name);
bool dupl_modules = false; bool dupl_modules = false;
// Create symbol* entry for module version. // Create symbol* entry for module version.
TempNewSymbol version_symbol; TempNewSymbol version_symbol;
if (module_version != NULL) { if (module_version != NULL) {
version_symbol = SymbolTable::new_symbol(module_version, CHECK); version_symbol = SymbolTable::new_symbol(module_version);
} else { } else {
version_symbol = NULL; version_symbol = NULL;
} }
@ -372,7 +372,7 @@ void Modules::define_module(jobject module, jboolean is_open, jstring version,
module_location = module_location =
java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(location)); java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(location));
if (module_location != NULL) { if (module_location != NULL) {
location_symbol = SymbolTable::new_symbol(module_location, CHECK); location_symbol = SymbolTable::new_symbol(module_location);
} }
} }
@ -657,7 +657,7 @@ jobject Modules::get_named_module(Handle h_loader, const char* package_name, TRA
if (strlen(package_name) == 0) { if (strlen(package_name) == 0) {
return NULL; return NULL;
} }
TempNewSymbol package_sym = SymbolTable::new_symbol(package_name, CHECK_NULL); TempNewSymbol package_sym = SymbolTable::new_symbol(package_name);
const PackageEntry* const pkg_entry = const PackageEntry* const pkg_entry =
get_package_entry_by_name(package_sym, h_loader, THREAD); get_package_entry_by_name(package_sym, h_loader, THREAD);
const ModuleEntry* const module_entry = (pkg_entry != NULL ? pkg_entry->module() : NULL); const ModuleEntry* const module_entry = (pkg_entry != NULL ? pkg_entry->module() : NULL);

View file

@ -92,8 +92,7 @@ VerificationType StackMapFrame::set_locals_from_arg(
// local num may be greater than size of parameters because long/double occupies two slots // local num may be greater than size of parameters because long/double occupies two slots
while(!ss.at_return_type()) { while(!ss.at_return_type()) {
init_local_num += _verifier->change_sig_to_verificationType( init_local_num += _verifier->change_sig_to_verificationType(
&ss, &_locals[init_local_num], &ss, &_locals[init_local_num]);
CHECK_VERIFY_(verifier(), VerificationType::bogus_type()));
ss.next(); ss.next();
} }
_locals_size = init_local_num; _locals_size = init_local_num;
@ -102,13 +101,12 @@ VerificationType StackMapFrame::set_locals_from_arg(
case T_OBJECT: case T_OBJECT:
case T_ARRAY: case T_ARRAY:
{ {
Symbol* sig = ss.as_symbol(CHECK_(VerificationType::bogus_type())); Symbol* sig = ss.as_symbol();
if (!sig->is_permanent()) { if (!sig->is_permanent()) {
// Create another symbol to save as signature stream unreferences // Create another symbol to save as signature stream unreferences
// this symbol. // this symbol.
Symbol *sig_copy = Symbol *sig_copy =
verifier()->create_temporary_symbol(sig, 0, sig->utf8_length(), verifier()->create_temporary_symbol(sig, 0, sig->utf8_length());
CHECK_(VerificationType::bogus_type()));
assert(sig_copy == sig, "symbols don't match"); assert(sig_copy == sig, "symbols don't match");
sig = sig_copy; sig = sig_copy;
} }

View file

@ -195,7 +195,7 @@ void SymbolTable::trigger_cleanup() {
Service_lock->notify_all(); Service_lock->notify_all();
} }
Symbol* SymbolTable::allocate_symbol(const char* name, int len, bool c_heap, TRAPS) { Symbol* SymbolTable::allocate_symbol(const char* name, int len, bool c_heap) {
assert (len <= Symbol::max_length(), "should be checked by caller"); assert (len <= Symbol::max_length(), "should be checked by caller");
Symbol* sym; Symbol* sym;
@ -204,12 +204,12 @@ Symbol* SymbolTable::allocate_symbol(const char* name, int len, bool c_heap, TRA
} }
if (c_heap) { if (c_heap) {
// refcount starts as 1 // refcount starts as 1
sym = new (len, THREAD) Symbol((const u1*)name, len, 1); sym = new (len) Symbol((const u1*)name, len, 1);
assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted"); assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted");
} else { } else {
// Allocate to global arena // Allocate to global arena
MutexLocker ml(SymbolArena_lock, Mutex::_no_safepoint_check_flag); // Protect arena MutexLocker ml(SymbolArena_lock, Mutex::_no_safepoint_check_flag); // Protect arena
sym = new (len, arena(), THREAD) Symbol((const u1*)name, len, PERM_REFCOUNT); sym = new (len, arena()) Symbol((const u1*)name, len, PERM_REFCOUNT);
} }
return sym; return sym;
} }
@ -317,25 +317,26 @@ Symbol* SymbolTable::lookup_common(const char* name,
return sym; return sym;
} }
Symbol* SymbolTable::lookup(const char* name, int len, TRAPS) { Symbol* SymbolTable::new_symbol(const char* name, int len) {
unsigned int hash = hash_symbol(name, len, SymbolTable::_alt_hash); unsigned int hash = hash_symbol(name, len, SymbolTable::_alt_hash);
Symbol* sym = SymbolTable::the_table()->lookup_common(name, len, hash); Symbol* sym = SymbolTable::the_table()->lookup_common(name, len, hash);
if (sym == NULL) { if (sym == NULL) {
sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, true, CHECK_NULL); sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, true);
} }
assert(sym->refcount() != 0, "lookup should have incremented the count"); assert(sym->refcount() != 0, "lookup should have incremented the count");
assert(sym->equals(name, len), "symbol must be properly initialized"); assert(sym->equals(name, len), "symbol must be properly initialized");
return sym; return sym;
} }
Symbol* SymbolTable::lookup(const Symbol* sym, int begin, int end, TRAPS) { Symbol* SymbolTable::new_symbol(const Symbol* sym, int begin, int end) {
assert(begin <= end && end <= sym->utf8_length(), "just checking");
assert(sym->refcount() != 0, "require a valid symbol"); assert(sym->refcount() != 0, "require a valid symbol");
const char* name = (const char*)sym->base() + begin; const char* name = (const char*)sym->base() + begin;
int len = end - begin; int len = end - begin;
unsigned int hash = hash_symbol(name, len, SymbolTable::_alt_hash); unsigned int hash = hash_symbol(name, len, SymbolTable::_alt_hash);
Symbol* found = SymbolTable::the_table()->lookup_common(name, len, hash); Symbol* found = SymbolTable::the_table()->lookup_common(name, len, hash);
if (found == NULL) { if (found == NULL) {
found = SymbolTable::the_table()->do_add_if_needed(name, len, hash, true, THREAD); found = SymbolTable::the_table()->do_add_if_needed(name, len, hash, true);
} }
return found; return found;
} }
@ -347,8 +348,8 @@ private:
int _len; int _len;
const char* _str; const char* _str;
public: public:
SymbolTableLookup(Thread* thread, const char* key, int len, uintx hash) SymbolTableLookup(const char* key, int len, uintx hash)
: _thread(thread), _hash(hash), _len(len), _str(key) {} : _hash(hash), _len(len), _str(key) {}
uintx get_hash() const { uintx get_hash() const {
return _hash; return _hash;
} }
@ -388,7 +389,7 @@ public:
Symbol* SymbolTable::do_lookup(const char* name, int len, uintx hash) { Symbol* SymbolTable::do_lookup(const char* name, int len, uintx hash) {
Thread* thread = Thread::current(); Thread* thread = Thread::current();
SymbolTableLookup lookup(thread, name, len, hash); SymbolTableLookup lookup(name, len, hash);
SymbolTableGet stg; SymbolTableGet stg;
bool rehash_warning = false; bool rehash_warning = false;
_local_table->get(thread, lookup, stg, &rehash_warning); _local_table->get(thread, lookup, stg, &rehash_warning);
@ -406,18 +407,18 @@ Symbol* SymbolTable::lookup_only(const char* name, int len, unsigned int& hash)
// Suggestion: Push unicode-based lookup all the way into the hashing // Suggestion: Push unicode-based lookup all the way into the hashing
// and probing logic, so there is no need for convert_to_utf8 until // and probing logic, so there is no need for convert_to_utf8 until
// an actual new Symbol* is created. // an actual new Symbol* is created.
Symbol* SymbolTable::lookup_unicode(const jchar* name, int utf16_length, TRAPS) { Symbol* SymbolTable::new_symbol(const jchar* name, int utf16_length) {
int utf8_length = UNICODE::utf8_length((jchar*) name, utf16_length); int utf8_length = UNICODE::utf8_length((jchar*) name, utf16_length);
char stack_buf[ON_STACK_BUFFER_LENGTH]; char stack_buf[ON_STACK_BUFFER_LENGTH];
if (utf8_length < (int) sizeof(stack_buf)) { if (utf8_length < (int) sizeof(stack_buf)) {
char* chars = stack_buf; char* chars = stack_buf;
UNICODE::convert_to_utf8(name, utf16_length, chars); UNICODE::convert_to_utf8(name, utf16_length, chars);
return lookup(chars, utf8_length, THREAD); return new_symbol(chars, utf8_length);
} else { } else {
ResourceMark rm(THREAD); ResourceMark rm;
char* chars = NEW_RESOURCE_ARRAY(char, utf8_length + 1); char* chars = NEW_RESOURCE_ARRAY(char, utf8_length + 1);
UNICODE::convert_to_utf8(name, utf16_length, chars); UNICODE::convert_to_utf8(name, utf16_length, chars);
return lookup(chars, utf8_length, THREAD); return new_symbol(chars, utf8_length);
} }
} }
@ -439,32 +440,33 @@ Symbol* SymbolTable::lookup_only_unicode(const jchar* name, int utf16_length,
void SymbolTable::new_symbols(ClassLoaderData* loader_data, const constantPoolHandle& cp, void SymbolTable::new_symbols(ClassLoaderData* loader_data, const constantPoolHandle& cp,
int names_count, const char** names, int* lengths, int names_count, const char** names, int* lengths,
int* cp_indices, unsigned int* hashValues, TRAPS) { int* cp_indices, unsigned int* hashValues) {
bool c_heap = !loader_data->is_the_null_class_loader_data(); bool c_heap = !loader_data->is_the_null_class_loader_data();
for (int i = 0; i < names_count; i++) { for (int i = 0; i < names_count; i++) {
const char *name = names[i]; const char *name = names[i];
int len = lengths[i]; int len = lengths[i];
unsigned int hash = hashValues[i]; unsigned int hash = hashValues[i];
assert(SymbolTable::the_table()->lookup_shared(name, len, hash) == NULL, "must have checked already"); assert(SymbolTable::the_table()->lookup_shared(name, len, hash) == NULL, "must have checked already");
Symbol* sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, c_heap, CHECK); Symbol* sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, c_heap);
assert(sym->refcount() != 0, "lookup should have incremented the count"); assert(sym->refcount() != 0, "lookup should have incremented the count");
cp->symbol_at_put(cp_indices[i], sym); cp->symbol_at_put(cp_indices[i], sym);
} }
} }
Symbol* SymbolTable::do_add_if_needed(const char* name, int len, uintx hash, bool heap, TRAPS) { Symbol* SymbolTable::do_add_if_needed(const char* name, int len, uintx hash, bool heap) {
SymbolTableLookup lookup(THREAD, name, len, hash); SymbolTableLookup lookup(name, len, hash);
SymbolTableGet stg; SymbolTableGet stg;
bool clean_hint = false; bool clean_hint = false;
bool rehash_warning = false; bool rehash_warning = false;
Symbol* sym = NULL; Symbol* sym = NULL;
Thread* THREAD = Thread::current();
do { do {
if (_local_table->get(THREAD, lookup, stg, &rehash_warning)) { if (_local_table->get(THREAD, lookup, stg, &rehash_warning)) {
sym = stg.get_res_sym(); sym = stg.get_res_sym();
break; break;
} }
sym = SymbolTable::the_table()->allocate_symbol(name, len, heap, THREAD); sym = SymbolTable::the_table()->allocate_symbol(name, len, heap);
if (_local_table->insert(THREAD, lookup, sym, &rehash_warning, &clean_hint)) { if (_local_table->insert(THREAD, lookup, sym, &rehash_warning, &clean_hint)) {
break; break;
} }
@ -481,12 +483,12 @@ Symbol* SymbolTable::do_add_if_needed(const char* name, int len, uintx hash, boo
return sym; return sym;
} }
Symbol* SymbolTable::new_permanent_symbol(const char* name, TRAPS) { Symbol* SymbolTable::new_permanent_symbol(const char* name) {
unsigned int hash = 0; unsigned int hash = 0;
int len = (int)strlen(name); int len = (int)strlen(name);
Symbol* sym = SymbolTable::lookup_only(name, len, hash); Symbol* sym = SymbolTable::lookup_only(name, len, hash);
if (sym == NULL) { if (sym == NULL) {
sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, false, CHECK_NULL); sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, false);
} }
if (!sym->is_permanent()) { if (!sym->is_permanent()) {
sym->make_permanent(); sym->make_permanent();

View file

@ -43,7 +43,7 @@ class JavaThread;
// it becomes "managed" by TempNewSymbol instances. As a handle class, TempNewSymbol // it becomes "managed" by TempNewSymbol instances. As a handle class, TempNewSymbol
// needs to maintain proper reference counting in context of copy semantics. // needs to maintain proper reference counting in context of copy semantics.
// //
// In SymbolTable, new_symbol() and lookup() will create a Symbol* if not already in the // In SymbolTable, new_symbol() will create a Symbol* if not already in the
// symbol table and add to the symbol's reference count. // symbol table and add to the symbol's reference count.
// probe() and lookup_only() will increment the refcount if symbol is found. // probe() and lookup_only() will increment the refcount if symbol is found.
class TempNewSymbol : public StackObj { class TempNewSymbol : public StackObj {
@ -139,16 +139,19 @@ private:
SymbolTable(); SymbolTable();
Symbol* allocate_symbol(const char* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F Symbol* allocate_symbol(const char* name, int len, bool c_heap); // Assumes no characters larger than 0x7F
Symbol* do_lookup(const char* name, int len, uintx hash); Symbol* do_lookup(const char* name, int len, uintx hash);
Symbol* do_add_if_needed(const char* name, int len, uintx hash, bool heap, TRAPS); Symbol* do_add_if_needed(const char* name, int len, uintx hash, bool heap);
// lookup only, won't add. Also calculate hash. Used by the ClassfileParser.
static Symbol* lookup_only(const char* name, int len, unsigned int& hash);
static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash);
// Adding elements // Adding elements
static void new_symbols(ClassLoaderData* loader_data, static void new_symbols(ClassLoaderData* loader_data,
const constantPoolHandle& cp, int names_count, const constantPoolHandle& cp, int names_count,
const char** name, int* lengths, const char** name, int* lengths,
int* cp_indices, unsigned int* hashValues, int* cp_indices, unsigned int* hashValues);
TRAPS);
static Symbol* lookup_shared(const char* name, int len, unsigned int hash); static Symbol* lookup_shared(const char* name, int len, unsigned int hash);
Symbol* lookup_dynamic(const char* name, int len, unsigned int hash); Symbol* lookup_dynamic(const char* name, int len, unsigned int hash);
@ -190,14 +193,6 @@ public:
static void trigger_cleanup(); static void trigger_cleanup();
// Probing // Probing
static Symbol* lookup(const char* name, int len, TRAPS);
// lookup only, won't add. Also calculate hash.
static Symbol* lookup_only(const char* name, int len, unsigned int& hash);
// adds new symbol if not found
static Symbol* lookup(const Symbol* sym, int begin, int end, TRAPS);
// jchar (UTF16) version of lookups
static Symbol* lookup_unicode(const jchar* name, int len, TRAPS);
static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash);
// Needed for preloading classes in signatures when compiling. // Needed for preloading classes in signatures when compiling.
// Returns the symbol is already present in symbol table, otherwise // Returns the symbol is already present in symbol table, otherwise
// NULL. NO ALLOCATION IS GUARANTEED! // NULL. NO ALLOCATION IS GUARANTEED!
@ -210,20 +205,18 @@ public:
return lookup_only_unicode(name, len, ignore_hash); return lookup_only_unicode(name, len, ignore_hash);
} }
// Symbol creation // Symbol lookup and create if not found.
static Symbol* new_symbol(const char* utf8_buffer, int length, TRAPS) { // jchar (UTF16) version of lookup
assert(utf8_buffer != NULL, "just checking"); static Symbol* new_symbol(const jchar* name, int len);
return lookup(utf8_buffer, length, THREAD); // char (UTF8) versions
} static Symbol* new_symbol(const Symbol* sym, int begin, int end);
static Symbol* new_symbol(const char* name, TRAPS) { static Symbol* new_symbol(const char* utf8_buffer, int length);
return new_symbol(name, (int)strlen(name), THREAD); static Symbol* new_symbol(const char* name) {
} return new_symbol(name, (int)strlen(name));
static Symbol* new_symbol(const Symbol* sym, int begin, int end, TRAPS) {
assert(begin <= end && end <= sym->utf8_length(), "just checking");
return lookup(sym, begin, end, THREAD);
} }
// Create a symbol in the arena for symbols that are not deleted // Create a symbol in the arena for symbols that are not deleted
static Symbol* new_permanent_symbol(const char* name, TRAPS); static Symbol* new_permanent_symbol(const char* name);
// Rehash the string table if it gets out of balance // Rehash the string table if it gets out of balance
static void rehash_table(); static void rehash_table();
@ -245,7 +238,6 @@ public:
static void dump(outputStream* st, bool verbose=false); static void dump(outputStream* st, bool verbose=false);
// Debugging // Debugging
static void verify(); static void verify();
static void read(const char* filename, TRAPS);
// Histogram // Histogram
static void print_histogram() PRODUCT_RETURN; static void print_histogram() PRODUCT_RETURN;

View file

@ -263,7 +263,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null_helper(Symbol* c
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
// Ignore wrapping L and ;. // Ignore wrapping L and ;.
TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1, TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
class_name->utf8_length() - 2, CHECK_NULL); class_name->utf8_length() - 2);
return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD); return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
} else { } else {
return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD); return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD);
@ -2356,7 +2356,7 @@ Symbol* SystemDictionary::check_signature_loaders(Symbol* signature,
SignatureStream sig_strm(signature, is_method); SignatureStream sig_strm(signature, is_method);
while (!sig_strm.is_done()) { while (!sig_strm.is_done()) {
if (sig_strm.is_object()) { if (sig_strm.is_object()) {
Symbol* sig = sig_strm.as_symbol(CHECK_NULL); Symbol* sig = sig_strm.as_symbol();
if (!add_loader_constraint(sig, loader1, loader2, THREAD)) { if (!add_loader_constraint(sig, loader1, loader2, THREAD)) {
return sig; return sig;
} }
@ -2626,7 +2626,7 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature,
mirror = ss.as_java_mirror(class_loader, protection_domain, mirror = ss.as_java_mirror(class_loader, protection_domain,
SignatureStream::NCDFError, CHECK_(empty)); SignatureStream::NCDFError, CHECK_(empty));
} }
assert(mirror != NULL, "%s", ss.as_symbol(THREAD)->as_C_string()); assert(mirror != NULL, "%s", ss.as_symbol()->as_C_string());
if (ss.at_return_type()) if (ss.at_return_type())
rt = Handle(THREAD, mirror); rt = Handle(THREAD, mirror);
else else

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -129,13 +129,11 @@ VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS)
case 'D': return VerificationType(Double); case 'D': return VerificationType(Double);
case '[': case '[':
component = context->create_temporary_symbol( component = context->create_temporary_symbol(
name(), 1, name()->utf8_length(), name(), 1, name()->utf8_length());
CHECK_(VerificationType::bogus_type()));
return VerificationType::reference_type(component); return VerificationType::reference_type(component);
case 'L': case 'L':
component = context->create_temporary_symbol( component = context->create_temporary_symbol(
name(), 2, name()->utf8_length() - 1, name(), 2, name()->utf8_length() - 1);
CHECK_(VerificationType::bogus_type()));
return VerificationType::reference_type(component); return VerificationType::reference_type(component);
default: default:
// Met an invalid type signature, e.g. [X // Met an invalid type signature, e.g. [X

View file

@ -595,9 +595,9 @@ VerificationType ClassVerifier::object_type() const {
return VerificationType::reference_type(vmSymbols::java_lang_Object()); return VerificationType::reference_type(vmSymbols::java_lang_Object());
} }
TypeOrigin ClassVerifier::ref_ctx(const char* sig, TRAPS) { TypeOrigin ClassVerifier::ref_ctx(const char* sig) {
VerificationType vt = VerificationType::reference_type( VerificationType vt = VerificationType::reference_type(
create_temporary_symbol(sig, (int)strlen(sig), THREAD)); create_temporary_symbol(sig, (int)strlen(sig)));
return TypeOrigin::implicit(vt); return TypeOrigin::implicit(vt);
} }
@ -647,7 +647,7 @@ void ClassVerifier::translate_signature(Symbol* const method_sig,
// Translate the signature arguments into verification types. // Translate the signature arguments into verification types.
while (!sig_stream.at_return_type()) { while (!sig_stream.at_return_type()) {
int n = change_sig_to_verificationType(&sig_stream, sig_type, CHECK_VERIFY(this)); int n = change_sig_to_verificationType(&sig_stream, sig_type);
assert(n <= 2, "Unexpected signature type"); assert(n <= 2, "Unexpected signature type");
// Store verification type(s). Longs and Doubles each have two verificationTypes. // Store verification type(s). Longs and Doubles each have two verificationTypes.
@ -664,7 +664,7 @@ void ClassVerifier::translate_signature(Symbol* const method_sig,
// Store verification type(s) for the return type, if there is one. // Store verification type(s) for the return type, if there is one.
if (sig_stream.type() != T_VOID) { if (sig_stream.type() != T_VOID) {
int n = change_sig_to_verificationType(&sig_stream, sig_type, CHECK_VERIFY(this)); int n = change_sig_to_verificationType(&sig_stream, sig_type);
assert(n <= 2, "Unexpected signature return type"); assert(n <= 2, "Unexpected signature return type");
for (int y = 0; y < n; y++) { for (int y = 0; y < n; y++) {
verif_types->push(sig_type[y]); verif_types->push(sig_type[y]);
@ -925,7 +925,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_int_array()) { if (!atype.is_int_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[I", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[I")),
bad_type_msg, "iaload"); bad_type_msg, "iaload");
return; return;
} }
@ -953,7 +953,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_char_array()) { if (!atype.is_char_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[C", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[C")),
bad_type_msg, "caload"); bad_type_msg, "caload");
return; return;
} }
@ -967,7 +967,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_short_array()) { if (!atype.is_short_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[S", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[S")),
bad_type_msg, "saload"); bad_type_msg, "saload");
return; return;
} }
@ -981,7 +981,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_long_array()) { if (!atype.is_long_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[J", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[J")),
bad_type_msg, "laload"); bad_type_msg, "laload");
return; return;
} }
@ -996,7 +996,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_float_array()) { if (!atype.is_float_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[F", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[F")),
bad_type_msg, "faload"); bad_type_msg, "faload");
return; return;
} }
@ -1010,7 +1010,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_double_array()) { if (!atype.is_double_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[D", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[D")),
bad_type_msg, "daload"); bad_type_msg, "daload");
return; return;
} }
@ -1099,7 +1099,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_int_array()) { if (!atype.is_int_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[I", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[I")),
bad_type_msg, "iastore"); bad_type_msg, "iastore");
return; return;
} }
@ -1127,7 +1127,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_char_array()) { if (!atype.is_char_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[C", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[C")),
bad_type_msg, "castore"); bad_type_msg, "castore");
return; return;
} }
@ -1141,7 +1141,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_short_array()) { if (!atype.is_short_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[S", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[S")),
bad_type_msg, "sastore"); bad_type_msg, "sastore");
return; return;
} }
@ -1156,7 +1156,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_long_array()) { if (!atype.is_long_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[J", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[J")),
bad_type_msg, "lastore"); bad_type_msg, "lastore");
return; return;
} }
@ -1170,7 +1170,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_float_array()) { if (!atype.is_float_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[F", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[F")),
bad_type_msg, "fastore"); bad_type_msg, "fastore");
return; return;
} }
@ -1185,7 +1185,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
VerificationType::reference_check(), CHECK_VERIFY(this)); VerificationType::reference_check(), CHECK_VERIFY(this));
if (!atype.is_double_array()) { if (!atype.is_double_array()) {
verify_error(ErrorContext::bad_type(bci, verify_error(ErrorContext::bad_type(bci,
current_frame.stack_top_ctx(), ref_ctx("[D", THREAD)), current_frame.stack_top_ctx(), ref_ctx("[D")),
bad_type_msg, "dastore"); bad_type_msg, "dastore");
return; return;
} }
@ -2183,8 +2183,7 @@ void ClassVerifier::verify_ldc(
uintptr_t constant_type_buffer[2]; uintptr_t constant_type_buffer[2];
VerificationType* v_constant_type = (VerificationType*)constant_type_buffer; VerificationType* v_constant_type = (VerificationType*)constant_type_buffer;
SignatureStream sig_stream(constant_type, false); SignatureStream sig_stream(constant_type, false);
int n = change_sig_to_verificationType( int n = change_sig_to_verificationType(&sig_stream, v_constant_type);
&sig_stream, v_constant_type, CHECK_VERIFY(this));
int opcode_n = (opcode == Bytecodes::_ldc2_w ? 2 : 1); int opcode_n = (opcode == Bytecodes::_ldc2_w ? 2 : 1);
if (n != opcode_n) { if (n != opcode_n) {
// wrong kind of ldc; reverify against updated type mask // wrong kind of ldc; reverify against updated type mask
@ -2325,8 +2324,7 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
SignatureStream sig_stream(field_sig, false); SignatureStream sig_stream(field_sig, false);
VerificationType stack_object_type; VerificationType stack_object_type;
int n = change_sig_to_verificationType( int n = change_sig_to_verificationType(&sig_stream, field_type);
&sig_stream, field_type, CHECK_VERIFY(this));
u2 bci = bcs->bci(); u2 bci = bcs->bci();
bool is_assignable; bool is_assignable;
switch (bcs->raw_code()) { switch (bcs->raw_code()) {
@ -3002,8 +3000,7 @@ VerificationType ClassVerifier::get_newarray_type(
} }
// from_bt[index] contains the array signature which has a length of 2 // from_bt[index] contains the array signature which has a length of 2
Symbol* sig = create_temporary_symbol( Symbol* sig = create_temporary_symbol(from_bt[index], 2);
from_bt[index], 2, CHECK_(VerificationType::bogus_type()));
return VerificationType::reference_type(sig); return VerificationType::reference_type(sig);
} }
@ -3041,8 +3038,7 @@ void ClassVerifier::verify_anewarray(
int n = os::snprintf(arr_sig_str, length + 1, "[L%s;", component_name); int n = os::snprintf(arr_sig_str, length + 1, "[L%s;", component_name);
assert(n == length, "Unexpected number of characters in string"); assert(n == length, "Unexpected number of characters in string");
} }
Symbol* arr_sig = create_temporary_symbol( Symbol* arr_sig = create_temporary_symbol(arr_sig_str, length);
arr_sig_str, length, CHECK_VERIFY(this));
VerificationType new_array_type = VerificationType::reference_type(arr_sig); VerificationType new_array_type = VerificationType::reference_type(arr_sig);
current_frame->push_stack(new_array_type, CHECK_VERIFY(this)); current_frame->push_stack(new_array_type, CHECK_VERIFY(this));
} }
@ -3150,18 +3146,18 @@ void ClassVerifier::verify_return_value(
// These are stored in the verifier until the end of verification so that // These are stored in the verifier until the end of verification so that
// they can be reference counted. // they can be reference counted.
Symbol* ClassVerifier::create_temporary_symbol(const Symbol *s, int begin, Symbol* ClassVerifier::create_temporary_symbol(const Symbol *s, int begin,
int end, TRAPS) { int end) {
const char* name = (const char*)s->base() + begin; const char* name = (const char*)s->base() + begin;
int length = end - begin; int length = end - begin;
return create_temporary_symbol(name, length, CHECK_NULL); return create_temporary_symbol(name, length);
} }
Symbol* ClassVerifier::create_temporary_symbol(const char *name, int length, TRAPS) { Symbol* ClassVerifier::create_temporary_symbol(const char *name, int length) {
// Quick deduplication check // Quick deduplication check
if (_previous_symbol != NULL && _previous_symbol->equals(name, length)) { if (_previous_symbol != NULL && _previous_symbol->equals(name, length)) {
return _previous_symbol; return _previous_symbol;
} }
Symbol* sym = SymbolTable::new_symbol(name, length, CHECK_NULL); Symbol* sym = SymbolTable::new_symbol(name, length);
if (!sym->is_permanent()) { if (!sym->is_permanent()) {
if (_symbols == NULL) { if (_symbols == NULL) {
_symbols = new GrowableArray<Symbol*>(50, 0, NULL); _symbols = new GrowableArray<Symbol*>(50, 0, NULL);

View file

@ -446,7 +446,7 @@ class ClassVerifier : public StackObj {
} }
int change_sig_to_verificationType( int change_sig_to_verificationType(
SignatureStream* sig_type, VerificationType* inference_type, TRAPS); SignatureStream* sig_type, VerificationType* inference_type);
VerificationType cp_index_to_type(int index, const constantPoolHandle& cp, TRAPS) { VerificationType cp_index_to_type(int index, const constantPoolHandle& cp, TRAPS) {
return VerificationType::reference_type(cp->klass_name_at(index)); return VerificationType::reference_type(cp->klass_name_at(index));
@ -456,8 +456,8 @@ class ClassVerifier : public StackObj {
// their reference counts need to be decremented when the verifier object // their reference counts need to be decremented when the verifier object
// goes out of scope. Since these symbols escape the scope in which they're // goes out of scope. Since these symbols escape the scope in which they're
// created, we can't use a TempNewSymbol. // created, we can't use a TempNewSymbol.
Symbol* create_temporary_symbol(const Symbol* s, int begin, int end, TRAPS); Symbol* create_temporary_symbol(const Symbol* s, int begin, int end);
Symbol* create_temporary_symbol(const char *s, int length, TRAPS); Symbol* create_temporary_symbol(const char *s, int length);
Symbol* create_temporary_symbol(Symbol* s) { Symbol* create_temporary_symbol(Symbol* s) {
if (s == _previous_symbol) { if (s == _previous_symbol) {
return s; return s;
@ -473,18 +473,18 @@ class ClassVerifier : public StackObj {
return s; return s;
} }
TypeOrigin ref_ctx(const char* str, TRAPS); TypeOrigin ref_ctx(const char* str);
}; };
inline int ClassVerifier::change_sig_to_verificationType( inline int ClassVerifier::change_sig_to_verificationType(
SignatureStream* sig_type, VerificationType* inference_type, TRAPS) { SignatureStream* sig_type, VerificationType* inference_type) {
BasicType bt = sig_type->type(); BasicType bt = sig_type->type();
switch (bt) { switch (bt) {
case T_OBJECT: case T_OBJECT:
case T_ARRAY: case T_ARRAY:
{ {
Symbol* name = sig_type->as_symbol(CHECK_0); Symbol* name = sig_type->as_symbol();
// Create another symbol to save as signature stream unreferences this symbol. // Create another symbol to save as signature stream unreferences this symbol.
Symbol* name_copy = create_temporary_symbol(name); Symbol* name_copy = create_temporary_symbol(name);
assert(name_copy == name, "symbols don't match"); assert(name_copy == name, "symbols don't match");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -84,7 +84,7 @@ void vmSymbols::initialize(TRAPS) {
if (!UseSharedSpaces) { if (!UseSharedSpaces) {
const char* string = &vm_symbol_bodies[0]; const char* string = &vm_symbol_bodies[0];
for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) { for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
Symbol* sym = SymbolTable::new_permanent_symbol(string, CHECK); Symbol* sym = SymbolTable::new_permanent_symbol(string);
_symbols[index] = sym; _symbols[index] = sym;
string += strlen(string); // skip string body string += strlen(string); // skip string body
string += 1; // skip trailing null string += 1; // skip trailing null
@ -141,7 +141,7 @@ void vmSymbols::initialize(TRAPS) {
// Spot-check correspondence between strings, symbols, and enums: // Spot-check correspondence between strings, symbols, and enums:
assert(_symbols[NO_SID] == NULL, "must be"); assert(_symbols[NO_SID] == NULL, "must be");
const char* str = "java/lang/Object"; const char* str = "java/lang/Object";
TempNewSymbol jlo = SymbolTable::new_permanent_symbol(str, CHECK); TempNewSymbol jlo = SymbolTable::new_permanent_symbol(str);
assert(strncmp(str, (char*)jlo->base(), jlo->utf8_length()) == 0, ""); assert(strncmp(str, (char*)jlo->base(), jlo->utf8_length()) == 0, "");
assert(jlo == java_lang_Object(), ""); assert(jlo == java_lang_Object(), "");
SID sid = VM_SYMBOL_ENUM_NAME(java_lang_Object); SID sid = VM_SYMBOL_ENUM_NAME(java_lang_Object);
@ -160,7 +160,7 @@ void vmSymbols::initialize(TRAPS) {
// The string "format" happens (at the moment) not to be a vmSymbol, // The string "format" happens (at the moment) not to be a vmSymbol,
// though it is a method name in java.lang.String. // though it is a method name in java.lang.String.
str = "format"; str = "format";
TempNewSymbol fmt = SymbolTable::new_permanent_symbol(str, CHECK); TempNewSymbol fmt = SymbolTable::new_permanent_symbol(str);
sid = find_sid(fmt); sid = find_sid(fmt);
assert(sid == NO_SID, "symbol index works (negative test)"); assert(sid == NO_SID, "symbol index works (negative test)");
} }

View file

@ -829,8 +829,8 @@ void CompilerOracle::parse_compile_only(char * line) {
} }
EXCEPTION_MARK; EXCEPTION_MARK;
Symbol* c_name = SymbolTable::new_symbol(className, CHECK); Symbol* c_name = SymbolTable::new_symbol(className);
Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK); Symbol* m_name = SymbolTable::new_symbol(methodName);
Symbol* signature = NULL; Symbol* signature = NULL;
BasicMatcher* bm = new BasicMatcher(); BasicMatcher* bm = new BasicMatcher();

View file

@ -300,10 +300,10 @@ void MethodMatcher::parse_method_pattern(char*& line, const char*& error_msg, Me
} }
line += bytes_read; line += bytes_read;
} }
signature = SymbolTable::new_symbol(sig, CHECK); signature = SymbolTable::new_symbol(sig);
} }
Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK); Symbol* c_name = SymbolTable::new_symbol(class_name);
Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK); Symbol* m_name = SymbolTable::new_symbol(method_name);
matcher->init(c_name, c_match, m_name, m_match, signature); matcher->init(c_name, c_match, m_name, m_match, signature);
return; return;

View file

@ -417,7 +417,7 @@ JRT_END
JRT_ENTRY(void, InterpreterRuntime::create_exception(JavaThread* thread, char* name, char* message)) JRT_ENTRY(void, InterpreterRuntime::create_exception(JavaThread* thread, char* name, char* message))
// lookup exception klass // lookup exception klass
TempNewSymbol s = SymbolTable::new_symbol(name, CHECK); TempNewSymbol s = SymbolTable::new_symbol(name);
if (ProfileTraps) { if (ProfileTraps) {
if (s == vmSymbols::java_lang_ArithmeticException()) { if (s == vmSymbols::java_lang_ArithmeticException()) {
note_trap(thread, Deoptimization::Reason_div0_check, CHECK); note_trap(thread, Deoptimization::Reason_div0_check, CHECK);
@ -436,7 +436,7 @@ JRT_ENTRY(void, InterpreterRuntime::create_klass_exception(JavaThread* thread, c
ResourceMark rm(thread); ResourceMark rm(thread);
const char* klass_name = obj->klass()->external_name(); const char* klass_name = obj->klass()->external_name();
// lookup exception klass // lookup exception klass
TempNewSymbol s = SymbolTable::new_symbol(name, CHECK); TempNewSymbol s = SymbolTable::new_symbol(name);
if (ProfileTraps) { if (ProfileTraps) {
note_trap(thread, Deoptimization::Reason_class_check, CHECK); note_trap(thread, Deoptimization::Reason_class_check, CHECK);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -171,8 +171,8 @@ static oop construct_dcmd_instance(JfrJavaArguments* args, TRAPS) {
assert(args != NULL, "invariant"); assert(args != NULL, "invariant");
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD)); DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
assert(args->klass() != NULL, "invariant"); assert(args->klass() != NULL, "invariant");
args->set_name("<init>", CHECK_NULL); args->set_name("<init>");
args->set_signature("()V", CHECK_NULL); args->set_signature("()V");
JfrJavaSupport::new_object(args, CHECK_NULL); JfrJavaSupport::new_object(args, CHECK_NULL);
return (oop)args->result()->get_jobject(); return (oop)args->result()->get_jobject();
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -357,7 +357,6 @@ class AnnotationIterator : public StackObj {
} }
}; };
static unsigned int unused_hash = 0;
static const char value_name[] = "value"; static const char value_name[] = "value";
static bool has_annotation(const InstanceKlass* ik, const Symbol* annotation_type, bool& value) { static bool has_annotation(const InstanceKlass* ik, const Symbol* annotation_type, bool& value) {
assert(annotation_type != NULL, "invariant"); assert(annotation_type != NULL, "invariant");
@ -372,7 +371,7 @@ static bool has_annotation(const InstanceKlass* ik, const Symbol* annotation_typ
if (annotation_iterator.type() == annotation_type) { if (annotation_iterator.type() == annotation_type) {
// target annotation found // target annotation found
static const Symbol* value_symbol = static const Symbol* value_symbol =
SymbolTable::lookup_only(value_name, sizeof value_name - 1, unused_hash); SymbolTable::probe(value_name, sizeof value_name - 1);
assert(value_symbol != NULL, "invariant"); assert(value_symbol != NULL, "invariant");
const AnnotationElementIterator element_iterator = annotation_iterator.elements(); const AnnotationElementIterator element_iterator = annotation_iterator.elements();
while (element_iterator.has_next()) { while (element_iterator.has_next()) {
@ -412,7 +411,7 @@ static bool java_base_can_read_jdk_jfr() {
} }
static Symbol* jdk_jfr_module_symbol = NULL; static Symbol* jdk_jfr_module_symbol = NULL;
if (jdk_jfr_module_symbol == NULL) { if (jdk_jfr_module_symbol == NULL) {
jdk_jfr_module_symbol = SymbolTable::lookup_only(jdk_jfr_module_name, sizeof jdk_jfr_module_name - 1, unused_hash); jdk_jfr_module_symbol = SymbolTable::probe(jdk_jfr_module_name, sizeof jdk_jfr_module_name - 1);
if (jdk_jfr_module_symbol == NULL) { if (jdk_jfr_module_symbol == NULL) {
return false; return false;
} }
@ -447,7 +446,7 @@ static bool should_register_klass(const InstanceKlass* ik, bool& untypedEventHan
assert(!untypedEventHandler, "invariant"); assert(!untypedEventHandler, "invariant");
static const Symbol* registered_symbol = NULL; static const Symbol* registered_symbol = NULL;
if (registered_symbol == NULL) { if (registered_symbol == NULL) {
registered_symbol = SymbolTable::lookup_only(registered_constant, sizeof registered_constant - 1, unused_hash); registered_symbol = SymbolTable::probe(registered_constant, sizeof registered_constant - 1);
if (registered_symbol == NULL) { if (registered_symbol == NULL) {
untypedEventHandler = true; untypedEventHandler = true;
return false; return false;
@ -1167,7 +1166,7 @@ static u2 find_or_add_utf8_info(JfrBigEndianWriter& writer,
u2& added_cp_entries, u2& added_cp_entries,
TRAPS) { TRAPS) {
assert(utf8_constant != NULL, "invariant"); assert(utf8_constant != NULL, "invariant");
TempNewSymbol utf8_sym = SymbolTable::new_symbol(utf8_constant, THREAD); TempNewSymbol utf8_sym = SymbolTable::new_symbol(utf8_constant);
// lookup existing // lookup existing
const int utf8_orig_idx = utf8_info_index(ik, utf8_sym, THREAD); const int utf8_orig_idx = utf8_info_index(ik, utf8_sym, THREAD);
if (utf8_orig_idx != invalid_cp_index) { if (utf8_orig_idx != invalid_cp_index) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -134,8 +134,7 @@ jobject JfrEventClasses::get_all_event_classes(TRAPS) {
initialize(THREAD); initialize(THREAD);
assert(empty_java_util_arraylist != NULL, "should have been setup already!"); assert(empty_java_util_arraylist != NULL, "should have been setup already!");
static const char jdk_jfr_event_name[] = "jdk/internal/event/Event"; static const char jdk_jfr_event_name[] = "jdk/internal/event/Event";
unsigned int unused_hash = 0; Symbol* const event_klass_name = SymbolTable::probe(jdk_jfr_event_name, sizeof jdk_jfr_event_name - 1);
Symbol* const event_klass_name = SymbolTable::lookup_only(jdk_jfr_event_name, sizeof jdk_jfr_event_name - 1, unused_hash);
if (NULL == event_klass_name) { if (NULL == event_klass_name) {
// not loaded yet // not loaded yet
@ -168,10 +167,10 @@ jobject JfrEventClasses::get_all_event_classes(TRAPS) {
const Klass* const array_list_klass = JfrJavaSupport::klass(empty_java_util_arraylist); const Klass* const array_list_klass = JfrJavaSupport::klass(empty_java_util_arraylist);
assert(array_list_klass != NULL, "invariant"); assert(array_list_klass != NULL, "invariant");
const Symbol* const add_method_sym = SymbolTable::lookup(add_method_name, sizeof add_method_name - 1, THREAD); const Symbol* const add_method_sym = SymbolTable::new_symbol(add_method_name);
assert(add_method_sym != NULL, "invariant"); assert(add_method_sym != NULL, "invariant");
const Symbol* const add_method_sig_sym = SymbolTable::lookup(add_method_signature, sizeof add_method_signature - 1, THREAD); const Symbol* const add_method_sig_sym = SymbolTable::new_symbol(add_method_signature);
assert(add_method_signature != NULL, "invariant"); assert(add_method_signature != NULL, "invariant");
JavaValue result(T_BOOLEAN); JavaValue result(T_BOOLEAN);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -38,9 +38,9 @@ static bool is_large_value(const JavaValue& value) {
} }
#endif // ASSERT #endif // ASSERT
static Symbol* resolve(const char* str, TRAPS) { static Symbol* resolve(const char* str) {
assert(str != NULL, "invariant"); assert(str != NULL, "invariant");
return SymbolTable::lookup(str, (int)strlen(str), THREAD); return SymbolTable::new_symbol(str);
} }
static Klass* resolve(Symbol* k_sym, TRAPS) { static Klass* resolve(Symbol* k_sym, TRAPS) {
@ -199,10 +199,10 @@ JfrJavaArguments::JfrJavaArguments(JavaValue* result, const char* klass_name, co
set_klass(klass_name, CHECK); set_klass(klass_name, CHECK);
} }
if (name != NULL) { if (name != NULL) {
set_name(name, CHECK); set_name(name);
} }
if (signature != NULL) { if (signature != NULL) {
set_signature(signature, THREAD); set_signature(signature);
} }
} }
@ -230,7 +230,7 @@ Klass* JfrJavaArguments::klass() const {
void JfrJavaArguments::set_klass(const char* klass_name, TRAPS) { void JfrJavaArguments::set_klass(const char* klass_name, TRAPS) {
assert(klass_name != NULL, "invariant"); assert(klass_name != NULL, "invariant");
Symbol* const k_sym = resolve(klass_name, CHECK); Symbol* const k_sym = resolve(klass_name);
assert(k_sym != NULL, "invariant"); assert(k_sym != NULL, "invariant");
const Klass* const klass = resolve(k_sym, CHECK); const Klass* const klass = resolve(k_sym, CHECK);
set_klass(klass); set_klass(klass);
@ -246,9 +246,9 @@ Symbol* JfrJavaArguments::name() const {
return const_cast<Symbol*>(_name); return const_cast<Symbol*>(_name);
} }
void JfrJavaArguments::set_name(const char* name, TRAPS) { void JfrJavaArguments::set_name(const char* name) {
assert(name != NULL, "invariant"); assert(name != NULL, "invariant");
const Symbol* const sym = resolve(name, CHECK); const Symbol* const sym = resolve(name);
set_name(sym); set_name(sym);
} }
@ -262,9 +262,9 @@ Symbol* JfrJavaArguments::signature() const {
return const_cast<Symbol*>(_signature); return const_cast<Symbol*>(_signature);
} }
void JfrJavaArguments::set_signature(const char* signature, TRAPS) { void JfrJavaArguments::set_signature(const char* signature) {
assert(signature != NULL, "invariant"); assert(signature != NULL, "invariant");
const Symbol* const sym = resolve(signature, CHECK); const Symbol* const sym = resolve(signature);
set_signature(sym); set_signature(sym);
} }

View file

@ -47,11 +47,11 @@ class JfrJavaArguments : public StackObj {
void set_klass(const Klass* klass); void set_klass(const Klass* klass);
Symbol* name() const; Symbol* name() const;
void set_name(const char* name, TRAPS); void set_name(const char* name);
void set_name(const Symbol* name); void set_name(const Symbol* name);
Symbol* signature() const; Symbol* signature() const;
void set_signature(const char* signature, TRAPS); void set_signature(const char* signature);
void set_signature(const Symbol* signature); void set_signature(const Symbol* signature);
int array_length() const; int array_length() const;

View file

@ -579,7 +579,7 @@ const char* const JDK_JFR_PACKAGE_NAME = "jdk/jfr";
static bool is_jdk_jfr_module_in_readability_graph() { static bool is_jdk_jfr_module_in_readability_graph() {
Thread* const t = Thread::current(); Thread* const t = Thread::current();
// take one of the packages in the module to be located and query for its definition. // take one of the packages in the module to be located and query for its definition.
TempNewSymbol pkg_sym = SymbolTable::new_symbol(JDK_JFR_PACKAGE_NAME, t); TempNewSymbol pkg_sym = SymbolTable::new_symbol(JDK_JFR_PACKAGE_NAME);
return Modules::is_package_defined(pkg_sym, Handle(), t); return Modules::is_package_defined(pkg_sym, Handle(), t);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,11 +49,11 @@ static bool initialize(TRAPS) {
static bool initialized = false; static bool initialized = false;
if (!initialized) { if (!initialized) {
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD)); DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
jvm_upcalls_class_sym = SymbolTable::new_permanent_symbol("jdk/jfr/internal/JVMUpcalls", CHECK_false); jvm_upcalls_class_sym = SymbolTable::new_permanent_symbol("jdk/jfr/internal/JVMUpcalls");
on_retransform_method_sym = SymbolTable::new_permanent_symbol("onRetransform", CHECK_false); on_retransform_method_sym = SymbolTable::new_permanent_symbol("onRetransform");
on_retransform_signature_sym = SymbolTable::new_permanent_symbol("(JZLjava/lang/Class;[B)[B", CHECK_false); on_retransform_signature_sym = SymbolTable::new_permanent_symbol("(JZLjava/lang/Class;[B)[B");
bytes_for_eager_instrumentation_sym = SymbolTable::new_permanent_symbol("bytesForEagerInstrumentation", CHECK_false); bytes_for_eager_instrumentation_sym = SymbolTable::new_permanent_symbol("bytesForEagerInstrumentation");
bytes_for_eager_instrumentation_sig_sym = SymbolTable::new_permanent_symbol("(JZLjava/lang/Class;[B)[B", THREAD); bytes_for_eager_instrumentation_sig_sym = SymbolTable::new_permanent_symbol("(JZLjava/lang/Class;[B)[B");
initialized = bytes_for_eager_instrumentation_sig_sym != NULL; initialized = bytes_for_eager_instrumentation_sig_sym != NULL;
} }
return initialized; return initialized;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -91,7 +91,7 @@ ObjectSampleDescription::ObjectSampleDescription(oop object) :
void ObjectSampleDescription::ensure_initialized() { void ObjectSampleDescription::ensure_initialized() {
if (symbol_size == NULL) { if (symbol_size == NULL) {
symbol_size = SymbolTable::new_permanent_symbol("size", Thread::current()); symbol_size = SymbolTable::new_permanent_symbol("size");
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -87,14 +87,14 @@ static void check_klass(const Klass* klass) {
static const Symbol* jdk_internal_event_sym = NULL; static const Symbol* jdk_internal_event_sym = NULL;
if (jdk_internal_event_sym == NULL) { if (jdk_internal_event_sym == NULL) {
// setup when loading the first TypeArrayKlass (Universe::genesis) hence single threaded invariant // setup when loading the first TypeArrayKlass (Universe::genesis) hence single threaded invariant
jdk_internal_event_sym = SymbolTable::new_permanent_symbol("jdk/internal/event/Event", Thread::current()); jdk_internal_event_sym = SymbolTable::new_permanent_symbol("jdk/internal/event/Event");
} }
assert(jdk_internal_event_sym != NULL, "invariant"); assert(jdk_internal_event_sym != NULL, "invariant");
static const Symbol* jdk_jfr_event_sym = NULL; static const Symbol* jdk_jfr_event_sym = NULL;
if (jdk_jfr_event_sym == NULL) { if (jdk_jfr_event_sym == NULL) {
// setup when loading the first TypeArrayKlass (Universe::genesis) hence single threaded invariant // setup when loading the first TypeArrayKlass (Universe::genesis) hence single threaded invariant
jdk_jfr_event_sym = SymbolTable::new_permanent_symbol("jdk/jfr/Event", Thread::current()); jdk_jfr_event_sym = SymbolTable::new_permanent_symbol("jdk/jfr/Event");
} }
assert(jdk_jfr_event_sym != NULL, "invariant"); assert(jdk_jfr_event_sym != NULL, "invariant");
const Symbol* const klass_name = klass->name(); const Symbol* const klass_name = klass->name();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -62,8 +62,8 @@ static void log_cfg_update(LogLevelType llt, JfrLogTagSetType jflt, TRAPS) {
JavaValue result(T_VOID); JavaValue result(T_VOID);
JfrJavaArguments args(&result); JfrJavaArguments args(&result);
args.set_klass(JfrJavaSupport::klass(lt)); args.set_klass(JfrJavaSupport::klass(lt));
args.set_name("tagSetLevel", CHECK); args.set_name("tagSetLevel");
args.set_signature("I", CHECK); args.set_signature("I");
args.set_receiver(JfrJavaSupport::resolve_non_null(lt)); args.set_receiver(JfrJavaSupport::resolve_non_null(lt));
args.push_int(llt); args.push_int(llt);
JfrJavaSupport::set_field(&args, THREAD); JfrJavaSupport::set_field(&args, THREAD);

View file

@ -76,55 +76,55 @@ static void compute_offset(int &dest_offset,
static bool setup_event_writer_offsets(TRAPS) { static bool setup_event_writer_offsets(TRAPS) {
const char class_name[] = "jdk/jfr/internal/EventWriter"; const char class_name[] = "jdk/jfr/internal/EventWriter";
Symbol* const k_sym = SymbolTable::lookup(class_name, sizeof class_name - 1, CHECK_false); Symbol* const k_sym = SymbolTable::new_symbol(class_name);
assert(k_sym != NULL, "invariant"); assert(k_sym != NULL, "invariant");
Klass* klass = SystemDictionary::resolve_or_fail(k_sym, true, CHECK_false); Klass* klass = SystemDictionary::resolve_or_fail(k_sym, true, CHECK_false);
assert(klass != NULL, "invariant"); assert(klass != NULL, "invariant");
const char start_pos_name[] = "startPosition"; const char start_pos_name[] = "startPosition";
Symbol* const start_pos_sym = SymbolTable::lookup(start_pos_name, sizeof start_pos_name - 1, CHECK_false); Symbol* const start_pos_sym = SymbolTable::new_symbol(start_pos_name);
assert(start_pos_sym != NULL, "invariant"); assert(start_pos_sym != NULL, "invariant");
assert(invalid_offset == start_pos_offset, "invariant"); assert(invalid_offset == start_pos_offset, "invariant");
compute_offset(start_pos_offset, klass, start_pos_sym, vmSymbols::long_signature()); compute_offset(start_pos_offset, klass, start_pos_sym, vmSymbols::long_signature());
assert(start_pos_offset != invalid_offset, "invariant"); assert(start_pos_offset != invalid_offset, "invariant");
const char start_pos_address_name[] = "startPositionAddress"; const char start_pos_address_name[] = "startPositionAddress";
Symbol* const start_pos_address_sym = SymbolTable::lookup(start_pos_address_name, sizeof start_pos_address_name - 1, CHECK_false); Symbol* const start_pos_address_sym = SymbolTable::new_symbol(start_pos_address_name);
assert(start_pos_address_sym != NULL, "invariant"); assert(start_pos_address_sym != NULL, "invariant");
assert(invalid_offset == start_pos_address_offset, "invariant"); assert(invalid_offset == start_pos_address_offset, "invariant");
compute_offset(start_pos_address_offset, klass, start_pos_address_sym, vmSymbols::long_signature()); compute_offset(start_pos_address_offset, klass, start_pos_address_sym, vmSymbols::long_signature());
assert(start_pos_address_offset != invalid_offset, "invariant"); assert(start_pos_address_offset != invalid_offset, "invariant");
const char event_pos_name[] = "currentPosition"; const char event_pos_name[] = "currentPosition";
Symbol* const event_pos_sym = SymbolTable::lookup(event_pos_name, sizeof event_pos_name - 1, CHECK_false); Symbol* const event_pos_sym = SymbolTable::new_symbol(event_pos_name);
assert(event_pos_sym != NULL, "invariant"); assert(event_pos_sym != NULL, "invariant");
assert(invalid_offset == current_pos_offset, "invariant"); assert(invalid_offset == current_pos_offset, "invariant");
compute_offset(current_pos_offset, klass, event_pos_sym,vmSymbols::long_signature()); compute_offset(current_pos_offset, klass, event_pos_sym,vmSymbols::long_signature());
assert(current_pos_offset != invalid_offset, "invariant"); assert(current_pos_offset != invalid_offset, "invariant");
const char max_pos_name[] = "maxPosition"; const char max_pos_name[] = "maxPosition";
Symbol* const max_pos_sym = SymbolTable::lookup(max_pos_name, sizeof max_pos_name - 1, CHECK_false); Symbol* const max_pos_sym = SymbolTable::new_symbol(max_pos_name);
assert(max_pos_sym != NULL, "invariant"); assert(max_pos_sym != NULL, "invariant");
assert(invalid_offset == max_pos_offset, "invariant"); assert(invalid_offset == max_pos_offset, "invariant");
compute_offset(max_pos_offset, klass, max_pos_sym, vmSymbols::long_signature()); compute_offset(max_pos_offset, klass, max_pos_sym, vmSymbols::long_signature());
assert(max_pos_offset != invalid_offset, "invariant"); assert(max_pos_offset != invalid_offset, "invariant");
const char max_event_size_name[] = "maxEventSize"; const char max_event_size_name[] = "maxEventSize";
Symbol* const max_event_size_sym = SymbolTable::lookup(max_event_size_name, sizeof max_event_size_name - 1, CHECK_false); Symbol* const max_event_size_sym = SymbolTable::new_symbol(max_event_size_name);
assert (max_event_size_sym != NULL, "invariant"); assert (max_event_size_sym != NULL, "invariant");
assert(invalid_offset == max_event_size_offset, "invariant"); assert(invalid_offset == max_event_size_offset, "invariant");
compute_offset(max_event_size_offset, klass, max_event_size_sym, vmSymbols::int_signature()); compute_offset(max_event_size_offset, klass, max_event_size_sym, vmSymbols::int_signature());
assert(max_event_size_offset != invalid_offset, "invariant"); assert(max_event_size_offset != invalid_offset, "invariant");
const char notified_name[] = "notified"; const char notified_name[] = "notified";
Symbol* const notified_sym = SymbolTable::lookup(notified_name, sizeof notified_name - 1, CHECK_false); Symbol* const notified_sym = SymbolTable::new_symbol(notified_name);
assert (notified_sym != NULL, "invariant"); assert (notified_sym != NULL, "invariant");
assert(invalid_offset == notified_offset, "invariant"); assert(invalid_offset == notified_offset, "invariant");
compute_offset(notified_offset, klass, notified_sym, vmSymbols::bool_signature()); compute_offset(notified_offset, klass, notified_sym, vmSymbols::bool_signature());
assert(notified_offset != invalid_offset, "invariant"); assert(notified_offset != invalid_offset, "invariant");
const char valid_name[] = "valid"; const char valid_name[] = "valid";
Symbol* const valid_sym = SymbolTable::lookup(valid_name, sizeof valid_name - 1, CHECK_false); Symbol* const valid_sym = SymbolTable::new_symbol(valid_name);
assert (valid_sym != NULL, "invariant"); assert (valid_sym != NULL, "invariant");
assert(invalid_offset == valid_offset, "invariant"); assert(invalid_offset == valid_offset, "invariant");
compute_offset(valid_offset, klass, valid_sym, vmSymbols::bool_signature()); compute_offset(valid_offset, klass, valid_sym, vmSymbols::bool_signature());

View file

@ -45,8 +45,7 @@ JRT_BLOCK_ENTRY(void, CompilerRuntime::resolve_string_by_symbol(JavaThread *thre
// First 2 bytes of name contains length (number of bytes). // First 2 bytes of name contains length (number of bytes).
int len = Bytes::get_Java_u2((address)name); int len = Bytes::get_Java_u2((address)name);
name += 2; name += 2;
TempNewSymbol sym = SymbolTable::new_symbol(name, len, CHECK); str = StringTable::intern(name, CHECK);
str = StringTable::intern(sym, CHECK);
assert(java_lang_String::is_instance(str), "must be string"); assert(java_lang_String::is_instance(str), "must be string");
*(oop*)string_result = str; // Store result *(oop*)string_result = str; // Store result
} }
@ -78,7 +77,7 @@ Klass* CompilerRuntime::resolve_klass_helper(JavaThread *thread, const char* nam
name++; name++;
len -= 2; len -= 2;
} }
TempNewSymbol sym = SymbolTable::new_symbol(name, len, CHECK_NULL); TempNewSymbol sym = SymbolTable::new_symbol(name, len);
if (sym == NULL) { if (sym == NULL) {
return NULL; return NULL;
} }

View file

@ -506,7 +506,7 @@ C2V_END
C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jclass accessing_class, jboolean resolve)) C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jclass accessing_class, jboolean resolve))
JVMCIObject name = JVMCIENV->wrap(jname); JVMCIObject name = JVMCIENV->wrap(jname);
const char* str = JVMCIENV->as_utf8_string(name); const char* str = JVMCIENV->as_utf8_string(name);
TempNewSymbol class_name = SymbolTable::new_symbol(str, CHECK_NULL); TempNewSymbol class_name = SymbolTable::new_symbol(str);
if (class_name->utf8_length() <= 1) { if (class_name->utf8_length() <= 1) {
JVMCI_THROW_MSG_0(InternalError, err_msg("Primitive type %s should be handled in Java code", class_name->as_C_string())); JVMCI_THROW_MSG_0(InternalError, err_msg("Primitive type %s should be handled in Java code", class_name->as_C_string()));
@ -537,8 +537,7 @@ C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jcla
// This is a name from a signature. Strip off the trimmings. // This is a name from a signature. Strip off the trimmings.
// Call recursive to keep scope of strippedsym. // Call recursive to keep scope of strippedsym.
TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1, TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1,
class_name->utf8_length()-2, class_name->utf8_length()-2);
CHECK_0);
resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0); resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0);
} else if (FieldType::is_array(class_name)) { } else if (FieldType::is_array(class_name)) {
FieldArrayInfo fd; FieldArrayInfo fd;
@ -547,8 +546,7 @@ C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jcla
BasicType t = FieldType::get_array_info(class_name, fd, CHECK_0); BasicType t = FieldType::get_array_info(class_name, fd, CHECK_0);
if (t == T_OBJECT) { if (t == T_OBJECT) {
TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1+fd.dimension(), TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1+fd.dimension(),
class_name->utf8_length()-2-fd.dimension(), class_name->utf8_length()-2-fd.dimension());
CHECK_0);
resolved_klass = SystemDictionary::find(strippedsym, resolved_klass = SystemDictionary::find(strippedsym,
class_loader, class_loader,
protection_domain, protection_domain,
@ -1762,7 +1760,7 @@ C2V_END
C2V_VMENTRY(void, compileToBytecode, (JNIEnv* env, jobject, jobject lambda_form_handle)) C2V_VMENTRY(void, compileToBytecode, (JNIEnv* env, jobject, jobject lambda_form_handle))
Handle lambda_form = JVMCIENV->asConstant(JVMCIENV->wrap(lambda_form_handle), JVMCI_CHECK); Handle lambda_form = JVMCIENV->asConstant(JVMCIENV->wrap(lambda_form_handle), JVMCI_CHECK);
if (lambda_form->is_a(SystemDictionary::LambdaForm_klass())) { if (lambda_form->is_a(SystemDictionary::LambdaForm_klass())) {
TempNewSymbol compileToBytecode = SymbolTable::new_symbol("compileToBytecode", CHECK); TempNewSymbol compileToBytecode = SymbolTable::new_symbol("compileToBytecode");
JavaValue result(T_VOID); JavaValue result(T_VOID);
JavaCalls::call_special(&result, lambda_form, SystemDictionary::LambdaForm_klass(), compileToBytecode, vmSymbols::void_method_signature(), CHECK); JavaCalls::call_special(&result, lambda_form, SystemDictionary::LambdaForm_klass(), compileToBytecode, vmSymbols::void_method_signature(), CHECK);
} else { } else {

View file

@ -92,7 +92,7 @@ void JVMCIEnv::copy_saved_properties() {
} }
// Get the serialized saved properties from HotSpot // Get the serialized saved properties from HotSpot
TempNewSymbol serializeSavedProperties = SymbolTable::new_symbol("serializeSavedProperties", CHECK_EXIT); TempNewSymbol serializeSavedProperties = SymbolTable::new_symbol("serializeSavedProperties");
JavaValue result(T_OBJECT); JavaValue result(T_OBJECT);
JavaCallArguments args; JavaCallArguments args;
JavaCalls::call_static(&result, ik, serializeSavedProperties, vmSymbols::serializePropertiesToByteArray_signature(), &args, THREAD); JavaCalls::call_static(&result, ik, serializeSavedProperties, vmSymbols::serializePropertiesToByteArray_signature(), &args, THREAD);

View file

@ -139,7 +139,7 @@ jmethodID JNIJVMCI::_HotSpotResolvedPrimitiveType_fromMetaspace_method;
#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) \ #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) \
check_resolve_method(#hsCallType, k, vmSymbols::methodName##_name(), vmSymbols::signatureSymbolName(), CHECK); check_resolve_method(#hsCallType, k, vmSymbols::methodName##_name(), vmSymbols::signatureSymbolName(), CHECK);
#define CONSTRUCTOR(className, signature) { \ #define CONSTRUCTOR(className, signature) { \
TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK); \ TempNewSymbol sig = SymbolTable::new_symbol(signature); \
check_resolve_method("call_special", k, vmSymbols::object_initializer_name(), sig, CHECK); \ check_resolve_method("call_special", k, vmSymbols::object_initializer_name(), sig, CHECK); \
} }
#endif #endif

View file

@ -469,20 +469,20 @@ JRT_LEAF(jboolean, JVMCIRuntime::object_notifyAll(JavaThread *thread, oopDesc* o
JRT_END JRT_END
JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message)) JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message))
TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK); TempNewSymbol symbol = SymbolTable::new_symbol(exception);
SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message); SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
JRT_END JRT_END
JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass)) JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass))
ResourceMark rm(thread); ResourceMark rm(thread);
TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK); TempNewSymbol symbol = SymbolTable::new_symbol(exception);
SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, klass->external_name()); SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, klass->external_name());
JRT_END JRT_END
JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass)) JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass))
ResourceMark rm(thread); ResourceMark rm(thread);
const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass); const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass);
TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK); TempNewSymbol symbol = SymbolTable::new_symbol(exception);
SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message); SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
JRT_END JRT_END
@ -1011,8 +1011,7 @@ Klass* JVMCIRuntime::get_klass_by_name_impl(Klass*& accessing_klass,
// This is a name from a signature. Strip off the trimmings. // This is a name from a signature. Strip off the trimmings.
// Call recursive to keep scope of strippedsym. // Call recursive to keep scope of strippedsym.
TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
sym->utf8_length()-2, sym->utf8_length()-2);
CHECK_NULL);
return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local); return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local);
} }
@ -1045,8 +1044,7 @@ Klass* JVMCIRuntime::get_klass_by_name_impl(Klass*& accessing_klass,
// We have an unloaded array. // We have an unloaded array.
// Build it on the fly if the element class exists. // Build it on the fly if the element class exists.
TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
sym->utf8_length()-1, sym->utf8_length()-1);
CHECK_NULL);
// Get element Klass recursively. // Get element Klass recursively.
Klass* elem_klass = Klass* elem_klass =

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -884,8 +884,8 @@ void HeapShared::init_subgraph_entry_fields(ArchivableStaticFieldInfo fields[],
int num, Thread* THREAD) { int num, Thread* THREAD) {
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
ArchivableStaticFieldInfo* info = &fields[i]; ArchivableStaticFieldInfo* info = &fields[i];
TempNewSymbol klass_name = SymbolTable::new_symbol(info->klass_name, THREAD); TempNewSymbol klass_name = SymbolTable::new_symbol(info->klass_name);
TempNewSymbol field_name = SymbolTable::new_symbol(info->field_name, THREAD); TempNewSymbol field_name = SymbolTable::new_symbol(info->field_name);
Klass* k = SystemDictionary::resolve_or_null(klass_name, THREAD); Klass* k = SystemDictionary::resolve_or_null(klass_name, THREAD);
assert(k != NULL && !HAS_PENDING_EXCEPTION, "class must exist"); assert(k != NULL && !HAS_PENDING_EXCEPTION, "class must exist");

View file

@ -371,7 +371,7 @@ void MetaspaceShared::read_extra_data(const char* filename, TRAPS) {
utf8_buffer[utf8_length] = '\0'; utf8_buffer[utf8_length] = '\0';
if (prefix_type == HashtableTextDump::SymbolPrefix) { if (prefix_type == HashtableTextDump::SymbolPrefix) {
SymbolTable::new_permanent_symbol(utf8_buffer, THREAD); SymbolTable::new_permanent_symbol(utf8_buffer);
} else{ } else{
assert(prefix_type == HashtableTextDump::StringPrefix, "Sanity"); assert(prefix_type == HashtableTextDump::StringPrefix, "Sanity");
oop s = StringTable::intern(utf8_buffer, THREAD); oop s = StringTable::intern(utf8_buffer, THREAD);

View file

@ -807,7 +807,7 @@ void initialize_known_method(LatestMethodCache* method_cache,
Symbol* signature, Symbol* signature,
bool is_static, TRAPS) bool is_static, TRAPS)
{ {
TempNewSymbol name = SymbolTable::new_symbol(method, CHECK); TempNewSymbol name = SymbolTable::new_symbol(method);
Method* m = NULL; Method* m = NULL;
// The klass must be linked before looking up the method. // The klass must be linked before looking up the method.
if (!ik->link_class_or_fail(THREAD) || if (!ik->link_class_or_fail(THREAD) ||

View file

@ -2611,7 +2611,7 @@ Symbol* InstanceKlass::package_from_name(const Symbol* name, TRAPS) {
if (package_name == NULL) { if (package_name == NULL) {
return NULL; return NULL;
} }
Symbol* pkg_name = SymbolTable::new_symbol(package_name, THREAD); Symbol* pkg_name = SymbolTable::new_symbol(package_name);
return pkg_name; return pkg_name;
} }
} }

View file

@ -1579,7 +1579,7 @@ bool Method::load_signature_classes(const methodHandle& m, TRAPS) {
Symbol* signature = m->signature(); Symbol* signature = m->signature();
for(SignatureStream ss(signature); !ss.is_done(); ss.next()) { for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
if (ss.is_object()) { if (ss.is_object()) {
Symbol* sym = ss.as_symbol(CHECK_(false)); Symbol* sym = ss.as_symbol();
Symbol* name = sym; Symbol* name = sym;
Klass* klass = SystemDictionary::resolve_or_null(name, class_loader, Klass* klass = SystemDictionary::resolve_or_null(name, class_loader,
protection_domain, THREAD); protection_domain, THREAD);

View file

@ -116,7 +116,7 @@ Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
new_str[idx++] = ';'; new_str[idx++] = ';';
} }
new_str[idx++] = '\0'; new_str[idx++] = '\0';
name = SymbolTable::new_permanent_symbol(new_str, CHECK_0); name = SymbolTable::new_permanent_symbol(new_str);
if (element_klass->is_instance_klass()) { if (element_klass->is_instance_klass()) {
InstanceKlass* ik = InstanceKlass::cast(element_klass); InstanceKlass* ik = InstanceKlass::cast(element_klass);
ik->set_array_name(name); ik->set_array_name(name);

View file

@ -57,13 +57,13 @@ Symbol::Symbol(const u1* name, int length, int refcount) {
} }
} }
void* Symbol::operator new(size_t sz, int len, TRAPS) throw() { void* Symbol::operator new(size_t sz, int len) throw() {
int alloc_size = size(len)*wordSize; int alloc_size = size(len)*wordSize;
address res = (address) AllocateHeap(alloc_size, mtSymbol); address res = (address) AllocateHeap(alloc_size, mtSymbol);
return res; return res;
} }
void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) throw() { void* Symbol::operator new(size_t sz, int len, Arena* arena) throw() {
int alloc_size = size(len)*wordSize; int alloc_size = size(len)*wordSize;
address res = (address)arena->Amalloc_4(alloc_size); address res = (address)arena->Amalloc_4(alloc_size);
return res; return res;

View file

@ -132,8 +132,8 @@ class Symbol : public MetaspaceObj {
} }
Symbol(const u1* name, int length, int refcount); Symbol(const u1* name, int length, int refcount);
void* operator new(size_t size, int len, TRAPS) throw(); void* operator new(size_t size, int len) throw();
void* operator new(size_t size, int len, Arena* arena, TRAPS) throw(); void* operator new(size_t size, int len, Arena* arena) throw();
void operator delete(void* p); void operator delete(void* p);

View file

@ -47,7 +47,7 @@ TypeArrayKlass* TypeArrayKlass::create_klass(BasicType type,
const char* name_str, TRAPS) { const char* name_str, TRAPS) {
Symbol* sym = NULL; Symbol* sym = NULL;
if (name_str != NULL) { if (name_str != NULL) {
sym = SymbolTable::new_permanent_symbol(name_str, CHECK_NULL); sym = SymbolTable::new_permanent_symbol(name_str);
} }
ClassLoaderData* null_loader_data = ClassLoaderData::the_null_class_loader_data(); ClassLoaderData* null_loader_data = ClassLoaderData::the_null_class_loader_data();

View file

@ -329,7 +329,7 @@ JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderR
name); name);
return 0; return 0;
} }
class_name = SymbolTable::new_symbol(name, CHECK_NULL); class_name = SymbolTable::new_symbol(name);
} }
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
ClassFileStream st((u1*)buf, bufLen, NULL, ClassFileStream::verify); ClassFileStream st((u1*)buf, bufLen, NULL, ClassFileStream::verify);
@ -416,7 +416,7 @@ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name))
} }
} }
TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); TempNewSymbol sym = SymbolTable::new_symbol(name);
result = find_class_from_class_loader(env, sym, true, loader, result = find_class_from_class_loader(env, sym, true, loader,
protection_domain, true, thread); protection_domain, true, thread);
@ -3288,7 +3288,7 @@ static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) {
Handle loader; // null (bootstrap) loader Handle loader; // null (bootstrap) loader
Handle protection_domain; // null protection domain Handle protection_domain; // null protection domain
TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); TempNewSymbol sym = SymbolTable::new_symbol(name);
jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL); jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL);
if (log_is_enabled(Debug, class, resolve) && result != NULL) { if (log_is_enabled(Debug, class, resolve) && result != NULL) {

View file

@ -138,9 +138,9 @@ static void trace_class_resolution_impl(Klass* to_class, TRAPS) {
vframeStream vfst(jthread); vframeStream vfst(jthread);
// scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames
TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController", CHECK); TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController");
Klass* access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK); Klass* access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK);
TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction", CHECK); TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction");
Klass* privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK); Klass* privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK);
Method* last_caller = NULL; Method* last_caller = NULL;
@ -786,7 +786,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,
return NULL; return NULL;
} }
TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); TempNewSymbol h_name = SymbolTable::new_symbol(name);
Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL); Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL);
if (k == NULL) { if (k == NULL) {
return NULL; return NULL;
@ -810,7 +810,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name,
THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
} }
TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); TempNewSymbol h_name = SymbolTable::new_symbol(name);
oop loader_oop = JNIHandles::resolve(loader); oop loader_oop = JNIHandles::resolve(loader);
oop from_class = JNIHandles::resolve(caller); oop from_class = JNIHandles::resolve(caller);
@ -852,7 +852,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name,
name); name);
return 0; return 0;
} }
TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); TempNewSymbol h_name = SymbolTable::new_symbol(name);
oop from_class_oop = JNIHandles::resolve(from); oop from_class_oop = JNIHandles::resolve(from);
Klass* from_class = (from_class_oop == NULL) Klass* from_class = (from_class_oop == NULL)
? (Klass*)NULL ? (Klass*)NULL
@ -933,7 +933,7 @@ static jclass jvm_define_class_common(JNIEnv *env, const char *name,
name); name);
return 0; return 0;
} }
class_name = SymbolTable::new_symbol(name, str_len, CHECK_NULL); class_name = SymbolTable::new_symbol(name, str_len);
} }
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
@ -989,7 +989,7 @@ JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
// into the constant pool. // into the constant pool.
return NULL; return NULL;
} }
TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len, CHECK_NULL); TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len);
// Security Note: // Security Note:
// The Java level wrapper will perform the necessary security check allowing // The Java level wrapper will perform the necessary security check allowing

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -609,7 +609,7 @@ bool VM_GetOrSetLocal::is_assignable(const char* ty_sign, Klass* klass, Thread*
ty_sign++; ty_sign++;
len -= 2; len -= 2;
} }
TempNewSymbol ty_sym = SymbolTable::new_symbol(ty_sign, len, thread); TempNewSymbol ty_sym = SymbolTable::new_symbol(ty_sign, len);
if (klass->name() == ty_sym) { if (klass->name() == ty_sym) {
return true; return true;
} }

View file

@ -519,12 +519,12 @@ bool MethodHandles::is_signature_polymorphic_public_name(Klass* klass, Symbol* n
// convert the external string or reflective type to an internal signature // convert the external string or reflective type to an internal signature
Symbol* MethodHandles::lookup_signature(oop type_str, bool intern_if_not_found, TRAPS) { Symbol* MethodHandles::lookup_signature(oop type_str, bool intern_if_not_found, TRAPS) {
if (java_lang_invoke_MethodType::is_instance(type_str)) { if (java_lang_invoke_MethodType::is_instance(type_str)) {
return java_lang_invoke_MethodType::as_signature(type_str, intern_if_not_found, THREAD); return java_lang_invoke_MethodType::as_signature(type_str, intern_if_not_found);
} else if (java_lang_Class::is_instance(type_str)) { } else if (java_lang_Class::is_instance(type_str)) {
return java_lang_Class::as_signature(type_str, false, THREAD); return java_lang_Class::as_signature(type_str, false);
} else if (java_lang_String::is_instance_inlined(type_str)) { } else if (java_lang_String::is_instance_inlined(type_str)) {
if (intern_if_not_found) { if (intern_if_not_found) {
return java_lang_String::as_symbol(type_str, THREAD); return java_lang_String::as_symbol(type_str);
} else { } else {
return java_lang_String::as_symbol_or_null(type_str); return java_lang_String::as_symbol_or_null(type_str);
} }
@ -602,7 +602,7 @@ Symbol* MethodHandles::lookup_basic_type_signature(Symbol* sig, bool keep_last_a
} }
const char* sigstr = buffer.base(); const char* sigstr = buffer.base();
int siglen = (int) buffer.size(); int siglen = (int) buffer.size();
bsig = SymbolTable::new_symbol(sigstr, siglen, THREAD); bsig = SymbolTable::new_symbol(sigstr, siglen);
} }
assert(is_basic_type_signature(bsig) || assert(is_basic_type_signature(bsig) ||
// detune assert in case the injected argument is not a basic type: // detune assert in case the injected argument is not a basic type:

View file

@ -407,9 +407,9 @@ address NativeLookup::lookup(const methodHandle& method, bool& in_base_library,
address NativeLookup::base_library_lookup(const char* class_name, const char* method_name, const char* signature) { address NativeLookup::base_library_lookup(const char* class_name, const char* method_name, const char* signature) {
EXCEPTION_MARK; EXCEPTION_MARK;
bool in_base_library = true; // SharedRuntime inits some math methods. bool in_base_library = true; // SharedRuntime inits some math methods.
TempNewSymbol c_name = SymbolTable::new_symbol(class_name, CATCH); TempNewSymbol c_name = SymbolTable::new_symbol(class_name);
TempNewSymbol m_name = SymbolTable::new_symbol(method_name, CATCH); TempNewSymbol m_name = SymbolTable::new_symbol(method_name);
TempNewSymbol s_name = SymbolTable::new_symbol(signature, CATCH); TempNewSymbol s_name = SymbolTable::new_symbol(signature);
// Find the class // Find the class
Klass* k = SystemDictionary::resolve_or_fail(c_name, true, CATCH); Klass* k = SystemDictionary::resolve_or_fail(c_name, true, CATCH);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,7 +51,7 @@
static const char* lookup_diagnosticArgumentEnum(const char* field_name, oop object) { static const char* lookup_diagnosticArgumentEnum(const char* field_name, oop object) {
Thread* THREAD = Thread::current(); Thread* THREAD = Thread::current();
const char* enum_sig = "Lsun/hotspot/parser/DiagnosticCommand$DiagnosticArgumentType;"; const char* enum_sig = "Lsun/hotspot/parser/DiagnosticCommand$DiagnosticArgumentType;";
TempNewSymbol enumSigSymbol = SymbolTable::lookup(enum_sig, (int) strlen(enum_sig), THREAD); TempNewSymbol enumSigSymbol = SymbolTable::new_symbol(enum_sig);
int offset = WhiteBox::offset_for_field(field_name, object, enumSigSymbol); int offset = WhiteBox::offset_for_field(field_name, object, enumSigSymbol);
oop enumOop = object->obj_field(offset); oop enumOop = object->obj_field(offset);

View file

@ -179,7 +179,7 @@ public:
WB_ENTRY(jboolean, WB_IsClassAlive(JNIEnv* env, jobject target, jstring name)) WB_ENTRY(jboolean, WB_IsClassAlive(JNIEnv* env, jobject target, jstring name))
oop h_name = JNIHandles::resolve(name); oop h_name = JNIHandles::resolve(name);
if (h_name == NULL) return false; if (h_name == NULL) return false;
Symbol* sym = java_lang_String::as_symbol(h_name, CHECK_false); Symbol* sym = java_lang_String::as_symbol(h_name);
TempNewSymbol tsym(sym); // Make sure to decrement reference count on sym on return TempNewSymbol tsym(sym); // Make sure to decrement reference count on sym on return
WBIsKlassAliveClosure closure(sym); WBIsKlassAliveClosure closure(sym);
@ -191,7 +191,7 @@ WB_END
WB_ENTRY(jint, WB_GetSymbolRefcount(JNIEnv* env, jobject unused, jstring name)) WB_ENTRY(jint, WB_GetSymbolRefcount(JNIEnv* env, jobject unused, jstring name))
oop h_name = JNIHandles::resolve(name); oop h_name = JNIHandles::resolve(name);
if (h_name == NULL) return false; if (h_name == NULL) return false;
Symbol* sym = java_lang_String::as_symbol(h_name, CHECK_0); Symbol* sym = java_lang_String::as_symbol(h_name);
TempNewSymbol tsym(sym); // Make sure to decrement reference count on sym on return TempNewSymbol tsym(sym); // Make sure to decrement reference count on sym on return
return (jint)sym->refcount(); return (jint)sym->refcount();
WB_END WB_END
@ -1996,8 +1996,7 @@ int WhiteBox::offset_for_field(const char* field_name, oop object,
InstanceKlass* ik = InstanceKlass::cast(arg_klass); InstanceKlass* ik = InstanceKlass::cast(arg_klass);
//Create symbols to look for in the class //Create symbols to look for in the class
TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name), TempNewSymbol name_symbol = SymbolTable::new_symbol(field_name);
THREAD);
//To be filled in with an offset of the field we're looking for //To be filled in with an offset of the field we're looking for
fieldDescriptor fd; fieldDescriptor fd;

View file

@ -1430,7 +1430,7 @@ void Deoptimization::load_class_by_index(const constantPoolHandle& constant_pool
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
for (SignatureStream ss(symbol); !ss.is_done(); ss.next()) { for (SignatureStream ss(symbol); !ss.is_done(); ss.next()) {
if (ss.is_object()) { if (ss.is_object()) {
Symbol* class_name = ss.as_symbol(CHECK); Symbol* class_name = ss.as_symbol();
Handle protection_domain (THREAD, constant_pool->pool_holder()->protection_domain()); Handle protection_domain (THREAD, constant_pool->pool_holder()->protection_domain());
SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK); SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -82,7 +82,7 @@ BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS
int len = (int)strlen(element); int len = (int)strlen(element);
assert(element[len-1] == ';', "last char should be a semicolon"); assert(element[len-1] == ';', "last char should be a semicolon");
element[len-1] = '\0'; // chop off semicolon element[len-1] = '\0'; // chop off semicolon
fd._object_key = SymbolTable::new_symbol(element + 1, CHECK_(T_BYTE)); fd._object_key = SymbolTable::new_symbol(element + 1);
} }
// Pass dimension back to caller // Pass dimension back to caller
fd._dimension = dim; fd._dimension = dim;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -757,7 +757,7 @@ static oop get_mirror_from_signature(const methodHandle& method,
if (T_OBJECT == ss->type() || T_ARRAY == ss->type()) { if (T_OBJECT == ss->type() || T_ARRAY == ss->type()) {
Symbol* name = ss->as_symbol(CHECK_NULL); Symbol* name = ss->as_symbol();
oop loader = method->method_holder()->class_loader(); oop loader = method->method_holder()->class_loader();
oop protection_domain = method->method_holder()->protection_domain(); oop protection_domain = method->method_holder()->protection_domain();
const Klass* k = SystemDictionary::resolve_or_fail(name, const Klass* k = SystemDictionary::resolve_or_fail(name,

View file

@ -336,7 +336,7 @@ bool SignatureStream::is_array() const {
return _type == T_ARRAY; return _type == T_ARRAY;
} }
Symbol* SignatureStream::as_symbol(TRAPS) { Symbol* SignatureStream::as_symbol() {
// Create a symbol from for string _begin _end // Create a symbol from for string _begin _end
int begin = _begin; int begin = _begin;
int end = _end; int end = _end;
@ -368,7 +368,7 @@ Symbol* SignatureStream::as_symbol(TRAPS) {
// Save names for cleaning up reference count at the end of // Save names for cleaning up reference count at the end of
// SignatureStream scope. // SignatureStream scope.
name = SymbolTable::new_symbol(symbol_chars, len, CHECK_NULL); name = SymbolTable::new_symbol(symbol_chars, len);
if (!name->is_permanent()) { if (!name->is_permanent()) {
if (_names == NULL) { if (_names == NULL) {
_names = new GrowableArray<Symbol*>(10); _names = new GrowableArray<Symbol*>(10);
@ -382,7 +382,7 @@ Symbol* SignatureStream::as_symbol(TRAPS) {
Klass* SignatureStream::as_klass(Handle class_loader, Handle protection_domain, Klass* SignatureStream::as_klass(Handle class_loader, Handle protection_domain,
FailureMode failure_mode, TRAPS) { FailureMode failure_mode, TRAPS) {
if (!is_object()) return NULL; if (!is_object()) return NULL;
Symbol* name = as_symbol(CHECK_NULL); Symbol* name = as_symbol();
if (failure_mode == ReturnNull) { if (failure_mode == ReturnNull) {
return SystemDictionary::resolve_or_null(name, class_loader, protection_domain, THREAD); return SystemDictionary::resolve_or_null(name, class_loader, protection_domain, THREAD);
} else { } else {

View file

@ -400,7 +400,7 @@ class SignatureStream : public StackObj {
bool is_object() const; // True if this argument is an object bool is_object() const; // True if this argument is an object
bool is_array() const; // True if this argument is an array bool is_array() const; // True if this argument is an array
BasicType type() const { return _type; } BasicType type() const { return _type; }
Symbol* as_symbol(TRAPS); Symbol* as_symbol();
enum FailureMode { ReturnNull, NCDFError }; enum FailureMode { ReturnNull, NCDFError };
Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS); Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS); oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,14 +34,14 @@ TEST_VM(SymbolTable, temp_new_symbol) {
// the thread should be in vm to use locks // the thread should be in vm to use locks
ThreadInVMfromNative ThreadInVMfromNative(THREAD); ThreadInVMfromNative ThreadInVMfromNative(THREAD);
Symbol* abc = SymbolTable::new_symbol("abc", CATCH); Symbol* abc = SymbolTable::new_symbol("abc");
int abccount = abc->refcount(); int abccount = abc->refcount();
TempNewSymbol ss = abc; TempNewSymbol ss = abc;
ASSERT_EQ(ss->refcount(), abccount) << "only one abc"; ASSERT_EQ(ss->refcount(), abccount) << "only one abc";
ASSERT_EQ(ss->refcount(), abc->refcount()) << "should match TempNewSymbol"; ASSERT_EQ(ss->refcount(), abc->refcount()) << "should match TempNewSymbol";
Symbol* efg = SymbolTable::new_symbol("efg", CATCH); Symbol* efg = SymbolTable::new_symbol("efg");
Symbol* hij = SymbolTable::new_symbol("hij", CATCH); Symbol* hij = SymbolTable::new_symbol("hij");
int efgcount = efg->refcount(); int efgcount = efg->refcount();
int hijcount = hij->refcount(); int hijcount = hij->refcount();
@ -63,12 +63,12 @@ TEST_VM(SymbolTable, temp_new_symbol) {
ASSERT_EQ(s1->refcount(), abccount + 1) << "should still be two abc (s1 and ss)"; ASSERT_EQ(s1->refcount(), abccount + 1) << "should still be two abc (s1 and ss)";
TempNewSymbol s3; TempNewSymbol s3;
Symbol* klm = SymbolTable::new_symbol("klm", CATCH); Symbol* klm = SymbolTable::new_symbol("klm");
int klmcount = klm->refcount(); int klmcount = klm->refcount();
s3 = klm; // assignment s3 = klm; // assignment
ASSERT_EQ(s3->refcount(), klmcount) << "only one klm now"; ASSERT_EQ(s3->refcount(), klmcount) << "only one klm now";
Symbol* xyz = SymbolTable::new_symbol("xyz", CATCH); Symbol* xyz = SymbolTable::new_symbol("xyz");
int xyzcount = xyz->refcount(); int xyzcount = xyz->refcount();
{ // inner scope { // inner scope
TempNewSymbol s_inner = xyz; TempNewSymbol s_inner = xyz;
@ -77,7 +77,7 @@ TEST_VM(SymbolTable, temp_new_symbol) {
<< "Should have been decremented by dtor in inner scope"; << "Should have been decremented by dtor in inner scope";
// Test overflowing refcount making symbol permanent // Test overflowing refcount making symbol permanent
Symbol* bigsym = SymbolTable::new_symbol("bigsym", CATCH); Symbol* bigsym = SymbolTable::new_symbol("bigsym");
for (int i = 0; i < PERM_REFCOUNT + 100; i++) { for (int i = 0; i < PERM_REFCOUNT + 100; i++) {
bigsym->increment_refcount(); bigsym->increment_refcount();
} }
@ -101,9 +101,8 @@ class SymbolThread : public JavaTestThread {
SymbolThread(Semaphore* post) : JavaTestThread(post) {} SymbolThread(Semaphore* post) : JavaTestThread(post) {}
virtual ~SymbolThread() {} virtual ~SymbolThread() {}
void main_run() { void main_run() {
Thread* THREAD = Thread::current();
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
TempNewSymbol sym = SymbolTable::new_symbol(symbol_name, CATCH); TempNewSymbol sym = SymbolTable::new_symbol(symbol_name);
// Create and destroy new symbol // Create and destroy new symbol
EXPECT_TRUE(sym->refcount() != 0) << "Symbol refcount unexpectedly zeroed"; EXPECT_TRUE(sym->refcount() != 0) << "Symbol refcount unexpectedly zeroed";
} }
@ -121,12 +120,10 @@ public:
void main_run() { void main_run() {
Semaphore done(0); Semaphore done(0);
Thread* THREAD = Thread::current();
// Find a symbol where there will probably be only one instance. // Find a symbol where there will probably be only one instance.
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
os::snprintf(symbol_name, SYM_NAME_LENGTH, "some_symbol%d", i); os::snprintf(symbol_name, SYM_NAME_LENGTH, "some_symbol%d", i);
TempNewSymbol ts = SymbolTable::new_symbol(symbol_name, CATCH); TempNewSymbol ts = SymbolTable::new_symbol(symbol_name);
if (ts->refcount() == 1) { if (ts->refcount() == 1) {
EXPECT_TRUE(ts->refcount() == 1) << "Symbol is just created"; EXPECT_TRUE(ts->refcount() == 1) << "Symbol is just created";
break; // found a unique symbol break; // found a unique symbol