mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpgscm: Allocate small integers in the rodata section.
* tests/gpgscm/Makefile.am (gpgscm_SOURCES): Add new file. * tests/gpgscm/scheme-private.h (struct cell): Move number to the top of the union so that we can initialize it. (struct scheme): Remove 'integer_segment'. * tests/gpgscm/scheme.c (initialize_small_integers): Remove function. (small_integers): New variable. (MAX_SMALL_INTEGER): Compute. (mk_small_integer): Adapt. (mark): Avoid marking objects already marked. This allows us to run the algorithm over objects in the rodata section if they are already marked. (scheme_init_custom_alloc): Remove initialization. (scheme_deinit): Remove deallocation. * tests/gpgscm/small-integers.h: New file. -- Allocate small integers from a fixed pool in the rodata section. This spares us the initialization, and deduplicates integers across different processes. It also makes the integers immutable, increasing memory safety. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
c9c3fe8832
commit
8640fa880d
4 changed files with 861 additions and 37 deletions
|
@ -45,11 +45,11 @@ typedef struct port {
|
|||
struct cell {
|
||||
uintptr_t _flag;
|
||||
union {
|
||||
num _number;
|
||||
struct {
|
||||
char *_svalue;
|
||||
int _length;
|
||||
} _string;
|
||||
num _number;
|
||||
port *_port;
|
||||
foreign_func _ff;
|
||||
struct {
|
||||
|
@ -152,11 +152,6 @@ pointer SHARP_HOOK; /* *sharp-hook* */
|
|||
pointer COMPILE_HOOK; /* *compile-hook* */
|
||||
#endif
|
||||
|
||||
#if USE_SMALL_INTEGERS
|
||||
/* A fixed allocation of small integers. */
|
||||
struct cell_segment *integer_segment;
|
||||
#endif
|
||||
|
||||
pointer free_cell; /* pointer to top of free cells */
|
||||
long fcells; /* # of free cells */
|
||||
size_t inhibit_gc; /* nesting of gc_disable */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue