X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fgc-common.c;h=b266f4296a648eee4c05e9107e01b2e54ee6e9ac;hb=dde834ef75cb12b8cdda23472b3365de72d9422a;hp=04096e8ae40377341de28130aafbdd12f2c68dde;hpb=fc999187f3f80dfcf170348df676386b8403e261;p=sbcl.git diff --git a/src/runtime/gc-common.c b/src/runtime/gc-common.c index 04096e8..b266f42 100644 --- a/src/runtime/gc-common.c +++ b/src/runtime/gc-common.c @@ -15,21 +15,6 @@ */ /* - * GENerational Conservative Garbage Collector for SBCL x86 - */ - -/* - * This software is part of the SBCL system. See the README file for - * more information. - * - * This software is derived from the CMU CL system, which was - * written at Carnegie Mellon University and released into the - * public domain. The software is in the public domain and is - * provided with absolutely no warranty. See the COPYING and CREDITS - * files for more information. - */ - -/* * For a review of garbage collection techniques (e.g. generational * GC) and terminology (e.g. "scavenging") see Paul R. Wilson, * "Uniprocessor Garbage Collection Techniques". As of 20000618, this @@ -42,6 +27,7 @@ #include #include +#include #include "runtime.h" #include "sbcl.h" #include "os.h" @@ -112,7 +98,6 @@ copy_object(lispobj object, int nwords) { int tag; lispobj *new; - lispobj *source, *dest; gc_assert(is_lisp_pointer(object)); gc_assert(from_space_p(object)); @@ -124,18 +109,8 @@ copy_object(lispobj object, int nwords) /* Allocate space. */ new = gc_general_alloc(nwords*4,ALLOC_BOXED,ALLOC_QUICK); - dest = new; - source = (lispobj *) native_pointer(object); - /* Copy the object. */ - while (nwords > 0) { - dest[0] = source[0]; - dest[1] = source[1]; - dest += 2; - source += 2; - nwords -= 2; - } - + memcpy(new,native_pointer(object),nwords*4); return make_lispobj(new,tag); } @@ -144,14 +119,12 @@ static int scav_lose(lispobj *where, lispobj object); /* forward decl */ /* FIXME: Most calls end up going to some trouble to compute an * 'n_words' value for this function. The system might be a little * simpler if this function used an 'end' parameter instead. */ - void scavenge(lispobj *start, long n_words) { lispobj *end = start + n_words; lispobj *object_ptr; int n_words_scavenged; - for (object_ptr = start; object_ptr < end; object_ptr += n_words_scavenged) { @@ -233,7 +206,6 @@ scav_fun_pointer(lispobj *where, lispobj object) switch (widetag_of(*first_pointer)) { case SIMPLE_FUN_HEADER_WIDETAG: - case CLOSURE_FUN_HEADER_WIDETAG: copy = trans_fun_header(object); break; default: @@ -328,7 +300,7 @@ trans_code(struct code *code) /* fix self pointer. */ nfheaderp->self = -#ifdef LISP_FEATURE_GENCGC /* GENCGC? Maybe x86 is better conditional */ +#ifdef LISP_FEATURE_X86 FUN_RAW_ADDR_OFFSET + #endif nfheaderl; @@ -408,6 +380,7 @@ size_code_header(lispobj *where) return nwords; } +#ifndef LISP_FEATURE_X86 static int scav_return_pc_header(lispobj *where, lispobj object) { @@ -416,6 +389,7 @@ scav_return_pc_header(lispobj *where, lispobj object) (unsigned long) object); return 0; /* bogus return value to satisfy static type checking */ } +#endif /* LISP_FEATURE_X86 */ static lispobj trans_return_pc_header(lispobj object) @@ -460,6 +434,7 @@ scav_closure_header(lispobj *where, lispobj object) } #endif +#ifndef LISP_FEATURE_X86 static int scav_fun_header(lispobj *where, lispobj object) { @@ -468,6 +443,7 @@ scav_fun_header(lispobj *where, lispobj object) (unsigned long) object); return 0; /* bogus return value to satisfy static type checking */ } +#endif /* LISP_FEATURE_X86 */ static lispobj trans_fun_header(lispobj object) @@ -1590,7 +1566,6 @@ gc_init_tables(void) scavtab[CODE_HEADER_WIDETAG] = scav_code_header; #ifndef LISP_FEATURE_GENCGC /* FIXME ..._X86 ? */ scavtab[SIMPLE_FUN_HEADER_WIDETAG] = scav_fun_header; - scavtab[CLOSURE_FUN_HEADER_WIDETAG] = scav_fun_header; scavtab[RETURN_PC_HEADER_WIDETAG] = scav_return_pc_header; #endif #ifdef LISP_FEATURE_X86 @@ -1698,7 +1673,6 @@ gc_init_tables(void) transother[COMPLEX_ARRAY_WIDETAG] = trans_boxed; transother[CODE_HEADER_WIDETAG] = trans_code_header; transother[SIMPLE_FUN_HEADER_WIDETAG] = trans_fun_header; - transother[CLOSURE_FUN_HEADER_WIDETAG] = trans_fun_header; transother[RETURN_PC_HEADER_WIDETAG] = trans_return_pc_header; transother[CLOSURE_HEADER_WIDETAG] = trans_boxed; transother[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = trans_boxed; @@ -1805,7 +1779,6 @@ gc_init_tables(void) #if 0 /* We shouldn't see these, so just lose if it happens. */ sizetab[SIMPLE_FUN_HEADER_WIDETAG] = size_function_header; - sizetab[CLOSURE_FUN_HEADER_WIDETAG] = size_function_header; sizetab[RETURN_PC_HEADER_WIDETAG] = size_return_pc_header; #endif sizetab[CLOSURE_HEADER_WIDETAG] = size_boxed; @@ -1819,3 +1792,25 @@ gc_init_tables(void) sizetab[INSTANCE_HEADER_WIDETAG] = size_boxed; sizetab[FDEFN_WIDETAG] = size_boxed; } + + +/* Find the code object for the given pc, or return NULL on + failure. */ +lispobj * +component_ptr_from_pc(lispobj *pc) +{ + lispobj *object = NULL; + + if ( (object = search_read_only_space(pc)) ) + ; + else if ( (object = search_static_space(pc)) ) + ; + else + object = search_dynamic_space(pc); + + if (object) /* if we found something */ + if (widetag_of(*object) == CODE_HEADER_WIDETAG) + return(object); + + return (NULL); +}