SlideShare une entreprise Scribd logo
1  sur  32
.NET Internals
stack memory management
Compilation flow
var hello = "Hello";
var world = "World";
Console.WriteLine(hello + world);
ldstr "Hello"
ldstr "World"
call System.String::Concat
call System.Console::WriteLine
movabs rdi, 0x196af5078
mov rdi, qword ptr [rdi]
movabs rsi, 0x196af5080
mov rsi, qword ptr [rsi]
call 0x10d5ad380
mov rdi, rax
call 0x10dbb1d40
Notation types
• Infix
• Suffix
• Postfix
2 + 3
+ 2 3
2 3 +
Notation types
• Infix
• Suffix
• Postfix
builder.Append("Hello!")
Append builder "Hello!"
builder "Hello!" Append
Stack machine
2 + 3 * 4
Stack machine
2 2
3
4
3
2 2
12
14
2 + 3 * 4
Stack machine
Stack
head
Stack machine
C#
var i = 2 + 2;
2 2 + i;
Forth
Developer Forth was Yoda just
Stack machine
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone);
C#
call Contact GetPhoneNumber()
dup
call void SendMessage(Contact)
call void MakeCall(Contact)
CIL
Stack machine
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone);
call Contact GetPhoneNumber()
dup
call void SendMessage(Contact)
call void MakeCall(Contact)
C# CIL
Stack phone
top
Stack machine
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone);
call Contact GetPhoneNumber()
dup
call void SendMessage(Contact)
call void MakeCall(Contact)
C# CIL
Stack phone
phone
top
Stack machine
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone);
call Contact GetPhoneNumber()
dup
call void SendMessage(Contact)
call void MakeCall(Contact)
C# CIL
Stack phone
phone
top
Stack machine
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone);
call Contact GetPhoneNumber()
dup
call void SendMessage(Contact)
call void MakeCall(Contact)
C# CIL
Stack phone
top
Stack machine
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone);
call Contact GetPhoneNumber()
dup
call void SendMessage(Contact)
call void MakeCall(Contact)
C# CIL
Stack
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
C#
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
CIL
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack 1
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack 1
Locals mode
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack phone
Locals mode
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack phone
Locals mode
phone
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack phone
Locals mode
phone
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack phone
Locals mode
phone
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack phone
Locals mode
phone
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack phone
mode
Locals mode
phone
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack phone
mode
Locals mode
phone
top
Stack machine
var mode = Mode.Default
var phone = GetPhoneNumber();
SendMessage(phone);
MakeCall(phone, mode);
ldc.i4.1
stloc.0
call Contact GetPhoneNumber()
stloc.1
ldloc.1
call void SendMessage(Contact)
ldloc.1
ldloc.0
call void MakeCall(Contact, valuetype Mode)
C# CIL
Stack Locals mode
phone
top
JIT compiler
Demo
JIT compiler
LdVar Sorting
& Tree
Ordering
Loop
Optimizations
Range Check
Elimination
Rationalization
Importer Inliner Morph
Flowgraph
Analysis
EmitterLowering LSRA CodeGen
Rationalized
LIR
Native
Code
GenTrees IR with reference counts
& evaluation order
Instr
Descs
Real
registers
Reg
Reqts
GenTrees
(IR)
IL
(bytecode)
Copy
Propagation
CSE
Assertion
Propagation
Loop
Optimizations
Range Check
Elimination
Copy
Propagation
CSE
Assertion
Propagation
JIT optimizations
• Not saving variables
• Method call inlining
• Range check elimination
• Jump instead of call
• …
Demo
.NET Internals
stack memory management
Nikolay Balakin
nikolay@balakin.me

Contenu connexe

Tendances

Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleRuby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Anton Shemerey
 

Tendances (13)

[CB20] Reflex: you give me a parser, I give you a token generator by Paolo Mo...
[CB20] Reflex: you give me a parser, I give you a token generator by Paolo Mo...[CB20] Reflex: you give me a parser, I give you a token generator by Paolo Mo...
[CB20] Reflex: you give me a parser, I give you a token generator by Paolo Mo...
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
Protecting C++
Protecting C++Protecting C++
Protecting C++
 
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleRuby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
 
Cisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-oneCisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-one
 
Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command Line
 
Learning go for perl programmers
Learning go for perl programmersLearning go for perl programmers
Learning go for perl programmers
 
iCloud keychain
iCloud keychainiCloud keychain
iCloud keychain
 
DConf 2016 std.database (a proposed interface & implementation)
DConf 2016 std.database (a proposed interface & implementation)DConf 2016 std.database (a proposed interface & implementation)
DConf 2016 std.database (a proposed interface & implementation)
 
ClojurianからみたElixir
ClojurianからみたElixirClojurianからみたElixir
ClojurianからみたElixir
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
The Stack and Buffer Overflows
The Stack and Buffer OverflowsThe Stack and Buffer Overflows
The Stack and Buffer Overflows
 

Similaire à .NET Fest 2018. Николай Балакин. .NET Internals: управление памятью в стеке

Your codebase sucks! and how to fix it
Your codebase sucks! and how to fix itYour codebase sucks! and how to fix it
Your codebase sucks! and how to fix it
Llewellyn Falco
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
Charles Nutter
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
C Omputer R Oom
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
C Omputer R Oom
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
C Omputer R Oom
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
C Omputer R Oom
 

Similaire à .NET Fest 2018. Николай Балакин. .NET Internals: управление памятью в стеке (20)

Common Intermediate Language (.NET) by Example
Common Intermediate Language (.NET) by ExampleCommon Intermediate Language (.NET) by Example
Common Intermediate Language (.NET) by Example
 
Kotlin / Android Update
Kotlin / Android UpdateKotlin / Android Update
Kotlin / Android Update
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
 
Your codebase sucks! and how to fix it
Your codebase sucks! and how to fix itYour codebase sucks! and how to fix it
Your codebase sucks! and how to fix it
 
0x01 - Breaking into Linux VMs for Fun and Profit.pdf
0x01 - Breaking into Linux VMs for Fun and Profit.pdf0x01 - Breaking into Linux VMs for Fun and Profit.pdf
0x01 - Breaking into Linux VMs for Fun and Profit.pdf
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
0x01 - Breaking into Linux VMs for Fun and Profit
0x01 - Breaking into Linux VMs for Fun and Profit0x01 - Breaking into Linux VMs for Fun and Profit
0x01 - Breaking into Linux VMs for Fun and Profit
 
NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016
 
A compact bytecode format for JavaScriptCore
A compact bytecode format for JavaScriptCoreA compact bytecode format for JavaScriptCore
A compact bytecode format for JavaScriptCore
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centre
 
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
 
Clean Code Development
Clean Code DevelopmentClean Code Development
Clean Code Development
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
 

Plus de NETFest

Plus de NETFest (20)

.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET
.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET
.NET Fest 2019. Николай Балакин. Микрооптимизации в мире .NET
 
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE....NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...
.NET Fest 2019. Сергей Калинец. Efficient Microservice Communication with .NE...
 
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET
.NET Fest 2019. Оля Гавриш. .NET Core 3.0 и будущее .NET
 
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов
.NET Fest 2019. Оля Гавриш. Машинное обучение для .NET программистов
 
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem....NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...
.NET Fest 2019. Roberto Freato. Provisioning Azure PaaS fluently with Managem...
 
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
 
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex
.NET Fest 2019. Сергій Бута. Feature Toggles: Dynamic Configuration at Wirex
 
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A....NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...
.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with A...
 
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture
.NET Fest 2019. Андрей Литвинов. Async lifetime tests with xUnit and AutoFixture
 
.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests
.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests
.NET Fest 2019. Анатолий Колесник. Love, Death & F# Tests
 
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос....NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
 
