SlideShare ist ein Scribd-Unternehmen logo
1 von 68
Downloaden Sie, um offline zu lesen
Tail Call Elimination in Opensmalltalk
Matthew Ralston Dave Mason
Department of Computer Science
Ryerson University
c 2019 Matthew Ralston
Agenda
What is a Tail Call?
Tail Call Elimination
Stack Interpreter Implementation
Cog VM JIT Implementation
Results
Conclusions and Future Work
What is a Tail Call?
Call followed by a return
Smalltalk Example
Array class>>new: sizeRequested
^ self basicNew: sizeRequested
Call to basicNew: is a tail call
Immediately followed by a return
What is a Tail Call?
Call followed by a return
Smalltalk Example
Array class>>new: sizeRequested
^ self basicNew: sizeRequested
Call to basicNew: is a tail call
Immediately followed by a return
What is a Tail Call?
Call followed by a return
Smalltalk Example
Array class>>new: sizeRequested
^ self basicNew: sizeRequested
Call to basicNew: is a tail call
Immediately followed by a return
What is a Tail Call?
Call followed by a return
Smalltalk Example
Array class>>new: sizeRequested
^ self basicNew: sizeRequested
Call to basicNew: is a tail call
Immediately followed by a return
Tail call in Bytecode
Bytecode for Array class»new:
self
pushTemp: 0
send: basicNew:
returnTop
Calling new without TCE
Stack after calling new:
new:’s stack frame
new:’s argument
Sender of new:’s frame
Calling new without TCE
Stack after calling new:
new:’s stack frame
new:’s argument
Sender of new:’s frame
Calling new without TCE - cont.
Stack after calling basicNew:
basicNew:’s stack frame
basicNew:’s argument
new:’s stack frame
new:’s argument
Sender of new:’s frame
Calling new without TCE - cont.
Stack after calling basicNew:
basicNew:’s stack frame
basicNew:’s argument
new:’s stack frame
new:’s argument
Sender of new:’s frame
Calling new without TCE - cont.
Stack after returning from basicNew:
basicNew:’s result
new:’s stack frame
new:’s argument
Sender of new:’s frame
Calling new without TCE - cont.
Stack after returning from basicNew:
basicNew:’s result
new:’s stack frame
new:’s argument
Sender of new:’s frame
Calling new without TCE - cont.
Stack after returning from new:
new:’s result
Sender of new:’s frame
Calling new without TCE - cont.
Stack after returning from new:
new:’s result
Sender of new:’s frame
Tail Call Elimination
Why return to new:?
Why keep new:’s stack frame?
Tail Call Elimination
Why return to new:?
Why keep new:’s stack frame?
Calling new with TCE
new:’s stack frame
new:’s argument
Sender of new:’s frame
Calling new with TCE - cont’d
basicNew:’s stack frame
basicNew:’s argument
Sender of new:’s frame
Calling new with TCE - cont’d
basicNew:’s return
Sender of new:’s frame
Tail Recursion Elimination
Special Case of Tail Call Elimination
Recursive Call is also a Tail Call
Tail Recursion Elimination
Special Case of Tail Call Elimination
Recursive Call is also a Tail Call
Motivation
Well Known Optimization
Support in functional languages, CLR, etc.
Not supported in JVM, Python
Necessary for functional languages
Can be useful for OO as well
In common patterns like Visitor Pattern
Iteration in Smalltalk
Motivation
Well Known Optimization
Support in functional languages, CLR, etc.
Not supported in JVM, Python
Necessary for functional languages
Can be useful for OO as well
In common patterns like Visitor Pattern
Iteration in Smalltalk
Motivation
Well Known Optimization
Support in functional languages, CLR, etc.
Not supported in JVM, Python
Necessary for functional languages
Can be useful for OO as well
In common patterns like Visitor Pattern
Iteration in Smalltalk
Motivation
Well Known Optimization
Support in functional languages, CLR, etc.
Not supported in JVM, Python
Necessary for functional languages
Can be useful for OO as well
In common patterns like Visitor Pattern
Iteration in Smalltalk
Motivation
Well Known Optimization
Support in functional languages, CLR, etc.
Not supported in JVM, Python
Necessary for functional languages
Can be useful for OO as well
In common patterns like Visitor Pattern
Iteration in Smalltalk
Motivation
Well Known Optimization
Support in functional languages, CLR, etc.
Not supported in JVM, Python
Necessary for functional languages
Can be useful for OO as well
In common patterns like Visitor Pattern
Iteration in Smalltalk
Motivation
Well Known Optimization
Support in functional languages, CLR, etc.
Not supported in JVM, Python
Necessary for functional languages
Can be useful for OO as well
In common patterns like Visitor Pattern
Iteration in Smalltalk
Frequency of Tail Calls
Static Frequency
Platform Packages Tail Calls Total Percentage
Squeak - All 25162 407971 6.17
Squeak - Compiler 863 8747 9.87
Higher Dynamic Frequency
Action Tail Calls Total Percentage
Startup 47669 219054 21.76
Recompile 92041349 551250016 16.70
Frequency of Tail Calls
Static Frequency
Platform Packages Tail Calls Total Percentage
Squeak - All 25162 407971 6.17
Squeak - Compiler 863 8747 9.87
Higher Dynamic Frequency
Action Tail Calls Total Percentage
Startup 47669 219054 21.76
Recompile 92041349 551250016 16.70
Implementations
Stack Interpreter
Cog VM
Implementations
Stack Interpreter
Cog VM
Stack Interpreter
Interpreter only
Look ahead to next bytecode for return
Switch to tail call eliminating implementation
Remove the existing stack frame and arguments
Pushes the new arguments and calls the next method
Stack Interpreter
Interpreter only
Look ahead to next bytecode for return
Switch to tail call eliminating implementation
Remove the existing stack frame and arguments
Pushes the new arguments and calls the next method
Stack Interpreter
Interpreter only
Look ahead to next bytecode for return
Switch to tail call eliminating implementation
Remove the existing stack frame and arguments
Pushes the new arguments and calls the next method
Stack Interpreter
Interpreter only
Look ahead to next bytecode for return
Switch to tail call eliminating implementation
Remove the existing stack frame and arguments
Pushes the new arguments and calls the next method
Stack Interpreter
Interpreter only
Look ahead to next bytecode for return
Switch to tail call eliminating implementation
Remove the existing stack frame and arguments
Pushes the new arguments and calls the next method
Cog JIT Compiler
Not optimizing interpreted calls
JIT compile tail calls as jumps
Cost of tail call check moved to JIT compile time
Cog JIT Compiler
Not optimizing interpreted calls
JIT compile tail calls as jumps
Cost of tail call check moved to JIT compile time
Cog JIT Compiler
Not optimizing interpreted calls
JIT compile tail calls as jumps
Cost of tail call check moved to JIT compile time
Cog VM - Inline Caching
Cog VM - levels of inline caching
No Inline Cache
Monomorphic Send Sites
Polymorphic Send Sites
Megamorphic Send Sites
Cog VM - Inline Caching
Cog VM - levels of inline caching
No Inline Cache
Monomorphic Send Sites
Polymorphic Send Sites
Megamorphic Send Sites
Cog VM - Inline Caching
Cog VM - levels of inline caching
No Inline Cache
Monomorphic Send Sites
Polymorphic Send Sites
Megamorphic Send Sites
Cog VM - Inline Caching
Cog VM - levels of inline caching
No Inline Cache
Monomorphic Send Sites
Polymorphic Send Sites
Megamorphic Send Sites
Cog VM - Inline Caching
Cog VM - levels of inline caching
No Inline Cache
Monomorphic Send Sites
Polymorphic Send Sites
Megamorphic Send Sites
Cog VM - Inline Caching - cont.
Bypass for unlinked send sites
Activate for monomorphic send sites
Bypass for polymorphic and megamorphic send sites
Need tail call and non-tail call JIT code for each send
Copy method lookup code to sender in tail calls
Cog VM - Inline Caching - cont.
Bypass for unlinked send sites
Activate for monomorphic send sites
Bypass for polymorphic and megamorphic send sites
Need tail call and non-tail call JIT code for each send
Copy method lookup code to sender in tail calls
Cog VM - Inline Caching - cont.
Bypass for unlinked send sites
Activate for monomorphic send sites
Bypass for polymorphic and megamorphic send sites
Need tail call and non-tail call JIT code for each send
Copy method lookup code to sender in tail calls
Cog VM - Inline Caching - cont.
Bypass for unlinked send sites
Activate for monomorphic send sites
Bypass for polymorphic and megamorphic send sites
Need tail call and non-tail call JIT code for each send
Copy method lookup code to sender in tail calls
Cog VM - Inline Caching - cont.
Bypass for unlinked send sites
Activate for monomorphic send sites
Bypass for polymorphic and megamorphic send sites
Need tail call and non-tail call JIT code for each send
Copy method lookup code to sender in tail calls
Results
Tail Recursive Tests
Real World Tests
Results
Tail Recursive Tests
Real World Tests
Factorial 500 x 1000
si
sitce
cog
cogtce0
50
100
150
200
250
Time(milliseconds)
Version Mean %Imp %SD Std Dev Median
si 258.43 1.41 258.00
sitce 251.61 2.6 0.7 1.02 251.00
cog 223.18 15.46 217.00
cogtce 199.01 10.8 6.9 1.04 199.00
Factorial 5000
si
sitce
cog
cogtce
0
2,000
4,000
6,000
Time(milliseconds)
Version Mean %Imp %SD Std Dev Median
si 6284.60 12.52 6283.00
sitce 1372.40 78.2 0.4 21.88 1356.00
cog 6587.72 16.45 6591.00
cogtce 1333.28 79.8 0.5 27.36 1314.00
Factorial 5000 Memory
si
sitce
cog
cogtce
0
20
40
60
MemoryUsage(megabytes)
Version Mean %Imp %SD Std Dev Median
si 61.11 3.28 60.33
sitce 47.37 22.5 7.7 3.35 47.22
cog 61.92 6.17 59.50
cogtce 46.99 24.1 11.3 3.33 46.89
Compile All Execution
si
sitce
cog
cogtce0
50
100
150
Time(seconds)
Version Mean %Imp %SD Std Dev Median
si 136.49 2.30 135.52
sitce 129.68 5.0 1.7 0.33 129.60
cog 109.59 0.90 109.29
cogtce 105.86 3.4 0.9 0.45 105.84
Browse Number Class Execution
si
sitce
cog
cogtce0
500
1,000
1,500
2,000
Time(milliseconds)
Version Mean %Imp %SD Std Dev Median
si 1842.60 51.99 1850.00
sitce 1759.90 4.5 4.2 56.60 1754.00
cog 1115.40 62.26 1124.00
cogtce 1127.20 -1.1 7.5 55.21 1124.00
Method Analyzer Execution
si
sitce
cog
cogtce
0
200
400
600
800
1,000
1,200
Time(milliseconds)
Version Mean %Imp %SD Std Dev Median
si 1215.38 29.02 1200.00
sitce 1180.62 2.9 3.1 23.67 1169.00
cog 254.14 38.37 243.00
cogtce 247.10 2.8 21.1 37.33 237.00
Conclusions
Significant improvements in execution time for tail recursive cases
Improvements in execution time for most general applications
Memory usage is only significantly affected for deep recursive call
chains
Stack Interpreter outperforms Cog in some tests
Stack Interpreter supports polymorphic calls
Increased JIT compiled method size leads to overhead
Conclusions
Significant improvements in execution time for tail recursive cases
Improvements in execution time for most general applications
Memory usage is only significantly affected for deep recursive call
chains
Stack Interpreter outperforms Cog in some tests
Stack Interpreter supports polymorphic calls
Increased JIT compiled method size leads to overhead
Conclusions
Significant improvements in execution time for tail recursive cases
Improvements in execution time for most general applications
Memory usage is only significantly affected for deep recursive call
chains
Stack Interpreter outperforms Cog in some tests
Stack Interpreter supports polymorphic calls
Increased JIT compiled method size leads to overhead
Conclusions
Significant improvements in execution time for tail recursive cases
Improvements in execution time for most general applications
Memory usage is only significantly affected for deep recursive call
chains
Stack Interpreter outperforms Cog in some tests
Stack Interpreter supports polymorphic calls
Increased JIT compiled method size leads to overhead
Conclusions
Significant improvements in execution time for tail recursive cases
Improvements in execution time for most general applications
Memory usage is only significantly affected for deep recursive call
chains
Stack Interpreter outperforms Cog in some tests
Stack Interpreter supports polymorphic calls
Increased JIT compiled method size leads to overhead
Conclusions
Significant improvements in execution time for tail recursive cases
Improvements in execution time for most general applications
Memory usage is only significantly affected for deep recursive call
chains
Stack Interpreter outperforms Cog in some tests
Stack Interpreter supports polymorphic calls
Increased JIT compiled method size leads to overhead
Conclusions and Future Work
Support polymorphic caches (partially complete!)
Reduce redundant code generation for Cog
Conclusions and Future Work
Support polymorphic caches (partially complete!)
Reduce redundant code generation for Cog
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

