From e5b3536583f742e0dda9fd377dffbda3c1e3d366 Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 15 Nov 2021 18:24:03 -0800 Subject: [PATCH] Delete non-interning, non-singleton @AutoCodec. PiperOrigin-RevId: 410130440 --- .../build/lib/actions/FileArtifactValue.java | 11 ++-- .../FilesetTraversalParamsFactory.java | 50 ++++--------------- .../starlark/StarlarkCustomCommandLine.java | 9 +--- .../build/lib/rules/cpp/LinkerInputs.java | 38 ++------------ 4 files changed, 23 insertions(+), 85 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java index a10cde4eaf3f12..58009868547c6a 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java +++ b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java @@ -22,7 +22,7 @@ import com.google.common.io.BaseEncoding; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; -import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant; import com.google.devtools.build.lib.util.Fingerprint; import com.google.devtools.build.lib.vfs.DigestUtils; import com.google.devtools.build.lib.vfs.FileStatus; @@ -177,14 +177,17 @@ protected boolean couldBeModifiedByMetadata(FileArtifactValue lastKnown) { */ interface Singleton {} - @AutoCodec public static final FileArtifactValue DEFAULT_MIDDLEMAN = new SingletonMarkerValue(); + @SerializationConstant + public static final FileArtifactValue DEFAULT_MIDDLEMAN = new SingletonMarkerValue(); /** Data that marks that a file is not present on the filesystem. */ - @AutoCodec public static final FileArtifactValue MISSING_FILE_MARKER = new SingletonMarkerValue(); + @SerializationConstant + public static final FileArtifactValue MISSING_FILE_MARKER = new SingletonMarkerValue(); /** * Represents an omitted file -- we are aware of it but it doesn't exist. All access methods are * unsupported. */ - @AutoCodec public static final FileArtifactValue OMITTED_FILE_MARKER = new OmittedFileValue(); + @SerializationConstant + public static final FileArtifactValue OMITTED_FILE_MARKER = new OmittedFileValue(); public static FileArtifactValue createForSourceArtifact(Artifact artifact, FileValue fileValue) throws IOException { diff --git a/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java b/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java index 58bad5dde908f0..4d29b19e0b2577 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java +++ b/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; -import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.util.Fingerprint; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.Locale; @@ -175,7 +174,6 @@ private static ImmutableSortedSet getOrderedExcludes(@Nullable Set excludedFiles, - Optional directTraversal) { return new AutoValue_FilesetTraversalParamsFactory_DirectoryTraversalParams( - ownerLabelForErrorMessages, destPath, excludedFiles, directTraversal); + ownerLabelForErrorMessages, + destPath, + getOrderedExcludes(excludes), + Optional.of(traversal)); } } - @AutoCodec @AutoValue abstract static class NestedTraversalParams implements FilesetTraversalParams { @Override @@ -270,26 +261,15 @@ public void fingerprint(Fingerprint fp) { } static NestedTraversalParams getNestedTraversal( - Label ownerLabel, + Label ownerLabelForErrorMessages, Artifact nestedArtifact, PathFragment destPath, @Nullable Set excludes) { - return create(ownerLabel, destPath, getOrderedExcludes(excludes), nestedArtifact); - } - - @AutoCodec.VisibleForSerialization - @AutoCodec.Instantiator - static NestedTraversalParams create( - Label ownerLabelForErrorMessages, - PathFragment destPath, - ImmutableSortedSet excludedFiles, - Artifact nestedArtifact) { return new AutoValue_FilesetTraversalParamsFactory_NestedTraversalParams( - ownerLabelForErrorMessages, destPath, excludedFiles, nestedArtifact); + ownerLabelForErrorMessages, destPath, getOrderedExcludes(excludes), nestedArtifact); } } - @AutoCodec @AutoValue abstract static class KnownLinksTraversalParams implements FilesetTraversalParams { @Override @@ -323,22 +303,12 @@ public void fingerprint(Fingerprint fp) { } static KnownLinksTraversalParams getKnownLinksTraversal( - Label ownerLabel, + Label ownerLabelForErrorMessages, LinkSupplier additionalLinks, PathFragment destPath, @Nullable Set excludes) { - return create(ownerLabel, destPath, getOrderedExcludes(excludes), additionalLinks); - } - - @AutoCodec.VisibleForSerialization - @AutoCodec.Instantiator - static KnownLinksTraversalParams create( - Label ownerLabelForErrorMessages, - PathFragment destPath, - ImmutableSortedSet excludedFiles, - LinkSupplier additionalLinks) { return new AutoValue_FilesetTraversalParamsFactory_KnownLinksTraversalParams( - ownerLabelForErrorMessages, destPath, excludedFiles, additionalLinks); + ownerLabelForErrorMessages, destPath, getOrderedExcludes(excludes), additionalLinks); } } } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkCustomCommandLine.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkCustomCommandLine.java index c17ece532201a6..cf82e84ea1bc9d 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkCustomCommandLine.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkCustomCommandLine.java @@ -59,7 +59,6 @@ import net.starlark.java.syntax.Location; /** Supports ctx.actions.args() from Starlark. */ -@AutoCodec public class StarlarkCustomCommandLine extends CommandLine { protected final ImmutableList arguments; @@ -680,9 +679,7 @@ StarlarkCustomCommandLine build(boolean flagPerLine) { } } - @AutoCodec.VisibleForSerialization - @AutoCodec.Instantiator - StarlarkCustomCommandLine(ImmutableList arguments) { + private StarlarkCustomCommandLine(ImmutableList arguments) { this.arguments = arguments; } @@ -718,9 +715,7 @@ private static class StarlarkCustomCommandLineWithIndexes extends StarlarkCustom */ private final ImmutableList argStartIndexes; - @AutoCodec.VisibleForSerialization - @AutoCodec.Instantiator - public StarlarkCustomCommandLineWithIndexes( + StarlarkCustomCommandLineWithIndexes( ImmutableList arguments, ImmutableList argStartIndexes) { super(arguments); this.argStartIndexes = argStartIndexes; diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java index ea0cee47e469db..59e0f4212eb5b5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java @@ -21,8 +21,6 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.collect.CollectionUtils; import com.google.devtools.build.lib.concurrent.ThreadSafety; -import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; -import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization; /** Factory for creating new {@link LinkerInput} objects. */ public abstract class LinkerInputs { @@ -31,15 +29,13 @@ public abstract class LinkerInputs { * object file. */ @ThreadSafety.Immutable - @AutoCodec - public static class SimpleLinkerInput implements LinkerInput { + private static class SimpleLinkerInput implements LinkerInput { private final Artifact artifact; private final ArtifactCategory category; private final boolean disableWholeArchive; private final String libraryIdentifier; - @AutoCodec.Instantiator - public SimpleLinkerInput( + SimpleLinkerInput( Artifact artifact, ArtifactCategory category, boolean disableWholeArchive, @@ -175,14 +171,11 @@ public interface LibraryToLink extends LinkerInput { * library that it links to. */ @ThreadSafety.Immutable - @AutoCodec - public static class SolibLibraryToLink implements LibraryToLink { + private static class SolibLibraryToLink implements LibraryToLink { private final Artifact solibSymlinkArtifact; private final Artifact libraryArtifact; private final String libraryIdentifier; - @AutoCodec.Instantiator - @VisibleForSerialization SolibLibraryToLink( Artifact solibSymlinkArtifact, Artifact libraryArtifact, String libraryIdentifier) { Preconditions.checkArgument( @@ -272,9 +265,7 @@ public boolean disableWholeArchive() { /** This class represents a library that may contain object files. */ @ThreadSafety.Immutable - @AutoCodec - @VisibleForSerialization - static class CompoundLibraryToLink implements LibraryToLink { + private static class CompoundLibraryToLink implements LibraryToLink { private final Artifact libraryArtifact; private final ArtifactCategory category; private final String libraryIdentifier; @@ -284,28 +275,7 @@ static class CompoundLibraryToLink implements LibraryToLink { private final boolean mustKeepDebug; private final boolean disableWholeArchive; - @AutoCodec.Instantiator - @VisibleForSerialization CompoundLibraryToLink( - Artifact libraryArtifact, - ArtifactCategory category, - String libraryIdentifier, - Iterable objectFiles, - LtoCompilationContext ltoCompilationContext, - ImmutableMap sharedNonLtoBackends, - boolean mustKeepDebug, - boolean disableWholeArchive) { - this.libraryArtifact = libraryArtifact; - this.category = category; - this.libraryIdentifier = libraryIdentifier; - this.objectFiles = objectFiles; - this.ltoCompilationContext = ltoCompilationContext; - this.sharedNonLtoBackends = sharedNonLtoBackends; - this.mustKeepDebug = mustKeepDebug; - this.disableWholeArchive = disableWholeArchive; - } - - private CompoundLibraryToLink( Artifact libraryArtifact, ArtifactCategory category, String libraryIdentifier,