SlideShare una empresa de Scribd logo
1 de 28
Descargar para leer sin conexión
Implementation
IMPLEMENTATION
Muhammad Adil Raja
Roaming Researchers, Inc.
cbna
April 24, 2015
Implementation
OUTLINE I
1 INTRODUCTION
2 REFERENCES
Implementation
Introduction
INTRODUCTION
Topics covered in this chapter include:
Compilers vs Interpreters.
The Receiver as Argument.
Inherited Methods.
The problem of Multiple Inheritance.
Overridden Methods.
Name Encoding.
Dispatch Tables.
Bytecode Interpreters.
Just in Time Compilation.
Implementation
Introduction
INSPIRATION
Design patterns speed the process of finding a solution, by
eliminating the need to reinvent well-known and proven
solutions.
Just as important, design patterns provide a vocabulary
with which to discuss the space of possible design choices.
This vocabulary is termed a pattern language.
Implementation
Introduction
TWO GENERAL APPROACHES TO IMPLEMENTATION
Compilers - translated into basic machine code, source
code not available at run-time, generally very efficient.
Interpreters - translated into intermediate representation,
source code available for reference at run-time, generally
somewhat less efficient.
Endpoints are clear, but there are lots of grey areas in the
middle.
Java JIT systems are one of those grey areas between
compilers and interpreters.
Implementation
Introduction
A method is eventually invoked just like any other function.
This means that the receiver just be passed as an
argument.
Traditionally, it is passed as the first argument.
This means a method call, such as
aCardPile->addCard (currentCard)
Is translated into
addCard (aCardPile, currentCard)
(This is ignoring the method lookup process, which we will
discuss shortly).
Implementation
Introduction
On the other side, the receiver pseudo-variable is just a
formal argument:
Instead of
EXAMPLE
void CardPile : : addCard ( Card ∗ aCard ) {
. . .
}
We have:
void CardPile : : addCard ( Card ∗ aCard ) {
. . .
}
The first argument can then be used to access data members
and other methods.
Implementation
Introduction
NO-VIRTUAL METHODS
In languages that permit both virtual and non-virtual
methods (such as C++) a non-virtual method is translated
into a simple procedure call.
The receiver is made into the first argument.
The name is encoded to make it unique.
Implementation
Introduction
NAME ENCODING
Different classes are allowed to have functions with the
same name.
Some languages (C++) even permit multiple functions with
the same name within a class.
Yet linkers usually want every function to have a unique
name.
Solution - generate an internal name that encodes both
class name, function name, and argument types.
Example: Foo::Bar_int_float_int
An encoded name is sometimes called a mangled name.
You will sometimes see mangled names in error messages
generated by a linker.
Implementation
Introduction
INHERITED METHODS I
Now consider those methods defined in a parent class, but
used by a child class.
How is it that this mechanism can work?
Normally you cannot change the types of arguments (recall
that the receiver is just an argument).
Solution is that the data associated with an instance of a
child class is an extension of the data associated with the
parent class.
This means that data fields in the parent class will be found
at the same offset in the child class.
Implementation
Introduction
INHERITED METHODS II
FIGURE : Inherited methods.
Implementation
Introduction
A PROBLEM WITH MULTIPLE INHERITANCE
The idea that a child is an extension of the parent explains
one of the most vexing problems in the implementation of
multiple inheritance.
A child can extend one parent, or the other, but not both.
That is the offset of data fields in the child cannot
simultaneously match both parents.
FIGURE : A problem with multiple inheritance.
Implementation
Introduction
SLICING PROBLEM
The idea that a child can extend the data area of the parent
also makes it difficult to support both the following goals.
The goal of keeping memory on the stack, which is laid out
at compile time
The goal of supporting the polymorphic variable, which can
hold an instance of the child class at run time.
Most OO languages uphold (2) and abandon (1), C++ is an
exception in that it upholds (1) and therefore abandons (2).
Implementation
Introduction
OVERRIDEN METHODS
We next consider those methods that are defined in a
parent class, and overridden in a child class.
Problem, how can a polymorphic method invocation find
the right method?
Note that the right method can change during the course of
execution, even for the same method call.
EXAMPLE
CardPile ∗ aCardPile = new DiscardPile ( ) ;
Card ∗ aCard = . . . ;
aCardPile−>addCard ( aCard ) ; / / how to f i n d the r i g h t method
Implementation
Introduction
SOLUTION – A VIRTUAL METHOD
The solution is that every object contains an extra hidden
data field.
This data field points to an array of pointers to functions.
The array is determined by the current dynamic type, and
is shared by all instances of the class.
The offset of each method can be determined at compile
time.
FIGURE : Solution.
Implementation
Introduction
INSTANCES SHARE THE SAME VIRTUAL METHOD
Two instances of a class will share the same virtual
method table.
FIGURE : Example.
Implementation
Introduction
METHOD CALLS BECOME INDEXED OFFSETS
Each object maintains a pointer to a table, called the virtual
method table.
Virtual methods are identified by a fixed address in this
table.
A method call, such as:
A.foo(B, C)
is translated into
(* A.virTable[idx])(A, B, C)
Implementation
Introduction
BUILDING A VIRTUAL TABLE FOR A SUBCLASS
When a subclass is created, a new virtual method table is
generated.
Methods that are inherited point to the same function as
the parent class. (and are found in the same offset in the
virtual method table).
Methods that are overridden occupy the same offset
location, but point to the new function, instead of the
version in the parent class.
FIGURE : Virtual table.
Implementation
Introduction
VIRTUAL METHOD TABLE FOR SUBCLASSES
FIGURE : Virtual method table.
Implementation
Introduction
ELIMINATION OF VIRTUAL CALLS
Even though the overhead of a virtual call is small, it can
still add up.
If the (dynamic) class of the receiver is know, a virtual call
can simply become an ordinary procedure call.
Good optimizing compiles spend a considerable amount of
time tracing possible execution flows to gather this
information.
Sometimes methods can even be expanded in-line at the
point of call.
Implementation
Introduction
DISPATCH TABLES
In languages without static typing it is not practical to use a
virtual table, since such a table would need to encode all
methods, not simply those in a given class hierarchy.
An alternative technique uses a pointer to a list of
selector/method pairs.
When a method is invoked, a run-time search is performed
to match the method being called with the list of known
selectors, until an appropriate method is found.
In Objective-C the messages. is translated into:
objc_msgSend(neighbor, “checkrow:column:”, row,
column)
Implementation
Introduction
AN OBJECT AND ITS DISPATCH TABLE
FIGURE : Dispatch table.
An important difference is that the dispatch table is
searched at run-time, not at compile time.
Objective-C uses a linear list for the table, Smalltalk
generally uses a balanced search tree, but the idea is
similar.
Implementation
Introduction
METHOD CACHE
In order to avoid the cost of a dynamic search of dispatch
tables, a single global cache can be used to hold
frequently invoked methods.
The cache is used as a large hash table.
Prior to searching a dispatch table, the a single hashed
entry is examined - if it matches the selector being sought,
the method is used, if not the dispatch table is searched
and the new entry replaces the value in the hash table.
Assuming a good hash function is used, efficiency can be
very high.
Implementation
Introduction
THE MESSAGING FUNCTION CHECKING THE CACHE
FIGURE : The messaging funciton checking the cache.
Implementation
Introduction
BYTECODE INTERPRETERS
An implementation technique that is widely used
(Smalltalk, Java)
Program is compiled into an “assembly language” for an
imaginary machine.
Since this assembly code is often represented by a string
of bytes, it is called bytecode.
Since the machine is imaginary, can run on any platform.
But it must be simulated (by a virtual machine) and hence
you pay an execution time cost.
Implementation
Introduction
BYTES IN LITTLE SMALLTALK SYSTEM
FIGURE : The bytes in little Smalltalk system.
Implementation
Introduction
JUST IN TIME COMPILERS
A currently popular mix between compilers and
interpreters.
Key idea, first time a method is executed, translate the
bytecode into native machine code.
Gives fast execution time, pay penalty for translation (and
analysis if you want to do a good job).
Currently very popular with Java systems.
Implementation
References
REFERENCES
Images and content for developing these slides have been
taken from the follwoing book with the permission of the
author.
An Introduction to Object Oriented Programming, Timothy
A. Budd.
This presentation is developed with Beamer:
JuanLesPins, spruce.

