summaryrefslogtreecommitdiff
path: root/yjit_core.c
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2021-04-06 12:00:09 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:33 -0400
commite98d2c5ec818abe9a274055c2308bf3488358529 (patch)
tree9e7ddc2215e903809c99cb119d635d5d7e07cde4 /yjit_core.c
parentad5cc39dcfd25e62ee92f7e82d4913631ab42355 (diff)
Add ctcx_stack_push_local()
Diffstat (limited to 'yjit_core.c')
-rw-r--r--yjit_core.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/yjit_core.c b/yjit_core.c
index f74c5e9318..4d95fc1312 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -71,6 +71,25 @@ ctx_stack_push_self(ctx_t* ctx)
}
/*
+Push a local variable on the stack
+*/
+x86opnd_t
+ctx_stack_push_local(ctx_t* ctx, size_t local_idx)
+{
+ // Keep track of the type of the value
+ if (ctx->stack_size < MAX_TEMP_TYPES && local_idx < MAX_LOCAL_TYPES) {
+ ctx->temp_mapping[ctx->stack_size] = (temp_mapping_t){ .kind = TEMP_LOCAL, .idx = local_idx };
+ }
+
+ ctx->stack_size += 1;
+ ctx->sp_offset += 1;
+
+ // SP points just above the topmost value
+ int32_t offset = (ctx->sp_offset - 1) * sizeof(VALUE);
+ return mem_opnd(64, REG_SP, offset);
+}
+
+/*
Pop N values off the stack
Return a pointer to the stack top before the pop operation
*/