Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ARC vs. GC?ARC in GC?

ARC vs. GC?ARC in GC?

Shigure Shimotori

September 16, 2017
Tweet

More Decks by Shigure Shimotori

Other Decks in Programming

Transcript

  1. iOSDC JAPAN 2017 #1349
    ARC vs. GCʁARC in GCʁ
    @S_Shimotori

    View full-size slide

  2. ͩΕʁ
    • @S_Shimotori / @S_Shimotori_pub
    • ϞϥτϦΞϜ ֶੜ
    • Swift͕޷͖ͳͷͰSwiftΛॻ͍͍ͯ·͢
    • SPMΛ΍ͬͨΓiOSΛ΍ͬͨΓ͠·͢

    View full-size slide

  3. ARC vs. GC
    ʘŲōŘŕ!!ʗ

    View full-size slide

  4. ਓྨ͸ARCͱGCΛൺֱ͕ͪ͠
    • GCΛ΍ΊͯARCʹ͠·͢ - Apple Guides and Sample Code[1]
    • ARCͱGCͷҧ͍ͬͯͳʹ - Stack Overflow[2]
    • ARC͔ΒGCʹม͑ͨ΄͏͕͍͍Μ͡Όͳ͍ͷ - Swift evolution[3]
    [1] https://developer.apple.com/library/content/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html
    [2] https://stackoverflow.com/questions/7874342/what-is-the-difference-between-objective-c-automatic-reference-counting-and-garb
    [3] https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160208/009403.html
    4

    View full-size slide

  5. • ͋ͷJVM͕࠾༻ͨ͠ϝϞϦ؅ཧํ๏
    • ώʔϓྖҬΛෳ਺(youngྖҬͱoldྖҬͳͲ)ʹ෼͚ͯ࢖͏
    • youngྖҬ͔Βॱ൪ʹ࢖͍ͬͯ͘
    • શྖҬΛ࢖͍੾ͬͨ࣌ͷϑϧGC͕ා͍
    • JVMʹ͸ΨϕʔδίϨΫλ͕ෳ਺༻ҙ͞Ε͍ͯΔ
    • ༻్ʹ߹ͬͨΞϧΰϦζϜͷ΋ͷΛ࢖͏
    ΈΜͳେ޷͖ʮΨϕʔδίϨΫγϣϯʯ
    5
    ͦΕΛGCͬͯݴ͍͍ͬͯͷʁʁ

    View full-size slide

  6. ͜Ε͕ຊ౰ͷΨϕʔδίϨΫγϣϯʂ
    • ࣗಈͰෆཁͳΦϒδΣΫτΛ୳͠ϝϞϦΛղ์͢Δ
    • ϝϞϦղ์ͷλΠϛϯάΛߟ͑ͳͯ͘Α͍
    • ͍ͭͰʹϝϞϦྖҬΛ੔ཧ͢Δ͜ͱ΋͋Δ
    • ํ๏ͷҟͳΔ3छͷΨϕʔδίϨΫλ͕͋Δ
    • ࢀরΧ΢ϯτ
    • ϚʔΫΞϯυεΠʔϓ
    • ίϐʔGC
    • ୯ʹGCͱݺΜͩ৔߹͸τϨʔγϯάίϨΫλΛࢦ͢
    • JVMͷGC΋τϨʔγϯάίϨΫλͷҰछ(ੈ୅ผGC)
    } τϨʔγϯάίϨΫλ
    6

    View full-size slide

  7. ARC͸GCͱରཱ͢Δ͠

    GCͷҰछͰ΋͋Δ

    View full-size slide

  8. Cyclone/Rustͷ
    ॴ༗ݖϞσϧɼ
    ਅࣅͪ͠Ό͓͏

    View full-size slide

  9. ࠾༻͍ͯ͠ΔϝϞϦ؅ཧํ๏Ͱ ௒ͬ͘͟Γ Θ͚ͯΈͨ
    खಈ
    C
    ಈతࣗಈ
    (޿ٛͷGC)
    ࢀরΧ΢ϯτ
    τϨʔγϯάίϨΫλ(ڱٛͷGC)
    Swift/ObjC
    Java Ruby
    D
    ※ݴޠࣗ਎ʹGC͕ͳ͍΋ͷͰ΋ϥΠϒϥϦ͕࡞ΒΕ͍ͯΔ͜ͱ͕͋Δɽ
    ※ओʹ࢖͍ͬͯΔํ๏ͷΈͰ෼͚ͨͷͰʮ௒ͬ͘͟ΓʯɽCyclone΋GCΛ෦෼తʹ࢖͍ͬͯΔ͠ɼJava΋੩తղੳΛ͍ͯ͠Δɽ
    OCaml
    .NET
    C++
    LISP
    Pascal
    ੩తࣗಈ
    10
    Cyclone
    Python
    Rust

    View full-size slide

  10. CycloneͱRust͸
    ϝϞϦ؅ཧͷେઌഐʂ

    View full-size slide

  11. ·ͱΊ
    • ARC͸GCͱൺֱ͞ΕΔ͠ɼGCͷҰһͰ΋͋Δ
    • ޿ٛͷGCͱڱٛͷGCͰࢦ͍ͯ͠Δ΋ͷ͕ҧ͏
    • Cyclone΋Rust΋ϝϞϦ؅ཧ໰୊ʹऔΓ૊ΜͰ͖ͨେઌഐ
    • ઌഐݴޠͷऔΓ૊Έ͕ͱͯ΋ࢀߟʹͳΔ͔΋
    13

    View full-size slide

  12. ࢀߟจݙ
    • ΨϕʔδίϨΫγϣϯͱ͸ͳΜͧ΍ɽ
    • ൧໺୎ݟʰΨϕʔδίϨΫγϣϯͷ࣮૷๏ͱධՁʱɼ(ࢀর2017-09-11)ɽ
    • ԕ౻හ෉ʮҰൠڭཆͱͯ͠ͷGarbage Collection (ίϯύΠϥԋश൪֎ฤ)ʯɼ(ࢀর2017-09-11)ɽ
    • ΑͦͷݴޠͰͷϝϞϦ؅ཧઓུ
    • Scott Oaksஶ(2015)ʰJavaύϑΥʔϚϯεʱ຀໺૱༁ɼגࣜձࣾΦϥΠϦʔɾδϟύϯɽ
    • ੨໦ๆ࿠ʰRubyιʔείʔυ׬શղઆʱɼ(ࢀর2017-09-11)ɽ
    • OCamlʰΨϕʔδίϨΫγϣϯ – OCamlʱɼ(ࢀর2017-09-11)ɽ
    • MicrosoftʰGarbage Collectionʱɼ(ࢀর2017-09-11)ɽ
    • Jeffrey Richterஶ(2013)ʰϓϩάϥϛϯά .NET Framework ୈ4൛ʱ౻ݪ༤հ༁ɼ೔ܦBPࣾɽ
    • Digital MarsʰΨϕʔδίϨΫγϣϯ - ϓϩάϥϛϯάݴޠ D (೔ຊޠ༁)ʱɼ(ࢀর2017-09-11)ɽ
    • naruseʰRuby 2.2.0 ϦϦʔεʱɼ(ࢀর2017-09-11)ɽ
    • CycloneʰCyclone: User Manualʱɼ(ࢀর2017-09-12)ɽ
    • Robert C. Seacordஶ(2014)ʰC/C++ηΩϡΞίʔσΟϯά ୈ2൛ʱՎ୅࿨ਖ਼΄͔༁ɼגࣜձࣾKADOKAWAɽ
    • Richard Reeseஶ(2013)ʰৄઆ CϙΠϯλʱ٠஑জ༁ɼגࣜձࣾΦϥΠϦʔɾδϟύϯɽ
    • Pythonʰcpython/gcmodule.c at 2ebc5ce42a8a9e047e790aefbf9a94811569b2b6 · python/cpythonʱ2ebc5ce42a8a9e047e790aefbf9a94811569b2b6/Modules/gcmodule.c>ɼ(ࢀর2017-09-13)ɽ
    • Neil SchemenauerʰGarbage Collection for Pythonʱɼ(ࢀর2017-09-13)ɽ

    View full-size slide

  13. ࢀߟจݙ
    • Swiftͷߦ͘຤΍͍͔ʹɽ
    • Appleʰswift/OwnershipManifesto.md at fa2f2bd4577e536130f9298fabfd2960a357693c · apple/swiftʱfa2f2bd4577e536130f9298fabfd2960a357693c/docs/OwnershipManifesto.md>ɼ(ࢀর2017-09-11)ɽ
    • Appleʰswift-evolution/0176-enforce-exclusive-access-to-memory.md at b9d815099453912069998b579948a3319246042b · apple/swift-evolutionʱgithub.com/apple/swift-evolution/blob/b9d815099453912069998b579948a3319246042b/proposals/0176-enforce-exclusive-access-to-memory.md>ɼ(ࢀর
    2017-09-11)ɽ
    • Appleʰ [swift-evolution] RFC: Preventing Retain Cycles (Memory Ownership Model)ʱMon-20160725/025695.html>ɼ(ࢀর2017-09-12)ɽ
    • ૉࡐ
    • TopeconHeroesʰਧ͖ग़͠ૉࡐઐ໳αΠτʮϑΩμγσβΠϯʯʱɼ(ࢀর2017-09-11)ɽ

    View full-size slide

  14. εϥΠυʹࡌͤͳ͔ͬͨ࿩͚ͩͲಡΜͩΒ໘ന͍͔΋
    • ΋ͬͱGCΛษڧ͢Δ
    • ౦ژେֶ৘ใՊֶՊʰIndex of Compiler Resumeʱɼ(ࢀর2017-09-16)ɽ
    • ాӜ ݈࣍࿕ʮϓϩάϥϛϯάݴޠ 6 ΨϕʔδίϨΫγϣϯ(2)ʯadv.pdf>ɼ(ࢀর2017-09-16)ɽ
    • ੈͷதʹ͸·ͩͨ͘͞Μͷݴޠ͕͋Δ
    • garicchiʰComponent Object Model(COM)ͱ͸Կ͔ ·ͱΊΔ – garicchi.comʱɼ(ࢀর2017-09-13)ɽ
    • தౡେҰʰGolangͷGCΛ௥͏ | SOTAʱɼ(ࢀর2017-09-11)ɽ
    • ໦ຊ༟لʰPerlͷΨʔϕοδίϨΫγϣϯ(GC)ͷಛੑʹ͍ͭͯ - PerlͳΒαϯϓϧίʔυPerlೖ໳ʱɼ(ࢀর
    2017-09-11)ɽ
    • ໦ຊ༟لʰʮϦϑΝϨϯεΧ΢ϯτࣜͷGCʯ͸ɺITքͰ͸GCͱೝࣝ͞Ε͍ͯͳ͍ͷͩΖ͏͔? - Qiitaʱɼ(ࢀর
    2017-09-11)ɽ
    • ʰΨʔϕδίϨΫγϣϯ - ݴޠผGCͷ࢓૊Έ(31402)ʛteratailʱɼ(ࢀর2017-09-12)ɽ
    • SwiftͲ͏ͳΔͷ
    • খ໺ক೭ʰSwift 3ͷ։ൃͷৼΓฦΓͱSwift 4ͷܭը͕ه͞Εͨϝʔϧͷ঺հ - Qiitaʱɼ(ࢀর2017-09-12)ɽ
    • দؗେًʰSwift5ͷٞ࿦͕ελʔτ:ABIͷ҆ఆԽɺฒߦॲཧɺݴޠͷਐԽϓϩηεͷมߋ – Daiki Matsudate – Mediumʱswift5%E3%81%AE%E8%AD%B0%E8%AB%96%E3%81%8C%E3%82%B9%E3%82%BF%E3%83%BC%E3%83%88-
    abi%E3%81%AE%E5%AE%89%E5%AE%9A%E5%8C%96-%E4%B8%A6%E8%A1%8C%E5%87%A6%E7%90%86-
    %E8%A8%80%E8%AA%9E%E3%81%AE%E9%80%B2%E5%8C%96%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%81%AE%E5%A4%89%E6%9B%B4-6b6540
    acd6e4>ɼ(ࢀর2017-09-12)ɽ

    View full-size slide