Fix atom_to_binary to use pre-allocated binary (Reopened) #8631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a continuation of #8615. I merged the previous one by mistake before it was ready.
When an atom is created, we now create a binary literal of it, so that atom_to_binary returns the pre-allocated binary literal instead of a newly converted one.
In atom.h, the name field in the atom struct is changed to a union of an original name (byte*) and an Eterm binary. The former is used by templates when creating an atom. The latter is used when the atom is in the table, therefore also for atom_to_binary.
erl_global_literals.h
anderl_global_literals.c
are also redesigned. Previously, lambdas inexport.c
and atoms inatom.c
both allocate literal areas separately, without using the global literals interface. Now they both use the new interface oferl_global_literals
, so that literal areas are allocated and registered in the same way for lambdas, atoms, and all other global literals. Helper functions likeatom_text_alloc()
andmore_atom_areas()
are removed from atom.c, as they are now handled by functions inerl_global_literals.c
.