A Taste of Pharo 7.0
A Taste of Pharo 7.0A Taste of Pharo 7.0
A Taste of Pharo 7.0ESUG
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationWei-Ren Chen
 
PIL - A Platform Independent Language
PIL - A Platform Independent LanguagePIL - A Platform Independent Language
PIL - A Platform Independent Languagezefhemel
 
Jit complier
Jit complierJit complier
Jit complierKaya Ota
 
Test-driven language development
Test-driven language developmentTest-driven language development
Test-driven language developmentlennartkats
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platformdeimos
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18Jorge Hidalgo
 
Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Rebaz Najeeb
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCTim Burks
 
PHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success StoryPHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success StoryMichael Spector
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVMJung Kim
 
just in time JIT compiler
just in time JIT compilerjust in time JIT compiler
just in time JIT compilerMohit kumar
 
Yang in OpenDaylight
Yang in OpenDaylightYang in OpenDaylight
Yang in OpenDaylightGunjan Patel
 
Thesis - LLVM toolchain support as a plug-in for Eclipse CDT
Thesis - LLVM toolchain support as a plug-in for Eclipse CDTThesis - LLVM toolchain support as a plug-in for Eclipse CDT
Thesis - LLVM toolchain support as a plug-in for Eclipse CDTTuononenP
 