Más contenido relacionado

La actualidad más candente

Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedNaresh Chintalcheru
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java Janu Jahnavi
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++ shammi mehra
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.pptTareq Hasan
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In JavaSpotle.ai
 
Intro. to prog. c++
Intro. to prog. c++Intro. to prog. c++
Intro. to prog. c++KurdGul
 
HDR Defence - Software Abstractions for Parallel Architectures
HDR Defence - Software Abstractions for Parallel ArchitecturesHDR Defence - Software Abstractions for Parallel Architectures
HDR Defence - Software Abstractions for Parallel ArchitecturesJoel Falcou
 
Polymorphism
PolymorphismPolymorphism
PolymorphismKumar
 
Oo Design And Patterns
Oo Design And PatternsOo Design And Patterns
Oo Design And PatternsAnil Bapat
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Abdul Hannan
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java PolymorphismSoba Arjun
 

La actualidad más candente (20)

Javapolymorphism
JavapolymorphismJavapolymorphism
Javapolymorphism
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism Unleashed
 
C++ interview question
C++ interview questionC++ interview question
C++ interview question
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
polymorphism
polymorphism polymorphism
polymorphism
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java
 
Intro. to prog. c++
Intro. to prog. c++Intro. to prog. c++
Intro. to prog. c++
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
C++ programing lanuage
C++ programing lanuageC++ programing lanuage
C++ programing lanuage
 
