@@ -33,6 +33,7 @@ public unsafe class MethodTableTests
33
33
{ nameof ( Data . EEClass . MethodTable ) , new ( ) { Offset = 8 , Type = DataType . pointer } } ,
34
34
{ nameof ( Data . EEClass . CorTypeAttr ) , new ( ) { Offset = 16 , Type = DataType . uint32 } } ,
35
35
{ nameof ( Data . EEClass . NumMethods ) , new ( ) { Offset = 20 , Type = DataType . uint16 } } ,
36
+ { nameof ( Data . EEClass . NumNonVirtualSlots ) , new ( ) { Offset = 22 , Type = DataType . uint16 } } ,
36
37
}
37
38
} ;
38
39
@@ -46,6 +47,7 @@ private static readonly (DataType Type, Target.TypeInfo Info)[] RTSTypes =
46
47
private static readonly ( string Name , ulong Value , string ? Type ) [ ] RTSGlobals =
47
48
[
48
49
( nameof ( Constants . Globals . FreeObjectMethodTable ) , TestFreeObjectMethodTableGlobalAddress , null ) ,
50
+ ( nameof ( Constants . Globals . MethodDescAlignment ) , 8 , nameof ( DataType . uint64 ) ) ,
49
51
] ;
50
52
51
53
private static MockMemorySpace . Builder AddFreeObjectMethodTable ( TargetTestHelpers targetTestHelpers , MockMemorySpace . Builder builder )
@@ -58,13 +60,14 @@ private static MockMemorySpace.Builder AddFreeObjectMethodTable(TargetTestHelper
58
60
] ) ;
59
61
}
60
62
61
- private static MockMemorySpace . Builder AddEEClass ( TargetTestHelpers targetTestHelpers , MockMemorySpace . Builder builder , TargetPointer eeClassPtr , string name , TargetPointer canonMTPtr , uint attr , ushort numMethods )
63
+ private static MockMemorySpace . Builder AddEEClass ( TargetTestHelpers targetTestHelpers , MockMemorySpace . Builder builder , TargetPointer eeClassPtr , string name , TargetPointer canonMTPtr , uint attr , ushort numMethods , ushort numNonVirtualSlots )
62
64
{
63
65
MockMemorySpace . HeapFragment eeClassFragment = new ( ) { Name = $ "EEClass '{ name } '", Address = eeClassPtr , Data = new byte [ targetTestHelpers . SizeOfTypeInfo ( EEClassTypeInfo ) ] } ;
64
66
Span < byte > dest = eeClassFragment . Data ;
65
67
targetTestHelpers . WritePointer ( dest . Slice ( EEClassTypeInfo . Fields [ nameof ( Data . EEClass . MethodTable ) ] . Offset ) , canonMTPtr ) ;
66
68
targetTestHelpers . Write ( dest . Slice ( EEClassTypeInfo . Fields [ nameof ( Data . EEClass . CorTypeAttr ) ] . Offset ) , attr ) ;
67
69
targetTestHelpers . Write ( dest . Slice ( EEClassTypeInfo . Fields [ nameof ( Data . EEClass . NumMethods ) ] . Offset ) , numMethods ) ;
70
+ targetTestHelpers . Write ( dest . Slice ( EEClassTypeInfo . Fields [ nameof ( Data . EEClass . NumNonVirtualSlots ) ] . Offset ) , numNonVirtualSlots ) ;
68
71
return builder . AddHeapFragment ( eeClassFragment ) ;
69
72
70
73
}
@@ -161,7 +164,7 @@ private static MockMemorySpace.Builder AddSystemObject(TargetTestHelpers targetT
161
164
System . Reflection . TypeAttributes typeAttributes = System . Reflection . TypeAttributes . Public | System . Reflection . TypeAttributes . Class ;
162
165
const int numMethods = 8 ; // System.Object has 8 methods
163
166
const int numVirtuals = 3 ; // System.Object has 3 virtual methods
164
- builder = AddEEClass ( targetTestHelpers , builder , systemObjectEEClassPtr , "System.Object" , systemObjectMethodTablePtr , attr : ( uint ) typeAttributes , numMethods : numMethods ) ;
167
+ builder = AddEEClass ( targetTestHelpers , builder , systemObjectEEClassPtr , "System.Object" , systemObjectMethodTablePtr , attr : ( uint ) typeAttributes , numMethods : numMethods , numNonVirtualSlots : 0 ) ;
165
168
builder = AddMethodTable ( targetTestHelpers , builder , systemObjectMethodTablePtr , "System.Object" , systemObjectEEClassPtr ,
166
169
mtflags : default , mtflags2 : default , baseSize : targetTestHelpers . ObjectBaseSize ,
167
170
module : TargetPointer . Null , parentMethodTable : TargetPointer . Null , numInterfaces : 0 , numVirtuals : numVirtuals ) ;
@@ -216,7 +219,7 @@ public void ValidateSystemStringMethodTable(MockTarget.Architecture arch)
216
219
const int numInterfaces = 8 ; // Arbitrary
217
220
const int numVirtuals = 3 ; // at least as many as System.Object
218
221
uint mtflags = ( uint ) RuntimeTypeSystem_1 . WFLAGS_HIGH . HasComponentSize | /*componentSize: */ 2 ;
219
- builder = AddEEClass ( targetTestHelpers , builder , systemStringEEClassPtr , "System.String" , systemStringMethodTablePtr , attr : ( uint ) typeAttributes , numMethods : numMethods ) ;
222
+ builder = AddEEClass ( targetTestHelpers , builder , systemStringEEClassPtr , "System.String" , systemStringMethodTablePtr , attr : ( uint ) typeAttributes , numMethods : numMethods , numNonVirtualSlots : 0 ) ;
220
223
builder = AddMethodTable ( targetTestHelpers , builder , systemStringMethodTablePtr , "System.String" , systemStringEEClassPtr ,
221
224
mtflags : mtflags , mtflags2 : default , baseSize : targetTestHelpers . StringBaseSize ,
222
225
module : TargetPointer . Null , parentMethodTable : systemObjectMethodTablePtr , numInterfaces : numInterfaces , numVirtuals : numVirtuals ) ;
@@ -291,7 +294,7 @@ public void ValidateGenericInstMethodTable(MockTarget.Architecture arch)
291
294
const int numInterfaces = 0 ;
292
295
const int numVirtuals = 3 ;
293
296
const uint gtd_mtflags = 0x00000030 ; // TODO: GenericsMask_TypicalInst
294
- builder = AddEEClass ( targetTestHelpers , builder , genericDefinitionEEClassPtr , "EEClass GenericDefinition" , genericDefinitionMethodTablePtr , attr : ( uint ) typeAttributes , numMethods : numMethods ) ;
297
+ builder = AddEEClass ( targetTestHelpers , builder , genericDefinitionEEClassPtr , "EEClass GenericDefinition" , genericDefinitionMethodTablePtr , attr : ( uint ) typeAttributes , numMethods : numMethods , numNonVirtualSlots : 0 ) ;
295
298
builder = AddMethodTable ( targetTestHelpers , builder , genericDefinitionMethodTablePtr , "MethodTable GenericDefinition" , genericDefinitionEEClassPtr ,
296
299
mtflags : gtd_mtflags , mtflags2 : default , baseSize : targetTestHelpers . ObjectBaseSize ,
297
300
module : TargetPointer . Null , parentMethodTable : systemObjectMethodTablePtr , numInterfaces : numInterfaces , numVirtuals : numVirtuals ) ;
@@ -346,15 +349,15 @@ public void ValidateArrayInstMethodTable(MockTarget.Architecture arch)
346
349
const ushort systemArrayNumMethods = 37 ; // Arbitrary. Not trying to exactly match the real System.Array
347
350
const uint systemArrayCorTypeAttr = ( uint ) ( System . Reflection . TypeAttributes . Public | System . Reflection . TypeAttributes . Class ) ;
348
351
349
- builder = AddEEClass ( targetTestHelpers , builder , systemArrayEEClassPtr , "EEClass System.Array" , systemArrayMethodTablePtr , attr : systemArrayCorTypeAttr , numMethods : systemArrayNumMethods ) ;
352
+ builder = AddEEClass ( targetTestHelpers , builder , systemArrayEEClassPtr , "EEClass System.Array" , systemArrayMethodTablePtr , attr : systemArrayCorTypeAttr , numMethods : systemArrayNumMethods , numNonVirtualSlots : 0 ) ;
350
353
builder = AddMethodTable ( targetTestHelpers , builder , systemArrayMethodTablePtr , "MethodTable System.Array" , systemArrayEEClassPtr ,
351
354
mtflags : default , mtflags2 : default , baseSize : targetTestHelpers . ObjectBaseSize ,
352
355
module : TargetPointer . Null , parentMethodTable : systemObjectMethodTablePtr , numInterfaces : systemArrayNumInterfaces , numVirtuals : 3 ) ;
353
356
354
357
const uint arrayInst_mtflags = ( uint ) ( RuntimeTypeSystem_1 . WFLAGS_HIGH . HasComponentSize | RuntimeTypeSystem_1 . WFLAGS_HIGH . Category_Array ) | arrayInstanceComponentSize ;
355
358
const uint arrayInstCorTypeAttr = ( uint ) ( System . Reflection . TypeAttributes . Public | System . Reflection . TypeAttributes . Class | System . Reflection . TypeAttributes . Sealed ) ;
356
359
357
- builder = AddEEClass ( targetTestHelpers , builder , arrayInstanceEEClassPtr , "EEClass ArrayInstance" , arrayInstanceMethodTablePtr , attr : arrayInstCorTypeAttr , numMethods : systemArrayNumMethods ) ;
360
+ builder = AddEEClass ( targetTestHelpers , builder , arrayInstanceEEClassPtr , "EEClass ArrayInstance" , arrayInstanceMethodTablePtr , attr : arrayInstCorTypeAttr , numMethods : systemArrayNumMethods , numNonVirtualSlots : 0 ) ;
358
361
builder = AddMethodTable ( targetTestHelpers , builder , arrayInstanceMethodTablePtr , "MethodTable ArrayInstance" , arrayInstanceEEClassPtr ,
359
362
mtflags : arrayInst_mtflags , mtflags2 : default , baseSize : targetTestHelpers . ObjectBaseSize ,
360
363
module : TargetPointer . Null , parentMethodTable : systemArrayMethodTablePtr , numInterfaces : systemArrayNumInterfaces , numVirtuals : 3 ) ;
0 commit comments