@@ -33,7 +33,9 @@ static const int TAG_VEC_PTR_BITFIELD_RSHIFT = 7;
3333
3434static const int TAG_VECOF_LENGTH_RSHIFT = 2 ;
3535static const int TAG_VECOF_PTR_BITFIELD_RSHIFT = 1 ;
36- static const int TAG_VECOF_RSHIFT = 63 ;
36+ static const int TAG_VECOF_RSHIFT = 62 ;
37+
38+ static const int TAG_ISPROXY_RSHIFT = 63 ;
3739
3840// cheney implements cheney's copying collection algorithm
3941// There is a stub and explaination below.
@@ -46,7 +48,7 @@ static inline int is_forwarding(int64_t tag) {
4648}
4749
4850static inline int is_vecof (int64_t tag ) {
49- return (tag >> TAG_VECOF_RSHIFT );
51+ return 1 & (tag >> TAG_VECOF_RSHIFT );
5052}
5153
5254// Get the length field out of a vector's tag.
@@ -62,15 +64,15 @@ static inline int64_t get_vec_ptr_bitfield(int64_t tag){
6264
6365// Get the length field out of a vectorof's tag.
6466static inline int get_vecof_length (int64_t tag ){
65- return ((tag << 1 ) >> 1 ) >> TAG_VECOF_LENGTH_RSHIFT ;
67+ return ((tag << 2 ) >> 2 ) >> TAG_VECOF_LENGTH_RSHIFT ;
6668}
6769
6870// Get the "is pointer bitfield" out of a vectorof's tag.
6971static inline int64_t get_vecof_ptr_bitfield (int64_t tag ){
70- return (tag >> TAG_VECOF_PTR_BITFIELD_RSHIFT ) & 1 ;
72+ return 1 & (tag >> TAG_VECOF_PTR_BITFIELD_RSHIFT );
7173}
7274
73- static inline int get_vec_length (int64_t tag ){
75+ int get_vec_length (int64_t tag ){
7476 if (is_vecof (tag ))
7577 return get_vecof_length (tag );
7678 else
@@ -727,7 +729,7 @@ int64_t apply_closure(int64_t* clos, int64_t arg) {
727729
728730int is_vector_proxy (int64_t * vec ) {
729731 int64_t tag = vec [0 ];
730- return (1 && (tag >> 57 )) == 1 ;
732+ return (1 & (tag >> TAG_ISPROXY_RSHIFT )) == 1 ;
731733}
732734
733735int64_t proxy_vector_length (int64_t * vec ) {
@@ -763,3 +765,61 @@ int64_t proxy_vector_set(int64_t* vec, int i, int64_t arg) {
763765}
764766
765767
768+ int64_t proxy_vecof_ref (int64_t * vec , int i );
769+ int64_t proxy_vecof_set (int64_t * vec , int i , int64_t arg );
770+ int64_t proxy_vecof_length (int64_t * vec );
771+
772+ int64_t proxy_vecof_length (int64_t * vec ) {
773+ if (is_vector_proxy (vec )) {
774+ int64_t vec2 = vec [1 ];
775+ return proxy_vecof_length ((int64_t * ) vec2 );
776+ } else {
777+ return get_vecof_length (vec [0 ]);
778+ }
779+ }
780+
781+ int64_t proxy_vecof_ref (int64_t * vec , int i ) {
782+ if (is_vector_proxy (vec )) {
783+ int64_t vec2 = vec [1 ];
784+ int64_t val = proxy_vecof_ref ((int64_t * ) vec2 , i );
785+ int64_t * rd = (int64_t * ) vec [2 ];
786+ return apply_closure (rd , val );
787+ } else {
788+ return vec [i + 1 ];
789+ }
790+ }
791+
792+ int64_t proxy_vecof_set (int64_t * vec , int i , int64_t arg ) {
793+ if (is_vector_proxy (vec )) {
794+ int64_t vec2 = vec [1 ];
795+ int64_t * wr = (int64_t * ) vec [3 ];
796+ int64_t arg2 = apply_closure (wr , arg );
797+ return proxy_vecof_set ((int64_t * ) vec2 , i , arg2 );
798+ } else {
799+ vec [i + 1 ] = arg ;
800+ return 0 ;
801+ }
802+ }
803+
804+ int64_t proxy_vec_length (int64_t * vec ) {
805+ if (is_vecof (vec [0 ]))
806+ return proxy_vecof_length (vec );
807+ else
808+ return proxy_vector_length (vec );
809+ }
810+
811+ int64_t proxy_vec_ref (int64_t * vec , int i ) {
812+ if (is_vecof (vec [0 ]))
813+ return proxy_vecof_ref (vec , i );
814+ else
815+ return proxy_vector_ref (vec , i );
816+ }
817+
818+ int64_t proxy_vec_set (int64_t * vec , int i , int64_t arg ) {
819+ if (is_vecof (vec [0 ]))
820+ return proxy_vecof_set (vec , i , arg );
821+ else {
822+ return proxy_vector_set (vec , i , arg );
823+ }
824+
825+ }
0 commit comments