Towards an improvement in the understanding of the operation of the interpreter of an object vm by means of a graphical tool - by Mariano Badoglio & Patricia Fracchia
The following work is about a proposal to use a graphical tool as a didactical teaching on a complex topic like it is the Smalltalk Interpreter and how it works inside the virtual machine. The motivations arises on the need to arrive "otherwise" to the students. Its main contribution is that there is a theorical and methodological vacancy on this topic, regarding the didactical aspects, and its relation ith the teaching and learning processes. The main goal is to show the first steps in the analysis of the topic that will be applied to the cathedra "Programming Paradigms" placed on second year of the career Information Systems Engeneering at UTN-FRRo.
Similar to Towards an improvement in the understanding of the operation of the interpreter of an object vm by means of a graphical tool - by Mariano Badoglio & Patricia Fracchia
Similar to Towards an improvement in the understanding of the operation of the interpreter of an object vm by means of a graphical tool - by Mariano Badoglio & Patricia Fracchia (20)
Towards an improvement in the understanding of the operation of the interpreter of an object vm by means of a graphical tool - by Mariano Badoglio & Patricia Fracchia
1. Towards an improvement in the
understanding of the operation of
the interpreter of an object VM by
means of a graphical tool
Ing. Mariano J. Badoglio
Lic. Patricia S. Fracchia
3. Why a graphic tool?
A picture is worth …
It is effective to face
complex scenarios rich
in knowledge and
information.
• It helps to transmit,
process and manage
It has significant
features:
• Is kind
• It could be understood in
only one shoot.
• It is "addictive", viral,
open, suggestive, inspiring
• Opens the possibility to
explore and motivates to
learn more.
It allows an effective
understanding
• The human being
processes images 600
times faster than texts
and, remember 80% of
what he see, compared to
20% of what he read.
• «A picture is worth a
thousand words.»
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
4. The difficulty for teaching and learning
the subject
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
Topic complexity
Abstract ideas covering
Activities that are pending execution and that must be
resumed later
Impossibility to directly observe the operation of the
interpreter
5. Introducción – Conceptos de base
Smalltalk
Virtual
Machine
Virtual
Image
Compiler /
Interpreter
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
6. Sistema Smalltalk
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
Smalltalk
Virtual Image
System objects
Virtual Machine
Hardware
devices
Machine
language
routines
7. Compiler / Interpreter
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
Compiler
Interpreter
Compiler /
Interpreter
•From source code…
•The compiler generates binary code
to be executed on a real processor.
•From source code…
•The interpreter translates and
executes the instructions
dynamically.
•From source code…
•The compiler generates
intermediate binary code to be
executed in a virtual processor.
•The interpreter translates and
executes on a real processor.
8. Development sequence
• Writing the source
code (String)
1.
Programming
• Translation of source
to bytecodes.
• Generation of the
CompiledMethod
2. Compilation
CompiledMethod
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
9. Operation of the Interpreter
Interpreter
State of Interpreter
Cycle of Interpreter
Contexts
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
10. Operation of the Interpreter
• CompiledMethod
• Location of next bytecode to be excecuted.
• Receiver and arguments
• Temporary variables
• Stack
State of Interpreter
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
11. Operation of the Interpreter
• 1. Fetch the
Bytecode
• 2. Increment the
instruction
pointer
• 3. Excecute the
Bytecode
Cycle del
Intérprete
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
12. Operation of the Interpreter
Contexts
The state of the interpreter is saved on contexts.
There will be many contexts in the system at any time
The context that represents the current state of the
interpreter is called the active context
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
13. Case study
Show the quote of a book in a specific format.
Class Diagram
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
14. Case study
• 1. Writing the source
of #formatoCorto
•Writing the source
code (String)
1.
Programming
•Translation of source
to bytecodes.
•Generation of the
CompiledMethod
2. Compilation
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
15. Case study
• 2. Compiled method of
#formatoCorto
• Writing the source
code (String)
1.
Programming
• Translation of source
to bytecodes.
• Generation of the
CompiledMethod
2. Compilation
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
16. Study case
• Execution of the method in the Pharo system.
• The objects will be inspected for the
visualization of the process of executing a
method.
• We will show the steps and their results based
on the information provided by the Pharo
system.
• The objective is to expose the complexity of
the operation of the interpreter.
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
17. Excecuting #formatoCorto
• Excecuting the method
to visualize its result
– We have an object of the
class #Libro (Book),
already created.
– Through the inspector
we will proceed to
excecute the method
#formatoCorto.
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
18. • Excecution step by
step:
– The MethodContext
is created in order to
excecute
#formatoCorto.
– It contains the
interpreter’s state.
Excecution of #formatoCorto
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
19. Excecution of #formatoCorto
• State:
– Location of next
bytecode to excecute
(PC).
– Receptor and
arguments
– Temporary variables
– Stack
– CompiledMethod
No temporary
variables
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
20. Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
• Excecution of #autor
– It only returns the value
of a variable, so it is not
necesary to generate a
new context.
– The result will be saved
on top of the stack.
– We will proceed to show
the excecution via the
cycle of the Interpreter.
Excecution of #formatoCorto
21. Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
• Excecution of #autor.
• 1. Fetch the Bytecode
– PC 66 => Bytecode 208
• 2. Increment Instruction pointer
– PC = PC + 1 => PC = 67
• 3. Excecute the bycode
– 208 -> Excecute unary method
#autor.
– The result is saved on the top of
the stack.
– Instruction pointer updated.
Excecution of #formatoCorto
22. Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
• Excecution of
#nombreYApellido.
– It returns the name and
surname of the autor
concatenated by a space (‘ ‘).
– The method is sent to the first
element on the stack: the
object autor.
– Its excecution will require the
creation of a new context.
– The result will besaved on top
of #formatoCorto excecution
context stack.
Excecution of #formatoCorto
23. Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
• Excecution of
#nombreYApellido.
• 1. Fetch the Bytecode
– PC 67 => Bytecode 209
• 2. Increment instruction pointer
– PC = PC + 1 => PC = 68
• 3. Excecute the Bytecode
– 209 -> Excecute unary method
#nombreYApellido
– A new context is created.
– Actual context is suspended.
Excecution of #formatoCorto
24. • Excecution of
#nombreYApellido.
– This is the new
context needed to
excecute the
method
#nombreYApellido.
Excecution of #formatoCorto
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
25. Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
Excecution of #nombreYApellido.
1. Fetch the Bytecode
– PC 58 => Bytecode 208
2. Increment the instruction pointer
– PC = PC + 1 => PC = 59
3. Excecute the Bytecode
– 208 -> Excecution of unary
method #nombre
– No new context is created,
the result is pushed to the
top of the stack.
Excecution of #formatoCorto
26. Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
• Excecution of
#nombreYApellido
1. Next step is the excecution of
method comma (#,) and then
the method #apellido all in the
same way.
2. The final result will return to the
caller context that is suspended,
and is pushed to the top of the
stack.
Excecution of #formatoCorto
27. • Excecution of
#nombreYApellido.
1. The suspended methos gets
the excecution flow and
become active.
2. The result of the last method is
now on the top of the stack.
Excecution of #formatoCorto
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
28. Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
• Excecution of
#formatoCorto.
1. Now we move the excecution
up to bytecode pointed by PC
72.
2. Here we could see that at the
top of the stack are the name
of the book and the name and
surname of the autor.
3. By excecuting the remaining
Bytecodes those strings will be
concatenated generating the
final result.
Excecution of #formatoCorto
29. Graphic tool
Main screen mock-up
• Elements on
screen:
– Excecution
sequence.
– Source code
of method
being in
excecution.
– Active
context.
– Suspended
context.
– Object
Memory.
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
30. Graphic tool
Main screen mock-up
• Navigation
of objects
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
31. Graphic tool
Conclusions
Graphics complements the orality.
They allow the simultaneous exposure of
concepts, observation and understanding
of their interrelation.
Helps to attract and maintain attention
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
32. Graphic tool
Conclusions
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
They help highlight the most important
concepts.
They materialize abstract ideas, decreasing
possible erroneous interpretations.
They are the means used by our brain to
represent, process and transform large
amounts of information.
33. Graphic tool
Conclusions
Ing. Mariano Badoglio – Lic. Patricia Fracchia – UTN-FRRo
They are a very important resource that
collaborates in the didactic transposition.
In the universe of human knowledge, pedagogy allows
the stars of knowledge to be brought closer, didactics
reach those more distant.
René Arango