Version 2.14.0-34.0.dev

Merge commit '80102c981b78594ceb6263a044e99e7233f7b365' into 'dev'
diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json
index 5bd7c51..6709196 100644
--- a/.dart_tool/package_config.json
+++ b/.dart_tool/package_config.json
@@ -11,7 +11,7 @@
     "constraint, update this by running tools/generate_package_config.dart."
   ],
   "configVersion": 2,
-  "generated": "2021-04-16T13:34:20.183158",
+  "generated": "2021-04-22T20:51:04.585975",
   "generator": "tools/generate_package_config.dart",
   "packages": [
     {
diff --git a/DEPS b/DEPS
index e9ac972..146ab90 100644
--- a/DEPS
+++ b/DEPS
@@ -148,7 +148,7 @@
   "shelf_static_rev": "fa30419055279a00c9e428439b1abe362d18f25d",
   "shelf_packages_handler_rev": "78302e67c035047e6348e692b0c1182131f0fe35",
   "shelf_proxy_tag": "v1.0.0",
-  "shelf_rev": "00e50adfb776602c25942a99d89f8704cc20db9c",
+  "shelf_rev": "4b9294e29eb308709444a5c0b890fa8ccd69fae4",
   "shelf_web_socket_rev": "24fb8a04befa75a94ac63a27047b231d1a22aab4",
   "source_map_stack_trace_rev": "1c3026f69d9771acf2f8c176a1ab750463309cce",
   "source_maps-0.9.4_rev": "38524",
diff --git a/pkg/front_end/lib/src/fasta/incremental_serializer.dart b/pkg/front_end/lib/src/fasta/incremental_serializer.dart
index 208022e..c9d9a0b 100644
--- a/pkg/front_end/lib/src/fasta/incremental_serializer.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_serializer.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 library fasta.incremental_serializer;
 
 import 'dart:typed_data' show Uint8List;
@@ -40,7 +38,7 @@
     for (int i = 0; i < views.length; i++) {
       SubComponentView view = views[i];
       bool good = true;
-      String packageName;
+      String? packageName;
       for (Library lib in view.libraries) {
         Uri uri = lib.importUri;
         // Uris need to be unique.
@@ -89,7 +87,7 @@
 
   /// Write packages to sink, cache new package data, trim input component.
   void writePackagesToSinkAndTrimComponent(
-      Component component, Sink<List<int>> sink) {
+      Component? component, Sink<List<int>> sink) {
     if (component == null) return;
     if (component.libraries.isEmpty) return;
 
@@ -132,13 +130,12 @@
     Set<SerializationGroup> cachedPackagesInOutput =
         new Set<SerializationGroup>.identity();
     for (Library lib in packageLibraries) {
-      SerializationGroup group = uriToGroup[lib.fileUri];
+      SerializationGroup? group = uriToGroup[lib.fileUri];
       if (group != null) {
         addDataButNotDependentData(group, cachedPackagesInOutput, sink);
       } else {
         String package = lib.importUri.pathSegments.first;
-        newPackages[package] ??= <Library>[];
-        newPackages[package].add(lib);
+        (newPackages[package] ??= <Library>[]).add(lib);
       }
     }
 
@@ -147,7 +144,7 @@
     for (SerializationGroup group in upFrontGroups) {
       if (group.dependencies != null) {
         // Now also add all dependencies.
-        for (SerializationGroup dep in group.dependencies) {
+        for (SerializationGroup dep in group.dependencies!) {
           addDataAndDependentData(dep, cachedPackagesInOutput, sink);
         }
       }
@@ -157,7 +154,7 @@
     Map<String, SerializationGroup> newPackageGroups =
         new Map<String, SerializationGroup>();
     for (String package in newPackages.keys) {
-      List<Library> libraries = newPackages[package];
+      List<Library> libraries = newPackages[package]!;
       List<int> data = serialize(component, libraries);
       sink.add(data);
       SerializationGroup newGroup = createGroupFor(libraries, data);
@@ -166,8 +163,8 @@
 
     // Setup dependency tracking for the new groups.
     for (String package in newPackages.keys) {
-      List<Library> libraries = newPackages[package];
-      SerializationGroup packageGroup = newPackageGroups[package];
+      List<Library> libraries = newPackages[package]!;
+      SerializationGroup packageGroup = newPackageGroups[package]!;
       setupDependencyTracking(libraries, packageGroup);
     }
 
@@ -228,7 +225,7 @@
     while (workList.isNotEmpty) {
       SerializationGroup group = workList.removeLast();
       if (group.othersDependingOnMe == null) continue;
-      for (SerializationGroup dependsOnGroup in group.othersDependingOnMe) {
+      for (SerializationGroup dependsOnGroup in group.othersDependingOnMe!) {
         removeUriFromMap(dependsOnGroup.uris.first, removed, workList);
       }
     }
@@ -247,7 +244,7 @@
         if (dependencyLibrary.importUri.scheme != "package") continue;
         Uri dependencyLibraryUri =
             dep.importedLibraryReference.asLibrary.fileUri;
-        SerializationGroup depGroup = uriToGroup[dependencyLibraryUri];
+        SerializationGroup? depGroup = uriToGroup[dependencyLibraryUri];
         if (depGroup == null) {
           throw "Didn't contain group for $dependencyLibraryUri";
         }
@@ -274,7 +271,7 @@
       sink.add(group.serializedData);
       if (group.dependencies != null) {
         // Now also add all dependencies.
-        for (SerializationGroup dep in group.dependencies) {
+        for (SerializationGroup dep in group.dependencies!) {
           addDataAndDependentData(dep, cachedPackagesInOutput, sink);
         }
       }
@@ -318,13 +315,13 @@
   /// the worklist.
   void removeUriFromMap(Uri uri, Set<SerializationGroup> removed,
       List<SerializationGroup> workList) {
-    SerializationGroup group = uriToGroup.remove(uri);
+    SerializationGroup? group = uriToGroup.remove(uri);
     if (group == null) return;
     bool added = removed.add(group);
     assert(added);
     workList.add(group);
     for (Uri groupUri in group.uris) {
-      SerializationGroup sameGroup = uriToGroup.remove(groupUri);
+      SerializationGroup? sameGroup = uriToGroup.remove(groupUri);
       assert((groupUri == uri && sameGroup == null) ||
           (groupUri != uri && sameGroup != null));
     }
@@ -334,8 +331,8 @@
 class SerializationGroup {
   final List<int> serializedData;
   final Set<Uri> uris;
-  Set<SerializationGroup> dependencies;
-  Set<SerializationGroup> othersDependingOnMe;
+  Set<SerializationGroup>? dependencies;
+  Set<SerializationGroup>? othersDependingOnMe;
 
   SerializationGroup(this.serializedData, this.uris);
 
@@ -344,9 +341,9 @@
   /// this, and this is added as a "others depend on me" for [other].
   void registerDependency(SerializationGroup other) {
     dependencies ??= new Set<SerializationGroup>.identity();
-    if (dependencies.add(other)) {
+    if (dependencies!.add(other)) {
       other.othersDependingOnMe ??= new Set<SerializationGroup>.identity();
-      other.othersDependingOnMe.add(this);
+      other.othersDependingOnMe!.add(this);
     }
   }
 }
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
index 7e7f6cd..caf6767 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE.md file.
 
-// @dart = 2.9
-
 import 'package:kernel/ast.dart';
 
 import 'package:kernel/core_types.dart';
@@ -47,12 +45,12 @@
   void addLowerBound(
       TypeConstraint constraint, DartType lower, Library clientLibrary);
 
-  Member getInterfaceMember(Class class_, Name name, {bool setter: false});
+  Member? getInterfaceMember(Class class_, Name name, {bool setter: false});
 
-  InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+  InterfaceType? getTypeAsInstanceOf(InterfaceType type, Class superclass,
       Library clientLibrary, CoreTypes coreTypes);
 
-  List<DartType> getTypeArgumentsAsInstanceOf(
+  List<DartType>? getTypeArgumentsAsInstanceOf(
       InterfaceType type, Class superclass);
 
   InterfaceType futureType(DartType type, Nullability nullability);
@@ -66,10 +64,10 @@
     }
     for (_ProtoConstraint protoConstraint in _protoConstraints) {
       if (protoConstraint.isUpper) {
-        addUpperBound(result[protoConstraint.parameter], protoConstraint.bound,
+        addUpperBound(result[protoConstraint.parameter]!, protoConstraint.bound,
             clientLibrary);
       } else {
-        addLowerBound(result[protoConstraint.parameter], protoConstraint.bound,
+        addLowerBound(result[protoConstraint.parameter]!, protoConstraint.bound,
             clientLibrary);
       }
     }
@@ -134,7 +132,8 @@
   /// parameters isn't allowed to also contain [UnknownType], that is, to be a
   /// type schema.
   bool _tryNullabilityAwareSubtypeMatch(DartType subtype, DartType supertype,
-      {bool constrainSupertype}) {
+      {required bool constrainSupertype}) {
+    // ignore: unnecessary_null_comparison
     assert(constrainSupertype != null);
     int baseConstraintCount = _protoConstraints.length;
     bool isMatch = _isNullabilityAwareSubtypeMatch(subtype, supertype,
@@ -258,7 +257,7 @@
     // of supertypes of a given type more than once, the order of the checks
     // above is irrelevant; we just need to find the matched superclass,
     // substitute, and then iterate through type variables.
-    List<DartType> matchingSupertypeOfSubtypeArguments =
+    List<DartType>? matchingSupertypeOfSubtypeArguments =
         getTypeArgumentsAsInstanceOf(subtype, supertype.classNode);
     if (matchingSupertypeOfSubtypeArguments == null) return false;
     for (int i = 0; i < supertype.classNode.typeParameters.length; i++) {
@@ -309,9 +308,12 @@
   /// The type that contains the type parameters isn't allowed to also contain
   /// [UnknownType], that is, to be a type schema.
   bool _isNullabilityAwareSubtypeMatch(DartType p, DartType q,
-      {bool constrainSupertype}) {
+      {required bool constrainSupertype}) {
+    // ignore: unnecessary_null_comparison
     assert(p != null);
+    // ignore: unnecessary_null_comparison
     assert(q != null);
+    // ignore: unnecessary_null_comparison
     assert(constrainSupertype != null);
 
     // If the type parameters being constrained occur in the supertype (that is,
@@ -639,7 +641,7 @@
     // Bj> is a subtype match for C1<N0, ..., Nj> with respect to L under
     // constraints C.
     if (p is InterfaceType && q is InterfaceType) {
-      final List<DartType> sArguments =
+      final List<DartType>? sArguments =
           getTypeArgumentsAsInstanceOf(p, q.classNode);
       if (sArguments != null) {
         assert(sArguments.length == q.typeArguments.length);
@@ -724,7 +726,7 @@
               isMatch && pNamedTypes.containsKey(q.namedParameters[i].name);
           isMatch = isMatch &&
               _isNullabilityAwareSubtypeMatch(q.namedParameters[i].type,
-                  pNamedTypes[q.namedParameters[i].name],
+                  pNamedTypes[q.namedParameters[i].name]!,
                   constrainSupertype: !constrainSupertype);
         }
         if (isMatch) return true;
@@ -972,9 +974,10 @@
     //   and `F` is a subtype match for a type `Q` with respect to `L` under
     //   constraints `C`.
     if (subtype is InterfaceType) {
-      Member callMember = getInterfaceMember(subtype.classNode, callName);
+      Member? callMember = getInterfaceMember(subtype.classNode, callName);
       if (callMember is Procedure && !callMember.isGetter) {
         DartType callType = callMember.getterType;
+        // ignore: unnecessary_null_comparison
         if (callType != null) {
           callType =
               Substitution.fromInterfaceType(subtype).substituteType(callType);
@@ -1053,20 +1056,20 @@
   }
 
   @override
-  Member getInterfaceMember(Class class_, Name name, {bool setter: false}) {
+  Member? getInterfaceMember(Class class_, Name name, {bool setter: false}) {
     return environment.hierarchy
         .getInterfaceMember(class_, name, setter: setter);
   }
 
   @override
-  InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+  InterfaceType? getTypeAsInstanceOf(InterfaceType type, Class superclass,
       Library clientLibrary, CoreTypes coreTypes) {
     return environment.getTypeAsInstanceOf(
         type, superclass, clientLibrary, coreTypes);
   }
 
   @override
-  List<DartType> getTypeArgumentsAsInstanceOf(
+  List<DartType>? getTypeArgumentsAsInstanceOf(
       InterfaceType type, Class superclass) {
     return environment.getTypeArgumentsAsInstanceOf(type, superclass);
   }
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
index 5e8e77f..f7e463b 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE.md file.
 
-// @dart = 2.9
-
 import 'package:kernel/ast.dart';
 
 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
@@ -49,7 +47,7 @@
       requiredParameterCount: type.requiredParameterCount,
       typedefType: type.typedefType == null
           ? null
-          : substitution.substituteType(type.typedefType));
+          : substitution.substituteType(type.typedefType!) as TypedefType);
 }
 
 /// Given a [FunctionType], gets the type of the named parameter with the given
@@ -247,8 +245,8 @@
   void inferGenericFunctionOrType(
       DartType declaredReturnType,
       List<TypeParameter> typeParametersToInfer,
-      List<DartType> formalTypes,
-      List<DartType> actualTypes,
+      List<DartType>? formalTypes,
+      List<DartType>? actualTypes,
       DartType returnContextType,
       List<DartType> inferredTypes,
       Library clientLibrary,
@@ -283,7 +281,7 @@
       for (int i = 0; i < formalTypes.length; i++) {
         // Try to pass each argument to each parameter, recording any type
         // parameter bounds that were implied by this assignment.
-        gatherer.tryConstrainLower(formalTypes[i], actualTypes[i]);
+        gatherer.tryConstrainLower(formalTypes[i], actualTypes![i]);
       }
     }
 
@@ -332,27 +330,27 @@
       List<DartType> inferredTypes,
       Library clientLibrary,
       {bool downwardsInferPhase: false}) {
-    List<DartType> typesFromDownwardsInference =
+    List<DartType>? typesFromDownwardsInference =
         downwardsInferPhase ? null : inferredTypes.toList(growable: false);
 
     for (int i = 0; i < typeParametersToInfer.length; i++) {
       TypeParameter typeParam = typeParametersToInfer[i];
 
       DartType typeParamBound = typeParam.bound;
-      DartType extendsConstraint;
+      DartType? extendsConstraint;
       if (!hasOmittedBound(typeParam)) {
         extendsConstraint =
             Substitution.fromPairs(typeParametersToInfer, inferredTypes)
                 .substituteType(typeParamBound);
       }
 
-      TypeConstraint constraint = constraints[typeParam];
+      TypeConstraint constraint = constraints[typeParam]!;
       if (downwardsInferPhase) {
         inferredTypes[i] = _inferTypeParameterFromContext(
             constraint, extendsConstraint, clientLibrary);
       } else {
         inferredTypes[i] = _inferTypeParameterFromAll(
-            typesFromDownwardsInference[i],
+            typesFromDownwardsInference![i],
             constraint,
             extendsConstraint,
             clientLibrary,
@@ -405,7 +403,7 @@
 
     DartType unwrappedSupertype = supertype;
     while (unwrappedSupertype is FutureOrType) {
-      unwrappedSupertype = (unwrappedSupertype as FutureOrType).typeArgument;
+      unwrappedSupertype = unwrappedSupertype.typeArgument;
     }
     if (unwrappedSupertype is UnknownType) {
       return const IsSubtypeOf.always();
@@ -413,7 +411,8 @@
     return super.performNullabilityAwareSubtypeCheck(subtype, supertype);
   }
 
-  bool isEmptyContext(DartType context) {
+  // TODO(johnniwinther): Should [context] be non-nullable?
+  bool isEmptyContext(DartType? context) {
     if (context is DynamicType) {
       // Analyzer treats a type context of `dynamic` as equivalent to an empty
       // context.  TODO(paulberry): this is not spec'ed anywhere; do we still
@@ -433,7 +432,8 @@
   /// by giving special treatment to certain arithmetic operators.
   bool isSpecialCasesBinaryForReceiverType(
       Procedure member, DartType receiverType,
-      {bool isNonNullableByDefault}) {
+      {required bool isNonNullableByDefault}) {
+    // ignore: unnecessary_null_comparison
     assert(isNonNullableByDefault != null);
     if (!isNonNullableByDefault) {
       // TODO(paulberry): this matches what is defined in the spec.  It would be
@@ -523,7 +523,7 @@
   DartType _inferTypeParameterFromAll(
       DartType typeFromContextInference,
       TypeConstraint constraint,
-      DartType extendsConstraint,
+      DartType? extendsConstraint,
       Library clientLibrary,
       {bool isContravariant: false,
       bool preferUpwardsInference: false}) {
@@ -552,7 +552,7 @@
   }
 
   DartType _inferTypeParameterFromContext(TypeConstraint constraint,
-      DartType extendsConstraint, Library clientLibrary) {
+      DartType? extendsConstraint, Library clientLibrary) {
     DartType t = solveTypeConstraint(
         constraint,
         clientLibrary.isNonNullableByDefault
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index eb7f26f..029f7b9 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -230,7 +230,6 @@
 
 abstract class FileUriNode extends TreeNode {
   /// The URI of the source file this node was loaded from.
-  // TODO(johnniwinther): Make this non-nullable.
   Uri get fileUri;
 }
 
@@ -12876,7 +12875,7 @@
   Component get enclosingComponent => this;
 
   /// Translates an offset to line and column numbers in the given file.
-  Location? getLocation(Uri? file, int offset) {
+  Location? getLocation(Uri file, int offset) {
     return uriToSource[file]?.getLocation(file, offset);
   }
 
@@ -12909,8 +12908,7 @@
 /// A tuple with file, line, and column number, for displaying human-readable
 /// locations.
 class Location {
-  // TODO(johnniwinther): Make this non-nullable.
-  final Uri? file;
+  final Uri file;
   final int line; // 1-based.
   final int column; // 1-based.
 
@@ -13098,7 +13096,7 @@
   }
 
   /// Translates an offset to 1-based line and column numbers in the given file.
-  Location getLocation(Uri? file, int offset) {
+  Location getLocation(Uri file, int offset) {
     List<int>? lineStarts = this.lineStarts;
     if (lineStarts == null || lineStarts.isEmpty) {
       return new Location(file, TreeNode.noOffset, TreeNode.noOffset);
@@ -13394,7 +13392,7 @@
 const Null informative = null;
 
 Location? _getLocationInComponent(
-    Component? component, Uri? fileUri, int offset) {
+    Component? component, Uri fileUri, int offset) {
   if (component != null) {
     return component.getLocation(fileUri, offset);
   } else {
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index a825278..adc7012 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -768,7 +768,7 @@
     _ComponentIndex index = _readComponentIndex(componentFileSize);
 
     _byteOffset = index.binaryOffsetForSourceTable;
-    Map<Uri?, Source> uriToSource = readUriToSource(readCoverage: false);
+    Map<Uri, Source> uriToSource = readUriToSource(readCoverage: false);
     _mergeUriToSource(component.uriToSource, uriToSource);
 
     _byteOffset = _componentStartOffset + componentFileSize;
@@ -818,7 +818,7 @@
     _associateMetadata(component, _componentStartOffset);
 
     _byteOffset = index.binaryOffsetForSourceTable;
-    Map<Uri?, Source> uriToSource = readUriToSource(readCoverage: true);
+    Map<Uri, Source> uriToSource = readUriToSource(readCoverage: true);
     _mergeUriToSource(component.uriToSource, uriToSource);
 
     _byteOffset = index.binaryOffsetForConstantTable;
@@ -866,7 +866,7 @@
   /// [readCoverage] is true, otherwise coverage will be skipped. Note also that
   /// if [readCoverage] is true, references are read and that the link table
   /// thus has to be read first.
-  Map<Uri?, Source> readUriToSource({required bool readCoverage}) {
+  Map<Uri, Source> readUriToSource({required bool readCoverage}) {
     // ignore: unnecessary_null_comparison
     assert(!readCoverage || (readCoverage && _linkTable != null));
 
@@ -874,10 +874,10 @@
 
     // Read data.
     _sourceUriTable.length = length;
-    Map<Uri?, Source> uriToSource = <Uri, Source>{};
+    Map<Uri, Source> uriToSource = <Uri, Source>{};
     for (int i = 0; i < length; ++i) {
       String uriString = readString();
-      Uri? uri = uriString.isEmpty ? null : Uri.parse(uriString);
+      Uri uri = Uri.parse(uriString);
       _sourceUriTable[i] = uri;
       Uint8List sourceCode = readByteList();
       int lineCount = readUInt30();
@@ -893,8 +893,7 @@
         previousLineStart = lineStart;
       }
       String importUriString = readString();
-      Uri? importUri =
-          importUriString.isEmpty ? null : Uri.parse(importUriString);
+      Uri importUri = Uri.parse(importUriString);
 
       Set<Reference>? coverageConstructors;
       {
@@ -928,12 +927,12 @@
   // source with an empty source. Empty sources may be introduced by
   // synthetic, copy-down implementations such as mixin applications or
   // noSuchMethod forwarders.
-  void _mergeUriToSource(Map<Uri?, Source> dst, Map<Uri?, Source> src) {
+  void _mergeUriToSource(Map<Uri, Source> dst, Map<Uri, Source> src) {
     if (dst.isEmpty) {
       // Fast path for the common case of one component per binary.
       dst.addAll(src);
     } else {
-      src.forEach((Uri? key, Source value) {
+      src.forEach((Uri key, Source value) {
         Source? originalDestinationSource = dst[key];
         Source? mergeFrom;
         Source mergeTo;
diff --git a/runtime/platform/utils.h b/runtime/platform/utils.h
index a73d6d9..24f7e68 100644
--- a/runtime/platform/utils.h
+++ b/runtime/platform/utils.h
@@ -395,29 +395,23 @@
     return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL));
   }
 
-  static constexpr uword NBitMaskUnsafe(uint32_t n) {
-    static_assert((sizeof(uword) * kBitsPerByte) == kBitsPerWord,
-                  "Unexpected uword size");
-    return n == kBitsPerWord ? std::numeric_limits<uword>::max()
-                             : (static_cast<uword>(1) << n) - 1;
-  }
-
   // The lowest n bits are 1, the others are 0.
-  static uword NBitMask(uint32_t n) {
-    ASSERT(n <= kBitsPerWord);
-    return NBitMaskUnsafe(n);
-  }
-
-  static word SignedNBitMask(uint32_t n) {
-    uword mask = NBitMask(n);
-    return bit_cast<word>(mask);
+  template <typename T = uword>
+  static constexpr T NBitMask(size_t n) {
+    static_assert(std::is_integral<T>::value, "Must be integral type");
+    using Unsigned = typename std::make_unsigned<T>::type;
+    assert(n <= sizeof(T) * kBitsPerByte);
+    return n == sizeof(T) * kBitsPerByte
+               ? static_cast<T>(-1)
+               : static_cast<T>((static_cast<Unsigned>(1) << n) - 1);
   }
 
   template <typename T = uword>
-  static T Bit(uint32_t n) {
-    ASSERT(n < sizeof(T) * kBitsPerByte);
-    T bit = 1;
-    return bit << n;
+  static constexpr T Bit(size_t n) {
+    static_assert(std::is_integral<T>::value, "Must be integral type");
+    using Unsigned = typename std::make_unsigned<T>::type;
+    assert(n < sizeof(T) * kBitsPerByte);
+    return static_cast<T>(static_cast<Unsigned>(1) << n);
   }
 
   template <typename T>
diff --git a/runtime/vm/code_descriptors.cc b/runtime/vm/code_descriptors.cc
index dd8bc1d..50f2ec5 100644
--- a/runtime/vm/code_descriptors.cc
+++ b/runtime/vm/code_descriptors.cc
@@ -54,8 +54,8 @@
         UntaggedPcDescriptors::KindAndMetadata::Encode(kind, try_index,
                                                        yield_index);
 
-    encoded_data_.WriteSLEB128(kind_and_metadata);
-    encoded_data_.WriteSLEB128(pc_offset - prev_pc_offset);
+    encoded_data_.Write(kind_and_metadata);
+    encoded_data_.Write(pc_offset - prev_pc_offset);
     prev_pc_offset = pc_offset;
 
     if (!FLAG_precompiled_mode) {
@@ -80,8 +80,8 @@
         }
       }
       const int32_t encoded_pos = token_pos.Serialize();
-      encoded_data_.WriteSLEB128(deopt_id - prev_deopt_id);
-      encoded_data_.WriteSLEB128(
+      encoded_data_.Write(deopt_id - prev_deopt_id);
+      encoded_data_.Write(
           Utils::SubWithWrapAround(encoded_pos, prev_token_pos));
       prev_deopt_id = deopt_id;
       prev_token_pos = encoded_pos;
@@ -106,9 +106,9 @@
   const uword pc_delta = pc_offset - last_pc_offset_;
   const uword non_spill_slot_bit_count =
       bitmap->Length() - spill_slot_bit_count;
-  encoded_bytes_.WriteLEB128(pc_delta);
-  encoded_bytes_.WriteLEB128(spill_slot_bit_count);
-  encoded_bytes_.WriteLEB128(non_spill_slot_bit_count);
+  encoded_bytes_.WriteUnsigned(pc_delta);
+  encoded_bytes_.WriteUnsigned(spill_slot_bit_count);
+  encoded_bytes_.WriteUnsigned(non_spill_slot_bit_count);
   bitmap->AppendAsBytesTo(&encoded_bytes_);
   last_pc_offset_ = pc_offset;
 }
diff --git a/runtime/vm/code_descriptors.h b/runtime/vm/code_descriptors.h
index 0d15c38..adf53b0 100644
--- a/runtime/vm/code_descriptors.h
+++ b/runtime/vm/code_descriptors.h
@@ -209,7 +209,7 @@
   using ArgField = BitField<int32_t, int32_t, OpField::kNextBit>;
 
   static constexpr int32_t kMaxArgValue =
-      Utils::NBitMaskUnsafe(ArgField::bitsize() - 1);
+      Utils::NBitMask(ArgField::bitsize() - 1);
   static constexpr int32_t kMinArgValue = ~kMaxArgValue;
   static constexpr int32_t kSignBits = static_cast<uint32_t>(kMinArgValue) << 1;
 };
diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc
index 70f7fb0..8782aec 100644
--- a/runtime/vm/compiler/backend/il_arm.cc
+++ b/runtime/vm/compiler/backend/il_arm.cc
@@ -778,8 +778,8 @@
   const intptr_t kCpuRegistersToPreserve =
       kDartAvailableCpuRegs & ~kNonChangeableInputRegs;
   const intptr_t kFpuRegistersToPreserve =
-      Utils::SignedNBitMask(kNumberOfFpuRegisters) &
-      ~(Utils::SignedNBitMask(kAbiPreservedFpuRegCount)
+      Utils::NBitMask<word>(kNumberOfFpuRegisters) &
+      ~(Utils::NBitMask<word>(kAbiPreservedFpuRegCount)
         << kAbiFirstPreservedFpuReg) &
       ~(1 << FpuTMP);
 
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index d375c59..e79bfbc 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -689,7 +689,7 @@
   const intptr_t kCpuRegistersToPreserve =
       kDartAvailableCpuRegs & ~kNonChangeableInputRegs;
   const intptr_t kFpuRegistersToPreserve =
-      Utils::SignedNBitMask(kNumberOfFpuRegisters) & ~(1l << FpuTMP);
+      Utils::NBitMask<word>(kNumberOfFpuRegisters) & ~Utils::Bit(FpuTMP);
 
   const intptr_t kNumTemps = (Utils::CountOneBits64(kCpuRegistersToPreserve) +
                               Utils::CountOneBits64(kFpuRegistersToPreserve));
diff --git a/runtime/vm/datastream.cc b/runtime/vm/datastream.cc
index 6d398fe..397f9c7 100644
--- a/runtime/vm/datastream.cc
+++ b/runtime/vm/datastream.cc
@@ -4,11 +4,126 @@
 
 #include "vm/datastream.h"
 
+#include "platform/text_buffer.h"
 #include "vm/compiler/runtime_api.h"
+#include "vm/os.h"
 #include "vm/zone.h"
 
 namespace dart {
 
+// Setting up needed variables for the unrolled loop sections below.
+#define UNROLLED_INIT()                                                        \
+  using Unsigned = typename std::make_unsigned<T>::type;                       \
+  Unsigned b = ReadByte();                                                     \
+  if ((b & C::kMoreDataMask) == 0) {                                           \
+    if ((b & C::kSignMask) != 0) {                                             \
+      b |= ~Utils::NBitMask<Unsigned>(C::kDataBitsPerByte);                    \
+    }                                                                          \
+    return static_cast<T>(b);                                                  \
+  }                                                                            \
+  T r = static_cast<T>(b & C::kDataByteMask);
+
+// Part of the unrolled loop where the loop may stop, having read the last part,
+// or continue reading.
+#define UNROLLED_BODY(bit_start)                                               \
+  static_assert(bit_start % C::kDataBitsPerByte == 0,                          \
+                "Bit start must be a multiple of the data bits per byte");     \
+  static_assert(bit_start >= 0 && bit_start < kBitsPerByte * sizeof(T),        \
+                "Starting unrolled body at invalid bit position");             \
+  static_assert(bit_start + C::kDataBitsPerByte < kBitsPerByte * sizeof(T),    \
+                "Unrolled body should not contain final bits in value");       \
+  b = ReadByte();                                                              \
+  r |= static_cast<Unsigned>(b & C::kDataByteMask) << bit_start;               \
+  if ((b & C::kMoreDataMask) == 0) {                                           \
+    if ((b & C::kSignMask) != 0) {                                             \
+      r |= ~Utils::NBitMask<T>(bit_start + C::kDataBitsPerByte);               \
+    }                                                                          \
+    return r;                                                                  \
+  }
+
+// The end of the unrolled loop. Does not need to handle sign extension, as the
+// last bits fill the rest of the bitspace.
+#define UNROLLED_END(bit_start)                                                \
+  static_assert(bit_start % C::kDataBitsPerByte == 0,                          \
+                "Bit start must be a multiple of the data bits per byte");     \
+  static_assert(bit_start >= 0 && bit_start < kBitsPerByte * sizeof(T),        \
+                "Starting unrolled end at invalid bit position");              \
+  static_assert(bit_start + C::kDataBitsPerByte >= kBitsPerByte * sizeof(T),   \
+                "Unrolled end does not contain final bits in value");          \
+  b = ReadByte();                                                              \
+  ASSERT_EQUAL((b & C::kMoreDataMask), 0);                                     \
+  r |= static_cast<Unsigned>(b & C::kDataByteMask) << bit_start;               \
+  return r;
+
+uint16_t ReadStream::Read16() {
+  using T = uint16_t;
+  UNROLLED_INIT();
+  UNROLLED_BODY(7);
+  UNROLLED_END(14);
+}
+
+uint32_t ReadStream::Read32() {
+  using T = uint32_t;
+  UNROLLED_INIT();
+  UNROLLED_BODY(7);
+  UNROLLED_BODY(14);
+  UNROLLED_BODY(21);
+  UNROLLED_END(28);
+}
+
+uint64_t ReadStream::Read64() {
+  using T = uint64_t;
+  UNROLLED_INIT();
+  UNROLLED_BODY(7);
+  UNROLLED_BODY(14);
+  UNROLLED_BODY(21);
+  UNROLLED_BODY(28);
+  UNROLLED_BODY(35);
+  UNROLLED_BODY(42);
+  UNROLLED_BODY(49);
+  UNROLLED_BODY(56);
+  UNROLLED_END(63);
+}
+#undef UNROLLED_INIT
+#undef UNROLLED_BODY
+#undef UNROLLED_END
+
+static constexpr intptr_t kRowSize = 16;
+
+void ReadStream::WriteWindow(BaseTextBuffer* buffer,
+                             intptr_t start,
+                             intptr_t window_size) {
+  const intptr_t buffer_size = end_ - buffer_;
+  ASSERT(0 <= start && start <= buffer_size);
+  intptr_t window_start = start - (window_size / 2);
+  intptr_t window_end = start + (window_size / 2);
+  if (window_start < 0) window_start = 0;
+  if (buffer_size < window_start + window_end) window_end = buffer_size;
+  for (intptr_t i = window_start - (window_start % kRowSize); i < window_end;
+       i += kRowSize) {
+    buffer->Printf("%016" Px " ", i);
+    intptr_t j = i;
+    if (j < window_start) {
+      while (j < window_start) {
+        buffer->AddString("    ");
+        ++j;
+      }
+    }
+    for (; j < Utils::Minimum(window_end, i + kRowSize); j++) {
+      buffer->AddChar(j == start ? '|' : ' ');
+      buffer->Printf("%02x", static_cast<uint8_t>(buffer_[j] % kMaxUint8));
+      buffer->AddChar(j == start ? '|' : ' ');
+    }
+    buffer->AddChar('\n');
+  }
+}
+
+void ReadStream::PrintWindow(intptr_t start, intptr_t window_size) {
+  TextBuffer buffer(1024);
+  WriteWindow(&buffer, start, window_size);
+  OS::Print("%s", buffer.buffer());
+}
+
 void BaseWriteStream::WriteTargetWord(word value) {
   ASSERT(compiler::target::kBitsPerWord == kBitsPerWord ||
          Utils::IsAbsoluteUint(compiler::target::kBitsPerWord, value));
diff --git a/runtime/vm/datastream.h b/runtime/vm/datastream.h
index 7da4532..fd343cd 100644
--- a/runtime/vm/datastream.h
+++ b/runtime/vm/datastream.h
@@ -15,14 +15,7 @@
 
 namespace dart {
 
-static const int8_t kDataBitsPerByte = 7;
-static const int8_t kByteMask = (1 << kDataBitsPerByte) - 1;
-static const int8_t kMaxUnsignedDataPerByte = kByteMask;
-static const int8_t kMinDataPerByte = -(1 << (kDataBitsPerByte - 1));
-static const int8_t kMaxDataPerByte = (~kMinDataPerByte & kByteMask);  // NOLINT
-static const uint8_t kEndByteMarker = (255 - kMaxDataPerByte);
-static const uint8_t kEndUnsignedByteMarker = (255 - kMaxUnsignedDataPerByte);
-
+class BaseTextBuffer;
 struct LEB128Constants : AllStatic {
   // Convenience template for ensuring non-signed types trigger SFINAE.
   template <typename T, typename S>
@@ -35,12 +28,13 @@
       typename std::enable_if<std::is_unsigned<T>::value, S>::type;
 
   // (S)LEB128 encodes 7 bits of data per byte (hence 128).
-  static constexpr uint8_t kDataBitsPerByte = 7;
-  static constexpr uint8_t kDataByteMask = (1 << kDataBitsPerByte) - 1;
+  static constexpr size_t kDataBitsPerByte = 7;
+  static constexpr auto kDataByteMask =
+      Utils::NBitMask<uint8_t>(kDataBitsPerByte);
   // If more data follows a given data byte, the high bit is set.
-  static constexpr uint8_t kMoreDataMask = (1 << kDataBitsPerByte);
+  static constexpr auto kMoreDataMask = Utils::Bit<uint8_t>(kDataBitsPerByte);
   // For SLEB128, the high bit in the data of the last byte is the sign bit.
-  static constexpr uint8_t kSignMask = (1 << (kDataBitsPerByte - 1));
+  static constexpr auto kSignMask = Utils::Bit<uint8_t>(kDataBitsPerByte - 1);
 };
 
 class NonStreamingWriteStream;
@@ -93,11 +87,6 @@
     current_ += len;
   }
 
-  template <typename T = intptr_t>
-  T ReadUnsigned() {
-    return Read<T>(kEndUnsignedByteMarker);
-  }
-
   intptr_t Position() const { return current_ - buffer_; }
   void SetPosition(intptr_t value) {
     ASSERT((end_ - buffer_) >= value);
@@ -122,11 +111,6 @@
     return (end_ - current_);
   }
 
-  template <typename T>
-  T Read() {
-    return Read<T>(kEndByteMarker);
-  }
-
   uword ReadWordWith32BitReads() {
     constexpr intptr_t kNumRead32PerWord = kBitsPerWord / kBitsPerInt32;
 
@@ -143,7 +127,7 @@
 
  public:
   template <typename T = uintptr_t>
-  C::only_if_unsigned<T, T> ReadLEB128() {
+  C::only_if_unsigned<T, T> ReadUnsigned() {
     constexpr intptr_t kBitsPerT = kBitsPerByte * sizeof(T);
     T r = 0;
     uint8_t s = 0;
@@ -159,12 +143,12 @@
   }
 
   template <typename T>
-  C::only_if_signed<T, T> ReadLEB128() {
-    return bit_cast<T>(ReadLEB128<typename std::make_unsigned<T>::type>());
+  C::only_if_signed<T, T> ReadUnsigned() {
+    return bit_cast<T>(ReadUnsigned<typename std::make_unsigned<T>::type>());
   }
 
   template <typename T>
-  C::only_if_unsigned<T, T> ReadSLEB128() {
+  C::only_if_unsigned<T, T> Read() {
     constexpr intptr_t kBitsPerT = kBitsPerByte * sizeof(T);
     T r = 0;
     uint8_t s = 0;
@@ -180,114 +164,33 @@
     // value. If the value is negative and the count of data bits is less than
     // the size of the value, then we need to extend the sign by setting the
     // remaining (unset) most significant bits (MSBs).
-    T sign_bits = 0;
     if ((b & C::kSignMask) != 0 && s < kBitsPerT) {
       // Create a bitmask for the current data bits and invert it.
-      sign_bits = ~((static_cast<T>(1) << s) - 1);
+      r |= ~Utils::NBitMask<T>(s);
     }
-    return r | sign_bits;
+    return r;
   }
 
   template <typename T = intptr_t>
-  C::only_if_signed<T, T> ReadSLEB128() {
-    return bit_cast<T>(ReadSLEB128<typename std::make_unsigned<T>::type>());
+  C::only_if_signed<T, T> Read() {
+    return bit_cast<T>(Read<typename std::make_unsigned<T>::type>());
   }
 
  private:
-  uint16_t Read16() { return Read16(kEndByteMarker); }
-
-  uint32_t Read32() { return Read32(kEndByteMarker); }
-
-  uint64_t Read64() { return Read64(kEndByteMarker); }
-
-  template <typename T>
-  T Read(uint8_t end_byte_marker) {
-    using Unsigned = typename std::make_unsigned<T>::type;
-    Unsigned b = ReadByte();
-    if (b > kMaxUnsignedDataPerByte) {
-      return b - end_byte_marker;
-    }
-    T r = 0;
-    uint8_t s = 0;
-    do {
-      r |= static_cast<Unsigned>(b) << s;
-      s += kDataBitsPerByte;
-      b = ReadByte();
-    } while (b <= kMaxUnsignedDataPerByte);
-    return r | (static_cast<Unsigned>(b - end_byte_marker) << s);
-  }
-
-// Setting up needed variables for the unrolled loop sections below.
-#define UNROLLED_INIT()                                                        \
-  using Unsigned = typename std::make_unsigned<T>::type;                       \
-  Unsigned b = ReadByte();                                                     \
-  if (b > kMaxUnsignedDataPerByte) {                                           \
-    return b - end_byte_marker;                                                \
-  }                                                                            \
-  T r = b;
-
-// Part of the unrolled loop where the loop may stop, having read the last part,
-// or continue reading.
-#define UNROLLED_BODY(bit_start)                                               \
-  static_assert(bit_start % kDataBitsPerByte == 0,                             \
-                "Bit start must be a multiple of the data bits per byte");     \
-  static_assert(bit_start >= 0 && bit_start < kBitsPerByte * sizeof(T),        \
-                "Starting unrolled body at invalid bit position");             \
-  static_assert(bit_start + kDataBitsPerByte < kBitsPerByte * sizeof(T),       \
-                "Unrolled body should not contain final bits in value");       \
-  b = ReadByte();                                                              \
-  if (b > kMaxUnsignedDataPerByte) {                                           \
-    return r | (static_cast<T>(b - end_byte_marker) << bit_start);             \
-  }                                                                            \
-  r |= b << bit_start;
-
-// The end of the unrolled loop.
-#define UNROLLED_END(bit_start)                                                \
-  static_assert(bit_start % kDataBitsPerByte == 0,                             \
-                "Bit start must be a multiple of the data bits per byte");     \
-  static_assert(bit_start >= 0 && bit_start < kBitsPerByte * sizeof(T),        \
-                "Starting unrolled end at invalid bit position");              \
-  static_assert(bit_start + kDataBitsPerByte >= kBitsPerByte * sizeof(T),      \
-                "Unrolled end does not contain final bits in value");          \
-  b = ReadByte();                                                              \
-  ASSERT(b > kMaxUnsignedDataPerByte);                                         \
-  return r | (static_cast<T>(b - end_byte_marker) << bit_start);
-
-  uint16_t Read16(uint8_t end_byte_marker) {
-    using T = uint16_t;
-    UNROLLED_INIT();
-    UNROLLED_BODY(7);
-    UNROLLED_END(14);
-  }
-
-  uint32_t Read32(uint8_t end_byte_marker) {
-    using T = uint32_t;
-    UNROLLED_INIT();
-    UNROLLED_BODY(7);
-    UNROLLED_BODY(14);
-    UNROLLED_BODY(21);
-    UNROLLED_END(28);
-  }
-
-  uint64_t Read64(uint8_t end_byte_marker) {
-    using T = uint64_t;
-    UNROLLED_INIT();
-    UNROLLED_BODY(7);
-    UNROLLED_BODY(14);
-    UNROLLED_BODY(21);
-    UNROLLED_BODY(28);
-    UNROLLED_BODY(35);
-    UNROLLED_BODY(42);
-    UNROLLED_BODY(49);
-    UNROLLED_BODY(56);
-    UNROLLED_END(63);
-  }
+  uint16_t Read16();
+  uint32_t Read32();
+  uint64_t Read64();
 
   DART_FORCE_INLINE uint8_t ReadByte() {
     ASSERT(current_ < end_);
     return *current_++;
   }
 
+  void WriteWindow(BaseTextBuffer* buffer,
+                   intptr_t start,
+                   intptr_t window_size = 64);
+  void PrintWindow(intptr_t start, intptr_t window_size = 64);
+
  private:
   const uint8_t* buffer_;
   const uint8_t* current_;
@@ -364,16 +267,6 @@
     }
   }
 
-  template <typename T>
-  void WriteUnsigned(T value) {
-    ASSERT(value >= 0);
-    while (value > kMaxUnsignedDataPerByte) {
-      WriteByte(static_cast<uint8_t>(value & kByteMask));
-      value = value >> kDataBitsPerByte;
-    }
-    WriteByte(static_cast<uint8_t>(value + kEndUnsignedByteMarker));
-  }
-
   void WriteBytes(const void* addr, intptr_t len) {
     if (len != 0) {
       EnsureSpace(len);
@@ -413,16 +306,6 @@
   }
 
   template <typename T>
-  void Write(T value) {
-    T v = value;
-    while (v < kMinDataPerByte || v > kMaxDataPerByte) {
-      WriteByte(static_cast<uint8_t>(v & kByteMask));
-      v = v >> kDataBitsPerByte;
-    }
-    WriteByte(static_cast<uint8_t>(v + kEndByteMarker));
-  }
-
-  template <typename T>
   void WriteFixed(T value) {
     WriteBytes(&value, sizeof(value));
   }
@@ -439,7 +322,7 @@
 
  public:
   template <typename T>
-  C::only_if_unsigned<T, void> WriteLEB128(T value) {
+  C::only_if_unsigned<T, void> WriteUnsigned(T value) {
     T remainder = value;
     bool is_last_part;
     do {
@@ -456,15 +339,15 @@
   }
 
   template <typename T>
-  C::only_if_signed<T, void> WriteLEB128(T value) {
+  C::only_if_signed<T, void> WriteUnsigned(T value) {
     // If we're trying to LEB128 encode a negative value, chances are we should
     // be using SLEB128 instead.
     ASSERT(value >= 0);
-    return WriteLEB128(bit_cast<typename std::make_unsigned<T>::type>(value));
+    return WriteUnsigned(bit_cast<typename std::make_unsigned<T>::type>(value));
   }
 
   template <typename T>
-  C::only_if_signed<T, void> WriteSLEB128(T value) {
+  C::only_if_signed<T, void> Write(T value) {
     constexpr intptr_t kBitsPerT = kBitsPerByte * sizeof(T);
     using Unsigned = typename std::make_unsigned<T>::type;
     // Record whether the original value was negative.
@@ -509,8 +392,8 @@
   }
 
   template <typename T>
-  C::only_if_unsigned<T, void> WriteSLEB128(T value) {
-    return WriteSLEB128(bit_cast<typename std::make_signed<T>::type>(value));
+  C::only_if_unsigned<T, void> Write(T value) {
+    return Write(bit_cast<typename std::make_signed<T>::type>(value));
   }
 
  protected:
diff --git a/runtime/vm/datastream_test.cc b/runtime/vm/datastream_test.cc
index 0b9ba6c..ec8eb5b 100644
--- a/runtime/vm/datastream_test.cc
+++ b/runtime/vm/datastream_test.cc
@@ -126,60 +126,4 @@
   TestRaw<int64_t>();
 }
 
-TEST_CASE(BaseWriteStream_WriteLEB128) {
-  MallocWriteStream writer(1 * KB);
-  for (uintptr_t i = 0; i < kUnsignedEnd; i++) {
-    writer.WriteLEB128(i);
-  }
-  DEFINE_LARGE_CONSTANTS(uintptr_t);
-  writer.WriteLEB128(all_ones);
-  writer.WriteLEB128(min);
-  writer.WriteLEB128(max);
-  writer.WriteLEB128(half_min);
-  writer.WriteLEB128(half_max);
-  ReadStream reader(writer.buffer(), writer.bytes_written());
-  for (uintptr_t i = 0; i < kUnsignedEnd; i++) {
-    const uintptr_t r = reader.ReadLEB128();
-    EXPECT_EQ(i, r);
-  }
-  const uintptr_t read_all_ones = reader.ReadLEB128();
-  EXPECT_EQ(all_ones, read_all_ones);
-  const uintptr_t read_min = reader.ReadLEB128();
-  EXPECT_EQ(min, read_min);
-  const uintptr_t read_max = reader.ReadLEB128();
-  EXPECT_EQ(max, read_max);
-  const uintptr_t read_half_min = reader.ReadLEB128();
-  EXPECT_EQ(half_min, read_half_min);
-  const uintptr_t read_half_max = reader.ReadLEB128();
-  EXPECT_EQ(half_max, read_half_max);
-}
-
-TEST_CASE(BaseWriteStream_WriteSLEB128) {
-  MallocWriteStream writer(1 * KB);
-  for (intptr_t i = kSignedStart; i < kSignedEnd; i++) {
-    writer.WriteSLEB128(i);
-  }
-  DEFINE_LARGE_CONSTANTS(intptr_t);
-  writer.WriteSLEB128(all_ones);
-  writer.WriteSLEB128(min);
-  writer.WriteSLEB128(max);
-  writer.WriteSLEB128(half_min);
-  writer.WriteSLEB128(half_max);
-  ReadStream reader(writer.buffer(), writer.bytes_written());
-  for (intptr_t i = kSignedStart; i < kSignedEnd; i++) {
-    const intptr_t r = reader.ReadSLEB128();
-    EXPECT_EQ(i, r);
-  }
-  const intptr_t read_all_ones = reader.ReadSLEB128();
-  EXPECT_EQ(all_ones, read_all_ones);
-  const intptr_t read_min = reader.ReadSLEB128();
-  EXPECT_EQ(min, read_min);
-  const intptr_t read_max = reader.ReadSLEB128();
-  EXPECT_EQ(max, read_max);
-  const intptr_t read_half_min = reader.ReadSLEB128();
-  EXPECT_EQ(half_min, read_half_min);
-  const intptr_t read_half_max = reader.ReadSLEB128();
-  EXPECT_EQ(half_max, read_half_max);
-}
-
 }  // namespace dart
diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc
index 7f17df5..dd11e4d 100644
--- a/runtime/vm/elf.cc
+++ b/runtime/vm/elf.cc
@@ -1106,8 +1106,8 @@
         stream_(ASSERT_NOTNULL(stream)),
         table_(table) {}
 
-  void sleb128(intptr_t value) { stream_->WriteSLEB128(value); }
-  void uleb128(uintptr_t value) { stream_->WriteLEB128(value); }
+  void sleb128(intptr_t value) { stream_->Write(value); }
+  void uleb128(uintptr_t value) { stream_->WriteUnsigned(value); }
   void u1(uint8_t value) { stream_->WriteByte(value); }
   void u2(uint16_t value) { stream_->WriteFixed(value); }
   void u4(uint32_t value) { stream_->WriteFixed(value); }
diff --git a/runtime/vm/kernel_binary.h b/runtime/vm/kernel_binary.h
index 38ca8fa..c14919a 100644
--- a/runtime/vm/kernel_binary.h
+++ b/runtime/vm/kernel_binary.h
@@ -309,14 +309,14 @@
 
   intptr_t ReadSLEB128() {
     ReadStream stream(this->buffer(), size_, offset_);
-    const intptr_t result = stream.ReadSLEB128();
+    const intptr_t result = stream.Read();
     offset_ = stream.Position();
     return result;
   }
 
   int64_t ReadSLEB128AsInt64() {
     ReadStream stream(this->buffer(), size_, offset_);
-    const int64_t result = stream.ReadSLEB128<int64_t>();
+    const int64_t result = stream.Read<int64_t>();
     offset_ = stream.Position();
     return result;
   }
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index ac92f8f..772a483 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -14660,7 +14660,7 @@
   NoSafepointScope scope;
   ReadStream stream(maps_.untag()->data(), maps_.payload_size(), next_offset_);
 
-  auto const pc_delta = stream.ReadLEB128();
+  auto const pc_delta = stream.ReadUnsigned();
   ASSERT(pc_delta <= (kMaxUint32 - current_pc_offset_));
   current_pc_offset_ += pc_delta;
 
@@ -14668,7 +14668,7 @@
   // the post-delta part of inlined entries has the same information as
   // global table entries.
   if (maps_.UsesGlobalTable()) {
-    current_global_table_offset_ = stream.ReadLEB128();
+    current_global_table_offset_ = stream.ReadUnsigned();
     ASSERT(current_global_table_offset_ < bits_container_.payload_size());
 
     // Since generally we only use entries in the GC and the GC only needs
@@ -14681,10 +14681,10 @@
 
     next_offset_ = stream.Position();
   } else {
-    current_spill_slot_bit_count_ = stream.ReadLEB128();
+    current_spill_slot_bit_count_ = stream.ReadUnsigned();
     ASSERT(current_spill_slot_bit_count_ >= 0);
 
-    current_non_spill_slot_bit_count_ = stream.ReadLEB128();
+    current_non_spill_slot_bit_count_ = stream.ReadUnsigned();
     ASSERT(current_non_spill_slot_bit_count_ >= 0);
 
     const auto stackmap_bits =
@@ -14730,10 +14730,10 @@
                     bits_container_.payload_size(),
                     current_global_table_offset_);
 
-  current_spill_slot_bit_count_ = stream.ReadLEB128();
+  current_spill_slot_bit_count_ = stream.ReadUnsigned();
   ASSERT(current_spill_slot_bit_count_ >= 0);
 
-  current_non_spill_slot_bit_count_ = stream.ReadLEB128();
+  current_non_spill_slot_bit_count_ = stream.ReadUnsigned();
   ASSERT(current_non_spill_slot_bit_count_ >= 0);
 
   const auto stackmap_bits = Length();
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 9ddb727..a03be0a 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -5641,7 +5641,7 @@
                         byte_index_);
       // Moves to record that matches kind_mask_.
       while (byte_index_ < descriptors_.Length()) {
-        const int32_t kind_and_metadata = stream.ReadSLEB128<int32_t>();
+        const int32_t kind_and_metadata = stream.Read<int32_t>();
         cur_kind_ = UntaggedPcDescriptors::KindAndMetadata::DecodeKind(
             kind_and_metadata);
         cur_try_index_ = UntaggedPcDescriptors::KindAndMetadata::DecodeTryIndex(
@@ -5650,12 +5650,12 @@
             UntaggedPcDescriptors::KindAndMetadata::DecodeYieldIndex(
                 kind_and_metadata);
 
-        cur_pc_offset_ += stream.ReadSLEB128();
+        cur_pc_offset_ += stream.Read();
 
         if (!FLAG_precompiled_mode) {
-          cur_deopt_id_ += stream.ReadSLEB128();
-          cur_token_pos_ = Utils::AddWithWrapAround(
-              cur_token_pos_, stream.ReadSLEB128<int32_t>());
+          cur_deopt_id_ += stream.Read();
+          cur_token_pos_ =
+              Utils::AddWithWrapAround(cur_token_pos_, stream.Read<int32_t>());
         }
         byte_index_ = stream.Position();
 
diff --git a/runtime/vm/program_visitor.cc b/runtime/vm/program_visitor.cc
index 4bb663a..e90c8ad 100644
--- a/runtime/vm/program_visitor.cc
+++ b/runtime/vm/program_visitor.cc
@@ -502,8 +502,8 @@
   // initial offset of the entry in the array.
   intptr_t EncodeTo(NonStreamingWriteStream* stream) {
     auto const current_offset = stream->Position();
-    stream->WriteLEB128(spill_slot_bit_count_);
-    stream->WriteLEB128(non_spill_slot_bit_count_);
+    stream->WriteUnsigned(spill_slot_bit_count_);
+    stream->WriteUnsigned(non_spill_slot_bit_count_);
     {
       NoSafepointScope scope;
       stream->WriteBytes(PayloadData(), PayloadLength());
@@ -711,8 +711,8 @@
         StackMapEntry entry(zone_, it);
         const intptr_t entry_offset = entry_offsets_.LookupValue(&entry);
         const intptr_t pc_delta = it.pc_offset() - last_offset;
-        new_payload.WriteLEB128(pc_delta);
-        new_payload.WriteLEB128(entry_offset);
+        new_payload.WriteUnsigned(pc_delta);
+        new_payload.WriteUnsigned(entry_offset);
         last_offset = it.pc_offset();
       }
       return CompressedStackMaps::NewUsingTable(new_payload.buffer(),
diff --git a/runtime/vm/v8_snapshot_writer.h b/runtime/vm/v8_snapshot_writer.h
index ea0a0e7..99ba832 100644
--- a/runtime/vm/v8_snapshot_writer.h
+++ b/runtime/vm/v8_snapshot_writer.h
@@ -58,7 +58,7 @@
    private:
     static constexpr size_t kIdSpaceBits =
         Utils::BitLength(static_cast<int64_t>(IdSpace::kArtificial));
-    static constexpr int64_t kIdSpaceMask = Utils::NBitMaskUnsafe(kIdSpaceBits);
+    static constexpr int64_t kIdSpaceMask = Utils::NBitMask(kIdSpaceBits);
     static const char* IdSpaceToCString(IdSpace space);
 
     int64_t encoded_;
diff --git a/tools/VERSION b/tools/VERSION
index 1a63460..7713491 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 14
 PATCH 0
-PRERELEASE 33
+PRERELEASE 34
 PRERELEASE_PATCH 0
\ No newline at end of file