Save another few bytes by redefining ecl_bds_overflow() to return a pointer.
authorJuan Jose Garcia Ripoll <jjgarcia@jjgr-2.local>
Fri, 22 Jan 2010 18:15:52 +0000 (19:15 +0100)
committerJuan Jose Garcia Ripoll <jjgarcia@jjgr-2.local>
Fri, 22 Jan 2010 18:15:52 +0000 (19:15 +0100)
src/c/stacks.d
src/h/external.h
src/h/stacks.h

index 87df451..f2e4cd7 100644 (file)
@@ -140,10 +140,6 @@ ecl_extend_bindings_array(cl_object vector)
 static cl_index
 ecl_bds_bind_special_case(cl_object s)
 {
-        if (s->symbol.binding == 0) {
-                printf("\nFOO\n");
-                abort();
-        }
         if (s->symbol.binding == ECL_MISSING_SPECIAL_BINDING) {
                 return ecl_new_binding_index(s);
         } else {
@@ -169,10 +165,7 @@ ecl_bds_bind(cl_env_ptr env, cl_object s, cl_object value)
         }
         location = env->thread_local_bindings + index;
         slot = ++env->bds_top;
-        if (slot >= env->bds_limit) {
-                ecl_bds_overflow();
-                slot = env->bds_top;
-        }
+        if (slot >= env->bds_limit) slot = ecl_bds_overflow();
         slot->symbol = s;
         slot->value = *location;
         *location = value;
@@ -191,10 +184,7 @@ ecl_bds_push(cl_env_ptr env, cl_object s)
         }
         location = env->thread_local_bindings + index;
         slot = ++env->bds_top;
-        if (slot >= env->bds_limit) {
-                ecl_bds_overflow();
-                slot = env->bds_top;
-        }
+        if (slot >= env->bds_limit) slot = ecl_bds_overflow();
         slot->symbol = s;
         slot->value = *location;
        if (!(*location)) *location = s->symbol.value;
@@ -213,7 +203,7 @@ cl_object *
 ecl_symbol_slot(cl_env_ptr env, cl_object s)
 {
        if (Null(s)) {
-               s = Cnil_symbol;
+               return &(Cnil_symbol->symbol.value);
         } else {
                 cl_index index = s->symbol.binding;
                 if (index < env->thread_local_bindings_size) {
@@ -269,7 +259,7 @@ ecl_bds_set_size(cl_env_ptr env, cl_index size)
        }
 }
 
-void
+struct bds_bd *
 ecl_bds_overflow(void)
 {
        cl_env_ptr env = ecl_process_env();
@@ -285,6 +275,7 @@ ecl_bds_overflow(void)
                  @'ext::stack-overflow', @':size', MAKE_FIXNUM(size),
                  @':type', @'ext::binding-stack');
        ecl_bds_set_size(env, size + (size / 2));
+        return env->bds_top;
 }
 
 void
index 78aa248..6866df8 100644 (file)
@@ -1484,7 +1484,6 @@ extern ECL_API cl_object si_reset_stack_limits(void);
 extern ECL_API cl_object si_set_limit(cl_object type, cl_object size);
 extern ECL_API cl_object si_get_limit(cl_object type);
 
-extern ECL_API void ecl_bds_overflow(void) /*__attribute__((noreturn))*/;
 extern ECL_API cl_index ecl_progv(cl_env_ptr env, cl_object vars, cl_object values);
 extern ECL_API void ecl_bds_unwind(cl_env_ptr env, cl_index new_bds_top_index);
 extern ECL_API void ecl_unwind(cl_env_ptr env, ecl_frame_ptr fr) /*__attribute__((noreturn))*/;
index 0fa9745..1a7edf3 100644 (file)
@@ -43,6 +43,7 @@ typedef struct bds_bd {
 
 typedef struct cl_env_struct *cl_env_ptr;
 
+extern ECL_API struct bds_bd *ecl_bds_overflow(void) /*__attribute__((noreturn))*/;
 #ifdef ECL_THREADS
 #define ECL_MISSING_SPECIAL_BINDING (~((cl_index)0))
 extern ECL_API void ecl_bds_bind(cl_env_ptr env, cl_object symbol, cl_object v);