/
Trace.java
72 lines (63 loc) · 1.89 KB
/
Trace.java
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* This file is part of the Jikes RVM project (http://jikesrvm.org).
*
* This file is licensed to You under the Common Public License (CPL);
* You may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.opensource.org/licenses/cpl1.0.php
*
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership.
*/
package org.mmtk.plan;
import org.mmtk.utility.Constants;
import org.mmtk.utility.deque.SharedDeque;
import org.mmtk.policy.RawPageSpace;
import org.vmmagic.pragma.*;
/**
* This abstract class implements the core functionality for a transitive
* closure over the heap. This class holds the global state, TraceLocal
* and its super-classes handle per-thread state.
*/
@Uninterruptible
public class Trace implements Constants {
// Global pools for load-balancing deques
final SharedDeque valuePool;
final SharedDeque rootLocationPool;
/**
* Constructor
*/
public Trace(RawPageSpace metaDataSpace) {
valuePool = new SharedDeque("valuePool",metaDataSpace, 1);
rootLocationPool = new SharedDeque("rootLocations", metaDataSpace, 1);
}
/**
* Prepare for a new collection pass.
*/
public void prepareNonBlocking() {
valuePool.prepareNonBlocking();
rootLocationPool.prepareNonBlocking();
}
/**
* Prepare for a new collection pass.
* All active GC threads take part.
*/
public void prepare() {
valuePool.prepare();
rootLocationPool.prepareNonBlocking();
}
/**
* Release resources after completing a collection pass.
*/
public void release() {
valuePool.reset();
rootLocationPool.reset();
}
/**
* Is there any work outstanding in this trace. That is are there any pages in the pools.
*/
public boolean hasWork() {
return (valuePool.enqueuedPages() + rootLocationPool.enqueuedPages()) > 0;
}
}