Single Sourcing RCP and RAP
Single Sourcing RCP and RAPSingle Sourcing RCP and RAP
Single Sourcing RCP and RAPChris Aniszczyk
 
CocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIsCocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIsTim Burks
 
Source-to-Source Compiler
Source-to-Source CompilerSource-to-Source Compiler
Source-to-Source CompilerMintoo Jakhmola
 
FOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRFOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRCharlie Gracie
 

Was ist angesagt? (20)

A Taste of Pharo 7.0
A Taste of Pharo 7.0A Taste of Pharo 7.0
A Taste of Pharo 7.0
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate Representation
 
PIL - A Platform Independent Language
PIL - A Platform Independent LanguagePIL - A Platform Independent Language
PIL - A Platform Independent Language
 
Jit complier
Jit complierJit complier
Jit complier
 
Test-driven language development
Test-driven language developmentTest-driven language development
Test-driven language development
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
Php7
Php7Php7
Php7
 
Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
 
PHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success StoryPHP Development Tools 2.0 - Success Story
PHP Development Tools 2.0 - Success Story
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
 
just in time JIT compiler
just in time JIT compilerjust in time JIT compiler
just in time JIT compiler
 
Yang in OpenDaylight
Yang in OpenDaylightYang in OpenDaylight
Yang in OpenDaylight
 
