[macruby-changes] [996] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 19 15:23:49 PDT 2009
Revision: 996
http://trac.macosforge.org/projects/ruby/changeset/996
Author: lsansonetti at apple.com
Date: 2009-03-19 15:23:48 -0700 (Thu, 19 Mar 2009)
Log Message:
-----------
disable block caching (for now) + only disable some inline ops when they are redefined on the right classes
Modified Paths:
--------------
MacRuby/branches/experimental/roxor.cpp
MacRuby/branches/experimental/roxor.h
Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp 2009-03-19 18:58:10 UTC (rev 995)
+++ MacRuby/branches/experimental/roxor.cpp 2009-03-19 22:23:48 UTC (rev 996)
@@ -480,6 +480,7 @@
void add_method(Class klass, SEL sel, IMP imp, NODE *node, const char *types);
GlobalVariable *redefined_op_gvar(SEL sel, bool create);
+ bool should_invalidate_inline_op(SEL sel, Class klass);
struct ccache *constant_cache_get(ID path);
void const_defined(ID path);
@@ -1900,6 +1901,29 @@
return gvar;
}
+inline bool
+RoxorVM::should_invalidate_inline_op(SEL sel, Class klass)
+{
+ if (sel == selPLUS || sel == selMINUS || sel == selDIV
+ || sel == selMULT || sel == selLT || sel == selLE
+ || sel == selGT || sel == selGE || sel == selEq
+ || sel == selNeq || sel == selEqq) {
+ return klass == (Class)rb_cFixnum;
+ }
+
+ if (sel == selLTLT || sel == selAREF || sel == selASET) {
+ return klass == (Class)rb_cNSArray || klass == (Class)rb_cNSMutableArray;
+ }
+
+ if (sel == selSend || sel == sel__send__ || sel == selEval) {
+ // Matches any class, since these are Kernel methods.
+ return true;
+ }
+
+ printf("invalid inline op `%s' to invalidate!\n", sel_getName(sel));
+ abort();
+}
+
void
RoxorVM::add_method(Class klass, SEL sel, IMP imp, NODE *node, const char *types)
{
@@ -1934,7 +1958,7 @@
// Invalidate inline operations.
if (running) {
GlobalVariable *gvar = redefined_op_gvar(sel, false);
- if (gvar != NULL) {
+ if (gvar != NULL && should_invalidate_inline_op(sel, klass)) {
void *val = ee->getOrEmitGlobalVariable(gvar);
#if ROXOR_DEBUG
printf("change redefined global for [%s %s] to true\n",
@@ -4831,46 +4855,37 @@
void *
rb_vm_block_create(IMP imp, NODE *node, VALUE self, int dvars_size, ...)
{
- std::map<IMP, rb_vm_block_t *>::iterator iter =
- GET_VM()->blocks.find(imp);
+// std::map<IMP, rb_vm_block_t *>::iterator iter =
+// GET_VM()->blocks.find(imp);
rb_vm_block_t *b;
- if (iter == GET_VM()->blocks.end()) {
- b = (rb_vm_block_t *)xmalloc(sizeof(rb_vm_block_t));
+ // if (iter == GET_VM()->blocks.end()) {
+ b = (rb_vm_block_t *)xmalloc(sizeof(rb_vm_block_t) + (sizeof(VALUE *) * dvars_size));
- VALUE **dvars = NULL;
- if (dvars_size > 0) {
- dvars = (VALUE **)xmalloc(sizeof(VALUE *) * (dvars_size + 10));
- GC_WB(&b->dvars, dvars);
- }
- else {
- b->dvars = NULL;
- }
-
b->imp = imp;
b->node = node;
b->self = self;
+ b->is_lambda = true;
b->dvars_size = dvars_size;
- b->is_lambda = true;
- rb_objc_retain(b);
- GET_VM()->blocks[imp] = b;
- }
- else {
- b = iter->second;
- assert(b->dvars_size == dvars_size);
- }
-
- if (dvars_size) {
- va_list ar;
- va_start(ar, dvars_size);
- for (int i = 0; i < dvars_size; ++i) {
- b->dvars[i] = va_arg(ar, VALUE *);
+ if (dvars_size) {
+ va_list ar;
+ va_start(ar, dvars_size);
+ for (int i = 0; i < dvars_size; ++i) {
+ b->dvars[i] = va_arg(ar, VALUE *);
+ }
+ va_end(ar);
}
- va_end(ar);
- }
+// rb_objc_retain(b);
+// GET_VM()->blocks[imp] = b;
+// }
+// else {
+// b = iter->second;
+// assert(b->dvars_size == dvars_size);
+// }
+
return b;
}
Modified: MacRuby/branches/experimental/roxor.h
===================================================================
--- MacRuby/branches/experimental/roxor.h 2009-03-19 18:58:10 UTC (rev 995)
+++ MacRuby/branches/experimental/roxor.h 2009-03-19 22:23:48 UTC (rev 996)
@@ -82,9 +82,9 @@
VALUE self;
NODE *node;
IMP imp;
- VALUE **dvars;
+ bool is_lambda;
int dvars_size;
- bool is_lambda;
+ VALUE *dvars[1];
} rb_vm_block_t;
static inline rb_vm_block_t *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090319/57450f23/attachment.html>
More information about the macruby-changes
mailing list