Squashed 'lispBM/lispBM/' changes from 1be203ec..7756d581

7756d581 update benchresults
bf99ae97 removed seldom used fundamental operations, is_fundamental, encode, decode

git-subtree-dir: lispBM/lispBM
git-subtree-split: 7756d5819e4dd18a4907f9ae68a5e8e752b962f1
This commit is contained in:
Benjamin Vedder 2022-10-04 11:17:07 +02:00
parent 63e050c452
commit e8748c33d6
16 changed files with 100 additions and 178 deletions

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.004100000, 0.006300000, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.001900000, 4.044300079, 484.042541503, 300, 500, 94, 1968
tak.lisp, 0.003100000, 3.492500066, 528.078796386, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001599999, 3.035700082, 478.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002199999, 1.438300013, 486.666656494, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001599999, 3.828000068, 469.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.003100000, 0.005299999, 3, 300, 300, 1, 2047
q2.lisp, 0.002799999, 1.641499996, 505.172424316, 300, 600, 58, 1920

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.004100000, 0.006300000, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.002000000, 3.922199964, 484.042541503, 300, 500, 94, 1968
tak.lisp, 0.003000000, 3.402800083, 532.512329101, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001599999, 2.977400064, 468.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002000000, 1.379600048, 460.000000000, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001700000, 3.696199893, 466.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.003100000, 0.005299999, 300.000000000, 300, 300, 1, 2047
q2.lisp, 0.002899999, 1.604099988, 517.241394042, 300, 600, 58, 1920

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.004100000, 0.006300000, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.001900000, 3.793200016, 503.191497802, 300, 600, 94, 1968
tak.lisp, 0.003100000, 3.300699949, 551.231506347, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001700000, 2.908799886, 498.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002099999, 1.286499977, 480.000000000, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001500000, 3.570600032, 489.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.003100000, 0.005200000, 300.000000000, 300, 300, 1, 2047
q2.lisp, 0.002899999, 1.555699944, 541.379333496, 300, 600, 58, 1920

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.004199999, 0.006300000, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.002000000, 3.737999916, 504.255310058, 300, 600, 94, 1968
tak.lisp, 0.002899999, 3.257499933, 552.709350585, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001599999, 2.860199928, 493.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002300000, 1.266800045, 486.666656494, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001799999, 3.529999971, 492.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.003000000, 0.005100000, 300.000000000, 300, 300, 1, 2047
q2.lisp, 0.003000000, 1.532999992, 536.206909179, 300, 600, 58, 1920

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.004199999, 0.006300000, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.002000000, 3.708300113, 508.510650634, 300, 600, 94, 1968
tak.lisp, 0.003000000, 3.239500045, 558.128051757, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001700000, 2.851300001, 492.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002199999, 1.259699940, 486.666656494, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001599999, 3.491199970, 491.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.003000000, 0.005100000, 300.000000000, 300, 300, 1, 2047
q2.lisp, 0.002799999, 1.523000001, 536.206909179, 300, 600, 58, 1920

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.004199999, 0.006300000, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.001900000, 3.658600091, 482.978729248, 300, 500, 94, 1968
tak.lisp, 0.003000000, 3.178600072, 526.601013183, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001500000, 2.794100046, 471.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002199999, 1.240399956, 460.000000000, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001599999, 3.441600084, 463.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.003000000, 0.005100000, 300.000000000, 300, 300, 1, 2047
q2.lisp, 0.002799999, 1.499600052, 518.965515136, 300, 600, 58, 1920

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.004199999, 0.006300000, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.002000000, 3.637799978, 464.893615722, 300, 500, 94, 1968
tak.lisp, 0.003100000, 3.147799968, 527.586181640, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001599999, 2.795900106, 465.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002300000, 1.244799971, 466.666656494, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001700000, 3.432600021, 467.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.002899999, 0.004999999, 3, 300, 300, 1, 2047
q2.lisp, 0.002899999, 1.484799981, 518.965515136, 300, 600, 58, 1920

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.005100000, 0.007199999, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.001900000, 3.561199903, 485.106384277, 300, 500, 94, 1968
tak.lisp, 0.003100000, 3.112699985, 532.019714355, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001700000, 2.727499961, 470.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002099999, 1.208600044, 466.666656494, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001599999, 3.360100030, 465.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.003000000, 0.004999999, 300.000000000, 300, 300, 1, 2047
q2.lisp, 0.002799999, 1.456400036, 518.965515136, 300, 600, 58, 1920

