From 40f6a8f39da1faba169a081dfd3aeb7ad8391f55 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Wed, 28 Mar 2012 13:40:35 +0300 Subject: [PATCH] cleanup: gencgc copy_unboxed_object and shared gc_general_copy_object Implement the first in terms of the second: they're identical except for the calling convention. Move the second to gc-internal.h as an inline function. Also eliminates a couple of longs. --- src/runtime/gc-common.c | 21 +-------------------- src/runtime/gc-internal.h | 24 ++++++++++++++++++++++++ src/runtime/gencgc.c | 18 +----------------- 3 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/runtime/gc-common.c b/src/runtime/gc-common.c index d9810fa..6816760 100644 --- a/src/runtime/gc-common.c +++ b/src/runtime/gc-common.c @@ -95,27 +95,8 @@ os_vm_size_t bytes_consed_between_gcs = 12*1024*1024; /* * copying objects */ -static -lispobj -gc_general_copy_object(lispobj object, long nwords, int page_type_flag) -{ - int tag; - lispobj *new; - - gc_assert(is_lisp_pointer(object)); - gc_assert(from_space_p(object)); - gc_assert((nwords & 0x01) == 0); - /* Get tag of object. */ - tag = lowtag_of(object); - - /* Allocate space. */ - new = gc_general_alloc(nwords*N_WORD_BYTES, page_type_flag, ALLOC_QUICK); - - /* Copy the object. */ - memcpy(new,native_pointer(object),nwords*N_WORD_BYTES); - return make_lispobj(new,tag); -} +/* gc_general_copy_object is inline from gc-internal.h */ /* to copy a boxed object */ lispobj diff --git a/src/runtime/gc-internal.h b/src/runtime/gc-internal.h index 3d0bfb7..a9a3802 100644 --- a/src/runtime/gc-internal.h +++ b/src/runtime/gc-internal.h @@ -19,6 +19,12 @@ #include #include "thread.h" +#ifdef LISP_FEATURE_GENCGC +#include "gencgc-internal.h" +#else +#include "cheneygc-internal.h" +#endif + /* disabling gc assertions made no discernable difference to GC speed, * last I tried it - dan 2003.12.21 * @@ -105,6 +111,24 @@ gc_general_alloc(long nbytes, int page_type_flag, int quick_p) extern void *gc_general_alloc(long nbytes,int page_type_flag,int quick_p); #endif +static inline lispobj +gc_general_copy_object(lispobj object, long nwords, int page_type_flag) +{ + lispobj *new; + + gc_assert(is_lisp_pointer(object)); + gc_assert(from_space_p(object)); + gc_assert((nwords & 0x01) == 0); + + /* Allocate space. */ + new = gc_general_alloc(nwords*N_WORD_BYTES, page_type_flag, ALLOC_QUICK); + + /* Copy the object. */ + memcpy(new,native_pointer(object),nwords*N_WORD_BYTES); + + return make_lispobj(new, lowtag_of(object)); +} + extern long (*scavtab[256])(lispobj *where, lispobj object); extern lispobj (*transother[256])(lispobj object); extern long (*sizetab[256])(lispobj *where); diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index 9f119ed..856b553 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -1588,23 +1588,7 @@ copy_large_unboxed_object(lispobj object, long nwords) lispobj copy_unboxed_object(lispobj object, long nwords) { - long tag; - lispobj *new; - - gc_assert(is_lisp_pointer(object)); - gc_assert(from_space_p(object)); - gc_assert((nwords & 0x01) == 0); - - /* Get tag of object. */ - tag = lowtag_of(object); - - /* Allocate space. */ - new = gc_quick_alloc_unboxed(nwords*N_WORD_BYTES); - - memcpy(new,native_pointer(object),nwords*N_WORD_BYTES); - - /* Return Lisp pointer of new object. */ - return ((lispobj) new) | tag; + return gc_general_copy_object(object, nwords, UNBOXED_PAGE_FLAG); } -- 1.7.10.4