File: tracker.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 (58 lines) | stat: -rw-r--r-- 1,473 bytes parent folder | download | duplicates (3)
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
50
51
52
53
54
55
56
57
58
/**
 * Object tracking reads and writes to memory.
 *
 * There are two types of reads and writes in order to make the visualization clearer:
 * 1. Recent reads/writes
 * 2. Old read/writes
 *
 * The set of old reads/writes contain recent reads/writes as well. The recent reads/writes only
 * contain reads writes in the last "step" (whatever that might have been). Thus, we use old
 * reads/writes to check for concurrency issues, and recent reads/writes to highlight the results of
 * the last step in the visualization.
 */
class MemTracker {
	// Old reads and writes.
	unsafe:PinnedSet reads;
	unsafe:PinnedSet writes;

	// Recent reads and writes. These reads and writes are a part of 'reads' and 'writes'.
	unsafe:PinnedSet newReads;
	unsafe:PinnedSet newWrites;

	// Initialize.
	init() { init{} }

	// Copy.
	init(MemTracker original) {
		init {
			reads = unsafe:PinnedSet(original.reads);
			writes = unsafe:PinnedSet(original.writes);
			newReads = unsafe:PinnedSet(original.newReads);
			newWrites = unsafe:PinnedSet(original.newWrites);
		}
	}

	// Clear content.
	void clearAll() {
		reads.clear();
		writes.clear();
		newReads.clear();
		newWrites.clear();
	}

	// Clear only recent.
	void clearNew() {
		newReads.clear();
		newWrites.clear();
	}

	// Convenience functions from ASM.
	void addRead(lang:unknown:PTR_NOGC ptr) {
		reads.put(ptr);
		newReads.put(ptr);
	}
	void addWrite(lang:unknown:PTR_NOGC ptr) {
		writes.put(ptr);
		newWrites.put(ptr);
	}
}