SlideShare a Scribd company logo
Beachhead implements
new opcode on CLR JIT
.NET FRINGE JAPAN 2016 KOUJI MATSUI (@KEKYO2)
2
Kouji Matsui - kekyo
• NAGOYA city, AICHI pref., JP
• Twitter – @kekyo2 / Facebook
• ux-spiral corporation
• Microsoft Most Valuable Professional VS
and DevTech 2015-
• Certified Scrum master / Scrum product
owner
• Center CLR organizer.
• .NET/C#/F#/IL/metaprogramming or
like…
• Bike rider
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
3
You can beginning hack:
“CoreCLR”
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI
MATSUI
4
Agenda
• Introduction / Background
• How to build coreclr/corefx
• Add custom IL opcode
• Deep-dive CLR JIT
• Verify custom IL opcode to work
• Conclusion
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
5
Introduction / Background
• .NET Core is open-sourced!!
• Become clearing the .NET internal implementations.
• .NET Framework noeq .NET Core, but very interesting internal
implements anythings…
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
6
Introduction / Background
• I am joining .NET Fringe Japan organizer teams. And thinking
what about speaks first conference…
• Roslyn and corefx already exploring and explaining any people
(in Japan) … Hmm.
• If can add custom IL opcode and build custom CLR ?
Fun, interesting and understanding internal CoreCLR ! :)
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
7
How to build coreclr/corefx
• Development and test bench requirements:
• Windows 10 x64
• Visual Studio 2015 Update 3 (Using C++ compiler)
• CMake 3.6.2 (Multiplatform building tool) https://cmake.org/
• Python 3.5.2 https://www.python.org/
• Official docs: “Building and running tests on Windows”
https://github.com/dotnet/coreclr/blob/master/Documentat
ion/building/windows-test-instructions.md
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
8
How to build coreclr/corefx
• Test summary:
1. Get source codes from GitHub dotnet/coreclr, corefx.
• git clone https://github.com/dotnet/coreclr
• git clone https://github.com/dotnet/corefx
2. Build coreclr and corefx.
• Run build.cmd both coreclr and corefx.
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
9
How to build coreclr/corefx
3. Test running minimum sample code using coreclr/corefx.
• Copy System.Runtime.dll and some assemblies from corefx into
coreclr.
• Compile the C# Hello world code using VS2015 C# compiler (csc.exe),
with /nostdlib /r:System.Runtime.dll and another strict options.
• Run the code, “CoreRun.exe Program.exe”
Need more informations?
see documents previous links.
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
10
How to build coreclr/corefx
•TIPS!!!
• Must use stable version commits for coreclr
and corefx!
• They are developing continuously and
worldwide, 10 or more commits/day.
• Hint: Look for CI status on GitHub
coreclr/corefx page.
https://github.com/dotnet/coreclr
https://github.com/dotnet/corefx
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
11
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
12
• This is just beginning :)
• Suggest first step: Very simple spec opcode:
• Opcode name: “customcode”
• No operand, no IL stack consume/produce.
• Use opcode: affect output demonstration string to Windows Debug log.
(Use Win32 API “OutputDebugStringW”)
Add custom IL opcode
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
13
• Debug log can capture use Sysinternals DebugView utility.
https://technet.microsoft.com/en-
us/sysinternals/debugview.aspx
Add custom IL opcode
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
14
Add custom IL opcode
• Thinking what currently declared opcode for completely
nothing input/output and no side-effect in CLR ?
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
15
Add custom IL opcode
• ex: Opcode “break” – Break execution the attached debugger current
position.
https://msdn.microsoft.com/en-
us/library/system.reflection.emit.opcodes.break(v=vs.110).aspx
• “Debugger break” means raise interruption native CPU (x64), such as
“DebugBreak” API or “__debugbreak” intrinsic.
• So, maybe contains invoke these API in coreclr source codes. I can find
related code easier, try using base for this opcode…
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
16
Add custom IL opcode
• Grep special-like or unique naming opcode in coreclr:
ex: “initobj”, “ldftn” etc…
--> Opcodes declared in src/inc/opcode.def by OPDEF() macro.
• Opcode break: “CEE_BREAK”
OPDEF(CEE_BREAK, "break", Pop0, Push0, InlineNone, IPrimitive, 1,
0xFF, 0x01, BREAK)
• Add “CEE_CUSTOMCODE” for last opcode “CEE_UNUSED70”’s next:
OPDEF(CEE_CUSTOMCODE, “customcode", Pop0, Push0, InlineNone,
IPrimitive, 2, 0xFE, 0x23, NEXT)
New 2 words opcode: fe,23
Instruction move hint:
“NEXT” is execute next opcode.
(Standard behavior)
No stack consume/produce
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
17
Deep-dive CLR JIT
•Oh, I’m just declared new opcode “customcode” now!! :)
•But this opcode used no coreclr runtime…
Require giving new opcode behavior
MANUALLY
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
18
Compiler-Importer JIT_CustomCode()JIT
Deep-dive CLR JIT
•How interpret opcodes in coreclr:
Assembly file:
MSIL section Parse Call OutputDebugStringW()
Parse IL opcodes
GTNODE
Call
Peek from JIT helper
function pointer table.
Internal IL stream
tree structures
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
19
Deep-dive CLR JIT
• Compiler-Importer (src/jit/importer.cpp) is IL opcode stream
parser use declaring CEE_* macros.
• CEE_BREAK case example:
case CEE_BREAK:
op1 = gtNewHelperCallNode(CORINFO_HELP_USER_BREAKPOINT, TYP_VOID);
goto SPILL_APPEND;
• “gtNewHelperCallNode” is construction GTNODE internal tree
structure node for invoke JIT helper function.
• “CORINFO_HELP_USER_BREAKPOINT” is JIT helper function index
symbol.
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
20
Deep-dive CLR JIT
• “CORINFO_HELP_USER_BREAKPOINT” declared in
src/inc/corinfo.h:
• Symbol declared in “enum CorInfoHelpFunc”. Because JIT helper
functions management by function pointer table. This table size
calculated from enum symbols count.
• And src/inc/jithelper.h:
JITHELPER(CORINFO_HELP_USER_BREAKPOINT, JIT_UserBreakpoint,
CORINFO_HELP_SIG_REG_ONLY)
REAL helper function name
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
21
Deep-dive CLR JIT
• Add “CORINFO_HELP_CUSTOMCODE” into CorInfoHelpFunc
and provide JIT helper function information by JITHELPER()
macro.
JITHELPER(CORINFO_HELP_CUSTOMCODE, JIT_CustomCode,
CORINFO_HELP_SIG_REG_ONLY)
• Back to Importer and add “CEE_CUSTOMCODE” handler:
case CEE_CUSTOMCODE:
op1 = gtNewHelperCallNode(CORINFO_HELP_CUSTOMCODE, TYP_VOID);
goto SPILL_APPEND;
• “TYP_VOID” is hold opcode value type (ex: operand type).
“customcode” opcode hold no value, so this ID is TYP_VOID.
• Importer done!
New JIT helper
function name
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
22
Deep-dive CLR JIT
• Implement JIT helper function “JIT_CustomCode”:
HCIMPL0(void, JIT_CustomCode)
{
FCALL_CONTRACT;
HELPER_METHOD_FRAME_BEGIN_NOPOLL();
::OutputDebugStringW(L"Triggered custom code!!!!!!! (for JIT)");
HELPER_METHOD_FRAME_END_POLL();
}
HCIMPLEND
• HCIMPL0(), FCALL_CONTRACT,
HELPER_METHOD_FRAME_BEGIN_NOPOLL(),
HELPER_METHOD_FRAME_END_POLL() macros are required for construct
hard-coded low level prologue/epilogue codes JIT helper functions.
• JIT helper function done!!
THIS IS CORE CODE!!
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
23
Deep-dive CLR JIT
• Anything done ?
• More two non-important points:
1. Implement interpreter-based code. Interpreter is
src/vm/interpreter.cpp.
• But Windows-x64 environments nothing to use interpreter, all
situation works only use JIT.
2. ILFormatter (src/utilcode/ilformatter.cpp).
• Format printer-friendly string from IL opcode. But default
implementation is printing uses CEE_* macro information, this
session’s custom code is not required.
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
24
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
25
Verify custom IL opcode to work
• OK, ready to run… How?
• The “customcode” IL opcode can work with CLR now, but how to generate
“customcode” contained assembly??
Manually paching with BINARY EDITOR…??
(; ゚Д゚)
This is TOP SECRET:
I fogot IMAGE_DOS_HEADER, IMAGE_FILE_HEADER, IMAGE_NT_HEADER,
IMAGE_OPTIONAL_HEADER, IMAGE_DATA_DIRECTORY, IMAGE…
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
26
Verify custom IL opcode to work
• Thinking about more easy construction:
1. Compile standard C# sample code by .NET Core 1.0.
2. Use “ildasm” to disassembled.
3. Insert “customcode” opcode into disassembled IL source code.
4. Use custom-opcode enabled “idasm” to build new assembly.
• The “ilasm” and “ildasm” are built with coreclr. New opcodes
can handling from “opcode.def” automatically.
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
27
Verify custom IL opcode to work
• Bootstrap test code in C#:
Generate template code from “dotnet new” command and simplied:
namespace ConsoleApplication
{
public static class Program
{
public static void Main(string[] args)
{
}
}
}
• Compile:
• dotnet restore
• dotnet build
• Storing compiled assembly: bin¥Debug¥netcoreapp1.0¥addil.dll
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
28
Verify custom IL opcode to work
• Disassembling:
• ..¥ildasm.exe bin¥Debug¥netcoreapp1.0¥addil.dll > addil.il
• Fixed attributes for referenced System.Runtime:
.assembly extern System.Runtime
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 4:2:0:0
}
Fix pubkey token and version similer to your
local built corefx binaries if different.
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
29
Verify custom IL opcode to work
• Insert “customcode” opcode into Main method body:
.method public hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.maxstack 8
IL_0000: nop
customcode
IL_0001: ret
}
Insert “customcode” opcode!!
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
30
Verify custom IL opcode to work
• Assemble by customcode-enabled “ilasm”:
• ..¥ilasm.exe Program.il
Success with nothing error.
If use official ilasm.exe, will cause error:
“syntax error at token ‘ret’”
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
31
Verify custom IL opcode to work
• Run the assembly and verify with DebugView:
• Before execute DbgView.exe
• ..¥CoreRun.exe Program.exe
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
32
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
33
Conclusion
• Custom IL opcode declare and implement:
• Declare opcode into opcode.def with OPDEF() macro.
• Declare JIT helper function into corinfo.h and jithelper.h with
JITHELPER() macro.
• Implement JIT helper function with HCIMPL() macros.
• Implement custom opcode handler into Compile-Importer.
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
34
Conclusion
• Verification:
• Generate IL codes from disassembled C# codes with “ildasm.”
(Or, write from scratch IL codes…)
• Using custom-opcode enabled “ilasm” to generate final binary.
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
35
Conclusion
• coreclr is truly OSS: Custom IL opcode can implements with
average difficulity.
• This session explain with constraints “No operand, No stack
consume/produce opcode.”
Maybe more hard work for intermediate usage opcode design…
• But YOU CAN DO THAT!!
• This session’s demonstration code:
• https://github.com/kekyo/coreclr git branch:addil
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
36
Thank you joining my session!!
• Become slides on slideshare and my blog entry.
http://www.kekyo.net/ (Sorry blog only Japanese language)
• My twitter account @kekyo2, follow <3
• GitHub https://github.com/kekyo/ contains:
• FusionTasks, RelaxVersioner, fscx and more…
• Open conference with “Center CLR” in Aichi
pref., Japan! Join us!!
https://www.meetup.com/en-US/CenterCLR/
CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI

