ref: 775cc94dbb55ddd1ab137527068dbc8bd0103602
parent: 6bfa81bb6a4343f3efdf6d086d404c36982a80fd
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Feb 9 18:07:32 EST 2025
don't recompute max stack for the functions in the boot image
binary files a/boot/flisp.boot.builtin b/boot/flisp.boot.builtin differ
--- a/src/compiler.lsp
+++ b/src/compiler.lsp
@@ -89,7 +89,7 @@
(bcode (buffer))
(vi nil)
(nxt nil))
- (io-write bcode #int32(0))
+ (io-write bcode #int32(-1))
(while (< i n)
(begin
(set! vi (aref v i))
--- a/src/flisp.c
+++ b/src/flisp.c
@@ -966,6 +966,7 @@
#include "maxstack.inc"
#undef compute_maxstack
#else
+#define compute_maxstack_swap compute_maxstack
#endif
// top = top frame pointer to start at
@@ -1020,25 +1021,20 @@
type_error("vector", args[1]);
cvalue_t *arr = ptr(args[0]);
cv_pin(arr);
- char *data = cv_data(arr);
- int ms;
- if((uint8_t)data[4] >= N_OPCODES){
+ uint8_t *data = cv_data(arr);
+ bool printed = data[4] >= N_OPCODES; /* first is always arg count check */
+ if(printed){
// read syntax, shifted 48 for compact text representation
size_t i, sz = cv_len(arr);
for(i = 0; i < sz; i++)
data[i] -= 48;
-#if BYTE_ORDER == BIG_ENDIAN
- ms = compute_maxstack((uint8_t*)data, cv_len(arr));
- }else{
- ms = compute_maxstack_swap((uint8_t*)data, cv_len(arr));
}
-#else
+ int ms = GET_INT32(data);
+ if(ms < 0){
+ if((ms = (printed ? compute_maxstack : compute_maxstack_swap)(data, cv_len(arr))) < 0)
+ lerrorf(FL_ArgError, "invalid bytecode");
+ PUT_INT32(data, ms);
}
- ms = compute_maxstack((uint8_t*)data, cv_len(arr));
-#endif
- if(ms < 0)
- lerrorf(FL_ArgError, "invalid bytecode");
- PUT_INT32(data, ms);
function_t *fn = alloc_words(sizeof(function_t)/sizeof(value_t));
value_t fv = tagptr(fn, TAG_FUNCTION);
fn->bcode = args[0];