1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool
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
..
annocheck
bundler [rubygems/rubygems] Also added x86_64-darwin-21 2022-09-15 12:50:48 +09:00
dummy-rake-compiler/rake
lib Remove git command existence check again 2022-09-17 23:05:10 +09:00
m4
mjit This commit implements the Object Shapes technique in CRuby. 2022-09-28 08:26:21 -07:00
releng
ruby_vm mjit_c.rb doesn't need to be an erb 2022-09-23 06:44:28 +09:00
test Allow strings in assert_pattern_list 2022-08-19 01:28:31 +09:00
asm_parse.rb
bisect.sh
build-transcode
checksum.rb
ci_functions.sh
colors
darwin-cc
disable_ipv6.sh
downloader.rb Downloader: Define long option aliases 2022-09-19 01:09:47 +09:00
enc-case-folding.rb Move case-folding.rb to tooldir with enc-prefix 2022-09-17 12:37:48 +09:00
enc-emoji-citrus-gen.rb
enc-emoji4unicode.rb
enc-unicode.rb reserved_word: just use gperf 3.1 declaration 2022-09-21 11:44:09 +09:00
eval.rb
expand-config.rb
extlibs.rb
fake.rb Use $(bindir) for path to executable in mkmf 2022-08-04 16:29:22 +09:00
fetch-bundled_gems.rb
file2lastrev.rb Fallback to VCS.release_date on VCS::NotFoundError 2022-09-17 22:24:10 +09:00
format-release
gen-mailmap.rb
gen_dummy_probes.rb
gen_ruby_tapset.rb
generic_erb.rb
git-refresh
gperf.sed
id2token.rb Process token IDs from id.def without id.h 2022-09-08 18:22:47 +09:00
ifchange
insns2vm.rb
install-sh
intern_ids.rb
leaked-globals
ln_sr.rb Quiet if the target is already linked the same source 2022-09-20 12:54:08 +09:00
make-snapshot Auto-generate the release date on version.h from git CommitDate (#6382) 2022-09-17 21:16:06 +09:00
make_hgraph.rb
mdoc2man.rb
merger.rb
mjit_archflag.sh
mjit_tabs.rb
mk_builtin_loader.rb Fix the trailing comma comment for builtin [ci skip] 2022-09-20 09:43:50 +09:00
mkconfig.rb
mkrunnable.rb
node_name.rb
parse.rb
prereq.status
probes_to_wiki.rb
pure_parser.rb
rbinstall.rb Install all file trees for lldb [ci skip] 2022-09-28 21:27:42 +09:00
rbuninstall.rb
redmine-backporter.rb
release.sh
rmdirs
run-gcov.rb
run-lcov.rb
runruby.rb
search-cgvars.rb
strip-rdoc.rb
sync_default_gems.rb Replace "Fixes"/"Fixed" in commit logs as well as vcs.rb [ci skip] 2022-09-14 11:24:06 +09:00
test-annocheck.sh
test-bundled-gems.rb Do not load library files from repository only for test 2022-07-27 17:36:45 +09:00
test-coverage.rb
transcode-tblgen.rb
transform_mjit_header.rb Fix a typo [ci skip] 2022-08-20 18:36:52 -07:00
travis_retry.sh
travis_wait.sh
update-bundled_gems.rb Preserve each column positions in gems/bundled_gems 2022-08-12 23:51:55 +09:00
update-deps Ruby MJIT (#6028) 2022-09-04 21:53:46 -07:00
vtlh.rb
wasm-clangw
ytab.sed