1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib
Jemma Issroff d594a5a8bd
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-28 08:26:21 -07:00
..
benchmark [ruby/benchmark] Freeze VERSION 2021-12-18 08:38:58 +09:00
bundler [rubygems/rubygems] Update GitLab CI template with new one 2022-09-22 11:42:57 +09:00
cgi [ruby/cgi] Implement CGI.url_encode and CGI.url_decode 2022-08-16 19:12:03 +09:00
csv [ruby/csv] Revert "parser: fix a keep bug that some texts may be dropped unexpectedly" 2021-12-24 14:35:33 +09:00
delegate [ruby/delegate] gemspec: Drop unused executables directives 2021-10-22 19:48:22 +09:00
did_you_mean [ruby/did_you_mean] Fixed correction duplicates in VariableNameChecker 2022-09-01 19:47:39 +09:00
drb lib/drb/drb.rb: Prevent a "warning: assigned but unused variable" 2022-01-17 14:56:11 +09:00
erb
error_highlight [ruby/error_highlight] Apply ErrorHighlight::CoreExt to TypeError and ArgumentError 2022-08-19 18:34:15 +09:00
forwardable [ruby/forwardable] Move :stopdoc: directive 2022-03-14 14:44:46 +09:00
getoptlong
irb [ruby/irb] Rewrite on_scan proc to be more readable. 2022-09-22 00:37:40 +09:00
logger [ruby/logger] Enhanced RDoc for Logger 2022-05-13 22:52:53 +09:00
mjit This commit implements the Object Shapes technique in CRuby. 2022-09-28 08:26:21 -07:00
net [ruby/net-http] Remove ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE 2022-09-28 17:26:03 +09:00
observer
open3 Fixed filename for Open3::VERSION 2021-12-09 19:48:22 +09:00
optparse [ruby/optparse] Add rdoc options 2022-01-12 21:16:01 +09:00
ostruct [ruby/ostruct] Drop unused directives from gemspec (https://github.com/ruby/ostruct/pull/39) 2022-03-07 20:08:29 +09:00
pstore
racc Update parser-text.rb with 4ecc13c9cb 2022-07-29 19:10:10 +09:00
random [ruby/securerandom] Use String#unpack1 2021-12-14 11:59:22 +09:00
rdoc [ruby/rdoc] Allow multiple footnotes without in-between blank lines 2022-08-08 01:12:49 +09:00
reline [ruby/reline] PR changes 2022-09-22 22:28:38 +09:00
rinda [ruby/rinda] Bump up rinda version to 0.1.1 2021-10-21 21:02:37 +09:00
rubygems [rubygems/rubygems] fix: Gem::Platform.match handles String argument properly 2022-09-28 05:55:28 +09:00
set [ruby/set] Bump version to 1.0.3 2022-09-06 10:41:20 +09:00
singleton
syntax_suggest syntax_suggest moved under the ruby organization from zombocom 2022-09-27 12:44:30 +09:00
timeout [ruby/timeout] gemspec: Drop unused directives "executables" 2022-07-14 16:21:25 +09:00
unicode_normalize [DOC] hide UnicodeNormalize in module index 2022-03-14 15:01:20 +09:00
uri [ruby/uri] Improve URI.register_scheme tests and automatically upcase the given scheme 2022-05-12 18:19:17 +09:00
weakref
yaml
abbrev.gemspec
abbrev.rb
base64.gemspec
base64.rb
benchmark.rb
bundler.rb Merge 16c3535413 2022-09-05 14:37:12 +09:00
cgi.rb [ruby/cgi] Bump up 0.3.3 2022-09-22 17:29:55 +09:00
csv.rb [ruby/csv] Add handling for ambiguous parsing options (https://github.com/ruby/csv/pull/226) 2021-12-24 14:35:33 +09:00
delegate.rb Kernel#=~: delete 2022-01-03 22:33:38 +09:00
did_you_mean.rb Sync did_you_mean 2021-12-24 23:20:30 +09:00
drb.rb
English.gemspec [ruby/English] gemspec: Remove unused "executables" configuration 2021-12-09 19:28:53 +09:00
English.rb
erb.gemspec
erb.rb [ruby/erb] Revert "Remove safe_level and further positional arguments (https://github.com/ruby/erb/pull/7)" 2022-01-17 12:39:17 -08:00
error_highlight.rb
fileutils.gemspec
fileutils.rb [ruby/fileutils] FileUtils.rm* methods swallows only Errno::ENOENT when force is true 2022-08-23 16:52:41 +09:00
find.gemspec
find.rb
forwardable.rb [ruby/forwardable] Freeze VERSION and FORWARDABLE_VERSION to improve Ractor-compliance 2022-09-08 14:31:42 +09:00
getoptlong.rb [ruby/getoptlong] Fixup https://github.com/ruby/getoptlong/commit/39faa7b390f0 2022-05-09 07:26:29 +09:00
ipaddr.gemspec Support directory layout of ruby/ruby repository 2022-02-10 17:18:05 +09:00
ipaddr.rb [ruby/ipaddr] Improve Ractor-compliance 2022-09-08 14:09:06 +09:00
irb.rb [ruby/irb] [DOC] Include updated help message (https://github.com/ruby/irb/pull/377) 2022-07-12 00:05:15 +09:00
logger.rb [ruby/logger] [DOC] Enhanced RDoc for Logger (https://github.com/ruby/logger/pull/77) 2022-05-14 05:02:18 +09:00
mkmf.rb [Bug #19005] dynamic_lookup linker option in external libraries 2022-09-17 12:09:34 +09:00
mutex_m.gemspec
mutex_m.rb [ruby/mutex_m] Make VERSION shareable 2021-10-22 19:49:34 +09:00
observer.rb
open-uri.gemspec [ruby/open-uri] gemspec: This gem exposes 0 executables 2021-12-09 19:28:54 +09:00
open-uri.rb [ruby/open-uri] [DOC] Fix markup for URI.open 2022-06-07 00:06:56 +09:00
open3.rb [ruby/open3] Update to match JRuby 9.4 2021-12-09 19:28:54 +09:00
optionparser.rb
optparse.rb [ruby/optparse] Also accept '-' as an optional argument (https://github.com/ruby/optparse/pull/35) 2022-07-29 19:10:10 +09:00
ostruct.rb [ruby/ostruct] v0.5.5 2022-04-01 00:18:36 +09:00
pp.gemspec [ruby/pp] Bump version to 0.3.0 2021-12-20 12:44:31 +09:00
pp.rb [ruby/pp] [DOC] Update for PP.width_for [Feature #12913] 2021-12-23 18:00:56 +09:00
prettyprint.gemspec [ruby/prettyprint] Bump up prettyprint version to 0.1.1 2021-10-21 21:05:39 +09:00
prettyprint.rb
pstore.rb [ruby/pstore] Emphasize keys instead of roots, values instead of objects (https://github.com/ruby/pstore/pull/7) 2022-07-07 07:05:01 +09:00
racc.rb
rdoc.rb [ruby/rdoc] Relative loading for easier development (https://github.com/ruby/rdoc/pull/821) 2022-02-12 15:06:06 +09:00
readline.gemspec [ruby/readline] Bump version to 0.0.3 2021-12-24 17:54:09 +09:00
readline.rb [ruby/readline] Suppress constant redefinition warning 2021-11-29 18:50:27 +09:00
reline.rb [ruby/reline] Support dumb terminal 2022-09-01 16:36:16 +09:00
resolv-replace.gemspec
resolv-replace.rb
resolv.gemspec
resolv.rb [ruby/resolv] Support more characters in link local addresses 2022-01-12 10:49:57 +09:00
ruby2_keywords.gemspec
rubygems.rb Merge rubygems/bundler HEAD. 2022-08-09 12:05:19 +09:00
securerandom.gemspec [ruby/securerandom] Bump up v0.2.0 2022-02-28 20:08:58 +09:00
securerandom.rb lib/securerandom.rb: Fix the check of availability of Random.urandom 2022-02-16 16:32:28 +09:00
set.rb [ruby/set] Fix a typo 2022-05-16 23:43:04 +09:00
shellwords.gemspec
shellwords.rb
singleton.rb
syntax_suggest.rb Sync SyntaxSuggest 2022-08-19 10:02:24 +09:00
tempfile.gemspec [ruby/tempfile] Drop unused gemspec directives 2022-05-20 17:49:14 +09:00
tempfile.rb [ruby/tempfile] Enhanced RDoc for ::new and ::create (https://github.com/ruby/tempfile/pull/10) 2022-05-20 17:49:14 +09:00
time.gemspec
time.rb fix typo in Time#xmlschema documentation 2022-07-29 19:10:10 +09:00
timeout.rb [ruby/timeout] Explicit add the timeout thread to default ThreadGroup 2022-09-28 01:59:35 +09:00
tmpdir.gemspec
tmpdir.rb [ruby/tmpdir] [DOC] Fix syntax in example code [ci skip] 2021-11-11 10:37:35 +09:00
tsort.gemspec
tsort.rb [ruby/tsort] Small tweaks for easier vendoring 2022-04-18 09:40:07 +09:00
un.gemspec
un.rb [ruby/un] Support FileUtils.cp_lr 2022-07-14 16:26:47 +09:00
uri.rb [ruby/uri] Feat: Support WSS 2022-04-22 11:59:54 +09:00
weakref.rb [DOC] Remove outdated note from WeakRef#initialize 2022-03-14 10:50:52 +01:00
yaml.rb [ruby/yaml] Add JRuby-specific warning when psych fails 2022-01-27 17:16:05 +09:00