More Related Content

What's hot

COSCUP - Fleet
COSCUP - FleetCOSCUP - Fleet
COSCUP - Fleet
Philip Zheng
 
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Pôle Systematic Paris-Region
 
Use MQTT in Docker on Raspberry Pi
Use MQTT in Docker on Raspberry PiUse MQTT in Docker on Raspberry Pi
Use MQTT in Docker on Raspberry Pi
Philip Zheng
 
Future of NodeJS
Future of NodeJSFuture of NodeJS
Future of NodeJS
Sébastien Pertus
 
Introduction to Tensorflow.js
Introduction to Tensorflow.jsIntroduction to Tensorflow.js
Introduction to Tensorflow.js
Riza Fahmi
 
Web of Technologies
Web of TechnologiesWeb of Technologies
Web of Technologies
dynamis
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
Phil Hawksworth
 
Nodejs intro
Nodejs introNodejs intro
Nodejs intro
Ndjido Ardo BAR
 
Super combinators
Super combinatorsSuper combinators
Super combinators
CocoaHeads France
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
Joseph de Castelnau
 
Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.
Yurii Bychenok
 
Kraken js at paypal
Kraken js at paypalKraken js at paypal
Kraken js at paypal
Lenny Markus
 
Les nouveautés de C# 7
Les nouveautés de C# 7Les nouveautés de C# 7
Les nouveautés de C# 7
Microsoft
 
