コード例 #1
0
        static bool FromColdCode()
        {
            int  yield   = -1;
            bool result1 = false;
            bool result2 = false;

            try
            {
                // This pinvoke should not be inline (cold)
                yield = PInvokeExampleNative.GetConstant();
                throw new Exception("expected");
            }
            catch (Exception)
            {
                // These two pinvokes should not be inline (catch)
                //
                // For the first call the jit won't inline the
                // wrapper, so it just calls GetConstant().
                //
                // For the second call, the force inline works, and
                // the subsequent inline of GetConstant() exposes
                // a call to the pinvoke GetConstantInternal().  This
                // pinvoke will not be inline.
                result1 = (yield == PInvokeExampleNative.GetConstant());
                result2 = (yield == AsForceInline());
            }

            return(result1 && result2);
        }
コード例 #2
0
        static bool FromNoInline()
        {
            // The only pinvoke should be inline
            bool result = (PInvokeExampleNative.GetConstant() == AsNoInline());

            return(result);
        }
コード例 #3
0
        static bool FromInline()
        {
            // These two pinvokes should be inline
            bool result = (PInvokeExampleNative.GetConstant() == AsForceInline());

            return(result);
        }
コード例 #4
0
        static bool FromTryFinally3()
        {
            bool result  = false;
            bool result1 = false;
            bool result2 = false;

            try
            {
                // These two pinvokes should be inline, except on x64
                result1 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
            }
            finally
            {
                try
                {
                    // These two pinvokes should *not* be inline (finally)
                    result2 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
                }
                catch (Exception)
                {
                    result2 = false;
                }

                result = result1 && result2;
            }

            return(result);
        }
コード例 #5
0
        static bool FromNoInline2()
        {
            // Three pinvokes should be inline
            bool result1 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
            bool result2 = (PInvokeExampleNative.GetConstant() == AsNoInline());

            return(result1 && result2);
        }
コード例 #6
0
        static bool FromTryCatch()
        {
            bool result = false;

            try
            {
                // All pinvokes should be inline, except on x64
                result = (PInvokeExampleNative.GetConstant() == AsNormalInline());
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }
コード例 #7
0
        static bool FromTryFinally()
        {
            bool result  = false;
            bool result1 = false;
            bool result2 = false;

            try
            {
                // All pinvokes should be inline, except on x64
                result1 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
                result2 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
            }
            finally
            {
                result = result1 && result2;
            }
            return(result);
        }
コード例 #8
0
        static bool FromFilter()
        {
            bool result = false;

            try
            {
                throw new Exception("expected");
            }
            // These two pinvokes should *not* be inline (filter)
            //
            // For the first call the jit won't inline the wrapper, so
            // it just calls GetConstant().
            //
            // For the second call, the force inline works, and the
            // subsequent inline of GetConstant() exposes a call
            // to the pinvoke GetConstantInternal().  This pinvoke will
            // not be inline.
            catch (Exception) when(PInvokeExampleNative.GetConstant() == AsForceInline())
            {
                result = true;
            }

            return(result);
        }
コード例 #9
0
 static int AsNoInline()
 {
     return(PInvokeExampleNative.GetConstant());
 }