PHPerKaigi 2019

218473ff7abad0fcd72865da2b23bb5b?s=47 memory
March 29, 2019

PHPerKaigi 2019

218473ff7abad0fcd72865da2b23bb5b?s=128

memory

March 29, 2019
Tweet

Transcript

  1. PHP Ͱ JVM ʹೖ໳͢Δ - ༧උ஌ࣝฤ - PHPerKaigi 2019 2019/03/29

    Ί΋Γʔ(@m3m0r7) લ ࠲
  2. ͩΕʁ Ί΋Γʔ(@m3m0r7) Ͱ͢ɻ ը૾͸ ϋϜελʔքͷఱ࢖ Lily ͪΌΜͰ͢ɻ ϫλγϋϐʔΤΠνϐʔνϣοτσΩϧ גࣜձࣾ GameWith

    ͱ͍͏ձࣾͰಇ͍ͯ·͢ɻ
  3. ༧උ஌ࣝฤͰ࿩͢͜ͱ લ ࠲

  4. ༧උ஌ࣝฤͰ࿩͢͜ͱ • 16ਐ਺ͷܭࢉํ๏ʹ͍ͭͯ • signed / unsgined ͳܕʹ͍ͭͯ • double

    ΍ float ͳͲͷුಈখ਺఺ͷܭࢉํ๏ʹ͍ͭͯ • ΤϯσΟΞϯʹ͍ͭͯ
  5. 16 ਐ਺ͷܭࢉํ๏ લ ࠲

  6. ܭࢉํ๏͝ଘ஌ͷํ✋ લ ࠲

  7. ͦ͏Ͱ͢Ͷɺ dechex / hexdec / base_convert ؔ਺Ͱ͢ લ ࠲

  8. ৑ஊͰ͢ લ ࠲

  9. 16ਐ਺ͷܭࢉํ๏ • 10ਐ਺͔Β16ਐ਺ͷܭࢉํ๏͸Լهͷࣜʹ౰ͯ͸ΊΒΕ·͢ 0xFF = (16 - 1) * 16^1

    + (16 - 1) * 16^0 = 255(10) 1ܻ໨͔Βܻ਺͕૿͑Δͨͼʹ1৐,2৐…N৐ͱ૿͍͖͑ͯ·͢ɻͭ·Γɺ0xFFFFͷ ৔߹͸ԼهͷΑ͏ʹͳΓ·͢ɻ 0xFFFF = (16 - 1) * 16^3 +(16 - 1) * 16^2 + (16 - 1) * 16^1 + (16 - 1) * 16^0 = 65535(10) 16͔Β1ΛҾ͍͍ͯΔͷ͸ɺ։࢝͢Δ਺ࣈ͕0͔Β࢝·ΔͨΊͰ͢ɻA͸10, B͸ 11, … F͸15ͱ֮͑ͯ͠·͍·͠ΐ͏ɻ
  10. 16ਐ਺ͷܭࢉํ๏ • PHPͰܭࢉ͢Δʹ͸ʁ ͜Μͳܭࢉਖ਼௚΍Γͨ͘ͳ͍ɻϓϩάϥϚςΟοΫʹղܾͰ͖ΔͳΒղܾ͢Δʹӽ ͨ͜͠ͱ͸ͳ͍Ͱ͢ɻ • 10ਐ਺͔Β16ਐ਺ʹ͢Δ <?= dechex(255) ?>

    • 16ਐ਺͔Β10ਐ਺ʹ͢Δ <?= hexdec(‘0xFF’) ?> <?= base_convert(255, 10, 16) ?> <?= base_convert(‘0xFF’, 16, 10) ?>
  11. ͱͬͯ΋؆୯Ͱ͢Ͷ લ ࠲

  12. signed / unsigned ͳܕʹ͍ͭͯ લ ࠲

  13. ͱ͜ΖͰɺPHPer ͷΈͳ͞Μ͕ ͝ଘ஌ͷܕ͸ԿͰ͠ΐ͏͔ લ ࠲

  14. JVM Ͱ͸ܕ͕૿͑·͢ લ ࠲

  15. PHP͔Βݟͯ૿͑ͨܕ • boolean • int (4 byte) • string •

    float • ࣮࣭ float ͷ double • byte (1 byte) • short (2 byte) • long (8 byte) • Ψν float (4 byte, ୯ਫ਼౓ුಈখ਺఺਺) • Ψν double (8 byte, ഒਫ਼౓ුಈখ਺఺਺)
  16. ଟݴޠΛѻͬͨ͜ͱͳ͍ํ͸ ೃછΈ͕ͳ͍͔΋͠Ε·ͤΜ લ ࠲

  17. JVM ্ͷ֤ܕʹ͍ͭͯ લ ࠲

  18. ֤ܕʹ͍ͭͯ - byte • signed byte (ූ߸෇͖ byte) • -128(10)

    ʙ 127(10) ͕ ූ߸෇͖ byte ͷൣғͱͳΓ·͢ɻ • 16ਐ਺Ͱ͸ 0x00 ʙ 0xFF ·ͰͰ͢ɻ • ਖ਼ͷ਺͸ 0x00ʙ0x7F, ෛͷ਺͸ 0x80 ʙ 0xFF ͱͳΓ·͢ɻ • unsigned byte (ූ߸ͳ͠ byte) • 0(10) ʙ 255(10) ͕ූ߸ͳ͠ byte ͷൣғͱͳΓ·͢ɻ • 16ਐ਺Ͱ͸ 0x00 ʙ 0xFF ·ͰͰ͢ • ਖ਼ͷ਺ͷΈͰ͢ɻ
  19. ֤ܕʹ͍ͭͯ - short • signed short (ූ߸෇͖ short) • -32768(10)

    ʙ 32767(10) ͕ ූ߸෇͖ short ͷൣғͱͳΓ·͢ɻ • 16ਐ਺Ͱ͸ 0x0000 ʙ 0xFFFF ·ͰͰ͢ɻ • ਖ਼ͷ਺͸ 0x0000ʙ0x7FFF, ෛͷ਺͸ 0x8000 ʙ 0xFFFF ͱͳΓ·͢ɻ • unsigned short (ූ߸ͳ͠ short) • 0(10) ʙ 65535(10) ͕ූ߸ͳ͠ short ͷൣғͱͳΓ·͢ɻ • 16ਐ਺Ͱ͸ 0x0000 ʙ 0xFFFF ·ͰͰ͢ • ਖ਼ͷ਺ͷΈͰ͢ɻ
  20. ֤ܕʹ͍ͭͯ - int • signed int (ූ߸෇͖ int) • -2147483648(10)

    ʙ 2147483647(10) ͕ ූ߸෇͖ int ͷൣғͱͳΓ· ͢ɻ • 16ਐ਺Ͱ͸ 0x000000 ʙ 0xFFFFFF ·ͰͰ͢ɻ • ਖ਼ͷ਺͸ 0x000000ʙ0x7FFFFF, ෛͷ਺͸ 0x800000 ʙ 0xFFFFFF ͱͳ Γ·͢ɻ • unsigned int (ූ߸ͳ͠ int) • 0(10) ʙ 4294967295(10) ͕ූ߸ͳ͠ int ͷൣғͱͳΓ·͢ɻ • 16ਐ਺Ͱ͸ 0x000000 ʙ 0xFFFFFF ·ͰͰ͢ • ਖ਼ͷ਺ͷΈͰ͢ɻ
  21. ֤ܕʹ͍ͭͯ - long • signed long (ූ߸෇͖ long) • -9223372036854775808(10)

    ʙ 9223372036854775807(10) ͕ ූ߸෇͖ long ͷൣғͱͳΓ·͢ɻ • 16ਐ਺Ͱ͸ 0x00000000 ʙ 0xFFFFFFFF ·ͰͰ͢ɻ • ਖ਼ͷ਺͸ 0x00000000ʙ0x7FFFFFFF, ෛͷ਺͸ 0x80000000 ʙ 0xFFFFFFFF ͱͳΓ·͢ɻ • unsigned long (ූ߸ͳ͠ long) • 0(10) ʙ 18446744073709551615(10) ͕ූ߸ͳ͠ long ͷൣғͱͳΓ· ͢ɻ • 16ਐ਺Ͱ͸ 0x00000000 ʙ 0xFFFFFFFF ·ͰͰ͢ • ਖ਼ͷ਺ͷΈͰ͢ɻ
  22. ͓ؾ͖ͮͷํ΋͍Δ͔΋஌Ε·ͤΜ લ ࠲

  23. ͦ͏ɺPHP Ͱ͸ܭࢉͰ͖ͳ͍਺ࣈ͕ ؚ·Ε͍ͯΔͷͰ͢ લ ࠲

  24. Ͱ΋େৎ෉ લ ࠲

  25. ͦ͏ gmp ؔ਺ͳΒͶ લ ࠲

  26. PHP ͰܭࢉͰ͖ͳ͍஋Λܭࢉ͢Δ • PHP Ͱ͸ unsigned long ͷ஋ΛܭࢉͰ͖ͳ͍͕ɺ gmpؔ਺ Ͱܭࢉͤ͞Δ͜ͱ͸Մೳɻྫ͑͹

    <?= gmp_strval(gmp_add(PHP_INT_MAX, PHP_INT_MAX));" ?> • ݁Ռ͸ 18446744073709551614 ͱͳΓ·͢
  27. ුಈখ਺఺ͷܭࢉʹ͍ͭͯ લ ࠲

  28. ܭࢉํ๏͝ଘ஌ͷํ✋ લ ࠲

  29. ͪͳΈʹɺࢲ͸ۤखͰ͢ લ ࠲

  30. ͋ͱɺຊฤͰ͸࢖Θͳ͍ͷͰ༨ஊͱͯ͠ ָ͓͠Έ͍ͩ͘͞ લ ࠲

  31. ුಈখ਺఺ͷܭࢉํ๏ • ුಈখ਺఺ͷܭࢉํ๏Ͱ༗໊ॴ͸Լه͔ͱࢥ͍·͢ɻ • ୯ਫ਼౓ුಈখ਺఺਺ • ഒਫ਼౓ුಈখ਺఺਺ • ͪͳΈʹ͜ΕΒ͸ IEEE754

    Ͱఆٛ͞Ε͍ͯΔͷͰৄ͘͠஌Γ ͍ͨํ͸ޚཡ͍ͩ͘͞ɻ • ୯ਫ਼౓ුಈখ਺఺਺͸ 32 Ϗοτ (4 byte) ഒਫ਼౓ුಈখ਺఺਺ ͸ 64 Ϗοτ (8 byte) ͷදݱ෯ͷҧ͍͕͋Γ·͢ɻ ࢀরɿhttps://ja.wikipedia.org/wiki/IEEE_754 ը૾ʹ͍ͭͯɿhttps://creativecommons.org/licenses/by-sa/3.0/
  32. ුಈখ਺఺ͷܭࢉํ๏ • ୯ਫ਼౓ුಈখ਺఺਺ (float) ͷܭࢉํ๏ • sign ͕ූ߸ͱͳΓ·͢ɻ (sͱஔ͖·͢) •

    exponent ͕ࢦ਺෦ͱͳΓ·͢ɻ (e ͱஔ͖·͢) • fraction ͕Ծ਺෦ͱͳΓ·͢ɻ (f ͱஔ͖·͢ɻ) ࢀরɿhttps://ja.wikipedia.org/wiki/IEEE_754 ը૾ʹ͍ͭͯɿhttps://creativecommons.org/licenses/by-sa/3.0/ ୯ਫ਼౓ුಈখ਺఺਺ͷܭࢉࣜ͸ = s * f * 2^(e - 127)
  33. ුಈখ਺఺ͷܭࢉํ๏ • ഒਫ਼౓ුಈখ਺఺਺ (double) ͷܭࢉํ๏ • جຊతʹ͸୯ਫ਼౓ුಈখ਺఺਺ͱมΘΓ·ͤΜɻ • sign ͕ූ߸ͱͳΓ·͢ɻ

    (sͱஔ͖·͢) • exponent ͕ࢦ਺෦ͱͳΓ·͢ɻ (e ͱஔ͖·͢) • fraction ͕Ծ਺෦ͱͳΓ·͢ɻ (f ͱஔ͖·͢ɻ) ࢀরɿhttps://ja.wikipedia.org/wiki/IEEE_754 ը૾ʹ͍ͭͯɿhttps://creativecommons.org/licenses/by-sa/3.0/ ഒਫ਼౓ුಈখ਺఺਺ͷܭࢉࣜ͸ = s * f * 2^(e - 1023)
  34. ͕͔ͩ͠͠ લ ࠲

  35. JVM ্ͩͱҧ͏ΜͰ͢ લ ࠲

  36. ුಈখ਺఺ͷܭࢉํ๏ • JVM্ʹ͓͚Δ୯ਫ਼౓ුಈখ਺఺਺ͷܭࢉํ๏͸Լهͷ௨Γ • JVM্ʹ͓͚Δഒਫ਼౓ුಈখ਺఺਺ͷܭࢉํ๏͸Լهͷ௨Γ • ࢦ਺෦ͷϚεΫ͍ͯ͠Δ஋͕ҟͳΓ·͢ɻ = s *

    f * 2^(e - 1075) = s * f * 2^(e - 150)
  37. ΤϯσΟΞϯʹ͍ͭͯ લ ࠲

  38. ΤϯσΟΞϯͱ͍͏ݴ༿Λ ஌͍ͬͯΔํ✋ લ ࠲

  39. ΤϯσΟΞϯʹ͍ͭͯ • ΤϯσΟΞϯ͸ओʹ2ͭ͋Γ·͢ • ϦτϧΤϯσΟΞϯ • ϏοάΤϯσΟΞϯ • ϦτϧΤϯσΟΞϯ͸ӈ͔Βࠨ΁ɺϏοάΤϯσΟΞϯ͸ࠨ ͔Βӈ΁ಡΉͱ֮͑Ε͹େৎ෉Ͱ͢ɻ

  40. ͪͳΈʹϛυϧΤϯσΟΞϯͱ͍͏ͷ΋ ͋ΔΒ͍͠ લ ࠲

  41. ࢀরɿhttps://ja.wikipedia.org/wiki/ %E3%82%A8%E3%83%B3%E3%83%87%E3%82%A3%E3%82%A2%E3%83%B3

  42. ࢀরɿhttps://ja.wikipedia.org/wiki/ %E3%82%A8%E3%83%B3%E3%83%87%E3%82%A3%E3%82%A2%E3%83%B3

  43. มͳ΋ͷͩͦ͏Ͱ͢ લ ࠲

  44. ϦτϧΤϯσΟΞϯʹ͍ͭͯ લ ࠲

  45. ϦτϧΤϯσΟΞϯʹ͍ͭͯ • ϦτϧΤϯσΟΞϯͷಈ͖͸ԼهͷΑ͏ʹϝϞϦʹੵ·Εͯ ͍͖·͢ 00 AA BB CC DD Ϩδελ

    DD CC ϝϞϦ 0xA ΞυϨε 0xB 0xC 0xD 0xE
  46. ϏοάΤϯσΟΞϯʹ͍ͭͯ લ ࠲

  47. ϏοάΤϯσΟΞϯʹ͍ͭͯ • ϏοάΤϯσΟΞϯͷಈ͖͸ԼهͷΑ͏ʹϝϞϦʹੵ·Εͯ ͍͖·͢ 00 AA BB CC DD Ϩδελ

    CC DD ϝϞϦ 0xA ΞυϨε 0xB 0xC 0xD 0xE
  48. ͓͞Β͍ લ ࠲

  49. ͓͞Β͍ •gmp_* ؔ਺Λ֮͑ͯؼΖ͏ •dechex / hexdec / base_convert ؔ਺Λ֮͑ͯ ؼΖ͏

    •signed, unsigned ͳ஋ʹ͍֮ͭͯ͑ͯؼΖ͏ •ුಈখ਺఺ͷܭࢉํ๏Λ֮͑ͯؼΖ͏ •ΤϯσΟΞϯʹ͍֮ͭͯ͑ͯؼΖ͏
  50. લ࠲͸ऴྃͰ͢ લ ࠲

  51. ͋ͳͨ͸஌͍ͬͯΔͩΖ͏͔ ຊ ฤ

  52. 30 ԯͷσόΠεͰ૸ΔϠπͷ͜ͱΛ… ຊ ฤ

  53. ͦ͏ Java ͷ͜ͱΛ… ຊ ฤ

  54. ͦ͏ Java ͷ͜ͱΛ… PHP ຊ ฤ

  55. PHP Ͱ JVM ʹೖ໳͢Δ - ຊฤ - ຊ ฤ PHPerKaigi

    2019 2019/03/29 Ί΋Γʔ(@m3m0r7)
  56. ͩΕʁ Ί΋Γʔ(@m3m0r7) ϫλγϋϐʔΤΠνϐʔνϣοτσΩϧ גࣜձࣾ GameWith ͱ͍͏ձࣾͰಇ͍ͯ·͢ɻ

  57. PHP ͰόΠφϦϦʔσΟϯά

  58. ΍ΓํΛ͝ଘ஌ͷํ✋

  59. ͦ΋ͦ΋ɺόΠφϦϦʔσΟϯάͱ͸ʁ

  60. None
  61. None
  62. ੺࿮ͷͱ͜ΖΛಡΜͰ͍͘͜ͱͰ͢

  63. ͦ΋ͦ΋ɺPHP Ͱ JVM Λ ಡΜͰԿָ͕͍͠ͷʁ

  64. PHP Ͱ JVM ΛಡΜͰԿָ͕͍͠ͷ͔ • ελοΫϚγϯ͕ͲͷΑ͏ʹಈ͍ͯΔ͔ཧղ͢Δ͜ͱ͕Ͱ͖ ͨؾ࣋ͪʹͳΔ • ͨͩ͠ JVM

    ͸ϩʔΧϧม਺ͷετΞ΍ϩʔυ͕ແݶେʹͰ ͖ΔͨΊ७ਮͳελοΫϚγϯͰ͸ͳ͍ • php ͷதؒίʔυ͕ཧղ͠΍͘͢ͳΔ • vld extension ͷؾ࣋ͪʹͳΕΔ • 30 ԯͷσόΠεͰ૸Δ͜ͱ͕Ͱ͖Δ • ͳΜͳΒ PHP ͕Քಇ͍ͯ͠Δαʔόʔ୆਺෼΋ؚΊΔͱ Java ΑΓ΋͍͢͝ͷͰ͸
  65. PHP Java

  66. ৑ஊͰ͢

  67. JVM Λೖ໳͢Δʹ͋ͨͬͯ

  68. None
  69. The Java® Virtual Machine Specification ΋ҰॹʹಡΜͰ͍͖·͢

  70. The Java® Virtual Machine Specification https://docs.oracle.com/javase/specs/jvms/se11/html/index.html

  71. ͬͦ͘͞όΠφϦϦʔσΟϯά͠·͢

  72. Java ͷΫϥεϑΝΠϧ͸͜ͷߏ଄

  73. None
  74. ಡΈํ

  75. unsigned int unsigned short object (PHPͩͬͨΒ഑ྻͰOK)

  76. ࣮ࡍʹ PHP ͰಡΜͰ͍͘

  77. όΠφϦΛಡΉʹ͸ • PHPͷϑΝΠϧؔ਺Λ࢖͏ • fopen ؔ਺ • fread ؔ਺ •

    fseek ؔ਺ • int ΍ short ͳͲͷ஋Λܭࢉ͢Δ • base_convert ؔ਺ • pack / unpack ؔ਺ (ࠓճ͸͜ΕΛ࢖͍·͢) • ord / chr ؔ਺ • ؾ߹
  78. unsigned int magic unsigned short minor version unsigned short major

    version unsigned short constant pool count
  79. PHP Ͱද͢ͱ

  80. None
  81. N ͸ unsigned int Ͱ ϏοάΤϯσΟΞϯ όΠτΦʔμʔ n ͸ unsigned

    short Ͱ ϏοάΤϯσΟΞϯ όΠτΦʔμʔ cafebabe 0 52 (JDK 8) 29 ͜͜Ͱ͍͏ int (4byte) ΍ short (2byte) ͷαΠζ͸ JVM ্Ͱͷ࿩ʹͳΓ·͢ɻ
  82. Ͷʁ؆୯Ͱ͠ΐʁ

  83. औಘͨ͠ constant_pool_count ΑΓ Constant Pool Λऔಘ͠·͢

  84. ੺࿮͕ constant pool

  85. PHP Ͱද͢ͱ

  86. None
  87. None
  88. ଴ͯΑ

  89. ʁʁʁ ʁʁʁ ʁʁʁ ʁʁʁ

  90. 0x0A ΍ 0x09 ͷ஋ͬͯʁ

  91. None
  92. Constant Kind ͱ Tag ͷ͜ͱΛ ͍ࣔͯ͠·͢ unsigned byte

  93. ͭ·Γ Constant Kind ͷ Tag ͷ ஋ʹΑͬͯॲཧͷ࢓ํ͕ มΘΓ·͢

  94. ॲཧͷํ๏͕ҟͳΔ • ࠓճ͸ Methodref (0x0A), Fieldref (0x09), String (0x08), Class

    (0x07), Utf8 (0x01), NameAndType(0x0C) ͷ6ͭͷΈ ରԠɻ Constant Kind Tag Read bytes CONSTANT_Methodref 0x0A 2 byte + 2 byte ( unsigned short + unsigned short ) CONSTANT_Fieldref 0x09 2 byte + 2 byte ( unsigned short + unsigned short ) CONSTANT_String 0x08 2 byte ( unsigned short ) CONSTANT_Class 0x07 2 byte ( unsigned short ) CONSTANT_Utf8 0x01 ( length = 2 byte ) + length bytes ( unsigned short + length bytes ) CONSTANT_NameAndType 0x0C 2 byte + 2 byte ( unsigned byte + unsigned byte )
  95. ͜ΕΛ΋ͱʹͯ͠…

  96. C ͸ unsigned byte constant pool count ͸ྺ࢙తͳ ཧ༝ʹΑΓ -1

    ͢Δ CONSTANT_Methodref CONSTANT_Fieldref CONSTANT_String CONSTANT_Class
  97. CONSTANT_Utf8 CONSTANT_NameAndType औಘͨ݁͠ՌΛ֨ೲ͢Δ

  98. ࣮ࡍʹग़ྗͯ͠ΈΔͱͲ͏ͳΔ͔ʁ

  99. None
  100. ͦΕͬΆ͍ͷ͕ݟ͑ͯ͘Δ

  101. ✌(‘ω'✌ )ࡾ✌('ω')✌ࡾ( ✌’ω’)✌ ָ͍͠ !!!

  102. Ҿ͖ଓ͖ಡΜͰ͍͖·͢

  103. None
  104. unsigned short access flag unsigned short this class unsigned short

    super class unsigned short interface count unsigned short fields count unsigned short methods count
  105. PHP Ͱද͢ͱ

  106. None
  107. 32 (ACC_SUPER) Test java/lang/Object 0 (ΠϯλϑΣʔε͸ఆٛ͞Ε͍ͯͳ͍ͨΊ) 0 (ϑΟʔϧυ͸ఆٛ͞Ε͍ͯͳ͍ͨΊ) 2 (<init>

    ͱ main ͕ఆٛ͞Ε͍ͯΔͨΊ)
  108. ϝιου͕ 2 ͭ͋ΔͷͰ ಡΜͰ͍͖·͢

  109. None
  110. unsigned short unsigned short unsigned short unsigned short ϝιουʹ͸ Code

    Attribute ؚ͕·ΕΔ ʢͦΕҎ֎΋ؚ·Ε·͕͢লུ͠·͢ʣ
  111. Code Attribute ͷߏ଄͸ʁ

  112. None
  113. unsigned short length byte unsigned int Code Attribute ʹ͸ LineNumberTable

    Attribute ؚ͕·Ε·͢ ʢͦΕҎ֎΋ؚ·Ε·͕͢লུ͠·͢ʣ
  114. LineNumberTable Attribute ͷߏ଄͸ʁ

  115. None
  116. unsigned short unsigned int

  117. None
  118. ੺࿮͕ϝιουͷ৘ใͱ JVM ͷίʔυͷ৘ใʹͳΓ·͢

  119. PHP Ͱද͢ͱ

  120. None
  121. None
  122. None
  123. ࣮ࡍͷ JVM ্ͷίʔυ͕֨ೲ͞Ε͍ͯ·͢ Attribute ͷछྨʹΑΓॲཧํ๏͕ҟͳΔͨΊ ෼ذ͍ͯ͠·͢ ࠶ؼ͢Δඞཁ͕͋ΔͷͰؔ਺Խͯ͠·͢

  124. Attribute ͷछྨʹΑΓॲཧํ๏͕ҟͳΔͨΊ ෼ذ͍ͯ͠·͢ ࠶ؼͰॲཧ͍ͯ͠·͢

  125. 0 (ϝιου΁ͷΞΫηεݖΛ͍ࣔͯ͠·͢) <init>, mainͳͲͷϝιου໊ ()V, ([Ljava/lang/String;)VͳͲͷ ϝιουͷҾ਺ͷ৘ใ Code Attribute ͳͲͷ৘ใ

  126. ࣮ࡍʹग़ྗͯ͠ΈΔͱʁ

  127. None
  128. ͍͍ײ͡ʹऔΕ͖ͯ·ͨ͠

  129. ϥετεύʔτ

  130. ࠷ޙ͸ Ϋϥεͷ Attribute Λऔಘ͢Δ

  131. ClassFile Structure ʹ͸ SourceFile Attribute ͕ ؚ·Ε·͢ ʢͦΕҎ֎΋ؚ·Ε·͕͢লུ͠·͢ʣ

  132. SourceFile Attribute ͷߏ଄͸ʁ

  133. None
  134. None
  135. unsigned short attribute count unsigned short attribute name index unsigned

    int attribute length unsigned short sourcefile index
  136. PHP Ͱද͢ͱ

  137. None
  138. None
  139. readAttributeؔ਺ʹ SourceFile Λ௥Ճ

  140. ϝιουͱಉ͡Α͏ͳॲཧΛॻ͘

  141. Ҏ্Ͱ JVM ೖ໳׬ྃͰ͢

  142. 30ԯͷσόΠεͰ૸Δ Java ͷ ؾ࣋ͪʹͳΕ·͔ͨ͠ʁ PHP

  143. ࣍ճ

  144. PHP Ͱ JVM Λಈ͔͢ χʔϞχοΫͱ͸ Operation Code ͱ͸ iload_0 ͬͯͳΜͩ…

    tableswitch ͱ lookupswitch ͷҧ͍ Φϖϥϯυ ϩʔΧϧετϨʔδ invokespecial ͱ invokevirtual ಥવͷ <clinit> ͳͥ PHP Ͱ΍ΔΜͩ…
  145. ָ͓͠Έʹʂ ※͓࿩͢Δ৔ॴ͸ܾ·ͬͯ·ͤΜ ※͓࿩͢Δ͜ͱࣗମܾ·ͬͯ·ͤΜ

  146. None
  147. ͜ͷ೔ͷͨΊʹɺେྔͷ࣮૷ͱ ϦϑΝΫλϦϯάΛ͖ͯ͠·ͨ͠

  148. JAR ͷରԠ, ΞϊςʔγϣϯͷରԠ, ֎෦Ϋϥε ͷରԠ ͳͲͳͲ…

  149. None
  150. None
  151. None
  152. Before

  153. Before ʊਓਓਓਓਓਓʊ ʼɹ.DS_Storeɹʻ ʉY^Y^Y^Y^Y^Y^ʉ ʊਓਓਓਓਓਓʊ ʼɹnbprojectɹʻ ʉY^Y^Y^Y^Y^Y^ʉ ʊਓਓਓਓʊ ʼɹ4೥લɹʻ ʉY^Y^Y^Y^ʉ

  154. 20ࡀͷͱ͖ʹ͜Εॻ͍ͨͷ͔…

  155. After

  156. After PHPUnit Ͱςετ composer ରԠ PHP CodeSniffer ͰίʔσΟϯάϧʔϧΛ౷Ұ TravisCIͰςετΛ୲อ

  157. ϞμϯʹͳΓ·ͨ͠

  158. DEMO (͕࣌ؒ͋Ε͹)

  159. php-java ͱ͍͏໊લͰ JVM ΤϛϡϨʔλΛެ։͍ͯ͠·͢ ͥͻࣗ͝਎ͷ PC Ͱࢼͯ͠Έ͍ͯͩ͘͞ ͦͯ͠ίϯτϦϏϡʔλʹͳ͍ͬͯͩ͘͞ʂʂ https://github.com/memory-agape/php-java

  160. ຊ೔ͷαϯϓϧ͸ͪ͜Β https://gist.github.com/memory-agape/ 6d4dce2af4ece6e41293afb4e2caa5e1

  161. THANK YOU FOR YOUR LISTENING