Permalink
Browse files

[sgen] Binary protocol entries for scanning objects and vtypes.

  • Loading branch information...
1 parent 1406545 commit c64966695333953c85bf8f9feff73cf2b8c3fc97 @schani schani committed Feb 27, 2013
@@ -557,7 +557,7 @@ sgen_cardtable_scan_object (char *obj, mword block_obj_size, guint8 *cards, gboo
ScanVTypeFunc scan_vtype_func = sgen_get_current_object_ops ()->scan_vtype;
for (; elem < card_end; elem += elem_size)
- scan_vtype_func (elem, desc, queue);
+ scan_vtype_func (elem, desc, queue BINARY_PROTOCOL_ARG (elem_size));
} else {
CopyOrMarkObjectFunc copy_func = sgen_get_current_object_ops ()->copy_or_mark_object;
View
@@ -466,6 +466,12 @@ enum {
GENERATION_MAX
};
+#ifdef SGEN_BINARY_PROTOCOL
+#define BINARY_PROTOCOL_ARG(x) ,x
+#else
+#define BINARY_PROTOCOL_ARG(x)
+#endif
+
void sgen_init_internal_allocator (void) MONO_INTERNAL;
typedef struct _ObjectList ObjectList;
@@ -476,7 +482,7 @@ struct _ObjectList {
typedef void (*CopyOrMarkObjectFunc) (void**, SgenGrayQueue*);
typedef void (*ScanObjectFunc) (char*, SgenGrayQueue*);
-typedef void (*ScanVTypeFunc) (char*, mword desc, SgenGrayQueue*);
+typedef void (*ScanVTypeFunc) (char*, mword desc, SgenGrayQueue* BINARY_PROTOCOL_ARG (size_t size));
typedef struct
{
@@ -57,6 +57,7 @@ extern long long stat_scan_object_called_major;
static void
CONCURRENT_NAME (major_scan_object) (char *start, SgenGrayQueue *queue)
{
+#define SCAN_OBJECT_PROTOCOL
#include "sgen-scan-object.h"
HEAVY_STAT (++stat_scan_object_called_major);
@@ -67,12 +68,13 @@ CONCURRENT_NAME (major_scan_object) (char *start, SgenGrayQueue *queue)
#error concurrent and parallel mark not supported yet
#else
static void
-CONCURRENT_NAME (major_scan_vtype) (char *start, mword desc, SgenGrayQueue *queue)
+CONCURRENT_NAME (major_scan_vtype) (char *start, mword desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
{
/* The descriptors include info about the MonoObject header as well */
start -= sizeof (MonoObject);
#define SCAN_OBJECT_NOVTABLE
+#define SCAN_OBJECT_PROTOCOL
#include "sgen-scan-object.h"
}
#endif
@@ -58,6 +58,7 @@ extern long long stat_scan_object_called_nursery;
static void
PARALLEL_SCAN_OBJECT (char *start, SgenGrayQueue *queue)
{
+#define SCAN_OBJECT_PROTOCOL
#include "sgen-scan-object.h"
HEAVY_STAT (++stat_scan_object_called_nursery);
@@ -71,12 +72,13 @@ PARALLEL_SCAN_OBJECT (char *start, SgenGrayQueue *queue)
* Returns a pointer to the end of the object.
*/
static void
-PARALLEL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue)
+PARALLEL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
{
/* The descriptors include info about the MonoObject header as well */
start -= sizeof (MonoObject);
#define SCAN_OBJECT_NOVTABLE
+#define SCAN_OBJECT_PROTOCOL
#include "sgen-scan-object.h"
}
@@ -93,18 +95,20 @@ PARALLEL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue)
static void
SERIAL_SCAN_OBJECT (char *start, SgenGrayQueue *queue)
{
+#define SCAN_OBJECT_PROTOCOL
#include "sgen-scan-object.h"
HEAVY_STAT (++stat_scan_object_called_nursery);
}
static void
-SERIAL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue)
+SERIAL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
{
/* The descriptors include info about the MonoObject header as well */
start -= sizeof (MonoObject);
#define SCAN_OBJECT_NOVTABLE
+#define SCAN_OBJECT_PROTOCOL
#include "sgen-scan-object.h"
}
@@ -209,6 +209,20 @@ binary_protocol_mark (gpointer obj, gpointer vtable, int size)
}
void
+binary_protocol_scan_begin (gpointer obj, gpointer vtable, int size)
+{
+ SGenProtocolScanBegin entry = { obj, vtable, size };
+ protocol_entry (SGEN_PROTOCOL_SCAN_BEGIN, &entry, sizeof (SGenProtocolScanBegin));
+}
+
+void
+binary_protocol_scan_vtype_begin (gpointer obj, int size)
+{
+ SGenProtocolScanVTypeBegin entry = { obj, size };
+ protocol_entry (SGEN_PROTOCOL_SCAN_VTYPE_BEGIN, &entry, sizeof (SGenProtocolScanVTypeBegin));
+}
+
+void
binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable)
{
SGenProtocolWBarrier entry = { ptr, value, value_vtable };
@@ -31,6 +31,8 @@ enum {
SGEN_PROTOCOL_COPY,
SGEN_PROTOCOL_PIN,
SGEN_PROTOCOL_MARK,
+ SGEN_PROTOCOL_SCAN_BEGIN,
+ SGEN_PROTOCOL_SCAN_VTYPE_BEGIN,
SGEN_PROTOCOL_WBARRIER,
SGEN_PROTOCOL_GLOBAL_REMSET,
SGEN_PROTOCOL_PTR_UPDATE,
@@ -79,6 +81,17 @@ typedef struct {
} SGenProtocolMark;
typedef struct {
+ gpointer obj;
+ gpointer vtable;
+ int size;
+} SGenProtocolScanBegin;
+
+typedef struct {
+ gpointer obj;
+ int size;
+} SGenProtocolScanVTypeBegin;
+
+typedef struct {
gpointer ptr;
gpointer value;
gpointer value_vtable;
@@ -166,6 +179,8 @@ void binary_protocol_alloc_degraded (gpointer obj, gpointer vtable, int size) MO
void binary_protocol_copy (gpointer from, gpointer to, gpointer vtable, int size) MONO_INTERNAL;
void binary_protocol_pin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
void binary_protocol_mark (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
+void binary_protocol_scan_begin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
+void binary_protocol_scan_vtype_begin (gpointer start, int size) MONO_INTERNAL;
void binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
void binary_protocol_global_remset (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
void binary_protocol_ptr_update (gpointer ptr, gpointer old_value, gpointer new_value, gpointer vtable, int size) MONO_INTERNAL;
@@ -195,6 +210,8 @@ void binary_protocol_dislink_update (gpointer link, gpointer obj, int track) MON
#define binary_protocol_copy(from, to, vtable, size)
#define binary_protocol_pin(obj, vtable, size)
#define binary_protocol_mark(obj, vtable, size)
+#define binary_protocol_scan_begin(obj, vtable, size)
+#define binary_protocol_scan_vtype_begin(obj, size)
#define binary_protocol_wbarrier(ptr, value, value_vtable)
#define binary_protocol_global_remset(ptr, value, value_vtable)
#define binary_protocol_ptr_update(ptr, old_value, new_value, vtable, size)
@@ -1,25 +1,22 @@
/*
+ * sgen-scan-object.h: Generic object scan.
+ *
* 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.
+ * Copyright (C) 2013 Xamarin Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License 2.0 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License 2.0 along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
* Scans one object, using the OBJ_XXX macros. The start of the
@@ -41,6 +38,10 @@
*
* SCAN_OBJECT_NOVTABLE - desc is provided by the includer, instead of
* vt. Complex arrays cannot not be scanned.
+ *
+ * SCAN_OBJECT_PROTOCOL - if defined, binary protocol the scan.
+ * Should only be used for scanning that's done for the actual
+ * collection, not for debugging scans.
*/
#ifndef SCAN_OBJECT_ACTION
@@ -57,6 +58,14 @@
/* gcc should be smart enough to remove the bounds check, but it isn't:( */
desc = vt->desc;
+
+#if defined(SGEN_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
+ binary_protocol_scan_begin (start, vt, sgen_safe_object_get_size ((MonoObject*)start));
+#endif
+#else
+#if defined(SGEN_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
+ binary_protocol_scan_vtype_begin (start + sizeof (MonoObject), size);
+#endif
#endif
switch (desc & 0x7) {
case DESC_TYPE_RUN_LENGTH:
@@ -123,3 +132,4 @@
#undef SCAN_OBJECT_NOSCAN
#undef SCAN_OBJECT_ACTION
#undef SCAN_OBJECT_NOVTABLE
+#undef SCAN_OBJECT_PROTOCOL
View
@@ -469,7 +469,7 @@ handle_remset (mword *p, void *start_nursery, void *end_nursery, gboolean global
count = p [2];
skip_size = p [3];
while (count-- > 0) {
- sgen_get_current_object_ops ()->scan_vtype ((char*)ptr, desc, queue);
+ sgen_get_current_object_ops ()->scan_vtype ((char*)ptr, desc, queue BINARY_PROTOCOL_ARG (skip_size));
ptr = (void**)((char*)ptr + skip_size);
}
return p + 4;
@@ -27,6 +27,8 @@ read_entry (FILE *in, void **data)
case SGEN_PROTOCOL_COPY: size = sizeof (SGenProtocolCopy); break;
case SGEN_PROTOCOL_PIN: size = sizeof (SGenProtocolPin); break;
case SGEN_PROTOCOL_MARK: size = sizeof (SGenProtocolMark); break;
+ case SGEN_PROTOCOL_SCAN_BEGIN: size = sizeof (SGenProtocolScanBegin); break;
+ case SGEN_PROTOCOL_SCAN_VTYPE_BEGIN: size = sizeof (SGenProtocolScanVTypeBegin); break;
case SGEN_PROTOCOL_WBARRIER: size = sizeof (SGenProtocolWBarrier); break;
case SGEN_PROTOCOL_GLOBAL_REMSET: size = sizeof (SGenProtocolGlobalRemset); break;
case SGEN_PROTOCOL_PTR_UPDATE: size = sizeof (SGenProtocolPtrUpdate); break;
@@ -99,6 +101,16 @@ print_entry (int type, void *data)
printf ("mark obj %p vtable %p size %d\n", entry->obj, entry->vtable, entry->size);
break;
}
+ case SGEN_PROTOCOL_SCAN_BEGIN: {
+ SGenProtocolScanBegin *entry = data;
+ printf ("scan_begin obj %p vtable %p size %d\n", entry->obj, entry->vtable, entry->size);
+ break;
+ }
+ case SGEN_PROTOCOL_SCAN_VTYPE_BEGIN: {
+ SGenProtocolScanVTypeBegin *entry = data;
+ printf ("scan_vtype_begin obj %p size %d\n", entry->obj, entry->size);
+ break;
+ }
case SGEN_PROTOCOL_WBARRIER: {
SGenProtocolWBarrier *entry = data;
printf ("wbarrier ptr %p value %p value_vtable %p\n", entry->ptr, entry->value, entry->value_vtable);
@@ -214,6 +226,14 @@ is_match (gpointer ptr, int type, void *data)
SGenProtocolMark *entry = data;
return matches_interval (ptr, entry->obj, entry->size);
}
+ case SGEN_PROTOCOL_SCAN_BEGIN: {
+ SGenProtocolScanBegin *entry = data;
+ return matches_interval (ptr, entry->obj, entry->size);
+ }
+ case SGEN_PROTOCOL_SCAN_VTYPE_BEGIN: {
+ SGenProtocolScanVTypeBegin *entry = data;
+ return matches_interval (ptr, entry->obj, entry->size);
+ }
case SGEN_PROTOCOL_WBARRIER: {
SGenProtocolWBarrier *entry = data;
return ptr == entry->ptr || ptr == entry->value;

0 comments on commit c649666

Please sign in to comment.