SlideShare uma empresa 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)

Mais conteúdo relacionado

Destaque (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
 

Semelhante a 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
 

Semelhante 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
 

Mais 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

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
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
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
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
 
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
 
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
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
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
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
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)
 
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
 
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
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
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
 
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!
 

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)