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

jsconf.eu x Node Collaborators Meetup journey

jsconf.eu x Node Collaborators Meetup journey

東京Node学園26時限目で飛び入りLTで発表した資料です。

Yosuke Furukawa

June 28, 2017
Tweet

More Decks by Yosuke Furukawa

Other Decks in Programming

Transcript

  1. ͨͩ͠ var obj = { x: 1, y: 2, };

    // obj ͷ y propΛফ͢ delete obj.y; // obj ʹ z propΛ଍͢ obj.z = 3; // obj ͷ props Λ֬ೝ͢Δ obj.hasOwnProperties ͜͏͍͏͜ͱ΍Δͱ஗͍
  2. ͨͩ͠ var obj = { x: 1, y: 2, };

    // obj ͷ y propΛফ͢ delete obj.y; // obj ʹ z propΛ଍͢ obj.z = 3; // obj ͷ props Λ֬ೝ͢Δ obj.hasOwnProperties ͜͏͍͏͜ͱ΍Δͱ஗͍ ͜ΕΛ%FPQUJNJ[BUJPOͱݺͿ
  3. DEMO function deopt(obj) { return obj.x; } for (var i

    = 0; i < 1000000; i++) { deopt({ x: 1, y: 2}); } // deoptimized… deopt({ x: 1, y: 2, z: 3});
  4. Parseॲཧ • v8ͷParser͸࣮͸2ͭ͋Δ • Eager Parser: • ίϯύΠϧ͍ͨ͠શͯͷؔ਺Λύʔε͢ΔͨΊʹ࢖ΘΕΔ • AST

    ߏங͕ϝΠϯλεΫ • JSͷscopeΛߏங͠ɺESSpecʹԊͬͨશͯͷsyntaxΤϥʔΛݟ͚ͭΔ • Lazy Parser: • ίϯύΠϧͨ͘͠ͳ͍ؔ਺ͷύʔεΛεΩοϓ͢ΔͨΊʹ࢖ΘΕΔ • AST͸ߏங͠ͳ͍ • ൑அՄೳͳsyntaxΤϥʔͷΈݟ͚ͭΔɺESspecʹ͸ඞͣ͠΋ԊΘͳ͍
  5. Parseॲཧ • ʮॳظஈ֊Ͱ͸ Lazy Parser ʹ࢓ࣄͤͯ͞ޙ൒ʹ Eager Parser ʹ࢓ࣄͤ͞Δʯͱ͍͏উෛ •

    Lazy Parse ͢Δͷ͔ Eager Parse ͢Δͷ͔͸ V8 ͷؾ ෼࣍ୈͰܾ·Δ΋ͷ͕ଟ͍(Heuristic) • ຊ౰ʹStartup࣌ʹඞཁͳ΋ͷ͚ͩEager Parseͤ͞ ͯɺଞ͸Lazy Parse ͍ͤͨ͞