X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fsgen%2Fsgen-simple-nursery.c;h=39d08abcf16027b60b884376a02acbc9a2517ea3;hb=a5fcc9413d630aa70743019b012b633f76d9e68c;hp=62c14a5392bc394ffef8420e9741629b458d1b2b;hpb=9657f07a9b56d0c0fbaffd9e80d8638670674035;p=mono.git diff --git a/mono/sgen/sgen-simple-nursery.c b/mono/sgen/sgen-simple-nursery.c index 62c14a5392b..39d08abcf16 100644 --- a/mono/sgen/sgen-simple-nursery.c +++ b/mono/sgen/sgen-simple-nursery.c @@ -1,5 +1,6 @@ -/* - * sgen-simple-nursery.c: Simple always promote nursery. +/** + * \file + * Simple always promote nursery. * * Copyright 2001-2003 Ximian, Inc * Copyright 2003-2010 Novell, Inc. @@ -18,6 +19,7 @@ #include "mono/sgen/sgen-protocol.h" #include "mono/sgen/sgen-layout-stats.h" #include "mono/sgen/sgen-client.h" +#include "mono/utils/mono-memory-model.h" static inline GCObject* alloc_for_promotion (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references) @@ -26,6 +28,19 @@ alloc_for_promotion (GCVTable vtable, GCObject *obj, size_t objsize, gboolean ha return major_collector.alloc_object (vtable, objsize, has_references); } +static inline GCObject* +alloc_for_promotion_par (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references) +{ + /* + * FIXME + * Note that the stat is not precise. total_promoted_size incrementing is not atomic and + * even in that case, the same object might be promoted simultaneously by different workers + * leading to one of the allocated major object to be discarded. + */ + total_promoted_size += objsize; + return major_collector.alloc_object_par (vtable, objsize, has_references); +} + static SgenFragment* build_fragments_get_exclude_head (void) { @@ -55,26 +70,71 @@ clear_fragments (void) static void init_nursery (SgenFragmentAllocator *allocator, char *start, char *end) { - sgen_fragment_allocator_add (allocator, start, end); + char *nursery_limit = sgen_nursery_start + sgen_nursery_size; + + if (start < nursery_limit && end > nursery_limit) { + sgen_fragment_allocator_add (allocator, start, nursery_limit); + sgen_fragment_allocator_add (allocator, nursery_limit, end); + } else { + sgen_fragment_allocator_add (allocator, start, end); + } } /******************************************Copy/Scan functins ************************************************/ +#define collector_pin_object(obj, queue) sgen_pin_object (obj, queue); +#define COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION alloc_for_promotion +#define COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION alloc_for_promotion_par + +#define COPY_OR_MARK_PARALLEL +#include "sgen-copy-object.h" + #define SGEN_SIMPLE_NURSERY -#define SERIAL_COPY_OBJECT simple_nursery_serial_copy_object -#define SERIAL_COPY_OBJECT_FROM_OBJ simple_nursery_serial_copy_object_from_obj +#include "sgen-minor-copy-object.h" +#include "sgen-minor-scan-object.h" + +static void +fill_serial_ops (SgenObjectOperations *ops) +{ + ops->copy_or_mark_object = SERIAL_COPY_OBJECT; + FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops); +} + +#define SGEN_SIMPLE_PAR_NURSERY #include "sgen-minor-copy-object.h" #include "sgen-minor-scan-object.h" +static void +fill_parallel_ops (SgenObjectOperations *ops) +{ + ops->copy_or_mark_object = SERIAL_COPY_OBJECT; + FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops); +} + +#undef SGEN_SIMPLE_PAR_NURSERY +#define SGEN_CONCURRENT_MAJOR + +#include "sgen-minor-copy-object.h" +#include "sgen-minor-scan-object.h" + +static void +fill_serial_with_concurrent_major_ops (SgenObjectOperations *ops) +{ + ops->copy_or_mark_object = SERIAL_COPY_OBJECT; + FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops); +} + void -sgen_simple_nursery_init (SgenMinorCollector *collector) +sgen_simple_nursery_init (SgenMinorCollector *collector, gboolean parallel) { collector->is_split = FALSE; + collector->is_parallel = parallel; collector->alloc_for_promotion = alloc_for_promotion; + collector->alloc_for_promotion_par = alloc_for_promotion_par; collector->prepare_to_space = prepare_to_space; collector->clear_fragments = clear_fragments; @@ -83,8 +143,9 @@ sgen_simple_nursery_init (SgenMinorCollector *collector) collector->build_fragments_finish = build_fragments_finish; collector->init_nursery = init_nursery; - FILL_MINOR_COLLECTOR_COPY_OBJECT (collector); - FILL_MINOR_COLLECTOR_SCAN_OBJECT (collector); + fill_serial_ops (&collector->serial_ops); + fill_serial_with_concurrent_major_ops (&collector->serial_ops_with_concurrent_major); + fill_parallel_ops (&collector->parallel_ops); }