Node ppt
Node pptNode ppt
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
Arvind Devaraj
 
NodeJS: an Introduction
NodeJS: an IntroductionNodeJS: an Introduction
NodeJS: an Introduction
Roberto Casadei
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
Dinesh U
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
Jackson Tian
 
C++からWebRTC (DataChannel)を利用する
C++からWebRTC (DataChannel)を利用するC++からWebRTC (DataChannel)を利用する
C++からWebRTC (DataChannel)を利用する
祐司 伊藤
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
cacois
 

What's hot (20)

COSCUP - Fleet
COSCUP - FleetCOSCUP - Fleet
COSCUP - Fleet
 
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
 
Use MQTT in Docker on Raspberry Pi
Use MQTT in Docker on Raspberry PiUse MQTT in Docker on Raspberry Pi
Use MQTT in Docker on Raspberry Pi
 
Future of NodeJS
Future of NodeJSFuture of NodeJS
Future of NodeJS
 
Introduction to Tensorflow.js
Introduction to Tensorflow.jsIntroduction to Tensorflow.js
Introduction to Tensorflow.js
 
Web of Technologies
Web of TechnologiesWeb of Technologies
Web of Technologies
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
 
Nodejs intro
Nodejs introNodejs intro
Nodejs intro
 
Super combinators
Super combinatorsSuper combinators
Super combinators
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.
 
Kraken js at paypal
Kraken js at paypalKraken js at paypal
Kraken js at paypal
 
Les nouveautés de C# 7
Les nouveautés de C# 7Les nouveautés de C# 7
Les nouveautés de C# 7
 
Node ppt
Node pptNode ppt
Node ppt
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
NodeJS: an Introduction
NodeJS: an IntroductionNodeJS: an Introduction
NodeJS: an Introduction
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
 
C++からWebRTC (DataChannel)を利用する
C++からWebRTC (DataChannel)を利用するC++からWebRTC (DataChannel)を利用する
C++からWebRTC (DataChannel)を利用する
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 

Viewers also liked

メタプログラミングでExcel仕様書よさらば
メタプログラミングでExcel仕様書よさらばメタプログラミングでExcel仕様書よさらば
メタプログラミングでExcel仕様書よさらば
Kouji Matsui
 
Nespのコード生成
Nespのコード生成Nespのコード生成
Nespのコード生成
Kouji Matsui
 
山椒の味は大人の味
山椒の味は大人の味山椒の味は大人の味
山椒の味は大人の味
Kouji Matsui
 
真Intermediate languageのキホン
真Intermediate languageのキホン真Intermediate languageのキホン
真Intermediate languageのキホン
Kouji Matsui
 
