442
443 Symbol* SymbolTable::lookup_only_unicode(const jchar* name, int utf16_length,
444 unsigned int& hash) {
445 int utf8_length = UNICODE::utf8_length((jchar*) name, utf16_length);
446 char stack_buf[ON_STACK_BUFFER_LENGTH];
447 if (utf8_length < (int) sizeof(stack_buf)) {
448 char* chars = stack_buf;
449 UNICODE::convert_to_utf8(name, utf16_length, chars);
450 return lookup_only(chars, utf8_length, hash);
451 } else {
452 ResourceMark rm;
453 char* chars = NEW_RESOURCE_ARRAY(char, utf8_length + 1);
454 UNICODE::convert_to_utf8(name, utf16_length, chars);
455 return lookup_only(chars, utf8_length, hash);
456 }
457 }
458
459 void SymbolTable::new_symbols(ClassLoaderData* loader_data, const constantPoolHandle& cp,
460 int names_count, const char** names, int* lengths,
461 int* cp_indices, unsigned int* hashValues) {
462 bool c_heap = !loader_data->is_the_null_class_loader_data();
463 for (int i = 0; i < names_count; i++) {
464 const char *name = names[i];
465 int len = lengths[i];
466 unsigned int hash = hashValues[i];
467 assert(lookup_shared(name, len, hash) == NULL, "must have checked already");
468 Symbol* sym = do_add_if_needed(name, len, hash, c_heap);
469 assert(sym->refcount() != 0, "lookup should have incremented the count");
470 cp->symbol_at_put(cp_indices[i], sym);
471 }
472 }
473
474 Symbol* SymbolTable::do_add_if_needed(const char* name, int len, uintx hash, bool heap) {
475 SymbolTableLookup lookup(name, len, hash);
476 SymbolTableGet stg;
477 bool clean_hint = false;
478 bool rehash_warning = false;
479 Symbol* sym = NULL;
480 Thread* THREAD = Thread::current();
481
|
442
443 Symbol* SymbolTable::lookup_only_unicode(const jchar* name, int utf16_length,
444 unsigned int& hash) {
445 int utf8_length = UNICODE::utf8_length((jchar*) name, utf16_length);
446 char stack_buf[ON_STACK_BUFFER_LENGTH];
447 if (utf8_length < (int) sizeof(stack_buf)) {
448 char* chars = stack_buf;
449 UNICODE::convert_to_utf8(name, utf16_length, chars);
450 return lookup_only(chars, utf8_length, hash);
451 } else {
452 ResourceMark rm;
453 char* chars = NEW_RESOURCE_ARRAY(char, utf8_length + 1);
454 UNICODE::convert_to_utf8(name, utf16_length, chars);
455 return lookup_only(chars, utf8_length, hash);
456 }
457 }
458
459 void SymbolTable::new_symbols(ClassLoaderData* loader_data, const constantPoolHandle& cp,
460 int names_count, const char** names, int* lengths,
461 int* cp_indices, unsigned int* hashValues) {
462 // Note that c_heap will be true for unsafe anonymous and weak hidden classes
463 // even if their loader is the boot loader because they will have a different cld.
464 bool c_heap = !loader_data->is_the_null_class_loader_data();
465 for (int i = 0; i < names_count; i++) {
466 const char *name = names[i];
467 int len = lengths[i];
468 unsigned int hash = hashValues[i];
469 assert(lookup_shared(name, len, hash) == NULL, "must have checked already");
470 Symbol* sym = do_add_if_needed(name, len, hash, c_heap);
471 assert(sym->refcount() != 0, "lookup should have incremented the count");
472 cp->symbol_at_put(cp_indices[i], sym);
473 }
474 }
475
476 Symbol* SymbolTable::do_add_if_needed(const char* name, int len, uintx hash, bool heap) {
477 SymbolTableLookup lookup(name, len, hash);
478 SymbolTableGet stg;
479 bool clean_hint = false;
480 bool rehash_warning = false;
481 Symbol* sym = NULL;
482 Thread* THREAD = Thread::current();
483
|