Verified Commit e641d333 authored by Camil Staps's avatar Camil Staps 🚀

Merge branch 'master' into optimise-wasm-interpreter

parents a1801513 cc45c57f
Pipeline #25351 passed with stages
in 15 minutes and 28 seconds
......@@ -58,7 +58,6 @@ benchmark-x86:
script:
- cd test
- ./run_tests.sh -3bf
allow_failure: true
benchmark-wasm:
extends: .base
......
......@@ -618,6 +618,7 @@ const char *instruction_type (BC_WORD i) {
case Cjsr_ap31: return "";
case Cjmp_ap32: return "";
case Cjsr_ap32: return "";
case Cadd_arg: return "";
case Cadd_arg0: return "";
case Cadd_arg1: return "";
case Cadd_arg2: return "";
......
......@@ -602,6 +602,7 @@ enum {
INSTRUCTION(jsr_ap31)
INSTRUCTION(jmp_ap32)
INSTRUCTION(jsr_ap32)
INSTRUCTION(add_arg)
INSTRUCTION(add_arg0)
INSTRUCTION(add_arg1)
INSTRUCTION(add_arg2)
......
......@@ -10,9 +10,6 @@
#define max_implemented_instruction_n CMAX-1
#define N_ADD_ARG_LABELS 32
#define MAX_Cadd_arg_INSTRUCTION_N 32
struct program pgrm;
uint32_t last_d, last_jsr_with_d;
......@@ -32,7 +29,11 @@ uint32_t allocated_strings_size;
uint32_t allocated_code_relocations_size;
uint32_t allocated_data_relocations_size;
#define N_ADD_ARG_LABELS 32
static uint32_t Fadd_arg_label_used[N_ADD_ARG_LABELS];
#ifndef LINK_CLEAN_RUNTIME
static int general_add_arg_label_used=0;
#endif
#ifndef LINK_CLEAN_RUNTIME
int16_t warned_unsupported_instructions[128]={-1};
......@@ -399,19 +400,20 @@ struct word *add_add_arg_labels(void) {
make_label_global(label);
label->label_offset = pgrm.code_size<<2;
}
if (i>MAX_Cadd_arg_INSTRUCTION_N) {
fprintf(stderr, "Error: Cadd_arg%d not yet implemented:\n",i);
++i;
while(i<N_ADD_ARG_LABELS) {
if (Fadd_arg_label_used[i])
fprintf(stderr, "Error: Cadd_arg%d not yet implemented:\n",i);
++i;
}
exit(1);
}
add_instruction(Cadd_arg0+i);
}
if (general_add_arg_label_used) {
fprintf(stderr,"Warning: currying of functions with more than 32 arguments is not implemented.\n");
struct label *label=enter_label("_add_arg");
if (label->label_module_n!=-1) {
make_label_global(label);
label->label_offset=pgrm.code_size<<2;
}
add_instruction(Cadd_arg);
}
return pgrm.code;
}
......@@ -4278,12 +4280,18 @@ struct label *code_descriptor
printf("%d\t.data2 %d %d\n",pgrm.data_size<<2,n,(arity-n)<<3);
store_data_l(n + (((arity-n)<<3)<<16));
if (n<arity-1 || (n==arity-1 && !strcmp (code_label_name,"__add__arg"))) {
struct label *label;
if (n>N_ADD_ARG_LABELS) {
general_add_arg_label_used=1;
label=enter_label("_add_arg");
} else {
Fadd_arg_label_used[n]=1;
char label_name[11];
sprintf(label_name,"_add_arg%d",n);
label = enter_label(label_name);
}
if (list_code)
printf("%d\t.data4 _add_arg%d\n",pgrm.data_size<<2,n);
Fadd_arg_label_used[n]=1;
char label_name[11];
sprintf(label_name,"_add_arg%d",n);
struct label *label = enter_label(label_name);
printf("%d\t.data4 %s\n",pgrm.data_size<<2,label->label_name);
store_data_label_value_of_label(label,0);
} else if (n==arity-1) {
if (list_code)
......
......@@ -245,8 +245,6 @@ void* __interpreter_indirection[9] = {
(void*) Cfill_a01_pop_rtn
};
static BC_WORD *asp, *bsp, *csp, *hp = NULL;
#include <setjmp.h>
#ifdef POSIX
# include <signal.h>
......@@ -372,6 +370,9 @@ int ensure_interpreter_init(void) {
return 1;
}
#ifdef LINK_CLEAN_RUNTIME
static BC_WORD *hp;
#endif
int interpret(
#ifdef LINK_CLEAN_RUNTIME
struct interpretation_environment *ie,
......@@ -381,7 +382,7 @@ int interpret(
#endif
BC_WORD *stack, size_t stack_size,
BC_WORD *heap, size_t heap_size,
BC_WORD *_asp, BC_WORD *_bsp, BC_WORD *_csp, BC_WORD *_hp,
BC_WORD *asp, BC_WORD *bsp, BC_WORD *csp, BC_WORD *_hp,
BC_WORD *_pc) {
#ifdef COMPUTED_GOTOS
/* When compiled with COMPUTED_GOTOS defined and stack=NULL, this function does
......@@ -414,10 +415,11 @@ int interpret(
#endif
BC_WORD *pc;
asp = _asp;
bsp = _bsp;
csp = _csp;
hp = _hp;
#ifdef LINK_CLEAN_RUNTIME
hp=_hp;
#else
BC_WORD *hp=_hp;
#endif
heap_size /= 2; /* copying garbage collector */
#ifdef LINK_CLEAN_RUNTIME
BC_WORD_S heap_free=heap + heap_size/(ie->options.in_first_semispace ? 2 : 1) - hp;
......
......@@ -27,4 +27,4 @@ typedef int64_t CleanInt;
#define BCGEN_INSTRUCTION_TABLE_SIZE 512
#define ABC_MAGIC_NUMBER 0x2a434241
#define ABC_VERSION 7
#define ABC_VERSION 8
......@@ -168,7 +168,7 @@ instr_mulUUL t = foldl (flip append) t
instr_RtoAC :: !Target -> Target
instr_RtoAC t = foldl (flip append) t
[ "{"
, "char r[20];"
, "char r[22];"
, "int n=sprintf(r,\"%.15g\",*((BC_REAL*)bsp)+0.0);"
, "NEED_HEAP(2+((n+IF_INT_64_OR_32(7,3))>>IF_INT_64_OR_32(3,2)));"
, "hp[0]=(BC_WORD)&__STRING__+2;"
......
......@@ -3711,7 +3711,8 @@ all_instructions opts t = bootstrap $ collect_instructions opts $ map (\i -> i t
d .= (d + if_i64_or_i32_expr (lit_word 7) (lit_word 3)) &. if_i64_or_i32_expr (lit_word -8) (lit_word -4) :.
d += (B @ 0 <<. if_i64_or_i32_expr (lit_word 3) (lit_word 2)) :.
B @ 0 .= to_word_ptr d @ 0
, alias "buildF_b" $
, alias "add_arg" $
alias "buildF_b" $
alias "ccall" $
alias "centry" $
alias "fillF_b" $
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment