Skip to content

Convert throw and thread helpers to UCO#126582

Merged
jkotas merged 15 commits intodotnet:mainfrom
am11:feature/MDCS-to-UCOA-pattern2
Apr 10, 2026
Merged

Convert throw and thread helpers to UCO#126582
jkotas merged 15 commits intodotnet:mainfrom
am11:feature/MDCS-to-UCOA-pattern2

Conversation

@am11
Copy link
Copy Markdown
Member

@am11 am11 commented Apr 6, 2026

Contributes to prio3 from #123864

@am11 am11 requested a review from MichalStrehovsky as a code owner April 6, 2026 17:39
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 6, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

@am11 am11 changed the title Convert throw and thread helpers and to UCO Convert throw and thread helpers to UCO Apr 6, 2026
@am11 am11 force-pushed the feature/MDCS-to-UCOA-pattern2 branch from 227f207 to df453ad Compare April 6, 2026 17:50
@am11
Copy link
Copy Markdown
Member Author

am11 commented Apr 6, 2026

@EgorBot -osx_arm64

using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

BenchmarkSwitcher
    .FromAssembly(typeof(ExceptionBench).Assembly)
    .Run(args);

[MemoryDiagnoser]
[SimpleJob(warmupCount: 3, iterationCount: 10)]
public class ExceptionBench
{
    private static volatile int _sink;

    [Benchmark]
    public void ThrowCatch()
    {
        try
        {
            Thrower();
        }
        catch (InvalidOperationException ex)
        {
            _sink = ex.HResult;
        }
    }

    private static void Thrower()
    {
        throw new InvalidOperationException("boom");
    }

    [Benchmark]
    public void NullRefThrow()
    {
        try
        {
            object o = null!;
            _ = o.ToString(); // NullRef
        }
        catch
        {
        }
    }

    [Benchmark]
    public void Rethrow()
    {
        try
        {
            try
            {
                Thrower();
            }
            catch
            {
                throw;
            }
        }
        catch
        {
        }
    }
}

@am11 am11 force-pushed the feature/MDCS-to-UCOA-pattern2 branch from 2d3d910 to ff25723 Compare April 7, 2026 16:21
@jkotas jkotas merged commit 1555020 into dotnet:main Apr 10, 2026
124 of 128 checks passed
@jkotas
Copy link
Copy Markdown
Member

jkotas commented Apr 10, 2026

Thank you!

@am11 am11 deleted the feature/MDCS-to-UCOA-pattern2 branch April 10, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-VM-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants