src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c
src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c
Print this page
*** 385,396 ****
for (cnt = 1; cnt < ehdr.e_shnum; cnt++) {
ELF_SHDR *shdr = scn_cache[cnt].c_shdr;
if (shdr->sh_type == sym_section) {
ELF_SYM *syms;
! int j, n, rslt;
! size_t size;
// FIXME: there could be multiple data buffers associated with the
// same ELF section. Here we can handle only one buffer. See man page
// for elf_getdata on Solaris.
--- 385,396 ----
for (cnt = 1; cnt < ehdr.e_shnum; cnt++) {
ELF_SHDR *shdr = scn_cache[cnt].c_shdr;
if (shdr->sh_type == sym_section) {
ELF_SYM *syms;
! int rslt;
! size_t size, n, j, htab_sz;
// FIXME: there could be multiple data buffers associated with the
// same ELF section. Here we can handle only one buffer. See man page
// for elf_getdata on Solaris.
*** 405,414 ****
--- 405,423 ----
// number of symbols
n = shdr->sh_size / shdr->sh_entsize;
// create hash table, we use hcreate_r, hsearch_r and hdestroy_r to
// manipulate the hash table.
+
+ // NOTES section in the man page of hcreate_r says
+ // "Hash table implementations are usually more efficient when
+ // the table contains enough free space to minimize collisions.
+ // Typically, this means that nel should be at least 25% larger
+ // than the maximum number of elements that the caller expects
+ // to store in the table."
+ htab_sz = n*1.25;
+
symtab->hash_table = (struct hsearch_data*) calloc(1, sizeof(struct hsearch_data));
rslt = hcreate_r(n, symtab->hash_table);
// guarantee(rslt, "unexpected failure: hcreate_r");
// shdr->sh_link points to the section that contains the actual strings
*** 450,460 ****
#endif
symtab->symbols[j].offset = sym_value - baseaddr;
item.key = sym_name;
item.data = (void *)&(symtab->symbols[j]);
-
hsearch_r(item, ENTER, &ret, symtab->hash_table);
}
}
}
--- 459,468 ----
src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File