Add DONE_CHECKING as a reason for requesting nodes.

Split registering the unique new deps of a node between those where we're enqueueing a known dependency from a prior build and one where we're adding a new dependency.

Replace prefetchBatch with getBatchAsync and add createIfAbsentBatchAsync.

PiperOrigin-RevId: 190471980
diff --git a/src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java b/src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java
index 1ac8620..d711fc1 100644
--- a/src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java
@@ -14,6 +14,7 @@
 package com.google.devtools.build.skyframe;
 
 import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import java.util.Collection;
 import java.util.Map;
 import javax.annotation.Nullable;
@@ -40,6 +41,21 @@
       @Nullable SkyKey requestor, Reason reason, Iterable<SkyKey> keys) throws InterruptedException;
 
   /**
+   * Like {@link QueryableGraph#getBatchAsync}, except it creates a new node for each key not
+   * already present in the graph. Thus, the returned map will have an entry for each key in {@code
+   * keys}.
+   *
+   * @param requestor if non-{@code null}, the node on behalf of which the given {@code keys} are
+   *     being requested.
+   * @param reason the reason the nodes are being requested.
+   */
+  @CanIgnoreReturnValue
+  default InterruptibleSupplier<Map<SkyKey, ? extends NodeEntry>> createIfAbsentBatchAsync(
+      @Nullable SkyKey requestor, Reason reason, Iterable<SkyKey> keys) {
+    return InterruptibleSupplier.Memoize.of(() -> createIfAbsentBatch(requestor, reason, keys));
+  }
+
+  /**
    * Optional optimization: graph may use internal knowledge to filter out keys in {@code deps} that
    * have not been recomputed since the last computation of {@code parent}. When determining if
    * {@code parent} needs to be re-evaluated, this may be used to avoid unnecessary graph accesses.