Skip to content

Commit

Permalink
Use FL_USER0 for ELTS_SHARED
Browse files Browse the repository at this point in the history
This makes space in RString for two bits for chilled strings.
  • Loading branch information
etiennebarrie authored and byroot committed Nov 12, 2024
1 parent dc08d6e commit 4d24096
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ VALUE rb_cArray_empty_frozen;

/* Flags of RArray
*
* 0: RARRAY_SHARED_FLAG (equal to ELTS_SHARED)
* The array is shared. The buffer this array points to is owned by
* another array (the shared root).
* 1: RARRAY_EMBED_FLAG
* The array is embedded (its contents follow the header, rather than
* being on a separately allocated buffer).
* 2: RARRAY_SHARED_FLAG (equal to ELTS_SHARED)
* The array is shared. The buffer this array points to is owned by
* another array (the shared root).
* 3-9: RARRAY_EMBED_LEN
* The length of the array when RARRAY_EMBED_FLAG is set.
* 12: RARRAY_SHARED_ROOT_FLAG
Expand Down
4 changes: 2 additions & 2 deletions include/ruby/internal/core/rarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
* here is at least incomplete.
*/
enum ruby_rarray_flags {
/* RUBY_FL_USER0 is for ELTS_SHARED */

/**
* This flag has something to do with memory footprint. If the array is
* "small" enough, ruby tries to be creative to abuse padding bits of
Expand All @@ -99,8 +101,6 @@ enum ruby_rarray_flags {
*/
RARRAY_EMBED_FLAG = RUBY_FL_USER1,

/* RUBY_FL_USER2 is for ELTS_SHARED */

/**
* When an array employs embedded strategy (see ::RARRAY_EMBED_FLAG), these
* bits are used to store the number of elements actually filled into
Expand Down
2 changes: 1 addition & 1 deletion include/ruby/internal/fl_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ ruby_fl_type {
* 3rd parties. It must be an implementation detail that they should never
* know. Might better be hidden.
*/
RUBY_ELTS_SHARED = RUBY_FL_USER2,
RUBY_ELTS_SHARED = RUBY_FL_USER0,

/**
* This flag has something to do with an object's class. There are kind of
Expand Down
2 changes: 1 addition & 1 deletion internal/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "ruby/encoding.h" /* for rb_encoding */
#include "ruby/ruby.h" /* for VALUE */

#define STR_SHARED FL_USER0 /* = ELTS_SHARED */
#define STR_NOEMBED FL_USER1
#define STR_SHARED FL_USER2 /* = ELTS_SHARED */
#define STR_CHILLED FL_USER3

enum ruby_rstring_private_flags {
Expand Down
6 changes: 3 additions & 3 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ VALUE rb_cSymbol;

/* Flags of RString
*
* 0: STR_SHARED (equal to ELTS_SHARED)
* The string is shared. The buffer this string points to is owned by
* another string (the shared root).
* 1: RSTRING_NOEMBED
* The string is not embedded. When a string is embedded, the contents
* follow the header. When a string is not embedded, the contents is
* on a separately allocated buffer.
* 2: STR_SHARED (equal to ELTS_SHARED)
* The string is shared. The buffer this string points to is owned by
* another string (the shared root).
* 3: STR_CHILLED (will be frozen in a future version)
* The string appears frozen but can be mutated with a warning.
* 4: STR_PRECOMPUTED_HASH
Expand Down
2 changes: 1 addition & 1 deletion yjit/src/cruby_bindings.inc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub const RUBY_FL_USER16: ruby_fl_type = 268435456;
pub const RUBY_FL_USER17: ruby_fl_type = 536870912;
pub const RUBY_FL_USER18: ruby_fl_type = 1073741824;
pub const RUBY_FL_USER19: ruby_fl_type = -2147483648;
pub const RUBY_ELTS_SHARED: ruby_fl_type = 16384;
pub const RUBY_ELTS_SHARED: ruby_fl_type = 4096;
pub const RUBY_FL_SINGLETON: ruby_fl_type = 8192;
pub type ruby_fl_type = i32;
pub const RSTRING_NOEMBED: ruby_rstring_flags = 8192;
Expand Down

0 comments on commit 4d24096

Please sign in to comment.