SlideShare a Scribd company logo
猿を
木から
落とさない
JIT-Aware AVM+ Programming



                              2007/03/23
                   omo <omo@dodgson.org>
                  http://www.dodgson.org/omo/
Tamarin↓   (w/ JIT)




                       SpiderMonkey↑          (w/o JIT)




                      http://flickr.com/photos/andrewn/125332736/
                      http://flickr.com/photos/subindie/336599998/
JIT 結果を確認する


# avmplus_sd.exe -Dverbose Hello.abc
JIT 0/2   package {
            ...
AS→ABC      public class Hello {
              prototype.hello
                 = function() {
                System.write(quot;Helloquot;);
              };
              ...
            }
          }

          var h = new Hello();
          h.hello();

          ...
            0:findpropstrict {...}::System
            2:getproperty {...}::System
            4:pushstring quot;Helloquot;
            6:callproperty {...}::write 1
            9:pop
            10:returnvoid
          ...
JIT 1/2   verify <function> ()
            ...
            0:findpropstrict {...}::System

ABC→MIR
                  @25  imm   13782760
                  @26  imm   14133232
                  @27  cmop MethodEnv::finddefNsset (@3, @26, @25)
            2:getproperty {...}::System
                  @29  ld    60(@27)
            4:pushstring quot;Byequot;
                  @30  imm   14150032
            6:callproperty {...}::write 1
                  @31  ucmp @29 @11
                  @32  jeq   @31 -> 0
                  @33  st    13490120(0) <- @3
                  @34  ldop 4(@3)
                  @35  ldop 24(@34)
                  @36  lea   8(@35)
                  @37  st    13489476(0) <- @36
                  @38  ldop 40(@29)
                  @39  ldop 108(@38)
                  @40  alloc 4
                  @41  st    0(@40) <- @29
                  @42  st    4(@40) <- @30
                  @43  lea   12(@39)
                  @44  lea   0(@40)
              save state:
                  @45  def   @29
                  @46  def   @30
                  @47  ci    @43 (@39, @14, @44, @-1)
            9:pop
            10:returnvoid
            ...
JIT 2/2   generate <function> ()
             ...
             @8 alloc 48

MIR→x86      @9 ldop 0(@5)
                 03D800E5 mov      eax, 16(ebp)
                 03D800E8 mov      ecx, 0(eax)
             ...
             @40 alloc 8
             @41 st    0(@40) <-   @29
                 03D80156 mov      -72(ebp), eax
             @42 st    4(@40) <-   @30
                 03D80159 mov      -68(ebp), 14150032
             @43 lea   12(@39)
             @44 lea   0(@40)
                 03D80160 lea      edx, -72(ebp)
             @45 def   @29
             @46 def   @30
             @47 ci    @43 (@39,   @14, @44, 0)
                 03D80163 push     edx
                 03D80164 push     1
                 03D80166 push     ecx
                 03D80167 call     12(ecx)
                 03D8016A add      esp, 12
             ...
                 03D8018B leave
                 03D8018C ret
             ...
本題 : JIT-Aware Programming
    JIT されないところ
●


    似た or 同じバイトコードで異なる JIT 結果
●
JIT されないところ
●


    似た or 同じバイトコードで異なる JIT 結果
●
JIT されないところ
package {
  ...
  public class Hello {
    // Hello$cinit
    prototype.hello
       = function() {
     System.write(quot;Helloquot;);
    };
    ...
  }
}

// global$init
var h = new Hello();
h.hello();
JIT されないところ
●


    似た or 同じバイトコードで異なる JIT 結果
●




    例題 :
➢

    メソッド呼び出し w/ メソッド定義いろいろ
メソッド w/ property
...
function Hello1() {
  this.hello = function()
    { System.write(quot;Helloquot;); };
}

function greeting(h) {
  h.hello();
}

greeting(new Hello1());

...
  0:getlocal1
  1:callproperty {...}::hello 0   4 ABC Ins.
  4:pop
  5:returnvoid
...
メソッド w/ property
       ...
 0:getlocal1
       @37   use  @29 [1]
 1:callproperty {public,Hello1.as$1,avmplus}::hello 0
       @38   def  @37
       @39   cm   MethodEnv::nullcheck (@3, @37)
       ...
       @56   ldop 12(@42)
       @57   cmop Toplevel::toVTable (@56, @53)
       ...
       @61   cm   Toplevel::callproperty (@56, ...)
 4:pop
 5:returnvoid
       ...
       @66   ret  @18




MIR 命令 : 約 66
ランタイム呼出 : 3
メソッド w/ type
 ...
 dynamic public class Hello2 {
   public function Hello2() {
     this.hello = function() { System.write(quot;Helloquot;); };
   }

   public static function greeting(h:Hello2)
     : void {
       h.hello();
   }
 }
 ...


