aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2013-04-21 01:00:01 +0200
committerMike Pall <mike>2013-04-21 01:00:01 +0200
commit7b629b7bcf6bca3bd7733db601722c551098557e (patch)
tree927a28b8eb4c13b198ce5bf8e66f19c89ddf77c9
parent9ead735159de2a83c6903360bec3f681e28ba10e (diff)
downloadluajit-7b629b7bcf6bca3bd7733db601722c551098557e.tar.gz
luajit-7b629b7bcf6bca3bd7733db601722c551098557e.tar.bz2
luajit-7b629b7bcf6bca3bd7733db601722c551098557e.zip
Move buffer shrinking to atomic GC phase.
-rw-r--r--src/lj_gc.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/lj_gc.c b/src/lj_gc.c
index 4ce6eb19..c9eaf21a 100644
--- a/src/lj_gc.c
+++ b/src/lj_gc.c
@@ -349,14 +349,6 @@ static size_t gc_propagate_gray(global_State *g)
349 349
350/* -- Sweep phase --------------------------------------------------------- */ 350/* -- Sweep phase --------------------------------------------------------- */
351 351
352/* Try to shrink some common data structures. */
353static void gc_shrink(global_State *g, lua_State *L)
354{
355 if (g->strnum <= (g->strmask >> 2) && g->strmask > LJ_MIN_STRTAB*2-1)
356 lj_str_resize(L, g->strmask >> 1); /* Shrink string table. */
357 lj_buf_shrink(L, &g->tmpbuf); /* Shrink temp buffer. */
358}
359
360/* Type of GC free functions. */ 352/* Type of GC free functions. */
361typedef void (LJ_FASTCALL *GCFreeFunc)(global_State *g, GCobj *o); 353typedef void (LJ_FASTCALL *GCFreeFunc)(global_State *g, GCobj *o);
362 354
@@ -591,6 +583,8 @@ static void atomic(global_State *g, lua_State *L)
591 /* All marking done, clear weak tables. */ 583 /* All marking done, clear weak tables. */
592 gc_clearweak(gcref(g->gc.weak)); 584 gc_clearweak(gcref(g->gc.weak));
593 585
586 lj_buf_shrink(L, &g->tmpbuf); /* Shrink temp buffer. */
587
594 /* Prepare for sweep phase. */ 588 /* Prepare for sweep phase. */
595 g->gc.currentwhite = (uint8_t)otherwhite(g); /* Flip current white. */ 589 g->gc.currentwhite = (uint8_t)otherwhite(g); /* Flip current white. */
596 g->strempty.marked = g->gc.currentwhite; 590 g->strempty.marked = g->gc.currentwhite;
@@ -631,7 +625,8 @@ static size_t gc_onestep(lua_State *L)
631 MSize old = g->gc.total; 625 MSize old = g->gc.total;
632 setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX)); 626 setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX));
633 if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) { 627 if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) {
634 gc_shrink(g, L); 628 if (g->strnum <= (g->strmask >> 2) && g->strmask > LJ_MIN_STRTAB*2-1)
629 lj_str_resize(L, g->strmask >> 1); /* Shrink string table. */
635 if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ 630 if (gcref(g->gc.mmudata)) { /* Need any finalizations? */
636 g->gc.state = GCSfinalize; 631 g->gc.state = GCSfinalize;
637 } else { /* Otherwise skip this phase to help the JIT. */ 632 } else { /* Otherwise skip this phase to help the JIT. */