Posts Tagged il2cpp

How Async and Await Work

Tags: , , , ,

Last week’s article tested the performance of the async and await keywords plus the C# Task system against Unity’s new C# jobs system. This week we’ll go in depth with async and await to learn how they work, how they relate to the Task system, and how we can customize them for our own uses.

Read the rest of this article »

1 Comment

IL2CPP Output for Iterators, Switch, and Using

Tags: , , ,

Today we’ll look at the C++ code that IL2CPP outputs when we use iterator functions (those that yield), switch statements, and using blocks. What are you really telling the computer to do when you use these C# features? Read on to find out.

(Website Announcement: check out the new tags page to find articles by topic)

Read the rest of this article »

No Comments

How NativeArray Works

Tags: ,

NativeArray<T> is a new type introduced recently in Unity 2018.1. It’s like List<T> except it’s backed by an unmanaged array instead of a managed array. It’s also a struct instead of a class. This means it creates no garbage for the GC to later collect. That’s the surface level description, but today we’ll go in depth to find out how it really works and learn some interesting facts along the way.

Read the rest of this article »

No Comments

C# 6 in IL2CPP

Tags: , , ,

Unity 2018.1 was released last week and with it comes support for C# 6. Today we’ll take a look at the C++ that IL2CPP generates when we use the new features in C# 6. Warning: one of them is buggy and shouldn’t be used.

Read the rest of this article »

No Comments

How IL2CPP implements lock, volatile, [ThreadStatic], and Interlocked

Tags: , , , ,

Writing multi-threaded code is one of the keys to maximizing performance. Currently, this means creating your own threads and synchronizing them with C# keywords like lock and volatile as well as .NET classes like [ThreadStatic] and Interlocked. Today we’ll take a look at how these are implemented behind the scenes by IL2CPP to get some understanding of what we’re really telling the computer to do when we use them.

Read the rest of this article »

No Comments

IL2CPP Output: readonly, sizeof, IntPtr, typeof, GetType

Tags: , , , , , ,

Today’s article looks at the IL2CPP and C++ compiler output for a variety of C# language features. Do you want to know what happens when you use them? Read on to find out!

Read the rest of this article »

No Comments

Common Functions That IL2CPP Slows Down

Tags: , , ,

IL2CPP can really slow our code down sometimes, and not just for esoteric features. Calling common math and string functions can be dramatically slower in IL2CPP. Today’s article shows you how you can work around this to speed them back up.

Read the rest of this article »

1 Comment

How to See What C# Turns Into

Tags: ,

I’ve been writing a lot recently about the C++ and assembly that C# code turns into when it’s run through IL2CPP and a C++ compiler. Today’s article shows you the steps so that you can see what your own game’s C# code turns into.

Read the rest of this article »

No Comments

Loops in IL2CPP

Tags: , , , , , , ,

There are many permutations of loops we can write, but what do they compile to? We should know the consequences of using an array versus a List<T>, for versus foreach, caching Length, and other factors. So today’s article dives into the C++ code that IL2CPP outputs when we write these various types of loops to examine the differences. We’ll even go further and look at the ARM assembly that the C++ compiles to and really find out how much overhead our choices are costing us.

Read the rest of this article »

2 Comments

IL2CPP Output: Abstract Classes, Sealed Classes, and Delegates

Tags: , , , ,

This week we continue to look at the C++ that IL2CPP outputs for C# to get a better understanding of what our C# is really doing. Today we’ll look at how abstract methods work, whether casting of sealed classes is faster than non-sealed classes, and what happens when creating a delegate.

Read the rest of this article »

No Comments