Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lrz committed Aug 8, 2008
1 parent a407e79 commit ec1f435
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ FRAMEWORK_INSTDIR = do_option('framework_instdir', '/Library/Frameworks')
NO_WARN_BUILD = !do_option('allow_build_warnings', false)
BUILD_AS_EMBEDDABLE = do_option('build_as_embeddable', false)
ENABLE_STATIC_LIBRARY = do_option('enable_static_library', 'no') { 'yes' }
ENABLE_DEBUG_LOGGING = do_option('enable_debug_logging', false)
ENABLE_DEBUG_LOGGING = do_option('enable_debug_logging', true)

# TODO: we should find a way to document these options in rake's --help

Expand Down
2 changes: 1 addition & 1 deletion class.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ rb_objc_push_methods(VALUE ary, VALUE mod)
method = methods[i];

sel = method_getName(method);
if (rb_ignored_selector(sel))
if (sel == sel_ignored)
continue;

sel_name = (char *)sel_getName(sel);
Expand Down
8 changes: 3 additions & 5 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,20 +692,18 @@ new_insn_send(rb_iseq_t *iseq, int line_no,
operands[1] = argc;
operands[2] = block;
operands[3] = flag;
operands[4] = 0;
if (FIX2INT(argc) > 0) {
char buf[512];

strlcpy(buf, rb_sym2name(id), sizeof buf);
if (buf[strlen(buf) - 1] != ':')
strlcat(buf, ":", sizeof buf);
operands[5] = (VALUE)sel_registerName(buf);
operands[4] = (VALUE)sel_registerName(buf);
}
else {
operands[5] = (VALUE)sel_registerName(rb_sym2name(id));
operands[4] = (VALUE)sel_registerName(rb_sym2name(id));
}
operands[6] = 0;
iobj = new_insn_core(iseq, line_no, BIN(send), 6, operands);
iobj = new_insn_core(iseq, line_no, BIN(send), 5, operands);
return iobj;
}

Expand Down
23 changes: 7 additions & 16 deletions debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,14 @@ void ruby_debug_breakpoint(void);
void ruby_debug_gc_check_func(void);

