[macruby-changes] [5233] MacRuby/trunk/vm.cpp

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 18 15:14:45 PST 2011


Revision: 5233
          http://trac.macosforge.org/projects/ruby/changeset/5233
Author:   lsansonetti at apple.com
Date:     2011-02-18 15:14:44 -0800 (Fri, 18 Feb 2011)
Log Message:
-----------
fix a race condition bug when spawning a new VM instance and copying the current VM dispatch cache + free unused memory when resolving JIT methods

Modified Paths:
--------------
    MacRuby/trunk/vm.cpp

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2011-02-15 22:36:06 UTC (rev 5232)
+++ MacRuby/trunk/vm.cpp	2011-02-18 23:14:44 UTC (rev 5233)
@@ -472,7 +472,6 @@
 
     mcache = (struct mcache *)calloc(VM_MCACHE_SIZE, sizeof(struct mcache));
     assert(mcache != NULL);
-    memcpy(mcache, vm.mcache, sizeof(struct mcache) * VM_MCACHE_SIZE);
 }
 
 RoxorVM::~RoxorVM(void)
@@ -1943,6 +1942,15 @@
 	}
     }
 
+    // If the map is empty, there is no point in keeping it.
+    if (map->size() == 0) {
+	std::map<SEL, std::map<Class, rb_vm_method_source_t *> *>::iterator
+	    iter = method_sources.find(sel);
+	assert(iter != method_sources.end());
+	method_sources.erase(iter);
+	delete map;	
+    }
+
     return did_something;
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110218/def55f8a/attachment.html>


More information about the macruby-changes mailing list