compile.scm serialization: emit 32bit-format header when possible

This commit is contained in:
Gabriel Scherer 2021-03-15 17:24:04 +01:00
parent 8eb89941db
commit c99c947c18
15 changed files with 34 additions and 20 deletions

View File

@ -1167,13 +1167,27 @@
))
(emit-header (lambda ()
; we assume that 'count' ran first to initialize len, objcount, size32, size64
(bytecode-put-u32 #x8495A6BF) ; Intext_magic_number_big
(bytecode-put-u32 0) ; Unused
(bytecode-put-u64 len)
(bytecode-put-u64 objcount) ; note: always 0, as objects are not used in the bytecode-object format
(bytecode-put-u64 size64)
(cond
((and
(fits-unsigned 32 len)
(fits-unsigned 32 size32)
(fits-unsigned 32 size64)
)
(bytecode-put-u32 #x8495A6BE) ; Intext_magic_number_small
(bytecode-put-u32 len)
(bytecode-put-u32 objcount) ; note: always 0, as objects are not used in the bytecode-object format
(bytecode-put-u32 size32)
(bytecode-put-u32 size64)
)
(else
(bytecode-put-u32 #x8495A6BF) ; Intext_magic_number_big
(bytecode-put-u32 0) ; Unused
(bytecode-put-u64 len)
(bytecode-put-u64 objcount)
(bytecode-put-u64 size64)
))
)
))
)
(begin
(count value)
(emit-header)

View File

@ -1 +1 @@
Bytecode size: 7624 bytes
Bytecode size: 7600 bytes

View File

@ -1 +1 @@
Bytecode size: 5044 bytes
Bytecode size: 5020 bytes

View File

@ -1 +1 @@
Bytecode size: 10060 bytes
Bytecode size: 10036 bytes

View File

@ -1 +1 @@
Bytecode size: 7920 bytes
Bytecode size: 7896 bytes

View File

@ -1 +1 @@
Bytecode size: 10622 bytes
Bytecode size: 10598 bytes

View File

@ -1 +1 @@
Bytecode size: 9316 bytes
Bytecode size: 9292 bytes

View File

@ -1 +1 @@
Bytecode size: 6183 bytes
Bytecode size: 6159 bytes

View File

@ -1 +1 @@
Bytecode size: 5613 bytes
Bytecode size: 5589 bytes

View File

@ -1 +1 @@
Bytecode size: 6704 bytes
Bytecode size: 6680 bytes

View File

@ -1 +1 @@
Bytecode size: 6327 bytes
Bytecode size: 6303 bytes

View File

@ -1 +1 @@
Bytecode size: 7883 bytes
Bytecode size: 7859 bytes

View File

@ -1 +1 @@
Bytecode size: 6862 bytes
Bytecode size: 6838 bytes

View File

@ -1 +1 @@
Bytecode size: 17753 bytes
Bytecode size: 17729 bytes

View File

@ -1 +1 @@
Bytecode size: 7311 bytes
Bytecode size: 7287 bytes