SlideShare una empresa de Scribd logo
1 de 11
S.Ducasse 1
QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.
Stéphane Ducasse
Stephane.Ducasse@univ-savoie.fr
http://www.listic.univ-savoie.fr/~ducasse/
Smalltalk gives to the programmer the illusion of
uniformity for example SmallIntegers are defined
as any other object but in memory they are
different than objects. In that case the object
The Internal Structure of
Objects in VW
S.Ducasse 2
License: CC-Attribution-ShareAlike 2.0
http://creativecommons.org/licenses/by-sa/2.0/
S.Ducasse 3
• Non indexable, pointer
Object subclass: #Packet
instanceVariableNames: 'contents addressee originator '
classVariableNames: ''
poolDictionaries: ''
category: 'Demo-LAN'
• Indexable pointer
• ArrayedCollection variableSubclass: #Array
• instanceVariableNames: ''
• classVariableNames: ''
• poolDictionaries: ''
• category: 'Collections-Arrayed'
Three Ways to Create Classes (VW30 Sq)
S.Ducasse 4
• Indexable, non pointer
•
LimitedPrecisionReal variableByteSubclass: #Float
instanceVariableNames: ''
classVariableNames: 'Pi RadiansPerDegree '
poolDictionaries: ''
category: 'Magnitude-Numbers'
It is not possible to define named instance variables
Three Ways to Create Classes
S.Ducasse 5
• Identifying subclass:
| collection |
collection := SortedCollection new.
Smalltalk allBehaviorsDo: [:each ||boolean|
boolean := each isMeta not and: [each isObsolete not].
boolean := boolean and: [each isFixed].
boolean ifTrue: [collection add: each name]].
^collection
Let there be Code
S.Ducasse 6
• Identifying variableSubclass:
boolean := each isMeta not and: [each isObsolete not].
boolean := boolean and: [each isPointers].
boolean := boolean and: [each isVariable].
boolean ifTrue: [collection add: each name]]
• Identifying variableByteSubclass:
boolean := each isMeta not and: [each isObsolete not].
boolean := boolean and: [each isBits].
boolean := boolean and: [each isVariable].
boolean ifTrue: [collection add: each name]]
Let there be Code
S.Ducasse 7
• The information for distinguishing between these three
type is stored in the format instance variable of Behavior.
• Behavior>>isBits
• "Answer whether the receiver contains just bits (not
pointers)."
• ^format noMask: self pointersMask
• Behavior>>hasImmediateInstances
immediate type object?
• Behavior>>isFixed
non-indexable type object?
• Behavior>>isPointers
pointers type object?
• Behavior>>isVariable
Format and other
S.Ducasse 8
pointer type [isPointers]
indexable type [isVariable] variableSubclass:
non-index type [isFixed] subclass:
non-pointer [isBits]
index type [isVariable] variableByteSubclass:
non-index type [isFixed] subclass:
immediate [hasImmediateInstances] subclass:
Format and other (ii)
S.Ducasse 9
• objectSizeInBytes: anObject
• |bytesInOTE bytesInOOP aClass indexableFieldSize instVarFieldSize size|
• bytesInOTE := ObjectMemory current bytesPerOTE.
• bytesInOOP := ObjectMemory current bytesPerOOP.
• aClass := anObject class.
• aClass isPointers
• ifTrue: [instVarFieldSize := aClass instSize * bytesInOOP.
• aClass isVariable
• ifTrue: [indexableFieldSize := anObject basicSize * bytesInOOP]
• ifFalse: [indexableFieldSize := 0]]
• ifFalse: [instVarFieldSize := 0.
• aClass isVariable
• ifTrue: [indexableFieldSize := anObject basicSize +
• (bytesInOOP -1) bitAnd: bytesInOOP
negated]
• ifFalse:[indexableFieldSize := 0]].
• size := bytesInOTE + instVarFieldSize + indexableFieldSize.
• ^size
Object size in bytes
S.Ducasse 10
• OTE (ObjectTable Entry) = 12 bytes: OTE is a description of an Object (class,
iv, hash, gc flags, ....)
• OOP (Object Oriented Pointer) = 4 bytes
• Pointers Type
• Internals new objectSizeInBytes:WorkStation new
• pointer, instSize = 3 (dependents name nextNode) * 4 = 12 not indexable
• Internals new objectSizeInBytes: (WorkStation new name: #abc)
• idem, because not recursive
• Internals new objectSizeInBytes: 1@2
• 12 + 2 * 4 = 20 bytes
• Indexable and Pointers Type
• Internals new objectSizeInBytes: (OrderedCollection new: 10)
• OrderedCollection new: 10
• = 2 inst variable and 10 indexes
• class instSize = 2 * 4
• basicSize = 10 * 4
• = 60 bytes
Analysis
S.Ducasse 11
• Indexable pure
• Internals new objectSizeInBytes: Float pi
• 4 indexed variable * 4 = 16 bytes
• Non pointer, non Index = immediate, but an
immediate type object has no object table entry.The
immediate object is stored into the OOP.
• Internals new objectSizeInBytes: 1
• = 12 bytes, but the code should use isImmediate
Analysis (ii)

Más contenido relacionado

Destacado (20)

Stoop 423-some designpatterns
Stoop 423-some designpatternsStoop 423-some designpatterns
Stoop 423-some designpatterns
 
Stoop 303-advanced blocks
Stoop 303-advanced blocksStoop 303-advanced blocks
Stoop 303-advanced blocks
 
06 debugging
06 debugging06 debugging
06 debugging
 
12 - Conditions and Loops
12 - Conditions and Loops12 - Conditions and Loops
12 - Conditions and Loops
 
Stoop 390-instruction stream
Stoop 390-instruction streamStoop 390-instruction stream
Stoop 390-instruction stream
 
Stoop sed-smells
Stoop sed-smellsStoop sed-smells
Stoop sed-smells
 
Stoop 436-strategy
Stoop 436-strategyStoop 436-strategy
Stoop 436-strategy
 
15 - Streams
15 - Streams15 - Streams
15 - Streams
 
Stoop ed-class forreuse
Stoop ed-class forreuseStoop ed-class forreuse
Stoop ed-class forreuse
 
Debugging VisualWorks
Debugging VisualWorksDebugging VisualWorks
Debugging VisualWorks
 
Stoop sed-sharing ornot
Stoop sed-sharing ornotStoop sed-sharing ornot
Stoop sed-sharing ornot
 
07 bestpractice
07 bestpractice07 bestpractice
07 bestpractice
 
Stoop metaclasses
Stoop metaclassesStoop metaclasses
Stoop metaclasses
 
Stoop ed-dual interface
Stoop ed-dual interfaceStoop ed-dual interface
Stoop ed-dual interface
 
09 metaclasses
09 metaclasses09 metaclasses
09 metaclasses
 
Stoop 305-reflective programming5
Stoop 305-reflective programming5Stoop 305-reflective programming5
Stoop 305-reflective programming5
 
03 standardclasses
03 standardclasses03 standardclasses
03 standardclasses
 
5 - OOP - Smalltalk in a Nutshell (c)
5 - OOP - Smalltalk in a Nutshell (c)5 - OOP - Smalltalk in a Nutshell (c)
5 - OOP - Smalltalk in a Nutshell (c)
 
14 - Exceptions
14 - Exceptions14 - Exceptions
14 - Exceptions
 
Stoop ed-lod
Stoop ed-lodStoop ed-lod
Stoop ed-lod
 

Similar a Stoop 301-internal objectstructureinvw

FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
Petr Dvorak
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
Kostas Mavridis
 

Similar a Stoop 301-internal objectstructureinvw (20)

iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev intro
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone development
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cph
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOS
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
 
Lecture 3-ARC
Lecture 3-ARCLecture 3-ARC
Lecture 3-ARC
 
How and Where in GLORP
How and Where in GLORPHow and Where in GLORP
How and Where in GLORP
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Management
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not Java
 
Introduction to java and oop
Introduction to java and oopIntroduction to java and oop
Introduction to java and oop
 
Real World MVC
Real World MVCReal World MVC
Real World MVC
 
About Python
About PythonAbout Python
About Python
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
 
Evolve your coding with some BDD
Evolve your coding with some BDDEvolve your coding with some BDD
Evolve your coding with some BDD
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
 
Slot Composition
Slot CompositionSlot Composition
Slot Composition
 
Slot Composition
Slot CompositionSlot Composition
Slot Composition
 
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
 

Más de The World of Smalltalk (20)

05 seaside canvas
05 seaside canvas05 seaside canvas
05 seaside canvas
 
99 questions
99 questions99 questions
99 questions
 
13 traits
13 traits13 traits
13 traits
 
12 virtualmachine
12 virtualmachine12 virtualmachine
12 virtualmachine
 
11 bytecode
11 bytecode11 bytecode
11 bytecode
 
10 reflection
10 reflection10 reflection
10 reflection
 
08 refactoring
08 refactoring08 refactoring
08 refactoring
 
05 seaside
05 seaside05 seaside
05 seaside
 
04 idioms
04 idioms04 idioms
04 idioms
 
02 basics
02 basics02 basics
02 basics
 
01 intro
01 intro01 intro
01 intro
 
Stoop sed-class initialization
Stoop sed-class initializationStoop sed-class initialization
Stoop sed-class initialization
 
Stoop sed-class initialization
Stoop sed-class initializationStoop sed-class initialization
Stoop sed-class initialization
 
Stoop ed-unit ofreuse
Stoop ed-unit ofreuseStoop ed-unit ofreuse
Stoop ed-unit ofreuse
 
Stoop ed-subtyping subclassing
Stoop ed-subtyping subclassingStoop ed-subtyping subclassing
Stoop ed-subtyping subclassing
 
Stoop ed-some principles
Stoop ed-some principlesStoop ed-some principles
Stoop ed-some principles
 
Stoop ed-inheritance composition
Stoop ed-inheritance compositionStoop ed-inheritance composition
Stoop ed-inheritance composition
 
Stoop ed-frameworks
Stoop ed-frameworksStoop ed-frameworks
Stoop ed-frameworks
 
Stoop 450-s unit
Stoop 450-s unitStoop 450-s unit
Stoop 450-s unit
 
Stoop 440-adaptor
Stoop 440-adaptorStoop 440-adaptor
Stoop 440-adaptor
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Stoop 301-internal objectstructureinvw

  • 1. S.Ducasse 1 QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture. Stéphane Ducasse Stephane.Ducasse@univ-savoie.fr http://www.listic.univ-savoie.fr/~ducasse/ Smalltalk gives to the programmer the illusion of uniformity for example SmallIntegers are defined as any other object but in memory they are different than objects. In that case the object The Internal Structure of Objects in VW
  • 2. S.Ducasse 2 License: CC-Attribution-ShareAlike 2.0 http://creativecommons.org/licenses/by-sa/2.0/
  • 3. S.Ducasse 3 • Non indexable, pointer Object subclass: #Packet instanceVariableNames: 'contents addressee originator ' classVariableNames: '' poolDictionaries: '' category: 'Demo-LAN' • Indexable pointer • ArrayedCollection variableSubclass: #Array • instanceVariableNames: '' • classVariableNames: '' • poolDictionaries: '' • category: 'Collections-Arrayed' Three Ways to Create Classes (VW30 Sq)
  • 4. S.Ducasse 4 • Indexable, non pointer • LimitedPrecisionReal variableByteSubclass: #Float instanceVariableNames: '' classVariableNames: 'Pi RadiansPerDegree ' poolDictionaries: '' category: 'Magnitude-Numbers' It is not possible to define named instance variables Three Ways to Create Classes
  • 5. S.Ducasse 5 • Identifying subclass: | collection | collection := SortedCollection new. Smalltalk allBehaviorsDo: [:each ||boolean| boolean := each isMeta not and: [each isObsolete not]. boolean := boolean and: [each isFixed]. boolean ifTrue: [collection add: each name]]. ^collection Let there be Code
  • 6. S.Ducasse 6 • Identifying variableSubclass: boolean := each isMeta not and: [each isObsolete not]. boolean := boolean and: [each isPointers]. boolean := boolean and: [each isVariable]. boolean ifTrue: [collection add: each name]] • Identifying variableByteSubclass: boolean := each isMeta not and: [each isObsolete not]. boolean := boolean and: [each isBits]. boolean := boolean and: [each isVariable]. boolean ifTrue: [collection add: each name]] Let there be Code
  • 7. S.Ducasse 7 • The information for distinguishing between these three type is stored in the format instance variable of Behavior. • Behavior>>isBits • "Answer whether the receiver contains just bits (not pointers)." • ^format noMask: self pointersMask • Behavior>>hasImmediateInstances immediate type object? • Behavior>>isFixed non-indexable type object? • Behavior>>isPointers pointers type object? • Behavior>>isVariable Format and other
  • 8. S.Ducasse 8 pointer type [isPointers] indexable type [isVariable] variableSubclass: non-index type [isFixed] subclass: non-pointer [isBits] index type [isVariable] variableByteSubclass: non-index type [isFixed] subclass: immediate [hasImmediateInstances] subclass: Format and other (ii)
  • 9. S.Ducasse 9 • objectSizeInBytes: anObject • |bytesInOTE bytesInOOP aClass indexableFieldSize instVarFieldSize size| • bytesInOTE := ObjectMemory current bytesPerOTE. • bytesInOOP := ObjectMemory current bytesPerOOP. • aClass := anObject class. • aClass isPointers • ifTrue: [instVarFieldSize := aClass instSize * bytesInOOP. • aClass isVariable • ifTrue: [indexableFieldSize := anObject basicSize * bytesInOOP] • ifFalse: [indexableFieldSize := 0]] • ifFalse: [instVarFieldSize := 0. • aClass isVariable • ifTrue: [indexableFieldSize := anObject basicSize + • (bytesInOOP -1) bitAnd: bytesInOOP negated] • ifFalse:[indexableFieldSize := 0]]. • size := bytesInOTE + instVarFieldSize + indexableFieldSize. • ^size Object size in bytes
  • 10. S.Ducasse 10 • OTE (ObjectTable Entry) = 12 bytes: OTE is a description of an Object (class, iv, hash, gc flags, ....) • OOP (Object Oriented Pointer) = 4 bytes • Pointers Type • Internals new objectSizeInBytes:WorkStation new • pointer, instSize = 3 (dependents name nextNode) * 4 = 12 not indexable • Internals new objectSizeInBytes: (WorkStation new name: #abc) • idem, because not recursive • Internals new objectSizeInBytes: 1@2 • 12 + 2 * 4 = 20 bytes • Indexable and Pointers Type • Internals new objectSizeInBytes: (OrderedCollection new: 10) • OrderedCollection new: 10 • = 2 inst variable and 10 indexes • class instSize = 2 * 4 • basicSize = 10 * 4 • = 60 bytes Analysis
  • 11. S.Ducasse 11 • Indexable pure • Internals new objectSizeInBytes: Float pi • 4 indexed variable * 4 = 16 bytes • Non pointer, non Index = immediate, but an immediate type object has no object table entry.The immediate object is stored into the OOP. • Internals new objectSizeInBytes: 1 • = 12 bytes, but the code should use isImmediate Analysis (ii)