Adventures with Mono Runtime on Mobile Platforms

Adventures with Mono Runtime on Mobile Platforms
.NET Stammtisch Linz
Bernhard Urban
beurba@microsoft.com
https://www.xamarin.com
https://www.mono-project.com
July 23, 2019
foundation
1 / 13
2 / 13
Xamarin
3 / 13
The Mono Runtime — Overview
Execution modes
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
FullAOT
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
FullAOT
Interpreter
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
FullAOT
Interpreter
Supported platforms
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
FullAOT
Interpreter
Supported platforms
Linux, macOS, Windows, *BSD, AIX, IBM i, . . .
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
FullAOT
Interpreter
Supported platforms
Linux, macOS, Windows, *BSD, AIX, IBM i, . . .
iOS, tvOS, watchOS & Android
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
FullAOT
Interpreter
Supported platforms
Linux, macOS, Windows, *BSD, AIX, IBM i, . . .
iOS, tvOS, watchOS & Android
XBox, PlayStation, WiiU, . . .
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
FullAOT
Interpreter
Supported platforms
Linux, macOS, Windows, *BSD, AIX, IBM i, . . .
iOS, tvOS, watchOS & Android
XBox, PlayStation, WiiU, . . .
amd64, x86, armv7, armv8, powerpc, s390x
4 / 13
The Mono Runtime — Overview
Execution modes
Just-In-Time compiler
Ahead-Of-Time compiler
normal AOT
FullAOT
Interpreter
Supported platforms
Linux, macOS, Windows, *BSD, AIX, IBM i, . . .
iOS, tvOS, watchOS & Android
XBox, PlayStation, WiiU, . . .
amd64, x86, armv7, armv8, powerpc, s390x
WebAssembly
4 / 13
Embedding the Mono Runtime
Embedding Mono
link Mono into your application
5 / 13
Embedding the Mono Runtime
Embedding Mono
link Mono into your application
allows execution of .NET, e.g. useful for scripting
5 / 13
Embedding the Mono Runtime
Embedding Mono
link Mono into your application
allows execution of .NET, e.g. useful for scripting
Users
5 / 13
Embedding the Mono Runtime
Embedding Mono
link Mono into your application
allows execution of .NET, e.g. useful for scripting
Users
Game Studios
5 / 13
Embedding the Mono Runtime
Embedding Mono
link Mono into your application
allows execution of .NET, e.g. useful for scripting
Users
Game Studios
Unity
5 / 13
Embedding the Mono Runtime
Embedding Mono
link Mono into your application
allows execution of .NET, e.g. useful for scripting
Users
Game Studios
Unity
Blazor: check out https://learn-blazor.com/
5 / 13
Embedding the Mono Runtime
Embedding Mono
link Mono into your application
allows execution of .NET, e.g. useful for scripting
Users
Game Studios
Unity
Blazor: check out https://learn-blazor.com/
Xamarin.Android & Xamarin.iOS
5 / 13
Platform & Device landscape
iOS on iPhone/iPad.
6 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
6 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
6 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
6 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
x86 64: JIT.
6 / 13
FullAOT
7 / 13
FullAOT
iOS does not allow JIT compilation
7 / 13
FullAOT
iOS does not allow JIT compilation
Normal AOT uses JIT occasionally at runtime
7 / 13
FullAOT
iOS does not allow JIT compilation
Normal AOT uses JIT occasionally at runtime
All trampolines and wrappers must be included in the AOT image
7 / 13
FullAOT
iOS does not allow JIT compilation
Normal AOT uses JIT occasionally at runtime
All trampolines and wrappers must be included in the AOT image
Side-effect: System.Reflection.Emit does not work
7 / 13
What about generics?
8 / 13
What about generics?
public T return_t<T> (T arg) {
return arg;
}
8 / 13
What about generics?
public T return_t<T> (T arg) {
return arg;
}
// "Generic sharing for value types"
public void return_t (T& ret, T& arg, ptr hidden_arg) {
int size = rgctx_fetch (hidden_arg);
memcpy (ret, arg, size);
}
8 / 13
What about generics?
public T return_t<T> (T arg) {
return arg;
}
// "Generic sharing for value types"
public void return_t (T& ret, T& arg, ptr hidden_arg) {
int size = rgctx_fetch (hidden_arg);
memcpy (ret, arg, size);
}
int i = return_t<int> (5);
8 / 13
What about generics?
public T return_t<T> (T arg) {
return arg;
}
// "Generic sharing for value types"
public void return_t (T& ret, T& arg, ptr hidden_arg) {
int size = rgctx_fetch (hidden_arg);
memcpy (ret, arg, size);
}
int i = return_t<int> (5);
// calling chain
caller
⇒ callee
8 / 13
What about generics?
public T return_t<T> (T arg) {
return arg;
}
// "Generic sharing for value types"
public void return_t (T& ret, T& arg, ptr hidden_arg) {
int size = rgctx_fetch (hidden_arg);
memcpy (ret, arg, size);
}
int i = return_t<int> (5);
// calling chain
caller
⇒ gsharedvt_arg_trampoline
⇒ callee
8 / 13
What about generics?
public T return_t<T> (T arg) {
return arg;
}
// "Generic sharing for value types"
public void return_t (T& ret, T& arg, ptr hidden_arg) {
int size = rgctx_fetch (hidden_arg);
memcpy (ret, arg, size);
}
int i = return_t<int> (5);
// calling chain
caller
⇒ gsharedvt_arg_trampoline
⇒ gsharedvt_in_trampoline
⇒ callee
8 / 13
System.Reflection.Emit?
System.ExecutionEngineException:
Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod ()
9 / 13
System.Reflection.Emit?
System.ExecutionEngineException:
Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod ()
9 / 13
System.Reflection.Emit?
System.ExecutionEngineException:
Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod ()
Runtime interpreter enables System.Reflection.Emit
9 / 13
System.Reflection.Emit?
System.ExecutionEngineException:
Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod ()
Runtime interpreter enables System.Reflection.Emit
Faster “inner dev loop”
No need to run the AOT compiler
Smaller app bundle size ⇒ faster deploy
9 / 13
System.Reflection.Emit?
System.ExecutionEngineException:
Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod ()
Runtime interpreter enables System.Reflection.Emit
Faster “inner dev loop”
No need to run the AOT compiler
Smaller app bundle size ⇒ faster deploy
Best of both worlds: “Mixed Mode” with FullAOT
9 / 13
System.Reflection.Emit?
System.ExecutionEngineException:
Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod ()
Runtime interpreter enables System.Reflection.Emit
Faster “inner dev loop”
No need to run the AOT compiler
Smaller app bundle size ⇒ faster deploy
Best of both worlds: “Mixed Mode” with FullAOT
Ships with upcoming release of Xamarin.iOS (Preview available)
9 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
x86 64: JIT.
tvOS on Apple TV.
10 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
x86 64: JIT.
tvOS on Apple TV.
arm64: FullAOT and interpreter.
10 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
x86 64: JIT.
tvOS on Apple TV.
arm64: FullAOT and interpreter.
x86 64: JIT.
10 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
x86 64: JIT.
tvOS on Apple TV.
arm64: FullAOT and interpreter.
x86 64: JIT.
watchOS on Apple Watch.
10 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
x86 64: JIT.
tvOS on Apple TV.
arm64: FullAOT and interpreter.
x86 64: JIT.
watchOS on Apple Watch.
armv7k: FullAOT and bitcode.
10 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
x86 64: JIT.
tvOS on Apple TV.
arm64: FullAOT and interpreter.
x86 64: JIT.
watchOS on Apple Watch.
armv7k: FullAOT and bitcode.
arm64 32: interpreter (WIP) and bitcode.
10 / 13
Platform & Device landscape
iOS on iPhone/iPad.
armv7: FullAOT.
arm64: FullAOT and interpreter.
x86: JIT.
x86 64: JIT.
tvOS on Apple TV.
arm64: FullAOT and interpreter.
x86 64: JIT.
watchOS on Apple Watch.
armv7k: FullAOT and bitcode.
arm64 32: interpreter (WIP) and bitcode.
x86: JIT.
10 / 13
Xamarin.Android
Simliar to Linux, except for interop between C# and Java
Two Garbage collectors have to work together
11 / 13
Xamarin.Android
Simliar to Linux, except for interop between C# and Java
Two Garbage collectors have to work together
War story: Samsung Galaxy S7
11 / 13
Xamarin.Android
Simliar to Linux, except for interop between C# and Java
Two Garbage collectors have to work together
War story: Samsung Galaxy S7
First bug report: “Xamarin.Android apps on the Samsung Galaxy S7
fails to start with the error System.ExecutionEngineException
SIGILL“.
11 / 13
Xamarin.Android
Simliar to Linux, except for interop between C# and Java
Two Garbage collectors have to work together
War story: Samsung Galaxy S7
First bug report: “Xamarin.Android apps on the Samsung Galaxy S7
fails to start with the error System.ExecutionEngineException
SIGILL“.
Co-worker in the US got the device.
11 / 13
Xamarin.Android
Simliar to Linux, except for interop between C# and Java
Two Garbage collectors have to work together
War story: Samsung Galaxy S7
First bug report: “Xamarin.Android apps on the Samsung Galaxy S7
fails to start with the error System.ExecutionEngineException
SIGILL“.
Co-worker in the US got the device. He could not reproduce it.
11 / 13
Xamarin.Android
Simliar to Linux, except for interop between C# and Java
Two Garbage collectors have to work together
War story: Samsung Galaxy S7
First bug report: “Xamarin.Android apps on the Samsung Galaxy S7
fails to start with the error System.ExecutionEngineException
SIGILL“.
Co-worker in the US got the device. He could not reproduce it.
US edition: Ships with Snapdragon 820.
11 / 13
Xamarin.Android
Simliar to Linux, except for interop between C# and Java
Two Garbage collectors have to work together
War story: Samsung Galaxy S7
First bug report: “Xamarin.Android apps on the Samsung Galaxy S7
fails to start with the error System.ExecutionEngineException
SIGILL“.
Co-worker in the US got the device. He could not reproduce it.
US edition: Ships with Snapdragon 820.
World edition: Ships with Exynos 8890.
11 / 13
Xamarin.Android
Simliar to Linux, except for interop between C# and Java
Two Garbage collectors have to work together
War story: Samsung Galaxy S7
First bug report: “Xamarin.Android apps on the Samsung Galaxy S7
fails to start with the error System.ExecutionEngineException
SIGILL“.
Co-worker in the US got the device. He could not reproduce it.
US edition: Ships with Snapdragon 820.
World edition: Ships with Exynos 8890.
Could reproduce it with Xamarin Test Cloud.
11 / 13
War story: Samsung Galaxy S7
$ grep SIGILL *.log
custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0
custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0
custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70
custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0
custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0
custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0
12 / 13
War story: Samsung Galaxy S7
$ grep SIGILL *.log
custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0
custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0
custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70
custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0
custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0
custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0
void __clear_cache (char *address, size_t size) {
static int cache_line_size = 0;
if (!cache_line_size)
cache_line_size = get_current_cpu_cache_line_size ();
for (int i = 0; i < size; i += cache_line_size)
flush_cache_line (address + i);
}
War story: Samsung Galaxy S7
$ grep SIGILL *.log
custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0
custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0
custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70
custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0
custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0
custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0
void __clear_cache (char *address, size_t size) {
static int cache_line_size = 0;
if (!cache_line_size)
cache_line_size = get_current_cpu_cache_line_size ();
for (int i = 0; i < size; i += cache_line_size)
flush_cache_line (address + i);
}
War story: Samsung Galaxy S7
$ grep SIGILL *.log
custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0
custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0
custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70
custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0
custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0
custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0
void __clear_cache (char *address, size_t size) {
static int cache_line_size = 0;
if (!cache_line_size)
cache_line_size = get_current_cpu_cache_line_size ();
for (int i = 0; i < size; i += cache_line_size)
flush_cache_line (address + i);
}
12 / 13
War story: Samsung Galaxy S7
$ grep SIGILL *.log
custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0
custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0
custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70
custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0
custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0
custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0
void __clear_cache (char *address, size_t size) {
static int cache_line_size = 0;
if (!cache_line_size)
cache_line_size = get_current_cpu_cache_line_size ();
for (int i = 0; i < size; i += cache_line_size)
flush_cache_line (address + i);
}
64byte buckets:
0x00-0x3f: always flushed
0x40-0x7f: only flushed when cacheline size is 64 byte.
0x80-0xbf: always flushed
0xc0-0xff: only flushed when cacheline size is 64 byte.
12 / 13
Thanks
Visit us
https://www.mono-project.com
Chat with us
https://gitter.im/mono/mono
Mail me
beurba@microsoft.com
foundation
13 / 13
1 von 66

Recomendados

ChatGPT and the Future of Work - Clark Boyd von
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
28K views69 Folien
Getting into the tech field. what next von
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
6.6K views22 Folien
Google's Just Not That Into You: Understanding Core Updates & Search Intent von
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
6.9K views99 Folien
How to have difficult conversations von
How to have difficult conversations How to have difficult conversations
How to have difficult conversations Rajiv Jayarajah, MAppComm, ACC
5.6K views19 Folien
Introduction to Data Science von
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceChristy Abraham Joy
82.6K views51 Folien
Time Management & Productivity - Best Practices von
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
169.8K views42 Folien

Más contenido relacionado

Último

How to build dyanmic dashboards and ensure they always work von
How to build dyanmic dashboards and ensure they always workHow to build dyanmic dashboards and ensure they always work
How to build dyanmic dashboards and ensure they always workWiiisdom
14 views13 Folien
Introduction to Maven von
Introduction to MavenIntroduction to Maven
Introduction to MavenJohn Valentino
6 views10 Folien
nintendo_64.pptx von
nintendo_64.pptxnintendo_64.pptx
nintendo_64.pptxpaiga02016
6 views7 Folien
predicting-m3-devopsconMunich-2023.pptx von
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptxTier1 app
8 views24 Folien
Quality Assurance von
Quality Assurance Quality Assurance
Quality Assurance interworksoftware2
5 views6 Folien
Streamlining Your Business Operations with Enterprise Application Integration... von
Streamlining Your Business Operations with Enterprise Application Integration...Streamlining Your Business Operations with Enterprise Application Integration...
Streamlining Your Business Operations with Enterprise Application Integration...Flexsin
5 views12 Folien

Último(20)

How to build dyanmic dashboards and ensure they always work von Wiiisdom
How to build dyanmic dashboards and ensure they always workHow to build dyanmic dashboards and ensure they always work
How to build dyanmic dashboards and ensure they always work
Wiiisdom14 views
predicting-m3-devopsconMunich-2023.pptx von Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app8 views
Streamlining Your Business Operations with Enterprise Application Integration... von Flexsin
Streamlining Your Business Operations with Enterprise Application Integration...Streamlining Your Business Operations with Enterprise Application Integration...
Streamlining Your Business Operations with Enterprise Application Integration...
Flexsin 5 views
Transport Management System - Shipment & Container Tracking von Freightoscope
Transport Management System - Shipment & Container TrackingTransport Management System - Shipment & Container Tracking
Transport Management System - Shipment & Container Tracking
Freightoscope 5 views
Understanding HTML terminology von artembondar5
Understanding HTML terminologyUnderstanding HTML terminology
Understanding HTML terminology
artembondar57 views
tecnologia18.docx von nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67025 views
Advanced API Mocking Techniques Using Wiremock von Dimpy Adhikary
Advanced API Mocking Techniques Using WiremockAdvanced API Mocking Techniques Using Wiremock
Advanced API Mocking Techniques Using Wiremock
Dimpy Adhikary5 views
Ports-and-Adapters Architecture for Embedded HMI von Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert33 views
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile... von Stefan Wolpers
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
Stefan Wolpers42 views
Automated Testing of Microsoft Power BI Reports von RTTS
Automated Testing of Microsoft Power BI ReportsAutomated Testing of Microsoft Power BI Reports
Automated Testing of Microsoft Power BI Reports
RTTS10 views
Top-5-production-devconMunich-2023.pptx von Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app9 views
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P... von NimaTorabi2
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
NimaTorabi216 views

