Project

General

Profile

Feature #10182 » mvm-fstring.patch

normalperson (Eric Wong), 08/28/2014 10:51 PM

View differences:

eval.c
Init_BareVM();
Init_heap();
Init_vm_objects();
Init_frozen_strings();
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
internal.h
#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
string.c
#include "internal.h"
#include "probes.h"
#include "gc.h"
#include "vm_core.h"
#include <assert.h>
#define BEG(no) (regs->beg[(no)])
......
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,
......
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;
......
{
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)) {
......
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);
}
vm_core.h
struct RArray at_exit;
VALUE *defined_strings;
st_table *frozen_strings;
/* params */
struct { /* size in byte */
-
(1-1/2)