File: barrier.bs

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (49 lines) | stat: -rw-r--r-- 1,349 bytes parent folder | download
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
46
47
48
49
use core:lang;

/**
 * Explicit barriers.
 *
 * We support three types of barriers:
 * - acquire
 * - release
 * - full (acquire + release, sequentially consistent)
 *
 * The runtime takes them into account from two places:
 * 1. From SrcBarrier instances inserted as metadata in the listing.
 * 2. From the CodeHints class. When a function call without a Barrier instance is encountered,
 *    the function 'functionBarrier' is called to determine the semantics. This allows an
 *    implementation to hide calls to internal helper functions, and properly treat library- or
 *    external functions as hidden. This will not be done for functions that are patched
 *    (as decided by 'patchExternal'). These barriers are inserted right before the function
 *    call. Thus, an implementation that inserts barriers itself should return "none"
 *    for the relevant functions in CodeHints.
 */
enum Barrier : bitmask {
	none = 0,
	acquire = 1,
	release = 2,
	full = 3,

	// Is this a function call where the call itself should be shown?
	showCall = 32,
}

/**
 * A barrier located in source code. Also provides location information.
 */
class SrcBarrier {
	init(Barrier type, SrcPos pos) {
		init {
			type = type;
			pos = pos;
		}
	}

	Barrier type;

	SrcPos pos;

	void toS(StrBuf to) : override {
		to << "Barrier: " << type << "@" << pos;
	}
}