Destacado

Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present... von
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
55.5K views138 Folien
12 Ways to Increase Your Influence at Work von
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
401.7K views64 Folien
ChatGPT webinar slides von
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slidesAlireza Esmikhani
30.5K views36 Folien
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G... von
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
3.6K views12 Folien
Barbie - Brand Strategy Presentation von
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
25.1K views46 Folien

Destacado(20)

Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present... von Applitools
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools55.5K views
12 Ways to Increase Your Influence at Work von GetSmarter
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter401.7K views
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G... von DevGAMM Conference
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference3.6K views
Barbie - Brand Strategy Presentation von Erica Santiago
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago25.1K views
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well von Saba Software
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software25.3K views
Introduction to C Programming Language von Simplilearn
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
Simplilearn8.5K views
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr... von Palo Alto Software
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
Palo Alto Software88.4K views
9 Tips for a Work-free Vacation von Weekdone.com
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
Weekdone.com7.2K views
How to Map Your Future von SlideShop.com
How to Map Your FutureHow to Map Your Future
How to Map Your Future
SlideShop.com275.1K views
Beyond Pride: Making Digital Marketing & SEO Authentically LGBTQ+ Inclusive -... von AccuraCast
Beyond Pride: Making Digital Marketing & SEO Authentically LGBTQ+ Inclusive -...Beyond Pride: Making Digital Marketing & SEO Authentically LGBTQ+ Inclusive -...
Beyond Pride: Making Digital Marketing & SEO Authentically LGBTQ+ Inclusive -...
AccuraCast3.4K views
Exploring ChatGPT for Effective Teaching and Learning.pptx von Stan Skrabut, Ed.D.
Exploring ChatGPT for Effective Teaching and Learning.pptxExploring ChatGPT for Effective Teaching and Learning.pptx
Exploring ChatGPT for Effective Teaching and Learning.pptx
Stan Skrabut, Ed.D.57.7K views
How to train your robot (with Deep Reinforcement Learning) von Lucas García, PhD
How to train your robot (with Deep Reinforcement Learning)How to train your robot (with Deep Reinforcement Learning)
How to train your robot (with Deep Reinforcement Learning)
Lucas García, PhD42.5K views
4 Strategies to Renew Your Career Passion von Daniel Goleman
4 Strategies to Renew Your Career Passion4 Strategies to Renew Your Career Passion
4 Strategies to Renew Your Career Passion
Daniel Goleman122K views
The Student's Guide to LinkedIn von LinkedIn
The Student's Guide to LinkedInThe Student's Guide to LinkedIn
The Student's Guide to LinkedIn
LinkedIn88.1K views
Different Roles in Machine Learning Career von Intellipaat
Different Roles in Machine Learning CareerDifferent Roles in Machine Learning Career
Different Roles in Machine Learning Career
Intellipaat12.4K views
Defining a Tech Project Vision in Eight Quick Steps pdf von TechSoup
Defining a Tech Project Vision in Eight Quick Steps pdfDefining a Tech Project Vision in Eight Quick Steps pdf
Defining a Tech Project Vision in Eight Quick Steps pdf
TechSoup 9.7K views