Thesis - LLVM toolchain support as a plug-in for Eclipse CDT
Thesis - LLVM toolchain support as a plug-in for Eclipse CDTThesis - LLVM toolchain support as a plug-in for Eclipse CDT
Thesis - LLVM toolchain support as a plug-in for Eclipse CDT
 
Single Sourcing RCP and RAP
Single Sourcing RCP and RAPSingle Sourcing RCP and RAP
Single Sourcing RCP and RAP
 
CocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIsCocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIs
 
Lab3 s2
Lab3 s2Lab3 s2
Lab3 s2
 
Source-to-Source Compiler
Source-to-Source CompilerSource-to-Source Compiler
Source-to-Source Compiler
 
FOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRFOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMR
 

Ähnlich wie Tail Call Elimination in Open Smalltalk

From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern CompilersMin-Yih Hsu
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced BasicsDoug Jones
 
oVirt CI Package Managenent
oVirt CI Package ManagenentoVirt CI Package Managenent
oVirt CI Package ManagenentBarak Korren
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsJean Deruelle
 
the grinder testing certification
the grinder testing certificationthe grinder testing certification
the grinder testing certificationVskills
 
Pharo Optimising JIT Internals
Pharo Optimising JIT InternalsPharo Optimising JIT Internals
Pharo Optimising JIT InternalsESUG
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVMJohn Lee
 
