aboutsummaryrefslogtreecommitdiffstats
path: root/internal/class.h
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2022-12-08 16:48:48 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2022-12-15 10:06:04 -0800
commita3d552aedd190b0f21a4f6479f0ef1d2ce90189b (patch)
tree1a3b505b76c40a0bcb07535a21ccf126e5543d1e /internal/class.h
parentf50aa19da63067c4b0de5964b6632df20202e71c (diff)
downloadruby-a3d552aedd190b0f21a4f6479f0ef1d2ce90189b.tar.gz
Add variation_count on classes
Count how many "variations" each class creates. A "variation" is a a unique ordering of instance variables on a particular class. This can also be thought of as a branch in the shape tree. For example, the following Foo class will have 2 variations: ```ruby class Foo ; end Foo.new.instance_variable_set(:@a, 1) # case 1: creates one variation Foo.new.instance_variable_set(:@b, 1) # case 2: creates another variation foo = Foo.new foo.instance_variable_set(:@a, 1) # does not create a new variation foo.instance_variable_set(:@b, 1) # does not create a new variation (a continuation of the variation in case 1) ``` We will use this number to limit the amount of shapes that a class can create and fallback to using a hash iv lookup. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Diffstat (limited to 'internal/class.h')
-rw-r--r--internal/class.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/class.h b/internal/class.h
index 8080725634..5731a5bc33 100644
--- a/internal/class.h
+++ b/internal/class.h
@@ -53,6 +53,7 @@ struct rb_classext_struct {
rb_alloc_func_t allocator;
const VALUE includer;
uint32_t max_iv_count;
+ uint32_t variation_count;
#if !SHAPE_IN_BASIC_FLAGS
shape_id_t shape_id;
#endif