抽象太郎ものがたり そして伝説へ
抽象太郎ものがたり そして伝説へ抽象太郎ものがたり そして伝説へ
抽象太郎ものがたり そして伝説へ
Kouji Matsui
 
Hello! intermediate language
Hello! intermediate languageHello! intermediate language
Hello! intermediate language
Kouji Matsui
 
式の体を成して無い式を式の体を成すように式と式木で何とかする式
式の体を成して無い式を式の体を成すように式と式木で何とかする式式の体を成して無い式を式の体を成すように式と式木で何とかする式
式の体を成して無い式を式の体を成すように式と式木で何とかする式
Kouji Matsui
 

Viewers also liked (7)

メタプログラミングでExcel仕様書よさらば
メタプログラミングでExcel仕様書よさらばメタプログラミングでExcel仕様書よさらば
メタプログラミングでExcel仕様書よさらば
 
Nespのコード生成
Nespのコード生成Nespのコード生成
Nespのコード生成
 
山椒の味は大人の味
山椒の味は大人の味山椒の味は大人の味
山椒の味は大人の味
 
真Intermediate languageのキホン
真Intermediate languageのキホン真Intermediate languageのキホン
真Intermediate languageのキホン
 
抽象太郎ものがたり そして伝説へ
抽象太郎ものがたり そして伝説へ抽象太郎ものがたり そして伝説へ
抽象太郎ものがたり そして伝説へ
 
Hello! intermediate language
Hello! intermediate languageHello! intermediate language
Hello! intermediate language
 
式の体を成して無い式を式の体を成すように式と式木で何とかする式
式の体を成して無い式を式の体を成すように式と式木で何とかする式式の体を成して無い式を式の体を成すように式と式木で何とかする式
式の体を成して無い式を式の体を成すように式と式木で何とかする式
 

Similar to Beachhead implements new opcode on CLR JIT

learning STM -32
learning STM -32 learning STM -32
learning STM -32
SeoTechnoscripts
 
STM -32
STM -32STM -32
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWERContinuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Indrajit Poddar
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
George Papaioannou
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
corehard_by
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
Paris Android User Group
 
英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug
英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug
英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug
Wang Hao Lee
 
Kotlin The Whole Damn Family
Kotlin The Whole Damn FamilyKotlin The Whole Damn Family
Kotlin The Whole Damn Family
Garth Gilmour
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013
Kevin Munc
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building Blocks
Max Kleiner
 
1_International_Google_CoLab_20220307.pptx
1_International_Google_CoLab_20220307.pptx1_International_Google_CoLab_20220307.pptx
1_International_Google_CoLab_20220307.pptx
FEG
 
Monkey space 2013
Monkey space 2013Monkey space 2013
Monkey space 2013
Miguel de Icaza
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
maznabili
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
A-Tech and Software Development
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
Jérôme Petazzoni
 
Conan.io - The C/C++ package manager for Developers
Conan.io - The C/C++ package manager for DevelopersConan.io - The C/C++ package manager for Developers
Conan.io - The C/C++ package manager for Developers
Uilian Ries
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An Introduction
POSSCON
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
ondrejbalas
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
biicode
 
New Features Webinar-April
New Features Webinar-AprilNew Features Webinar-April
New Features Webinar-April
Codefresh
 

Similar to Beachhead implements new opcode on CLR JIT (20)

learning STM -32
learning STM -32 learning STM -32
learning STM -32
 
STM -32
STM -32STM -32
STM -32
 
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWERContinuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
 
英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug
英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug
英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug
 
Kotlin The Whole Damn Family
Kotlin The Whole Damn FamilyKotlin The Whole Damn Family
Kotlin The Whole Damn Family
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building Blocks
 
1_International_Google_CoLab_20220307.pptx
1_International_Google_CoLab_20220307.pptx1_International_Google_CoLab_20220307.pptx
1_International_Google_CoLab_20220307.pptx
 
Monkey space 2013
Monkey space 2013Monkey space 2013
Monkey space 2013
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
 
Conan.io - The C/C++ package manager for Developers
Conan.io - The C/C++ package manager for DevelopersConan.io - The C/C++ package manager for Developers
Conan.io - The C/C++ package manager for Developers
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An Introduction
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
New Features Webinar-April
New Features Webinar-AprilNew Features Webinar-April
New Features Webinar-April
 

More from Kouji Matsui

パターンでわかる! .NET Coreの非同期処理
パターンでわかる! .NET Coreの非同期処理パターンでわかる! .NET Coreの非同期処理
パターンでわかる! .NET Coreの非同期処理
Kouji Matsui
 
Making archive IL2C #6-55 dotnet600 2018
Making archive IL2C #6-55 dotnet600 2018Making archive IL2C #6-55 dotnet600 2018
Making archive IL2C #6-55 dotnet600 2018
Kouji Matsui
 
Matrix signal controller and BrainPad overview
Matrix signal controller and BrainPad overviewMatrix signal controller and BrainPad overview
Matrix signal controller and BrainPad overview
Kouji Matsui
 
Fun with BrainPad
Fun with BrainPadFun with BrainPad
Fun with BrainPad
Kouji Matsui
 
What's Functional?
What's Functional?What's Functional?
What's Functional?
Kouji Matsui
 
Pitfall for WioLTE
Pitfall for WioLTEPitfall for WioLTE
Pitfall for WioLTE
Kouji Matsui
 
How to make the calculator
How to make the calculatorHow to make the calculator
How to make the calculator
Kouji Matsui
 
