summaryrefslogtreecommitdiff
path: root/rts/Messages.h
blob: 49b8e8b2a86617e7480694e74c325d3a84300b8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* ---------------------------------------------------------------------------
 *
 * (c) The GHC Team, 2010
 *
 * Inter-Capability message passing
 *
 * --------------------------------------------------------------------------*/

#pragma once

#include "Capability.h"
#include "Updates.h" // for DEBUG_FILL_SLOP
#include "Schedule.h" // for SCHED_INTERRUPTING
#include "SMPClosureOps.h"

#include "BeginPrivate.h"

uint32_t messageBlackHole(Capability *cap, MessageBlackHole *msg);
StgTSO * blackHoleOwner (StgClosure *bh);

#if defined(THREADED_RTS)
void executeMessage (Capability *cap, Message *m);
void sendMessage    (Capability *from_cap, Capability *to_cap, Message *msg);
#endif

INLINE_HEADER void
doneWithMsgThrowTo (Capability *cap, MessageThrowTo *m)
{
    // The message better be locked (unless we are running single-threaded,
    // where we are a bit more lenient (#19075) or we got here from
    // deleteAllThreads() due to RTS shutdown).
    ASSERT(getNumCapabilities() == 1 || m->header.info == &stg_WHITEHOLE_info || getSchedState() == SCHED_INTERRUPTING);
    IF_NONMOVING_WRITE_BARRIER_ENABLED {
      updateRemembSetPushMessageThrowTo(cap, m);
    }
    OVERWRITING_CLOSURE((StgClosure*)m);
    unlockClosure((StgClosure*)m, &stg_MSG_NULL_info);
    LDV_RECORD_CREATE(m);
}

#include "EndPrivate.h"

#if defined(THREADED_RTS) && defined(PROF_SPIN)
extern volatile StgWord64 whitehole_executeMessage_spin;
#endif