Revision: 1503 http://trac.macosforge.org/projects/ruby/changeset/1503 Author: vincent.isambart@gmail.com Date: 2009-04-28 18:11:35 -0700 (Tue, 28 Apr 2009) Log Message: ----------- do not always use the cached version of a block object Modified Paths: -------------- MacRuby/branches/experimental/roxor.cpp MacRuby/branches/experimental/roxor.h Modified: MacRuby/branches/experimental/roxor.cpp =================================================================== --- MacRuby/branches/experimental/roxor.cpp 2009-04-29 01:11:29 UTC (rev 1502) +++ MacRuby/branches/experimental/roxor.cpp 2009-04-29 01:11:35 UTC (rev 1503) @@ -7700,7 +7700,7 @@ rb_vm_block_t *b; bool cached = false; - if (iter == GET_VM()->blocks.end()) { + if ((iter == GET_VM()->blocks.end()) || (iter->second->flags & (VM_BLOCK_ACTIVE | VM_BLOCK_PROC))) { b = (rb_vm_block_t *)xmalloc(sizeof(rb_vm_block_t) + (sizeof(VALUE *) * dvars_size)); @@ -8005,23 +8005,11 @@ block_call: - // We need to preserve dynamic variable slots here because our block may - // call the parent method which may call the block again, and since dvars - // are currently implemented using alloca() we will painfully die if the - // previous slots are not restored. - VALUE *old_dvars[100]; - assert(b->dvars_size < 100); - for (int i = 0; i < b->dvars_size; i++) { - old_dvars[i] = b->dvars[i]; - } - + b->flags |= VM_BLOCK_ACTIVE; VALUE v = __rb_vm_bcall(b->self, (VALUE)b->dvars, b->imp, b->arity, argc, argv); + b->flags &= ~VM_BLOCK_ACTIVE; - for (int i = 0; i < b->dvars_size; i++) { - b->dvars[i] = old_dvars[i]; - } - return v; } Modified: MacRuby/branches/experimental/roxor.h =================================================================== --- MacRuby/branches/experimental/roxor.h 2009-04-29 01:11:29 UTC (rev 1502) +++ MacRuby/branches/experimental/roxor.h 2009-04-29 01:11:35 UTC (rev 1503) @@ -21,6 +21,7 @@ #define VM_BLOCK_PROC 0x0001 // block is a Proc object #define VM_BLOCK_LAMBDA 0x0002 // block is a lambda +#define VM_BLOCK_ACTIVE 0x0004 // block is active (being executed) typedef struct { VALUE self;
participants (1)
-
source_changes@macosforge.org