@@ -3157,7 +3157,7 @@ public :
3157
3157
3158
3158
protected:
3159
3159
// --------------------------------------------------------------------------------------
3160
- class MethodDataObject : public MethodData
3160
+ class MethodDataObject final : public MethodData
3161
3161
{
3162
3162
public:
3163
3163
// Static method that returns the amount of memory to allocate for a particular type.
@@ -3237,19 +3237,32 @@ public :
3237
3237
{ LIMITED_METHOD_CONTRACT; return m_pMDImpl; }
3238
3238
};
3239
3239
3240
- //
3241
- // At the end of this object is an array, so you cannot derive from this class.
3242
- //
3243
3240
3244
3241
inline MethodDataObjectEntry *GetEntryData ()
3245
- { LIMITED_METHOD_CONTRACT; return (MethodDataObjectEntry *)( this + 1 ) ; }
3242
+ { LIMITED_METHOD_CONTRACT; return &m_rgEntries[ 0 ] ; }
3246
3243
3247
3244
inline MethodDataObjectEntry *GetEntry (UINT32 i)
3248
3245
{ LIMITED_METHOD_CONTRACT; CONSISTENCY_CHECK (i < GetNumMethods ()); return GetEntryData () + i; }
3249
3246
3250
3247
void FillEntryDataForAncestor (MethodTable *pMT);
3251
3248
3252
- // MethodDataObjectEntry m_rgEntries[...];
3249
+ //
3250
+ // At the end of this object is an array
3251
+ //
3252
+ MethodDataObjectEntry m_rgEntries[0 ];
3253
+
3254
+ public:
3255
+ struct TargetMethodTable
3256
+ {
3257
+ MethodTable* pMT;
3258
+ };
3259
+
3260
+ static void * operator new (size_t size, TargetMethodTable targetMT)
3261
+ {
3262
+ _ASSERTE (size <= GetObjectSize (targetMT.pMT ));
3263
+ return ::operator new (GetObjectSize (targetMT.pMT ));
3264
+ }
3265
+ static void * operator new (size_t size) = delete ;
3253
3266
}; // class MethodDataObject
3254
3267
3255
3268
// --------------------------------------------------------------------------------------
@@ -3303,7 +3316,7 @@ public :
3303
3316
}; // class MethodDataInterface
3304
3317
3305
3318
// --------------------------------------------------------------------------------------
3306
- class MethodDataInterfaceImpl : public MethodData
3319
+ class MethodDataInterfaceImpl final : public MethodData
3307
3320
{
3308
3321
public:
3309
3322
// Object construction-related methods
@@ -3377,12 +3390,25 @@ public :
3377
3390
//
3378
3391
3379
3392
inline MethodDataEntry *GetEntryData ()
3380
- { LIMITED_METHOD_CONTRACT; return (MethodDataEntry *)( this + 1 ) ; }
3393
+ { LIMITED_METHOD_CONTRACT; return &m_rgEntries[ 0 ] ; }
3381
3394
3382
3395
inline MethodDataEntry *GetEntry (UINT32 i)
3383
3396
{ LIMITED_METHOD_CONTRACT; CONSISTENCY_CHECK (i < GetNumMethods ()); return GetEntryData () + i; }
3384
3397
3385
- // MethodDataEntry m_rgEntries[...];
3398
+ MethodDataEntry m_rgEntries[0 ];
3399
+
3400
+ public:
3401
+ struct TargetMethodTable
3402
+ {
3403
+ MethodTable* pMT;
3404
+ };
3405
+
3406
+ static void * operator new (size_t size, TargetMethodTable targetMT)
3407
+ {
3408
+ _ASSERTE (size <= GetObjectSize (targetMT.pMT ));
3409
+ return ::operator new (GetObjectSize (targetMT.pMT ));
3410
+ }
3411
+ static void * operator new (size_t size) = delete ;
3386
3412
}; // class MethodDataInterfaceImpl
3387
3413
3388
3414
// --------------------------------------------------------------------------------------
0 commit comments