diff options
author | Justus Winter <[email protected]> | 2017-04-06 09:52:36 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2017-05-03 13:36:16 +0000 |
commit | 8a168a6d4052ec31fed77c79bb96ffdd32bf9646 (patch) | |
tree | bf8a9b6cc69fe22071e1894fd737d93772b88a4f /tests/gpgscm/scheme-private.h | |
parent | gpgscm: Merge opexe_0. (diff) | |
download | gnupg-8a168a6d4052ec31fed77c79bb96ffdd32bf9646.tar.gz gnupg-8a168a6d4052ec31fed77c79bb96ffdd32bf9646.zip |
gpgscm: Create and re-use frame objects.
* tests/gpgscm/scheme-private.h (struct scheme): New field
'frame_freelist'.
* tests/gpgscm/scheme.c (enum scheme_types): New type 'T_FRAME'.
(type_to_string): Handle new type.
(settype): New macro.
(gc_disable): Make sure there is at least one frame in the free list.
(mark): Handle frame objects.
(finalize_cell): Likewise.
(dump_stack_initialize): Initialize free list.
(dump_stack_free): Simplify.
(frame_length): New variable.
(dump_stack_make_frame): New function.
(frame_slots): Likewise.
(frame_payload): New macro.
(dump_stack_allocate_frame): New function.
(dump_stack_deallocate_frame): Likewise.
(dump_stack_preallocate_frame): Likewise.
(_s_return): Unpack frame object and deallocate it.
(s_save): Wrap state in an frame object.
(dump_stack_mark): Mark the free list.
--
TinySCHEME being a SECD-machine needs to push frames onto the dump
stack. Previously, the dump stack was a list. This required four
cells for the spine, as well as up to one additional cell to encode
the current opcode. This was quite inefficient despite the fact that
we recovered the spine as well as the integer cell.
We introduce frame objects, which are a special variant of vectors of
length four. Since the length is fixed, this frees up the length
field of the vector object to store the unboxed opcode. A frame
object now fits in two cells.
Saving two or three cells is a mere byproduct, the performance gain
comes from increased locality, unboxed opcode representation, and the
ability to easily put the objects in a free list, keeping the garbage
collector out of the continuous motion of the virtual machine.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rw-r--r-- | tests/gpgscm/scheme-private.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/gpgscm/scheme-private.h b/tests/gpgscm/scheme-private.h index 0ba9a53a5..7f92bda2c 100644 --- a/tests/gpgscm/scheme-private.h +++ b/tests/gpgscm/scheme-private.h @@ -122,6 +122,7 @@ pointer args; /* register for arguments of function */ pointer envir; /* stack register for current environment */ pointer code; /* register for current code */ pointer dump; /* stack register for next evaluation */ +pointer frame_freelist; #if USE_HISTORY struct history history; /* we keep track of the call history for |