Adventures with Mono Runtime on Mobile Platforms

  • 1. Adventures with Mono Runtime on Mobile Platforms .NET Stammtisch Linz Bernhard Urban beurba@microsoft.com https://www.xamarin.com https://www.mono-project.com July 23, 2019 foundation 1 / 13
  • 4. The Mono Runtime — Overview Execution modes 4 / 13
  • 5. The Mono Runtime — Overview Execution modes Just-In-Time compiler 4 / 13
  • 6. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler 4 / 13
  • 7. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT 4 / 13
  • 8. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT FullAOT 4 / 13
  • 9. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT FullAOT Interpreter 4 / 13
  • 10. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT FullAOT Interpreter Supported platforms 4 / 13
  • 11. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT FullAOT Interpreter Supported platforms Linux, macOS, Windows, *BSD, AIX, IBM i, . . . 4 / 13
  • 12. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT FullAOT Interpreter Supported platforms Linux, macOS, Windows, *BSD, AIX, IBM i, . . . iOS, tvOS, watchOS & Android 4 / 13
  • 13. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT FullAOT Interpreter Supported platforms Linux, macOS, Windows, *BSD, AIX, IBM i, . . . iOS, tvOS, watchOS & Android XBox, PlayStation, WiiU, . . . 4 / 13
  • 14. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT FullAOT Interpreter Supported platforms Linux, macOS, Windows, *BSD, AIX, IBM i, . . . iOS, tvOS, watchOS & Android XBox, PlayStation, WiiU, . . . amd64, x86, armv7, armv8, powerpc, s390x 4 / 13
  • 15. The Mono Runtime — Overview Execution modes Just-In-Time compiler Ahead-Of-Time compiler normal AOT FullAOT Interpreter Supported platforms Linux, macOS, Windows, *BSD, AIX, IBM i, . . . iOS, tvOS, watchOS & Android XBox, PlayStation, WiiU, . . . amd64, x86, armv7, armv8, powerpc, s390x WebAssembly 4 / 13
  • 16. Embedding the Mono Runtime Embedding Mono link Mono into your application 5 / 13
  • 17. Embedding the Mono Runtime Embedding Mono link Mono into your application allows execution of .NET, e.g. useful for scripting 5 / 13
  • 18. Embedding the Mono Runtime Embedding Mono link Mono into your application allows execution of .NET, e.g. useful for scripting Users 5 / 13
  • 19. Embedding the Mono Runtime Embedding Mono link Mono into your application allows execution of .NET, e.g. useful for scripting Users Game Studios 5 / 13
  • 20. Embedding the Mono Runtime Embedding Mono link Mono into your application allows execution of .NET, e.g. useful for scripting Users Game Studios Unity 5 / 13
  • 21. Embedding the Mono Runtime Embedding Mono link Mono into your application allows execution of .NET, e.g. useful for scripting Users Game Studios Unity Blazor: check out https://learn-blazor.com/ 5 / 13
  • 22. Embedding the Mono Runtime Embedding Mono link Mono into your application allows execution of .NET, e.g. useful for scripting Users Game Studios Unity Blazor: check out https://learn-blazor.com/ Xamarin.Android & Xamarin.iOS 5 / 13
  • 23. Platform & Device landscape iOS on iPhone/iPad. 6 / 13
  • 24. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. 6 / 13
  • 25. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. 6 / 13
  • 26. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. 6 / 13
  • 27. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. x86 64: JIT. 6 / 13
  • 29. FullAOT iOS does not allow JIT compilation 7 / 13
  • 30. FullAOT iOS does not allow JIT compilation Normal AOT uses JIT occasionally at runtime 7 / 13
  • 31. FullAOT iOS does not allow JIT compilation Normal AOT uses JIT occasionally at runtime All trampolines and wrappers must be included in the AOT image 7 / 13
  • 32. FullAOT iOS does not allow JIT compilation Normal AOT uses JIT occasionally at runtime All trampolines and wrappers must be included in the AOT image Side-effect: System.Reflection.Emit does not work 7 / 13
  • 34. What about generics? public T return_t<T> (T arg) { return arg; } 8 / 13
  • 35. What about generics? public T return_t<T> (T arg) { return arg; } // "Generic sharing for value types" public void return_t (T& ret, T& arg, ptr hidden_arg) { int size = rgctx_fetch (hidden_arg); memcpy (ret, arg, size); } 8 / 13
  • 36. What about generics? public T return_t<T> (T arg) { return arg; } // "Generic sharing for value types" public void return_t (T& ret, T& arg, ptr hidden_arg) { int size = rgctx_fetch (hidden_arg); memcpy (ret, arg, size); } int i = return_t<int> (5); 8 / 13
  • 37. What about generics? public T return_t<T> (T arg) { return arg; } // "Generic sharing for value types" public void return_t (T& ret, T& arg, ptr hidden_arg) { int size = rgctx_fetch (hidden_arg); memcpy (ret, arg, size); } int i = return_t<int> (5); // calling chain caller ⇒ callee 8 / 13
  • 38. What about generics? public T return_t<T> (T arg) { return arg; } // "Generic sharing for value types" public void return_t (T& ret, T& arg, ptr hidden_arg) { int size = rgctx_fetch (hidden_arg); memcpy (ret, arg, size); } int i = return_t<int> (5); // calling chain caller ⇒ gsharedvt_arg_trampoline ⇒ callee 8 / 13
  • 39. What about generics? public T return_t<T> (T arg) { return arg; } // "Generic sharing for value types" public void return_t (T& ret, T& arg, ptr hidden_arg) { int size = rgctx_fetch (hidden_arg); memcpy (ret, arg, size); } int i = return_t<int> (5); // calling chain caller ⇒ gsharedvt_arg_trampoline ⇒ gsharedvt_in_trampoline ⇒ callee 8 / 13
  • 40. System.Reflection.Emit? System.ExecutionEngineException: Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod () 9 / 13
  • 41. System.Reflection.Emit? System.ExecutionEngineException: Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod () 9 / 13
  • 42. System.Reflection.Emit? System.ExecutionEngineException: Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod () Runtime interpreter enables System.Reflection.Emit 9 / 13
  • 43. System.Reflection.Emit? System.ExecutionEngineException: Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod () Runtime interpreter enables System.Reflection.Emit Faster “inner dev loop” No need to run the AOT compiler Smaller app bundle size ⇒ faster deploy 9 / 13
  • 44. System.Reflection.Emit? System.ExecutionEngineException: Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod () Runtime interpreter enables System.Reflection.Emit Faster “inner dev loop” No need to run the AOT compiler Smaller app bundle size ⇒ faster deploy Best of both worlds: “Mixed Mode” with FullAOT 9 / 13
  • 45. System.Reflection.Emit? System.ExecutionEngineException: Attempting to JIT compile method MyClass:DynamicallyGeneratedMethod () Runtime interpreter enables System.Reflection.Emit Faster “inner dev loop” No need to run the AOT compiler Smaller app bundle size ⇒ faster deploy Best of both worlds: “Mixed Mode” with FullAOT Ships with upcoming release of Xamarin.iOS (Preview available) 9 / 13
  • 46. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. x86 64: JIT. tvOS on Apple TV. 10 / 13
  • 47. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. x86 64: JIT. tvOS on Apple TV. arm64: FullAOT and interpreter. 10 / 13
  • 48. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. x86 64: JIT. tvOS on Apple TV. arm64: FullAOT and interpreter. x86 64: JIT. 10 / 13
  • 49. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. x86 64: JIT. tvOS on Apple TV. arm64: FullAOT and interpreter. x86 64: JIT. watchOS on Apple Watch. 10 / 13
  • 50. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. x86 64: JIT. tvOS on Apple TV. arm64: FullAOT and interpreter. x86 64: JIT. watchOS on Apple Watch. armv7k: FullAOT and bitcode. 10 / 13
  • 51. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. x86 64: JIT. tvOS on Apple TV. arm64: FullAOT and interpreter. x86 64: JIT. watchOS on Apple Watch. armv7k: FullAOT and bitcode. arm64 32: interpreter (WIP) and bitcode. 10 / 13
  • 52. Platform & Device landscape iOS on iPhone/iPad. armv7: FullAOT. arm64: FullAOT and interpreter. x86: JIT. x86 64: JIT. tvOS on Apple TV. arm64: FullAOT and interpreter. x86 64: JIT. watchOS on Apple Watch. armv7k: FullAOT and bitcode. arm64 32: interpreter (WIP) and bitcode. x86: JIT. 10 / 13
  • 53. Xamarin.Android Simliar to Linux, except for interop between C# and Java Two Garbage collectors have to work together 11 / 13
  • 54. Xamarin.Android Simliar to Linux, except for interop between C# and Java Two Garbage collectors have to work together War story: Samsung Galaxy S7 11 / 13
  • 55. Xamarin.Android Simliar to Linux, except for interop between C# and Java Two Garbage collectors have to work together War story: Samsung Galaxy S7 First bug report: “Xamarin.Android apps on the Samsung Galaxy S7 fails to start with the error System.ExecutionEngineException SIGILL“. 11 / 13
  • 56. Xamarin.Android Simliar to Linux, except for interop between C# and Java Two Garbage collectors have to work together War story: Samsung Galaxy S7 First bug report: “Xamarin.Android apps on the Samsung Galaxy S7 fails to start with the error System.ExecutionEngineException SIGILL“. Co-worker in the US got the device. 11 / 13
  • 57. Xamarin.Android Simliar to Linux, except for interop between C# and Java Two Garbage collectors have to work together War story: Samsung Galaxy S7 First bug report: “Xamarin.Android apps on the Samsung Galaxy S7 fails to start with the error System.ExecutionEngineException SIGILL“. Co-worker in the US got the device. He could not reproduce it. 11 / 13
  • 58. Xamarin.Android Simliar to Linux, except for interop between C# and Java Two Garbage collectors have to work together War story: Samsung Galaxy S7 First bug report: “Xamarin.Android apps on the Samsung Galaxy S7 fails to start with the error System.ExecutionEngineException SIGILL“. Co-worker in the US got the device. He could not reproduce it. US edition: Ships with Snapdragon 820. 11 / 13
  • 59. Xamarin.Android Simliar to Linux, except for interop between C# and Java Two Garbage collectors have to work together War story: Samsung Galaxy S7 First bug report: “Xamarin.Android apps on the Samsung Galaxy S7 fails to start with the error System.ExecutionEngineException SIGILL“. Co-worker in the US got the device. He could not reproduce it. US edition: Ships with Snapdragon 820. World edition: Ships with Exynos 8890. 11 / 13
  • 60. Xamarin.Android Simliar to Linux, except for interop between C# and Java Two Garbage collectors have to work together War story: Samsung Galaxy S7 First bug report: “Xamarin.Android apps on the Samsung Galaxy S7 fails to start with the error System.ExecutionEngineException SIGILL“. Co-worker in the US got the device. He could not reproduce it. US edition: Ships with Snapdragon 820. World edition: Ships with Exynos 8890. Could reproduce it with Xamarin Test Cloud. 11 / 13
  • 61. War story: Samsung Galaxy S7 $ grep SIGILL *.log custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0 custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0 custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70 custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0 custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0 custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0 12 / 13
  • 62. War story: Samsung Galaxy S7 $ grep SIGILL *.log custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0 custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0 custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70 custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0 custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0 custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0 void __clear_cache (char *address, size_t size) { static int cache_line_size = 0; if (!cache_line_size) cache_line_size = get_current_cpu_cache_line_size (); for (int i = 0; i < size; i += cache_line_size) flush_cache_line (address + i); }
  • 63. War story: Samsung Galaxy S7 $ grep SIGILL *.log custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0 custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0 custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70 custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0 custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0 custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0 void __clear_cache (char *address, size_t size) { static int cache_line_size = 0; if (!cache_line_size) cache_line_size = get_current_cpu_cache_line_size (); for (int i = 0; i < size; i += cache_line_size) flush_cache_line (address + i); }
  • 64. War story: Samsung Galaxy S7 $ grep SIGILL *.log custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0 custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0 custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70 custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0 custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0 custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0 void __clear_cache (char *address, size_t size) { static int cache_line_size = 0; if (!cache_line_size) cache_line_size = get_current_cpu_cache_line_size (); for (int i = 0; i < size; i += cache_line_size) flush_cache_line (address + i); } 12 / 13
  • 65. War story: Samsung Galaxy S7 $ grep SIGILL *.log custom_01.log:E/mono (13964): SIGILL at ip=0x0000007f4f15e8d0 custom_02.log:E/mono (13088): SIGILL at ip=0x0000007f8ff76cc0 custom_03.log:E/mono (12824): SIGILL at ip=0x0000007f68e93c70 custom_04.log:E/mono (12876): SIGILL at ip=0x0000007f4b3d55f0 custom_05.log:E/mono (13008): SIGILL at ip=0x0000007f8df1e8d0 custom_06.log:E/mono (14093): SIGILL at ip=0x0000007f6c21edf0 void __clear_cache (char *address, size_t size) { static int cache_line_size = 0; if (!cache_line_size) cache_line_size = get_current_cpu_cache_line_size (); for (int i = 0; i < size; i += cache_line_size) flush_cache_line (address + i); } 64byte buckets: 0x00-0x3f: always flushed 0x40-0x7f: only flushed when cacheline size is 64 byte. 0x80-0xbf: always flushed 0xc0-0xff: only flushed when cacheline size is 64 byte. 12 / 13
  • 66. Thanks Visit us https://www.mono-project.com Chat with us https://gitter.im/mono/mono Mail me beurba@microsoft.com foundation 13 / 13