Skip to content

Instantly share code, notes, and snippets.

@timo
Created April 10, 2017 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timo/3ac9a97cbaf710d0d13a13eb27f6c504 to your computer and use it in GitHub Desktop.
Save timo/3ac9a97cbaf710d0d13a13eb27f6c504 to your computer and use it in GitHub Desktop.
attempt to add "prepargs" implementation to exprjit
diff --git a/src/jit/core.expr b/src/jit/core.expr
index 1bb71c8..25fb63a 100644
--- a/src/jit/core.expr
+++ b/src/jit/core.expr
@@ -19,6 +19,8 @@
(macro: ^cu_string (,a) (idx (^getf (cu) MVMCompUnit body.strings) ,a ptr_sz))
(template: const_s (load (^cu_string $1) ptr_sz))
+(macro: ^cu_callsite (,a) (idx (^getf (cu) MVMCompUnit body.callsites) ,a ptr_sz))
+
(template: set (copy $1))
(template: getlex (copy $1))
(template: bindlex (store $0 $1 reg_sz))
@@ -103,6 +105,9 @@
$replace
(addr ,a (&offsetof MVMP6opaque body)))))
+(template: prepargs (^setf (^getf (tc) MVMThreadContext cur_frame) MVMFrame cur_args_callsite
+ (^cu_callsite $0))))
+
(template: sp_p6oget_i (load (add (^p6obody $1) $2) int_sz))
(template: sp_p6oget_n (load (add (^p6obody $1) $2) (&sizeof MVMnum64)))
(template: sp_p6oget_s (load (add (^p6obody $1) $2) ptr_sz))
OP(prepargs):
/* Store callsite in the frame so that the GC knows how to mark
* any arguments. Note that since none of the arg-setting ops can
* trigger GC, there's no way the setup can be interrupted, so we
* don't need to clear the args buffer before we start. */
cur_callsite = cu->body.callsites[GET_UI16(cur_op, 0)];
tc->cur_frame->cur_args_callsite = cur_callsite;
cur_op += 2;
goto NEXT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment