diff options
author | 2015-11-19 02:16:24 +0000 | |
---|---|---|
committer | 2015-11-19 10:04:36 +0000 | |
commit | 26b3d8532cda8e38244b33222935e5c478d25ad0 (patch) | |
tree | 85becd59cc73bbcff56365a59fb41bfaf24c1b3c /src/main/java | |
parent | 3ac42bf4a979c96e73fd79fb8f5416ae7d7621eb (diff) |
Allow SkyValues to be marked not "comparable". Such values are not compared for the purpose of change pruning.
--
MOS_MIGRATED_REVID=108203369
Diffstat (limited to 'src/main/java')
4 files changed, 51 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageValue.java index 58753ad2b8..be934a538e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageValue.java @@ -20,8 +20,8 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; import com.google.devtools.build.lib.packages.BuildFileContainsErrorsException; import com.google.devtools.build.lib.packages.Package; import com.google.devtools.build.lib.vfs.RootedPath; +import com.google.devtools.build.skyframe.NotComparableSkyValue; import com.google.devtools.build.skyframe.SkyKey; -import com.google.devtools.build.skyframe.SkyValue; import java.util.ArrayList; import java.util.List; @@ -31,7 +31,7 @@ import java.util.List; */ @Immutable @ThreadSafe -public class PackageValue implements SkyValue { +public class PackageValue implements NotComparableSkyValue { private final Package pkg; diff --git a/src/main/java/com/google/devtools/build/skyframe/BuildingState.java b/src/main/java/com/google/devtools/build/skyframe/BuildingState.java index 1f72484b60..d0d2573af7 100644 --- a/src/main/java/com/google/devtools/build/skyframe/BuildingState.java +++ b/src/main/java/com/google/devtools/build/skyframe/BuildingState.java @@ -300,6 +300,9 @@ public class BuildingState { */ boolean unchangedFromLastBuild(SkyValue newValue) { checkFinishedBuildingWhenAboutToSetValue(); + if (newValue instanceof NotComparableSkyValue) { + return false; + } return getLastBuildValue().equals(newValue) && lastBuildDirectDeps.equals(directDeps); } diff --git a/src/main/java/com/google/devtools/build/skyframe/NotComparableSkyValue.java b/src/main/java/com/google/devtools/build/skyframe/NotComparableSkyValue.java new file mode 100644 index 0000000000..5cb211bc6b --- /dev/null +++ b/src/main/java/com/google/devtools/build/skyframe/NotComparableSkyValue.java @@ -0,0 +1,18 @@ +// Copyright 2015 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.skyframe; + +/** A SkyValue which, after a fresh evaluation, can never be equal to its last value. */ +public interface NotComparableSkyValue extends SkyValue { +} diff --git a/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java b/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java index 6eab026445..b7024334a2 100644 --- a/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java +++ b/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java @@ -60,7 +60,7 @@ public abstract class ValueWithMetadata implements SkyValue { if (errorInfo == null) { return transitiveEvents.isEmpty() ? value - : new ValueWithEvents(value, transitiveEvents); + : ValueWithEvents.createValueWithEvents(value, transitiveEvents); } return new ErrorInfoValue(errorInfo, value, transitiveEvents); } @@ -75,15 +75,24 @@ public abstract class ValueWithMetadata implements SkyValue { public abstract NestedSet<TaggedEvents> getTransitiveEvents(); /** Implementation of {@link ValueWithMetadata} for the value case. */ - public static final class ValueWithEvents extends ValueWithMetadata { + public static class ValueWithEvents extends ValueWithMetadata { private final NestedSet<TaggedEvents> transitiveEvents; - public ValueWithEvents(SkyValue value, NestedSet<TaggedEvents> transitiveEvents) { + private ValueWithEvents(SkyValue value, NestedSet<TaggedEvents> transitiveEvents) { super(Preconditions.checkNotNull(value)); this.transitiveEvents = Preconditions.checkNotNull(transitiveEvents); } + public static ValueWithEvents createValueWithEvents(SkyValue value, + NestedSet<TaggedEvents> transitiveEvents) { + if (value instanceof NotComparableSkyValue) { + return new NotComparableValueWithEvents(value, transitiveEvents); + } else { + return new ValueWithEvents(value, transitiveEvents); + } + } + @Nullable @Override ErrorInfo getErrorInfo() { return null; } @@ -124,8 +133,21 @@ public abstract class ValueWithMetadata implements SkyValue { public String toString() { return value.toString(); } } - /** Implementation of {@link ValueWithMetadata} for the error case. */ - private static final class ErrorInfoValue extends ValueWithMetadata { + private static final class NotComparableValueWithEvents extends ValueWithEvents + implements NotComparableSkyValue { + private NotComparableValueWithEvents(SkyValue value, + NestedSet<TaggedEvents> transitiveEvents) { + super(value, transitiveEvents); + } + } + + /** + * Implementation of {@link ValueWithMetadata} for the error case. + * + * ErorInfo does not override equals(), so it may as well be marked NotComparableSkyValue. + */ + private static final class ErrorInfoValue extends ValueWithMetadata + implements NotComparableSkyValue { private final ErrorInfo errorInfo; private final NestedSet<TaggedEvents> transitiveEvents; @@ -198,7 +220,7 @@ public abstract class ValueWithMetadata implements SkyValue { if (value instanceof ValueWithMetadata) { return (ValueWithMetadata) value; } - return new ValueWithEvents(value, NO_EVENTS); + return ValueWithEvents.createValueWithEvents(value, NO_EVENTS); } @Nullable |