Exemplo n.º 1
0
        public static void RegisterTailCallThunk(IntPtr thunk)
        {
            NativePrimitiveEncoder encoder = new NativePrimitiveEncoder();

            if (!s_tailCallThunkSizeRegistered)
            {
                lock (Instance)
                {
                    if (!s_tailCallThunkSizeRegistered)
                    {
                        // Write out the size of thunks used by the calling convention converter
                        // Make sure that this is called only once
                        encoder.Init();
                        SerializeDataBlobTypeAndFlags(ref encoder,
                                                      SerializedDataBlobKind.StepThroughStubSize,
                                                      (byte)StepThroughStubFlags.IsTailCallStub);
                        encoder.WriteUnsigned((uint)RuntimeAugments.GetThunkSize());
                        Instance.ThreadSafeWriteBytes(encoder.GetBytes());
                        s_tailCallThunkSizeRegistered = true;
                    }
                }
            }

            encoder.Init();
            SerializeDataBlobTypeAndFlags(ref encoder,
                                          SerializedDataBlobKind.StepThroughStubAddress,
                                          (byte)StepThroughStubFlags.IsTailCallStub);
            encoder.WriteUnsignedLong((ulong)thunk.ToInt64());
            Instance.ThreadSafeWriteBytes(encoder.GetBytes());
        }