Revision
5233
Author
lsansonetti@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

Diff

Modified: MacRuby/trunk/vm.cpp (5232 => 5233)


--- 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;
 }