SlideShare une entreprise Scribd logo
1  sur  66
Télécharger pour lire hors ligne
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

Contenu connexe

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Dernier (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
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-...
 
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 🔝✔️✔️
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
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
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

En vedette

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
 

En vedette (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