[dart2js] Refactor serialization/deserialization implementations (6/6)

Rename DataSource -> DataSourceReader and SourceReader -> DataSource to more accurately reflect these classes' new roles. 'Writer' and 'Reader' are used for the higher level class that composes serialization operations. The 'Sink' and 'Source' handle the low-level conversions to/from the storage format.

Change-Id: I384b5f134beb040676f8e1ef4fba056e0c40358f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238243
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
diff --git a/pkg/compiler/lib/src/closure.dart b/pkg/compiler/lib/src/closure.dart
index af806f9..e5e807e 100644
--- a/pkg/compiler/lib/src/closure.dart
+++ b/pkg/compiler/lib/src/closure.dart
@@ -16,11 +16,11 @@
 abstract class ClosureData {
   /// Deserializes a [ClosureData] object from [source].
   factory ClosureData.readFromDataSource(
-          JsToElementMap elementMap, DataSource source) =
+          JsToElementMap elementMap, DataSourceReader source) =
       ClosureDataImpl.readFromDataSource;
 
   /// Serializes this [ClosureData] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   /// Look up information about the variables that have been mutated and are
   /// used inside the scope of [node].
@@ -66,7 +66,7 @@
   const ScopeInfo();
 
   /// Deserializes a [ScopeInfo] object from [source].
-  factory ScopeInfo.readFromDataSource(DataSource source) {
+  factory ScopeInfo.readFromDataSource(DataSourceReader source) {
     ScopeInfoKind kind = source.readEnum(ScopeInfoKind.values);
     switch (kind) {
       case ScopeInfoKind.scopeInfo:
@@ -82,7 +82,7 @@
   }
 
   /// Serializes this [ScopeInfo] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     throw UnsupportedError('${runtimeType}.writeToDataSink');
   }
 
@@ -126,7 +126,7 @@
   const CapturedScope();
 
   /// Deserializes a [CapturedScope] object from [source].
-  factory CapturedScope.readFromDataSource(DataSource source) {
+  factory CapturedScope.readFromDataSource(DataSourceReader source) {
     ScopeInfoKind kind = source.readEnum(ScopeInfoKind.values);
     switch (kind) {
       case ScopeInfoKind.scopeInfo:
@@ -173,7 +173,7 @@
   const CapturedLoopScope();
 
   /// Deserializes a [CapturedLoopScope] object from [source].
-  factory CapturedLoopScope.readFromDataSource(DataSource source) {
+  factory CapturedLoopScope.readFromDataSource(DataSourceReader source) {
     ScopeInfoKind kind = source.readEnum(ScopeInfoKind.values);
     switch (kind) {
       case ScopeInfoKind.scopeInfo:
@@ -241,7 +241,8 @@
   const ClosureRepresentationInfo();
 
   /// Deserializes a [ClosureRepresentationInfo] object from [source].
-  factory ClosureRepresentationInfo.readFromDataSource(DataSource source) {
+  factory ClosureRepresentationInfo.readFromDataSource(
+      DataSourceReader source) {
     ScopeInfoKind kind = source.readEnum(ScopeInfoKind.values);
     switch (kind) {
       case ScopeInfoKind.scopeInfo:
diff --git a/pkg/compiler/lib/src/common/codegen.dart b/pkg/compiler/lib/src/common/codegen.dart
index 0cf5baf..527f2fa 100644
--- a/pkg/compiler/lib/src/common/codegen.dart
+++ b/pkg/compiler/lib/src/common/codegen.dart
@@ -40,10 +40,10 @@
 class CodegenImpact extends WorldImpact {
   const CodegenImpact();
 
-  factory CodegenImpact.readFromDataSource(DataSource source) =
+  factory CodegenImpact.readFromDataSource(DataSourceReader source) =
       _CodegenImpact.readFromDataSource;
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     throw UnsupportedError('CodegenImpact.writeToDataSink');
   }
 
@@ -105,7 +105,7 @@
       this._oneShotInterceptors)
       : super.internal(dynamicUses, staticUses, typeUses, constantUses);
 
-  factory _CodegenImpact.readFromDataSource(DataSource source) {
+  factory _CodegenImpact.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberEntity member = source.readMember();
     Set<DynamicUse> dynamicUses = source
@@ -165,7 +165,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMember(member);
     sink.writeList(dynamicUses, (DynamicUse use) => use.writeToDataSink(sink),
@@ -502,7 +502,7 @@
   /// deserialization are collected in [modularNames] and [modularExpressions]
   /// to avoid the need for visiting the [code] node post deserialization.
   factory CodegenResult.readFromDataSource(
-      DataSource source,
+      DataSourceReader source,
       List<ModularName> modularNames,
       List<ModularExpression> modularExpressions) {
     source.begin(tag);
@@ -517,7 +517,7 @@
   /// The [modularNames] and [modularExpressions] fields are not directly
   /// serializes because these are embedded in the [code] node and collected
   /// through this during deserialization.
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeJsNodeOrNull(code);
     impact.writeToDataSink(sink);
@@ -635,7 +635,7 @@
 
   ModularName(this.kind, {this.data, this.set});
 
-  factory ModularName.readFromDataSource(DataSource source) {
+  factory ModularName.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ModularNameKind kind = source.readEnum(ModularNameKind.values);
     Object data;
@@ -678,7 +678,7 @@
     return ModularName(kind, data: data, set: set);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeEnum(kind);
     switch (kind) {
@@ -884,7 +884,7 @@
 
   ModularExpression(this.kind, this.data);
 
-  factory ModularExpression.readFromDataSource(DataSource source) {
+  factory ModularExpression.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ModularExpressionKind kind = source.readEnum(ModularExpressionKind.values);
     Object data;
@@ -900,7 +900,7 @@
     return ModularExpression(kind, data);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeEnum(kind);
     switch (kind) {
@@ -1107,13 +1107,13 @@
   static const String deferredHolderExpression = 'js-deferredHolderExpression';
 }
 
-/// Visitor that serializes a [js.Node] into a [DataSink].
+/// Visitor that serializes a [js.Node] into a [DataSinkWriter].
 class JsNodeSerializer implements js.NodeVisitor<void> {
-  final DataSink sink;
+  final DataSinkWriter sink;
 
   JsNodeSerializer._(this.sink);
 
-  static void writeToDataSink(DataSink sink, js.Node node) {
+  static void writeToDataSink(DataSinkWriter sink, js.Node node) {
     sink.begin(JsNodeTags.tag);
     JsNodeSerializer serializer = JsNodeSerializer._(sink);
     serializer.visit(node);
@@ -1775,19 +1775,19 @@
   }
 }
 
-/// Helper class that deserializes a [js.Node] from [DataSource].
+/// Helper class that deserializes a [js.Node] from [DataSourceReader].
 ///
 /// Deserialized [ModularName]s and [ModularExpression]s are collected in the
 /// [modularNames] and [modularExpressions] lists.
 class JsNodeDeserializer {
-  final DataSource source;
+  final DataSourceReader source;
   final List<ModularName> modularNames;
   final List<ModularExpression> modularExpressions;
 
   JsNodeDeserializer._(this.source, this.modularNames, this.modularExpressions);
 
   static js.Node readFromDataSource(
-      DataSource source,
+      DataSourceReader source,
       List<ModularName> modularNames,
       List<ModularExpression> modularExpressions) {
     source.begin(JsNodeTags.tag);
@@ -2229,24 +2229,24 @@
       this.closedWorld, this.modularNames, this.modularExpressions);
 
   @override
-  AbstractValue readAbstractValue(DataSource source) {
+  AbstractValue readAbstractValue(DataSourceReader source) {
     return closedWorld.abstractValueDomain
         .readAbstractValueFromDataSource(source);
   }
 
   @override
-  js.Node readJsNode(DataSource source) {
+  js.Node readJsNode(DataSourceReader source) {
     return JsNodeDeserializer.readFromDataSource(
         source, modularNames, modularExpressions);
   }
 
   @override
-  OutputUnit readOutputUnitReference(DataSource source) {
+  OutputUnit readOutputUnitReference(DataSourceReader source) {
     return closedWorld.outputUnitData.outputUnits[source.readInt()];
   }
 
   @override
-  TypeRecipe readTypeRecipe(DataSource source) {
+  TypeRecipe readTypeRecipe(DataSourceReader source) {
     return TypeRecipe.readFromDataSource(source);
   }
 }
@@ -2257,22 +2257,22 @@
   CodegenWriterImpl(this.closedWorld);
 
   @override
-  void writeAbstractValue(DataSink sink, AbstractValue value) {
+  void writeAbstractValue(DataSinkWriter sink, AbstractValue value) {
     closedWorld.abstractValueDomain.writeAbstractValueToDataSink(sink, value);
   }
 
   @override
-  void writeJsNode(DataSink sink, js.Node node) {
+  void writeJsNode(DataSinkWriter sink, js.Node node) {
     JsNodeSerializer.writeToDataSink(sink, node);
   }
 
   @override
-  void writeOutputUnitReference(DataSink sink, OutputUnit value) {
+  void writeOutputUnitReference(DataSinkWriter sink, OutputUnit value) {
     sink.writeInt(closedWorld.outputUnitData.outputUnits.indexOf(value));
   }
 
   @override
-  void writeTypeRecipe(DataSink sink, TypeRecipe recipe) {
+  void writeTypeRecipe(DataSinkWriter sink, TypeRecipe recipe) {
     recipe.writeToDataSink(sink);
   }
 }
diff --git a/pkg/compiler/lib/src/deferred_load/output_unit.dart b/pkg/compiler/lib/src/deferred_load/output_unit.dart
index 17daef0..bd27d06 100644
--- a/pkg/compiler/lib/src/deferred_load/output_unit.dart
+++ b/pkg/compiler/lib/src/deferred_load/output_unit.dart
@@ -156,7 +156,7 @@
   }
 
   /// Deserializes an [OutputUnitData] object from [source].
-  factory OutputUnitData.readFromDataSource(DataSource source) {
+  factory OutputUnitData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     bool isProgramSplit = source.readBool();
     List<OutputUnit> outputUnits = source.readList(() {
@@ -205,7 +205,7 @@
   }
 
   /// Serializes this [OutputUnitData] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeBool(isProgramSplit);
     Map<OutputUnit, int> outputUnitIndices = {};
diff --git a/pkg/compiler/lib/src/elements/entities.dart b/pkg/compiler/lib/src/elements/entities.dart
index a9f5514..f8d96a3 100644
--- a/pkg/compiler/lib/src/elements/entities.dart
+++ b/pkg/compiler/lib/src/elements/entities.dart
@@ -350,7 +350,7 @@
   }
 
   /// Deserializes a [ParameterStructure] object from [source].
-  factory ParameterStructure.readFromDataSource(DataSource source) {
+  factory ParameterStructure.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     int requiredPositionalParameters = source.readInt();
     int positionalParameters = source.readInt();
@@ -368,7 +368,7 @@
   }
 
   /// Serializes this [ParameterStructure] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeInt(requiredPositionalParameters);
     sink.writeInt(positionalParameters);
diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart
index c93c535..a0d63a9 100644
--- a/pkg/compiler/lib/src/elements/types.dart
+++ b/pkg/compiler/lib/src/elements/types.dart
@@ -24,7 +24,7 @@
 /// implemented directly but other entity systems, for instance based directly
 /// on kernel ir without the need for [Element].
 
-extension on DataSource {
+extension on DataSourceReader {
   List<DartType> _readDartTypes(
       List<FunctionTypeVariable> functionTypeVariables) {
     int count = readInt();
@@ -36,7 +36,7 @@
   }
 }
 
-extension on DataSink {
+extension on DataSinkWriter {
   void _writeDartTypes(
       List<DartType> types, List<FunctionTypeVariable> functionTypeVariables) {
     writeInt(types.length);
@@ -49,8 +49,8 @@
 abstract class DartType {
   const DartType();
 
-  factory DartType.readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory DartType.readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     DartTypeKind kind = source.readEnum(DartTypeKind.values);
     switch (kind) {
       case DartTypeKind.none:
@@ -86,7 +86,7 @@
   }
 
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables);
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables);
 
   /// Returns the base type if this is a [LegacyType] or [NullableType] and
   /// returns this type otherwise.
@@ -204,8 +204,8 @@
 
   const LegacyType._(this.baseType);
 
-  factory LegacyType._readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory LegacyType._readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     DartType baseType =
         DartType.readFromDataSource(source, functionTypeVariables);
     return LegacyType._(baseType);
@@ -213,7 +213,7 @@
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.legacyType);
     baseType.writeToDataSink(sink, functionTypeVariables);
   }
@@ -259,8 +259,8 @@
 
   const NullableType._(this.baseType);
 
-  factory NullableType._readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory NullableType._readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     DartType baseType =
         DartType.readFromDataSource(source, functionTypeVariables);
     return NullableType._(baseType);
@@ -268,7 +268,7 @@
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.nullableType);
     baseType.writeToDataSink(sink, functionTypeVariables);
   }
@@ -321,8 +321,8 @@
     return InterfaceType._allocate(element, typeArguments);
   }
 
-  factory InterfaceType._readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory InterfaceType._readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     ClassEntity element = source.readClass();
     List<DartType> typeArguments = source._readDartTypes(functionTypeVariables);
     return InterfaceType._(element, typeArguments);
@@ -330,7 +330,7 @@
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.interfaceType);
     sink.writeClass(element);
     sink._writeDartTypes(typeArguments, functionTypeVariables);
@@ -393,15 +393,15 @@
 
   const TypeVariableType._(this.element);
 
-  factory TypeVariableType._readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory TypeVariableType._readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     TypeVariableEntity element = source.readTypeVariable();
     return TypeVariableType._(element);
   }
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.typeVariable);
     sink.writeTypeVariable(element);
   }
@@ -449,8 +449,8 @@
 
   FunctionTypeVariable._(this.index);
 
-  factory FunctionTypeVariable._readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory FunctionTypeVariable._readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     int index = source.readInt();
     assert(0 <= index && index < functionTypeVariables.length);
     return functionTypeVariables[index];
@@ -458,7 +458,7 @@
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     int index = functionTypeVariables.indexOf(this);
     if (index == -1) {
       // TODO(johnniwinther): Avoid free variables.
@@ -498,14 +498,14 @@
 class NeverType extends DartType {
   const NeverType._();
 
-  factory NeverType._readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory NeverType._readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     return const NeverType._();
   }
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.neverType);
   }
 
@@ -526,13 +526,13 @@
 class VoidType extends DartType {
   const VoidType._();
 
-  factory VoidType._readFromDataSource(DataSource source,
+  factory VoidType._readFromDataSource(DataSourceReader source,
           List<FunctionTypeVariable> functionTypeVariables) =>
       const VoidType._();
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.voidType);
   }
 
@@ -553,13 +553,13 @@
 class DynamicType extends DartType {
   const DynamicType._();
 
-  factory DynamicType._readFromDataSource(DataSource source,
+  factory DynamicType._readFromDataSource(DataSourceReader source,
           List<FunctionTypeVariable> functionTypeVariables) =>
       const DynamicType._();
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.dynamicType);
   }
 
@@ -580,13 +580,13 @@
 class ErasedType extends DartType {
   const ErasedType._();
 
-  factory ErasedType._readFromDataSource(DataSource source,
+  factory ErasedType._readFromDataSource(DataSourceReader source,
           List<FunctionTypeVariable> functionTypeVariables) =>
       const ErasedType._();
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.erasedType);
   }
 
@@ -618,13 +618,13 @@
 class AnyType extends DartType {
   const AnyType._();
 
-  factory AnyType._readFromDataSource(DataSource source,
+  factory AnyType._readFromDataSource(DataSourceReader source,
           List<FunctionTypeVariable> functionTypeVariables) =>
       const AnyType._();
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.anyType);
   }
 
@@ -706,8 +706,8 @@
         typeVariables);
   }
 
-  factory FunctionType._readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory FunctionType._readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     int typeVariableCount = source.readInt();
     List<FunctionTypeVariable> typeVariables =
         List<FunctionTypeVariable>.generate(
@@ -745,7 +745,7 @@
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.functionType);
     functionTypeVariables = List<FunctionTypeVariable>.of(functionTypeVariables)
       ..addAll(typeVariables);
@@ -851,8 +851,8 @@
 
   const FutureOrType._(this.typeArgument);
 
-  factory FutureOrType._readFromDataSource(
-      DataSource source, List<FunctionTypeVariable> functionTypeVariables) {
+  factory FutureOrType._readFromDataSource(DataSourceReader source,
+      List<FunctionTypeVariable> functionTypeVariables) {
     DartType typeArgument =
         DartType.readFromDataSource(source, functionTypeVariables);
     return FutureOrType._(typeArgument);
@@ -860,7 +860,7 @@
 
   @override
   void writeToDataSink(
-      DataSink sink, List<FunctionTypeVariable> functionTypeVariables) {
+      DataSinkWriter sink, List<FunctionTypeVariable> functionTypeVariables) {
     sink.writeEnum(DartTypeKind.futureOr);
     typeArgument.writeToDataSink(sink, functionTypeVariables);
   }
diff --git a/pkg/compiler/lib/src/inferrer/abstract_value_domain.dart b/pkg/compiler/lib/src/inferrer/abstract_value_domain.dart
index 582d331..e6d05b1 100644
--- a/pkg/compiler/lib/src/inferrer/abstract_value_domain.dart
+++ b/pkg/compiler/lib/src/inferrer/abstract_value_domain.dart
@@ -632,8 +632,8 @@
   String getCompactText(AbstractValue value);
 
   /// Deserializes an [AbstractValue] for this domain from [source].
-  AbstractValue readAbstractValueFromDataSource(DataSource source);
+  AbstractValue readAbstractValueFromDataSource(DataSourceReader source);
 
   /// Serializes this [value] for this domain to [sink].
-  void writeAbstractValueToDataSink(DataSink sink, AbstractValue value);
+  void writeAbstractValueToDataSink(DataSinkWriter sink, AbstractValue value);
 }
diff --git a/pkg/compiler/lib/src/inferrer/inferrer_engine.dart b/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
index c56d855..3d9dd84 100644
--- a/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
+++ b/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
@@ -1354,7 +1354,7 @@
 
   /// Deserializes a [GlobalTypeInferenceElementData] object from [source].
   factory KernelGlobalTypeInferenceElementData.readFromDataSource(
-      DataSource source,
+      DataSourceReader source,
       ir.Member context,
       AbstractValueDomain abstractValueDomain) {
     return source.inMemberContext(context, () {
@@ -1381,7 +1381,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink, ir.Member context,
+  void writeToDataSink(DataSinkWriter sink, ir.Member context,
       AbstractValueDomain abstractValueDomain) {
     sink.inMemberContext(context, () {
       sink.begin(tag);
diff --git a/pkg/compiler/lib/src/inferrer/powersets/powersets.dart b/pkg/compiler/lib/src/inferrer/powersets/powersets.dart
index b4f6789..6314434 100644
--- a/pkg/compiler/lib/src/inferrer/powersets/powersets.dart
+++ b/pkg/compiler/lib/src/inferrer/powersets/powersets.dart
@@ -74,14 +74,14 @@
   //TODO(coam)
   @override
   void writeAbstractValueToDataSink(
-      DataSink sink, covariant PowersetValue value) {
+      DataSinkWriter sink, covariant PowersetValue value) {
     _abstractValueDomain.writeAbstractValueToDataSink(
         sink, value._abstractValue);
   }
 
   //TODO(coam)
   @override
-  AbstractValue readAbstractValueFromDataSource(DataSource source) {
+  AbstractValue readAbstractValueFromDataSource(DataSourceReader source) {
     int powersetBits = _powersetBitsDomain.powersetTop;
     AbstractValue abstractValue =
         _abstractValueDomain.readAbstractValueFromDataSource(source);
diff --git a/pkg/compiler/lib/src/inferrer/powersets/wrapped.dart b/pkg/compiler/lib/src/inferrer/powersets/wrapped.dart
index 7e21d25..35c2641 100644
--- a/pkg/compiler/lib/src/inferrer/powersets/wrapped.dart
+++ b/pkg/compiler/lib/src/inferrer/powersets/wrapped.dart
@@ -58,13 +58,13 @@
 
   @override
   void writeAbstractValueToDataSink(
-      DataSink sink, covariant WrappedAbstractValue value) {
+      DataSinkWriter sink, covariant WrappedAbstractValue value) {
     _abstractValueDomain.writeAbstractValueToDataSink(
         sink, value._abstractValue);
   }
 
   @override
-  AbstractValue readAbstractValueFromDataSource(DataSource source) =>
+  AbstractValue readAbstractValueFromDataSource(DataSourceReader source) =>
       WrappedAbstractValue(
           _abstractValueDomain.readAbstractValueFromDataSource(source));
 
diff --git a/pkg/compiler/lib/src/inferrer/trivial.dart b/pkg/compiler/lib/src/inferrer/trivial.dart
index 6ba231b..c81c91f 100644
--- a/pkg/compiler/lib/src/inferrer/trivial.dart
+++ b/pkg/compiler/lib/src/inferrer/trivial.dart
@@ -31,10 +31,10 @@
   AbstractValue get dynamicType => const TrivialAbstractValue();
 
   @override
-  void writeAbstractValueToDataSink(DataSink sink, AbstractValue value) {}
+  void writeAbstractValueToDataSink(DataSinkWriter sink, AbstractValue value) {}
 
   @override
-  AbstractValue readAbstractValueFromDataSource(DataSource source) =>
+  AbstractValue readAbstractValueFromDataSource(DataSourceReader source) =>
       const TrivialAbstractValue();
 
   @override
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/container_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/container_type_mask.dart
index ab14e11..a001c78 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/container_type_mask.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/container_type_mask.dart
@@ -32,7 +32,7 @@
 
   /// Deserializes a [ContainerTypeMask] object from [source].
   factory ContainerTypeMask.readFromDataSource(
-      DataSource source, CommonMasks domain) {
+      DataSourceReader source, CommonMasks domain) {
     source.begin(tag);
     TypeMask forwardTo = TypeMask.readFromDataSource(source, domain);
     ir.TreeNode allocationNode = source.readTreeNodeOrNull();
@@ -46,7 +46,7 @@
 
   /// Serializes this [ContainerTypeMask] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(TypeMaskKind.container);
     sink.begin(tag);
     forwardTo.writeToDataSink(sink);
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/dictionary_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/dictionary_type_mask.dart
index 00eece2..20adc15 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/dictionary_type_mask.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/dictionary_type_mask.dart
@@ -29,7 +29,7 @@
 
   /// Deserializes a [DictionaryTypeMask] object from [source].
   factory DictionaryTypeMask.readFromDataSource(
-      DataSource source, CommonMasks domain) {
+      DataSourceReader source, CommonMasks domain) {
     source.begin(tag);
     TypeMask forwardTo = TypeMask.readFromDataSource(source, domain);
     ir.TreeNode allocationNode = source.readTreeNodeOrNull();
@@ -45,7 +45,7 @@
 
   /// Serializes this [DictionaryTypeMask] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(TypeMaskKind.dictionary);
     sink.begin(tag);
     forwardTo.writeToDataSink(sink);
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart
index 321a8d7..d42d4bd 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart
@@ -123,7 +123,7 @@
 
   /// Deserializes a [FlatTypeMask] object from [source].
   factory FlatTypeMask.readFromDataSource(
-      DataSource source, CommonMasks domain) {
+      DataSourceReader source, CommonMasks domain) {
     source.begin(tag);
     ClassEntity base = source.readClassOrNull();
     int flags = source.readInt();
@@ -133,7 +133,7 @@
 
   /// Serializes this [FlatTypeMask] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(TypeMaskKind.flat);
     sink.begin(tag);
     sink.writeClassOrNull(base);
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/map_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/map_type_mask.dart
index 035fa9d..7232e60 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/map_type_mask.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/map_type_mask.dart
@@ -32,7 +32,7 @@
 
   /// Deserializes a [MapTypeMask] object from [source].
   factory MapTypeMask.readFromDataSource(
-      DataSource source, CommonMasks domain) {
+      DataSourceReader source, CommonMasks domain) {
     source.begin(tag);
     TypeMask forwardTo = TypeMask.readFromDataSource(source, domain);
     ir.TreeNode allocationNode = source.readTreeNodeOrNull();
@@ -46,7 +46,7 @@
 
   /// Serializes this [MapTypeMask] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(TypeMaskKind.map);
     sink.begin(tag);
     forwardTo.writeToDataSink(sink);
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/masks.dart b/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
index c6e534b..9de70a3 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
@@ -974,13 +974,14 @@
   }
 
   @override
-  TypeMask readAbstractValueFromDataSource(DataSource source) {
+  TypeMask readAbstractValueFromDataSource(DataSourceReader source) {
     return source
         .readCached<TypeMask>(() => TypeMask.readFromDataSource(source, this));
   }
 
   @override
-  void writeAbstractValueToDataSink(DataSink sink, covariant TypeMask value) {
+  void writeAbstractValueToDataSink(
+      DataSinkWriter sink, covariant TypeMask value) {
     sink.writeCached<TypeMask>(
         value, (TypeMask value) => value.writeToDataSink(sink));
   }
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/set_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/set_type_mask.dart
index bfa9098..ab01cc4 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/set_type_mask.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/set_type_mask.dart
@@ -29,7 +29,7 @@
 
   /// Deserializes a [SetTypeMask] object from [source].
   factory SetTypeMask.readFromDataSource(
-      DataSource source, CommonMasks domain) {
+      DataSourceReader source, CommonMasks domain) {
     source.begin(tag);
     TypeMask forwardTo = TypeMask.readFromDataSource(source, domain);
     ir.TreeNode allocationNode = source.readTreeNodeOrNull();
@@ -42,7 +42,7 @@
 
   /// Serializes this [SetTypeMask] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(TypeMaskKind.set);
     sink.begin(tag);
     forwardTo.writeToDataSink(sink);
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/type_mask.dart
index 4702bdf..7f8af43 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/type_mask.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/type_mask.dart
@@ -242,7 +242,8 @@
   }
 
   /// Deserializes a [TypeMask] object from [source].
-  factory TypeMask.readFromDataSource(DataSource source, CommonMasks domain) {
+  factory TypeMask.readFromDataSource(
+      DataSourceReader source, CommonMasks domain) {
     TypeMaskKind kind = source.readEnum(TypeMaskKind.values);
     switch (kind) {
       case TypeMaskKind.flat:
@@ -264,7 +265,7 @@
   }
 
   /// Serializes this [TypeMask] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   /// If [mask] is forwarding, returns the first non-forwarding [TypeMask] in
   /// [mask]'s forwarding chain.
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/union_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/union_type_mask.dart
index 3a647ea..c9abe7d 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/union_type_mask.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/union_type_mask.dart
@@ -39,7 +39,7 @@
 
   /// Deserializes a [UnionTypeMask] object from [source].
   factory UnionTypeMask.readFromDataSource(
-      DataSource source, CommonMasks domain) {
+      DataSourceReader source, CommonMasks domain) {
     source.begin(tag);
     List<FlatTypeMask> disjointMasks =
         source.readList(() => TypeMask.readFromDataSource(source, domain));
@@ -52,7 +52,7 @@
 
   /// Serializes this [UnionTypeMask] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(TypeMaskKind.union);
     sink.begin(tag);
     sink.writeList(
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/value_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/value_type_mask.dart
index 62b6747..61b43de 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/value_type_mask.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/value_type_mask.dart
@@ -17,7 +17,7 @@
 
   /// Deserializes a [ValueTypeMask] object from [source].
   factory ValueTypeMask.readFromDataSource(
-      DataSource source, CommonMasks domain) {
+      DataSourceReader source, CommonMasks domain) {
     source.begin(tag);
     TypeMask forwardTo = TypeMask.readFromDataSource(source, domain);
     ConstantValue constant = source.readConstant();
@@ -27,7 +27,7 @@
 
   /// Serializes this [ValueTypeMask] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(TypeMaskKind.value);
     sink.begin(tag);
     forwardTo.writeToDataSink(sink);
diff --git a/pkg/compiler/lib/src/inferrer/types.dart b/pkg/compiler/lib/src/inferrer/types.dart
index c72c1f5..bd2c38d 100644
--- a/pkg/compiler/lib/src/inferrer/types.dart
+++ b/pkg/compiler/lib/src/inferrer/types.dart
@@ -34,12 +34,14 @@
 /// based queries (the runtime value could be anything).
 abstract class GlobalTypeInferenceMemberResult {
   /// Deserializes a [GlobalTypeInferenceMemberResult] object from [source].
-  factory GlobalTypeInferenceMemberResult.readFromDataSource(DataSource source,
-          ir.Member context, AbstractValueDomain abstractValueDomain) =
+  factory GlobalTypeInferenceMemberResult.readFromDataSource(
+          DataSourceReader source,
+          ir.Member context,
+          AbstractValueDomain abstractValueDomain) =
       GlobalTypeInferenceMemberResultImpl.readFromDataSource;
 
   /// Serializes this [GlobalTypeInferenceMemberResult] to [sink].
-  void writeToDataSink(DataSink sink, ir.Member context,
+  void writeToDataSink(DataSinkWriter sink, ir.Member context,
       AbstractValueDomain abstractValueDomain);
 
   /// The inferred type when this result belongs to a field, null otherwise.
@@ -73,12 +75,14 @@
 /// a single element.
 abstract class GlobalTypeInferenceElementData {
   /// Deserializes a [GlobalTypeInferenceElementData] object from [source].
-  factory GlobalTypeInferenceElementData.readFromDataSource(DataSource source,
-          ir.Member context, AbstractValueDomain abstractValueDomain) =
+  factory GlobalTypeInferenceElementData.readFromDataSource(
+          DataSourceReader source,
+          ir.Member context,
+          AbstractValueDomain abstractValueDomain) =
       KernelGlobalTypeInferenceElementData.readFromDataSource;
 
   /// Serializes this [GlobalTypeInferenceElementData] to [sink].
-  void writeToDataSink(DataSink sink, ir.Member context,
+  void writeToDataSink(DataSinkWriter sink, ir.Member context,
       AbstractValueDomain abstractValueDomain);
 
   /// Compresses the inner representation by removing [AbstractValue] mappings
@@ -110,7 +114,7 @@
 abstract class GlobalTypeInferenceResults {
   /// Deserializes a [GlobalTypeInferenceResults] object from [source].
   factory GlobalTypeInferenceResults.readFromDataSource(
-      DataSource source,
+      DataSourceReader source,
       JsToElementMap elementMap,
       JClosedWorld closedWorld,
       GlobalLocalsMap globalLocalsMap,
@@ -124,7 +128,7 @@
   }
 
   /// Serializes this [GlobalTypeInferenceResults] to [sink].
-  void writeToDataSink(DataSink sink, JsToElementMap elementMap);
+  void writeToDataSink(DataSinkWriter sink, JsToElementMap elementMap);
 
   JClosedWorld get closedWorld;
 
@@ -239,7 +243,7 @@
         _trivialParameterResult = closedWorld.abstractValueDomain.dynamicType;
 
   factory GlobalTypeInferenceResultsImpl.readFromDataSource(
-      DataSource source,
+      DataSourceReader source,
       JsToElementMap elementMap,
       JClosedWorld closedWorld,
       GlobalLocalsMap globalLocalsMap,
@@ -275,7 +279,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink, JsToElementMap elementMap) {
+  void writeToDataSink(DataSinkWriter sink, JsToElementMap elementMap) {
     sink.writeBool(false); // Is _not_ trivial.
     sink.begin(tag);
     sink.writeMemberMap(
@@ -436,7 +440,7 @@
       {this.throwsAlways, this.isCalledOnce});
 
   factory GlobalTypeInferenceMemberResultImpl.readFromDataSource(
-      DataSource source,
+      DataSourceReader source,
       ir.Member context,
       AbstractValueDomain abstractValueDomain) {
     source.begin(tag);
@@ -456,7 +460,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink, ir.Member context,
+  void writeToDataSink(DataSinkWriter sink, ir.Member context,
       AbstractValueDomain abstractValueDomain) {
     sink.begin(tag);
     sink.writeValueOrNull(_data, (GlobalTypeInferenceElementData data) {
@@ -497,7 +501,7 @@
         _trivialParameterResult = closedWorld.abstractValueDomain.dynamicType;
 
   @override
-  void writeToDataSink(DataSink sink, JsToElementMap elementMap) {
+  void writeToDataSink(DataSinkWriter sink, JsToElementMap elementMap) {
     sink.writeBool(true); // Is trivial.
   }
 
@@ -557,7 +561,7 @@
   bool get isCalledOnce => false;
 
   @override
-  void writeToDataSink(DataSink sink, ir.Member context,
+  void writeToDataSink(DataSinkWriter sink, ir.Member context,
       AbstractValueDomain abstractValueDomain) {
     throw UnsupportedError(
         "TrivialGlobalTypeInferenceMemberResult.writeToDataSink");
@@ -598,7 +602,7 @@
   bool get isCalledOnce => false;
 
   @override
-  void writeToDataSink(DataSink sink, ir.Member context,
+  void writeToDataSink(DataSinkWriter sink, ir.Member context,
       AbstractValueDomain abstractValueDomain) {
     throw UnsupportedError(
         "DeadFieldGlobalTypeInferenceResult.writeToDataSink");
@@ -639,7 +643,7 @@
   bool get isCalledOnce => false;
 
   @override
-  void writeToDataSink(DataSink sink, ir.Member context,
+  void writeToDataSink(DataSinkWriter sink, ir.Member context,
       AbstractValueDomain abstractValueDomain) {
     throw UnsupportedError(
         "DeadFieldGlobalTypeInferenceResult.writeToDataSink");
diff --git a/pkg/compiler/lib/src/io/position_information.dart b/pkg/compiler/lib/src/io/position_information.dart
index b3195a7..5844712 100644
--- a/pkg/compiler/lib/src/io/position_information.dart
+++ b/pkg/compiler/lib/src/io/position_information.dart
@@ -33,7 +33,8 @@
   PositionSourceInformation(
       this.startPosition, this.innerPosition, this.inliningContext);
 
-  factory PositionSourceInformation.readFromDataSource(DataSource source) {
+  factory PositionSourceInformation.readFromDataSource(
+      DataSourceReader source) {
     source.begin(tag);
     SourceLocation startPosition = source.readCached<SourceLocation>(
         () => SourceLocation.readFromDataSource(source));
@@ -47,7 +48,7 @@
         startPosition, innerPosition, inliningContext);
   }
 
-  void writeToDataSinkInternal(DataSink sink) {
+  void writeToDataSinkInternal(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeCached(
         startPosition,
diff --git a/pkg/compiler/lib/src/io/source_information.dart b/pkg/compiler/lib/src/io/source_information.dart
index d31486b..9098af0 100644
--- a/pkg/compiler/lib/src/io/source_information.dart
+++ b/pkg/compiler/lib/src/io/source_information.dart
@@ -18,7 +18,7 @@
 abstract class SourceInformation extends JavaScriptNodeSourceInformation {
   const SourceInformation();
 
-  static SourceInformation readFromDataSource(DataSource source) {
+  static SourceInformation readFromDataSource(DataSourceReader source) {
     int hasSourceInformation = source.readInt();
     if (hasSourceInformation == 0) {
       return null;
@@ -31,7 +31,7 @@
   }
 
   static void writeToDataSink(
-      DataSink sink, SourceInformation sourceInformation) {
+      DataSinkWriter sink, SourceInformation sourceInformation) {
     if (sourceInformation == null) {
       sink.writeInt(0);
     } else if (sourceInformation is SourceMappedMarker) {
@@ -82,7 +82,7 @@
 
   FrameContext(this.callInformation, this.inlinedMethodName);
 
-  factory FrameContext.readFromDataSource(DataSource source) {
+  factory FrameContext.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     SourceInformation callInformation = source.readCached<SourceInformation>(
         () => SourceInformation.readFromDataSource(source));
@@ -91,7 +91,7 @@
     return FrameContext(callInformation, inlinedMethodName);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeCached<SourceInformation>(
         callInformation,
@@ -273,7 +273,7 @@
   /// The name associated with this source location, if any.
   String get sourceName;
 
-  static SourceLocation readFromDataSource(DataSource source) {
+  static SourceLocation readFromDataSource(DataSourceReader source) {
     int hasSourceLocation = source.readInt();
     if (hasSourceLocation == 0) {
       return null;
@@ -292,7 +292,8 @@
     }
   }
 
-  static void writeToDataSink(DataSink sink, SourceLocation sourceLocation) {
+  static void writeToDataSink(
+      DataSinkWriter sink, SourceLocation sourceLocation) {
     if (sourceLocation == null) {
       sink.writeInt(0);
     } else if (sourceLocation is NoSourceLocationMarker) {
diff --git a/pkg/compiler/lib/src/ir/impact.dart b/pkg/compiler/lib/src/ir/impact.dart
index c72bbde..c68ffeb 100644
--- a/pkg/compiler/lib/src/ir/impact.dart
+++ b/pkg/compiler/lib/src/ir/impact.dart
@@ -699,7 +699,7 @@
   ImpactBuilderData(this.node, this.impactData, this.typeMapsForTesting,
       this.cachedStaticTypes);
 
-  factory ImpactBuilderData.fromDataSource(DataSource source) {
+  factory ImpactBuilderData.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     var node = source.readMemberNode();
     var data = ImpactData.fromDataSource(source);
@@ -708,7 +708,7 @@
     return ImpactBuilderData(node, data, const {}, cache);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberNode(node);
     impactData.toDataSink(sink);
diff --git a/pkg/compiler/lib/src/ir/impact_data.dart b/pkg/compiler/lib/src/ir/impact_data.dart
index 34f94bd..eb3f407 100644
--- a/pkg/compiler/lib/src/ir/impact_data.dart
+++ b/pkg/compiler/lib/src/ir/impact_data.dart
@@ -530,7 +530,7 @@
 
   ImpactData();
 
-  ImpactData.fromDataSource(DataSource source) {
+  ImpactData.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     _superInitializers = source.readList(
         () => _SuperInitializer.fromDataSource(source),
@@ -628,7 +628,7 @@
     source.end(tag);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
 
     sink.writeList(
@@ -1065,7 +1065,7 @@
         typeArguments, positionalArguments, namedArguments);
   }
 
-  factory _CallStructure.fromDataSource(DataSource source) {
+  factory _CallStructure.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     List<ir.DartType> typeArguments = source.readDartTypeNodes();
     int positionalArguments = source.readInt();
@@ -1075,7 +1075,7 @@
         typeArguments, positionalArguments, namedArguments);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNodes(typeArguments);
     sink.writeInt(positionalArguments);
@@ -1093,7 +1093,7 @@
 
   _SuperInitializer(this.source, this.target, this.callStructure);
 
-  factory _SuperInitializer.fromDataSource(DataSource source) {
+  factory _SuperInitializer.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Constructor sourceConstructor = source.readMemberNode();
     ir.Constructor targetConstructor = source.readMemberNode();
@@ -1103,7 +1103,7 @@
         sourceConstructor, targetConstructor, callStructure);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberNode(source);
     sink.writeMemberNode(target);
@@ -1120,7 +1120,7 @@
 
   _SuperInvocation(this.target, this.callStructure);
 
-  factory _SuperInvocation.fromDataSource(DataSource source) {
+  factory _SuperInvocation.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Member member = source.readMemberNode();
     _CallStructure callStructure = _CallStructure.fromDataSource(source);
@@ -1128,7 +1128,7 @@
     return _SuperInvocation(member, callStructure);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberNode(target);
     callStructure.toDataSink(sink);
@@ -1145,7 +1145,7 @@
 
   _InstanceAccess(this.receiverType, this.classRelation, this.target);
 
-  factory _InstanceAccess.fromDataSource(DataSource source) {
+  factory _InstanceAccess.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType receiverType = source.readDartTypeNode();
     ClassRelation classRelation = source.readEnum(ClassRelation.values);
@@ -1154,7 +1154,7 @@
     return _InstanceAccess(receiverType, classRelation, target);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(receiverType);
     sink.writeEnum(classRelation);
@@ -1172,7 +1172,7 @@
 
   _DynamicAccess(this.receiverType, this.classRelation, this.name);
 
-  factory _DynamicAccess.fromDataSource(DataSource source) {
+  factory _DynamicAccess.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType receiverType = source.readDartTypeNode();
     ClassRelation classRelation = source.readEnum(ClassRelation.values);
@@ -1181,7 +1181,7 @@
     return _DynamicAccess(receiverType, classRelation, name);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(receiverType);
     sink.writeEnum(classRelation);
@@ -1198,7 +1198,7 @@
 
   _FunctionInvocation(this.receiverType, this.callStructure);
 
-  factory _FunctionInvocation.fromDataSource(DataSource source) {
+  factory _FunctionInvocation.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType receiverType = source.readDartTypeNode();
     _CallStructure callStructure = _CallStructure.fromDataSource(source);
@@ -1206,7 +1206,7 @@
     return _FunctionInvocation(receiverType, callStructure);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(receiverType);
     callStructure.toDataSink(sink);
@@ -1225,7 +1225,7 @@
   _InstanceInvocation(
       this.receiverType, this.classRelation, this.target, this.callStructure);
 
-  factory _InstanceInvocation.fromDataSource(DataSource source) {
+  factory _InstanceInvocation.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType receiverType = source.readDartTypeNode();
     ClassRelation classRelation = source.readEnum(ClassRelation.values);
@@ -1236,7 +1236,7 @@
         receiverType, classRelation, target, callStructure);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(receiverType);
     sink.writeEnum(classRelation);
@@ -1257,7 +1257,7 @@
   _DynamicInvocation(
       this.receiverType, this.classRelation, this.name, this.callStructure);
 
-  factory _DynamicInvocation.fromDataSource(DataSource source) {
+  factory _DynamicInvocation.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType receiverType = source.readDartTypeNode();
     ClassRelation classRelation = source.readEnum(ClassRelation.values);
@@ -1267,7 +1267,7 @@
     return _DynamicInvocation(receiverType, classRelation, name, callStructure);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(receiverType);
     sink.writeEnum(classRelation);
@@ -1285,7 +1285,7 @@
 
   _LocalFunctionInvocation(this.localFunction, this.callStructure);
 
-  factory _LocalFunctionInvocation.fromDataSource(DataSource source) {
+  factory _LocalFunctionInvocation.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.FunctionDeclaration localFunction = source.readTreeNode();
     _CallStructure callStructure = _CallStructure.fromDataSource(source);
@@ -1293,7 +1293,7 @@
     return _LocalFunctionInvocation(localFunction, callStructure);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeTreeNode(localFunction);
     callStructure.toDataSink(sink);
@@ -1310,7 +1310,7 @@
 
   _StaticInvocation(this.target, this.callStructure, this.import);
 
-  factory _StaticInvocation.fromDataSource(DataSource source) {
+  factory _StaticInvocation.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Procedure target = source.readMemberNode();
     _CallStructure callStructure = _CallStructure.fromDataSource(source);
@@ -1319,7 +1319,7 @@
     return _StaticInvocation(target, callStructure, import);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberNode(target);
     callStructure.toDataSink(sink);
@@ -1341,7 +1341,7 @@
       this.constructor, this.type, this.callStructure, this.import,
       {this.isConst});
 
-  factory _ConstructorInvocation.fromDataSource(DataSource source) {
+  factory _ConstructorInvocation.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Member constructor = source.readMemberNode();
     ir.InterfaceType type = source.readDartTypeNode();
@@ -1353,7 +1353,7 @@
         isConst: isConst);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberNode(constructor);
     sink.writeDartTypeNode(type);
@@ -1393,7 +1393,7 @@
 
   _TypeUse(this.type, this.kind);
 
-  factory _TypeUse.fromDataSource(DataSource source) {
+  factory _TypeUse.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType type = source.readDartTypeNode();
     _TypeUseKind kind = source.readEnum(_TypeUseKind.values);
@@ -1401,7 +1401,7 @@
     return _TypeUse(type, kind);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(type);
     sink.writeEnum(kind);
@@ -1428,7 +1428,7 @@
 
   _RedirectingInitializer(this.constructor, this.callStructure);
 
-  factory _RedirectingInitializer.fromDataSource(DataSource source) {
+  factory _RedirectingInitializer.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Constructor constructor = source.readMemberNode();
     _CallStructure callStructure = _CallStructure.fromDataSource(source);
@@ -1436,7 +1436,7 @@
     return _RedirectingInitializer(constructor, callStructure);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberNode(constructor);
     callStructure.toDataSink(sink);
@@ -1452,7 +1452,7 @@
 
   _TypeLiteral(this.type, this.import);
 
-  factory _TypeLiteral.fromDataSource(DataSource source) {
+  factory _TypeLiteral.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType type = source.readDartTypeNode();
     ir.LibraryDependency import = source.readLibraryDependencyNodeOrNull();
@@ -1460,7 +1460,7 @@
     return _TypeLiteral(type, import);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(type);
     sink.writeLibraryDependencyNodeOrNull(import);
@@ -1476,7 +1476,7 @@
 
   _GenericInstantiation(this.expressionType, this.typeArguments);
 
-  factory _GenericInstantiation.fromDataSource(DataSource source) {
+  factory _GenericInstantiation.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.FunctionType expressionType = source.readDartTypeNode();
     List<ir.DartType> typeArguments = source.readDartTypeNodes();
@@ -1484,7 +1484,7 @@
     return _GenericInstantiation(expressionType, typeArguments);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(expressionType);
     sink.writeDartTypeNodes(typeArguments);
@@ -1500,7 +1500,7 @@
 
   _StaticAccess(this.target, this.import);
 
-  factory _StaticAccess.fromDataSource(DataSource source) {
+  factory _StaticAccess.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Member target = source.readMemberNode();
     ir.LibraryDependency import = source.readLibraryDependencyNodeOrNull();
@@ -1508,7 +1508,7 @@
     return _StaticAccess(target, import);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberNode(target);
     sink.writeLibraryDependencyNodeOrNull(import);
@@ -1526,7 +1526,7 @@
 
   _MapLiteral(this.keyType, this.valueType, {this.isConst, this.isEmpty});
 
-  factory _MapLiteral.fromDataSource(DataSource source) {
+  factory _MapLiteral.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType keyType = source.readDartTypeNode();
     ir.DartType valueType = source.readDartTypeNode();
@@ -1536,7 +1536,7 @@
     return _MapLiteral(keyType, valueType, isConst: isConst, isEmpty: isEmpty);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(keyType);
     sink.writeDartTypeNode(valueType);
@@ -1555,7 +1555,7 @@
 
   _ContainerLiteral(this.elementType, {this.isConst, this.isEmpty});
 
-  factory _ContainerLiteral.fromDataSource(DataSource source) {
+  factory _ContainerLiteral.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.DartType elementType = source.readDartTypeNode();
     bool isConst = source.readBool();
@@ -1564,7 +1564,7 @@
     return _ContainerLiteral(elementType, isConst: isConst, isEmpty: isEmpty);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartTypeNode(elementType);
     sink.writeBool(isConst);
@@ -1585,7 +1585,7 @@
 
   _RuntimeTypeUse(this.node, this.kind, this.receiverType, this.argumentType);
 
-  factory _RuntimeTypeUse.fromDataSource(DataSource source) {
+  factory _RuntimeTypeUse.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.TreeNode node = source.readTreeNode();
     RuntimeTypeUseKind kind = source.readEnum(RuntimeTypeUseKind.values);
@@ -1595,7 +1595,7 @@
     return _RuntimeTypeUse(node, kind, receiverType, argumentType);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeTreeNode(node);
     sink.writeEnum(kind);
diff --git a/pkg/compiler/lib/src/ir/modular.dart b/pkg/compiler/lib/src/ir/modular.dart
index bdb89a3..24afe70 100644
--- a/pkg/compiler/lib/src/ir/modular.dart
+++ b/pkg/compiler/lib/src/ir/modular.dart
@@ -54,7 +54,7 @@
 
   ModuleData(this.impactData);
 
-  factory ModuleData.fromDataSource(DataSource source) {
+  factory ModuleData.fromDataSource(DataSourceReader source) {
     source.begin(tag);
     var impactData = source
         .readMemberNodeMap(() => ImpactBuilderData.fromDataSource(source));
@@ -62,7 +62,7 @@
     return ModuleData(impactData);
   }
 
-  void toDataSink(DataSink sink) {
+  void toDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberNodeMap<ImpactBuilderData>(
         impactData, (e) => e.toDataSink(sink));
diff --git a/pkg/compiler/lib/src/ir/static_type_cache.dart b/pkg/compiler/lib/src/ir/static_type_cache.dart
index 59f2d66..f389c80 100644
--- a/pkg/compiler/lib/src/ir/static_type_cache.dart
+++ b/pkg/compiler/lib/src/ir/static_type_cache.dart
@@ -16,7 +16,7 @@
       [this._expressionTypes = const {}, this._forInIteratorTypes]);
 
   factory StaticTypeCache.readFromDataSource(
-      DataSource source, ir.Member context) {
+      DataSourceReader source, ir.Member context) {
     return source.inMemberContext(context, () {
       source.begin(tag);
       Map<ir.Expression, ir.DartType> expressionTypes =
@@ -28,7 +28,7 @@
     });
   }
 
-  void writeToDataSink(DataSink sink, ir.Member context) {
+  void writeToDataSink(DataSinkWriter sink, ir.Member context) {
     sink.inMemberContext(context, () {
       sink.begin(tag);
       sink.writeTreeNodeMapInContext(_expressionTypes, sink.writeDartTypeNode);
diff --git a/pkg/compiler/lib/src/js_backend/annotations.dart b/pkg/compiler/lib/src/js_backend/annotations.dart
index cf4c049..6994be7 100644
--- a/pkg/compiler/lib/src/js_backend/annotations.dart
+++ b/pkg/compiler/lib/src/js_backend/annotations.dart
@@ -256,11 +256,11 @@
 abstract class AnnotationsData {
   /// Deserializes a [AnnotationsData] object from [source].
   factory AnnotationsData.readFromDataSource(
-          CompilerOptions options, DataSource source) =
+          CompilerOptions options, DataSourceReader source) =
       AnnotationsDataImpl.readFromDataSource;
 
   /// Serializes this [AnnotationsData] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   /// Returns `true` if [member] has an `@pragma('dart2js:assumeDynamic')`
   /// annotation.
@@ -356,7 +356,7 @@
             options.defaultIndexBoundsCheckPolicy;
 
   factory AnnotationsDataImpl.readFromDataSource(
-      CompilerOptions options, DataSource source) {
+      CompilerOptions options, DataSourceReader source) {
     source.begin(tag);
     Map<MemberEntity, EnumSet<PragmaAnnotation>> pragmaAnnotations =
         source.readMemberMap(
@@ -366,7 +366,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberMap(pragmaAnnotations,
         (MemberEntity member, EnumSet<PragmaAnnotation> set) {
diff --git a/pkg/compiler/lib/src/js_backend/backend_usage.dart b/pkg/compiler/lib/src/js_backend/backend_usage.dart
index 08f17ce..600075d 100644
--- a/pkg/compiler/lib/src/js_backend/backend_usage.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_usage.dart
@@ -15,11 +15,11 @@
 
 abstract class BackendUsage {
   /// Deserializes a [BackendUsage] object from [source].
-  factory BackendUsage.readFromDataSource(DataSource source) =
+  factory BackendUsage.readFromDataSource(DataSourceReader source) =
       BackendUsageImpl.readFromDataSource;
 
   /// Serializes this [BackendUsage] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   bool needToInitializeIsolateAffinityTag;
   bool needToInitializeDispatchProperty;
@@ -356,7 +356,7 @@
         this._helperClassesUsed = helperClassesUsed,
         this._runtimeTypeUses = runtimeTypeUses;
 
-  factory BackendUsageImpl.readFromDataSource(DataSource source) {
+  factory BackendUsageImpl.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Set<FunctionEntity> globalFunctionDependencies =
         source.readMembers<FunctionEntity>().toSet();
@@ -396,7 +396,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMembers(_globalFunctionDependencies);
     sink.writeClasses(_globalClassDependencies);
diff --git a/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart b/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart
index e038554..22329a2 100644
--- a/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart
+++ b/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart
@@ -56,7 +56,7 @@
         DeferredHolderExpressionKind.globalObjectForStaticState, null);
   }
 
-  factory DeferredHolderExpression.readFromDataSource(DataSource source) {
+  factory DeferredHolderExpression.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     var kind = source.readEnum(DeferredHolderExpressionKind.values);
     Object data;
@@ -79,7 +79,7 @@
     return DeferredHolderExpression(kind, data);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeEnum(kind);
     switch (kind) {
diff --git a/pkg/compiler/lib/src/js_backend/field_analysis.dart b/pkg/compiler/lib/src/js_backend/field_analysis.dart
index 0f3326c..96c5bf9 100644
--- a/pkg/compiler/lib/src/js_backend/field_analysis.dart
+++ b/pkg/compiler/lib/src/js_backend/field_analysis.dart
@@ -252,7 +252,7 @@
 
   /// Deserializes a [JFieldAnalysis] object from [source].
   factory JFieldAnalysis.readFromDataSource(
-      DataSource source, CompilerOptions options) {
+      DataSourceReader source, CompilerOptions options) {
     source.begin(tag);
     Map<FieldEntity, FieldAnalysisData> fieldData = source.readMemberMap(
         (MemberEntity member) => FieldAnalysisData.fromDataSource(source));
@@ -261,7 +261,7 @@
   }
 
   /// Serializes this [JFieldAnalysis] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberMap(
         _fieldData,
@@ -602,7 +602,7 @@
       this.eagerCreationIndex = null,
       this.eagerFieldDependenciesForTesting = null});
 
-  factory FieldAnalysisData.fromDataSource(DataSource source) {
+  factory FieldAnalysisData.fromDataSource(DataSourceReader source) {
     source.begin(tag);
 
     ConstantValue initialValue = source.readConstantOrNull();
@@ -624,7 +624,7 @@
         eagerFieldDependenciesForTesting: eagerFieldDependencies);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeConstantOrNull(initialValue);
     sink.writeBool(isInitializedInAllocator);
diff --git a/pkg/compiler/lib/src/js_backend/inferred_data.dart b/pkg/compiler/lib/src/js_backend/inferred_data.dart
index 3dc454a..bf12d8c 100644
--- a/pkg/compiler/lib/src/js_backend/inferred_data.dart
+++ b/pkg/compiler/lib/src/js_backend/inferred_data.dart
@@ -16,7 +16,7 @@
 abstract class InferredData {
   /// Deserializes a [InferredData] object from [source].
   factory InferredData.readFromDataSource(
-      DataSource source, JClosedWorld closedWorld) {
+      DataSourceReader source, JClosedWorld closedWorld) {
     bool isTrivial = source.readBool();
     if (isTrivial) {
       return TrivialInferredData();
@@ -26,7 +26,7 @@
   }
 
   /// Serializes this [InferredData] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   /// Returns the side effects of executing [element].
   SideEffects getSideEffectsOfElement(FunctionEntity element);
@@ -100,7 +100,7 @@
       this._functionsThatMightBePassedToApply);
 
   factory InferredDataImpl.readFromDataSource(
-      DataSource source, JClosedWorld closedWorld) {
+      DataSourceReader source, JClosedWorld closedWorld) {
     source.begin(tag);
     Set<MemberEntity> functionsCalledInLoop = source.readMembers().toSet();
     Map<FunctionEntity, SideEffects> sideEffects = source.readMemberMap(
@@ -122,7 +122,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeBool(false); // Is _not_ trivial.
     sink.begin(tag);
     sink.writeMembers(_functionsCalledInLoop);
@@ -302,7 +302,7 @@
   final SideEffects _allSideEffects = SideEffects();
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeBool(true); // Is trivial.
   }
 
diff --git a/pkg/compiler/lib/src/js_backend/interceptor_data.dart b/pkg/compiler/lib/src/js_backend/interceptor_data.dart
index 0300e2d..36052c1 100644
--- a/pkg/compiler/lib/src/js_backend/interceptor_data.dart
+++ b/pkg/compiler/lib/src/js_backend/interceptor_data.dart
@@ -21,12 +21,12 @@
 abstract class InterceptorData {
   /// Deserializes a [InterceptorData] object from [source].
   factory InterceptorData.readFromDataSource(
-      DataSource source,
+      DataSourceReader source,
       NativeData nativeData,
       CommonElements commonElements) = InterceptorDataImpl.readFromDataSource;
 
   /// Serializes this [InterceptorData] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   /// Returns `true` if [cls] is an intercepted class.
   bool isInterceptedClass(ClassEntity element);
@@ -110,8 +110,8 @@
       this.interceptedClasses,
       this.classesMixedIntoInterceptedClasses);
 
-  factory InterceptorDataImpl.readFromDataSource(
-      DataSource source, NativeData nativeData, CommonElements commonElements) {
+  factory InterceptorDataImpl.readFromDataSource(DataSourceReader source,
+      NativeData nativeData, CommonElements commonElements) {
     source.begin(tag);
     int interceptedMembersCount = source.readInt();
     Map<String, Set<MemberEntity>> interceptedMembers = {};
@@ -129,7 +129,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeInt(interceptedMembers.length);
     interceptedMembers.forEach((String name, Set<MemberEntity> members) {
diff --git a/pkg/compiler/lib/src/js_backend/native_data.dart b/pkg/compiler/lib/src/js_backend/native_data.dart
index 00ee207..6bbf4ea 100644
--- a/pkg/compiler/lib/src/js_backend/native_data.dart
+++ b/pkg/compiler/lib/src/js_backend/native_data.dart
@@ -200,7 +200,7 @@
 
   /// Deserializes a [NativeBasicData] object from [source].
   factory NativeBasicData.readFromDataSource(
-      DataSource source, ElementEnvironment elementEnvironment) {
+      DataSourceReader source, ElementEnvironment elementEnvironment) {
     source.begin(tag);
     bool isAllowInteropUsed = source.readBool();
     Map<ClassEntity, NativeClassTag> nativeClassTagInfo =
@@ -228,7 +228,7 @@
   }
 
   /// Serializes this [NativeBasicData] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeBool(isAllowInteropUsed);
     sink.writeClassMap(_nativeClassTagInfo, (NativeClassTag tag) {
@@ -484,7 +484,7 @@
 
   /// Deserializes a [NativeData] object from [source].
   factory NativeData.readFromDataSource(
-      DataSource source, ElementEnvironment elementEnvironment) {
+      DataSourceReader source, ElementEnvironment elementEnvironment) {
     source.begin(tag);
     NativeBasicData nativeBasicData =
         NativeBasicData.readFromDataSource(source, elementEnvironment);
@@ -506,7 +506,7 @@
 
   /// Serializes this [NativeData] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     _nativeBasicData.writeToDataSink(sink);
 
diff --git a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
index 8c957ec..f9c2749 100644
--- a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
+++ b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
@@ -190,7 +190,7 @@
       this._throwingImpls, this._otherImpls, this._forwardingSyntaxImpls);
 
   /// Deserializes a [NoSuchMethodData] object from [source].
-  factory NoSuchMethodData.readFromDataSource(DataSource source) {
+  factory NoSuchMethodData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Set<FunctionEntity> throwingImpls =
         source.readMembers<FunctionEntity>().toSet();
@@ -209,7 +209,7 @@
   }
 
   /// Serializes this [NoSuchMethodData] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMembers(_throwingImpls);
     sink.writeMembers(_otherImpls);
diff --git a/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart b/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart
index 5bf8933..c53fa5f 100644
--- a/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart
+++ b/pkg/compiler/lib/src/js_backend/runtime_types_resolution.dart
@@ -660,7 +660,7 @@
 abstract class RuntimeTypesNeed {
   /// Deserializes a [RuntimeTypesNeed] object from [source].
   factory RuntimeTypesNeed.readFromDataSource(
-      DataSource source, ElementEnvironment elementEnvironment) {
+      DataSourceReader source, ElementEnvironment elementEnvironment) {
     bool isTrivial = source.readBool();
     if (isTrivial) {
       return TrivialRuntimeTypesNeed(elementEnvironment);
@@ -669,7 +669,7 @@
   }
 
   /// Serializes this [RuntimeTypesNeed] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   /// Returns `true` if [cls] needs type arguments at runtime.
   ///
@@ -742,7 +742,7 @@
   const TrivialRuntimeTypesNeed(this._elementEnvironment);
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeBool(true); // Is trivial.
   }
 
@@ -797,7 +797,7 @@
       this.instantiationsNeedingTypeArguments);
 
   factory RuntimeTypesNeedImpl.readFromDataSource(
-      DataSource source, ElementEnvironment elementEnvironment) {
+      DataSourceReader source, ElementEnvironment elementEnvironment) {
     source.begin(tag);
     Set<ClassEntity> classesNeedingTypeArguments =
         source.readClasses<ClassEntity>().toSet();
@@ -822,7 +822,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeBool(false); // Is _not_ trivial.
     sink.begin(tag);
     sink.writeClasses(classesNeedingTypeArguments);
diff --git a/pkg/compiler/lib/src/js_backend/string_reference.dart b/pkg/compiler/lib/src/js_backend/string_reference.dart
index 19aba0e..06d7370 100644
--- a/pkg/compiler/lib/src/js_backend/string_reference.dart
+++ b/pkg/compiler/lib/src/js_backend/string_reference.dart
@@ -101,14 +101,14 @@
   StringReference(this.constant) : sourceInformation = null;
   StringReference._(this.constant, this._value, this.sourceInformation);
 
-  factory StringReference.readFromDataSource(DataSource source) {
+  factory StringReference.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     StringConstantValue constant = source.readConstant() as StringConstantValue;
     source.end(tag);
     return StringReference(constant);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeConstant(constant);
     sink.end(tag);
diff --git a/pkg/compiler/lib/src/js_backend/type_reference.dart b/pkg/compiler/lib/src/js_backend/type_reference.dart
index d796de1..b603532 100644
--- a/pkg/compiler/lib/src/js_backend/type_reference.dart
+++ b/pkg/compiler/lib/src/js_backend/type_reference.dart
@@ -117,7 +117,7 @@
   TypeReference(this.typeRecipe) : sourceInformation = null;
   TypeReference._(this.typeRecipe, this._value, this.sourceInformation);
 
-  factory TypeReference.readFromDataSource(DataSource source) {
+  factory TypeReference.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     TypeRecipe recipe = source.readTypeRecipe();
     bool forLazyInitializer = source.readBool();
@@ -125,7 +125,7 @@
     return TypeReference(recipe)..forLazyInitializer = forLazyInitializer;
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeTypeRecipe(typeRecipe);
     sink.writeBool(forLazyInitializer);
diff --git a/pkg/compiler/lib/src/js_model/closure.dart b/pkg/compiler/lib/src/js_model/closure.dart
index 7aa5677..62b1101 100644
--- a/pkg/compiler/lib/src/js_model/closure.dart
+++ b/pkg/compiler/lib/src/js_model/closure.dart
@@ -51,7 +51,7 @@
 
   /// Deserializes a [ClosureData] object from [source].
   factory ClosureDataImpl.readFromDataSource(
-      JsToElementMap elementMap, DataSource source) {
+      JsToElementMap elementMap, DataSourceReader source) {
     source.begin(tag);
     // TODO(johnniwinther): Support shared [ScopeInfo].
     Map<MemberEntity, ScopeInfo> scopeMap = source.readMemberMap(
@@ -78,7 +78,7 @@
 
   /// Serializes this [ClosureData] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMemberMap(_scopeMap,
         (MemberEntity member, ScopeInfo info) => info.writeToDataSink(sink));
@@ -507,7 +507,7 @@
     return _boxedVariablesCache.containsKey(variable);
   }
 
-  factory JsScopeInfo.readFromDataSource(DataSource source) {
+  factory JsScopeInfo.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Iterable<ir.VariableDeclaration> localsUsedInTryOrSync =
         source.readTreeNodes<ir.VariableDeclaration>();
@@ -522,7 +522,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(ScopeInfoKind.scopeInfo);
     sink.begin(tag);
     sink.writeTreeNodes(_localsUsedInTryOrSync);
@@ -556,7 +556,7 @@
   @override
   bool get requiresContextBox => _boxedVariables.isNotEmpty;
 
-  factory JsCapturedScope.readFromDataSource(DataSource source) {
+  factory JsCapturedScope.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Iterable<ir.VariableDeclaration> localsUsedInTryOrSync =
         source.readTreeNodes<ir.VariableDeclaration>();
@@ -571,7 +571,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(ScopeInfoKind.capturedScope);
     sink.begin(tag);
     sink.writeTreeNodes(_localsUsedInTryOrSync);
@@ -608,7 +608,7 @@
   @override
   bool get hasBoxedLoopVariables => _boxedLoopVariables.isNotEmpty;
 
-  factory JsCapturedLoopScope.readFromDataSource(DataSource source) {
+  factory JsCapturedLoopScope.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Iterable<ir.VariableDeclaration> localsUsedInTryOrSync =
         source.readTreeNodes<ir.VariableDeclaration>();
@@ -625,7 +625,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(ScopeInfoKind.capturedLoopScope);
     sink.begin(tag);
     sink.writeTreeNodes(_localsUsedInTryOrSync);
@@ -705,7 +705,7 @@
         _localToFieldMap = {},
         super.from(boxedVariables, info, enclosingClass);
 
-  factory JsClosureClassInfo.readFromDataSource(DataSource source) {
+  factory JsClosureClassInfo.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Iterable<ir.VariableDeclaration> localsUsedInTryOrSync =
         source.readTreeNodes<ir.VariableDeclaration>();
@@ -743,7 +743,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(ScopeInfoKind.closureRepresentationInfo);
     sink.begin(tag);
     sink.writeTreeNodes(_localsUsedInTryOrSync);
@@ -855,7 +855,7 @@
   JClosureClass(JLibrary library, String name)
       : super(library, name, isAbstract: false);
 
-  factory JClosureClass.readFromDataSource(DataSource source) {
+  factory JClosureClass.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JLibrary library = source.readLibrary();
     String name = source.readString();
@@ -864,7 +864,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassKind.closure);
     sink.begin(tag);
     sink.writeLibrary(library);
@@ -926,7 +926,7 @@
       : super(library, enclosingClass, memberName,
             isAssignable: isAssignable, isConst: isConst, isStatic: false);
 
-  factory JClosureField.readFromDataSource(DataSource source) {
+  factory JClosureField.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JClass cls = source.readClass();
     String name = source.readString();
@@ -940,7 +940,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.closureField);
     sink.begin(tag);
     sink.writeClass(enclosingClass);
@@ -975,7 +975,7 @@
   RecordClassData(
       this.definition, this.thisType, this.supertype, this.orderedTypeSet);
 
-  factory RecordClassData.readFromDataSource(DataSource source) {
+  factory RecordClassData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ClassDefinition definition = ClassDefinition.readFromDataSource(source);
     InterfaceType thisType = source.readDartType();
@@ -986,7 +986,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassDataKind.record);
     sink.begin(tag);
     definition.writeToDataSink(sink);
@@ -1036,7 +1036,7 @@
   JRecord(LibraryEntity library, String name)
       : super(library, name, isAbstract: false);
 
-  factory JRecord.readFromDataSource(DataSource source) {
+  factory JRecord.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JLibrary library = source.readLibrary();
     String name = source.readString();
@@ -1045,7 +1045,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassKind.record);
     sink.begin(tag);
     sink.writeLibrary(library);
@@ -1075,7 +1075,7 @@
             Name(name, box.container.library),
             isStatic: false, isAssignable: true, isConst: isConst);
 
-  factory JRecordField.readFromDataSource(DataSource source) {
+  factory JRecordField.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     String name = source.readString();
     JClass enclosingClass = source.readClass();
@@ -1085,7 +1085,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.recordField);
     sink.begin(tag);
     sink.writeString(name);
@@ -1118,7 +1118,7 @@
       InterfaceType supertype, OrderedTypeSet orderedTypeSet)
       : super(definition, thisType, supertype, orderedTypeSet);
 
-  factory ClosureClassData.readFromDataSource(DataSource source) {
+  factory ClosureClassData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ClassDefinition definition = ClassDefinition.readFromDataSource(source);
     InterfaceType thisType = source.readDartType();
@@ -1131,7 +1131,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassDataKind.closure);
     sink.begin(tag);
     definition.writeToDataSink(sink);
@@ -1153,7 +1153,7 @@
 
   ClosureClassDefinition(this.location);
 
-  factory ClosureClassDefinition.readFromDataSource(DataSource source) {
+  factory ClosureClassDefinition.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     SourceSpan location = source.readSourceSpan();
     source.end(tag);
@@ -1161,7 +1161,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(ClassKind.closure);
     sink.begin(tag);
     sink.writeSourceSpan(location);
@@ -1221,7 +1221,7 @@
       this.classTypeVariableAccess)
       : super(definition, memberThisType);
 
-  factory ClosureFunctionData.readFromDataSource(DataSource source) {
+  factory ClosureFunctionData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ClosureMemberDefinition definition =
         MemberDefinition.readFromDataSource(source);
@@ -1236,7 +1236,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberDataKind.closureFunction);
     sink.begin(tag);
     definition.writeToDataSink(sink);
@@ -1275,7 +1275,7 @@
   ClosureFieldData(MemberDefinition definition, InterfaceType memberThisType)
       : super(definition, memberThisType);
 
-  factory ClosureFieldData.readFromDataSource(DataSource source) {
+  factory ClosureFieldData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberDefinition definition = MemberDefinition.readFromDataSource(source);
     InterfaceType memberThisType = source.readDartType(allowNull: true);
@@ -1284,7 +1284,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberDataKind.closureField);
     sink.begin(tag);
     definition.writeToDataSink(sink);
@@ -1341,7 +1341,7 @@
             kind == MemberKind.closureCall || kind == MemberKind.closureField);
 
   factory ClosureMemberDefinition.readFromDataSource(
-      DataSource source, MemberKind kind) {
+      DataSourceReader source, MemberKind kind) {
     source.begin(tag);
     SourceSpan location = source.readSourceSpan();
     ir.TreeNode node = source.readTreeNode();
@@ -1350,7 +1350,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(kind);
     sink.begin(tag);
     sink.writeSourceSpan(location);
@@ -1372,7 +1372,8 @@
 
   RecordContainerDefinition(this.location);
 
-  factory RecordContainerDefinition.readFromDataSource(DataSource source) {
+  factory RecordContainerDefinition.readFromDataSource(
+      DataSourceReader source) {
     source.begin(tag);
     SourceSpan location = source.readSourceSpan();
     source.end(tag);
@@ -1380,7 +1381,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(ClassKind.record);
     sink.begin(tag);
     sink.writeSourceSpan(location);
diff --git a/pkg/compiler/lib/src/js_model/element_map.dart b/pkg/compiler/lib/src/js_model/element_map.dart
index e87d834..985d77f 100644
--- a/pkg/compiler/lib/src/js_model/element_map.dart
+++ b/pkg/compiler/lib/src/js_model/element_map.dart
@@ -269,7 +269,7 @@
   JumpTarget getJumpTargetForWhile(ir.WhileStatement node);
 
   /// Serializes this [KernelToLocalsMap] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 }
 
 /// Returns the [ir.FunctionNode] that defines [member] or `null` if [member]
@@ -338,7 +338,7 @@
   SourceSpan get location;
 
   /// Deserializes a [MemberDefinition] object from [source].
-  factory MemberDefinition.readFromDataSource(DataSource source) {
+  factory MemberDefinition.readFromDataSource(DataSourceReader source) {
     MemberKind kind = source.readEnum(MemberKind.values);
     switch (kind) {
       case MemberKind.regular:
@@ -356,7 +356,7 @@
   }
 
   /// Serializes this [MemberDefinition] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 }
 
 enum ClassKind {
@@ -378,7 +378,7 @@
 
   RegularMemberDefinition(this.node);
 
-  factory RegularMemberDefinition.readFromDataSource(DataSource source) {
+  factory RegularMemberDefinition.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Member node = source.readMemberNode();
     source.end(tag);
@@ -386,7 +386,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(MemberKind.regular);
     sink.begin(tag);
     sink.writeMemberNode(node);
@@ -418,7 +418,7 @@
   SpecialMemberDefinition(this.node, this.kind);
 
   factory SpecialMemberDefinition.readFromDataSource(
-      DataSource source, MemberKind kind) {
+      DataSourceReader source, MemberKind kind) {
     source.begin(tag);
     ir.TreeNode node = source.readTreeNode();
     source.end(tag);
@@ -426,7 +426,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(kind);
     sink.begin(tag);
     sink.writeTreeNode(node);
@@ -454,7 +454,7 @@
   SourceSpan get location;
 
   /// Deserializes a [ClassDefinition] object from [source].
-  factory ClassDefinition.readFromDataSource(DataSource source) {
+  factory ClassDefinition.readFromDataSource(DataSourceReader source) {
     ClassKind kind = source.readEnum(ClassKind.values);
     switch (kind) {
       case ClassKind.regular:
@@ -468,7 +468,7 @@
   }
 
   /// Serializes this [ClassDefinition] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 }
 
 /// A class directly defined by its [ir.Class] node.
@@ -482,7 +482,7 @@
 
   RegularClassDefinition(this.node);
 
-  factory RegularClassDefinition.readFromDataSource(DataSource source) {
+  factory RegularClassDefinition.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Class node = source.readClassNode();
     source.end(tag);
@@ -490,7 +490,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(kind);
     sink.begin(tag);
     sink.writeClassNode(node);
diff --git a/pkg/compiler/lib/src/js_model/element_map_impl.dart b/pkg/compiler/lib/src/js_model/element_map_impl.dart
index accde9d..5b30ba7 100644
--- a/pkg/compiler/lib/src/js_model/element_map_impl.dart
+++ b/pkg/compiler/lib/src/js_model/element_map_impl.dart
@@ -293,7 +293,7 @@
   }
 
   JsKernelToElementMap.readFromDataSource(this.options, this.reporter,
-      this._environment, ir.Component component, DataSource source) {
+      this._environment, ir.Component component, DataSourceReader source) {
     _elementEnvironment = JsElementEnvironment(this);
     _typeConverter = DartTypeConverter(this);
     _types = KernelDartTypes(this, options);
@@ -430,7 +430,7 @@
   }
 
   /// Serializes this [JsToElementMap] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
 
     // Serialize the entities before serializing the data.
@@ -2629,7 +2629,7 @@
 
   @override
   IndexedMember readMemberFromDataSource(
-      DataSource source, EntityLookup entityLookup) {
+      DataSourceReader source, EntityLookup entityLookup) {
     int index = source.readInt();
     if (index == 0) {
       return _readLateMemberFromDataSource(source, entityLookup);
@@ -2639,7 +2639,7 @@
   }
 
   IndexedMember _readLateMemberFromDataSource(
-      DataSource source, EntityLookup entityLookup) {
+      DataSourceReader source, EntityLookup entityLookup) {
     LateMemberKind kind = source.readEnum(LateMemberKind.values);
     switch (kind) {
       case LateMemberKind.constructorBody:
@@ -2664,7 +2664,7 @@
   ClosedEntityWriter(this._earlyMemberIndexLimit);
 
   @override
-  void writeMemberToDataSink(DataSink sink, IndexedMember value) {
+  void writeMemberToDataSink(DataSinkWriter sink, IndexedMember value) {
     if (value.memberIndex >= _earlyMemberIndexLimit) {
       sink.writeInt(0);
       _writeLateMemberToDataSink(sink, value);
@@ -2673,7 +2673,7 @@
     }
   }
 
-  void _writeLateMemberToDataSink(DataSink sink, IndexedMember value) {
+  void _writeLateMemberToDataSink(DataSinkWriter sink, IndexedMember value) {
     if (value is JConstructorBody) {
       sink.writeEnum(LateMemberKind.constructorBody);
       sink.writeMember(value.constructor);
diff --git a/pkg/compiler/lib/src/js_model/elements.dart b/pkg/compiler/lib/src/js_model/elements.dart
index 62b7315..01c50f9 100644
--- a/pkg/compiler/lib/src/js_model/elements.dart
+++ b/pkg/compiler/lib/src/js_model/elements.dart
@@ -30,7 +30,7 @@
   JLibrary(this.name, this.canonicalUri, this.isNonNullableByDefault);
 
   /// Deserializes a [JLibrary] object from [source].
-  factory JLibrary.readFromDataSource(DataSource source) {
+  factory JLibrary.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     String name = source.readString();
     Uri canonicalUri = source.readUri();
@@ -40,7 +40,7 @@
   }
 
   /// Serializes this [JLibrary] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeString(name);
     sink.writeUri(canonicalUri);
@@ -71,7 +71,7 @@
   JClass(this.library, this.name, {this.isAbstract});
 
   /// Deserializes a [JClass] object from [source].
-  factory JClass.readFromDataSource(DataSource source) {
+  factory JClass.readFromDataSource(DataSourceReader source) {
     JClassKind kind = source.readEnum(JClassKind.values);
     switch (kind) {
       case JClassKind.node:
@@ -90,7 +90,7 @@
   }
 
   /// Serializes this [JClass] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassKind.node);
     sink.begin(tag);
     sink.writeLibrary(library);
@@ -135,7 +135,7 @@
       : _isStatic = isStatic;
 
   /// Deserializes a [JMember] object from [source].
-  factory JMember.readFromDataSource(DataSource source) {
+  factory JMember.readFromDataSource(DataSourceReader source) {
     JMemberKind kind = source.readEnum(JMemberKind.values);
     switch (kind) {
       case JMemberKind.generativeConstructor:
@@ -167,7 +167,7 @@
   }
 
   /// Serializes this [JMember] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   @override
   String get name => _name.text;
@@ -272,7 +272,7 @@
       : super(enclosingClass, name, parameterStructure,
             isExternal: isExternal, isConst: isConst);
 
-  factory JGenerativeConstructor.readFromDataSource(DataSource source) {
+  factory JGenerativeConstructor.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JClass enclosingClass = source.readClass();
     String name = source.readString();
@@ -287,7 +287,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.generativeConstructor);
     sink.begin(tag);
     sink.writeClass(enclosingClass);
@@ -319,7 +319,7 @@
       : super(enclosingClass, name, parameterStructure,
             isExternal: isExternal, isConst: isConst);
 
-  factory JFactoryConstructor.readFromDataSource(DataSource source) {
+  factory JFactoryConstructor.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JClass enclosingClass = source.readClass();
     String name = source.readString();
@@ -337,7 +337,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.factoryConstructor);
     sink.begin(tag);
     sink.writeClass(enclosingClass);
@@ -369,7 +369,7 @@
             constructor.memberName, parameterStructure, AsyncMarker.SYNC,
             isStatic: false, isExternal: false);
 
-  factory JConstructorBody.readFromDataSource(DataSource source) {
+  factory JConstructorBody.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JConstructor constructor = source.readMember();
     ParameterStructure parameterStructure =
@@ -379,7 +379,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.constructorBody);
     sink.begin(tag);
     sink.writeMember(constructor);
@@ -405,7 +405,7 @@
       : super(library, enclosingClass, name, parameterStructure, asyncMarker,
             isStatic: isStatic, isExternal: isExternal);
 
-  factory JMethod.readFromDataSource(DataSource source) {
+  factory JMethod.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberContextKind kind = source.readEnum(MemberContextKind.values);
     JLibrary library;
@@ -433,7 +433,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.method);
     sink.begin(tag);
     if (enclosingClass != null) {
@@ -475,7 +475,7 @@
             function.parameterStructure, function.asyncMarker,
             isStatic: function.isStatic, isExternal: false);
 
-  factory JGeneratorBody.readFromDataSource(DataSource source) {
+  factory JGeneratorBody.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JFunction function = source.readMember();
     DartType elementType = source.readDartType();
@@ -484,7 +484,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.generatorBody);
     sink.begin(tag);
     sink.writeMember(function);
@@ -511,7 +511,7 @@
             asyncMarker,
             isStatic: isStatic, isExternal: isExternal);
 
-  factory JGetter.readFromDataSource(DataSource source) {
+  factory JGetter.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberContextKind kind = source.readEnum(MemberContextKind.values);
     JLibrary library;
@@ -536,7 +536,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.getter);
     sink.begin(tag);
     if (enclosingClass != null) {
@@ -575,7 +575,7 @@
             AsyncMarker.SYNC,
             isStatic: isStatic, isExternal: isExternal);
 
-  factory JSetter.readFromDataSource(DataSource source) {
+  factory JSetter.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberContextKind kind = source.readEnum(MemberContextKind.values);
     JLibrary library;
@@ -599,7 +599,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.setter);
     sink.begin(tag);
     if (enclosingClass != null) {
@@ -640,7 +640,7 @@
       {bool isStatic, this.isAssignable, this.isConst})
       : super(library, enclosingClass, name, isStatic: isStatic);
 
-  factory JField.readFromDataSource(DataSource source) {
+  factory JField.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberContextKind kind = source.readEnum(MemberContextKind.values);
     JLibrary library;
@@ -664,7 +664,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.field);
     sink.begin(tag);
     if (enclosingClass != null) {
@@ -699,7 +699,7 @@
             parameterStructure, asyncMarker,
             isStatic: false, isExternal: false, isAbstract: false);
 
-  factory JClosureCallMethod.readFromDataSource(DataSource source) {
+  factory JClosureCallMethod.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JClass enclosingClass = source.readClass();
     ParameterStructure parameterStructure =
@@ -710,7 +710,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.closureCallMethod);
     sink.begin(tag);
     sink.writeClass(enclosingClass);
@@ -735,7 +735,7 @@
             ParameterStructure.zeroArguments, AsyncMarker.SYNC,
             isStatic: false, isExternal: false, isAbstract: false);
 
-  factory JSignatureMethod.readFromDataSource(DataSource source) {
+  factory JSignatureMethod.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JClass cls = source.readClass();
     source.end(tag);
@@ -743,7 +743,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberKind.signatureMethod);
     sink.begin(tag);
     sink.writeClass(enclosingClass);
@@ -772,7 +772,7 @@
   JTypeVariable(this.typeDeclaration, this.name, this.index);
 
   /// Deserializes a [JTypeVariable] object from [source].
-  factory JTypeVariable.readFromDataSource(DataSource source) {
+  factory JTypeVariable.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     JTypeVariableKind kind = source.readEnum(JTypeVariableKind.values);
     Entity typeDeclaration;
@@ -797,7 +797,7 @@
   }
 
   /// Serializes this [JTypeVariable] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     if (typeDeclaration is IndexedClass) {
       IndexedClass cls = typeDeclaration;
diff --git a/pkg/compiler/lib/src/js_model/env.dart b/pkg/compiler/lib/src/js_model/env.dart
index c0bcc93..a60b310 100644
--- a/pkg/compiler/lib/src/js_model/env.dart
+++ b/pkg/compiler/lib/src/js_model/env.dart
@@ -67,7 +67,7 @@
   JLibraryEnv(this.library, this._memberMap, this._setterMap);
 
   /// Deserializes a [JLibraryEnv] object from [source].
-  factory JLibraryEnv.readFromDataSource(DataSource source) {
+  factory JLibraryEnv.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Library library = source.readLibraryNode();
     Map<String, ir.Member> memberMap =
@@ -79,7 +79,7 @@
   }
 
   /// Serializes this [JLibraryEnv] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeLibraryNode(library);
     sink.writeStringMap(_memberMap, sink.writeMemberNode);
@@ -130,7 +130,7 @@
 
   JLibraryData(this.library, this.imports);
 
-  factory JLibraryData.readFromDataSource(DataSource source) {
+  factory JLibraryData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Library library = source.readLibraryNode();
     int importCount = source.readInt();
@@ -147,7 +147,7 @@
     return JLibraryData(library, imports);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeLibraryNode(library);
     if (imports == null) {
@@ -174,7 +174,7 @@
 /// Member data for a class.
 abstract class JClassEnv {
   /// Deserializes a [JClassEnv] object from [source].
-  factory JClassEnv.readFromDataSource(DataSource source) {
+  factory JClassEnv.readFromDataSource(DataSourceReader source) {
     JClassEnvKind kind = source.readEnum(JClassEnvKind.values);
     switch (kind) {
       case JClassEnvKind.node:
@@ -188,7 +188,7 @@
   }
 
   /// Serializes this [JClassEnv] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   /// The [ir.Class] that defined the class, if any.
   ir.Class get cls;
@@ -244,7 +244,7 @@
   JClassEnvImpl(this.cls, this._constructorMap, this._memberMap,
       this._setterMap, this._members, this.isMixinApplicationWithMembers);
 
-  factory JClassEnvImpl.readFromDataSource(DataSource source) {
+  factory JClassEnvImpl.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Class cls = source.readClassNode();
     Map<String, ir.Member> constructorMap =
@@ -261,7 +261,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassEnvKind.node);
     sink.begin(tag);
     sink.writeClassNode(cls);
@@ -324,7 +324,7 @@
 
   RecordEnv(this._memberMap);
 
-  factory RecordEnv.readFromDataSource(DataSource source) {
+  factory RecordEnv.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Map<String, IndexedMember> _memberMap =
         source.readStringMap(() => source.readMember());
@@ -333,7 +333,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassEnvKind.record);
     sink.begin(tag);
     sink.writeStringMap(
@@ -386,7 +386,7 @@
 
   ClosureClassEnv(Map<String, MemberEntity> memberMap) : super(memberMap);
 
-  factory ClosureClassEnv.readFromDataSource(DataSource source) {
+  factory ClosureClassEnv.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Map<String, IndexedMember> _memberMap =
         source.readStringMap(() => source.readMember());
@@ -395,7 +395,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassEnvKind.closure);
     sink.begin(tag);
     sink.writeStringMap(
@@ -419,7 +419,7 @@
 
 abstract class JClassData {
   /// Deserializes a [JClassData] object from [source].
-  factory JClassData.readFromDataSource(DataSource source) {
+  factory JClassData.readFromDataSource(DataSourceReader source) {
     JClassDataKind kind = source.readEnum(JClassDataKind.values);
     switch (kind) {
       case JClassDataKind.node:
@@ -433,7 +433,7 @@
   }
 
   /// Serializes this [JClassData] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   ClassDefinition get definition;
 
@@ -485,7 +485,7 @@
 
   JClassDataImpl(this.cls, this.definition);
 
-  factory JClassDataImpl.readFromDataSource(DataSource source) {
+  factory JClassDataImpl.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Class cls = source.readClassNode();
     ClassDefinition definition = ClassDefinition.readFromDataSource(source);
@@ -494,7 +494,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JClassDataKind.node);
     sink.begin(tag);
     sink.writeClassNode(cls);
@@ -538,7 +538,7 @@
   JMemberData();
 
   /// Deserializes a [JMemberData] object from [source].
-  factory JMemberData.readFromDataSource(DataSource source) {
+  factory JMemberData.readFromDataSource(DataSourceReader source) {
     JMemberDataKind kind = source.readEnum(JMemberDataKind.values);
     switch (kind) {
       case JMemberDataKind.function:
@@ -562,7 +562,7 @@
   }
 
   /// Serializes this [JMemberData] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 }
 
 abstract class JMemberDataImpl implements JMemberData {
@@ -689,7 +689,7 @@
       MemberDefinition definition, StaticTypeCache staticTypes)
       : super(node, definition, staticTypes);
 
-  factory FunctionDataImpl.readFromDataSource(DataSource source) {
+  factory FunctionDataImpl.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Member node = source.readMemberNode();
     ir.FunctionNode functionNode;
@@ -709,7 +709,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberDataKind.function);
     sink.begin(tag);
     sink.writeMemberNode(node);
@@ -748,7 +748,7 @@
   SignatureFunctionData(this.definition, this.memberThisType,
       this.typeParameters, this.classTypeVariableAccess);
 
-  factory SignatureFunctionData.readFromDataSource(DataSource source) {
+  factory SignatureFunctionData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberDefinition definition = MemberDefinition.readFromDataSource(source);
     InterfaceType memberThisType = source.readDartType(allowNull: true);
@@ -761,7 +761,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberDataKind.signature);
     sink.begin(tag);
     definition.writeToDataSink(sink);
@@ -851,7 +851,8 @@
   GeneratorBodyFunctionData(FunctionData baseData, this.definition)
       : super(baseData);
 
-  factory GeneratorBodyFunctionData.readFromDataSource(DataSource source) {
+  factory GeneratorBodyFunctionData.readFromDataSource(
+      DataSourceReader source) {
     source.begin(tag);
     // TODO(johnniwinther): Share the original base data on deserialization.
     FunctionData baseData = JMemberData.readFromDataSource(source);
@@ -861,7 +862,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberDataKind.generatorBody);
     sink.begin(tag);
     baseData.writeToDataSink(sink);
@@ -887,7 +888,7 @@
       MemberDefinition definition, StaticTypeCache staticTypes)
       : super(node, functionNode, definition, staticTypes);
 
-  factory JConstructorDataImpl.readFromDataSource(DataSource source) {
+  factory JConstructorDataImpl.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Member node = source.readMemberNode();
     ir.FunctionNode functionNode;
@@ -907,7 +908,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberDataKind.constructor);
     sink.begin(tag);
     sink.writeMemberNode(node);
@@ -931,7 +932,7 @@
       MemberDefinition definition, StaticTypeCache staticTypes)
       : super(node, functionNode, definition, staticTypes);
 
-  factory ConstructorBodyDataImpl.readFromDataSource(DataSource source) {
+  factory ConstructorBodyDataImpl.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Member node = source.readMemberNode();
     ir.FunctionNode functionNode;
@@ -951,7 +952,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberDataKind.constructorBody);
     sink.begin(tag);
     sink.writeMemberNode(node);
@@ -982,7 +983,7 @@
       ir.Field node, MemberDefinition definition, StaticTypeCache staticTypes)
       : super(node, definition, staticTypes);
 
-  factory JFieldDataImpl.readFromDataSource(DataSource source) {
+  factory JFieldDataImpl.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.Member node = source.readMemberNode();
     MemberDefinition definition = MemberDefinition.readFromDataSource(source);
@@ -993,7 +994,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.writeEnum(JMemberDataKind.field);
     sink.begin(tag);
     sink.writeMemberNode(node);
@@ -1028,14 +1029,14 @@
 
   JTypeVariableData(this.node);
 
-  factory JTypeVariableData.readFromDataSource(DataSource source) {
+  factory JTypeVariableData.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ir.TypeParameter node = source.readTypeParameterNode();
     source.end(tag);
     return JTypeVariableData(node);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeTypeParameterNode(node);
     sink.end(tag);
diff --git a/pkg/compiler/lib/src/js_model/js_strategy.dart b/pkg/compiler/lib/src/js_model/js_strategy.dart
index 8740692..61dfd89 100644
--- a/pkg/compiler/lib/src/js_model/js_strategy.dart
+++ b/pkg/compiler/lib/src/js_model/js_strategy.dart
@@ -318,12 +318,12 @@
     if (_compiler.options.testMode) {
       bool useDataKinds = true;
       List<Object> data = [];
-      DataSink sink =
-          DataSink(ObjectSinkWriter(data), useDataKinds: useDataKinds);
+      DataSinkWriter sink =
+          DataSinkWriter(ObjectDataSink(data), useDataKinds: useDataKinds);
       sink.registerCodegenWriter(CodegenWriterImpl(closedWorld));
       result.writeToDataSink(sink);
-      DataSource source =
-          DataSource(ObjectSourceReader(data), useDataKinds: useDataKinds);
+      DataSourceReader source =
+          DataSourceReader(ObjectDataSource(data), useDataKinds: useDataKinds);
       List<ModularName> modularNames = [];
       List<ModularExpression> modularExpression = [];
       source.registerCodegenReader(
@@ -390,7 +390,7 @@
   }
 
   /// Prepare [source] to deserialize modular code generation data.
-  void prepareCodegenReader(DataSource source) {
+  void prepareCodegenReader(DataSourceReader source) {
     source.registerEntityReader(ClosedEntityReader(_elementMap));
     source.registerEntityLookup(ClosedEntityLookup(_elementMap));
     source.registerComponentLookup(
diff --git a/pkg/compiler/lib/src/js_model/js_world.dart b/pkg/compiler/lib/src/js_model/js_world.dart
index 1c45fd2..e6803aa 100644
--- a/pkg/compiler/lib/src/js_model/js_world.dart
+++ b/pkg/compiler/lib/src/js_model/js_world.dart
@@ -126,7 +126,7 @@
       Environment environment,
       AbstractValueStrategy abstractValueStrategy,
       ir.Component component,
-      DataSource source) {
+      DataSourceReader source) {
     source.begin(tag);
 
     JsKernelToElementMap elementMap = JsKernelToElementMap.readFromDataSource(
@@ -198,7 +198,7 @@
   }
 
   /// Serializes this [JsClosedWorld] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     elementMap.writeToDataSink(sink);
     classHierarchy.writeToDataSink(sink);
diff --git a/pkg/compiler/lib/src/js_model/locals.dart b/pkg/compiler/lib/src/js_model/locals.dart
index 6f88356..ff38486 100644
--- a/pkg/compiler/lib/src/js_model/locals.dart
+++ b/pkg/compiler/lib/src/js_model/locals.dart
@@ -38,7 +38,7 @@
   /// Deserializes a [GlobalLocalsMap] object from [source].
   factory GlobalLocalsMap.readFromDataSource(
       MemberEntity Function(MemberEntity) localMapKeyLookup,
-      DataSource source) {
+      DataSourceReader source) {
     source.begin(tag);
     Map<MemberEntity, KernelToLocalsMap> _localsMaps = {};
     int mapCount = source.readInt();
@@ -55,7 +55,7 @@
   }
 
   /// Serializes this [GlobalLocalsMap] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     // [KernelToLocalsMap]s are shared between members and their nested
     // closures, so we reverse [_localsMaps] to ensure that [KernelToLocalsMap]s
@@ -107,7 +107,7 @@
   KernelToLocalsMapImpl(this._currentMember);
 
   /// Deserializes a [KernelToLocalsMapImpl] object from [source].
-  KernelToLocalsMapImpl.readFromDataSource(DataSource source) {
+  KernelToLocalsMapImpl.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     _currentMember = source.readMember();
     int localsCount = source.readInt();
@@ -143,7 +143,7 @@
 
   /// Serializes this [KernelToLocalsMapImpl] to [sink].
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMember(currentMember);
     sink.writeInt(_locals.size);
@@ -475,7 +475,7 @@
       this.isContinueTarget = false});
 
   /// Deserializes a [JJumpTarget] object from [source].
-  factory JJumpTarget.readFromDataSource(DataSource source) {
+  factory JJumpTarget.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberEntity memberContext = source.readMember();
     int nestingLevel = source.readInt();
@@ -501,7 +501,7 @@
   }
 
   /// Serializes this [JJumpTarget] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeMember(memberContext);
     sink.writeInt(nestingLevel);
diff --git a/pkg/compiler/lib/src/js_model/type_recipe.dart b/pkg/compiler/lib/src/js_model/type_recipe.dart
index 161e6cc..590ef0a 100644
--- a/pkg/compiler/lib/src/js_model/type_recipe.dart
+++ b/pkg/compiler/lib/src/js_model/type_recipe.dart
@@ -147,7 +147,7 @@
 
   int _computeHashCode();
 
-  factory TypeRecipe.readFromDataSource(DataSource source) {
+  factory TypeRecipe.readFromDataSource(DataSourceReader source) {
     TypeRecipe recipe;
     source.begin(tag);
     _TypeRecipeKind kind = source.readEnum(_TypeRecipeKind.values);
@@ -166,7 +166,7 @@
     return recipe;
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeEnum(_kind);
     _writeToDataSink(sink);
@@ -174,7 +174,7 @@
   }
 
   _TypeRecipeKind get _kind;
-  void _writeToDataSink(DataSink sink);
+  void _writeToDataSink(DataSinkWriter sink);
 
   /// Returns `true` is [recipeB] evaluated in an environment described by
   /// [structureB] gives the same type as [recipeA] evaluated in environment
@@ -203,7 +203,7 @@
 
   TypeExpressionRecipe(this.type);
 
-  static TypeExpressionRecipe _readFromDataSource(DataSource source) {
+  static TypeExpressionRecipe _readFromDataSource(DataSourceReader source) {
     return TypeExpressionRecipe(source.readDartType());
   }
 
@@ -211,7 +211,7 @@
   _TypeRecipeKind get _kind => _TypeRecipeKind.expression;
 
   @override
-  void _writeToDataSink(DataSink sink) {
+  void _writeToDataSink(DataSinkWriter sink) {
     sink.writeDartType(type);
   }
 
@@ -237,7 +237,8 @@
 
   SingletonTypeEnvironmentRecipe(this.type);
 
-  static SingletonTypeEnvironmentRecipe _readFromDataSource(DataSource source) {
+  static SingletonTypeEnvironmentRecipe _readFromDataSource(
+      DataSourceReader source) {
     return SingletonTypeEnvironmentRecipe(source.readDartType());
   }
 
@@ -245,7 +246,7 @@
   _TypeRecipeKind get _kind => _TypeRecipeKind.singletonEnvironment;
 
   @override
-  void _writeToDataSink(DataSink sink) {
+  void _writeToDataSink(DataSinkWriter sink) {
     sink.writeDartType(type);
   }
 
@@ -277,7 +278,8 @@
 
   FullTypeEnvironmentRecipe({this.classType, this.types = const []});
 
-  static FullTypeEnvironmentRecipe _readFromDataSource(DataSource source) {
+  static FullTypeEnvironmentRecipe _readFromDataSource(
+      DataSourceReader source) {
     InterfaceType classType =
         source.readDartType(allowNull: true) as InterfaceType;
     List<DartType> types = source.readDartTypes(emptyAsNull: true) ?? const [];
@@ -288,7 +290,7 @@
   _TypeRecipeKind get _kind => _TypeRecipeKind.fullEnvironment;
 
   @override
-  void _writeToDataSink(DataSink sink) {
+  void _writeToDataSink(DataSinkWriter sink) {
     sink.writeDartType(classType, allowNull: true);
     sink.writeDartTypes(types, allowNull: false);
   }
diff --git a/pkg/compiler/lib/src/native/behavior.dart b/pkg/compiler/lib/src/native/behavior.dart
index f8f41cb..cf696e9 100644
--- a/pkg/compiler/lib/src/native/behavior.dart
+++ b/pkg/compiler/lib/src/native/behavior.dart
@@ -195,7 +195,7 @@
   NativeBehavior.internal(this.sideEffects);
 
   /// Deserializes a [NativeBehavior] object from [source].
-  factory NativeBehavior.readFromDataSource(DataSource source) {
+  factory NativeBehavior.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
 
     List<Object> readTypes() {
@@ -233,7 +233,7 @@
   }
 
   /// Serializes this [NativeBehavior] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
 
     void writeTypes(List<Object> types) {
diff --git a/pkg/compiler/lib/src/ordered_typeset.dart b/pkg/compiler/lib/src/ordered_typeset.dart
index dc2b669..34232db 100644
--- a/pkg/compiler/lib/src/ordered_typeset.dart
+++ b/pkg/compiler/lib/src/ordered_typeset.dart
@@ -38,7 +38,7 @@
   OrderedTypeSet.internal(this._levels, this.types);
 
   /// Deserializes a [OrderedTypeSet] object from [source].
-  factory OrderedTypeSet.readFromDataSource(DataSource source) {
+  factory OrderedTypeSet.readFromDataSource(DataSourceReader source) {
     // TODO(johnniwinther): Make the deserialized type sets share their
     // internal links like the original type sets do?
     source.begin(tag);
@@ -63,7 +63,7 @@
   }
 
   /// Serializes this [OrderedTypeSet] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     List<InterfaceType> typeList = types.toList();
     sink.writeInt(typeList.length);
diff --git a/pkg/compiler/lib/src/serialization/binary_sink.dart b/pkg/compiler/lib/src/serialization/binary_sink.dart
index a697329..7817a31 100644
--- a/pkg/compiler/lib/src/serialization/binary_sink.dart
+++ b/pkg/compiler/lib/src/serialization/binary_sink.dart
@@ -4,15 +4,15 @@
 
 part of 'serialization.dart';
 
-/// [SinkWriter] that writes data as a sequence of bytes.
+/// [DataSink] that writes data as a sequence of bytes.
 ///
 /// This data sink works together with [BinarySourceWriter].
-class BinarySinkWriter implements SinkWriter {
+class BinaryDataSink implements DataSink {
   final Sink<List<int>> sink;
   BufferedSink _bufferedSink;
   int _length = 0;
 
-  BinarySinkWriter(this.sink) : _bufferedSink = BufferedSink(sink);
+  BinaryDataSink(this.sink) : _bufferedSink = BufferedSink(sink);
 
   @override
   int get length => _length;
diff --git a/pkg/compiler/lib/src/serialization/binary_source.dart b/pkg/compiler/lib/src/serialization/binary_source.dart
index 8c424d3..149f362 100644
--- a/pkg/compiler/lib/src/serialization/binary_source.dart
+++ b/pkg/compiler/lib/src/serialization/binary_source.dart
@@ -4,15 +4,15 @@
 
 part of 'serialization.dart';
 
-/// [SourceReader] that reads data from a sequence of bytes.
+/// [DataSource] that reads data from a sequence of bytes.
 ///
-/// This data source works together with [BinarySinkWriter].
-class BinarySourceReader implements SourceReader {
+/// This data source works together with [BinaryDataSink].
+class BinaryDataSource implements DataSource {
   int _byteOffset = 0;
   final List<int> _bytes;
   final StringInterner _stringInterner;
 
-  BinarySourceReader(this._bytes, {StringInterner stringInterner})
+  BinaryDataSource(this._bytes, {StringInterner stringInterner})
       : _stringInterner = stringInterner;
 
   @override
diff --git a/pkg/compiler/lib/src/serialization/helpers.dart b/pkg/compiler/lib/src/serialization/helpers.dart
index 14dee10..81b2e20 100644
--- a/pkg/compiler/lib/src/serialization/helpers.dart
+++ b/pkg/compiler/lib/src/serialization/helpers.dart
@@ -66,7 +66,7 @@
   functionNode,
 }
 
-/// Class used for encoding tags in [ObjectSinkWriter] and [ObjectSourceReader].
+/// Class used for encoding tags in [ObjectDataSink] and [ObjectDataSource].
 class Tag {
   final String value;
 
@@ -126,7 +126,7 @@
 
 class DartTypeNodeWriter
     extends ir.DartTypeVisitor1<void, List<ir.TypeParameter>> {
-  final DataSink _sink;
+  final DataSinkWriter _sink;
 
   DartTypeNodeWriter(this._sink);
 
@@ -262,7 +262,7 @@
 
 /// Data sink helper that canonicalizes [E] values using indices.
 class IndexedSink<E> {
-  final SinkWriter _sink;
+  final DataSink _sink;
   Map<E, int> cache;
 
   IndexedSink(this._sink, {this.cache}) {
@@ -293,7 +293,7 @@
 
 /// Data source helper reads canonicalized [E] values through indices.
 class IndexedSource<E> {
-  final SourceReader _sourceReader;
+  final DataSource _sourceReader;
   List<E> cache;
 
   IndexedSource(this._sourceReader, {this.cache}) {
diff --git a/pkg/compiler/lib/src/serialization/object_sink.dart b/pkg/compiler/lib/src/serialization/object_sink.dart
index e98bdb0..1388dc6 100644
--- a/pkg/compiler/lib/src/serialization/object_sink.dart
+++ b/pkg/compiler/lib/src/serialization/object_sink.dart
@@ -7,11 +7,11 @@
 /// [DataSinkWriter] that writes to a list of objects, useful for debugging
 /// inconsistencies between serialization and deserialization.
 ///
-/// This data sink writer works together with [ObjectSourceReader].
-class ObjectSinkWriter implements SinkWriter {
+/// This data sink writer works together with [ObjectDataSource].
+class ObjectDataSink implements DataSink {
   List<dynamic> _data;
 
-  ObjectSinkWriter(this._data);
+  ObjectDataSink(this._data);
 
   @override
   void beginTag(String tag) {
diff --git a/pkg/compiler/lib/src/serialization/object_source.dart b/pkg/compiler/lib/src/serialization/object_source.dart
index f34c60c..01b602b 100644
--- a/pkg/compiler/lib/src/serialization/object_source.dart
+++ b/pkg/compiler/lib/src/serialization/object_source.dart
@@ -4,15 +4,15 @@
 
 part of 'serialization.dart';
 
-/// [SourceReader] that read from a list of objects, useful for debugging
+/// [DataSource] that read from a list of objects, useful for debugging
 /// inconsistencies between serialization and deserialization.
 ///
-/// This data source works together with [ObjectSinkWriter].
-class ObjectSourceReader implements SourceReader {
+/// This data source works together with [ObjectDataSink].
+class ObjectDataSource implements DataSource {
   int _index = 0;
   final List<dynamic> _data;
 
-  ObjectSourceReader(this._data);
+  ObjectDataSource(this._data);
 
   T _read<T>() {
     dynamic value = _data[_index++];
diff --git a/pkg/compiler/lib/src/serialization/serialization.dart b/pkg/compiler/lib/src/serialization/serialization.dart
index 4a2648b..b7747d9 100644
--- a/pkg/compiler/lib/src/serialization/serialization.dart
+++ b/pkg/compiler/lib/src/serialization/serialization.dart
@@ -37,7 +37,7 @@
 }
 
 /// Data class representing cache information for a given [T] which can be
-/// passed from a [DataSource] to other [DataSource]s and [DataSink]s.
+/// passed from a [DataSourceReader] to other [DataSourceReader]s and [DataSinkWriter]s.
 class DataSourceTypeIndices<E, T> {
   /// Reshapes a [List<T>] to a [Map<E, int>] using [_getValue].
   Map<E, int> _reshape() {
@@ -57,9 +57,9 @@
   Map<E, int> _cache;
 
   /// Though [DataSourceTypeIndices] supports two types of caches. If the
-  /// exported indices are imported into a [DataSource] then the [cacheAsList]
+  /// exported indices are imported into a [DataSourceReader] then the [cacheAsList]
   /// will be used as is. If, however, the exported indices are imported into a
-  /// [DataSink] then we need to reshape the [List<T>] into a [Map<E, int>]
+  /// [DataSinkWriter] then we need to reshape the [List<T>] into a [Map<E, int>]
   /// where [E] is either [T] or some value which can be derived from [T] by
   /// [_getValue].
   DataSourceTypeIndices(this.cacheAsList, [this._getValue]) {
@@ -69,7 +69,7 @@
 }
 
 /// Data class representing the sum of all cache information for a given
-/// [DataSource].
+/// [DataSourceReader].
 class DataSourceIndices {
   final Map<Type, DataSourceTypeIndices> caches = {};
 }
@@ -94,22 +94,22 @@
   const EntityReader();
 
   IndexedLibrary readLibraryFromDataSource(
-      DataSource source, EntityLookup entityLookup) {
+      DataSourceReader source, EntityLookup entityLookup) {
     return entityLookup.getLibraryByIndex(source.readInt());
   }
 
   IndexedClass readClassFromDataSource(
-      DataSource source, EntityLookup entityLookup) {
+      DataSourceReader source, EntityLookup entityLookup) {
     return entityLookup.getClassByIndex(source.readInt());
   }
 
   IndexedMember readMemberFromDataSource(
-      DataSource source, EntityLookup entityLookup) {
+      DataSourceReader source, EntityLookup entityLookup) {
     return entityLookup.getMemberByIndex(source.readInt());
   }
 
   IndexedTypeVariable readTypeVariableFromDataSource(
-      DataSource source, EntityLookup entityLookup) {
+      DataSourceReader source, EntityLookup entityLookup) {
     return entityLookup.getTypeVariableByIndex(source.readInt());
   }
 }
@@ -118,19 +118,20 @@
 class EntityWriter {
   const EntityWriter();
 
-  void writeLibraryToDataSink(DataSink sink, IndexedLibrary value) {
+  void writeLibraryToDataSink(DataSinkWriter sink, IndexedLibrary value) {
     sink.writeInt(value.libraryIndex);
   }
 
-  void writeClassToDataSink(DataSink sink, IndexedClass value) {
+  void writeClassToDataSink(DataSinkWriter sink, IndexedClass value) {
     sink.writeInt(value.classIndex);
   }
 
-  void writeMemberToDataSink(DataSink sink, IndexedMember value) {
+  void writeMemberToDataSink(DataSinkWriter sink, IndexedMember value) {
     sink.writeInt(value.memberIndex);
   }
 
-  void writeTypeVariableToDataSink(DataSink sink, IndexedTypeVariable value) {
+  void writeTypeVariableToDataSink(
+      DataSinkWriter sink, IndexedTypeVariable value) {
     sink.writeInt(value.typeVariableIndex);
   }
 }
@@ -142,16 +143,16 @@
 
 /// Interface used for reading codegen only data during deserialization.
 abstract class CodegenReader {
-  AbstractValue readAbstractValue(DataSource source);
-  OutputUnit readOutputUnitReference(DataSource source);
-  js.Node readJsNode(DataSource source);
-  TypeRecipe readTypeRecipe(DataSource source);
+  AbstractValue readAbstractValue(DataSourceReader source);
+  OutputUnit readOutputUnitReference(DataSourceReader source);
+  js.Node readJsNode(DataSourceReader source);
+  TypeRecipe readTypeRecipe(DataSourceReader source);
 }
 
 /// Interface used for writing codegen only data during serialization.
 abstract class CodegenWriter {
-  void writeAbstractValue(DataSink sink, AbstractValue value);
-  void writeOutputUnitReference(DataSink sink, OutputUnit value);
-  void writeJsNode(DataSink sink, js.Node node);
-  void writeTypeRecipe(DataSink sink, TypeRecipe recipe);
+  void writeAbstractValue(DataSinkWriter sink, AbstractValue value);
+  void writeOutputUnitReference(DataSinkWriter sink, OutputUnit value);
+  void writeJsNode(DataSinkWriter sink, js.Node node);
+  void writeTypeRecipe(DataSinkWriter sink, TypeRecipe recipe);
 }
diff --git a/pkg/compiler/lib/src/serialization/sink.dart b/pkg/compiler/lib/src/serialization/sink.dart
index 9a4703f..3158728 100644
--- a/pkg/compiler/lib/src/serialization/sink.dart
+++ b/pkg/compiler/lib/src/serialization/sink.dart
@@ -4,11 +4,11 @@
 
 part of 'serialization.dart';
 
-/// Interface handling [DataSink] low-level data serialization.
+/// Interface handling [DataSinkWriter] low-level data serialization.
 ///
-/// Each implementation of [SinkWriter] should have a corresponding
-/// [SourceReader] that deserializes data serialized by that implementation.
-abstract class SinkWriter {
+/// Each implementation of [DataSink] should have a corresponding
+/// [DataSource] that deserializes data serialized by that implementation.
+abstract class DataSink {
   int get length;
 
   /// Serialization of a non-negative integer value.
@@ -32,10 +32,10 @@
 
 /// Serialization writer
 ///
-/// To be used with [DataSource] to read and write serialized data.
-/// Serialization format is deferred to provided [SinkWriter].
-class DataSink {
-  final SinkWriter _sinkWriter;
+/// To be used with [DataSourceReader] to read and write serialized data.
+/// Serialization format is deferred to provided [DataSink].
+class DataSinkWriter {
+  final DataSink _sinkWriter;
 
   /// If `true`, serialization of every data kind is preceded by a [DataKind]
   /// value.
@@ -80,7 +80,7 @@
     }
   }
 
-  DataSink(this._sinkWriter,
+  DataSinkWriter(this._sinkWriter,
       {this.useDataKinds = false, this.tagFrequencyMap, this.importedIndices}) {
     _dartTypeNodeWriter = DartTypeNodeWriter(this);
     _stringIndex = _createSink<String>();
@@ -143,7 +143,7 @@
   /// non-null [f] is called to write the non-null value to the data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readValueOrNull].
+  /// [DataSourceReader.readValueOrNull].
   void writeValueOrNull<E>(E value, void f(E value)) {
     writeBool(value != null);
     if (value != null) {
@@ -155,7 +155,7 @@
   /// the data sink. If [allowNull] is `true`, [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readList].
+  /// [DataSourceReader.readList].
   void writeList<E>(Iterable<E> values, void f(E value),
       {bool allowNull = false}) {
     if (values == null) {
@@ -189,7 +189,7 @@
   /// Writes the potentially `null` non-negative [value] to this data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readIntOrNull].
+  /// [DataSourceReader.readIntOrNull].
   void writeIntOrNull(int value) {
     writeBool(value != null);
     if (value != null) {
@@ -211,7 +211,7 @@
   /// Writes the potentially `null` string [value] to this data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readStringOrNull].
+  /// [DataSourceReader.readStringOrNull].
   void writeStringOrNull(String value) {
     writeBool(value != null);
     if (value != null) {
@@ -224,7 +224,7 @@
   /// allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readStringMap].
+  /// [DataSourceReader.readStringMap].
   void writeStringMap<V>(Map<String, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -243,7 +243,7 @@
   /// [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readStrings].
+  /// [DataSourceReader.readStrings].
   void writeStrings(Iterable<String> values, {bool allowNull = false}) {
     if (values == null) {
       assert(allowNull);
@@ -339,7 +339,7 @@
   /// If [allowNull] is `true`, [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readMemberNodes].
+  /// [DataSourceReader.readMemberNodes].
   void writeMemberNodes(Iterable<ir.Member> values, {bool allowNull = false}) {
     if (values == null) {
       assert(allowNull);
@@ -357,7 +357,7 @@
   /// [allowNull] is `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readMemberNodeMap].
+  /// [DataSourceReader.readMemberNodeMap].
   void writeMemberNodeMap<V>(Map<ir.Member, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -437,7 +437,7 @@
   /// to this data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readTreeNodeOrNull].
+  /// [DataSourceReader.readTreeNodeOrNull].
   void writeTreeNodeOrNull(ir.TreeNode value) {
     writeBool(value != null);
     if (value != null) {
@@ -449,7 +449,7 @@
   /// If [allowNull] is `true`, [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readTreeNodes].
+  /// [DataSourceReader.readTreeNodes].
   void writeTreeNodes(Iterable<ir.TreeNode> values, {bool allowNull = false}) {
     if (values == null) {
       assert(allowNull);
@@ -467,7 +467,7 @@
   /// [allowNull] is `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readTreeNodeMap].
+  /// [DataSourceReader.readTreeNodeMap].
   void writeTreeNodeMap<V>(Map<ir.TreeNode, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -498,7 +498,7 @@
   /// the known [context] to this data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readTreeNodeOrNullInContext].
+  /// [DataSourceReader.readTreeNodeOrNullInContext].
   void writeTreeNodeOrNullInContext(ir.TreeNode value) {
     writeBool(value != null);
     if (value != null) {
@@ -511,7 +511,7 @@
   /// `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readTreeNodesInContext].
+  /// [DataSourceReader.readTreeNodesInContext].
   void writeTreeNodesInContext(Iterable<ir.TreeNode> values,
       {bool allowNull = false}) {
     if (values == null) {
@@ -530,7 +530,7 @@
   /// data sink. If [allowNull] is `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readTreeNodeMapInContext].
+  /// [DataSourceReader.readTreeNodeMapInContext].
   void writeTreeNodeMapInContext<V>(Map<ir.TreeNode, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -573,7 +573,7 @@
   /// If [allowNull] is `true`, [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readTypeParameterNodes].
+  /// [DataSourceReader.readTypeParameterNodes].
   void writeTypeParameterNodes(Iterable<ir.TypeParameter> values,
       {bool allowNull = false}) {
     if (values == null) {
@@ -611,7 +611,7 @@
   /// [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readDartTypes].
+  /// [DataSourceReader.readDartTypes].
   void writeDartTypes(Iterable<DartType> values, {bool allowNull = false}) {
     if (values == null) {
       assert(allowNull);
@@ -648,7 +648,7 @@
   /// `true`, [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readDartTypeNodes].
+  /// [DataSourceReader.readDartTypeNodes].
   void writeDartTypeNodes(Iterable<ir.DartType> values,
       {bool allowNull = false}) {
     if (values == null) {
@@ -679,7 +679,7 @@
   /// to this data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readLibraryOrNull].
+  /// [DataSourceReader.readLibraryOrNull].
   void writeLibraryOrNull(IndexedLibrary value) {
     writeBool(value != null);
     if (value != null) {
@@ -692,7 +692,7 @@
   /// [allowNull] is `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readLibraryMap].
+  /// [DataSourceReader.readLibraryMap].
   void writeLibraryMap<V>(Map<LibraryEntity, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -716,7 +716,7 @@
   /// to this data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readClassOrNull].
+  /// [DataSourceReader.readClassOrNull].
   void writeClassOrNull(IndexedClass value) {
     writeBool(value != null);
     if (value != null) {
@@ -728,7 +728,7 @@
   /// [allowNull] is `true`, [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readClasses].
+  /// [DataSourceReader.readClasses].
   void writeClasses(Iterable<ClassEntity> values, {bool allowNull = false}) {
     if (values == null) {
       assert(allowNull);
@@ -746,7 +746,7 @@
   /// [allowNull] is `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readClassMap].
+  /// [DataSourceReader.readClassMap].
   void writeClassMap<V>(Map<ClassEntity, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -770,7 +770,7 @@
   /// to this data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readMemberOrNull].
+  /// [DataSourceReader.readMemberOrNull].
   void writeMemberOrNull(IndexedMember value) {
     writeBool(value != null);
     if (value != null) {
@@ -782,7 +782,7 @@
   /// [allowNull] is `true`, [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readMembers].
+  /// [DataSourceReader.readMembers].
   void writeMembers(Iterable<MemberEntity> values, {bool allowNull = false}) {
     if (values == null) {
       assert(allowNull);
@@ -800,7 +800,7 @@
   /// [allowNull] is `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readMemberMap].
+  /// [DataSourceReader.readMemberMap].
   void writeMemberMap<V>(
       Map<MemberEntity, V> map, void f(MemberEntity member, V value),
       {bool allowNull = false}) {
@@ -826,7 +826,7 @@
   /// [allowNull] is `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readTypeVariableMap].
+  /// [DataSourceReader.readTypeVariableMap].
   void writeTypeVariableMap<V>(Map<IndexedTypeVariable, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -868,7 +868,7 @@
   /// to this data sink.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readLocalOrNull].
+  /// [DataSourceReader.readLocalOrNull].
   void writeLocalOrNull(Local value) {
     writeBool(value != null);
     if (value != null) {
@@ -880,7 +880,7 @@
   /// is `true`, [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readLocals].
+  /// [DataSourceReader.readLocals].
   void writeLocals(Iterable<Local> values, {bool allowNull = false}) {
     if (values == null) {
       assert(allowNull);
@@ -898,7 +898,7 @@
   /// `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readLocalMap].
+  /// [DataSourceReader.readLocalMap].
   void writeLocalMap<V>(Map<Local, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -1019,7 +1019,7 @@
   /// [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readConstants].
+  /// [DataSourceReader.readConstants].
   void writeConstants(Iterable<ConstantValue> values,
       {bool allowNull = false}) {
     if (values == null) {
@@ -1038,7 +1038,7 @@
   /// `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readConstantMap].
+  /// [DataSourceReader.readConstantMap].
   void writeConstantMap<V>(Map<ConstantValue, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
@@ -1111,7 +1111,7 @@
   /// [values] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readImports].
+  /// [DataSourceReader.readImports].
   void writeImports(Iterable<ImportEntity> values, {bool allowNull = false}) {
     if (values == null) {
       assert(allowNull);
@@ -1129,7 +1129,7 @@
   /// `true`, [map] is allowed to be `null`.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSource.readImportMap].
+  /// [DataSourceReader.readImportMap].
   void writeImportMap<V>(Map<ImportEntity, V> map, void f(V value),
       {bool allowNull = false}) {
     if (map == null) {
diff --git a/pkg/compiler/lib/src/serialization/source.dart b/pkg/compiler/lib/src/serialization/source.dart
index cf7fdad..b43c1ad 100644
--- a/pkg/compiler/lib/src/serialization/source.dart
+++ b/pkg/compiler/lib/src/serialization/source.dart
@@ -4,11 +4,11 @@
 
 part of 'serialization.dart';
 
-/// Interface handling [DataSource] low-level data deserialization.
+/// Interface handling [DataSourceReader] low-level data deserialization.
 ///
-/// Each implementation of [SourceReader] should have a corresponding
-/// [SinkWriter] for which it deserializes data.
-abstract class SourceReader {
+/// Each implementation of [DataSource] should have a corresponding
+/// [DataSink] for which it deserializes data.
+abstract class DataSource {
   /// Deserialization of a section begin tag.
   void begin(String tag);
 
@@ -32,10 +32,10 @@
 
 /// Deserialization reader
 ///
-/// To be used with [DataSink] to read and write serialized data.
-/// Deserialization format is deferred to provided [SourceReader].
-class DataSource {
-  final SourceReader _sourceReader;
+/// To be used with [DataSinkWriter] to read and write serialized data.
+/// Deserialization format is deferred to provided [DataSource].
+class DataSourceReader {
+  final DataSource _sourceReader;
 
   static final List<ir.DartType> emptyListOfDartTypes =
       List<ir.DartType>.filled(0, null, growable: false);
@@ -68,7 +68,7 @@
     }
   }
 
-  DataSource(this._sourceReader,
+  DataSourceReader(this._sourceReader,
       {this.useDataKinds = false, this.importedIndices}) {
     _stringIndex = _createSource<String>();
     _uriIndex = _createSource<Uri>();
@@ -77,8 +77,8 @@
     _constantIndex = _createSource<ConstantValue>();
   }
 
-  /// Exports [DataSourceIndices] for use in other [DataSource]s and
-  /// [DataSink]s.
+  /// Exports [DataSourceIndices] for use in other [DataSourceReader]s and
+  /// [DataSinkWriter]s.
   DataSourceIndices exportIndices() {
     var indices = DataSourceIndices();
     indices.caches[String] = DataSourceTypeIndices(_stringIndex.cache);
@@ -200,7 +200,7 @@
   /// read the non-null value from the data source.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeValueOrNull].
+  /// [DataSinkWriter.writeValueOrNull].
   E readValueOrNull<E>(E f()) {
     bool hasValue = readBool();
     if (hasValue) {
@@ -213,7 +213,7 @@
   /// `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeList].
+  /// [DataSinkWriter.writeList].
   List<E> readList<E>(E f(), {bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -246,7 +246,7 @@
   /// source.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeIntOrNull].
+  /// [DataSinkWriter.writeIntOrNull].
   int readIntOrNull() {
     bool hasValue = readBool();
     if (hasValue) {
@@ -268,7 +268,7 @@
   /// Reads a potentially `null` string value from this data source.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeStringOrNull].
+  /// [DataSinkWriter.writeStringOrNull].
   String readStringOrNull() {
     bool hasValue = readBool();
     if (hasValue) {
@@ -281,7 +281,7 @@
   /// `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeStrings].
+  /// [DataSinkWriter.writeStrings].
   List<String> readStrings({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -297,7 +297,7 @@
   /// `true`, `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeStringMap].
+  /// [DataSinkWriter.writeStringMap].
   Map<String, V> readStringMap<V>(V f(), {bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -402,7 +402,7 @@
   /// If [emptyAsNull] is `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeMemberNodes].
+  /// [DataSinkWriter.writeMemberNodes].
   List<E> readMemberNodes<E extends ir.Member>({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -419,7 +419,7 @@
   /// `true`, `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeMemberNodeMap].
+  /// [DataSinkWriter.writeMemberNodeMap].
   Map<K, V> readMemberNodeMap<K extends ir.Member, V>(V f(),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -506,7 +506,7 @@
   /// If [emptyAsNull] is `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeTreeNodes].
+  /// [DataSinkWriter.writeTreeNodes].
   List<E> readTreeNodes<E extends ir.TreeNode>({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -523,7 +523,7 @@
   /// `true`, `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeTreeNodeMap].
+  /// [DataSinkWriter.writeTreeNodeMap].
   Map<K, V> readTreeNodeMap<K extends ir.TreeNode, V>(V f(),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -563,7 +563,7 @@
   /// instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeTreeNodesInContext].
+  /// [DataSinkWriter.writeTreeNodesInContext].
   List<E> readTreeNodesInContext<E extends ir.TreeNode>(
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -582,7 +582,7 @@
   /// map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeTreeNodeMapInContext].
+  /// [DataSinkWriter.writeTreeNodeMapInContext].
   Map<K, V> readTreeNodeMapInContext<K extends ir.TreeNode, V>(V f(),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -620,7 +620,7 @@
   /// list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeTypeParameterNodes].
+  /// [DataSinkWriter.writeTypeParameterNodes].
   List<ir.TypeParameter> readTypeParameterNodes({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -644,7 +644,7 @@
   /// `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeDartTypes].
+  /// [DataSinkWriter.writeDartTypes].
   List<DartType> readDartTypes({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -771,7 +771,7 @@
   /// is `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeDartTypeNodes].
+  /// [DataSinkWriter.writeDartTypeNodes].
   List<ir.DartType> readDartTypeNodes({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -823,7 +823,7 @@
   /// map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeLibraryMap].
+  /// [DataSinkWriter.writeLibraryMap].
   Map<K, V> readLibraryMap<K extends LibraryEntity, V>(V f(),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -856,7 +856,7 @@
   /// If [emptyAsNull] is `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeClasses].
+  /// [DataSinkWriter.writeClasses].
   List<E> readClasses<E extends ClassEntity>({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -873,7 +873,7 @@
   /// `true`, `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeClassMap].
+  /// [DataSinkWriter.writeClassMap].
   Map<K, V> readClassMap<K extends ClassEntity, V>(V f(),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -906,7 +906,7 @@
   /// If [emptyAsNull] is `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeMembers].
+  /// [DataSinkWriter.writeMembers].
   List<E> readMembers<E extends MemberEntity>({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -923,7 +923,7 @@
   /// `true`, `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeMemberMap].
+  /// [DataSinkWriter.writeMemberMap].
   Map<K, V> readMemberMap<K extends MemberEntity, V>(V f(MemberEntity member),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -947,7 +947,7 @@
   /// [emptyAsNull] is `true`, `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeTypeVariableMap].
+  /// [DataSinkWriter.writeTypeVariableMap].
   Map<K, V> readTypeVariableMap<K extends IndexedTypeVariable, V>(V f(),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -998,7 +998,7 @@
   /// [emptyAsNull] is `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeLocals].
+  /// [DataSinkWriter.writeLocals].
   List<E> readLocals<E extends Local>({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -1015,7 +1015,7 @@
   /// `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeLocalMap].
+  /// [DataSinkWriter.writeLocalMap].
   Map<K, V> readLocalMap<K extends Local, V>(V f(),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -1124,7 +1124,7 @@
   /// `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeConstants].
+  /// [DataSinkWriter.writeConstants].
   List<E> readConstants<E extends ConstantValue>({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -1141,7 +1141,7 @@
   /// `true`, `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeConstantMap].
+  /// [DataSinkWriter.writeConstantMap].
   Map<K, V> readConstantMap<K extends ConstantValue, V>(V f(),
       {bool emptyAsNull = false}) {
     int count = readInt();
@@ -1214,7 +1214,7 @@
   /// `true`, `null` is returned instead of an empty list.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeImports].
+  /// [DataSinkWriter.writeImports].
   List<ImportEntity> readImports({bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
@@ -1230,7 +1230,7 @@
   /// `true`, `null` is returned instead of an empty map.
   ///
   /// This is a convenience method to be used together with
-  /// [DataSink.writeImportMap].
+  /// [DataSinkWriter.writeImportMap].
   Map<ImportEntity, V> readImportMap<V>(V f(), {bool emptyAsNull = false}) {
     int count = readInt();
     if (count == 0 && emptyAsNull) return null;
diff --git a/pkg/compiler/lib/src/serialization/strategies.dart b/pkg/compiler/lib/src/serialization/strategies.dart
index 95c04aa..d73bddd 100644
--- a/pkg/compiler/lib/src/serialization/strategies.dart
+++ b/pkg/compiler/lib/src/serialization/strategies.dart
@@ -73,7 +73,7 @@
   List<int> serializeGlobalTypeInferenceResults(
       DataSourceIndices indices, GlobalTypeInferenceResults results) {
     ByteSink byteSink = ByteSink();
-    DataSink sink = DataSink(BinarySinkWriter(byteSink),
+    DataSinkWriter sink = DataSinkWriter(BinaryDataSink(byteSink),
         useDataKinds: useDataKinds, importedIndices: indices);
     serializeGlobalTypeInferenceResultsToSink(results, sink);
     return byteSink.builder.takeBytes();
@@ -89,8 +89,8 @@
       JsClosedWorld closedWorld,
       DataSourceIndices indices,
       List<int> globalTypeInferenceResultsData) {
-    DataSource globalTypeInferenceResultsSource = DataSource(
-        BinarySourceReader(globalTypeInferenceResultsData),
+    DataSourceReader globalTypeInferenceResultsSource = DataSourceReader(
+        BinaryDataSource(globalTypeInferenceResultsData),
         useDataKinds: useDataKinds,
         importedIndices: indices);
     return deserializeGlobalTypeInferenceResultsFromSource(
@@ -106,8 +106,8 @@
   @override
   List<int> serializeClosedWorld(JsClosedWorld closedWorld) {
     ByteSink byteSink = ByteSink();
-    DataSink sink =
-        DataSink(BinarySinkWriter(byteSink), useDataKinds: useDataKinds);
+    DataSinkWriter sink =
+        DataSinkWriter(BinaryDataSink(byteSink), useDataKinds: useDataKinds);
     serializeClosedWorldToSink(closedWorld, sink);
     return byteSink.builder.takeBytes();
   }
@@ -120,8 +120,8 @@
       AbstractValueStrategy abstractValueStrategy,
       ir.Component component,
       List<int> data) {
-    DataSource source =
-        DataSource(BinarySourceReader(data), useDataKinds: useDataKinds);
+    DataSourceReader source =
+        DataSourceReader(BinaryDataSource(data), useDataKinds: useDataKinds);
     var closedWorld = deserializeClosedWorldFromSource(options, reporter,
         environment, abstractValueStrategy, component, source);
     return ClosedWorldAndIndices(closedWorld, source.exportIndices());
@@ -137,8 +137,8 @@
   List<int> serializeGlobalTypeInferenceResults(
       DataSourceIndices indices, GlobalTypeInferenceResults results) {
     Uri uri = Uri.base.resolve('world.data');
-    DataSink sink = DataSink(
-        BinarySinkWriter(
+    DataSinkWriter sink = DataSinkWriter(
+        BinaryDataSink(
             BinaryOutputSinkAdapter(RandomAccessBinaryOutputSink(uri))),
         useDataKinds: useDataKinds,
         importedIndices: indices);
@@ -156,8 +156,8 @@
       JsClosedWorld closedWorld,
       DataSourceIndices indices,
       List<int> globalTypeInferenceResultsData) {
-    DataSource globalTypeInferenceResultsSource = DataSource(
-        BinarySourceReader(globalTypeInferenceResultsData),
+    DataSourceReader globalTypeInferenceResultsSource = DataSourceReader(
+        BinaryDataSource(globalTypeInferenceResultsData),
         useDataKinds: useDataKinds,
         importedIndices: indices);
     return deserializeGlobalTypeInferenceResultsFromSource(
@@ -173,8 +173,8 @@
   @override
   List<int> serializeClosedWorld(JsClosedWorld closedWorld) {
     Uri uri = Uri.base.resolve('closed_world.data');
-    DataSink sink = DataSink(
-        BinarySinkWriter(
+    DataSinkWriter sink = DataSinkWriter(
+        BinaryDataSink(
             BinaryOutputSinkAdapter(RandomAccessBinaryOutputSink(uri))),
         useDataKinds: useDataKinds);
     serializeClosedWorldToSink(closedWorld, sink);
@@ -189,8 +189,8 @@
       AbstractValueStrategy abstractValueStrategy,
       ir.Component component,
       List<int> data) {
-    DataSource source =
-        DataSource(BinarySourceReader(data), useDataKinds: useDataKinds);
+    DataSourceReader source =
+        DataSourceReader(BinaryDataSource(data), useDataKinds: useDataKinds);
     var closedWorld = deserializeClosedWorldFromSource(options, reporter,
         environment, abstractValueStrategy, component, source);
     return ClosedWorldAndIndices(closedWorld, source.exportIndices());
@@ -207,7 +207,7 @@
   List<Object> serializeGlobalTypeInferenceResults(
       DataSourceIndices indices, GlobalTypeInferenceResults results) {
     List<Object> data = [];
-    DataSink sink = DataSink(ObjectSinkWriter(data),
+    DataSinkWriter sink = DataSinkWriter(ObjectDataSink(data),
         useDataKinds: useDataKinds, importedIndices: indices);
     serializeGlobalTypeInferenceResultsToSink(results, sink);
     return data;
@@ -223,8 +223,8 @@
       JsClosedWorld closedWorld,
       DataSourceIndices indices,
       List<Object> globalTypeInferenceResultsData) {
-    DataSource globalTypeInferenceResultsSource =
-        DataSource(ObjectSourceReader(globalTypeInferenceResultsData));
+    DataSourceReader globalTypeInferenceResultsSource =
+        DataSourceReader(ObjectDataSource(globalTypeInferenceResultsData));
     return deserializeGlobalTypeInferenceResultsFromSource(
         options,
         reporter,
@@ -238,8 +238,8 @@
   @override
   List<Object> serializeClosedWorld(JsClosedWorld closedWorld) {
     List<Object> data = [];
-    DataSink sink =
-        DataSink(ObjectSinkWriter(data), useDataKinds: useDataKinds);
+    DataSinkWriter sink =
+        DataSinkWriter(ObjectDataSink(data), useDataKinds: useDataKinds);
     serializeClosedWorldToSink(closedWorld, sink);
     return data;
   }
@@ -252,8 +252,8 @@
       AbstractValueStrategy abstractValueStrategy,
       ir.Component component,
       List<Object> data) {
-    DataSource source =
-        DataSource(ObjectSourceReader(data), useDataKinds: useDataKinds);
+    DataSourceReader source =
+        DataSourceReader(ObjectDataSource(data), useDataKinds: useDataKinds);
     var closedWorld = deserializeClosedWorldFromSource(options, reporter,
         environment, abstractValueStrategy, component, source);
     return ClosedWorldAndIndices(closedWorld, source.exportIndices());
diff --git a/pkg/compiler/lib/src/serialization/task.dart b/pkg/compiler/lib/src/serialization/task.dart
index 2077fe9..c69d158 100644
--- a/pkg/compiler/lib/src/serialization/task.dart
+++ b/pkg/compiler/lib/src/serialization/task.dart
@@ -38,7 +38,7 @@
 }
 
 void serializeGlobalTypeInferenceResultsToSink(
-    GlobalTypeInferenceResults results, DataSink sink) {
+    GlobalTypeInferenceResults results, DataSinkWriter sink) {
   JsClosedWorld closedWorld = results.closedWorld;
   GlobalLocalsMap globalLocalsMap = results.globalLocalsMap;
   InferredData inferredData = results.inferredData;
@@ -55,7 +55,7 @@
     AbstractValueStrategy abstractValueStrategy,
     ir.Component component,
     JsClosedWorld closedWorld,
-    DataSource source) {
+    DataSourceReader source) {
   source.registerComponentLookup(ComponentLookup(component));
   source.registerEntityLookup(ClosedEntityLookup(closedWorld.elementMap));
   GlobalLocalsMap globalLocalsMap = GlobalLocalsMap.readFromDataSource(
@@ -66,7 +66,8 @@
       closedWorld.elementMap, closedWorld, globalLocalsMap, inferredData);
 }
 
-void serializeClosedWorldToSink(JsClosedWorld closedWorld, DataSink sink) {
+void serializeClosedWorldToSink(
+    JsClosedWorld closedWorld, DataSinkWriter sink) {
   closedWorld.writeToDataSink(sink);
   sink.close();
 }
@@ -77,7 +78,7 @@
     Environment environment,
     AbstractValueStrategy abstractValueStrategy,
     ir.Component component,
-    DataSource source) {
+    DataSourceReader source) {
   return JsClosedWorld.readFromDataSource(
       options, reporter, environment, abstractValueStrategy, component, source);
 }
@@ -177,8 +178,8 @@
       _reporter.log('Writing data to ${_options.writeModularAnalysisUri}');
       api.BinaryOutputSink dataOutput =
           _outputProvider.createBinarySink(_options.writeModularAnalysisUri);
-      DataSink sink =
-          DataSink(BinarySinkWriter(BinaryOutputSinkAdapter(dataOutput)));
+      DataSinkWriter sink =
+          DataSinkWriter(BinaryDataSink(BinaryOutputSinkAdapter(dataOutput)));
       data.toDataSink(sink);
       sink.close();
     });
@@ -197,11 +198,11 @@
       //   ModuleData.fromDataSource(source);
 
       BytesSink bytes = BytesSink();
-      DataSink binarySink =
-          DataSink(BinarySinkWriter(bytes), useDataKinds: true);
+      DataSinkWriter binarySink =
+          DataSinkWriter(BinaryDataSink(bytes), useDataKinds: true);
       data.toDataSink(binarySink);
       binarySink.close();
-      var source = DataSource(BinarySourceReader(bytes.builder.toBytes()),
+      var source = DataSourceReader(BinaryDataSource(bytes.builder.toBytes()),
           useDataKinds: true);
       source.registerComponentLookup(ComponentLookup(component));
       ModuleData.fromDataSource(source);
@@ -215,7 +216,8 @@
       for (Uri uri in _options.modularAnalysisInputs) {
         api.Input<List<int>> dataInput =
             await _provider.readFromUri(uri, inputKind: api.InputKind.binary);
-        DataSource source = DataSource(BinarySourceReader(dataInput.data));
+        DataSourceReader source =
+            DataSourceReader(BinaryDataSource(dataInput.data));
         source.registerComponentLookup(ComponentLookup(component));
         results.add(ModuleData.fromDataSource(source));
       }
@@ -228,8 +230,8 @@
       _reporter.log('Writing closed world to ${_options.writeClosedWorldUri}');
       api.BinaryOutputSink dataOutput =
           _outputProvider.createBinarySink(_options.writeClosedWorldUri);
-      DataSink sink =
-          DataSink(BinarySinkWriter(BinaryOutputSinkAdapter(dataOutput)));
+      DataSinkWriter sink =
+          DataSinkWriter(BinaryDataSink(BinaryOutputSinkAdapter(dataOutput)));
       serializeClosedWorldToSink(closedWorld, sink);
     });
   }
@@ -243,8 +245,8 @@
       api.Input<List<int>> dataInput = await _provider.readFromUri(
           _options.readClosedWorldUri,
           inputKind: api.InputKind.binary);
-      DataSource source = DataSource(
-          BinarySourceReader(dataInput.data, stringInterner: _stringInterner));
+      DataSourceReader source = DataSourceReader(
+          BinaryDataSource(dataInput.data, stringInterner: _stringInterner));
       var closedWorld = deserializeClosedWorldFromSource(_options, _reporter,
           environment, abstractValueStrategy, component, source);
       return ClosedWorldAndIndices(closedWorld, source.exportIndices());
@@ -261,8 +263,8 @@
       _reporter.log('Writing data to ${_options.writeDataUri}');
       api.BinaryOutputSink dataOutput =
           _outputProvider.createBinarySink(_options.writeDataUri);
-      DataSink sink = DataSink(
-          BinarySinkWriter(BinaryOutputSinkAdapter(dataOutput)),
+      DataSinkWriter sink = DataSinkWriter(
+          BinaryDataSink(BinaryOutputSinkAdapter(dataOutput)),
           importedIndices: indices);
       serializeGlobalTypeInferenceResultsToSink(results, sink);
     });
@@ -277,8 +279,8 @@
       _reporter.log('Reading data from ${_options.readDataUri}');
       api.Input<List<int>> dataInput = await _provider
           .readFromUri(_options.readDataUri, inputKind: api.InputKind.binary);
-      DataSource source = DataSource(
-          BinarySourceReader(dataInput.data, stringInterner: _stringInterner),
+      DataSourceReader source = DataSourceReader(
+          BinaryDataSource(dataInput.data, stringInterner: _stringInterner),
           importedIndices: closedWorldAndIndices.indices);
       return deserializeGlobalTypeInferenceResultsFromSource(
           _options,
@@ -311,8 +313,8 @@
     measureSubtask('serialize codegen', () {
       Uri uri = Uri.parse('${_options.writeCodegenUri}$shard');
       api.BinaryOutputSink dataOutput = _outputProvider.createBinarySink(uri);
-      DataSink sink = DataSink(
-          BinarySinkWriter(BinaryOutputSinkAdapter(dataOutput)),
+      DataSinkWriter sink = DataSinkWriter(
+          BinaryDataSink(BinaryOutputSinkAdapter(dataOutput)),
           importedIndices: indices);
       _reporter.log('Writing data to ${uri}');
       sink.registerEntityWriter(entityWriter);
@@ -357,8 +359,8 @@
       api.Input<List<int>> dataInput,
       DataSourceIndices importedIndices,
       Map<MemberEntity, CodegenResult> results) {
-    DataSource source = DataSource(
-        BinarySourceReader(dataInput.data, stringInterner: _stringInterner),
+    DataSourceReader source = DataSourceReader(
+        BinaryDataSource(dataInput.data, stringInterner: _stringInterner),
         importedIndices: importedIndices);
     backendStrategy.prepareCodegenReader(source);
     Map<MemberEntity, CodegenResult> codegenResults =
diff --git a/pkg/compiler/lib/src/universe/call_structure.dart b/pkg/compiler/lib/src/universe/call_structure.dart
index 1dc8cdd..0062fc9 100644
--- a/pkg/compiler/lib/src/universe/call_structure.dart
+++ b/pkg/compiler/lib/src/universe/call_structure.dart
@@ -82,7 +82,7 @@
   }
 
   /// Deserializes a [CallStructure] object from [source].
-  factory CallStructure.readFromDataSource(DataSource source) {
+  factory CallStructure.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     int argumentCount = source.readInt();
     List<String> namedArguments = source.readStrings();
@@ -92,7 +92,7 @@
   }
 
   /// Serializes this [CallStructure] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeInt(argumentCount);
     sink.writeStrings(namedArguments);
diff --git a/pkg/compiler/lib/src/universe/class_hierarchy.dart b/pkg/compiler/lib/src/universe/class_hierarchy.dart
index 24cc4ce..a2e6d01 100644
--- a/pkg/compiler/lib/src/universe/class_hierarchy.dart
+++ b/pkg/compiler/lib/src/universe/class_hierarchy.dart
@@ -15,11 +15,11 @@
 abstract class ClassHierarchy {
   /// Deserializes a [ClassHierarchy] object from [source].
   factory ClassHierarchy.readFromDataSource(
-          DataSource source, CommonElements commonElements) =
+          DataSourceReader source, CommonElements commonElements) =
       ClassHierarchyImpl.readFromDataSource;
 
   /// Serializes this [ClassHierarchy] to [sink].
-  void writeToDataSink(DataSink sink);
+  void writeToDataSink(DataSinkWriter sink);
 
   /// Returns `true` if [cls] is either directly or indirectly instantiated.
   bool isInstantiated(ClassEntity cls);
@@ -170,7 +170,7 @@
       this._commonElements, this._classHierarchyNodes, this._classSets);
 
   factory ClassHierarchyImpl.readFromDataSource(
-      DataSource source, CommonElements commonElements) {
+      DataSourceReader source, CommonElements commonElements) {
     source.begin(tag);
     Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes =
         ClassHierarchyNodesMap();
@@ -192,7 +192,7 @@
   }
 
   @override
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeInt(_classSets.length);
     ClassHierarchyNode node =
diff --git a/pkg/compiler/lib/src/universe/class_set.dart b/pkg/compiler/lib/src/universe/class_set.dart
index 5dc7629..f7c899d 100644
--- a/pkg/compiler/lib/src/universe/class_set.dart
+++ b/pkg/compiler/lib/src/universe/class_set.dart
@@ -213,7 +213,7 @@
 
   /// Deserializes a [ClassHierarchyNode] object from [source].
   factory ClassHierarchyNode.readFromDataSource(
-      DataSource source, Map<ClassEntity, ClassHierarchyNode> nodeMap) {
+      DataSourceReader source, Map<ClassEntity, ClassHierarchyNode> nodeMap) {
     source.begin(tag);
     IndexedClass cls = source.readClass();
     ClassHierarchyNode parentNode;
@@ -233,7 +233,7 @@
   }
 
   /// Serializes this [ClassHierarchyNode] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeClass(cls);
     sink.writeClassOrNull(parentNode?.cls);
@@ -541,7 +541,7 @@
 
   /// Deserializes a [ClassSet] object from [source].
   factory ClassSet.readFromDataSource(
-      DataSource source, Map<ClassEntity, ClassHierarchyNode> nodeMap) {
+      DataSourceReader source, Map<ClassEntity, ClassHierarchyNode> nodeMap) {
     source.begin(tag);
     ClassHierarchyNode node = nodeMap[source.readClass()];
     List<ClassHierarchyNode> subtypes = source.readList(() {
@@ -557,7 +557,7 @@
   }
 
   /// Serializes this [ClassSet] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeClass(node.cls);
     sink.writeList(_subtypes, (ClassHierarchyNode node) {
diff --git a/pkg/compiler/lib/src/universe/feature.dart b/pkg/compiler/lib/src/universe/feature.dart
index ca27733..a35a348 100644
--- a/pkg/compiler/lib/src/universe/feature.dart
+++ b/pkg/compiler/lib/src/universe/feature.dart
@@ -241,7 +241,7 @@
 
   GenericInstantiation(this.functionType, this.typeArguments);
 
-  factory GenericInstantiation.readFromDataSource(DataSource source) {
+  factory GenericInstantiation.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     DartType functionType = source.readDartType();
     List<DartType> typeArguments = source.readDartTypes();
@@ -249,7 +249,7 @@
     return GenericInstantiation(functionType, typeArguments);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartType(functionType);
     sink.writeDartTypes(typeArguments);
diff --git a/pkg/compiler/lib/src/universe/member_usage.dart b/pkg/compiler/lib/src/universe/member_usage.dart
index 451b6c5..f3fe0b1 100644
--- a/pkg/compiler/lib/src/universe/member_usage.dart
+++ b/pkg/compiler/lib/src/universe/member_usage.dart
@@ -839,7 +839,7 @@
 
   MemberAccess(this.reads, this.writes, this.invokes);
 
-  factory MemberAccess.readFromDataSource(DataSource source) {
+  factory MemberAccess.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     EnumSet<Access> reads = EnumSet.fixed(source.readInt());
     EnumSet<Access> writes = EnumSet.fixed(source.readInt());
@@ -848,7 +848,7 @@
     return MemberAccess(reads, writes, invokes);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeInt(reads.value);
     sink.writeInt(writes.value);
diff --git a/pkg/compiler/lib/src/universe/selector.dart b/pkg/compiler/lib/src/universe/selector.dart
index dddc39b..8ea7244 100644
--- a/pkg/compiler/lib/src/universe/selector.dart
+++ b/pkg/compiler/lib/src/universe/selector.dart
@@ -199,7 +199,7 @@
       CallStructure(0, null, typeArguments));
 
   /// Deserializes a [Selector] object from [source].
-  factory Selector.readFromDataSource(DataSource source) {
+  factory Selector.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     SelectorKind kind = source.readEnum(SelectorKind.values);
     bool isSetter = source.readBool();
@@ -212,7 +212,7 @@
   }
 
   /// Serializes this [Selector] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeEnum(kind);
     sink.writeBool(memberName.isSetter);
diff --git a/pkg/compiler/lib/src/universe/side_effects.dart b/pkg/compiler/lib/src/universe/side_effects.dart
index f4101839..4e8bab0 100644
--- a/pkg/compiler/lib/src/universe/side_effects.dart
+++ b/pkg/compiler/lib/src/universe/side_effects.dart
@@ -43,7 +43,7 @@
   SideEffects.fromFlags(this._flags);
 
   /// Deserializes a [SideEffects] object from [source].
-  factory SideEffects.readFromDataSource(DataSource source) {
+  factory SideEffects.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     int flags = source.readInt();
     source.end(tag);
@@ -51,7 +51,7 @@
   }
 
   /// Serializes this [SideEffects] to [sink].
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeInt(_flags);
     sink.end(tag);
diff --git a/pkg/compiler/lib/src/universe/use.dart b/pkg/compiler/lib/src/universe/use.dart
index bb33b0e..cffa3fc 100644
--- a/pkg/compiler/lib/src/universe/use.dart
+++ b/pkg/compiler/lib/src/universe/use.dart
@@ -59,7 +59,7 @@
     return DynamicUse(selector, otherReceiverConstraint, _typeArguments);
   }
 
-  factory DynamicUse.readFromDataSource(DataSource source) {
+  factory DynamicUse.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     Selector selector = Selector.readFromDataSource(source);
     bool hasConstraint = source.readBool();
@@ -72,7 +72,7 @@
     return DynamicUse(selector, receiverConstraint, typeArguments);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     selector.writeToDataSink(sink);
     sink.writeBool(receiverConstraint != null);
@@ -215,7 +215,7 @@
     return true;
   }
 
-  factory StaticUse.readFromDataSource(DataSource source) {
+  factory StaticUse.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     MemberEntity element = source.readMember();
     StaticUseKind kind = source.readEnum(StaticUseKind.values);
@@ -234,7 +234,7 @@
         typeArguments: typeArguments);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     assert(element is MemberEntity, "Unsupported entity: $element");
     sink.writeMember(element);
@@ -727,7 +727,7 @@
         this.kind = kind,
         this.hashCode = Hashing.objectsHash(type, kind, deferredImport);
 
-  factory TypeUse.readFromDataSource(DataSource source) {
+  factory TypeUse.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     DartType type = source.readDartType();
     TypeUseKind kind = source.readEnum(TypeUseKind.values);
@@ -736,7 +736,7 @@
     return TypeUse.internal(type, kind, deferredImport);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeDartType(type);
     sink.writeEnum(kind);
@@ -900,14 +900,14 @@
 
   ConstantUse._(this.value);
 
-  factory ConstantUse.readFromDataSource(DataSource source) {
+  factory ConstantUse.readFromDataSource(DataSourceReader source) {
     source.begin(tag);
     ConstantValue value = source.readConstant();
     source.end(tag);
     return ConstantUse._(value);
   }
 
-  void writeToDataSink(DataSink sink) {
+  void writeToDataSink(DataSinkWriter sink) {
     sink.begin(tag);
     sink.writeConstant(value);
     sink.end(tag);