...
  0:getlocal0
  1:pushscope
                                       6 ABC Ins.
  2:getlocal1
  3:callproperty {...}::hello 0
  6:pop
  7:returnvoid
...
メソッド w/ type
   ...
 0:getlocal0
       @33   use  @17 [0]
 1:pushscope
 2:getlocal1
       @34   use  @22 [1]
 3:callproperty {...}::hello 0
   ...
       @61   cm   Toplevel::callproperty (@54, @50, ...)
 6:pop
 7:returnvoid
   ...; error handling follows ...
       @66   ret  @11
   ...
       @68   cm   MethodEnv::npe (@3); null-pointer exception
   ...



MIR 命令 : 約 61 (Hello1 - 5)
ランタイム呼出 : 1(Hello1 - 2)
Toplevel::callproperty()
Atom Toplevel::callproperty(...) {
  Binding b = getBinding(...); // ハッシュ検索
  switch (b&7) {
    case BIND_METHOD:
       ...
    default:
      ...
      return AvmCore::atomToScriptObject(base)->callProperty(...);
       ...
}

Atom ScriptObject::callProperty(...) {
   ...
   Atom method = getMultinameProperty(multiname); // ハッシュ検索
   ...
   return toplevel->op_call(method, argc, argv);
}



2 回ハッシュをひく!
メソッド w/ 1 -class method
                  st

 ...
 public class Hello3 {
   public function hello() : void
     { System.write(quot;Helloquot;); }

   public static function greeting(h:Hello3)
     : void {
       h.hello();
   }
 }
 ...

...
  0:getlocal0
  1:pushscope
                                    6 ABC Ins.
  2:getlocal1
                                      (== Hello2)
  3:callproperty {...}::hello 0
  6:pop
  7:returnvoid
...
メソッド w/ 1 -class method st

...
  0:getlocal0
        @33 use   @17 [0]
  1:pushscope
  2:getlocal1
        @34 use   @22 [1]
  3:callproperty {...}::hello 0
        ...
        @35 ucmp @34 @12
        ...
        @47 ci    @41 (@38, @12, @42, @-1); call indirect
  6:pop
  7:returnvoid
        ... ; error handling follows ...
        @51 ret   @11
        ...
        @53 cm    MethodEnv::npe (@3)
...



MIR 命令 : 約 53 (Hello2 - 8)
ランタイム呼出 : 0 (Hello2 - 1)
仕組み : アーリーバインド
                                                         per-class
                                            Traits
  ScriptObject       VTable
                      ...
                                        method size
                                         slot size
                     traits
                                            ...
    GC, etc
      ...
                  methods...
                                            code


    vtable

   delegate                       Another Object

   instances
                 GCHashtable
                                    “foo”
    slots...
                                                     Another Object
                                      ...

                 Another Object
まとめ : JIT-Aware Programming
    一見同じバイトコードでも JIT 結果は色々
●


        型やアーリーバインドを意識する
    ●

        ( type, method, slot )
        JIT 結果をのぞく
    ●



    速度計測を忘れずに
●
    (今回やってないけど。)
Happy JIT-ing!


             おしまい

More Related Content

What's hot

Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
Sergey Platonov
 
Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)
Benjamin Bock
 
The mighty js_function
The mighty js_functionThe mighty js_function
The mighty js_function
timotheeg
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
Wim Godden
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
julien pauli
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
Wim Godden
 
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip CalçadoJustjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Paulo Silveira
 
Notes for xx_use_serialgc
Notes for xx_use_serialgcNotes for xx_use_serialgc
Notes for xx_use_serialgc
ytoshima
 
Алексей Кутумов, Coroutines everywhere
Алексей Кутумов, Coroutines everywhereАлексей Кутумов, Coroutines everywhere
Алексей Кутумов, Coroutines everywhere
Sergey Platonov
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
Wim Godden
 
Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
Ingvar Stepanyan
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
julien pauli
 
An introduction to PHP 5.4
An introduction to PHP 5.4An introduction to PHP 5.4
An introduction to PHP 5.4
Giovanni Derks
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
Wim Godden
 
Oxygine 2 d objects,events,debug and resources
Oxygine 2 d objects,events,debug and resourcesOxygine 2 d objects,events,debug and resources
Oxygine 2 d objects,events,debug and resources
corehard_by
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
Atsushi Tadokoro
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
Wim Godden
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.
Platonov Sergey
 
C++ Core Guidelines
C++ Core GuidelinesC++ Core Guidelines
C++ Core Guidelines
Thomas Pollak
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
Sean Hess
 

What's hot (20)

Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
 
Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)
 
The mighty js_function
The mighty js_functionThe mighty js_function
The mighty js_function
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip CalçadoJustjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
 
