mirror of https://github.com/rusefi/bldc.git
Squashed 'lispBM/lispBM/' changes from 4a176b04..9c2023ac
9c2023ac revert callcc gc fix and make the env hashmap static e091c36c added tests of sort and one for callcc eb164666 small tweak to make static analysis more happy git-subtree-dir: lispBM/lispBM git-subtree-split: 9c2023acd81fc12ebdc276b58a5bee6e11c18770
This commit is contained in:
parent
105c6682a5
commit
f71d005d03
|
@ -24,11 +24,9 @@
|
||||||
#include "env.h"
|
#include "env.h"
|
||||||
#include "lbm_memory.h"
|
#include "lbm_memory.h"
|
||||||
|
|
||||||
static lbm_value *env_global;
|
static lbm_value env_global[GLOBAL_ENV_ROOTS];
|
||||||
|
|
||||||
int lbm_init_env(void) {
|
int lbm_init_env(void) {
|
||||||
env_global = (lbm_value*)lbm_malloc(GLOBAL_ENV_ROOTS * sizeof(lbm_value));
|
|
||||||
if (!env_global) return 0;
|
|
||||||
for (int i = 0; i < GLOBAL_ENV_ROOTS; i ++) {
|
for (int i = 0; i < GLOBAL_ENV_ROOTS; i ++) {
|
||||||
env_global[i] = ENC_SYM_NIL;
|
env_global[i] = ENC_SYM_NIL;
|
||||||
}
|
}
|
||||||
|
|
12
src/heap.c
12
src/heap.c
|
@ -722,18 +722,6 @@ void lbm_gc_mark_phase(lbm_value root) {
|
||||||
if (t_ptr >= LBM_NON_CONS_POINTER_TYPE_FIRST &&
|
if (t_ptr >= LBM_NON_CONS_POINTER_TYPE_FIRST &&
|
||||||
t_ptr <= LBM_NON_CONS_POINTER_TYPE_LAST) continue;
|
t_ptr <= LBM_NON_CONS_POINTER_TYPE_LAST) continue;
|
||||||
|
|
||||||
if (cell->car == ENC_SYM_CONT) {
|
|
||||||
lbm_value cont = cell->cdr;
|
|
||||||
lbm_array_header_t *arr = (lbm_array_header_t*)lbm_car(cont);
|
|
||||||
lbm_value *arrdata = (lbm_value *)arr->data;
|
|
||||||
for (lbm_uint i = 0; i < arr->size / 4; i ++) {
|
|
||||||
if (lbm_is_ptr(arrdata[i])){
|
|
||||||
if (!lbm_push (s, arrdata[i])) {
|
|
||||||
lbm_critical_error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lbm_is_ptr(cell->cdr)) {
|
if (lbm_is_ptr(cell->cdr)) {
|
||||||
if (!lbm_push(s, cell->cdr)) {
|
if (!lbm_push(s, cell->cdr)) {
|
||||||
lbm_critical_error();
|
lbm_critical_error();
|
||||||
|
|
|
@ -202,7 +202,7 @@ int print_emit_continuation(lbm_char_channel_t *chan, lbm_value v) {
|
||||||
int print_emit_custom(lbm_char_channel_t *chan, lbm_value v) {
|
int print_emit_custom(lbm_char_channel_t *chan, lbm_value v) {
|
||||||
lbm_uint *custom = (lbm_uint*)lbm_car(v);
|
lbm_uint *custom = (lbm_uint*)lbm_car(v);
|
||||||
int r;
|
int r;
|
||||||
if (custom[CUSTOM_TYPE_DESCRIPTOR]) {
|
if (custom && custom[CUSTOM_TYPE_DESCRIPTOR]) {
|
||||||
r = print_emit_string(chan, (char*)custom[CUSTOM_TYPE_DESCRIPTOR]);
|
r = print_emit_string(chan, (char*)custom[CUSTOM_TYPE_DESCRIPTOR]);
|
||||||
} else {
|
} else {
|
||||||
r = print_emit_string(chan, "Unspecified_Custom_Type");
|
r = print_emit_string(chan, "Unspecified_Custom_Type");
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
(let ((r '(1 2 3 4)))
|
||||||
|
(def result (eq r (call-cc (fn (k) (define cc k))))))
|
||||||
|
|
||||||
|
(gc)
|
||||||
|
|
||||||
|
(cc '(1 2 3 4))
|
||||||
|
|
||||||
|
(check result)
|
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
(define r-list '(3 7 12 19 25 8 14 30 5 22 17 11))
|
||||||
|
|
||||||
|
(defun cmp (x y)
|
||||||
|
{
|
||||||
|
(gc)
|
||||||
|
(> x y)
|
||||||
|
})
|
||||||
|
|
||||||
|
(defun f (x)
|
||||||
|
(if (= x 0)
|
||||||
|
t
|
||||||
|
{
|
||||||
|
(sort cmp r-list)
|
||||||
|
(f (- x 1))
|
||||||
|
}))
|
||||||
|
|
||||||
|
(check (f 5))
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
(define r-list '(3 7 12 19 25 8 14 30 5 22 17 11))
|
||||||
|
|
||||||
|
|
||||||
|
(defun f (x)
|
||||||
|
(if (= x 0)
|
||||||
|
t
|
||||||
|
{
|
||||||
|
(sort > r-list)
|
||||||
|
(f (- x 1))
|
||||||
|
}))
|
||||||
|
|
||||||
|
(check (f 10000))
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
(define r-list '(3 7 12 19 25 8 14 30 5 22 17 11))
|
||||||
|
|
||||||
|
|
||||||
|
(defun f (x)
|
||||||
|
(if (= x 0)
|
||||||
|
t
|
||||||
|
{
|
||||||
|
(sort > r-list)
|
||||||
|
(gc)
|
||||||
|
(f (- x 1))
|
||||||
|
}))
|
||||||
|
|
||||||
|
(check (f 100))
|
Loading…
Reference in New Issue