HDR Defence - Software Abstractions for Parallel Architectures
HDR Defence - Software Abstractions for Parallel ArchitecturesHDR Defence - Software Abstractions for Parallel Architectures
HDR Defence - Software Abstractions for Parallel Architectures
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Oo Design And Patterns
Oo Design And PatternsOo Design And Patterns
Oo Design And Patterns
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java Polymorphism
 

Destacado

Messages, Instances and Initialization
Messages, Instances and InitializationMessages, Instances and Initialization
Messages, Instances and Initializationadil raja
 
Polymorphism and Software Reuse
Polymorphism and Software ReusePolymorphism and Software Reuse
Polymorphism and Software Reuseadil raja
 
The Polymorphic Variable
The Polymorphic VariableThe Polymorphic Variable
The Polymorphic Variableadil raja
 
Container Classes
Container ClassesContainer Classes
Container Classesadil raja
 
Object Interconnections
Object InterconnectionsObject Interconnections
Object Interconnectionsadil raja
 
Implications of Substitution
Implications of SubstitutionImplications of Substitution
Implications of Substitutionadil raja
 
Distributed Computing
Distributed ComputingDistributed Computing
Distributed Computingadil raja
 
Object-Oriented Design
Object-Oriented DesignObject-Oriented Design
Object-Oriented Designadil raja
 
Classes And Methods
Classes And MethodsClasses And Methods
Classes And Methodsadil raja
 
Thinking Object-Oriented
Thinking Object-OrientedThinking Object-Oriented
Thinking Object-Orientedadil raja
 
Static and Dynamic Behavior
Static and Dynamic BehaviorStatic and Dynamic Behavior
Static and Dynamic Behavioradil raja
 
Inheritance and Substitution
Inheritance and SubstitutionInheritance and Substitution
Inheritance and Substitutionadil raja
 
Subclasses and Subtypes
Subclasses and SubtypesSubclasses and Subtypes
Subclasses and Subtypesadil raja
 
Reflection and Introspection
Reflection and IntrospectionReflection and Introspection
Reflection and Introspectionadil raja
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swingadil raja
 
Software Frameworks
Software FrameworksSoftware Frameworks
Software Frameworksadil raja
 

Destacado (20)

Messages, Instances and Initialization
Messages, Instances and InitializationMessages, Instances and Initialization
Messages, Instances and Initialization
 