Notes for xx_use_serialgc
Notes for xx_use_serialgcNotes for xx_use_serialgc
Notes for xx_use_serialgc
 
Алексей Кутумов, Coroutines everywhere
Алексей Кутумов, Coroutines everywhereАлексей Кутумов, Coroutines everywhere
Алексей Кутумов, Coroutines everywhere
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
An introduction to PHP 5.4
An introduction to PHP 5.4An introduction to PHP 5.4
An introduction to PHP 5.4
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
 
Oxygine 2 d objects,events,debug and resources
Oxygine 2 d objects,events,debug and resourcesOxygine 2 d objects,events,debug and resources
Oxygine 2 d objects,events,debug and resources
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.
 
C++ Core Guidelines
C++ Core GuidelinesC++ Core Guidelines
C++ Core Guidelines
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
 

Similar to Stop Monkeys Fall

Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3
guesta3202
 
Groovy
GroovyGroovy
Groovy
Zen Urban
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
Ganesh Samarthyam
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVM
Linaro
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
Dharmalingam Ganesan
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?
jonbodner
 
LISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesLISA QooxdooTutorial Slides
LISA QooxdooTutorial Slides
Tobias Oetiker
 
Vcs16
Vcs16Vcs16
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
Alex Miller
 
10 Catalyst Tips
10 Catalyst Tips10 Catalyst Tips
10 Catalyst Tips
Jay Shirley
 
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Badoo Development
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
Caridy Patino
 
The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196
Mahmoud Samir Fayed
 
Java bytecode Malware Analysis
Java bytecode Malware AnalysisJava bytecode Malware Analysis
Java bytecode Malware Analysis
Brian Baskin
 
Vcs23
Vcs23Vcs23
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usage
Wayne Tsai
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
Domenic Denicola
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
Samsung Open Source Group
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf Edition
Paulo Morgado
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
Functional Thursday
 

Similar to Stop Monkeys Fall (20)

Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3
 
Groovy
GroovyGroovy
Groovy
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVM
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?
 
LISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesLISA QooxdooTutorial Slides
LISA QooxdooTutorial Slides
 
Vcs16
Vcs16Vcs16
Vcs16
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
 
10 Catalyst Tips
10 Catalyst Tips10 Catalyst Tips
10 Catalyst Tips
 
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
 
The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196
 
Java bytecode Malware Analysis
Java bytecode Malware AnalysisJava bytecode Malware Analysis
Java bytecode Malware Analysis
 
Vcs23
Vcs23Vcs23
Vcs23
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usage
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf Edition
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 

Recently uploaded

Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
Data Hops
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 

Recently uploaded (20)

Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 