.NET Fest 2019. Roberto Freato. Azure App Service deep dive
.NET Fest 2019. Roberto Freato. Azure App Service deep dive.NET Fest 2019. Roberto Freato. Azure App Service deep dive
.NET Fest 2019. Roberto Freato. Azure App Service deep dive
 
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
 
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com...
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com....NET Fest 2019. Александр Демчук. How to measure relationships within the Com...
.NET Fest 2019. Александр Демчук. How to measure relationships within the Com...
 
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real....NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...
.NET Fest 2019. Anna Melashkina та Philipp Bauknecht. Dragons in a Mixed Real...
 
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
 
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ....NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...
.NET Fest 2019. Stas Lebedenko. Practical serverless use cases in Azure with ...
 
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali....NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...
.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reali...
 
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET
.NET Fest 2019. Сергей Корж. Natural Language Processing in .NET
 
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur....NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
 

Dernier

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Dernier (20)

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 

.NET Fest 2018. Николай Балакин. .NET Internals: управление памятью в стеке

  • 2. Compilation flow var hello = "Hello"; var world = "World"; Console.WriteLine(hello + world); ldstr "Hello" ldstr "World" call System.String::Concat call System.Console::WriteLine movabs rdi, 0x196af5078 mov rdi, qword ptr [rdi] movabs rsi, 0x196af5080 mov rsi, qword ptr [rsi] call 0x10d5ad380 mov rdi, rax call 0x10dbb1d40
  • 3. Notation types • Infix • Suffix • Postfix 2 + 3 + 2 3 2 3 +
  • 4. Notation types • Infix • Suffix • Postfix builder.Append("Hello!") Append builder "Hello!" builder "Hello!" Append
  • 6. 2 + 3 * 4 Stack machine
  • 7. 2 2 3 4 3 2 2 12 14 2 + 3 * 4 Stack machine Stack head
  • 8. Stack machine C# var i = 2 + 2; 2 2 + i; Forth
  • 10. Stack machine var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone); C# call Contact GetPhoneNumber() dup call void SendMessage(Contact) call void MakeCall(Contact) CIL
  • 11. Stack machine var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone); call Contact GetPhoneNumber() dup call void SendMessage(Contact) call void MakeCall(Contact) C# CIL Stack phone top
  • 12. Stack machine var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone); call Contact GetPhoneNumber() dup call void SendMessage(Contact) call void MakeCall(Contact) C# CIL Stack phone phone top
  • 13. Stack machine var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone); call Contact GetPhoneNumber() dup call void SendMessage(Contact) call void MakeCall(Contact) C# CIL Stack phone phone top
  • 14. Stack machine var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone); call Contact GetPhoneNumber() dup call void SendMessage(Contact) call void MakeCall(Contact) C# CIL Stack phone top
  • 15. Stack machine var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone); call Contact GetPhoneNumber() dup call void SendMessage(Contact) call void MakeCall(Contact) C# CIL Stack top
  • 16. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); C# ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) CIL
  • 17. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack 1 top
  • 18. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack 1 Locals mode top
  • 19. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack phone Locals mode top
  • 20. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack phone Locals mode phone top
  • 21. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack phone Locals mode phone top
  • 22. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack phone Locals mode phone top
  • 23. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack phone Locals mode phone top
  • 24. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack phone mode Locals mode phone top
  • 25. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack phone mode Locals mode phone top
  • 26. Stack machine var mode = Mode.Default var phone = GetPhoneNumber(); SendMessage(phone); MakeCall(phone, mode); ldc.i4.1 stloc.0 call Contact GetPhoneNumber() stloc.1 ldloc.1 call void SendMessage(Contact) ldloc.1 ldloc.0 call void MakeCall(Contact, valuetype Mode) C# CIL Stack Locals mode phone top
  • 28. Demo
  • 29. JIT compiler LdVar Sorting & Tree Ordering Loop Optimizations Range Check Elimination Rationalization Importer Inliner Morph Flowgraph Analysis EmitterLowering LSRA CodeGen Rationalized LIR Native Code GenTrees IR with reference counts & evaluation order Instr Descs Real registers Reg Reqts GenTrees (IR) IL (bytecode) Copy Propagation CSE Assertion Propagation Loop Optimizations Range Check Elimination Copy Propagation CSE Assertion Propagation
  • 30. JIT optimizations • Not saving variables • Method call inlining • Range check elimination • Jump instead of call • …
  • 31. Demo
  • 32. .NET Internals stack memory management Nikolay Balakin nikolay@balakin.me