Write common, run anywhere
Write common, run anywhereWrite common, run anywhere
Write common, run anywhere
Kouji Matsui
 
Locality of Reference
Locality of ReferenceLocality of Reference
Locality of Reference
Kouji Matsui
 
C#でわかる こわくないMonad
C#でわかる こわくないMonadC#でわかる こわくないMonad
C#でわかる こわくないMonad
Kouji Matsui
 
You will be assimilated. Resistance is futile.
You will be assimilated. Resistance is futile.You will be assimilated. Resistance is futile.
You will be assimilated. Resistance is futile.
Kouji Matsui
 
How to meets Async and Task
How to meets Async and TaskHow to meets Async and Task
How to meets Async and Task
Kouji Matsui
 
Async deepdive before de:code
Async deepdive before de:codeAsync deepdive before de:code
Async deepdive before de:code
Kouji Matsui
 
Thread affinity and CPS
Thread affinity and CPSThread affinity and CPS
Thread affinity and CPS
Kouji Matsui
 
Async DeepDive basics
Async DeepDive basicsAsync DeepDive basics
Async DeepDive basics
Kouji Matsui
 
continuatioN Linking
continuatioN LinkingcontinuatioN Linking
continuatioN Linking
Kouji Matsui
 
.NET Coreから概観する.NETのOSSへの取り組み
.NET Coreから概観する.NETのOSSへの取り組み.NET Coreから概観する.NETのOSSへの取り組み
.NET Coreから概観する.NETのOSSへの取り組み
Kouji Matsui
 
Win32 APIをてなずけよう
Win32 APIをてなずけようWin32 APIをてなずけよう
Win32 APIをてなずけよう
Kouji Matsui
 
不健康なIt戦士を健康的にするアレの話
不健康なIt戦士を健康的にするアレの話不健康なIt戦士を健康的にするアレの話
不健康なIt戦士を健康的にするアレの話
Kouji Matsui
 
Final LINQ extensions III
Final LINQ extensions IIIFinal LINQ extensions III
Final LINQ extensions III
Kouji Matsui
 

More from Kouji Matsui (20)

パターンでわかる! .NET Coreの非同期処理
パターンでわかる! .NET Coreの非同期処理パターンでわかる! .NET Coreの非同期処理
パターンでわかる! .NET Coreの非同期処理
 
Making archive IL2C #6-55 dotnet600 2018
Making archive IL2C #6-55 dotnet600 2018Making archive IL2C #6-55 dotnet600 2018
Making archive IL2C #6-55 dotnet600 2018
 
Matrix signal controller and BrainPad overview
Matrix signal controller and BrainPad overviewMatrix signal controller and BrainPad overview
Matrix signal controller and BrainPad overview
 
Fun with BrainPad
Fun with BrainPadFun with BrainPad
Fun with BrainPad
 
What's Functional?
What's Functional?What's Functional?
What's Functional?
 
Pitfall for WioLTE
Pitfall for WioLTEPitfall for WioLTE
Pitfall for WioLTE
 
How to make the calculator
How to make the calculatorHow to make the calculator
How to make the calculator
 
Write common, run anywhere
Write common, run anywhereWrite common, run anywhere
Write common, run anywhere
 
Locality of Reference
Locality of ReferenceLocality of Reference
Locality of Reference
 
C#でわかる こわくないMonad
C#でわかる こわくないMonadC#でわかる こわくないMonad
C#でわかる こわくないMonad
 
You will be assimilated. Resistance is futile.
You will be assimilated. Resistance is futile.You will be assimilated. Resistance is futile.
You will be assimilated. Resistance is futile.
 
How to meets Async and Task
How to meets Async and TaskHow to meets Async and Task
How to meets Async and Task
 
Async deepdive before de:code
Async deepdive before de:codeAsync deepdive before de:code
Async deepdive before de:code
 
Thread affinity and CPS
Thread affinity and CPSThread affinity and CPS
Thread affinity and CPS
 
Async DeepDive basics
Async DeepDive basicsAsync DeepDive basics
Async DeepDive basics
 
continuatioN Linking
continuatioN LinkingcontinuatioN Linking
continuatioN Linking
 
.NET Coreから概観する.NETのOSSへの取り組み
.NET Coreから概観する.NETのOSSへの取り組み.NET Coreから概観する.NETのOSSへの取り組み
.NET Coreから概観する.NETのOSSへの取り組み
 
Win32 APIをてなずけよう
Win32 APIをてなずけようWin32 APIをてなずけよう
Win32 APIをてなずけよう
 
不健康なIt戦士を健康的にするアレの話
不健康なIt戦士を健康的にするアレの話不健康なIt戦士を健康的にするアレの話
不健康なIt戦士を健康的にするアレの話
 
Final LINQ extensions III
Final LINQ extensions IIIFinal LINQ extensions III
Final LINQ extensions III
 

Recently uploaded

Tour and travel website management in odoo,
Tour and travel website management in odoo,Tour and travel website management in odoo,
Tour and travel website management in odoo,
Axis Technolabs
 
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDSAmadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
aadhiyaeliza
 
07. Ruby String Slides - Ruby Core Teaching
07. Ruby String Slides - Ruby Core Teaching07. Ruby String Slides - Ruby Core Teaching
07. Ruby String Slides - Ruby Core Teaching
quanhoangd129
 
Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)
andrehoraa
 
