From 29718f2e84478b296c3198ae6d35cfd5d79efb14 Mon Sep 17 00:00:00 2001
From: Kimplul <kimi.h.kuparinen@gmail.com>
Date: Fri, 28 Jun 2024 19:33:03 +0300
Subject: optimize interpreter a bit

+ Use a gpr/fpr/arg stack shared between different functions to minimize
  amount of memory allocations done at runtime while still allowing
  interleaving bytecode/machine code functions during call, just with a
  bit of extra setup in between
---
 src/common.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'src/common.h')

diff --git a/src/common.h b/src/common.h
index 1f52f76..1f2289d 100644
--- a/src/common.h
+++ b/src/common.h
@@ -136,7 +136,15 @@ union interp_ret {
 	double d;
 };
 
-union interp_ret ejit_interp(struct ejit_func *f, size_t argc, struct ejit_arg args[argc], bool run, void ***labels_wb);
+struct interp_state {
+	struct vec gprs;
+	struct vec fprs;
+	struct vec args;
+};
+
+union interp_ret ejit_interp(struct ejit_func *f, size_t argc, struct ejit_arg args[argc], struct interp_state *state, bool run, void ***labels_wb);
+
+long ejit_run_interp(struct ejit_func *f, size_t argc, struct ejit_arg args[argc], struct interp_state *state);
 
 bool ejit_compile(struct ejit_func *f);
 
-- 
cgit v1.2.3