1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

string.c: remove vm_core.h dependency [ruby-core:64627]

* string.c: revert part of r47311, add rb_vm_fstring_table(),
  remove vm_core.h dependency. [ruby-core:64627]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2014-08-29 07:22:23 +00:00
parent 2bb4c26893
commit 343f8b02a1
3 changed files with 21 additions and 8 deletions

View file

@ -1,3 +1,8 @@
Fri Aug 29 16:18:26 2014 Eric Wong <e@80x24.org>
* string.c: revert part of r47311, add rb_vm_fstring_table(),
remove vm_core.h dependency. [ruby-core:64627]
Fri Aug 29 15:17:13 2014 Eric Wong <e@80x24.org>
* string.c: remove static frozen_strings

View file

@ -778,7 +778,7 @@ strftime.$(OBJEXT): {$(VPATH)}strftime.c $(RUBY_H_INCLUDES) \
{$(VPATH)}timev.h $(ENCODING_H_INCLUDES)
string.$(OBJEXT): {$(VPATH)}string.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h {$(VPATH)}gc.h \
{$(VPATH)}regex.h $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h \
$(PROBES_H_INCLUDES) $(VM_CORE_H_INCLUDES)
$(PROBES_H_INCLUDES)
struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h
symbol.$(OBJEXT): {$(VPATH)}symbol.c $(RUBY_H_INCLUDES) $(ENCODING_H_INCLUDES) \
{$(VPATH)}internal.h {$(VPATH)}node.h {$(VPATH)}id.h {$(VPATH)}symbol.h \

View file

@ -17,7 +17,6 @@
#include "internal.h"
#include "probes.h"
#include "gc.h"
#include "vm_core.h"
#include <assert.h>
#define BEG(no) (regs->beg[(no)])
@ -177,6 +176,15 @@ mustnot_broken(VALUE str)
static int fstring_cmp(VALUE a, VALUE b);
/* in case we restart MVM development, this needs to be per-VM */
static st_table* frozen_strings;
static inline st_table*
rb_vm_fstring_table(void)
{
return frozen_strings;
}
static const struct st_hash_type fstring_hash_type = {
fstring_cmp,
rb_str_hash,
@ -227,7 +235,7 @@ rb_fstring(VALUE str)
do {
ret = str;
st_update(GET_VM()->frozen_strings, (st_data_t)str,
st_update(rb_vm_fstring_table(), (st_data_t)str,
fstr_update_callback, (st_data_t)&ret);
} while (ret == Qundef);
@ -949,7 +957,7 @@ rb_str_free(VALUE str)
{
if (FL_TEST(str, RSTRING_FSTR)) {
st_data_t fstr = (st_data_t)str;
st_delete(GET_VM()->frozen_strings, &fstr, NULL);
st_delete(rb_vm_fstring_table(), &fstr, NULL);
}
if (!STR_EMBED_P(str) && !FL_TEST(str, STR_SHARED)) {
@ -8947,13 +8955,13 @@ Init_String(void)
rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0);
assert(GET_VM()->frozen_strings);
st_foreach(GET_VM()->frozen_strings, fstring_set_class_i, rb_cString);
assert(rb_vm_fstring_table());
st_foreach(rb_vm_fstring_table(), fstring_set_class_i, rb_cString);
}
void
Init_frozen_strings(void)
{
assert(!GET_VM()->frozen_strings);
GET_VM()->frozen_strings = st_init_table(&fstring_hash_type);
assert(!frozen_strings);
frozen_strings = st_init_table(&fstring_hash_type);
}