GT degree offer diploma Transcript
GT degree offer diploma TranscriptGT degree offer diploma Transcript
GT degree offer diploma Transcript
attueb
 
當測試開始左移
當測試開始左移當測試開始左移
當測試開始左移
Jersey (CHE-PING) Su
 
B.Sc. Computer Science Department PPT 2024
B.Sc. Computer Science Department PPT 2024B.Sc. Computer Science Department PPT 2024
B.Sc. Computer Science Department PPT 2024
vmsdeptcom
 
Private Girls Call Navi Mumbai 🛵🚡9820252231 💃 Choose Best And Top Girl Servic...
Private Girls Call Navi Mumbai 🛵🚡9820252231 💃 Choose Best And Top Girl Servic...Private Girls Call Navi Mumbai 🛵🚡9820252231 💃 Choose Best And Top Girl Servic...
Private Girls Call Navi Mumbai 🛵🚡9820252231 💃 Choose Best And Top Girl Servic...
902basic
 
How to Secure Your Kubernetes Software Supply Chain at Scale
How to Secure Your Kubernetes Software Supply Chain at ScaleHow to Secure Your Kubernetes Software Supply Chain at Scale
How to Secure Your Kubernetes Software Supply Chain at Scale
Anchore
 
Hotel Management Software Development Company
Hotel Management Software Development CompanyHotel Management Software Development Company
Hotel Management Software Development Company
XongoLab Technologies LLP
 
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdfA Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
kalichargn70th171
 
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
rachitkumar09887
 
02. Ruby Basic slides - Ruby Core Teaching
02. Ruby Basic slides - Ruby Core Teaching02. Ruby Basic slides - Ruby Core Teaching
02. Ruby Basic slides - Ruby Core Teaching
quanhoangd129
 
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
jealousviolet
 
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing ToolsOld Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Benjamin Bischoff
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
bhumivarma35300
 
Mumbai Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service A...
Mumbai Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service A...Mumbai Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service A...
Mumbai Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service A...
3610stuck
 
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
singhlata50dh
 
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
45unexpected
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
attueb
 

Recently uploaded (20)

Tour and travel website management in odoo,
Tour and travel website management in odoo,Tour and travel website management in odoo,
Tour and travel website management in odoo,
 
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDSAmadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
 
07. Ruby String Slides - Ruby Core Teaching
07. Ruby String Slides - Ruby Core Teaching07. Ruby String Slides - Ruby Core Teaching
07. Ruby String Slides - Ruby Core Teaching
 
Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)
 
GT degree offer diploma Transcript
GT degree offer diploma TranscriptGT degree offer diploma Transcript
GT degree offer diploma Transcript
 
當測試開始左移
當測試開始左移當測試開始左移
當測試開始左移
 
B.Sc. Computer Science Department PPT 2024
B.Sc. Computer Science Department PPT 2024B.Sc. Computer Science Department PPT 2024
B.Sc. Computer Science Department PPT 2024
 
Private Girls Call Navi Mumbai 🛵🚡9820252231 💃 Choose Best And Top Girl Servic...
Private Girls Call Navi Mumbai 🛵🚡9820252231 💃 Choose Best And Top Girl Servic...Private Girls Call Navi Mumbai 🛵🚡9820252231 💃 Choose Best And Top Girl Servic...
Private Girls Call Navi Mumbai 🛵🚡9820252231 💃 Choose Best And Top Girl Servic...
 
How to Secure Your Kubernetes Software Supply Chain at Scale
How to Secure Your Kubernetes Software Supply Chain at ScaleHow to Secure Your Kubernetes Software Supply Chain at Scale
How to Secure Your Kubernetes Software Supply Chain at Scale
 
Hotel Management Software Development Company
Hotel Management Software Development CompanyHotel Management Software Development Company
Hotel Management Software Development Company
 
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdfA Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
 
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
 
02. Ruby Basic slides - Ruby Core Teaching
02. Ruby Basic slides - Ruby Core Teaching02. Ruby Basic slides - Ruby Core Teaching
02. Ruby Basic slides - Ruby Core Teaching
 
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
 
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing ToolsOld Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
 
Mumbai Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service A...
Mumbai Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service A...Mumbai Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service A...
Mumbai Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service A...
 
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
 
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
 

