summaryrefslogtreecommitdiff
path: root/yjit_utils.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-10-01 18:38:39 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:42 -0400
commitf6da559d5b88981000d4c575b6384f59d30dec22 (patch)
tree00fab354584931dd6f88dc275c26260c17259379 /yjit_utils.c
parent25eed2848344f19385b39daaac8ca5eef79f9466 (diff)
Put YJIT into a single compilation unit
For upstreaming, we want functions we export either prefixed with "rb_" or made static. Historically we haven't been following this rule, so we were "leaking" a lot of symbols as `make leak-globals` would tell us. This change unifies everything YJIT into a single compilation unit, yjit.o, and makes everything unprefixed static to pass `make leak-globals`. This manual "unified build" setup is similar to that of vm.o. Having everything in one compilation unit allows static functions to be visible across YJIT files and removes the need for declarations in headers in some cases. Unnecessary declarations were removed. Other changes of note: - switched to MJIT_SYMBOL_EXPORT_BEGIN which indicates stuff as being off limits for native extensions - the first include of each YJIT file is change to be "internal.h" - undefined MAP_STACK before explicitly redefining it since it collide's with a definition in system headers. Consider renaming?
Diffstat (limited to 'yjit_utils.c')
-rw-r--r--yjit_utils.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/yjit_utils.c b/yjit_utils.c
index 57bd027b89..ce89c5dd96 100644
--- a/yjit_utils.c
+++ b/yjit_utils.c
@@ -1,11 +1,8 @@
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include "yjit_utils.h"
-#include "yjit_asm.h"
+// This file is a fragment of the yjit.o compilation unit. See yjit.c.
// Save caller-save registers on the stack before a C call
-void push_regs(codeblock_t *cb)
+static void
+push_regs(codeblock_t *cb)
{
push(cb, RAX);
push(cb, RCX);
@@ -20,7 +17,8 @@ void push_regs(codeblock_t *cb)
}
// Restore caller-save registers from the after a C call
-void pop_regs(codeblock_t *cb)
+static void
+pop_regs(codeblock_t *cb)
{
popfq(cb);
pop(cb, R11);
@@ -34,12 +32,15 @@ void pop_regs(codeblock_t *cb)
pop(cb, RAX);
}
-static void print_int_cfun(int64_t val)
+static void
+print_int_cfun(int64_t val)
{
fprintf(stderr, "%lld\n", (long long int)val);
}
-void print_int(codeblock_t *cb, x86opnd_t opnd)
+RBIMPL_ATTR_MAYBE_UNUSED()
+static void
+print_int(codeblock_t *cb, x86opnd_t opnd)
{
push_regs(cb);
@@ -55,12 +56,15 @@ void print_int(codeblock_t *cb, x86opnd_t opnd)
pop_regs(cb);
}
-static void print_ptr_cfun(void *val)
+static void
+print_ptr_cfun(void *val)
{
fprintf(stderr, "%p\n", val);
}
-void print_ptr(codeblock_t *cb, x86opnd_t opnd)
+RBIMPL_ATTR_MAYBE_UNUSED()
+static void
+print_ptr(codeblock_t *cb, x86opnd_t opnd)
{
assert (opnd.num_bits == 64);
@@ -73,13 +77,15 @@ void print_ptr(codeblock_t *cb, x86opnd_t opnd)
pop_regs(cb);
}
-static void print_str_cfun(const char *str)
+static void
+print_str_cfun(const char *str)
{
fprintf(stderr, "%s\n", str);
}
// Print a constant string to stdout
-void print_str(codeblock_t *cb, const char *str)
+static void
+print_str(codeblock_t *cb, const char *str)
{
//as.comment("printStr(\"" ~ str ~ "\")");
size_t len = strlen(str);