Polymorphism and Software Reuse
Polymorphism and Software ReusePolymorphism and Software Reuse
Polymorphism and Software Reuse
 
Overriding
OverridingOverriding
Overriding
 
The Polymorphic Variable
The Polymorphic VariableThe Polymorphic Variable
The Polymorphic Variable
 
The STL
The STLThe STL
The STL
 
Container Classes
Container ClassesContainer Classes
Container Classes
 
Object Interconnections
Object InterconnectionsObject Interconnections
Object Interconnections
 
Implications of Substitution
Implications of SubstitutionImplications of Substitution
Implications of Substitution
 
Distributed Computing
Distributed ComputingDistributed Computing
Distributed Computing
 
Overloading
OverloadingOverloading
Overloading
 
Generics
GenericsGenerics
Generics
 
Object-Oriented Design
Object-Oriented DesignObject-Oriented Design
Object-Oriented Design
 
Classes And Methods
Classes And MethodsClasses And Methods
Classes And Methods
 
Thinking Object-Oriented
Thinking Object-OrientedThinking Object-Oriented
Thinking Object-Oriented
 
Static and Dynamic Behavior
Static and Dynamic BehaviorStatic and Dynamic Behavior
Static and Dynamic Behavior
 
Inheritance and Substitution
Inheritance and SubstitutionInheritance and Substitution
Inheritance and Substitution
 
Subclasses and Subtypes
Subclasses and SubtypesSubclasses and Subtypes
Subclasses and Subtypes
 
Reflection and Introspection
Reflection and IntrospectionReflection and Introspection
Reflection and Introspection
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swing
 
Software Frameworks
Software FrameworksSoftware Frameworks
Software Frameworks
 

Similar a Implementation

INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxINDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxIndu65
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
 
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questionsnicolbiden
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using ReflectionGanesh Samarthyam
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++smumbahelp
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++smumbahelp
 
De-virtualizing virtual Function Calls using various Type Analysis Technique...
De-virtualizing virtual Function Calls using various Type  Analysis Technique...De-virtualizing virtual Function Calls using various Type  Analysis Technique...
De-virtualizing virtual Function Calls using various Type Analysis Technique...IOSR Journals
 

Similar a Implementation (20)

INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxINDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
 
Csci360 20 (1)
Csci360 20 (1)Csci360 20 (1)
Csci360 20 (1)
 
Csci360 20
Csci360 20Csci360 20
Csci360 20
 
Andy On Closures
Andy On ClosuresAndy On Closures
Andy On Closures
 
Java performance
Java performanceJava performance
Java performance
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
 
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questions
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
C#
C#C#
C#
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++
 
Java Basics
Java BasicsJava Basics
Java Basics
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Java mcq
Java mcqJava mcq
Java mcq
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
C# interview
C# interviewC# interview
C# interview
 
De-virtualizing virtual Function Calls using various Type Analysis Technique...
De-virtualizing virtual Function Calls using various Type  Analysis Technique...De-virtualizing virtual Function Calls using various Type  Analysis Technique...
De-virtualizing virtual Function Calls using various Type Analysis Technique...
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
 

Más de adil raja

A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specificationadil raja
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehiclesadil raja
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystifiedadil raja
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)adil raja
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Researchadil raja
 
The Knock Knock Protocol
The Knock Knock ProtocolThe Knock Knock Protocol
The Knock Knock Protocoladil raja
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Socketsadil raja
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Executionadil raja
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistanadil raja
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousingadil raja
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...adil raja
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...adil raja
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPadil raja
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specificationsadil raja
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...adil raja
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...adil raja
 

Más de adil raja (20)

ANNs.pdf
ANNs.pdfANNs.pdf
ANNs.pdf
 
A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specification
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystified
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Research
 
The Knock Knock Protocol
The Knock Knock ProtocolThe Knock Knock Protocol
The Knock Knock Protocol
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Sockets
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Execution
 
Thesis
ThesisThesis
Thesis
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistan
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
 
