[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog engine/lib_object.c include/il_i...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog engine/lib_object.c include/il_i... |
Date: |
Mon, 04 Aug 2008 10:42:06 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 08/08/04 10:42:06
Modified files:
. : ChangeLog
engine : lib_object.c
include : il_image.h il_program.h
Log message:
Optimize _ILGetClrType and fix possible race and add some missing
prototypes.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3552&r2=1.3553
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/lib_object.c?cvsroot=dotgnu-pnet&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_image.h?cvsroot=dotgnu-pnet&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_program.h?cvsroot=dotgnu-pnet&r1=1.62&r2=1.63
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3552
retrieving revision 1.3553
diff -u -b -r1.3552 -r1.3553
--- ChangeLog 3 Aug 2008 21:49:12 -0000 1.3552
+++ ChangeLog 4 Aug 2008 10:42:05 -0000 1.3553
@@ -1,3 +1,18 @@
+2008-08-04 Klaus Treichel <address@hidden>
+
+ * engine/lib_object.c (_ILGetClrType): Optimize function so that the
+ clrType will simply be returned if it was created previously without
+ trying to layout the class again (and acquiring the metadata lock).
+ Use ILInterlockedCompareAndExchangePointers to set the clrType to
+ make sure that only one clrType will be used for one class (fix
+ possible race codition).
+
+ * include/il_image.h (ILContextGetShadowCopyFiles): Add missed prototype
+ from previous commit.
+
+ * include/il_program.h (ILClassNeedsExpansion,
ILMemberIsGenericInstance):
+ Add missing prototypes.
+
2008-08-03 Klaus Treichel <address@hidden>
* cscc/common/cc_main.c (InitCodeGen): Pass an array that can safely be
Index: engine/lib_object.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_object.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- engine/lib_object.c 15 Jul 2006 17:04:04 -0000 1.16
+++ engine/lib_object.c 4 Aug 2008 10:42:06 -0000 1.17
@@ -20,6 +20,7 @@
#include "engine_private.h"
#include "lib_defs.h"
+#include "../support/interlocked.h"
#ifdef __cplusplus
extern "C" {
@@ -128,8 +129,6 @@
ILObject *_ILGetClrType(ILExecThread *thread, ILClass *classInfo)
{
- ILObject *obj;
-
classInfo = ILClassResolve(classInfo);
if(!classInfo)
@@ -139,6 +138,12 @@
return 0;
}
+ if((!classInfo->userData) ||
+ !((ILClassPrivate *)(classInfo->userData))->clrType)
+ {
+ ILClassPrivate *classPrivate;
+ ILObject *obj;
+
/* Make sure that the class has been laid out */
IL_METADATA_WRLOCK(_ILExecThreadProcess(thread));
if(!_ILLayoutClass(_ILExecThreadProcess(thread), classInfo))
@@ -150,12 +155,11 @@
}
IL_METADATA_UNLOCK(_ILExecThreadProcess(thread));
+ classPrivate = (ILClassPrivate *)(classInfo->userData);
+
/* Does the class already have a "ClrType" instance? */
- if(((ILClassPrivate *)(classInfo->userData))->clrType)
+ if(!classPrivate->clrType)
{
- return ((ILClassPrivate *)(classInfo->userData))->clrType;
- }
-
/* Create a new "ClrType" instance */
if(!(thread->process->clrTypeClass))
{
@@ -173,11 +177,18 @@
((System_Reflection *)obj)->privateData = classInfo;
/* Attach the object to the class so that it will be returned
- for future calls to this function */
- ((ILClassPrivate *)(classInfo->userData))->clrType = obj;
+ for future calls to this function.
+ We have to use a locked compare and exchange here
because of
+ possible race conditions to be sure that only one
clr object
+ for each class is used.
+ If there was one extra object created it will be
collected by
+ the garbage collector */
+ ILInterlockedCompareAndExchangePointers((void
**)&(classPrivate->clrType), obj, 0);
+ }
+ }
/* Return the object to the caller */
- return obj;
+ return ((ILClassPrivate *)(classInfo->userData))->clrType;
}
ILClass *_ILGetClrClass(ILExecThread *thread, ILObject *type)
Index: include/il_image.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_image.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- include/il_image.h 3 Aug 2008 21:49:13 -0000 1.23
+++ include/il_image.h 4 Aug 2008 10:42:06 -0000 1.24
@@ -273,12 +273,17 @@
void ILContextClearShadowCopyDirs(ILContext *context);
/*
- * Set shadowCopyFiles to a 0 to disable shadow copies or a non null
- * value to enable shadow copies.
+ * Set shadowCopyFiles to a 0 to disable shadow copies or a value != 0
+ * to enable shadow copies.
*/
void ILContextSetShadowCopyFiles(ILContext *context, int shadowCopyFiles);
/*
+ * Get the shadowCopyFiles setting of the context
+ */
+int ILContextGetShadowCopyFiles(ILContext *context);
+
+/*
* Used by the engine to attach user data to the context instance.
*/
void ILContextSetUserData(ILContext *context, void *userData);
Index: include/il_program.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_program.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- include/il_program.h 12 Nov 2007 19:06:47 -0000 1.62
+++ include/il_program.h 4 Aug 2008 10:42:06 -0000 1.63
@@ -875,6 +875,12 @@
ILType *classArgs, ILType
*methodArgs);
/*
+ * Check if the instance if a generic class has has to be expanded
+ * with the members of the underlying generic class.
+ */
+int ILClassNeedsExpansion(ILClass *info);
+
+/*
* Return true is the generic class is already expanded.
*/
int ILClassIsExpanded(ILClass *info);
@@ -1100,6 +1106,11 @@
ILMember *ILMemberGetBase(ILMember *member);
/*
+ * Determine if a member is a generic instanciation.
+ */
+int ILMemberIsGenericInstance(ILMember *member);
+
+/*
* Helper macros for querying information about members.
*/
#define ILMember_FromToken(image,token) \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog engine/lib_object.c include/il_i...,
Klaus Treichel <=