[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/image item.c,1.6,1.7 meta_build.c,1.25,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/image item.c,1.6,1.7 meta_build.c,1.25,1.26 program.h,1.17,1.18 |
Date: |
Fri, 13 Jun 2003 00:33:29 -0400 |
Update of /cvsroot/dotgnu-pnet/pnet/image
In directory subversions:/tmp/cvs-serv27870/image
Modified Files:
item.c meta_build.c program.h
Log Message:
Convert a number of token tables to on-demand loading - Module, ModuleRef,
Assembly, AssemblyRef, OSDef, ProcessorDef, OSRef, ProcessorRef,
File, and CustomAttr.
Index: item.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/item.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** item.c 28 Feb 2003 03:59:00 -0000 1.6
--- item.c 13 Jun 2003 04:33:27 -0000 1.7
***************
*** 34,43 ****
else if(!(item->linked))
{
! return (ILAttribute *)(item->attrsOrLink);
}
else
{
! return ((ILProgramItemLink *)(item->attrsOrLink))->customAttrs;
}
}
--- 34,57 ----
else if(!(item->linked))
{
! attr = (ILAttribute *)(item->attrsOrLink);
}
else
{
! attr = ((ILProgramItemLink *)(item->attrsOrLink))->customAttrs;
}
+ if(!attr && item->image->type != IL_IMAGETYPE_BUILDING)
+ {
+ /* We need to perform on-demand loading of the attributes */
+ _ILProgramItemLoadAttributes(item);
+ if(!(item->linked))
+ {
+ attr = (ILAttribute *)(item->attrsOrLink);
+ }
+ else
+ {
+ attr = ((ILProgramItemLink
*)(item->attrsOrLink))->customAttrs;
+ }
+ }
+ return attr;
}
Index: meta_build.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/meta_build.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** meta_build.c 6 May 2003 09:53:21 -0000 1.25
--- meta_build.c 13 Jun 2003 04:33:27 -0000 1.26
***************
*** 1951,1954 ****
--- 1951,2071 ----
/*
+ * Search the raw values in an owned item table for a token match.
+ * Returns the first token that matches in the "ownedType" table
+ * in "firstMatch". The number of tokens that match is returned
+ * from the function, or zero if there are no matches.
+ */
+ typedef int (*SearchRawFunc)(ILUInt32 *values, ILToken searchFor);
+ static ILUInt32 SearchForRawToken(ILImage *image, SearchRawFunc func,
+ ILToken
ownedType, ILToken *firstMatch,
+ ILToken
searchFor)
+ {
+ ILUInt32 values[IL_IMAGE_TOKEN_COLUMNS];
+ ILToken minToken, maxToken, current;
+ ILUInt32 count;
+ int cmp;
+
+ /* Determine how to perform the search: binary or linear */
+ minToken = (ownedType | 1);
+ maxToken = (ownedType | image->tokenCount[ownedType >> 24]);
+ if((image->sorted & (1 << (int)(ownedType >> 24))) != 0)
+ {
+ /* Perform a binary search for the item */
+ while(minToken <= maxToken)
+ {
+ current = minToken + ((maxToken - minToken) / 2);
+ if(!_ILImageRawTokenData(image, current, values))
+ {
+ return 0;
+ }
+ cmp = (*func)(values, searchFor);
+ if(cmp == 0)
+ {
+ /* We have found a match: search backwards to
find the
+ start of the range */
+ minToken = (ownedType | 1);
+ maxToken = (ownedType |
image->tokenCount[ownedType >> 24]);
+ while(current > minToken)
+ {
+ if(!_ILImageRawTokenData(image, current
- 1, values))
+ {
+ return 0;
+ }
+ if((*func)(values, searchFor) != 0)
+ {
+ break;
+ }
+ --current;
+ }
+
+ /* This is the first match in the table.
Determine
+ how large the range of items is */
+ *firstMatch = current;
+ count = 1;
+ ++current;
+ while(current <= maxToken)
+ {
+ if(!_ILImageRawTokenData(image,
current, values))
+ {
+ return 0;
+ }
+ if((*func)(values, searchFor) != 0)
+ {
+ break;
+ }
+ ++current;
+ ++count;
+ }
+ return count;
+ }
+ else if(cmp < 0)
+ {
+ maxToken = current - 1;
+ }
+ else
+ {
+ minToken = current + 1;
+ }
+ }
+ }
+ else
+ {
+ /* Perform a linear search for the item */
+ for(current = minToken; current <= maxToken; ++current)
+ {
+ if(!_ILImageRawTokenData(image, current, values))
+ {
+ return 0;
+ }
+ if((*func)(values, searchFor) == 0)
+ {
+ /* This is the first match in the table.
Determine
+ how large the range of items is */
+ *firstMatch = current;
+ count = 1;
+ ++current;
+ while(current <= maxToken)
+ {
+ if(!_ILImageRawTokenData(image,
current, values))
+ {
+ return 0;
+ }
+ if((*func)(values, searchFor) != 0)
+ {
+ break;
+ }
+ ++current;
+ ++count;
+ }
+ return count;
+ }
+ }
+ }
+
+ /* If we get here, then we were unable to find a match */
+ return 0;
+ }
+
+ /*
* Load a custom attribute token.
*/
***************
*** 1998,2001 ****
--- 2115,2227 ----
/*
+ * Search for a custom attribute declaration in a raw token table.
+ */
+ static int Search_CustomAttr(ILUInt32 *values, ILToken token1)
+ {
+ ILToken token2 = (ILToken)(values[IL_OFFSET_CUSTOMATTR_OWNER]);
+ ILToken tokenNum1 = (token1 & ~IL_META_TOKEN_MASK);
+ ILToken tokenNum2 = (token2 & ~IL_META_TOKEN_MASK);
+ int type1, type2;
+
+ /* Compare the bottom parts of the token first, because
+ the table must be sorted on its encoded value, not
+ on the original value. Encoded values put the token
+ type in the low order bits */
+ if(tokenNum1 < tokenNum2)
+ {
+ return -1;
+ }
+ else if(tokenNum1 > tokenNum2)
+ {
+ return 1;
+ }
+
+ /* Convert the token types into encoded type values */
+ switch(token1 & IL_META_TOKEN_MASK)
+ {
+ case IL_META_TOKEN_METHOD_DEF: type1 =
0; break;
+ case IL_META_TOKEN_FIELD_DEF: type1 =
1; break;
+ case IL_META_TOKEN_TYPE_REF: type1 =
2; break;
+ case IL_META_TOKEN_TYPE_DEF: type1 =
3; break;
+ case IL_META_TOKEN_PARAM_DEF: type1 =
4; break;
+ case IL_META_TOKEN_INTERFACE_IMPL: type1 =
5; break;
+ case IL_META_TOKEN_MEMBER_REF: type1 =
6; break;
+ case IL_META_TOKEN_MODULE:
type1 = 7; break;
+ case IL_META_TOKEN_DECL_SECURITY: type1 =
8; break;
+ case IL_META_TOKEN_PROPERTY: type1 =
9; break;
+ case IL_META_TOKEN_EVENT:
type1 = 10; break;
+ case IL_META_TOKEN_STAND_ALONE_SIG: type1 =
11; break;
+ case IL_META_TOKEN_MODULE_REF: type1 =
12; break;
+ case IL_META_TOKEN_TYPE_SPEC: type1 =
13; break;
+ case IL_META_TOKEN_ASSEMBLY: type1 =
14; break;
+ case IL_META_TOKEN_ASSEMBLY_REF: type1 =
15; break;
+ case IL_META_TOKEN_FILE:
type1 = 16; break;
+ case IL_META_TOKEN_EXPORTED_TYPE: type1 =
17; break;
+ case IL_META_TOKEN_MANIFEST_RESOURCE: type1 = 18;
break;
+ default:
type1 = 19; break;
+ }
+ switch(token2 & IL_META_TOKEN_MASK)
+ {
+ case IL_META_TOKEN_METHOD_DEF: type2 =
0; break;
+ case IL_META_TOKEN_FIELD_DEF: type2 =
1; break;
+ case IL_META_TOKEN_TYPE_REF: type2 =
2; break;
+ case IL_META_TOKEN_TYPE_DEF: type2 =
3; break;
+ case IL_META_TOKEN_PARAM_DEF: type2 =
4; break;
+ case IL_META_TOKEN_INTERFACE_IMPL: type2 =
5; break;
+ case IL_META_TOKEN_MEMBER_REF: type2 =
6; break;
+ case IL_META_TOKEN_MODULE:
type2 = 7; break;
+ case IL_META_TOKEN_DECL_SECURITY: type2 =
8; break;
+ case IL_META_TOKEN_PROPERTY: type2 =
9; break;
+ case IL_META_TOKEN_EVENT:
type2 = 10; break;
+ case IL_META_TOKEN_STAND_ALONE_SIG: type2 =
11; break;
+ case IL_META_TOKEN_MODULE_REF: type2 =
12; break;
+ case IL_META_TOKEN_TYPE_SPEC: type2 =
13; break;
+ case IL_META_TOKEN_ASSEMBLY: type2 =
14; break;
+ case IL_META_TOKEN_ASSEMBLY_REF: type2 =
15; break;
+ case IL_META_TOKEN_FILE:
type2 = 16; break;
+ case IL_META_TOKEN_EXPORTED_TYPE: type2 =
17; break;
+ case IL_META_TOKEN_MANIFEST_RESOURCE: type2 = 18;
break;
+ default:
type2 = 19; break;
+ }
+
+ /* Compare the encoded token types */
+ if(type1 < type2)
+ {
+ return -1;
+ }
+ else if(type1 > type2)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ void _ILProgramItemLoadAttributes(ILProgramItem *item)
+ {
+ ILToken token;
+ ILUInt32 numTokens;
+ ILUInt32 values[IL_IMAGE_TOKEN_COLUMNS];
+
+ /* Find the custom attribute information for this token */
+ numTokens = SearchForRawToken(item->image, Search_CustomAttr,
+
IL_META_TOKEN_CUSTOM_ATTRIBUTE,
+ &token,
(ILToken)(item->token));
+
+ /* Load the custom attribute tokens for this item */
+ while(numTokens > 0)
+ {
+ if(_ILImageRawTokenData(item->image, token, values))
+ {
+ Load_CustomAttr(item->image, values, 0, token, 0);
+ }
+ --numTokens;
+ ++token;
+ }
+ }
+
+ /*
* Load a stand alone signature token.
*/
***************
*** 2405,2408 ****
--- 2631,2635 ----
/* Load information about modules, assemblies, and files */
+ #if 0
EXIT_IF_ERROR(LoadTokens(image, IL_META_TOKEN_MODULE,
Load_Module, 0));
***************
*** 2423,2426 ****
--- 2650,2654 ----
EXIT_IF_ERROR(LoadTokens(image, IL_META_TOKEN_FILE,
Load_File, 0));
+ #endif
/* Load the assemblies that this image depends upon */
***************
*** 2484,2490 ****
--- 2712,2720 ----
Load_Override, 0));
+ #if 0
/* Load the custom attributes for all of the above */
EXIT_IF_ERROR(LoadTokens(image, IL_META_TOKEN_CUSTOM_ATTRIBUTE,
Load_CustomAttr, 0));
+ #endif
/* Load generic type parameters */
***************
*** 2528,2534 ****
--- 2758,2766 ----
}
+ #if 0
/* Load security declarations */
EXIT_IF_ERROR(LoadTokens(image, IL_META_TOKEN_DECL_SECURITY,
Load_DeclSecurity, 0));
+ #endif
/* Load exported type declarations */
***************
*** 2545,2549 ****
*/
static TokenLoadFunc const TokenLoadFunctions[] = {
! 0, /* 00 */
0,
0,
--- 2777,2781 ----
*/
static TokenLoadFunc const TokenLoadFunctions[] = {
! Load_Module, /* 00 */
0,
0,
***************
*** 2559,2563 ****
0,
Load_FieldMarshal,
! 0,
Load_ClassLayout,
Load_FieldLayout, /* 10 */
--- 2791,2795 ----
0,
Load_FieldMarshal,
! Load_DeclSecurity,
Load_ClassLayout,
Load_FieldLayout, /* 10 */
***************
*** 2571,2575 ****
0, /* 18 */
0,
! 0,
0,
0,
--- 2803,2807 ----
0, /* 18 */
0,
! Load_ModuleRef,
0,
0,
***************
*** 2577,2587 ****
0,
0,
! 0, /* 20 */
! 0,
! 0,
! 0,
! 0,
! 0,
! 0,
0,
Load_ManifestRes, /* 28 */
--- 2809,2819 ----
0,
0,
! Load_Assembly, /* 20 */
! Load_ProcessorDef,
! Load_OSDef,
! Load_AssemblyRef,
! Load_ProcessorRef,
! Load_OSRef,
! Load_File,
0,
Load_ManifestRes, /* 28 */
Index: program.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/program.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** program.h 6 May 2003 09:53:21 -0000 1.17
--- program.h 13 Jun 2003 04:33:27 -0000 1.18
***************
*** 87,90 ****
--- 87,95 ----
/*
+ * Load the attributes for a program item on demand.
+ */
+ void _ILProgramItemLoadAttributes(ILProgramItem *item);
+
+ /*
* Information about a custom attribute.
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/image item.c,1.6,1.7 meta_build.c,1.25,1.26 program.h,1.17,1.18,
Rhys Weatherley <address@hidden> <=