#if ENABLE_DEBUG_LOGGING
static inline bool dlog_enabled(void) {
static int flag = -1;
if (flag == -1) {
char *s = getenv("MACRUBY_DEBUG");
flag = !(s == NULL || *s == '0');
# include "vm_core.h"
extern bool ruby_dlog_enabled;
# define DLOG(mod, fmt, args...) \
if (UNLIKELY(ruby_dlog_enabled)) { \
printf("%10s ", mod); \
printf(fmt, ##args); \
printf("\n"); \
}
return (bool)flag;
}
# define DLOG(mod, fmt, args...) \
do { \
if (dlog_enabled()) { \
printf("%10s ", mod); \
printf(fmt, ##args); \
printf("\n"); \
} \
} \
while (0)
#else
# define DLOG(mod, fmt, args...)
#endif
Expand Down
9 changes: 9 additions & 0 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ void Init_ext(void);
void Init_PreGC(void);
void Init_BareVM(void);

#if WITH_OBJC
bool ruby_dlog_enabled = false;
#endif

void
ruby_init(void)
{
Expand All @@ -70,6 +74,11 @@ ruby_init(void)
rb_origenviron = environ;
#endif

#if WITH_OBJC
char *s = getenv("MACRUBY_DEBUG");
ruby_dlog_enabled = !(s == NULL || *s == '0');
#endif

Init_stack((void *)&state);
Init_PreGC();
Init_BareVM();
Expand Down
2 changes: 2 additions & 0 deletions id.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Init_id(void)
selNot = sel_registerName("!");
selInit = sel_registerName("init");
selCopy = sel_registerName("copy");
sel_ignored = sel_registerName("retain");
assert(sel_ignored == sel_registerName("release"));
#endif

idAREF = rb_intern("[]");
Expand Down
1 change: 1 addition & 0 deletions id.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ extern SEL selSucc;
extern SEL selNot;
extern SEL selInit;
extern SEL selCopy;
extern SEL sel_ignored;
extern ID idIncludedModules;
extern ID idIncludedInClasses;
#endif
Expand Down
12 changes: 0 additions & 12 deletions include/ruby/ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,18 +1138,6 @@ rb_ocid_to_rval(id obj)
#define RB2OC(obj) (rb_rval_to_ocid((VALUE)obj))
#define OC2RB(obj) (rb_ocid_to_rval((id)obj))

static inline bool
rb_ignored_selector(SEL sel)
{
#if defined(__ppc__)
return sel == (SEL)0xfffef000;
#elif defined(__i386__)
return sel == (SEL)0xfffeb010;
#else
# error Unsupported arch
#endif
}

static inline VALUE
rb_ary_elt_fast(CFArrayRef ary, long i)
{
Expand Down
3 changes: 1 addition & 2 deletions insns.def
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ defineclass
*/
DEFINE_INSN
send
(ID op_id, rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag, IC ic, VALUE sel)
(ID op_id, rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag, VALUE sel)
(...)
(VALUE val) // inc += - (op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0));
{
Expand All @@ -1051,7 +1051,6 @@ send
recv = (flag & VM_CALL_FCALL_BIT) ? GET_SELF() : TOPN(num);
klass = CLASS_OF(recv);
#if WITH_OBJC
ic = 0;
mn = NULL;
#else
mn = vm_method_search(id, klass, ic);
Expand Down
8 changes: 4 additions & 4 deletions objc.m
Original file line number Diff line number Diff line change
Expand Up @@ -1460,10 +1460,10 @@ VALUE rb_vm_call(rb_thread_t * th, VALUE klass, VALUE recv, VALUE id,
sel = sel_registerName(mid_str);
}

if (rb_ignored_selector(sel)) {
rb_warn("cannot register %c[%s %s] because it is an ignored selector",
class_isMetaClass((Class)mod) ? '+' : '-', class_getName((Class)mod), mid_str);
return;
if (sel == sel_ignored) {
char buf[100];
snprintf(buf, sizeof buf, "__rb_%s__", mid_str);
sel = sel_registerName(buf);
}

direct_override = false;
Expand Down
11 changes: 11 additions & 0 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -9380,6 +9380,17 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
e = m + len;
}
SEL name_hash = sel_registerName(name);
if (name_hash == sel_ignored) {
if (strcmp(name, "retain") == 0) {
name_hash = (SEL)0x1000;
}
else if (strcmp(name, "release") == 0) {
name_hash = (SEL)0x2000;
}
else {
assert(1==0);
}
}
id = (ID)CFDictionaryGetValue((CFDictionaryRef)global_symbols.sym_id,
(const void *)name_hash);
if (id != 0)
Expand Down
5 changes: 4 additions & 1 deletion variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,13 @@ struct global_variable {
struct trace_var *trace;
};

#if !WITH_OBJC
/* defined in vm_core.h, imported by debug.h */
struct global_entry {
struct global_variable *var;
ID id;
};
#endif

static VALUE undef_getter(ID id);
static void undef_setter(VALUE val, ID id, void *data, struct global_variable *var);
Expand Down Expand Up @@ -482,7 +485,7 @@ val_getter(ID id, VALUE val)
static void
val_setter(VALUE val, ID id, void *data, struct global_variable *var)
{
var->data = (void*)val;
GC_WB(&var->data, (void*)val);
}

static void
Expand Down
8 changes: 7 additions & 1 deletion vm_insnhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,13 @@ vm_call_method(rb_thread_t * const th, rb_control_frame_t * const cfp,
#if WITH_OBJC
IMP imp;

#define STUPID_CACHE 1
#define STUPID_CACHE 0

if (sel == sel_ignored) {
char buf[100];
snprintf(buf, sizeof buf, "__rb_%s__", rb_id2name(id));
sel = sel_registerName(buf);
}

#if STUPID_CACHE
static VALUE c_klass = 0;
Expand Down

0 comments on commit ec1f435

Please sign in to comment.