From a3d552aedd190b0f21a4f6479f0ef1d2ce90189b Mon Sep 17 00:00:00 2001 From: Jemma Issroff Date: Thu, 8 Dec 2022 16:48:48 -0500 Subject: 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 --- internal/class.h | 1 + 1 file changed, 1 insertion(+) (limited to 'internal') 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 -- cgit v1.2.3