Introduction to JVM JIT Optimizations
Introduction to JVM JIT OptimizationsIntroduction to JVM JIT Optimizations
Introduction to JVM JIT Optimizationsdiegosoftware
 
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"LogeekNightUkraine
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav DukhinFwdays
 
The Value of Reactive
The Value of ReactiveThe Value of Reactive
The Value of ReactiveVMware Tanzu
 
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI serverPyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI serverPloneFoundation
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
open sta testing Certification
open sta testing Certificationopen sta testing Certification
open sta testing CertificationVskills
 
Clipper: A Low-Latency Online Prediction Serving System
Clipper: A Low-Latency Online Prediction Serving SystemClipper: A Low-Latency Online Prediction Serving System
Clipper: A Low-Latency Online Prediction Serving SystemDatabricks
 
Fisl - Deployment
Fisl - DeploymentFisl - Deployment
Fisl - DeploymentFabio Akita
 

Ähnlich wie Tail Call Elimination in Open Smalltalk (20)

From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern Compilers
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced Basics
 
JVM Under The Hood WDI.pdf
JVM Under The Hood WDI.pdfJVM Under The Hood WDI.pdf
JVM Under The Hood WDI.pdf
 
oVirt CI Package Managenent
oVirt CI Package ManagenentoVirt CI Package Managenent
oVirt CI Package Managenent
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on Mobicents
 
the grinder testing certification
the grinder testing certificationthe grinder testing certification
the grinder testing certification
 
Pharo Optimising JIT Internals
Pharo Optimising JIT InternalsPharo Optimising JIT Internals
Pharo Optimising JIT Internals
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVM
 
Introduction to JVM JIT Optimizations
Introduction to JVM JIT OptimizationsIntroduction to JVM JIT Optimizations
Introduction to JVM JIT Optimizations
 
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
 
The value of reactive
The value of reactiveThe value of reactive
The value of reactive
 
The Value of Reactive
The Value of ReactiveThe Value of Reactive
The Value of Reactive
 
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI serverPyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
Pyruvate, a reasonably fast, non-blocking, multithreaded WSGI server
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
open sta testing Certification
open sta testing Certificationopen sta testing Certification
open sta testing Certification
 
Clipper: A Low-Latency Online Prediction Serving System
Clipper: A Low-Latency Online Prediction Serving SystemClipper: A Low-Latency Online Prediction Serving System
Clipper: A Low-Latency Online Prediction Serving System
 
Fisl - Deployment
Fisl - DeploymentFisl - Deployment
Fisl - Deployment
 
Kubernetes 1001
Kubernetes 1001Kubernetes 1001
Kubernetes 1001
 

Mehr von ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 

Mehr von ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Kürzlich hochgeladen

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 

Kürzlich hochgeladen (20)

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 