View File

@ -0,0 +1,9 @@
File, Load time (s), Eval time (s), GC avg time (us), GC min time (us), GC max time (us), GC invocations, GC least free
insertionsort.lisp, 0.004100000, 0.006200000, 300.000000000, 300, 300, 2, 2047
fibonacci.lisp, 0.001900000, 3.562700033, 484.042541503, 300, 500, 94, 1968
tak.lisp, 0.003000000, 3.111000061, 524.137939453, 300, 600, 203, 1854
dec_cnt2.lisp, 0.001500000, 2.718400001, 470.000000000, 300, 500, 100, 2014
dec_cnt3.lisp, 0.002099999, 1.210800051, 460.000000000, 300, 500, 15, 1996
dec_cnt1.lisp, 0.001599999, 3.355900049, 469.000000000, 300, 500, 100, 2014
fibonacci_tail.lisp, 0.003100000, 0.005100000, 300.000000000, 300, 300, 1, 2047
q2.lisp, 0.002700000, 1.456699967, 520.689636230, 300, 600, 58, 1920

View File

@ -243,30 +243,25 @@
#define SYM_ACONS 0x222 #define SYM_ACONS 0x222
#define SYM_SET_ASSOC 0x223 #define SYM_SET_ASSOC 0x223
#define SYM_COSSA 0x224 #define SYM_COSSA 0x224
#define SYM_IS_FUNDAMENTAL 0x225 #define SYM_IX 0x225
#define SYM_IX 0x226 #define SYM_TO_I 0x226
#define SYM_ENCODE_I32 0x227 #define SYM_TO_I32 0x227
#define SYM_ENCODE_U32 0x228 #define SYM_TO_U 0x228
#define SYM_ENCODE_FLOAT 0x229 #define SYM_TO_U32 0x229
#define SYM_DECODE 0x22A #define SYM_TO_FLOAT 0x22A
#define SYM_TO_I 0x22B #define SYM_TO_I64 0x22B
#define SYM_TO_I32 0x22C #define SYM_TO_U64 0x22C
#define SYM_TO_U 0x22D #define SYM_TO_DOUBLE 0x22D
#define SYM_TO_U32 0x22E #define SYM_TO_BYTE 0x22E
#define SYM_TO_FLOAT 0x22F #define SYM_SHL 0x22F
#define SYM_TO_I64 0x230 #define SYM_SHR 0x230
#define SYM_TO_U64 0x231 #define SYM_BITWISE_AND 0x231
#define SYM_TO_DOUBLE 0x232 #define SYM_BITWISE_OR 0x232
#define SYM_TO_BYTE 0x233 #define SYM_BITWISE_XOR 0x233
#define SYM_SHL 0x234 #define SYM_BITWISE_NOT 0x234
#define SYM_SHR 0x235 #define SYM_CUSTOM_DESTRUCT 0x235 /* run the destructor of a custom type */
#define SYM_BITWISE_AND 0x236 #define SYM_TYPE_OF 0x236
#define SYM_BITWISE_OR 0x237 #define FUNDAMENTALS_END 0x236
#define SYM_BITWISE_XOR 0x238
#define SYM_BITWISE_NOT 0x239
#define SYM_CUSTOM_DESTRUCT 0x23A /* run the destructor of a custom type */
#define SYM_TYPE_OF 0x23B
#define FUNDAMENTALS_END 0x23B
#define SPECIAL_SYMBOLS_START 0 #define SPECIAL_SYMBOLS_START 0
#define SPECIAL_SYMBOLS_END 0xFFFF #define SPECIAL_SYMBOLS_END 0xFFFF