VoIP
VoIPVoIP
VoIP
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specifications
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 
ULMAN-GUI
ULMAN-GUIULMAN-GUI
ULMAN-GUI
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 

Último

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 

Último (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

Implementation

  • 1. Implementation IMPLEMENTATION Muhammad Adil Raja Roaming Researchers, Inc. cbna April 24, 2015
  • 3. Implementation Introduction INTRODUCTION Topics covered in this chapter include: Compilers vs Interpreters. The Receiver as Argument. Inherited Methods. The problem of Multiple Inheritance. Overridden Methods. Name Encoding. Dispatch Tables. Bytecode Interpreters. Just in Time Compilation.
  • 4. Implementation Introduction INSPIRATION Design patterns speed the process of finding a solution, by eliminating the need to reinvent well-known and proven solutions. Just as important, design patterns provide a vocabulary with which to discuss the space of possible design choices. This vocabulary is termed a pattern language.
  • 5. Implementation Introduction TWO GENERAL APPROACHES TO IMPLEMENTATION Compilers - translated into basic machine code, source code not available at run-time, generally very efficient. Interpreters - translated into intermediate representation, source code available for reference at run-time, generally somewhat less efficient. Endpoints are clear, but there are lots of grey areas in the middle. Java JIT systems are one of those grey areas between compilers and interpreters.
  • 6. Implementation Introduction A method is eventually invoked just like any other function. This means that the receiver just be passed as an argument. Traditionally, it is passed as the first argument. This means a method call, such as aCardPile->addCard (currentCard) Is translated into addCard (aCardPile, currentCard) (This is ignoring the method lookup process, which we will discuss shortly).
  • 7. Implementation Introduction On the other side, the receiver pseudo-variable is just a formal argument: Instead of EXAMPLE void CardPile : : addCard ( Card ∗ aCard ) { . . . } We have: void CardPile : : addCard ( Card ∗ aCard ) { . . . } The first argument can then be used to access data members and other methods.
  • 8. Implementation Introduction NO-VIRTUAL METHODS In languages that permit both virtual and non-virtual methods (such as C++) a non-virtual method is translated into a simple procedure call. The receiver is made into the first argument. The name is encoded to make it unique.
  • 9. Implementation Introduction NAME ENCODING Different classes are allowed to have functions with the same name. Some languages (C++) even permit multiple functions with the same name within a class. Yet linkers usually want every function to have a unique name. Solution - generate an internal name that encodes both class name, function name, and argument types. Example: Foo::Bar_int_float_int An encoded name is sometimes called a mangled name. You will sometimes see mangled names in error messages generated by a linker.
  • 10. Implementation Introduction INHERITED METHODS I Now consider those methods defined in a parent class, but used by a child class. How is it that this mechanism can work? Normally you cannot change the types of arguments (recall that the receiver is just an argument). Solution is that the data associated with an instance of a child class is an extension of the data associated with the parent class. This means that data fields in the parent class will be found at the same offset in the child class.
  • 12. Implementation Introduction A PROBLEM WITH MULTIPLE INHERITANCE The idea that a child is an extension of the parent explains one of the most vexing problems in the implementation of multiple inheritance. A child can extend one parent, or the other, but not both. That is the offset of data fields in the child cannot simultaneously match both parents. FIGURE : A problem with multiple inheritance.
  • 13. Implementation Introduction SLICING PROBLEM The idea that a child can extend the data area of the parent also makes it difficult to support both the following goals. The goal of keeping memory on the stack, which is laid out at compile time The goal of supporting the polymorphic variable, which can hold an instance of the child class at run time. Most OO languages uphold (2) and abandon (1), C++ is an exception in that it upholds (1) and therefore abandons (2).
  • 14. Implementation Introduction OVERRIDEN METHODS We next consider those methods that are defined in a parent class, and overridden in a child class. Problem, how can a polymorphic method invocation find the right method? Note that the right method can change during the course of execution, even for the same method call. EXAMPLE CardPile ∗ aCardPile = new DiscardPile ( ) ; Card ∗ aCard = . . . ; aCardPile−>addCard ( aCard ) ; / / how to f i n d the r i g h t method
  • 15. Implementation Introduction SOLUTION – A VIRTUAL METHOD The solution is that every object contains an extra hidden data field. This data field points to an array of pointers to functions. The array is determined by the current dynamic type, and is shared by all instances of the class. The offset of each method can be determined at compile time. FIGURE : Solution.
  • 16. Implementation Introduction INSTANCES SHARE THE SAME VIRTUAL METHOD Two instances of a class will share the same virtual method table. FIGURE : Example.
  • 17. Implementation Introduction METHOD CALLS BECOME INDEXED OFFSETS Each object maintains a pointer to a table, called the virtual method table. Virtual methods are identified by a fixed address in this table. A method call, such as: A.foo(B, C) is translated into (* A.virTable[idx])(A, B, C)
  • 18. Implementation Introduction BUILDING A VIRTUAL TABLE FOR A SUBCLASS When a subclass is created, a new virtual method table is generated. Methods that are inherited point to the same function as the parent class. (and are found in the same offset in the virtual method table). Methods that are overridden occupy the same offset location, but point to the new function, instead of the version in the parent class. FIGURE : Virtual table.
  • 19. Implementation Introduction VIRTUAL METHOD TABLE FOR SUBCLASSES FIGURE : Virtual method table.
  • 20. Implementation Introduction ELIMINATION OF VIRTUAL CALLS Even though the overhead of a virtual call is small, it can still add up. If the (dynamic) class of the receiver is know, a virtual call can simply become an ordinary procedure call. Good optimizing compiles spend a considerable amount of time tracing possible execution flows to gather this information. Sometimes methods can even be expanded in-line at the point of call.
  • 21. Implementation Introduction DISPATCH TABLES In languages without static typing it is not practical to use a virtual table, since such a table would need to encode all methods, not simply those in a given class hierarchy. An alternative technique uses a pointer to a list of selector/method pairs. When a method is invoked, a run-time search is performed to match the method being called with the list of known selectors, until an appropriate method is found. In Objective-C the messages. is translated into: objc_msgSend(neighbor, “checkrow:column:”, row, column)
  • 22. Implementation Introduction AN OBJECT AND ITS DISPATCH TABLE FIGURE : Dispatch table. An important difference is that the dispatch table is searched at run-time, not at compile time. Objective-C uses a linear list for the table, Smalltalk generally uses a balanced search tree, but the idea is similar.
  • 23. Implementation Introduction METHOD CACHE In order to avoid the cost of a dynamic search of dispatch tables, a single global cache can be used to hold frequently invoked methods. The cache is used as a large hash table. Prior to searching a dispatch table, the a single hashed entry is examined - if it matches the selector being sought, the method is used, if not the dispatch table is searched and the new entry replaces the value in the hash table. Assuming a good hash function is used, efficiency can be very high.
  • 24. Implementation Introduction THE MESSAGING FUNCTION CHECKING THE CACHE FIGURE : The messaging funciton checking the cache.
  • 25. Implementation Introduction BYTECODE INTERPRETERS An implementation technique that is widely used (Smalltalk, Java) Program is compiled into an “assembly language” for an imaginary machine. Since this assembly code is often represented by a string of bytes, it is called bytecode. Since the machine is imaginary, can run on any platform. But it must be simulated (by a virtual machine) and hence you pay an execution time cost.
  • 26. Implementation Introduction BYTES IN LITTLE SMALLTALK SYSTEM FIGURE : The bytes in little Smalltalk system.
  • 27. Implementation Introduction JUST IN TIME COMPILERS A currently popular mix between compilers and interpreters. Key idea, first time a method is executed, translate the bytecode into native machine code. Gives fast execution time, pay penalty for translation (and analysis if you want to do a good job). Currently very popular with Java systems.
  • 28. Implementation References REFERENCES Images and content for developing these slides have been taken from the follwoing book with the permission of the author. An Introduction to Object Oriented Programming, Timothy A. Budd. This presentation is developed with Beamer: JuanLesPins, spruce.