From 4d1c36baeb29efabbd0485bd24e8430574afffe5 Mon Sep 17 00:00:00 2001 From: Isabell H <50595752+lucioleKi@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:25:22 +0200 Subject: [PATCH] Revert "Fix atom_to_binary to use pre-allocated binary" --- erts/emulator/beam/atom.c | 65 +++++++--------------- erts/emulator/beam/atom.h | 11 +--- erts/emulator/beam/bif.c | 4 +- erts/emulator/beam/dist.c | 2 +- erts/emulator/beam/erl_bif_ddll.c | 4 +- erts/emulator/beam/erl_bif_info.c | 2 +- erts/emulator/beam/erl_bif_re.c | 2 +- erts/emulator/beam/erl_db_util.c | 2 +- erts/emulator/beam/erl_nif.c | 10 ++-- erts/emulator/beam/erl_printf_term.c | 4 +- erts/emulator/beam/erl_process_dump.c | 2 +- erts/emulator/beam/erl_unicode.c | 55 +++++++++--------- erts/emulator/beam/erl_utils.h | 4 +- erts/emulator/beam/external.c | 12 ++-- erts/emulator/beam/jit/beam_jit_common.cpp | 2 +- erts/emulator/test/bif_SUITE.erl | 3 - 16 files changed, 77 insertions(+), 107 deletions(-) diff --git a/erts/emulator/beam/atom.c b/erts/emulator/beam/atom.c index 1a3153028170..036816df2fae 100644 --- a/erts/emulator/beam/atom.c +++ b/erts/emulator/beam/atom.c @@ -89,7 +89,7 @@ more_atom_space(void) { AtomText* ptr; - ptr = (AtomText*) erts_alloc(ERTS_ALC_T_LITERAL, sizeof(AtomText)); + ptr = (AtomText*) erts_alloc(ERTS_ALC_T_ATOM_TXT, sizeof(AtomText)); ptr->next = text_list; text_list = ptr; @@ -105,28 +105,19 @@ more_atom_space(void) * Allocate string space within an atom text segment. */ -static Eterm* -atom_text_alloc(int bytes, Uint* size) +static byte* +atom_text_alloc(int bytes) { byte *res; ASSERT(bytes <= MAX_ATOM_SZ_LIMIT); - if (bytes <= ERL_ONHEAP_BINARY_LIMIT) { - bytes = heap_bits_size(NBITS(bytes)); - } else { - bytes = ERL_REFC_BITS_SIZE; - } - bytes *= sizeof(Eterm); - if (atom_text_pos + bytes >= atom_text_end) { more_atom_space(); } res = atom_text_pos; atom_text_pos += bytes; atom_space += bytes; - *size = bytes; - ASSERT(_is_taggable_pointer(res)); - return (Eterm*)res; + return res; } /* @@ -137,7 +128,7 @@ atom_text_alloc(int bytes, Uint* size) static HashValue atom_hash(Atom* obj) { - byte* p = obj->u.name; + byte* p = obj->name; int len = obj->len; HashValue h = 0, g; byte v; @@ -159,22 +150,12 @@ atom_hash(Atom* obj) return h; } -byte *erts_atom_get_name(Atom *atom) -{ - byte *name; - Uint size; - Uint offset; - ERTS_GET_BITSTRING(atom->u.bin, name, size, offset); - (void) size; - (void) offset; - return name; -} static int atom_cmp(Atom* tmpl, Atom* obj) { if (tmpl->len == obj->len && - sys_memcmp(tmpl->u.name, erts_atom_get_name(obj), tmpl->len) == 0) + sys_memcmp(tmpl->name, obj->name, tmpl->len) == 0) return 0; return 1; } @@ -183,18 +164,13 @@ atom_cmp(Atom* tmpl, Atom* obj) static Atom* atom_alloc(Atom* tmpl) { - Eterm* bin_ptr; - Uint size = 0; - ErtsHeapFactory factory; Atom* obj = (Atom*) erts_alloc(ERTS_ALC_T_ATOM, sizeof(Atom)); - bin_ptr = atom_text_alloc(tmpl->len, &size); - erts_factory_tmp_init(&factory, bin_ptr, size, ERTS_ALC_T_LITERAL); - obj->u.bin = erts_hfact_new_binary_from_data(&factory, 0, tmpl->len, tmpl->u.name); - erts_set_literal_tag(&obj->u.bin, bin_ptr, size); + + obj->name = atom_text_alloc(tmpl->len); + sys_memcpy(obj->name, tmpl->name, tmpl->len); obj->len = tmpl->len; obj->latin1_chars = tmpl->latin1_chars; obj->slot.index = -1; - /* * Precompute ordinal value of first 3 bytes + 7 bits. @@ -210,7 +186,7 @@ atom_alloc(Atom* tmpl) j = (tmpl->len < 4) ? tmpl->len : 4; for(i = 0; i < j; ++i) - c[i] = tmpl->u.name[i]; + c[i] = tmpl->name[i]; for(; i < 4; ++i) c[i] = '\0'; obj->ord0 = (c[0] << 23) + (c[1] << 15) + (c[2] << 7) + (c[3] >> 1); @@ -317,7 +293,7 @@ erts_atom_put_index(const byte *name, Sint len, ErtsAtomEncoding enc, int trunc) } a.len = tlen; - a.u.name = (byte *) text; + a.name = (byte *) text; atom_read_lock(); aix = index_get(&erts_atom_table, (void*) &a); atom_read_unlock(); @@ -357,7 +333,7 @@ erts_atom_put_index(const byte *name, Sint len, ErtsAtomEncoding enc, int trunc) a.len = tlen; a.latin1_chars = (Sint16) no_latin1_chars; - a.u.name = (byte *) text; + a.name = (byte *) text; atom_write_lock(); aix = index_put(&erts_atom_table, (void*) &a); atom_write_unlock(); @@ -424,7 +400,7 @@ erts_atom_get(const char *name, Uint len, Eterm* ap, ErtsAtomEncoding enc) latin1_to_utf8(utf8_copy, sizeof(utf8_copy), (const byte**)&name, &len); - a.u.name = (byte*)name; + a.name = (byte*)name; a.len = (Sint16)len; break; case ERTS_ATOM_ENC_7BIT_ASCII: @@ -439,7 +415,7 @@ erts_atom_get(const char *name, Uint len, Eterm* ap, ErtsAtomEncoding enc) } a.len = (Sint16)len; - a.u.name = (byte*)name; + a.name = (byte*)name; break; case ERTS_ATOM_ENC_UTF8: if (len > MAX_ATOM_SZ_LIMIT) { @@ -451,7 +427,7 @@ erts_atom_get(const char *name, Uint len, Eterm* ap, ErtsAtomEncoding enc) * name will fail. */ a.len = (Sint16)len; - a.u.name = (byte*)name; + a.name = (byte*)name; break; } @@ -518,19 +494,18 @@ init_atom_table(void) int ix; a.len = sys_strlen(erl_atom_names[i]); a.latin1_chars = a.len; - a.u.name = (byte*)erl_atom_names[i]; + a.name = (byte*)erl_atom_names[i]; a.slot.index = i; - - #ifdef DEBUG /* Verify 7-bit ascii */ for (ix = 0; ix < a.len; ix++) { - ASSERT((a.u.name[ix] & 0x80) == 0); + ASSERT((a.name[ix] & 0x80) == 0); } #endif ix = index_put(&erts_atom_table, (void*) &a); - (void) ix; - ASSERT(erts_atom_get_name(atom_tab(ix))); + atom_text_pos -= a.len; + atom_space -= a.len; + atom_tab(ix)->name = (byte*)erl_atom_names[i]; } } diff --git a/erts/emulator/beam/atom.h b/erts/emulator/beam/atom.h index 00b61a8b2a42..681bd4586f06 100644 --- a/erts/emulator/beam/atom.h +++ b/erts/emulator/beam/atom.h @@ -50,10 +50,7 @@ typedef struct atom { Sint16 len; /* length of atom name (UTF-8 encoded) */ Sint16 latin1_chars; /* 0-255 if atom can be encoded in latin1; otherwise, -1 */ int ord0; /* ordinal value of first 3 bytes + 7 bits */ - union{ - byte* name; /* name of atom, used by templates */ - Eterm bin; /* name of atom, used when atom is in table*/ - } u; + byte* name; /* name of atom */ } Atom; extern IndexTable erts_atom_table; @@ -62,8 +59,6 @@ ERTS_GLB_INLINE Atom* atom_tab(Uint i); ERTS_GLB_INLINE int erts_is_atom_utf8_bytes(byte *text, size_t len, Eterm term); ERTS_GLB_INLINE int erts_is_atom_str(const char *str, Eterm term, int is_latin1); -byte *erts_atom_get_name(Atom *atom); - #if ERTS_GLB_INLINE_INCL_FUNC_DEF ERTS_GLB_INLINE Atom* atom_tab(Uint i) @@ -78,7 +73,7 @@ ERTS_GLB_INLINE int erts_is_atom_utf8_bytes(byte *text, size_t len, Eterm term) return 0; a = atom_tab(atom_val(term)); return (len == (size_t) a->len - && sys_memcmp((void *) erts_atom_get_name(a), (void *) text, len) == 0); + && sys_memcmp((void *) a->name, (void *) text, len) == 0); } ERTS_GLB_INLINE int erts_is_atom_str(const char *str, Eterm term, int is_latin1) @@ -92,7 +87,7 @@ ERTS_GLB_INLINE int erts_is_atom_str(const char *str, Eterm term, int is_latin1) return 0; a = atom_tab(atom_val(term)); len = a->len; - aname = erts_atom_get_name(a); + aname = a->name; if (is_latin1) { for (i = 0; i < len; s++) { if (aname[i] < 0x80) { diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index d48292c2ae2c..9d6fd75807d3 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -2929,10 +2929,10 @@ BIF_RETTYPE atom_to_list_1(BIF_ALIST_1) BIF_RET(NIL); /* the empty atom */ ares = - erts_analyze_utf8(erts_atom_get_name(ap), ap->len, &err_pos, &num_chars, NULL); + erts_analyze_utf8(ap->name, ap->len, &err_pos, &num_chars, NULL); ASSERT(ares == ERTS_UTF8_OK); (void)ares; - res = erts_utf8_to_list(BIF_P, num_chars, erts_atom_get_name(ap), ap->len, ap->len, + res = erts_utf8_to_list(BIF_P, num_chars, ap->name, ap->len, ap->len, &num_built, &num_eaten, NIL); ASSERT(num_built == num_chars); ASSERT(num_eaten == ap->len); diff --git a/erts/emulator/beam/dist.c b/erts/emulator/beam/dist.c index 10dbf4bfedcb..59281208a60e 100644 --- a/erts/emulator/beam/dist.c +++ b/erts/emulator/beam/dist.c @@ -838,7 +838,7 @@ int is_node_name_atom(Eterm a) return 0; i = atom_val(a); ASSERT((i > 0) && (i < atom_table_size()) && (atom_tab(i) != NULL)); - return is_node_name((char*)erts_atom_get_name(atom_tab(i)), atom_tab(i)->len); + return is_node_name((char*)atom_tab(i)->name, atom_tab(i)->len); } static void diff --git a/erts/emulator/beam/erl_bif_ddll.c b/erts/emulator/beam/erl_bif_ddll.c index 15f37e3fd5b7..9279b5cce743 100644 --- a/erts/emulator/beam/erl_bif_ddll.c +++ b/erts/emulator/beam/erl_bif_ddll.c @@ -1725,7 +1725,7 @@ static int errdesc_to_code(Eterm errdesc, int *code /* out */) for (i = 0; errcode_tab[i].atm != NULL; ++i) { int len = sys_strlen(errcode_tab[i].atm); if (len == ap->len && - !sys_strncmp(errcode_tab[i].atm,(char *) erts_atom_get_name(ap),len)) { + !sys_strncmp(errcode_tab[i].atm,(char *) ap->name,len)) { *code = errcode_tab[i].code; return 0; } @@ -1799,7 +1799,7 @@ static char *pick_list_or_atom(Eterm name_term) goto error; } name = erts_alloc(ERTS_ALC_T_DDLL_TMP_BUF, ap->len + 1); - sys_memcpy(name,erts_atom_get_name(ap),ap->len); + sys_memcpy(name,ap->name,ap->len); name[ap->len] = '\0'; } else { if (erts_iolist_size(name_term, &name_len)) { diff --git a/erts/emulator/beam/erl_bif_info.c b/erts/emulator/beam/erl_bif_info.c index 7ccab058462b..6395bbefbdd2 100644 --- a/erts/emulator/beam/erl_bif_info.c +++ b/erts/emulator/beam/erl_bif_info.c @@ -2703,7 +2703,7 @@ c_compiler_used(Eterm **hpp, Uint *szp) static int is_snif_term(Eterm module_atom) { int i; Atom *a = atom_tab(atom_val(module_atom)); - char *aname = (char *) erts_atom_get_name(a); + char *aname = (char *) a->name; /* if a->name has a '.' then the bif (snif) is bogus i.e a package */ for (i = 0; i < a->len; i++) { diff --git a/erts/emulator/beam/erl_bif_re.c b/erts/emulator/beam/erl_bif_re.c index 38072f3fcd73..91554f65f7f9 100644 --- a/erts/emulator/beam/erl_bif_re.c +++ b/erts/emulator/beam/erl_bif_re.c @@ -1024,7 +1024,7 @@ build_capture(Eterm capture_spec[CAPSPEC_SIZE], const pcre *code) } } ASSERT(tmpb != NULL); - sys_memcpy(tmpb,erts_atom_get_name(ap),ap->len); + sys_memcpy(tmpb,ap->name,ap->len); tmpb[ap->len] = '\0'; } else { ErlDrvSizeT slen; diff --git a/erts/emulator/beam/erl_db_util.c b/erts/emulator/beam/erl_db_util.c index bd821f1cafed..b7666a0eb209 100644 --- a/erts/emulator/beam/erl_db_util.c +++ b/erts/emulator/beam/erl_db_util.c @@ -3857,7 +3857,7 @@ int db_is_variable(Eterm obj) if (is_not_atom(obj)) return -1; - b = erts_atom_get_name(atom_tab(atom_val(obj))); + b = atom_tab(atom_val(obj))->name; if ((n = atom_tab(atom_val(obj))->len) < 2) return -1; if (*b++ != '$') diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index 2563d40ad563..d9c61182a36e 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -1799,9 +1799,9 @@ int enif_get_atom(ErlNifEnv* env, Eterm atom, char* buf, unsigned len, return 0; } if (ap->latin1_chars == ap->len) { - sys_memcpy(buf, erts_atom_get_name(ap), ap->len); + sys_memcpy(buf, ap->name, ap->len); } else { - int dlen = erts_utf8_to_latin1((byte*)buf, erts_atom_get_name(ap), ap->len); + int dlen = erts_utf8_to_latin1((byte*)buf, ap->name, ap->len); ASSERT(dlen == ap->latin1_chars); (void)dlen; } buf[ap->latin1_chars] = '\0'; @@ -1810,7 +1810,7 @@ int enif_get_atom(ErlNifEnv* env, Eterm atom, char* buf, unsigned len, if (ap->len >= len) { return 0; } - sys_memcpy(buf, erts_atom_get_name(ap), ap->len); + sys_memcpy(buf, ap->name, ap->len); buf[ap->len] = '\0'; return ap->len + 1; } @@ -4480,8 +4480,8 @@ void erts_print_nif_taints(fmtfn_t to, void* to_arg) t = (struct tainted_module_t*) erts_atomic_read_nob(&first_taint); for ( ; t; t = t->next) { - Atom* atom = atom_tab(atom_val(t->module_atom)); - erts_cbprintf(to,to_arg,"%s%.*s", delim, atom->len, erts_atom_get_name(atom)); + const Atom* atom = atom_tab(atom_val(t->module_atom)); + erts_cbprintf(to,to_arg,"%s%.*s", delim, atom->len, atom->name); delim = ","; } erts_cbprintf(to,to_arg,"\n"); diff --git a/erts/emulator/beam/erl_printf_term.c b/erts/emulator/beam/erl_printf_term.c index b578efeb5b84..fecbbc593b98 100644 --- a/erts/emulator/beam/erl_printf_term.c +++ b/erts/emulator/beam/erl_printf_term.c @@ -234,7 +234,7 @@ static int print_atom_name(fmtfn_t fn, void* arg, Eterm atom, long *dcount) return res; } - s = erts_atom_get_name(atom_tab(i)); + s = atom_tab(i)->name; n = atom_tab(i)->len; *dcount -= atom_tab(i)->len; @@ -657,7 +657,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount) { Atom *ap = atom_tab(atom_val(fe->module)); PRINT_STRING(res, fn, arg, "#Fun<"); - PRINT_BUF(res, fn, arg, erts_atom_get_name(ap), ap->len); + PRINT_BUF(res, fn, arg, ap->name, ap->len); PRINT_CHAR(res, fn, arg, '.'); PRINT_SWORD(res, fn, arg, 'd', 0, 1, (ErlPfSWord) fe->old_index); diff --git a/erts/emulator/beam/erl_process_dump.c b/erts/emulator/beam/erl_process_dump.c index 64c143fed2c7..cf6d03454262 100644 --- a/erts/emulator/beam/erl_process_dump.c +++ b/erts/emulator/beam/erl_process_dump.c @@ -323,7 +323,7 @@ dump_element(fmtfn_t to, void *to_arg, Eterm x) erts_print(to, to_arg, "H" PTR_FMT, boxed_val(x)); } else if (is_immed(x)) { if (is_atom(x)) { - unsigned char* s = erts_atom_get_name(atom_tab(atom_val(x))); + unsigned char* s = atom_tab(atom_val(x))->name; int len = atom_tab(atom_val(x))->len; int i; diff --git a/erts/emulator/beam/erl_unicode.c b/erts/emulator/beam/erl_unicode.c index 3ac3924e99e9..970ca89bd9c0 100644 --- a/erts/emulator/beam/erl_unicode.c +++ b/erts/emulator/beam/erl_unicode.c @@ -1366,7 +1366,7 @@ Uint erts_atom_to_string_length(Eterm atom) const byte* err_pos; Uint num_chars; int ares = - erts_analyze_utf8(erts_atom_get_name(ap), ap->len, &err_pos, &num_chars, NULL); + erts_analyze_utf8(ap->name, ap->len, &err_pos, &num_chars, NULL); ASSERT(ares == ERTS_UTF8_OK); (void)ares; return num_chars; @@ -1380,7 +1380,7 @@ Eterm erts_atom_to_string(Eterm **hpp, Eterm atom, Eterm tail) ASSERT(is_atom(atom)); ap = atom_tab(atom_val(atom)); if (ap->latin1_chars >= 0) - return buf_to_intlist(hpp, (char*)erts_atom_get_name(ap), ap->len, tail); + return buf_to_intlist(hpp, (char*)ap->name, ap->len, tail); else { Eterm res; const byte* err_pos; @@ -1389,10 +1389,10 @@ Eterm erts_atom_to_string(Eterm **hpp, Eterm atom, Eterm tail) Eterm *hp_start = *hpp; int ares = #endif - erts_analyze_utf8(erts_atom_get_name(ap), ap->len, &err_pos, &num_chars, NULL); + erts_analyze_utf8(ap->name, ap->len, &err_pos, &num_chars, NULL); ASSERT(ares == ERTS_UTF8_OK); - res = erts_make_list_from_utf8_buf(hpp, num_chars, erts_atom_get_name(ap), ap->len, + res = erts_make_list_from_utf8_buf(hpp, num_chars, ap->name, ap->len, &num_built, &num_eaten, tail); ASSERT(num_built == num_chars); @@ -1924,23 +1924,26 @@ BIF_RETTYPE atom_to_binary_2(BIF_ALIST_2) ap = atom_tab(atom_val(BIF_ARG_1)); if (BIF_ARG_2 == am_latin1) { - Eterm bin_term; + Eterm bin_term; + if (ap->latin1_chars < 0) { goto error; } if (ap->latin1_chars == ap->len) { - BIF_RET(ap->u.bin); + bin_term = erts_new_binary_from_data(BIF_P, ap->len, ap->name); } else { byte* bin_p; int dbg_sz; + bin_term = erts_new_binary(BIF_P, ap->latin1_chars, &bin_p); - dbg_sz = erts_utf8_to_latin1(bin_p, erts_atom_get_name(ap), ap->len); + dbg_sz = erts_utf8_to_latin1(bin_p, ap->name, ap->len); ASSERT(dbg_sz == ap->latin1_chars); (void)dbg_sz; - BIF_RET(bin_term); } + + BIF_RET(bin_term); } else if (BIF_ARG_2 == am_utf8 || BIF_ARG_2 == am_unicode) { - BIF_RET(ap->u.bin); + BIF_RET(erts_new_binary_from_data(BIF_P, ap->len, ap->name)); } else { error: BIF_ERROR(BIF_P, BADARG); @@ -2231,11 +2234,11 @@ Sint erts_native_filename_need(Eterm ioterm, int encoding) } else { for (i = 0; i < ap->len; ) { - if (erts_atom_get_name(ap)[i] < 0x80) { + if (ap->name[i] < 0x80) { i++; - } else if (erts_atom_get_name(ap)[i] < 0xE0) { + } else if (ap->name[i] < 0xE0) { i += 2; - } else if (erts_atom_get_name(ap)[i] < 0xF0) { + } else if (ap->name[i] < 0xF0) { i += 3; } else { need = -1; @@ -2253,7 +2256,7 @@ Sint erts_native_filename_need(Eterm ioterm, int encoding) * the middle of filenames */ if (need > 0) { - byte *name = erts_atom_get_name(ap); + byte *name = ap->name; int len = ap->len; for (i = 0; i < len; i++) { if (name[i] == 0) { @@ -2395,33 +2398,33 @@ void erts_native_filename_put(Eterm ioterm, int encoding, byte *p) switch (encoding) { case ERL_FILENAME_LATIN1: for (i = 0; i < ap->len; i++) { - if (erts_atom_get_name(ap)[i] < 0x80) { - *p++ = erts_atom_get_name(ap)[i]; + if (ap->name[i] < 0x80) { + *p++ = ap->name[i]; } else { - ASSERT(erts_atom_get_name(ap)[i] < 0xC4); - *p++ = ((erts_atom_get_name(ap)[i] & 3) << 6) | (erts_atom_get_name(ap)[i+1] & 0x3F); + ASSERT(ap->name[i] < 0xC4); + *p++ = ((ap->name[i] & 3) << 6) | (ap->name[i+1] & 0x3F); i++; } } break; case ERL_FILENAME_UTF8_MAC: case ERL_FILENAME_UTF8: - sys_memcpy(p, erts_atom_get_name(ap), ap->len); + sys_memcpy(p, ap->name, ap->len); break; case ERL_FILENAME_WIN_WCHAR: for (i = 0; i < ap->len; i++) { /* Little endian */ - if (erts_atom_get_name(ap)[i] < 0x80) { - *p++ = erts_atom_get_name(ap)[i]; + if (ap->name[i] < 0x80) { + *p++ = ap->name[i]; *p++ = 0; - } else if (erts_atom_get_name(ap)[i] < 0xE0) { - *p++ = ((erts_atom_get_name(ap)[i] & 3) << 6) | (erts_atom_get_name(ap)[i+1] & 0x3F); - *p++ = ((erts_atom_get_name(ap)[i] & 0x1C) >> 2); + } else if (ap->name[i] < 0xE0) { + *p++ = ((ap->name[i] & 3) << 6) | (ap->name[i+1] & 0x3F); + *p++ = ((ap->name[i] & 0x1C) >> 2); i++; } else { - ASSERT(erts_atom_get_name(ap)[i] < 0xF0); - *p++ = ((erts_atom_get_name(ap)[i+1] & 3) << 6) | (erts_atom_get_name(ap)[i+2] & 0x3C); - *p++ = ((erts_atom_get_name(ap)[i] & 0xF) << 4) | ((erts_atom_get_name(ap)[i+1] & 0x3C) >> 2); + ASSERT(ap->name[i] < 0xF0); + *p++ = ((ap->name[i+1] & 3) << 6) | (ap->name[i+2] & 0x3C); + *p++ = ((ap->name[i] & 0xF) << 4) | ((ap->name[i+1] & 0x3C) >> 2); i += 2; } } diff --git a/erts/emulator/beam/erl_utils.h b/erts/emulator/beam/erl_utils.h index 2cbfdf9ba8d2..e29555e0de47 100644 --- a/erts/emulator/beam/erl_utils.h +++ b/erts/emulator/beam/erl_utils.h @@ -201,8 +201,8 @@ ERTS_GLB_INLINE int erts_cmp_atoms(Eterm a, Eterm b) { return diff; } - name_a = &erts_atom_get_name(aa)[3]; - name_b = &erts_atom_get_name(bb)[3]; + name_a = &aa->name[3]; + name_b = &bb->name[3]; len_a = aa->len-3; len_b = bb->len-3; diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c index d815235eacb3..cfa51387b81c 100644 --- a/erts/emulator/beam/external.c +++ b/erts/emulator/beam/external.c @@ -591,7 +591,7 @@ Sint erts_encode_ext_dist_header_finalize(ErtsDistOutputBuf* ob, a = atom_tab(atom_val(atom)); sz = a->len; ep -= sz; - sys_memcpy((void *) ep, (void *) erts_atom_get_name(a), sz); + sys_memcpy((void *) ep, (void *) a->name, sz); if (long_atoms) { ep -= 2; put_int16(sz, ep); @@ -2910,16 +2910,16 @@ enc_atom(ErtsAtomCacheMap *acmp, Eterm atom, byte *ep, Uint64 dflags) put_int8(len, ep); ep += 1; } - sys_memcpy((char *) ep, (char *) erts_atom_get_name(a), len); + sys_memcpy((char *) ep, (char *) a->name, len); } else { if (a->latin1_chars <= 255 && (dflags & DFLAG_SMALL_ATOM_TAGS)) { *ep++ = SMALL_ATOM_EXT; if (len == a->latin1_chars) { - sys_memcpy(ep+1, erts_atom_get_name(a), len); + sys_memcpy(ep+1, a->name, len); } else { - len = erts_utf8_to_latin1(ep+1, erts_atom_get_name(a), len); + len = erts_utf8_to_latin1(ep+1, a->name, len); ASSERT(len == a->latin1_chars); } put_int8(len, ep); @@ -2928,10 +2928,10 @@ enc_atom(ErtsAtomCacheMap *acmp, Eterm atom, byte *ep, Uint64 dflags) else { *ep++ = ATOM_EXT; if (len == a->latin1_chars) { - sys_memcpy(ep+2, erts_atom_get_name(a), len); + sys_memcpy(ep+2, a->name, len); } else { - len = erts_utf8_to_latin1(ep+2, erts_atom_get_name(a), len); + len = erts_utf8_to_latin1(ep+2, a->name, len); ASSERT(len == a->latin1_chars); } put_int16(len, ep); diff --git a/erts/emulator/beam/jit/beam_jit_common.cpp b/erts/emulator/beam/jit/beam_jit_common.cpp index fde678606ffa..aac423948518 100644 --- a/erts/emulator/beam/jit/beam_jit_common.cpp +++ b/erts/emulator/beam/jit/beam_jit_common.cpp @@ -39,7 +39,7 @@ extern "C" static std::string getAtom(Eterm atom) { Atom *ap = atom_tab(atom_val(atom)); - return std::string((char *)erts_atom_get_name(ap), ap->len); + return std::string((char *)ap->name, ap->len); } BeamAssemblerCommon::BeamAssemblerCommon(BaseAssembler &assembler_) diff --git a/erts/emulator/test/bif_SUITE.erl b/erts/emulator/test/bif_SUITE.erl index 33f8365b4a10..fd50e9e2bb53 100644 --- a/erts/emulator/test/bif_SUITE.erl +++ b/erts/emulator/test/bif_SUITE.erl @@ -657,9 +657,6 @@ t_atom_to_binary(Config) when is_list(Config) -> <<>> = atom_to_binary('', unicode), <<127>> = atom_to_binary('\177', utf8), <<"abcdef">> = atom_to_binary(abcdef, utf8), - <<"qwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwe">> = atom_to_binary(qwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwe, utf8), - <<"qwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwer">> = atom_to_binary(qwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwer, utf8), - <<"qwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerq">> = atom_to_binary(qwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerqwerq, utf8), HalfLongBin = atom_to_binary(HalfLongAtom, utf8), HalfLongBin = atom_to_binary(HalfLongAtom), LongAtomBin = atom_to_binary(LongAtom, utf8),