[llvm-commits] [vmkit] r51374 - /vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed May 21 07:41:09 PDT 2008
Author: geoffray
Date: Wed May 21 09:41:09 2008
New Revision: 51374
URL: http://llvm.org/viewvc/llvm-project?rev=51374&view=rev
Log:
Perform the collection check before allocating.
Modified:
vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=51374&r1=51373&r2=51374&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Wed May 21 09:41:09 2008
@@ -165,6 +165,15 @@
STATIC inline void *gcmalloc(VirtualTable *vt, size_t n) {
lock();
+
+ _since_last_collection -= n;
+ if(_enable_auto && (_since_last_collection <= 0)) {
+#ifdef SERVICE_GC
+ ++gcTriggered;
+#endif
+ collect_unprotect();
+ }
+
register GCChunkNode *header = allocator->alloc_chunk(n + sizeof(gc_header), 1, current_mark & 1);
#ifdef SERVICE_GC
header->meta = this;
@@ -176,13 +185,6 @@
register struct gc_header *p = header->chunk();
p->_XXX_vt = vt;
- _since_last_collection -= n;
- if(_enable_auto && (_since_last_collection <= 0)) {
-#ifdef SERVICE_GC
- ++gcTriggered;
-#endif
- collect_unprotect();
- }
unlock();
return p->_2gc();
@@ -190,7 +192,7 @@
STATIC inline void *gcrealloc(void *ptr, size_t n) {
lock();
-
+
GCPage *desc = GCHash::get(ptr);
GCChunkNode *node = desc->o2node(ptr, GCChunkNode::maskCollectable);
@@ -198,6 +200,16 @@
gcfatal("%p isn't a avalid object", ptr);
size_t old_sz = node->nbb();
+
+ _since_last_collection -= (n - old_sz);
+
+ if(_enable_auto && (_since_last_collection <= 0)) {
+#ifdef SERVICE_GC
+ ++gcTriggered;
+#endif
+ collect_unprotect();
+ }
+
GCChunkNode *res = allocator->realloc_chunk(desc, node, n+sizeof(gc_header));
#ifdef SERVICE_GC
res->meta = this;
@@ -210,14 +222,6 @@
}
gc_header *obj = res->chunk();
- _since_last_collection -= (n - old_sz);
-
- if(_enable_auto && (_since_last_collection <= 0)) {
-#ifdef SERVICE_GC
- ++gcTriggered;
-#endif
- collect_unprotect();
- }
unlock();
return obj->_2gc();
More information about the llvm-commits
mailing list