Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Shaw Summa <[email protected]>
  • Loading branch information
ShawSumma committed Mar 25, 2024
1 parent 9cef9b4 commit b91c074
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions core.mak
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ $(TB_OBJS): $(@:$(OBJ_DIR)/%.o=%.c)
$(TCC_DIR)/config.h: $(TCC_DIR)/configure
cd $(TCC_DIR)/ && ./configure

$(TCC_DIR)/tccdefs_.h: $(TCC_DIR)/include/tccdefs.h
$(MAKE) -C $(TCC_DIR) tccdefs_.h
$(TCC_DIR)/tccdefs_.h: $(TCC_DIR)/include/tccdefs.h $(TCC_DIR)/config.h
# $(MAKE) -C $(TCC_DIR) tccdefs_.h
echo '""' > $(TCC_DIR)/tccdefs_.h

$(TCC_OBJS): $(@:$(OBJ_DIR)/%.o=%.c) $(TCC_DIR) $(TCC_DIR)/config.h
$(TCC_OBJS): $(@:$(OBJ_DIR)/%.o=%.c) $(TCC_DIR) $(TCC_DIR)/tccdefs_.h $(TCC_DIR)/config.h
@mkdir -p $$(dirname $(@))
$(CC) -c $(OPT) $(@:$(OBJ_DIR)/%.o=%.c) -o $(@) $(CFLAGS)

Expand Down
3 changes: 3 additions & 0 deletions main/minivm.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ int main(int argc, char **argv) {
.use_tb_opt = false,
.use_num = VM_USE_NUM_F64,
.target = VM_TARGET_TB,
.tb_use_tailcall = true,
#endif
};
vm_blocks_t val_blocks = {0};
Expand Down Expand Up @@ -105,6 +106,8 @@ int main(int argc, char **argv) {
config->tb_regs_node = enable;
} else if (!strcmp(arg, "force-bitcast")) {
config->tb_force_bitcast = enable;
} else if (!strcmp(arg, "tailcall")) {
config->tb_use_tailcall = enable;
} else {
fprintf(stderr, "error: unknown flag --tb-%s want --tb-recompile, --tb-cast-regs, or --tb-raw-regs", arg);
return 1;
Expand Down
6 changes: 3 additions & 3 deletions vm/backend/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ void *vm_cache_comp(const char *comp, const char **srcs, const char *entry) {
fwrite(src_buf->buf, src_buf->len, 1, out);
fclose(out);
vm_io_buffer_t *cmd_buf = vm_io_buffer_new();
// vm_io_buffer_format(cmd_buf, "%s -shared -O2 -foptimize-sibling-calls -fPIC %s -o %s -w -pipe", comp, c_file, so_file);
vm_io_buffer_format(cmd_buf, "%s -shared -g2 -foptimize-sibling-calls -fPIC %s -o %s -w -pipe", comp, c_file, so_file);
vm_io_buffer_format(cmd_buf, "%s -shared -O2 -foptimize-sibling-calls -fPIC %s -o %s -w -pipe", comp, c_file, so_file);
// vm_io_buffer_format(cmd_buf, "%s -shared -g2 -foptimize-sibling-calls -fPIC %s -o %s -w -pipe", comp, c_file, so_file);
int res = system(cmd_buf->buf);
if (res) {
return NULL;
}
// remove(c_file);
remove(c_file);
}
void *handle = dlopen(so_file, RTLD_LAZY);
void *sym = dlsym(handle, entry);
Expand Down
6 changes: 3 additions & 3 deletions vm/backend/tb.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ branch_uses_reg:;
false
);

if (VM_NO_TAILCALL) {
if (state->config->tb_use_tailcall) {
TB_MultiOutput out = vm_tb_inst_call(
state,
next_proto,
Expand Down Expand Up @@ -565,7 +565,7 @@ branch_uses_reg:;
false
);

if (VM_NO_TAILCALL) {
if (state->config->tb_use_tailcall) {
TB_MultiOutput out = vm_tb_inst_call(
state,
next_proto,
Expand Down Expand Up @@ -599,7 +599,7 @@ branch_uses_reg:;
}
}

if (VM_NO_TAILCALL) {
if (state->config->tb_use_tailcall) {
TB_MultiOutput out = vm_tb_inst_call(
state,
next_proto,
Expand Down
2 changes: 1 addition & 1 deletion vm/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stdbool.h>

#define VM_USE_DUMP 1
#define VM_NO_TAILCALL 1
#define VM_FORMAT_FLOAT "%.14g"

struct vm_config_t;
Expand Down Expand Up @@ -64,6 +63,7 @@ struct vm_config_t {
bool tb_regs_cast: 1;
bool tb_regs_node: 1;
bool tb_force_bitcast: 1;
bool tb_use_tailcall;
};

#endif

0 comments on commit b91c074

Please sign in to comment.