[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/image meta_types.c,1.11,1.12
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/image meta_types.c,1.11,1.12 |
Date: |
Wed, 16 Jul 2003 19:44:17 -0400 |
Update of /cvsroot/dotgnu-pnet/pnet/image
In directory subversions:/tmp/cvs-serv923/image
Modified Files:
meta_types.c
Log Message:
Add the function "ILTypeFindOrCreateArray", which will attempt to locate an
array type in the synthetic hash before creating a new one; this is used to
prevent unlimited memory growth in loop bodies that allocate arrays.
Index: meta_types.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/meta_types.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** meta_types.c 23 May 2003 02:32:25 -0000 1.11
--- meta_types.c 16 Jul 2003 23:44:15 -0000 1.12
***************
*** 50,53 ****
--- 50,57 ----
elem = type;
type = ILMemPoolCalloc(&(context->typePool), ILType);
+ if(!type)
+ {
+ return 0;
+ }
type->kind__ = IL_TYPE_COMPLEX_ARRAY_CONTINUE;
type->un.array__.elemType__ = elem;
***************
*** 58,61 ****
--- 62,105 ----
}
return type;
+ }
+
+ ILType *ILTypeFindOrCreateArray(ILContext *context, unsigned long rank,
+ ILType *elem)
+ {
+ ILType *type;
+ ILType dims[8];
+ unsigned long index;
+ ILClass *info;
+
+ /* Bail out if too many dimensions to be worth checking */
+ if(rank > 8)
+ {
+ return ILTypeCreateArray(context, rank, elem);
+ }
+
+ /* Create a pseudo type on the stack, for performing hash lookups */
+ ILMemZero(dims, sizeof(ILType) * rank);
+ for(index = 0; index < (rank - 1); ++index)
+ {
+ dims[index].kind__ = IL_TYPE_COMPLEX_ARRAY_CONTINUE;
+ dims[index].un.array__.elemType__ = &(dims[index + 1]);
+ dims[index].un.array__.size__ = 0;
+ dims[index].un.array__.lowBound__ = 0;
+ }
+ dims[index].kind__ = IL_TYPE_COMPLEX_ARRAY;
+ dims[index].un.array__.elemType__ = elem;
+ dims[index].un.array__.size__ = 0;
+ dims[index].un.array__.lowBound__ = 0;
+ type = &(dims[0]);
+
+ /* Look for the type in the synthetic hash */
+ info = ILHashFindType(context->syntheticHash, type, ILClass);
+ if(info)
+ {
+ return info->synthetic;
+ }
+
+ /* Create the type for the first time */
+ return ILTypeCreateArray(context, rank, elem);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/image meta_types.c,1.11,1.12,
Rhys Weatherley <address@hidden> <=