SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
@
Kaigi The Future Shape of Ruby Objects 202:1
name: ‘Chris’
age: 36
company: ‘Shopify’
home: ‘Cheshire’
struct RObject {
VALUE klass;
int numiv;
VALUE[] ivptr;
};
struct RClass {
struct st_table *iv_index_tbl; // Hash of Symbol -> index
};
VALUE vm_getivar(VALUE obj, IVC inline_cache) {
if (inline_cache && inline_cache->class_serial == obj->klass->class_serial) {
int index = inline_cache->index;
if (obj->type == T_OBJECT) && index < obj->numiv) {
return obj->ivptr[index];
} else {
// slow path
}
} else {
// slow path
}
}
VALUE vm_setivar(VALUE obj, VALUE val, IVC inline_cache) {
if (inline_cache && inline_cache->class_serial == obj->klass->class_serial) {
int index = inline_cache->index;
if (obj->type == T_OBJECT) && index < obj->numiv) {
obj->ivptr[index] = val;
} else {
// slow path
} } else {
// slow path
}
}
def vm_getivar(cache, obj)
if cache.serial == obj.klass.serial && cache.index < obj.numiv
obj.ivptr[cache.index]
else
# slow path
end
end
def vm_setivar(cache, obj, val)
if cache.serial == obj.klass.serial && cache.index < obj.numiv
obj.ivptr[cache.index] = val
else
# slow path
end
end
class TwoVariablesObject {
Object var0;
Object var1;
}
def vm_getivar(cache, obj)
if cache.id == obj.getMetaClass().getRealClass().id
obj[cache.index]
else
# slow path
end
end
name: 0
home: 1
company: 2
age: 3
klass
shape
‘Chris’
‘Cheshire’
‘Shopify’
36
index = obj.shape[:name]
obj[index]
index = obj.shape[:name]
obj[index] = value
name: 0
home: 1
company: 2
age: 3
klass
shape
‘Chris’
‘Cheshire’
‘Shopify’
36
181 name: 0
home: 1
company: 2
age: 3
height: 4
+ height
new_shape = obj.shape.transitions[:add_height]
index = new_shape[:name]
obj.shape = new_shape
obj.resize
obj[index] = value
slow_path unless obj.shape == 0x12345678
obj[4]
def getter
@ivar
End
0x1242ec600: cmp dword ptr [rax*8 + 0xc], expected_shape
0x1242ec60b: jne slow_path
0x1242ec611: mov r10d, dword ptr [rax*8 + index]
def setter(value)
@ivar = value
end
0x11fd28a00: cmp dword ptr [rsi*8 + 0xc], expected_shape
0x11fd28a0b: jne slow_path
0x11fd28a1f: mov qword ptr [rsi*8 + 0x20], r10
def add
@a + @b
end
0x12258d380: cmp dword ptr [rax*8 + 0xc], expected_shape
0x12258d38b: jne slow_path
0x12258d391: mov esi, dword ptr [rax*8 + index_a]
0x12258d398: mov eax, dword ptr [rax*8 + index_b]
0x12258d39f: mov r10d, eax
0x12258d3a2: add r10d, esi
0x12258d3a5: jo overflow
name: 0
home: 1
company: 2
age: 3
klass
shape
‘Chris’
‘Cheshire’
‘Shopify’
36
181 name: 0
home: 1
company: 2
age: 3
(frozen)
freeze
0x11fd28a00: cmp dword ptr [rsi*8 + 0xc], expected_shape
0x11fd28a0b: jne slow_path
0x11fd28a11: mov eax, dword ptr [rdx + index]
@chrisgseaton

Más contenido relacionado

La actualidad más candente

Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
S Akai
 

La actualidad más candente (20)

The Ring programming language version 1.8 book - Part 43 of 202
The Ring programming language version 1.8 book - Part 43 of 202The Ring programming language version 1.8 book - Part 43 of 202
The Ring programming language version 1.8 book - Part 43 of 202
 
