Home

Awesome

stackalloc for reference types with Roslyn and CoreCLR

This repository contains the prototype used in the post A new stackalloc operator for reference types with CoreCLR and Roslyn

Content

It contains:

How to Build?

Make sure that all submodules are correctly initialized when cloning this repository.

Building CoreCLR

The official instructions are here.

But using this simple steps should work:

Building Roslyn

The official build instructions are here

How to Test?

If you run this command, it will use the version using stackalloc operator:

You should get the following output:

Mode: StackAlloc . To switch to HeapAlloc, simply pass an argument to this exe
[before] GC gen0 collect: 0
[before] GC gen1 collect: 0
[before] GC gen2 collect: 0
Result: -729545010
[after] GC gen0 collect: 0
[after] GC gen1 collect: 0
[after] GC gen2 collect: 0
Elapsed: 418.9245ms

Passing a single parameter will switch to heap mode:

In heap mode:

Mode: HeapAlloc
[before] GC gen0 collect: 0
[before] GC gen1 collect: 0
[before] GC gen2 collect: 0
Result: -729545010
[after] GC gen0 collect: 114
[after] GC gen1 collect: 0
[after] GC gen2 collect: 0
Elapsed: 4984.224ms

License

Same license as CoreCLR and Roslyn.

Author

Alexandre Mutel aka @xoofx