1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext
Jemma Issroff 9ddfd2ca00 This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-26 09:21:30 -07:00
..
-test- [Bug #18964] Update the code range of appended portion 2022-08-18 14:57:08 +09:00
bigdecimal [ruby/bigdecimal] Remove trailing whitespace. 2022-09-25 19:34:27 +09:00
cgi/escape [ruby/cgi] Implement CGI.url_encode and CGI.url_decode 2022-08-16 19:12:03 +09:00
continuation [Feature #18249] Update dependencies 2022-02-22 09:55:21 -05:00
coverage This commit implements the Object Shapes technique in CRuby. 2022-09-26 09:21:30 -07:00
date reserved_word: just use gperf 3.1 declaration 2022-09-21 11:44:09 +09:00
digest Revert "* expand tabs. [ci skip]" 2022-07-30 17:03:13 +09:00
etc getenv: is in stdlib.h 2022-09-21 11:44:09 +09:00
fcntl [Feature #18249] Update dependencies 2022-02-22 09:55:21 -05:00
fiddle [ruby/fiddle] Fix PACK_MAP for unsigned types (https://github.com/ruby/fiddle/pull/110) 2022-09-11 15:30:49 +09:00
io Revert "* expand tabs. [ci skip]" 2022-07-30 17:29:56 +09:00
json [flori/json] Stop including the parser source __LINE__ in exceptions 2022-07-29 19:10:10 +09:00
monitor [Feature #18249] Update dependencies 2022-02-22 09:55:21 -05:00
nkf Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
objspace This commit implements the Object Shapes technique in CRuby. 2022-09-26 09:21:30 -07:00
openssl proper function prototypes for openssl 2022-09-21 11:44:09 +09:00
pathname [ruby/pathname] Fix autoload of FileUtils 2022-07-27 21:05:10 +09:00
psych [ruby/psych] Convert some of Parser#parse to Ruby 2022-09-20 00:44:30 +09:00
pty getenv: is in stdlib.h 2022-09-21 11:44:09 +09:00
racc/cparse [Feature #18249] Update dependencies 2022-02-22 09:55:21 -05:00
rbconfig/sizeof [Feature #18249] Update dependencies 2022-02-22 09:55:21 -05:00
readline Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
ripper Process token IDs from id.def without id.h 2022-09-08 18:22:47 +09:00
rubyvm
socket sockopt adding Linux constants, SO_INCOMING_CPU/SO_INCOMING_NAPI_ID. 2022-09-21 17:15:54 +09:00
stringio [ruby/stringio] Fix the result of StringIO#truncate so compatible with File 2022-07-01 00:52:29 +09:00
strscan [Feature #18249] Update dependencies 2022-02-22 09:55:21 -05:00
syslog Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
win32 Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
win32ole Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
zlib Removed mswin patch for zlib-1.2.11 2022-04-05 14:30:47 +09:00
.document Remove unnecessary files from .document 2020-12-20 16:00:13 +09:00
extmk.rb Quiet if the target is already linked the same source 2022-09-20 12:54:08 +09:00
Setup Removed sdbm entries from toolchanins 2020-06-19 08:26:47 +09:00
Setup.atheos Removed sdbm entries from toolchanins 2020-06-19 08:26:47 +09:00
Setup.nt Removed sdbm entries from toolchanins 2020-06-19 08:26:47 +09:00