mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
string.c: move frozen_strings table to rb_vm_t
Cleanup in case MVM development proceeds. * string.c: remove static frozen_strings * string.c (Init_frozen_strings): new function * string.c (rb_fstring): remove check for frozen strings, use per-VM table * string.c (rb_str_free): use per-VM table * string.c (Init_String): use per-VM table * vm_core.h (rb_vm_t): add frozen_strings table * internal.h (Init_frozen_strings): new function prototype * eval.c (ruby_setup): call Init_frozen_strings [Feature #10182] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dacc19e409
commit
a1e95636ac
6 changed files with 31 additions and 10 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Fri Aug 29 15:17:13 2014 Eric Wong <e@80x24.org>
|
||||
|
||||
* string.c: remove static frozen_strings
|
||||
* string.c (Init_frozen_strings): new function
|
||||
* string.c (rb_fstring): remove check for frozen strings,
|
||||
use per-VM table
|
||||
* string.c (rb_str_free): use per-VM table
|
||||
* string.c (Init_String): use per-VM table
|
||||
* vm_core.h (rb_vm_t): add frozen_strings table
|
||||
* internal.h (Init_frozen_strings): new function prototype
|
||||
* eval.c (ruby_setup): call Init_frozen_strings
|
||||
[Feature #10182]
|
||||
|
||||
Wed Aug 27 23:10:24 2014 Masaki Matsushita <glass.saga@gmail.com>
|
||||
|
||||
* lib/tempfile.rb: remove "require 'thread'". its features are no
|
||||
|
|
|
@ -777,7 +777,8 @@ st.$(OBJEXT): {$(VPATH)}st.c $(RUBY_H_INCLUDES)
|
|||
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)
|
||||
{$(VPATH)}regex.h $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h \
|
||||
$(PROBES_H_INCLUDES) $(VM_CORE_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 \
|
||||
|
|
1
eval.c
1
eval.c
|
@ -52,6 +52,7 @@ ruby_setup(void)
|
|||
Init_BareVM();
|
||||
Init_heap();
|
||||
Init_vm_objects();
|
||||
Init_frozen_strings();
|
||||
|
||||
PUSH_TAG();
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
|
|
|
@ -891,6 +891,7 @@ size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc
|
|||
#endif
|
||||
|
||||
/* string.c */
|
||||
void Init_frozen_strings(void);
|
||||
VALUE rb_fstring(VALUE);
|
||||
VALUE rb_fstring_new(const char *ptr, long len);
|
||||
#ifdef RUBY_ENCODING_H
|
||||
|
|
22
string.c
22
string.c
|
@ -17,6 +17,7 @@
|
|||
#include "internal.h"
|
||||
#include "probes.h"
|
||||
#include "gc.h"
|
||||
#include "vm_core.h"
|
||||
#include <assert.h>
|
||||
|
||||
#define BEG(no) (regs->beg[(no)])
|
||||
|
@ -176,8 +177,6 @@ mustnot_broken(VALUE str)
|
|||
|
||||
static int fstring_cmp(VALUE a, VALUE b);
|
||||
|
||||
static st_table* frozen_strings;
|
||||
|
||||
static const struct st_hash_type fstring_hash_type = {
|
||||
fstring_cmp,
|
||||
rb_str_hash,
|
||||
|
@ -223,15 +222,13 @@ rb_fstring(VALUE str)
|
|||
|
||||
Check_Type(str, T_STRING);
|
||||
|
||||
if (!frozen_strings)
|
||||
frozen_strings = st_init_table(&fstring_hash_type);
|
||||
|
||||
if (FL_TEST(str, RSTRING_FSTR))
|
||||
return str;
|
||||
|
||||
do {
|
||||
ret = str;
|
||||
st_update(frozen_strings, (st_data_t)str, fstr_update_callback, (st_data_t)&ret);
|
||||
st_update(GET_VM()->frozen_strings, (st_data_t)str,
|
||||
fstr_update_callback, (st_data_t)&ret);
|
||||
} while (ret == Qundef);
|
||||
|
||||
return ret;
|
||||
|
@ -952,7 +949,7 @@ rb_str_free(VALUE str)
|
|||
{
|
||||
if (FL_TEST(str, RSTRING_FSTR)) {
|
||||
st_data_t fstr = (st_data_t)str;
|
||||
st_delete(frozen_strings, &fstr, NULL);
|
||||
st_delete(GET_VM()->frozen_strings, &fstr, NULL);
|
||||
}
|
||||
|
||||
if (!STR_EMBED_P(str) && !FL_TEST(str, STR_SHARED)) {
|
||||
|
@ -8950,6 +8947,13 @@ Init_String(void)
|
|||
|
||||
rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0);
|
||||
|
||||
if (frozen_strings)
|
||||
st_foreach(frozen_strings, fstring_set_class_i, rb_cString);
|
||||
assert(GET_VM()->frozen_strings);
|
||||
st_foreach(GET_VM()->frozen_strings, 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);
|
||||
}
|
||||
|
|
|
@ -430,6 +430,7 @@ typedef struct rb_vm_struct {
|
|||
struct RArray at_exit;
|
||||
|
||||
VALUE *defined_strings;
|
||||
st_table *frozen_strings;
|
||||
|
||||
/* params */
|
||||
struct { /* size in byte */
|
||||
|
|
Loading…
Add table
Reference in a new issue