The Ring programming language version 1.5.2 book - Part 30 of 181
The Ring programming language version 1.5.2 book - Part 30 of 181The Ring programming language version 1.5.2 book - Part 30 of 181
The Ring programming language version 1.5.2 book - Part 30 of 181
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
Deriving Scalaz
Deriving ScalazDeriving Scalaz
Deriving Scalaz
 
Real World Generics In Swift
Real World Generics In SwiftReal World Generics In Swift
Real World Generics In Swift
 
Scalaz
ScalazScalaz
Scalaz
 
From android/ java to swift (2)
From android/ java to swift (2)From android/ java to swift (2)
From android/ java to swift (2)
 
Adopting Swift Generics
Adopting Swift GenericsAdopting Swift Generics
Adopting Swift Generics
 
2 dimension array in programms
2 dimension array in programms2 dimension array in programms
2 dimension array in programms
 
The Ring programming language version 1.9 book - Part 46 of 210
The Ring programming language version 1.9 book - Part 46 of 210The Ring programming language version 1.9 book - Part 46 of 210
The Ring programming language version 1.9 book - Part 46 of 210
 
Spark Schema For Free with David Szakallas
 Spark Schema For Free with David Szakallas Spark Schema For Free with David Szakallas
Spark Schema For Free with David Szakallas
 
The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.2 book - Part 22 of 84The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.2 book - Part 22 of 84
 
The Ring programming language version 1.5.4 book - Part 38 of 185
The Ring programming language version 1.5.4 book - Part 38 of 185The Ring programming language version 1.5.4 book - Part 38 of 185
The Ring programming language version 1.5.4 book - Part 38 of 185
 
Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
 
Learn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeLearn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik Cube
 
The Ring programming language version 1.5.4 book - Part 31 of 185
The Ring programming language version 1.5.4 book - Part 31 of 185The Ring programming language version 1.5.4 book - Part 31 of 185
The Ring programming language version 1.5.4 book - Part 31 of 185
 
Constructors
ConstructorsConstructors
Constructors
 
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189
 
RubyistのためのObjective-C入門
RubyistのためのObjective-C入門RubyistのためのObjective-C入門
RubyistのためのObjective-C入門
 
C++ nothrow movable types
C++ nothrow movable typesC++ nothrow movable types
C++ nothrow movable types
 

Similar a The Future Shape of Ruby Objects

Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Alex Sharp
 
ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2
RORLAB
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik Erlandson
Databricks
 

Similar a The Future Shape of Ruby Objects (20)

The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
PyData Paris 2015 - Track 1.2 Gilles Louppe
PyData Paris 2015 - Track 1.2 Gilles LouppePyData Paris 2015 - Track 1.2 Gilles Louppe
PyData Paris 2015 - Track 1.2 Gilles Louppe
 
The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4.1 book - Part 13 of 31The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4.1 book - Part 13 of 31
 
An Introduction to Higher Order Functions in Spark SQL with Herman van Hovell
An Introduction to Higher Order Functions in Spark SQL with Herman van HovellAn Introduction to Higher Order Functions in Spark SQL with Herman van Hovell
An Introduction to Higher Order Functions in Spark SQL with Herman van Hovell
 
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
 
c#(loops,arrays)
c#(loops,arrays)c#(loops,arrays)
c#(loops,arrays)
 
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
 
Hidden Gems in Swift
Hidden Gems in SwiftHidden Gems in Swift
Hidden Gems in Swift
 
Working With a Real-World Dataset in Neo4j: Import and Modeling
Working With a Real-World Dataset in Neo4j: Import and ModelingWorking With a Real-World Dataset in Neo4j: Import and Modeling
Working With a Real-World Dataset in Neo4j: Import and Modeling
 
ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210
 
Importing Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflowImporting Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflow
 
Score (smart contract for icon)
Score (smart contract for icon) Score (smart contract for icon)
Score (smart contract for icon)
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik Erlandson
 
Spark schema for free with David Szakallas
Spark schema for free with David SzakallasSpark schema for free with David Szakallas
Spark schema for free with David Szakallas
 
