Moved implementation of safe make-vector to foreign-call.

This commit is contained in:
Abdulaziz Ghuloum 2007-12-01 05:38:09 -05:00
parent 4c16c8b340
commit 3056d26a9d
3 changed files with 39 additions and 1 deletions

View File

@ -1 +1 @@
1159
1160

View File

@ -358,6 +358,14 @@
[(P len) (K #t)]
[(E len) (nop)])
(define-primop make-vector safe
[(V len)
(with-tmp ([x (make-forcall "ikrt_make_vector1" (list (T len)))])
(interrupt-when (prm '= x (K 0)))
x)])
(define-primop $vector-ref unsafe
[(V x i)
(or

View File

@ -1055,6 +1055,36 @@ ikrt_getenv(ikp bv, ikpcb* pcb){
}
}
ikp
ikrt_make_vector1(ikp len, ikpcb* pcb){
if(is_fixnum(len) && (((int)len) >= 0)){
ikp s = ik_safe_alloc(pcb, align(((int)len) + disp_vector_data));
ref(s, 0) = len;
memset(s+disp_vector_data, 0, (int)len);
return s+vector_tag;
} else {
return 0;
}
}
#if 0
ikp
ikrt_make_vector2(ikp len, ikp obj, ikpcb* pcb){
if(is_fixnum(len) && ((len >> 31)!=0)){
pcb->root0 = &obj;
ikp s = ik_safe_alloc(pcb, align(((int)len) + disp_vector_data));
pcb->root0 = 0;
ref(s, 0) = len;
memset(s+disp_vector_data, 0, (int)len);
return s+vector_tag;
} else {
return false_object;
}
}
#endif
ikp
ikrt_setenv(ikp key, ikp val, ikp overwrite){
fprintf(stderr, "setenv busted!\n");