@@ -2170,17 +2170,21 @@ void Compiler::lvaDecRefCnts(GenTreePtr tree)
2170
2170
2171
2171
if ((tree->gtOper == GT_CALL) && (tree->gtFlags & GTF_CALL_UNMANAGED))
2172
2172
{
2173
- /* Get the special variable descriptor */
2173
+ assert ((!opts.ShouldUsePInvokeHelpers ()) || (info.compLvFrameListRoot == BAD_VAR_NUM));
2174
+ if (!opts.ShouldUsePInvokeHelpers ())
2175
+ {
2176
+ /* Get the special variable descriptor */
2174
2177
2175
- lclNum = info.compLvFrameListRoot ;
2176
-
2177
- noway_assert (lclNum <= lvaCount);
2178
- varDsc = lvaTable + lclNum;
2179
-
2180
- /* Decrement the reference counts twice */
2178
+ lclNum = info.compLvFrameListRoot ;
2181
2179
2182
- varDsc->decRefCnts (compCurBB->getBBWeight (this ), this );
2183
- varDsc->decRefCnts (compCurBB->getBBWeight (this ), this );
2180
+ noway_assert (lclNum <= lvaCount);
2181
+ varDsc = lvaTable + lclNum;
2182
+
2183
+ /* Decrement the reference counts twice */
2184
+
2185
+ varDsc->decRefCnts (compCurBB->getBBWeight (this ), this );
2186
+ varDsc->decRefCnts (compCurBB->getBBWeight (this ), this );
2187
+ }
2184
2188
}
2185
2189
else
2186
2190
{
@@ -2225,17 +2229,21 @@ void Compiler::lvaIncRefCnts(GenTreePtr tree)
2225
2229
2226
2230
if ((tree->gtOper == GT_CALL) && (tree->gtFlags & GTF_CALL_UNMANAGED))
2227
2231
{
2228
- /* Get the special variable descriptor */
2232
+ assert ((!opts.ShouldUsePInvokeHelpers ()) || (info.compLvFrameListRoot == BAD_VAR_NUM));
2233
+ if (!opts.ShouldUsePInvokeHelpers ())
2234
+ {
2235
+ /* Get the special variable descriptor */
2229
2236
2230
- lclNum = info.compLvFrameListRoot ;
2231
-
2232
- noway_assert (lclNum <= lvaCount);
2233
- varDsc = lvaTable + lclNum;
2234
-
2235
- /* Increment the reference counts twice */
2237
+ lclNum = info.compLvFrameListRoot ;
2236
2238
2237
- varDsc->incRefCnts (compCurBB->getBBWeight (this ), this );
2238
- varDsc->incRefCnts (compCurBB->getBBWeight (this ), this );
2239
+ noway_assert (lclNum <= lvaCount);
2240
+ varDsc = lvaTable + lclNum;
2241
+
2242
+ /* Increment the reference counts twice */
2243
+
2244
+ varDsc->incRefCnts (compCurBB->getBBWeight (this ), this );
2245
+ varDsc->incRefCnts (compCurBB->getBBWeight (this ), this );
2246
+ }
2239
2247
}
2240
2248
else
2241
2249
{
@@ -2811,16 +2819,20 @@ void Compiler::lvaMarkLclRefs(GenTreePtr tree)
2811
2819
/* Is this a call to unmanaged code ? */
2812
2820
if (tree->gtOper == GT_CALL && tree->gtFlags & GTF_CALL_UNMANAGED)
2813
2821
{
2814
- /* Get the special variable descriptor */
2822
+ assert ((!opts.ShouldUsePInvokeHelpers ()) || (info.compLvFrameListRoot == BAD_VAR_NUM));
2823
+ if (!opts.ShouldUsePInvokeHelpers ())
2824
+ {
2825
+ /* Get the special variable descriptor */
2815
2826
2816
- unsigned lclNum = info.compLvFrameListRoot ;
2817
-
2818
- noway_assert (lclNum <= lvaCount);
2819
- LclVarDsc * varDsc = lvaTable + lclNum;
2827
+ unsigned lclNum = info.compLvFrameListRoot ;
2828
+
2829
+ noway_assert (lclNum <= lvaCount);
2830
+ LclVarDsc * varDsc = lvaTable + lclNum;
2820
2831
2821
- /* Increment the ref counts twice */
2822
- varDsc->incRefCnts (lvaMarkRefsWeight, this );
2823
- varDsc->incRefCnts (lvaMarkRefsWeight, this );
2832
+ /* Increment the ref counts twice */
2833
+ varDsc->incRefCnts (lvaMarkRefsWeight, this );
2834
+ varDsc->incRefCnts (lvaMarkRefsWeight, this );
2835
+ }
2824
2836
}
2825
2837
#endif
2826
2838
@@ -3177,15 +3189,19 @@ void Compiler::lvaMarkLocalVars()
3177
3189
3178
3190
if (info.compCallUnmanaged != 0 )
3179
3191
{
3180
- noway_assert (info.compLvFrameListRoot >= info.compLocalsCount &&
3181
- info.compLvFrameListRoot < lvaCount);
3192
+ assert ((!opts.ShouldUsePInvokeHelpers ()) || (info.compLvFrameListRoot == BAD_VAR_NUM));
3193
+ if (!opts.ShouldUsePInvokeHelpers ())
3194
+ {
3195
+ noway_assert (info.compLvFrameListRoot >= info.compLocalsCount &&
3196
+ info.compLvFrameListRoot < lvaCount);
3182
3197
3183
- lvaTable[info.compLvFrameListRoot ].lvType = TYP_I_IMPL;
3198
+ lvaTable[info.compLvFrameListRoot ].lvType = TYP_I_IMPL;
3184
3199
3185
- /* Set the refCnt, it is used in the prolog and return block(s) */
3200
+ /* Set the refCnt, it is used in the prolog and return block(s) */
3186
3201
3187
- lvaTable[info.compLvFrameListRoot ].lvRefCnt = 2 ;
3188
- lvaTable[info.compLvFrameListRoot ].lvRefCntWtd = 2 * BB_UNITY_WEIGHT;
3202
+ lvaTable[info.compLvFrameListRoot ].lvRefCnt = 2 ;
3203
+ lvaTable[info.compLvFrameListRoot ].lvRefCntWtd = 2 * BB_UNITY_WEIGHT;
3204
+ }
3189
3205
}
3190
3206
#endif
3191
3207
0 commit comments