The Ring programming language version 1.5.4 book - Part 30 of 185
The Ring programming language version 1.5.4 book - Part 30 of 185The Ring programming language version 1.5.4 book - Part 30 of 185
The Ring programming language version 1.5.4 book - Part 30 of 185
 
Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
 
The Ring programming language version 1.2 book - Part 19 of 84
The Ring programming language version 1.2 book - Part 19 of 84The Ring programming language version 1.2 book - Part 19 of 84
The Ring programming language version 1.2 book - Part 19 of 84
 
The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180
 

Último

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 

Último (20)

Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 

The Future Shape of Ruby Objects

  • 1. @ Kaigi The Future Shape of Ruby Objects 202:1
  • 2. name: ‘Chris’ age: 36 company: ‘Shopify’ home: ‘Cheshire’
  • 3. struct RObject { VALUE klass; int numiv; VALUE[] ivptr; }; struct RClass { struct st_table *iv_index_tbl; // Hash of Symbol -> index };
  • 4. VALUE vm_getivar(VALUE obj, IVC inline_cache) { if (inline_cache && inline_cache->class_serial == obj->klass->class_serial) { int index = inline_cache->index; if (obj->type == T_OBJECT) && index < obj->numiv) { return obj->ivptr[index]; } else { // slow path } } else { // slow path } } VALUE vm_setivar(VALUE obj, VALUE val, IVC inline_cache) { if (inline_cache && inline_cache->class_serial == obj->klass->class_serial) { int index = inline_cache->index; if (obj->type == T_OBJECT) && index < obj->numiv) { obj->ivptr[index] = val; } else { // slow path } } else { // slow path } }
  • 5. def vm_getivar(cache, obj) if cache.serial == obj.klass.serial && cache.index < obj.numiv obj.ivptr[cache.index] else # slow path end end def vm_setivar(cache, obj, val) if cache.serial == obj.klass.serial && cache.index < obj.numiv obj.ivptr[cache.index] = val else # slow path end end
  • 6. class TwoVariablesObject { Object var0; Object var1; } def vm_getivar(cache, obj) if cache.id == obj.getMetaClass().getRealClass().id obj[cache.index] else # slow path end end
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. name: 0 home: 1 company: 2 age: 3 klass shape ‘Chris’ ‘Cheshire’ ‘Shopify’ 36
  • 15. name: 0 home: 1 company: 2 age: 3 klass shape ‘Chris’ ‘Cheshire’ ‘Shopify’ 36 181 name: 0 home: 1 company: 2 age: 3 height: 4 + height
  • 16. new_shape = obj.shape.transitions[:add_height] index = new_shape[:name] obj.shape = new_shape obj.resize obj[index] = value
  • 17. slow_path unless obj.shape == 0x12345678 obj[4]
  • 18.
  • 19. def getter @ivar End 0x1242ec600: cmp dword ptr [rax*8 + 0xc], expected_shape 0x1242ec60b: jne slow_path 0x1242ec611: mov r10d, dword ptr [rax*8 + index]
  • 20. def setter(value) @ivar = value end 0x11fd28a00: cmp dword ptr [rsi*8 + 0xc], expected_shape 0x11fd28a0b: jne slow_path 0x11fd28a1f: mov qword ptr [rsi*8 + 0x20], r10
  • 21.
  • 22. def add @a + @b end 0x12258d380: cmp dword ptr [rax*8 + 0xc], expected_shape 0x12258d38b: jne slow_path 0x12258d391: mov esi, dword ptr [rax*8 + index_a] 0x12258d398: mov eax, dword ptr [rax*8 + index_b] 0x12258d39f: mov r10d, eax 0x12258d3a2: add r10d, esi 0x12258d3a5: jo overflow
  • 23. name: 0 home: 1 company: 2 age: 3 klass shape ‘Chris’ ‘Cheshire’ ‘Shopify’ 36 181 name: 0 home: 1 company: 2 age: 3 (frozen) freeze
  • 24. 0x11fd28a00: cmp dword ptr [rsi*8 + 0xc], expected_shape 0x11fd28a0b: jne slow_path 0x11fd28a11: mov eax, dword ptr [rdx + index]