View File

@ -463,7 +463,6 @@ static void array_write(lbm_value *args, lbm_uint nargs, lbm_uint *result) {
} }
} }
/* (array-create type size) */ /* (array-create type size) */
static void array_create(lbm_value *args, lbm_uint nargs, lbm_value *result) { static void array_create(lbm_value *args, lbm_uint nargs, lbm_value *result) {
*result = ENC_SYM_EERROR; *result = ENC_SYM_EERROR;
@ -1159,19 +1158,6 @@ static lbm_value fundamental_cossa(lbm_value *args, lbm_uint nargs, eval_context
return result; return result;
} }
static lbm_value fundamental_is_fundamental(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) {
(void) ctx;
lbm_value result = ENC_SYM_EERROR;
if (nargs < 1 ||
lbm_type_of(args[0]) != LBM_TYPE_SYMBOL)
result = ENC_SYM_NIL;
else if (lbm_is_fundamental(args[0]))
result = ENC_SYM_TRUE;
else
result = ENC_SYM_NIL;
return result;
}
static lbm_value fundamental_ix(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) { static lbm_value fundamental_ix(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) {
(void) ctx; (void) ctx;
lbm_value result = ENC_SYM_EERROR; lbm_value result = ENC_SYM_EERROR;
@ -1181,118 +1167,6 @@ static lbm_value fundamental_ix(lbm_value *args, lbm_uint nargs, eval_context_t
return result; return result;
} }
static lbm_value fundamental_encode_i32(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) {
(void) ctx;
lbm_value result = ENC_SYM_EERROR;
if (nargs == 1 && lbm_type_of(args[0]) == LBM_TYPE_CONS) {
lbm_value curr = args[0];
uint32_t r = 0;
int n = 4;
while (lbm_type_of(curr) == LBM_TYPE_CONS && n > 0) {
if (n < 4) r = r << 8;
if (lbm_is_number(lbm_car(curr))) {
uint32_t v = lbm_dec_as_u32(lbm_car(curr));
r |= (0xFF & v);
n --;
curr = lbm_cdr(curr);
} else {
break;
}
}
result = lbm_enc_i32((int32_t)r);
}
return result;
}
static lbm_value fundamental_encode_u32(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) {
(void) ctx;
lbm_value result = ENC_SYM_EERROR;
if (nargs == 1 && lbm_type_of(args[0]) == LBM_TYPE_CONS) {
lbm_value curr = args[0];
uint32_t r = 0;
int n = 4;
while (lbm_type_of(curr) == LBM_TYPE_CONS && n > 0) {
if (n < 4) r = r << 8;
if (lbm_is_number(lbm_car(curr))) {
uint32_t v = lbm_dec_as_u32(lbm_car(curr));
r |= (0xFF & v);
n --;
curr = lbm_cdr(curr);
} else {
break;
}
}
result = lbm_enc_u32(r);
}
return result;
}
static lbm_value fundamental_encode_float(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) {
(void) ctx;
lbm_value result = ENC_SYM_EERROR;
if (nargs == 1 && lbm_type_of(args[0]) == LBM_TYPE_CONS) {
lbm_value curr = args[0];
uint32_t r = 0;
float f;
int n = 4;
while (lbm_type_of(curr) == LBM_TYPE_CONS && n > 0) {
if (n < 4) r = r << 8;
if (lbm_is_number(lbm_car(curr))) {
uint32_t v = (uint32_t)lbm_dec_as_u32(lbm_car(curr));
r |= (0xFF & v);
n --;
curr = lbm_cdr(curr);
} else {
break;
}
}
memcpy(&f,&r, sizeof(float)); // float result
result = lbm_enc_float(f);
}
return result;
}
static lbm_value fundamental_decode(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) {
(void) ctx;
lbm_value result = ENC_SYM_EERROR;
if (nargs == 1 && (lbm_is_number(args[0]) ||
lbm_is_char(args[0]))) {
switch (lbm_type_of(args[0])) {
case LBM_TYPE_CHAR:
/*fall through*/
case LBM_TYPE_I:
/* fall through */
case LBM_TYPE_U: {
lbm_uint v = lbm_dec_as_u32(args[0]);
result = lbm_cons(lbm_enc_u(v & 0xFF), ENC_SYM_NIL);
result = lbm_cons(lbm_enc_u(v >> 8 & 0xFF), result);
result = lbm_cons(lbm_enc_u(v >> 16 & 0xFF), result);
result = lbm_cons(lbm_enc_u(v >> 24 & 0xF), result);
} break;
case LBM_TYPE_FLOAT: {
float tmp = (float)lbm_dec_float(args[0]);
uint32_t v;
memcpy(&v, &tmp, sizeof(uint32_t));
result = lbm_cons(lbm_enc_u(v & 0xFF), ENC_SYM_NIL);
result = lbm_cons(lbm_enc_u(v >> 8 & 0xFF), result);
result = lbm_cons(lbm_enc_u(v >> 16 & 0xFF), result);
result = lbm_cons(lbm_enc_u(v >> 24 & 0xFF), result);
} break;
case LBM_TYPE_I32:
/* fall through */
case LBM_TYPE_U32: {
lbm_uint v = lbm_dec_as_u32(args[0]);
result = lbm_cons(lbm_enc_u(v & 0xFF), ENC_SYM_NIL);
result = lbm_cons(lbm_enc_u(v >> 8 & 0xFF), result);
result = lbm_cons(lbm_enc_u(v >> 16 & 0xFF), result);
result = lbm_cons(lbm_enc_u(v >> 24 & 0xFF), result);
} break;
} // close switch
} // close if
return result;
}
static lbm_value fundamental_to_i(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) { static lbm_value fundamental_to_i(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) {
(void) ctx; (void) ctx;
lbm_value result = ENC_SYM_EERROR; lbm_value result = ENC_SYM_EERROR;
@ -1568,12 +1442,7 @@ const fundamental_fun fundamental_table[] =
fundamental_acons, fundamental_acons,
fundamental_set_assoc, fundamental_set_assoc,
fundamental_cossa, fundamental_cossa,
fundamental_is_fundamental,
fundamental_ix, fundamental_ix,
fundamental_encode_i32,
fundamental_encode_u32,
fundamental_encode_float,
fundamental_decode,
fundamental_to_i, fundamental_to_i,
fundamental_to_i32, fundamental_to_i32,
fundamental_to_u, fundamental_to_u,

View File

@ -200,14 +200,6 @@ special_sym const special_symbols[] = {
// fast access in list // fast access in list
{"ix" , SYM_IX}, {"ix" , SYM_IX},
// Low-level
{"encode-i32" , SYM_ENCODE_I32},
{"encode-u32" , SYM_ENCODE_U32},
{"encode-float" , SYM_ENCODE_FLOAT},
{"decode" , SYM_DECODE},
{"is-fundamental" , SYM_IS_FUNDAMENTAL},
// aliases // aliases
{"first" , SYM_CAR}, {"first" , SYM_CAR},
{"rest" , SYM_CDR}, {"rest" , SYM_CDR},

View File

@ -1,2 +0,0 @@
(eq '(0u 0u 255u 255u) (take 4 (decode (- 65536 1))))

View File

@ -1 +0,0 @@
(= 12345678i32 (encode-i32 (decode 12345678i32)))

View File

@ -1,11 +0,0 @@
(define close-enough
(lambda (x y)
(if (> x y)
(< (- x y) 0.0001)
(< (- y x) 0.0001)
)))
(close-enough 3.14 (encode-float (decode 3.14)))

View File

@ -1 +0,0 @@
(= 999999u32 (encode-u32 (decode 999999u32)))