狠狠撸

狠狠撸Share a Scribd company logo
call命令 / callvirt命令
2016_5_17 @sunotora
自己紹介
? スノトラ
? @sunotoraさん結婚式n次会主催(してた、勉強会だよ^^)
? ???????????????????? → 道の上のカエル
? C#歴3日、F#歴0.5日
? なごやでいちばんこわくないカエル
? ざっきーさんの先輩(年的な意味で)、ここでは後輩
アジェンダ
?なぜcall命令/ callvirt命令なのか
?ILについて
?call命令 / callvirt命令
?call命令 / callvirt命令違い?挙動
?まとめ
なぜcall命令/ callvirt命令なのか
?昨日発表が決まりました。
なぜcall命令/ callvirt命令なのか
?昨日発表が決まりました。
(あとは察しよう)
ILについて
https://msdn.microsoft.com/ja-jp/library/z1zx9t92.aspx
ILについて
https://msdn.microsoft.com/ja-jp/library/z1zx9t92.aspx
ソースコードがコンパイルされ
るとIL(中間言語)になる
call命令 / callvirt命令
?メソッド呼び出し用のIL命令で
CLR(共通言語ランタイム)が提供
call命令 / callvirt命令
?メソッド呼び出し用のIL命令で
CLR(共通言語ランタイム)が提供
?2つしかない、覚えるの楽、やったね
call命令 / callvirt命令
?メソッド呼び出し用のIL命令で
CLR(共通言語ランタイム)が提供
?2つしかない、覚えるの楽、やったね
?そんなわけなかったー
?よくわからんー
?calli命令というのもあるらしい
(2つじゃない!)
call命令 / callvirt命令違い?挙動
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
call命令 / callvirt命令違い?挙動
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
call命令 / callvirt命令違い?挙動
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
call命令 / callvirt命令違い?挙動
①引数オブジェクトのGetTypeした型のSay
②Base型のSay
③Derived型のSay
④Duck型のSay
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
call命令 / callvirt命令違い?挙動
①引数オブジェクトのGetTypeした型のSay
②Base型のSay
③Derived型のSay
④Duck型のSay
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
call命令 / callvirt命令違い?挙動
①引数オブジェクトのGetTypeした型のSay
②Base型のSay
③Derived型のSay
④Duck型のSay
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
call命令 / callvirt命令違い?挙動
①引数オブジェクトのGetTypeした型のSay
②Base型のSay
③Derived型のSay
④Duck型のSay
ILの call と callvirt の違い
http://d.hatena.ne.jp/siokoshou/20070517
call命令 / callvirt命令違い?挙動
①引数オブジェクトのGetTypeした型のSay
②Base型のSay
③Derived型のSay
④Duck型のSay
まとめ
?call命令
変数そのものの型で動作
Base d = new Derived(5);
?callvirt命令
オブジェクトの実際の型で動作(ポリモーフィックに)
Base d = new Derived(5);
まとめ
?今回はILGeneratorで(無理やり)ILを生成
→実際にソースコードをコンパイルした
結果のILは、各コンパイラが言語仕様に従って
call/callvirtを判断して生成してくれる、やったね
ご静聴ありがとうございました。
ご静聴ありがとうございました。
颁补濒濒,肠补濒濒惫颈谤迟命令

More Related Content

Featured (20)

2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design ProcessStorytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
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
Albert Qian
?
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)
?
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
Search Engine Journal
?
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
SpeakerHub
?
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
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
Tessa Mero
?
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
Lily Ray
?
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
?
2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design ProcessStorytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
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
Albert Qian
?
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
Search Engine Journal
?
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
SpeakerHub
?
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
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
Tessa Mero
?
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
Lily Ray
?

颁补濒濒,肠补濒濒惫颈谤迟命令

Editor's Notes

  • #3: 贬补蝉办别濒濒歴、ぶれいすさんにすごい贬本を借りて1笔も読まずに返した経歴ががが???
  • #7: みんなすでに知っていると思うけど From Introduction to the C# Language and the .NET Framework https://msdn.microsoft.com/ja-jp/library/z1zx9t92.aspx ソースファイルは別にC#だけじゃなくてF#とかVBとかでもよい
  • #12: Base(基底クラス) : Baseという文字列とthisの型を表示 Derived (派生クラス): Derivedという文字列とthisの型とメンバ変数の値を表示 Duck(まったく関係ないクラス) : ガーという文字列を表示 ILの call と callvirt の違い http://d.hatena.ne.jp/siokoshou/20070517
  • #13: callとcallvirtで ①引数のオブジェクトのGetTypeした型のSay ②Base型のSay ③Derived型のSay ④Duck型のSay を呼び出すIL命令を動的に生成?実行するメソッドを用意
  • #14: 実行
  • #16: 基底型の各種call命令 3つめのDerivedのSay呼び出しができちゃっています。 Baseはintのメンバを持っていないので初期値0が出力されています。
  • #17: 派生型の各種call命令 派生型に関しては予想通りの出力ですね
  • #18: Duck型の各種call命令 こちらも各種呼べちゃっています。 int iはメンバに持っていますが、nは持っていないのでDerivedのSayの値出力は初期値0になっています。
  • #19: 基底型と派生形の各種callvirt命令 すべて一致して呼べていますね
  • #20: Duck型のcallvirt呼び出しですが、 Base型のSayとしての呼び出しの時点でSystem.AccessViolationExceptionが発生しました。 元記事の2007年の時点ではガー、ガー、ガー、ガーで例外発生せず呼べていたみたいです。 AccessViolationExceptionは無効なポインターによる読み取りまたは書き込み、メモリの破損で発生する
  • #21: 以上のことからわかる挙动の违い
  • #25: 骋别迟齿がないクラスに対して无理やり虫の値を取得できちゃったりもする???