Beachhead implements new opcode on CLR JIT

  • 1. Beachhead implements new opcode on CLR JIT .NET FRINGE JAPAN 2016 KOUJI MATSUI (@KEKYO2)
  • 2. 2 Kouji Matsui - kekyo • NAGOYA city, AICHI pref., JP • Twitter – @kekyo2 / Facebook • ux-spiral corporation • Microsoft Most Valuable Professional VS and DevTech 2015- • Certified Scrum master / Scrum product owner • Center CLR organizer. • .NET/C#/F#/IL/metaprogramming or like… • Bike rider CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 3. 3 You can beginning hack: “CoreCLR” CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 4. 4 Agenda • Introduction / Background • How to build coreclr/corefx • Add custom IL opcode • Deep-dive CLR JIT • Verify custom IL opcode to work • Conclusion CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 5. 5 Introduction / Background • .NET Core is open-sourced!! • Become clearing the .NET internal implementations. • .NET Framework noeq .NET Core, but very interesting internal implements anythings… CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 6. 6 Introduction / Background • I am joining .NET Fringe Japan organizer teams. And thinking what about speaks first conference… • Roslyn and corefx already exploring and explaining any people (in Japan) … Hmm. • If can add custom IL opcode and build custom CLR ? Fun, interesting and understanding internal CoreCLR ! :) CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 7. 7 How to build coreclr/corefx • Development and test bench requirements: • Windows 10 x64 • Visual Studio 2015 Update 3 (Using C++ compiler) • CMake 3.6.2 (Multiplatform building tool) https://cmake.org/ • Python 3.5.2 https://www.python.org/ • Official docs: “Building and running tests on Windows” https://github.com/dotnet/coreclr/blob/master/Documentat ion/building/windows-test-instructions.md CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 8. 8 How to build coreclr/corefx • Test summary: 1. Get source codes from GitHub dotnet/coreclr, corefx. • git clone https://github.com/dotnet/coreclr • git clone https://github.com/dotnet/corefx 2. Build coreclr and corefx. • Run build.cmd both coreclr and corefx. CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 9. 9 How to build coreclr/corefx 3. Test running minimum sample code using coreclr/corefx. • Copy System.Runtime.dll and some assemblies from corefx into coreclr. • Compile the C# Hello world code using VS2015 C# compiler (csc.exe), with /nostdlib /r:System.Runtime.dll and another strict options. • Run the code, “CoreRun.exe Program.exe” Need more informations? see documents previous links. CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 10. 10 How to build coreclr/corefx •TIPS!!! • Must use stable version commits for coreclr and corefx! • They are developing continuously and worldwide, 10 or more commits/day. • Hint: Look for CI status on GitHub coreclr/corefx page. https://github.com/dotnet/coreclr https://github.com/dotnet/corefx CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 11. 11 CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 12. 12 • This is just beginning :) • Suggest first step: Very simple spec opcode: • Opcode name: “customcode” • No operand, no IL stack consume/produce. • Use opcode: affect output demonstration string to Windows Debug log. (Use Win32 API “OutputDebugStringW”) Add custom IL opcode CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 13. 13 • Debug log can capture use Sysinternals DebugView utility. https://technet.microsoft.com/en- us/sysinternals/debugview.aspx Add custom IL opcode CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 14. 14 Add custom IL opcode • Thinking what currently declared opcode for completely nothing input/output and no side-effect in CLR ? CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 15. 15 Add custom IL opcode • ex: Opcode “break” – Break execution the attached debugger current position. https://msdn.microsoft.com/en- us/library/system.reflection.emit.opcodes.break(v=vs.110).aspx • “Debugger break” means raise interruption native CPU (x64), such as “DebugBreak” API or “__debugbreak” intrinsic. • So, maybe contains invoke these API in coreclr source codes. I can find related code easier, try using base for this opcode… CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 16. 16 Add custom IL opcode • Grep special-like or unique naming opcode in coreclr: ex: “initobj”, “ldftn” etc… --> Opcodes declared in src/inc/opcode.def by OPDEF() macro. • Opcode break: “CEE_BREAK” OPDEF(CEE_BREAK, "break", Pop0, Push0, InlineNone, IPrimitive, 1, 0xFF, 0x01, BREAK) • Add “CEE_CUSTOMCODE” for last opcode “CEE_UNUSED70”’s next: OPDEF(CEE_CUSTOMCODE, “customcode", Pop0, Push0, InlineNone, IPrimitive, 2, 0xFE, 0x23, NEXT) New 2 words opcode: fe,23 Instruction move hint: “NEXT” is execute next opcode. (Standard behavior) No stack consume/produce CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 17. 17 Deep-dive CLR JIT •Oh, I’m just declared new opcode “customcode” now!! :) •But this opcode used no coreclr runtime… Require giving new opcode behavior MANUALLY CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 18. 18 Compiler-Importer JIT_CustomCode()JIT Deep-dive CLR JIT •How interpret opcodes in coreclr: Assembly file: MSIL section Parse Call OutputDebugStringW() Parse IL opcodes GTNODE Call Peek from JIT helper function pointer table. Internal IL stream tree structures CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 19. 19 Deep-dive CLR JIT • Compiler-Importer (src/jit/importer.cpp) is IL opcode stream parser use declaring CEE_* macros. • CEE_BREAK case example: case CEE_BREAK: op1 = gtNewHelperCallNode(CORINFO_HELP_USER_BREAKPOINT, TYP_VOID); goto SPILL_APPEND; • “gtNewHelperCallNode” is construction GTNODE internal tree structure node for invoke JIT helper function. • “CORINFO_HELP_USER_BREAKPOINT” is JIT helper function index symbol. CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 20. 20 Deep-dive CLR JIT • “CORINFO_HELP_USER_BREAKPOINT” declared in src/inc/corinfo.h: • Symbol declared in “enum CorInfoHelpFunc”. Because JIT helper functions management by function pointer table. This table size calculated from enum symbols count. • And src/inc/jithelper.h: JITHELPER(CORINFO_HELP_USER_BREAKPOINT, JIT_UserBreakpoint, CORINFO_HELP_SIG_REG_ONLY) REAL helper function name CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 21. 21 Deep-dive CLR JIT • Add “CORINFO_HELP_CUSTOMCODE” into CorInfoHelpFunc and provide JIT helper function information by JITHELPER() macro. JITHELPER(CORINFO_HELP_CUSTOMCODE, JIT_CustomCode, CORINFO_HELP_SIG_REG_ONLY) • Back to Importer and add “CEE_CUSTOMCODE” handler: case CEE_CUSTOMCODE: op1 = gtNewHelperCallNode(CORINFO_HELP_CUSTOMCODE, TYP_VOID); goto SPILL_APPEND; • “TYP_VOID” is hold opcode value type (ex: operand type). “customcode” opcode hold no value, so this ID is TYP_VOID. • Importer done! New JIT helper function name CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 22. 22 Deep-dive CLR JIT • Implement JIT helper function “JIT_CustomCode”: HCIMPL0(void, JIT_CustomCode) { FCALL_CONTRACT; HELPER_METHOD_FRAME_BEGIN_NOPOLL(); ::OutputDebugStringW(L"Triggered custom code!!!!!!! (for JIT)"); HELPER_METHOD_FRAME_END_POLL(); } HCIMPLEND • HCIMPL0(), FCALL_CONTRACT, HELPER_METHOD_FRAME_BEGIN_NOPOLL(), HELPER_METHOD_FRAME_END_POLL() macros are required for construct hard-coded low level prologue/epilogue codes JIT helper functions. • JIT helper function done!! THIS IS CORE CODE!! CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 23. 23 Deep-dive CLR JIT • Anything done ? • More two non-important points: 1. Implement interpreter-based code. Interpreter is src/vm/interpreter.cpp. • But Windows-x64 environments nothing to use interpreter, all situation works only use JIT. 2. ILFormatter (src/utilcode/ilformatter.cpp). • Format printer-friendly string from IL opcode. But default implementation is printing uses CEE_* macro information, this session’s custom code is not required. CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 24. 24 CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 25. 25 Verify custom IL opcode to work • OK, ready to run… How? • The “customcode” IL opcode can work with CLR now, but how to generate “customcode” contained assembly?? Manually paching with BINARY EDITOR…?? (; ゚Д゚) This is TOP SECRET: I fogot IMAGE_DOS_HEADER, IMAGE_FILE_HEADER, IMAGE_NT_HEADER, IMAGE_OPTIONAL_HEADER, IMAGE_DATA_DIRECTORY, IMAGE… CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 26. 26 Verify custom IL opcode to work • Thinking about more easy construction: 1. Compile standard C# sample code by .NET Core 1.0. 2. Use “ildasm” to disassembled. 3. Insert “customcode” opcode into disassembled IL source code. 4. Use custom-opcode enabled “idasm” to build new assembly. • The “ilasm” and “ildasm” are built with coreclr. New opcodes can handling from “opcode.def” automatically. CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 27. 27 Verify custom IL opcode to work • Bootstrap test code in C#: Generate template code from “dotnet new” command and simplied: namespace ConsoleApplication { public static class Program { public static void Main(string[] args) { } } } • Compile: • dotnet restore • dotnet build • Storing compiled assembly: bin¥Debug¥netcoreapp1.0¥addil.dll CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 28. 28 Verify custom IL opcode to work • Disassembling: • ..¥ildasm.exe bin¥Debug¥netcoreapp1.0¥addil.dll > addil.il • Fixed attributes for referenced System.Runtime: .assembly extern System.Runtime { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:2:0:0 } Fix pubkey token and version similer to your local built corefx binaries if different. CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 29. 29 Verify custom IL opcode to work • Insert “customcode” opcode into Main method body: .method public hidebysig static void Main(string[] args) cil managed { .entrypoint .maxstack 8 IL_0000: nop customcode IL_0001: ret } Insert “customcode” opcode!! CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 30. 30 Verify custom IL opcode to work • Assemble by customcode-enabled “ilasm”: • ..¥ilasm.exe Program.il Success with nothing error. If use official ilasm.exe, will cause error: “syntax error at token ‘ret’” CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 31. 31 Verify custom IL opcode to work • Run the assembly and verify with DebugView: • Before execute DbgView.exe • ..¥CoreRun.exe Program.exe CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 32. 32 CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 33. 33 Conclusion • Custom IL opcode declare and implement: • Declare opcode into opcode.def with OPDEF() macro. • Declare JIT helper function into corinfo.h and jithelper.h with JITHELPER() macro. • Implement JIT helper function with HCIMPL() macros. • Implement custom opcode handler into Compile-Importer. CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 34. 34 Conclusion • Verification: • Generate IL codes from disassembled C# codes with “ildasm.” (Or, write from scratch IL codes…) • Using custom-opcode enabled “ilasm” to generate final binary. CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 35. 35 Conclusion • coreclr is truly OSS: Custom IL opcode can implements with average difficulity. • This session explain with constraints “No operand, No stack consume/produce opcode.” Maybe more hard work for intermediate usage opcode design… • But YOU CAN DO THAT!! • This session’s demonstration code: • https://github.com/kekyo/coreclr git branch:addil CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI
  • 36. 36 Thank you joining my session!! • Become slides on slideshare and my blog entry. http://www.kekyo.net/ (Sorry blog only Japanese language) • My twitter account @kekyo2, follow <3 • GitHub https://github.com/kekyo/ contains: • FusionTasks, RelaxVersioner, fscx and more… • Open conference with “Center CLR” in Aichi pref., Japan! Join us!! https://www.meetup.com/en-US/CenterCLR/ CC-BY-SA 4.0 COPYRIGHT (C) 2016 KOUJI MATSUI