Tail Call Elimination in Open Smalltalk

  • 1. Tail Call Elimination in Opensmalltalk Matthew Ralston Dave Mason Department of Computer Science Ryerson University c 2019 Matthew Ralston
  • 2. Agenda What is a Tail Call? Tail Call Elimination Stack Interpreter Implementation Cog VM JIT Implementation Results Conclusions and Future Work
  • 3. What is a Tail Call? Call followed by a return Smalltalk Example Array class>>new: sizeRequested ^ self basicNew: sizeRequested Call to basicNew: is a tail call Immediately followed by a return
  • 4. What is a Tail Call? Call followed by a return Smalltalk Example Array class>>new: sizeRequested ^ self basicNew: sizeRequested Call to basicNew: is a tail call Immediately followed by a return
  • 5. What is a Tail Call? Call followed by a return Smalltalk Example Array class>>new: sizeRequested ^ self basicNew: sizeRequested Call to basicNew: is a tail call Immediately followed by a return
  • 6. What is a Tail Call? Call followed by a return Smalltalk Example Array class>>new: sizeRequested ^ self basicNew: sizeRequested Call to basicNew: is a tail call Immediately followed by a return
  • 7. Tail call in Bytecode Bytecode for Array class»new: self pushTemp: 0 send: basicNew: returnTop
  • 8. Calling new without TCE Stack after calling new: new:’s stack frame new:’s argument Sender of new:’s frame
  • 9. Calling new without TCE Stack after calling new: new:’s stack frame new:’s argument Sender of new:’s frame
  • 10. Calling new without TCE - cont. Stack after calling basicNew: basicNew:’s stack frame basicNew:’s argument new:’s stack frame new:’s argument Sender of new:’s frame
  • 11. Calling new without TCE - cont. Stack after calling basicNew: basicNew:’s stack frame basicNew:’s argument new:’s stack frame new:’s argument Sender of new:’s frame
  • 12. Calling new without TCE - cont. Stack after returning from basicNew: basicNew:’s result new:’s stack frame new:’s argument Sender of new:’s frame
  • 13. Calling new without TCE - cont. Stack after returning from basicNew: basicNew:’s result new:’s stack frame new:’s argument Sender of new:’s frame
  • 14. Calling new without TCE - cont. Stack after returning from new: new:’s result Sender of new:’s frame
  • 15. Calling new without TCE - cont. Stack after returning from new: new:’s result Sender of new:’s frame
  • 16. Tail Call Elimination Why return to new:? Why keep new:’s stack frame?
  • 17. Tail Call Elimination Why return to new:? Why keep new:’s stack frame?
  • 18. Calling new with TCE new:’s stack frame new:’s argument Sender of new:’s frame
  • 19. Calling new with TCE - cont’d basicNew:’s stack frame basicNew:’s argument Sender of new:’s frame
  • 20. Calling new with TCE - cont’d basicNew:’s return Sender of new:’s frame
  • 21. Tail Recursion Elimination Special Case of Tail Call Elimination Recursive Call is also a Tail Call
  • 22. Tail Recursion Elimination Special Case of Tail Call Elimination Recursive Call is also a Tail Call
  • 23. Motivation Well Known Optimization Support in functional languages, CLR, etc. Not supported in JVM, Python Necessary for functional languages Can be useful for OO as well In common patterns like Visitor Pattern Iteration in Smalltalk
  • 24. Motivation Well Known Optimization Support in functional languages, CLR, etc. Not supported in JVM, Python Necessary for functional languages Can be useful for OO as well In common patterns like Visitor Pattern Iteration in Smalltalk
  • 25. Motivation Well Known Optimization Support in functional languages, CLR, etc. Not supported in JVM, Python Necessary for functional languages Can be useful for OO as well In common patterns like Visitor Pattern Iteration in Smalltalk
  • 26. Motivation Well Known Optimization Support in functional languages, CLR, etc. Not supported in JVM, Python Necessary for functional languages Can be useful for OO as well In common patterns like Visitor Pattern Iteration in Smalltalk
  • 27. Motivation Well Known Optimization Support in functional languages, CLR, etc. Not supported in JVM, Python Necessary for functional languages Can be useful for OO as well In common patterns like Visitor Pattern Iteration in Smalltalk
  • 28. Motivation Well Known Optimization Support in functional languages, CLR, etc. Not supported in JVM, Python Necessary for functional languages Can be useful for OO as well In common patterns like Visitor Pattern Iteration in Smalltalk
  • 29. Motivation Well Known Optimization Support in functional languages, CLR, etc. Not supported in JVM, Python Necessary for functional languages Can be useful for OO as well In common patterns like Visitor Pattern Iteration in Smalltalk
  • 30. Frequency of Tail Calls Static Frequency Platform Packages Tail Calls Total Percentage Squeak - All 25162 407971 6.17 Squeak - Compiler 863 8747 9.87 Higher Dynamic Frequency Action Tail Calls Total Percentage Startup 47669 219054 21.76 Recompile 92041349 551250016 16.70
  • 31. Frequency of Tail Calls Static Frequency Platform Packages Tail Calls Total Percentage Squeak - All 25162 407971 6.17 Squeak - Compiler 863 8747 9.87 Higher Dynamic Frequency Action Tail Calls Total Percentage Startup 47669 219054 21.76 Recompile 92041349 551250016 16.70
  • 34. Stack Interpreter Interpreter only Look ahead to next bytecode for return Switch to tail call eliminating implementation Remove the existing stack frame and arguments Pushes the new arguments and calls the next method
  • 35. Stack Interpreter Interpreter only Look ahead to next bytecode for return Switch to tail call eliminating implementation Remove the existing stack frame and arguments Pushes the new arguments and calls the next method
  • 36. Stack Interpreter Interpreter only Look ahead to next bytecode for return Switch to tail call eliminating implementation Remove the existing stack frame and arguments Pushes the new arguments and calls the next method
  • 37. Stack Interpreter Interpreter only Look ahead to next bytecode for return Switch to tail call eliminating implementation Remove the existing stack frame and arguments Pushes the new arguments and calls the next method
  • 38. Stack Interpreter Interpreter only Look ahead to next bytecode for return Switch to tail call eliminating implementation Remove the existing stack frame and arguments Pushes the new arguments and calls the next method
  • 39. Cog JIT Compiler Not optimizing interpreted calls JIT compile tail calls as jumps Cost of tail call check moved to JIT compile time
  • 40. Cog JIT Compiler Not optimizing interpreted calls JIT compile tail calls as jumps Cost of tail call check moved to JIT compile time
  • 41. Cog JIT Compiler Not optimizing interpreted calls JIT compile tail calls as jumps Cost of tail call check moved to JIT compile time
  • 42. Cog VM - Inline Caching Cog VM - levels of inline caching No Inline Cache Monomorphic Send Sites Polymorphic Send Sites Megamorphic Send Sites
  • 43. Cog VM - Inline Caching Cog VM - levels of inline caching No Inline Cache Monomorphic Send Sites Polymorphic Send Sites Megamorphic Send Sites
  • 44. Cog VM - Inline Caching Cog VM - levels of inline caching No Inline Cache Monomorphic Send Sites Polymorphic Send Sites Megamorphic Send Sites
  • 45. Cog VM - Inline Caching Cog VM - levels of inline caching No Inline Cache Monomorphic Send Sites Polymorphic Send Sites Megamorphic Send Sites
  • 46. Cog VM - Inline Caching Cog VM - levels of inline caching No Inline Cache Monomorphic Send Sites Polymorphic Send Sites Megamorphic Send Sites
  • 47. Cog VM - Inline Caching - cont. Bypass for unlinked send sites Activate for monomorphic send sites Bypass for polymorphic and megamorphic send sites Need tail call and non-tail call JIT code for each send Copy method lookup code to sender in tail calls
  • 48. Cog VM - Inline Caching - cont. Bypass for unlinked send sites Activate for monomorphic send sites Bypass for polymorphic and megamorphic send sites Need tail call and non-tail call JIT code for each send Copy method lookup code to sender in tail calls
  • 49. Cog VM - Inline Caching - cont. Bypass for unlinked send sites Activate for monomorphic send sites Bypass for polymorphic and megamorphic send sites Need tail call and non-tail call JIT code for each send Copy method lookup code to sender in tail calls
  • 50. Cog VM - Inline Caching - cont. Bypass for unlinked send sites Activate for monomorphic send sites Bypass for polymorphic and megamorphic send sites Need tail call and non-tail call JIT code for each send Copy method lookup code to sender in tail calls
  • 51. Cog VM - Inline Caching - cont. Bypass for unlinked send sites Activate for monomorphic send sites Bypass for polymorphic and megamorphic send sites Need tail call and non-tail call JIT code for each send Copy method lookup code to sender in tail calls
  • 54. Factorial 500 x 1000 si sitce cog cogtce0 50 100 150 200 250 Time(milliseconds) Version Mean %Imp %SD Std Dev Median si 258.43 1.41 258.00 sitce 251.61 2.6 0.7 1.02 251.00 cog 223.18 15.46 217.00 cogtce 199.01 10.8 6.9 1.04 199.00
  • 55. Factorial 5000 si sitce cog cogtce 0 2,000 4,000 6,000 Time(milliseconds) Version Mean %Imp %SD Std Dev Median si 6284.60 12.52 6283.00 sitce 1372.40 78.2 0.4 21.88 1356.00 cog 6587.72 16.45 6591.00 cogtce 1333.28 79.8 0.5 27.36 1314.00
  • 56. Factorial 5000 Memory si sitce cog cogtce 0 20 40 60 MemoryUsage(megabytes) Version Mean %Imp %SD Std Dev Median si 61.11 3.28 60.33 sitce 47.37 22.5 7.7 3.35 47.22 cog 61.92 6.17 59.50 cogtce 46.99 24.1 11.3 3.33 46.89
  • 57. Compile All Execution si sitce cog cogtce0 50 100 150 Time(seconds) Version Mean %Imp %SD Std Dev Median si 136.49 2.30 135.52 sitce 129.68 5.0 1.7 0.33 129.60 cog 109.59 0.90 109.29 cogtce 105.86 3.4 0.9 0.45 105.84
  • 58. Browse Number Class Execution si sitce cog cogtce0 500 1,000 1,500 2,000 Time(milliseconds) Version Mean %Imp %SD Std Dev Median si 1842.60 51.99 1850.00 sitce 1759.90 4.5 4.2 56.60 1754.00 cog 1115.40 62.26 1124.00 cogtce 1127.20 -1.1 7.5 55.21 1124.00
  • 59. Method Analyzer Execution si sitce cog cogtce 0 200 400 600 800 1,000 1,200 Time(milliseconds) Version Mean %Imp %SD Std Dev Median si 1215.38 29.02 1200.00 sitce 1180.62 2.9 3.1 23.67 1169.00 cog 254.14 38.37 243.00 cogtce 247.10 2.8 21.1 37.33 237.00
  • 60. Conclusions Significant improvements in execution time for tail recursive cases Improvements in execution time for most general applications Memory usage is only significantly affected for deep recursive call chains Stack Interpreter outperforms Cog in some tests Stack Interpreter supports polymorphic calls Increased JIT compiled method size leads to overhead
  • 61. Conclusions Significant improvements in execution time for tail recursive cases Improvements in execution time for most general applications Memory usage is only significantly affected for deep recursive call chains Stack Interpreter outperforms Cog in some tests Stack Interpreter supports polymorphic calls Increased JIT compiled method size leads to overhead
  • 62. Conclusions Significant improvements in execution time for tail recursive cases Improvements in execution time for most general applications Memory usage is only significantly affected for deep recursive call chains Stack Interpreter outperforms Cog in some tests Stack Interpreter supports polymorphic calls Increased JIT compiled method size leads to overhead
  • 63. Conclusions Significant improvements in execution time for tail recursive cases Improvements in execution time for most general applications Memory usage is only significantly affected for deep recursive call chains Stack Interpreter outperforms Cog in some tests Stack Interpreter supports polymorphic calls Increased JIT compiled method size leads to overhead
  • 64. Conclusions Significant improvements in execution time for tail recursive cases Improvements in execution time for most general applications Memory usage is only significantly affected for deep recursive call chains Stack Interpreter outperforms Cog in some tests Stack Interpreter supports polymorphic calls Increased JIT compiled method size leads to overhead
  • 65. Conclusions Significant improvements in execution time for tail recursive cases Improvements in execution time for most general applications Memory usage is only significantly affected for deep recursive call chains Stack Interpreter outperforms Cog in some tests Stack Interpreter supports polymorphic calls Increased JIT compiled method size leads to overhead
  • 66. Conclusions and Future Work Support polymorphic caches (partially complete!) Reduce redundant code generation for Cog
  • 67. Conclusions and Future Work Support polymorphic caches (partially complete!) Reduce redundant code generation for Cog