Commit 08b40fe6 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan Committed by Ben Gamari

NonMoving: Implement selector optimisation

parent cafa9963
......@@ -470,6 +470,7 @@ library
sm/NonMovingCensus.c
sm/NonMovingMark.c
sm/NonMovingScav.c
sm/NonMovingShortcut.c
sm/NonMovingSweep.c
sm/Sanity.c
sm/Scav.c
......
......@@ -294,6 +294,11 @@ INLINE_HEADER bool nonmovingClosureBeingSwept(StgClosure *p)
}
}
INLINE_HEADER bool isNonmovingClosure(StgClosure *p)
{
return !HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING;
}
#if defined(DEBUG)
void nonmovingPrintSegment(struct NonmovingSegment *seg);
......
......@@ -11,6 +11,7 @@
// This is sometimes declared as a register variable therefore it is necessary
// to include the declaration so that the compiler doesn't clobber the register.
#include "NonMovingMark.h"
#include "NonMovingShortcut.h"
#include "NonMoving.h"
#include "BlockAlloc.h" /* for countBlocks */
#include "HeapAlloc.h"
......@@ -25,7 +26,7 @@
#include "MarkWeak.h"
#include "sm/Storage.h"
static void mark_closure (MarkQueue *queue, StgClosure *p, StgClosure **origin);
static void mark_closure (MarkQueue *queue, const StgClosure *p, StgClosure **origin);
static void mark_tso (MarkQueue *queue, StgTSO *tso);
static void mark_stack (MarkQueue *queue, StgStack *stack);
static void mark_PAP_payload (MarkQueue *queue,
......@@ -1448,8 +1449,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin)
}
case THUNK_SELECTOR:
PUSH_FIELD((StgSelector *) p, selectee);
// TODO: selector optimization
nonmoving_eval_thunk_selector(queue, (StgSelector*)p, origin);
break;
case AP_STACK: {
......@@ -1595,6 +1595,7 @@ done:
if (origin != NULL && (!HEAP_ALLOCED(p) || bd->flags & BF_NONMOVING)) {
if (UNTAG_CLOSURE((StgClosure*)p0) != p && *origin == p0) {
if (cas((StgVolatilePtr)origin, (StgWord)p0, (StgWord)TAG_CLOSURE(tag, p)) == (StgWord)p0) {
// debugBelch("Thunk optimization successful\n");
}
}
}
......
This diff is collapsed.
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team, 1998-2019
*
* Non-moving garbage collector and allocator:
* Indirection short-cutting and the selector optimisation
*
* ---------------------------------------------------------------------------*/
#pragma once
#include "BeginPrivate.h"
void
nonmoving_eval_thunk_selector(MarkQueue *queue, StgSelector *p, StgClosure **origin);
#include "EndPrivate.h"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment