Compile code without Symbol GC always

This commit is contained in:
Nobuyoshi Nakada 2023-06-28 22:54:13 +09:00
parent 469e644c93
commit ac0163949a
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465

View File

@ -23,7 +23,11 @@
#include "vm_sync.h" #include "vm_sync.h"
#include "builtin.h" #include "builtin.h"
#ifndef USE_SYMBOL_GC #if defined(USE_SYMBOL_GC) && !(USE_SYMBOL_GC+0)
# undef USE_SYMBOL_GC
# define USE_SYMBOL_GC 0
#else
# undef USE_SYMBOL_GC
# define USE_SYMBOL_GC 1 # define USE_SYMBOL_GC 1
#endif #endif
#ifndef SYMBOL_DEBUG #ifndef SYMBOL_DEBUG
@ -843,12 +847,7 @@ VALUE
rb_str_intern(VALUE str) rb_str_intern(VALUE str)
{ {
VALUE sym; VALUE sym;
#if USE_SYMBOL_GC
rb_encoding *enc, *ascii;
int type;
#else
ID id;
#endif
GLOBAL_SYMBOLS_ENTER(symbols); GLOBAL_SYMBOLS_ENTER(symbols);
{ {
sym = lookup_str_sym_with_lock(symbols, str); sym = lookup_str_sym_with_lock(symbols, str);
@ -856,10 +855,9 @@ rb_str_intern(VALUE str)
if (sym) { if (sym) {
// ok // ok
} }
else { else if (USE_SYMBOL_GC) {
#if USE_SYMBOL_GC rb_encoding *enc = rb_enc_get(str);
enc = rb_enc_get(str); rb_encoding *ascii = rb_usascii_encoding();
ascii = rb_usascii_encoding();
if (enc != ascii && sym_check_asciionly(str)) { if (enc != ascii && sym_check_asciionly(str)) {
str = rb_str_dup(str); str = rb_str_dup(str);
rb_enc_associate(str, ascii); rb_enc_associate(str, ascii);
@ -871,13 +869,13 @@ rb_str_intern(VALUE str)
OBJ_FREEZE(str); OBJ_FREEZE(str);
} }
str = rb_fstring(str); str = rb_fstring(str);
type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN); int type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
if (type < 0) type = ID_JUNK; if (type < 0) type = ID_JUNK;
sym = dsymbol_alloc(symbols, rb_cSymbol, str, enc, type); sym = dsymbol_alloc(symbols, rb_cSymbol, str, enc, type);
#else }
id = intern_str(str, 0); else {
ID id = intern_str(str, 0);
sym = ID2SYM(id); sym = ID2SYM(id);
#endif
} }
} }
GLOBAL_SYMBOLS_LEAVE(); GLOBAL_SYMBOLS_LEAVE();