Skip to content

Commit

Permalink
bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawSumma committed Jun 7, 2024
1 parent a0e9a44 commit 0d34450
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
9 changes: 3 additions & 6 deletions tool/core.mak
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@



OPT ?= -Os -flto

EXE ?=
Expand Down Expand Up @@ -60,7 +61,7 @@ VM_SRCS += $(VM_AST_SRCS) $(VM_BASE_SRCS) $(VM_BACKEND_SRCS) $(VM_DATA_SRCS) $(V
VM_OBJS = $(VM_SRCS:%.c=$(OBJ_DIR)/%.o)
CFLAGS_VM_TCC_YES = -DVM_USE_TCC

TCC_SRCS ?= $(TCC_DIR)/libtcc.c
TCC_SRCS ?= $(TCC_DIR)/libtcc.c $(TCC_DIR)/lib/libtcc1.c
TCC_OBJS = $(TCC_SRCS:%.c=$(OBJ_DIR)/%.o)

TB_SRCS_BASE = $(CUIK_DIR)/common/common.c $(CUIK_DIR)/common/perf.c $(CUIK_DIR)/tb/src/libtb.c $(CUIK_DIR)/tb/src/x64/x64_target.c $(CUIK_DIR)/tb/src/wasm/wasm_target.c
Expand Down Expand Up @@ -105,11 +106,7 @@ MKDIR = @mkdir -p
# find test -name '*.lua' | xargs echo
TEST_LUAS = test/closure/funcons.lua test/closure/ccall.lua test/closure/recursive.lua test/closure/funcret.lua test/closure/delay.lua test/closure/yodacall.lua test/tables/len.lua test/tables/test.lua test/tables/tbench.lua test/tables/concat.lua test/tables/trees_no_loop.lua test/tables/trees2.lua test/tables/abench.lua test/tables/trees.lua test/types/scary.lua test/basic/boolean.lua test/basic/countdown.lua test/basic/method.lua test/basic/mod.lua test/basic/if.lua test/basic/hello.lua test/basic/types.lua test/basic/while.lua test/basic/idiv.lua test/basic/numtype.lua test/basic/arg.lua test/rec/tak.lua test/rec/tarai.lua test/fib/tab.lua test/fib/ptr.lua test/fib/fib.lua test/loop/squares.lua test/loop/primes_for.lua test/loop/loop2.lua test/loop/eval.lua test/loop/primes4.lua test/loop/primes5.lua test/loop/primes2.lua test/loop/primes3.lua test/loop/primes1.lua test/loop/sqrt.lua test/loop/range.lua test/loop/loop.lua
TEST_TEXTS = $(TEST_LUAS:%.lua=$(TEST_DIR)/%.diff)
TEST_TIMEOUT_WINDOWS = timeout /t $(TEST_TIME)
TEST_TIMEOUT_MAC = timeout $(TEST_TIME)s
TEST_TIMEOUT_LINUX = timeout $(TEST_TIME)s
TEST_TIMEOUT_FREEBSD = timeout $(TEST_TIME)s
TEST_TIMEOUT = $(TEST_TIMEOUT_$(OS))
TEST_TIMEOUT = timeout $(TEST_TIME)s

default: all

Expand Down
16 changes: 13 additions & 3 deletions vm/backend/tb.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@
#define VM_TB_TYPE_VALUE TB_TYPE_I64

#if defined(VM_USE_TCC)
#include "../../vendor/tcc/libtcc.h"

void vm_tb_tcc_error_func(void *user, const char *msg) {
(void) user;
printf("%s\n", msg);
exit(1);
}

static void *vm_tcc_new(void) {
unsigned long long __fixunsdfdi(double a1);

TCCState *state = tcc_new();
tcc_set_error_func(state, 0, vm_tb_tcc_error_func);
tcc_set_options(state, "-nostdlib");
tcc_add_symbol(state, "__fixunsdfdi", (const void *) &__fixunsdfdi);
return state;
}
#endif

static bool vm_tb_str_eq(const char *str1, const char *str2) {
Expand Down Expand Up @@ -76,9 +88,7 @@ vm_std_value_t vm_tb_run_repl(vm_config_t *config, vm_block_t *entry, vm_blocks_
if (config->dump_c) {
printf("\n--- c ---\n%s", buf);
}
TCCState *state = tcc_new();
tcc_set_error_func(state, 0, vm_tb_tcc_error_func);
tcc_set_options(state, "-nostdlib");
TCCState *state = vm_tcc_new();
tcc_set_output_type(state, TCC_OUTPUT_MEMORY);
tcc_compile_string(state, buf);
tcc_add_symbol(state, "memmove", &memmove);
Expand Down
5 changes: 1 addition & 4 deletions vm/backend/tb_dyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#define VM_BE_TB_DYN

#include "../../vendor/cuik/common/arena.h"
#include "../../vendor/tcc/libtcc.h"
#include "../ir/check.h"
#include "./exec.h"

Expand Down Expand Up @@ -1683,9 +1682,7 @@ vm_tb_dyn_func_t *vm_tb_dyn_comp(vm_tb_dyn_state_t *state, vm_block_t *entry) {
if (state->config->dump_c) {
printf("\n--- c ---\n%s", buf);
}
TCCState *tcc = tcc_new();
tcc_set_error_func(tcc, 0, vm_tb_tcc_error_func);
tcc_set_options(tcc, "-nostdlib");
TCCState *tcc = vm_tcc_new();
tcc_set_output_type(tcc, TCC_OUTPUT_MEMORY);
tcc_compile_string(tcc, buf);
tcc_add_symbol(tcc, "memmove", &memmove);
Expand Down
5 changes: 1 addition & 4 deletions vm/backend/tb_ver.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#define VM_BE_TB_VER

#include "../../vendor/cuik/common/arena.h"
#include "../../vendor/tcc/libtcc.h"
#include "../ir/check.h"
#include "../ir/rblock.h"
#include "./exec.h"
Expand Down Expand Up @@ -1762,9 +1761,7 @@ static void *vm_tb_ver_rfunc_comp(vm_rblock_t *rblock) {
if (state->config->dump_c) {
printf("\n--- c ---\n%s", buf);
}
TCCState *state = tcc_new();
tcc_set_error_func(state, 0, vm_tb_tcc_error_func);
tcc_set_options(state, "-nostdlib");
TCCState *state = vm_tcc_new();
tcc_set_output_type(state, TCC_OUTPUT_MEMORY);
tcc_compile_string(state, buf);
tcc_add_symbol(state, "memmove", &memmove);
Expand Down

0 comments on commit 0d34450

Please sign in to comment.