Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SwiftとCPUレジスタ
Search
rikusouda
June 24, 2019
Technology
2
620
SwiftとCPUレジスタ
rikusouda
June 24, 2019
Tweet
Share
More Decks by rikusouda
See All by rikusouda
Swiftのスタック変数とCPUレジスタの関係を読み解いた
rikusouda
2
2.3k
OSSを育てながらiOSアプリでパンくずリストを実現した
rikusouda
2
5.1k
fastlaneはともだち こわくないよ
rikusouda
1
950
Other Decks in Technology
See All in Technology
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
550
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
670
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
170
Server-Side Engineer of LINE Sukimani
lycorp_recruit_jp
0
360
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
160
能動的ドメイン名ライフサイクル管理のすゝめ / Practice on Active Domain Name Lifecycle Management
nttcom
0
240
事業貢献を考えるための技術改善の目標設計と改善実績 / Targeted design of technical improvements to consider business contribution and improvement performance
oomatomo
0
150
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
140
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.9k
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
2
120
ハイテク休憩
sat
PRO
2
180
AWS環境におけるランサムウェア攻撃対策の設計
nrinetcom
PRO
0
170
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
A better future with KSS
kneath
238
17k
Optimising Largest Contentful Paint
csswizardry
33
3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Code Reviewing Like a Champion
maltzj
521
39k
KATA
mclloyd
29
14k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Faster Mobile Websites
deanohume
305
30k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Transcript
SwiftͱCPUϨδελ 2019/06/24 YUMEMI.swift #1 @rikusouda
ࣗݾհ • @rikusouda (٢Ԭ༞थ) • גࣜձࣾGunosy • ϧʔτϏΞ͕͖ • WWDC19͕ॳWWDC
None
Swiftͱ CPUϨδελ
ͳͥWWDC͔ΒϨδελͷ? • WWDCʹLab͕͋ΔɻAppleͷΤϯδχΞ ʹ࣭͕Ͱ͖Δॴ • Swiftؔ࿈ͷLabߦ͖ͬͯͨ • ղܾͰ͖ͳ͔ͬͨ͜ͱ͕͋Γɺຊʹؼͬͯ ͖͔ͯΒࣗͰௐͨ
CPUϨδελͬͯԿ͚ͩͬ • ԋࢉ͢Δͱ͖ʹ͏࡞ۀྖҬ = ൚༻Ϩδελ • CPUͷ෦ʹ͋ͬͯɺϝΠϯϝϞϦΑΓܻҧ ͍ʹૣ͍ • ͨͩ͠ेݸͱ͔ɺ͕ݶΒΕ͍ͯΔ
• Ϩδελʹͳ͍σʔλΛԋࢉ͢Δͱ͖ϝΠϯ ϝϞϦ͔ΒҰ୴ϩʔυ͢Δ
ࡐͷSwiftίʔυ
͜͏͍͏ܕͷม ʮελοΫͷϝϞϦྖҬʹ֬อ ͞ΕΔʯͱ͍͏ͷ༗໊ ࡐͷSwiftίʔυ
ϝΠϯϝϞϦΘͣʹϨδελ ͚ͩͬͨ΄͏͕ޮΑ͘ͳ͍ ͦ͏ͳ͍ͬͯΔ ࡐͷSwiftίʔυ
LabͰฉ͍ͯΈͨ • SwiftͷLabʹͯ • A. SwiftίϯύΠϥνʔϜͰ୲͍ͯ͠ͳ͍ൣғɻ LLVMͷਓʹฉ͘ͱΑͦ͞͏ • LLVMͷLabʹͯ •
A. SwiftΘ͔Βͳ͍ɻCݴޠͩͱ͢ΔͱYesɻLLVM IRͱ͔ΞηϯϒϥಡΉͱ͍Ζ͍ΖΘ͔ͬͯ໘ന͍Α
LLVM IRͱΞηϯϒϥͱ http://llvm.org/devmtg/2015-10/slides/GroffLattner-SILHighLevelIR.pdf
LLVM IRͱΞηϯϒϥͱ http://llvm.org/devmtg/2015-10/slides/GroffLattner-SILHighLevelIR.pdf
LLVM IRݟͯΈΑ͏
Swiftίʔυ
swiftc -emit-ir -O test.swift > test.ll ௨ৗɺϦϦʔεϏϧυ࠷ద Խ͢ΔͷͰಉ༷ʹ࠷దԽ
None
࠷దԽ͞Ε͗͢!!
Swiftίʔυ
Swiftίʔυ ϝιουͷࢀরܦ༝ͷݺͼग़͠ʹ͠ ͯؔίʔϧ͕ͳ͘ͳΔͷΛආ͚Δ
swiftc -emit-ir -O test.swift > test.ll
LLVM IRίʔυ(barؔ)
LLVM IRίʔυ(barؔ) ͷؔΛίʔϧ݁͠ՌΛ GPPؔͷϙΠϯλ͕ʹೖ͍ͬͯΔ
LLVM IRίʔυ(barؔ) ʹΛͯ͠ɺΓΛʹ
LLVM IRίʔυ(barؔ) !MMWNTBEEXJUIPWFSqPXJͷΓ ߏମ͔Βܭࢉ݁ՌΛऔΓग़͠ɺ ͦΕΛΓͱͯ͠SFUVSO
Α͛͞
೦ͷҝΞηϯϒϥݟΑ͏ iPhoneΛఆ͠ARM64Ͱ
xcrun -sdk iphoneos swiftc - emit-assembly -O -target arm64- apple-ios12.0
test.swift > test.s ͜ͷίϚϯυ͕ϕετͳͷ͔ ࣗ৴͕ͳ͍ͷͰϚαΧϦืू
ARM64ͷ Ξηϯϒϥ
None
Y ΛҾͱͯ͠YʹඈͿ YʹGPPͷΞυϨε͕ೖ͍ͬͯΔ
Γ Y ΛYʹίϐʔ
YY ϨδελͱϦςϥϧͷՃࢉ ϝϞϦΞΫηεͳ͠
YΛΓͱͯ͠SFUVSO
SwiftͷؔͷInt ϨδελͰ͍݁ͯͨ͠
͜Ε͔Β • LLVMίʔυΛݟͯཪ͚͕Ͱ͖͍ͯͳ͍ͷͰ Γ͍ͨ • ↑͜͜·ͰͬͯiOSDCͷLTͰΓ͍ͨ
ϓϩϙʔβϧʹελʔ͍ͩ͘͞ • SwiftͷελοΫมͱCPUϨδελͷؔΛಡΈղ͍ͨ • https://fortee.jp/iosdc-japan-2019/proposal/ c2a89fff-ce66-4821-b2d4-4b7b6ff293d5 • SwiftͷࣝΛͬͯC++ͷੈքʹඈͼࠐ͏ • https://fortee.jp/iosdc-japan-2019/proposal/
c39e331a-8c70-42ef-b58e-38f798f40295 • “rikusouda”Ͱݕࡧ͢Εग़͖ͯ·͢
·ͱΊ • Swiftͷ෦ಈ࡞ΛΓ͍ͨ߹தؒίʔυ ΛಡΉ͚ͩͰ݁ߏ͔Δɻ • ໋ྩͷ༷ͱ͔άάΕ݁ߏಡΊΔ • ίϯύΠϥͷࣝͳͯ͘͜͜·Ͱߦ͚Δ • SwiftͷIntɺҰൠతʹ࠷దԽ͋ΓͳΒϨδ
ελͰ݁͢Δ͜ͱ͕Θ͔ͬͨ
None