X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fsgen-old-bridge.c;h=346e4b0aeb50a1aff3d8ada64bf8b2042898dd17;hb=029fe6cfec3036b5150088c2993336ab7e257619;hp=f8437fe4810ccb775aa0858ddc85bce4e30207ce;hpb=a41d501c722ee0771de74d7c1341f3d3c57efcc9;p=mono.git diff --git a/mono/metadata/sgen-old-bridge.c b/mono/metadata/sgen-old-bridge.c index f8437fe4810..346e4b0aeb5 100644 --- a/mono/metadata/sgen-old-bridge.c +++ b/mono/metadata/sgen-old-bridge.c @@ -3,38 +3,9 @@ * * Copyright 2011 Novell, Inc (http://www.novell.com) * Copyright 2011 Xamarin Inc (http://www.xamarin.com) - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED - * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program - * for any purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is granted, - * provided the above notices are retained, and a notice that the code was - * modified is included with the above copyright notice. - * - * * Copyright 2001-2003 Ximian, Inc * Copyright 2003-2010 Novell, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include "config.h" @@ -70,11 +41,12 @@ typedef struct { DynArray array; } DynSCCArray; - /* + * Bridge data for a single managed object + * * FIXME: Optimizations: * - * Don't allocate a scrs array for just one source. Most objects have + * Don't allocate a srcs array for just one source. Most objects have * just one source, so use the srcs pointer itself. */ typedef struct _HashEntry { @@ -85,8 +57,10 @@ typedef struct _HashEntry { int finishing_time; + // "Source" managed objects pointing at this destination DynPtrArray srcs; + // Index in sccs array of SCC this object was folded into int scc_index; } HashEntry; @@ -95,13 +69,19 @@ typedef struct { double weight; } HashEntryWithAccounting; +// The graph of managed objects/HashEntries is reduced to a graph of strongly connected components typedef struct _SCC { int index; int api_index; + + // How many bridged objects does this SCC hold references to? int num_bridge_entries; + + // Index in global sccs array of SCCs holding pointers to this SCC DynIntArray xrefs; /* these are incoming, not outgoing */ } SCC; +// Maps managed objects to corresponding HashEntry stricts static SgenHashTable hash_table = SGEN_HASH_TABLE_INIT (INTERNAL_MEM_OLD_BRIDGE_HASH_TABLE, INTERNAL_MEM_OLD_BRIDGE_HASH_TABLE_ENTRY, sizeof (HashEntry), mono_aligned_addr_hash, NULL); static int current_time; @@ -392,11 +372,13 @@ dyn_array_int_merge_one (DynIntArray *array, int value) static void -enable_accounting (void) +set_config (const SgenBridgeProcessorConfig *config) { - SgenHashTable table = SGEN_HASH_TABLE_INIT (INTERNAL_MEM_BRIDGE_HASH_TABLE, INTERNAL_MEM_BRIDGE_HASH_TABLE_ENTRY, sizeof (HashEntryWithAccounting), mono_aligned_addr_hash, NULL); - bridge_accounting_enabled = TRUE; - hash_table = table; + if (config->accounting) { + SgenHashTable table = SGEN_HASH_TABLE_INIT (INTERNAL_MEM_BRIDGE_HASH_TABLE, INTERNAL_MEM_BRIDGE_HASH_TABLE_ENTRY, sizeof (HashEntryWithAccounting), mono_aligned_addr_hash, NULL); + bridge_accounting_enabled = TRUE; + hash_table = table; + } } static MonoGCBridgeObjectKind @@ -942,7 +924,7 @@ sgen_old_bridge_init (SgenBridgeProcessor *collector) collector->class_kind = class_kind; collector->register_finalized_object = register_finalized_object; collector->describe_pointer = describe_pointer; - collector->enable_accounting = enable_accounting; + collector->set_config = set_config; bridge_processor = collector; }