Stop Monkeys Fall

  • 1. 猿を 木から 落とさない JIT-Aware AVM+ Programming 2007/03/23 omo <omo@dodgson.org> http://www.dodgson.org/omo/
  • 2. Tamarin↓ (w/ JIT) SpiderMonkey↑ (w/o JIT) http://flickr.com/photos/andrewn/125332736/ http://flickr.com/photos/subindie/336599998/
  • 4. JIT 0/2 package { ... AS→ABC public class Hello { prototype.hello = function() { System.write(quot;Helloquot;); }; ... } } var h = new Hello(); h.hello(); ... 0:findpropstrict {...}::System 2:getproperty {...}::System 4:pushstring quot;Helloquot; 6:callproperty {...}::write 1 9:pop 10:returnvoid ...
  • 5. JIT 1/2 verify <function> () ... 0:findpropstrict {...}::System ABC→MIR @25 imm 13782760 @26 imm 14133232 @27 cmop MethodEnv::finddefNsset (@3, @26, @25) 2:getproperty {...}::System @29 ld 60(@27) 4:pushstring quot;Byequot; @30 imm 14150032 6:callproperty {...}::write 1 @31 ucmp @29 @11 @32 jeq @31 -> 0 @33 st 13490120(0) <- @3 @34 ldop 4(@3) @35 ldop 24(@34) @36 lea 8(@35) @37 st 13489476(0) <- @36 @38 ldop 40(@29) @39 ldop 108(@38) @40 alloc 4 @41 st 0(@40) <- @29 @42 st 4(@40) <- @30 @43 lea 12(@39) @44 lea 0(@40) save state: @45 def @29 @46 def @30 @47 ci @43 (@39, @14, @44, @-1) 9:pop 10:returnvoid ...
  • 6. JIT 2/2 generate <function> () ... @8 alloc 48 MIR→x86 @9 ldop 0(@5) 03D800E5 mov eax, 16(ebp) 03D800E8 mov ecx, 0(eax) ... @40 alloc 8 @41 st 0(@40) <- @29 03D80156 mov -72(ebp), eax @42 st 4(@40) <- @30 03D80159 mov -68(ebp), 14150032 @43 lea 12(@39) @44 lea 0(@40) 03D80160 lea edx, -72(ebp) @45 def @29 @46 def @30 @47 ci @43 (@39, @14, @44, 0) 03D80163 push edx 03D80164 push 1 03D80166 push ecx 03D80167 call 12(ecx) 03D8016A add esp, 12 ... 03D8018B leave 03D8018C ret ...
  • 7. 本題 : JIT-Aware Programming JIT されないところ ● 似た or 同じバイトコードで異なる JIT 結果 ●
  • 8. JIT されないところ ● 似た or 同じバイトコードで異なる JIT 結果 ●
  • 9. JIT されないところ package { ... public class Hello { // Hello$cinit prototype.hello = function() { System.write(quot;Helloquot;); }; ... } } // global$init var h = new Hello(); h.hello();
  • 10. JIT されないところ ● 似た or 同じバイトコードで異なる JIT 結果 ● 例題 : ➢ メソッド呼び出し w/ メソッド定義いろいろ
  • 11. メソッド w/ property ... function Hello1() { this.hello = function() { System.write(quot;Helloquot;); }; } function greeting(h) { h.hello(); } greeting(new Hello1()); ... 0:getlocal1 1:callproperty {...}::hello 0 4 ABC Ins. 4:pop 5:returnvoid ...
  • 12. メソッド w/ property ... 0:getlocal1 @37 use @29 [1] 1:callproperty {public,Hello1.as$1,avmplus}::hello 0 @38 def @37 @39 cm MethodEnv::nullcheck (@3, @37) ... @56 ldop 12(@42) @57 cmop Toplevel::toVTable (@56, @53) ... @61 cm Toplevel::callproperty (@56, ...) 4:pop 5:returnvoid ... @66 ret @18 MIR 命令 : 約 66 ランタイム呼出 : 3
  • 13. メソッド w/ type ... dynamic public class Hello2 { public function Hello2() { this.hello = function() { System.write(quot;Helloquot;); }; } public static function greeting(h:Hello2) : void { h.hello(); } } ... ... 0:getlocal0 1:pushscope 6 ABC Ins. 2:getlocal1 3:callproperty {...}::hello 0 6:pop 7:returnvoid ...
  • 14. メソッド w/ type ... 0:getlocal0 @33 use @17 [0] 1:pushscope 2:getlocal1 @34 use @22 [1] 3:callproperty {...}::hello 0 ... @61 cm Toplevel::callproperty (@54, @50, ...) 6:pop 7:returnvoid ...; error handling follows ... @66 ret @11 ... @68 cm MethodEnv::npe (@3); null-pointer exception ... MIR 命令 : 約 61 (Hello1 - 5) ランタイム呼出 : 1(Hello1 - 2)
  • 15. Toplevel::callproperty() Atom Toplevel::callproperty(...) { Binding b = getBinding(...); // ハッシュ検索 switch (b&7) { case BIND_METHOD: ... default: ... return AvmCore::atomToScriptObject(base)->callProperty(...); ... } Atom ScriptObject::callProperty(...) {    ...    Atom method = getMultinameProperty(multiname); // ハッシュ検索    ...    return toplevel->op_call(method, argc, argv); } 2 回ハッシュをひく!
  • 16. メソッド w/ 1 -class method st ... public class Hello3 { public function hello() : void { System.write(quot;Helloquot;); } public static function greeting(h:Hello3) : void { h.hello(); } } ... ... 0:getlocal0 1:pushscope 6 ABC Ins. 2:getlocal1 (== Hello2) 3:callproperty {...}::hello 0 6:pop 7:returnvoid ...
  • 17. メソッド w/ 1 -class method st ... 0:getlocal0 @33 use @17 [0] 1:pushscope 2:getlocal1 @34 use @22 [1] 3:callproperty {...}::hello 0 ... @35 ucmp @34 @12 ... @47 ci @41 (@38, @12, @42, @-1); call indirect 6:pop 7:returnvoid ... ; error handling follows ... @51 ret @11 ... @53 cm MethodEnv::npe (@3) ... MIR 命令 : 約 53 (Hello2 - 8) ランタイム呼出 : 0 (Hello2 - 1)
  • 18. 仕組み : アーリーバインド per-class Traits ScriptObject VTable ... method size slot size traits ... GC, etc ... methods... code vtable delegate Another Object instances GCHashtable “foo” slots... Another Object ... Another Object
  • 19. まとめ : JIT-Aware Programming 一見同じバイトコードでも JIT 結果は色々 ● 型やアーリーバインドを意識する ● ( type, method, slot ) JIT 結果をのぞく ● 速度計測を忘れずに ● (今回やってないけど。)
  • 20. Happy JIT-ing! おしまい