SlideShare ist ein Scribd-Unternehmen logo
1 von 66
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Kürzlich hochgeladen

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Kürzlich hochgeladen (20)

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

Empfohlen

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Good 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 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 Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
Simplilearn
 

Empfohlen (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
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 Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
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...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
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...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good 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 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
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

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