Skip to content

Commit f1f9120

Browse files
committed
Small additions to documentation, and convenience methods.
1 parent bd46f4a commit f1f9120

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/main/java/org/truffleruby/core/MarkingService.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public MarkRunnerService(RubyContext context, ReferenceProcessor referenceProces
7979

8080
@Override
8181
protected void processReference(ProcessingReference<?> reference) {
82+
/*
83+
* We need to keep all the objects that might be marked
84+
* alive during the marking process itself, so we add the
85+
* arrays to a list to achieve this.
86+
*/
8287
ArrayList<Object[]> keptObjectLists = new ArrayList<>();
8388
Object[] list;
8489
while (true) {
@@ -189,6 +194,10 @@ private boolean isFull() {
189194
* We can just copy its contents into our buffer.
190195
* 4. The other buffer will not fit into our buffer. We need to copy across as much as will
191196
* fit, queue the now full buffer, and then copy the rest.
197+
*
198+
* We do this rather than simply add the threads objects to
199+
* the queue because we want to avoid increasing the marking
200+
* overhead unnecessarily.
192201
*/
193202
public void keepObjects(MarkerKeptObjects otherObjects) {
194203
if (isFull()) {
@@ -275,6 +284,13 @@ public void queueForMarking(Object[] objects) {
275284
runnerService.add(new MarkRunnerReference(new Object(), referenceProcessor.processingQueue, runnerService));
276285
}
277286

287+
/*
288+
* Convenience method to schedule marking now. Puts an empty array on the queue.
289+
*/
290+
public void queueMarking() {
291+
queueForMarking(new Object[0]);
292+
}
293+
278294
public void addMarker(DynamicObject object, MarkerAction action) {
279295
add(new MarkerReference(object, referenceProcessor.processingQueue, action, this));
280296
}

src/main/java/org/truffleruby/core/VMPrimitiveNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static abstract class VMGCStartPrimitiveNode extends PrimitiveArrayArgume
109109
@TruffleBoundary
110110
@Specialization
111111
public DynamicObject vmGCStart() {
112-
getContext().getMarkingService().queueForMarking(new Object[0]);
112+
getContext().getMarkingService().queueMarking();
113113
System.gc();
114114
return nil();
115115
}

src/main/java/org/truffleruby/language/objects/ObjectGraph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static Set<DynamicObject> newRubyObjectSet() {
4040

4141
@TruffleBoundary
4242
public static Set<DynamicObject> stopAndGetAllObjects(Node currentNode, final RubyContext context) {
43-
context.getMarkingService().queueForMarking(new Object[0]);
43+
context.getMarkingService().queueMarking();
4444
final Set<DynamicObject> visited = newRubyObjectSet();
4545

4646
final Thread initiatingJavaThread = Thread.currentThread();

0 commit comments

Comments
 (0)