SlideShare une entreprise Scribd logo
1  sur  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)

Contenu connexe

En vedette (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
 

Similaire à Stoop 301-internal objectstructureinvw

iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev introVonbo
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone developmentVonbo
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cphcyberswat
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOSPetr Dvorak
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsPetr Dvorak
 
How and Where in GLORP
How and Where in GLORPHow and Where in GLORP
How and Where in GLORPESUG
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Managementstable|kernel
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not JavaChris Adamson
 
JavaScript!
JavaScript!JavaScript!
JavaScript!RTigger
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jqueryKostas Mavridis
 
Slot Composition
Slot CompositionSlot Composition
Slot CompositionESUG
 
[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 TypesMuhammad Hammad Waseem
 
[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 JSIvano Malavolta
 

Similaire à 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
 

Plus 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
 

Dernier

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Dernier (20)

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

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)