Fix some more shorten-64-to-32 warnings:
- Remove duplicate check for javascript integer overflow.
- Make sure the BitField class knows the type it is
  encoding into.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1644223006 .
diff --git a/runtime/platform/utils.h b/runtime/platform/utils.h
index 9e4a384..508e0e7 100644
--- a/runtime/platform/utils.h
+++ b/runtime/platform/utils.h
@@ -204,16 +204,9 @@
 
   // dart2js represents integers as double precision floats, which can
   // represent anything in the range -2^53 ... 2^53.
-  static bool IsJavascriptInt64(int64_t value) {
+  static bool IsJavascriptInt(int64_t value) {
     return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL));
   }
-  static bool IsJavascriptInt(intptr_t value) {
-#if defined(ARCH_IS_64BIT)
-    return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL));
-#else
-    return true;
-#endif
-  }
 
   static char* StrError(int err, char* buffer, size_t bufsize);
 };
diff --git a/runtime/vm/bitfield.h b/runtime/vm/bitfield.h
index 6108065..42a121a 100644
--- a/runtime/vm/bitfield.h
+++ b/runtime/vm/bitfield.h
@@ -9,26 +9,26 @@
 
 static const uword kUwordOne = 1U;
 
-// BitField is a template for encoding and decoding a bit field inside
-// an unsigned machine word.
-template<typename T, int position, int size>
+// BitField is a template for encoding and decoding a value of type T
+// inside a storage of type S.
+template<typename S, typename T, int position, int size>
 class BitField {
  public:
   static const intptr_t kNextBit = position + size;
 
   // Tells whether the provided value fits into the bit field.
   static bool is_valid(T value) {
-    return (static_cast<uword>(value) & ~((kUwordOne << size) - 1)) == 0;
+    return (static_cast<S>(value) & ~((kUwordOne << size) - 1)) == 0;
   }
 
-  // Returns a uword mask of the bit field.
-  static uword mask() {
+  // Returns a S mask of the bit field.
+  static S mask() {
     return (kUwordOne << size) - 1;
   }
 
-  // Returns a uword mask of the bit field which can be applied directly to
+  // Returns a S mask of the bit field which can be applied directly to
   // to the raw unshifted bits.
-  static uword mask_in_place() {
+  static S mask_in_place() {
     return ((kUwordOne << size) - 1) << position;
   }
 
@@ -43,23 +43,24 @@
     return size;
   }
 
-  // Returns a uword with the bit field value encoded.
-  static uword encode(T value) {
+  // Returns an S with the bit field value encoded.
+  static S encode(T value) {
+    COMPILE_ASSERT((sizeof(S) * kBitsPerByte) >= (position + size));
     ASSERT(is_valid(value));
-    return static_cast<uword>(value) << position;
+    return static_cast<S>(value) << position;
   }
 
   // Extracts the bit field from the value.
-  static T decode(uword value) {
+  static T decode(S value) {
     return static_cast<T>((value >> position) & ((kUwordOne << size) - 1));
   }
 
-  // Returns a uword with the bit field value encoded based on the
+  // Returns an S with the bit field value encoded based on the
   // original value. Only the bits corresponding to this bit field
   // will be changed.
-  static uword update(T value, uword original) {
+  static S update(T value, S original) {
     ASSERT(is_valid(value));
-    return (static_cast<uword>(value) << position) |
+    return (static_cast<S>(value) << position) |
         (~mask_in_place() & original);
   }
 };
diff --git a/runtime/vm/bitfield_test.cc b/runtime/vm/bitfield_test.cc
index 7728b29..a9d41c9 100644
--- a/runtime/vm/bitfield_test.cc
+++ b/runtime/vm/bitfield_test.cc
@@ -10,7 +10,7 @@
 namespace dart {
 
 UNIT_TEST_CASE(BitFields) {
-  class TestBitFields : public BitField<int32_t, 1, 8> {};
+  class TestBitFields : public BitField<uword, int32_t, 1, 8> {};
   EXPECT(TestBitFields::is_valid(16));
   EXPECT(!TestBitFields::is_valid(256));
   EXPECT_EQ(0x00ffU, TestBitFields::mask());
diff --git a/runtime/vm/class_table.h b/runtime/vm/class_table.h
index aaabdf4..aa8c366 100644
--- a/runtime/vm/class_table.h
+++ b/runtime/vm/class_table.h
@@ -132,7 +132,8 @@
     kTraceAllocationBit = 0,
   };
 
-  class TraceAllocationBit : public BitField<bool, kTraceAllocationBit, 1> {};
+  class TraceAllocationBit :
+      public BitField<intptr_t, bool, kTraceAllocationBit, 1> {};
 
   // Recent old at start of last new GC (used to compute promoted_*).
   intptr_t old_pre_new_gc_count_;
diff --git a/runtime/vm/dart_api_state.h b/runtime/vm/dart_api_state.h
index e0f6e00..ec005b6 100644
--- a/runtime/vm/dart_api_state.h
+++ b/runtime/vm/dart_api_state.h
@@ -261,12 +261,14 @@
 
   // This part of external_data_ is the number of externally allocated bytes.
   // TODO(koda): Measure size in words instead.
-  class ExternalSizeBits : public BitField<intptr_t,
+  class ExternalSizeBits : public BitField<uword,
+                                           intptr_t,
                                            kExternalSizeBits,
-                                           kExternalSizeBitsSize> {};  // NOLINT
+                                           kExternalSizeBitsSize> {};
   // This bit of external_data_ is true if the referent was created in new
   // space and UpdateRelocated has not yet detected any promotion.
-  class ExternalNewSpaceBit : public BitField<bool, kExternalNewSpaceBit, 1> {};
+  class ExternalNewSpaceBit :
+      public BitField<uword, bool, kExternalNewSpaceBit, 1> {};
 
   friend class FinalizablePersistentHandles;
 
diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc
index 5d985a3..bdb5035 100644
--- a/runtime/vm/deopt_instructions.cc
+++ b/runtime/vm/deopt_instructions.cc
@@ -423,8 +423,10 @@
 
  private:
   static const intptr_t kFieldWidth = kBitsPerWord / 2;
-  class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { };
-  class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { };
+  class ObjectTableIndex :
+      public BitField<intptr_t, intptr_t, 0, kFieldWidth> { };
+  class DeoptId :
+      public BitField<intptr_t, intptr_t, kFieldWidth, kFieldWidth> { };
 
   const intptr_t object_table_index_;
   const intptr_t deopt_id_;
@@ -547,8 +549,9 @@
 
  private:
   static const intptr_t kFieldWidth = kBitsPerWord / 2;
-  class LoRegister : public BitField<intptr_t, 0, kFieldWidth> { };
-  class HiRegister : public BitField<intptr_t, kFieldWidth, kFieldWidth> { };
+  class LoRegister : public BitField<intptr_t, intptr_t, 0, kFieldWidth> { };
+  class HiRegister :
+      public BitField<intptr_t, intptr_t, kFieldWidth, kFieldWidth> { };
 
   const CpuRegisterSource lo_;
   const CpuRegisterSource hi_;
diff --git a/runtime/vm/deopt_instructions.h b/runtime/vm/deopt_instructions.h
index acbf92b..3dd538f 100644
--- a/runtime/vm/deopt_instructions.h
+++ b/runtime/vm/deopt_instructions.h
@@ -399,8 +399,9 @@
   }
 
  private:
-  class KindField : public BitField<intptr_t, 0, 1> { };
-  class RawIndexField : public BitField<intptr_t, 1, kBitsPerWord - 1> { };
+  class KindField : public BitField<intptr_t, intptr_t, 0, 1> { };
+  class RawIndexField :
+      public BitField<intptr_t, intptr_t, 1, kBitsPerWord - 1> { };
 
   bool is_register() const {
     return KindField::decode(source_index_) == kRegister;
@@ -543,8 +544,9 @@
                     FlagsField::encode(flags));
   }
 
-  class ReasonField : public BitField<ICData::DeoptReasonId, 0, 8> { };
-  class FlagsField : public BitField<uint32_t, 8, 8> { };
+  class ReasonField :
+      public BitField<intptr_t, ICData::DeoptReasonId, 0, 8> { };
+  class FlagsField : public BitField<intptr_t, uint32_t, 8, 8> { };
 
  private:
   static const intptr_t kEntrySize = 3;
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index 7b31036..848cdb0 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -5822,10 +5822,11 @@
     return offset & ~(ElementSizeMultiplier(size) - 1);
   }
 
-  typedef BitField<Kind, 0, 3> KindBits;
-  typedef BitField<Representation, KindBits::kNextBit, 11> RepresentationBits;
-  typedef BitField<
-      ElementSize, RepresentationBits::kNextBit, 3> ElementSizeBits;
+  class KindBits : public BitField<uword, Kind, 0, 3> {};
+  class RepresentationBits :
+      public BitField<uword, Representation, KindBits::kNextBit, 11> {};
+  class ElementSizeBits :
+      public BitField<uword, ElementSize, RepresentationBits::kNextBit, 3> {};
 
   uword flags_;
   Definition* instance_;
diff --git a/runtime/vm/locations.h b/runtime/vm/locations.h
index 047b663..963c4b4 100644
--- a/runtime/vm/locations.h
+++ b/runtime/vm/locations.h
@@ -387,19 +387,20 @@
     return PayloadField::decode(value_);
   }
 
-  typedef BitField<Kind, 0, kBitsForKind> KindField;
-  typedef BitField<uword, kBitsForKind, kBitsForPayload> PayloadField;
+  class KindField : public BitField<uword, Kind, 0, kBitsForKind> {};
+  class PayloadField :
+      public BitField<uword, uword, kBitsForKind, kBitsForPayload> {};
 
   // Layout for kUnallocated locations payload.
-  typedef BitField<Policy, 0, 3> PolicyField;
+  typedef BitField<uword, Policy, 0, 3> PolicyField;
 
   // Layout for stack slots.
   static const intptr_t kBitsForBaseReg = 5;
   static const intptr_t kBitsForStackIndex = kBitsForPayload - kBitsForBaseReg;
-  typedef BitField<Register, 0, kBitsForBaseReg> StackSlotBaseField;
-  typedef BitField<intptr_t,
-                   kBitsForBaseReg,
-                   kBitsForStackIndex> StackIndexField;
+  class StackSlotBaseField :
+      public BitField<uword, Register, 0, kBitsForBaseReg> {};
+  class StackIndexField :
+      public BitField<uword, intptr_t, kBitsForBaseReg, kBitsForStackIndex> {};
   COMPILE_ASSERT(1 << kBitsForBaseReg >= kNumberOfCpuRegisters);
 
   static const intptr_t kStackIndexBias =
diff --git a/runtime/vm/native_arguments.h b/runtime/vm/native_arguments.h
index 028b58b..8bb1d6e 100644
--- a/runtime/vm/native_arguments.h
+++ b/runtime/vm/native_arguments.h
@@ -189,9 +189,11 @@
     kFunctionSize = 2,
     kAutoSetupScopeBit = 26,
   };
-  class ArgcBits : public BitField<int, kArgcBit, kArgcSize> {};
-  class FunctionBits : public BitField<int, kFunctionBit, kFunctionSize> {};
-  class AutoSetupScopeBits : public BitField<int, kAutoSetupScopeBit, 1> {};
+  class ArgcBits : public BitField<intptr_t, int32_t, kArgcBit, kArgcSize> {};
+  class FunctionBits :
+      public BitField<intptr_t, int, kFunctionBit, kFunctionSize> {};
+  class AutoSetupScopeBits :
+      public BitField<intptr_t, int, kAutoSetupScopeBit, 1> {};
   friend class Api;
   friend class BootstrapNatives;
   friend class Simulator;
@@ -226,7 +228,7 @@
   }
 
   Thread* thread_;  // Current thread pointer.
-  int argc_tag_;  // Encodes argument count and invoked native call type.
+  intptr_t argc_tag_;  // Encodes argument count and invoked native call type.
   RawObject*(*argv_)[];  // Pointer to an array of arguments to runtime call.
   RawObject** retval_;  // Pointer to the return value area.
 };
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index d1d590c..340735f 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -17994,7 +17994,7 @@
   const bool is_smi = Smi::IsValid(value);
   if (!silent &&
       FLAG_throw_on_javascript_int_overflow &&
-      !Utils::IsJavascriptInt64(value)) {
+      !Utils::IsJavascriptInt(value)) {
     const Integer& i = is_smi ?
         Integer::Handle(Smi::New(static_cast<intptr_t>(value))) :
         Integer::Handle(Mint::New(value, space));
@@ -18092,7 +18092,7 @@
       value = AsInt64Value();
     }
   }
-  return !Utils::IsJavascriptInt64(value);
+  return !Utils::IsJavascriptInt(value);
 }
 
 
@@ -18114,7 +18114,9 @@
   if (Bigint::Cast(*this).FitsIntoInt64()) {
     const int64_t value = AsInt64Value();
     if (Smi::IsValid(value)) {
-      return Smi::New(value);
+      // This cast is safe because Smi::IsValid verifies that value will fit.
+      intptr_t val = static_cast<intptr_t>(value);
+      return Smi::New(val);
     }
     return Mint::New(value);
   }
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 30f6ca0..a78a0f4 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1362,22 +1362,29 @@
     kEnumBit = 13,
     kIsAllocatedBit = 15,
   };
-  class ConstBit : public BitField<bool, kConstBit, 1> {};
-  class ImplementedBit : public BitField<bool, kImplementedBit, 1> {};
-  class TypeFinalizedBit : public BitField<bool, kTypeFinalizedBit, 1> {};
-  class ClassFinalizedBits : public BitField<RawClass::ClassFinalizedState,
-      kClassFinalizedPos, kClassFinalizedSize> {};  // NOLINT
-  class AbstractBit : public BitField<bool, kAbstractBit, 1> {};
-  class PatchBit : public BitField<bool, kPatchBit, 1> {};
-  class SynthesizedClassBit : public BitField<bool, kSynthesizedClassBit, 1> {};
-  class MarkedForParsingBit : public BitField<bool, kMarkedForParsingBit, 1> {};
-  class MixinAppAliasBit : public BitField<bool, kMixinAppAliasBit, 1> {};
-  class MixinTypeAppliedBit : public BitField<bool, kMixinTypeAppliedBit, 1> {};
-  class FieldsMarkedNullableBit : public BitField<bool,
-      kFieldsMarkedNullableBit, 1> {};  // NOLINT
-  class CycleFreeBit : public BitField<bool, kCycleFreeBit, 1> {};
-  class EnumBit : public BitField<bool, kEnumBit, 1> {};
-  class IsAllocatedBit : public BitField<bool, kIsAllocatedBit, 1> {};
+  class ConstBit : public BitField<uint16_t, bool, kConstBit, 1> {};
+  class ImplementedBit : public BitField<uint16_t, bool, kImplementedBit, 1> {};
+  class TypeFinalizedBit :
+      public BitField<uint16_t, bool, kTypeFinalizedBit, 1> {};
+  class ClassFinalizedBits : public BitField<uint16_t,
+                                             RawClass::ClassFinalizedState,
+                                             kClassFinalizedPos,
+                                             kClassFinalizedSize> {};
+  class AbstractBit : public BitField<uint16_t, bool, kAbstractBit, 1> {};
+  class PatchBit : public BitField<uint16_t, bool, kPatchBit, 1> {};
+  class SynthesizedClassBit :
+      public BitField<uint16_t, bool, kSynthesizedClassBit, 1> {};
+  class MarkedForParsingBit :
+      public BitField<uint16_t, bool, kMarkedForParsingBit, 1> {};
+  class MixinAppAliasBit :
+      public BitField<uint16_t, bool, kMixinAppAliasBit, 1> {};
+  class MixinTypeAppliedBit :
+      public BitField<uint16_t, bool, kMixinTypeAppliedBit, 1> {};
+  class FieldsMarkedNullableBit :
+      public BitField<uint16_t, bool, kFieldsMarkedNullableBit, 1> {};
+  class CycleFreeBit : public BitField<uint16_t, bool, kCycleFreeBit, 1> {};
+  class EnumBit : public BitField<uint16_t, bool, kEnumBit, 1> {};
+  class IsAllocatedBit : public BitField<uint16_t, bool, kIsAllocatedBit, 1> {};
 
   void set_name(const String& value) const;
   void set_pretty_name(const String& value) const;
@@ -2037,12 +2044,19 @@
   };
 
   class NumArgsTestedBits : public BitField<uint32_t,
-      kNumArgsTestedPos, kNumArgsTestedSize> {};  // NOLINT
+                                            uint32_t,
+                                            kNumArgsTestedPos,
+                                            kNumArgsTestedSize> {};
   class DeoptReasonBits : public BitField<uint32_t,
-      ICData::kDeoptReasonPos, ICData::kDeoptReasonSize> {};  // NOLINT
-  class IssuedJSWarningBit : public BitField<bool, kIssuedJSWarningBit, 1> {};
+                                          uint32_t,
+                                          ICData::kDeoptReasonPos,
+                                          ICData::kDeoptReasonSize> {};
+  class IssuedJSWarningBit :
+      public BitField<uint32_t, bool, kIssuedJSWarningBit, 1> {};
   class RangeFeedbackBits : public BitField<uint32_t,
-      ICData::kRangeFeedbackPos, ICData::kRangeFeedbackSize> {};  // NOLINT
+                                            uint32_t,
+                                            ICData::kRangeFeedbackPos,
+                                            ICData::kRangeFeedbackSize> {};
 
 #if defined(DEBUG)
   // Used in asserts to verify that a check is not added twice.
@@ -2732,18 +2746,19 @@
       (kBitsPerByte * sizeof(static_cast<RawFunction*>(0)->kind_tag_)));
 
   class KindBits :
-    public BitField<RawFunction::Kind, kKindTagPos, kKindTagSize> {};  // NOLINT
+    public BitField<uint32_t, RawFunction::Kind, kKindTagPos, kKindTagSize> {};
 
-  class RecognizedBits : public BitField<MethodRecognizer::Kind,
+  class RecognizedBits : public BitField<uint32_t,
+                                         MethodRecognizer::Kind,
                                          kRecognizedTagPos,
                                          kRecognizedTagSize> {};
-  class ModifierBits :
-    public BitField<RawFunction::AsyncModifier,
-                   kModifierPos,
-                   kModifierSize> {};  // NOLINT
+  class ModifierBits : public BitField<uint32_t,
+                                       RawFunction::AsyncModifier,
+                                       kModifierPos,
+                                       kModifierSize> {};
 
 #define DEFINE_BIT(name, _) \
-  class name##Bit : public BitField<bool, k##name##Bit, 1> {};
+  class name##Bit : public BitField<uint32_t, bool, k##name##Bit, 1> {};
 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT)
 #undef DEFINE_BIT
 
@@ -3080,15 +3095,16 @@
     kReflectableBit,
     kDoubleInitializedBit,
   };
-  class ConstBit : public BitField<bool, kConstBit, 1> {};
-  class StaticBit : public BitField<bool, kStaticBit, 1> {};
-  class FinalBit : public BitField<bool, kFinalBit, 1> {};
-  class HasInitializerBit : public BitField<bool, kHasInitializerBit, 1> {};
-  class UnboxingCandidateBit : public BitField<bool,
-                                               kUnboxingCandidateBit, 1> {};
-  class ReflectableBit : public BitField<bool, kReflectableBit, 1> {};
-  class DoubleInitializedBit : public BitField<bool,
-                                               kDoubleInitializedBit, 1> {};
+  class ConstBit : public BitField<uint8_t, bool, kConstBit, 1> {};
+  class StaticBit : public BitField<uint8_t, bool, kStaticBit, 1> {};
+  class FinalBit : public BitField<uint8_t, bool, kFinalBit, 1> {};
+  class HasInitializerBit :
+      public BitField<uint8_t, bool, kHasInitializerBit, 1> {};
+  class UnboxingCandidateBit :
+      public BitField<uint8_t, bool, kUnboxingCandidateBit, 1> {};
+  class ReflectableBit : public BitField<uint8_t, bool, kReflectableBit, 1> {};
+  class DoubleInitializedBit :
+      public BitField<uint8_t, bool, kDoubleInitializedBit, 1> {};
 
   // Update guarded cid and guarded length for this field. Returns true, if
   // deoptimization of dependent code is required.
@@ -3110,8 +3126,8 @@
   void set_token_pos(TokenPosition token_pos) const {
     StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
   }
-  void set_kind_bits(intptr_t value) const {
-    StoreNonPointer(&raw_ptr()->kind_bits_, static_cast<uint8_t>(value));
+  void set_kind_bits(uint8_t value) const {
+    StoreNonPointer(&raw_ptr()->kind_bits_, value);
   }
 
   static RawField* New();
@@ -4520,9 +4536,10 @@
     kPtrOffSize = 30,
   };
 
-  class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {};
-  class AliveBit : public BitField<bool, kAliveBit, 1> {};
-  class PtrOffBits : public BitField<intptr_t, kPtrOffBit, kPtrOffSize> {};
+  class OptimizedBit : public BitField<int32_t, bool, kOptimizedBit, 1> {};
+  class AliveBit : public BitField<int32_t, bool, kAliveBit, 1> {};
+  class PtrOffBits :
+      public BitField<int32_t, intptr_t, kPtrOffBit, kPtrOffSize> {};
 
   class SlowFindRawCodeVisitor : public FindObjectVisitor {
    public:
@@ -8016,8 +8033,8 @@
     kFlagsSize = 4,
   };
 
-  class TypeBits : public BitField<RegExType, kTypePos, kTypeSize> {};
-  class FlagsBits : public BitField<intptr_t, kFlagsPos, kFlagsSize> {};
+  class TypeBits : public BitField<int8_t, RegExType, kTypePos, kTypeSize> {};
+  class FlagsBits : public BitField<int8_t, intptr_t, kFlagsPos, kFlagsSize> {};
 
   bool is_initialized() const { return (type() != kUnitialized); }
   bool is_simple() const { return (type() == kSimple); }
diff --git a/runtime/vm/profiler.h b/runtime/vm/profiler.h
index c755890..e4f6c8d 100644
--- a/runtime/vm/profiler.h
+++ b/runtime/vm/profiler.h
@@ -340,17 +340,19 @@
     kClassAllocationSampleBit = 6,
     kContinuationSampleBit = 7,
   };
-  class HeadSampleBit : public BitField<bool, kHeadSampleBit, 1> {};
-  class LeafFrameIsDart : public BitField<bool, kLeafFrameIsDartBit, 1> {};
-  class IgnoreBit : public BitField<bool, kIgnoreBit, 1> {};
-  class ExitFrameBit : public BitField<bool, kExitFrameBit, 1> {};
+  class HeadSampleBit : public BitField<uword, bool, kHeadSampleBit, 1> {};
+  class LeafFrameIsDart :
+      public BitField<uword, bool, kLeafFrameIsDartBit, 1> {};
+  class IgnoreBit : public BitField<uword, bool, kIgnoreBit, 1> {};
+  class ExitFrameBit : public BitField<uword, bool, kExitFrameBit, 1> {};
   class MissingFrameInsertedBit
-      : public BitField<bool, kMissingFrameInsertedBit, 1> {};
-  class TruncatedTraceBit : public BitField<bool, kTruncatedTraceBit, 1> {};
+      : public BitField<uword, bool, kMissingFrameInsertedBit, 1> {};
+  class TruncatedTraceBit :
+      public BitField<uword, bool, kTruncatedTraceBit, 1> {};
   class ClassAllocationSampleBit
-      : public BitField<bool, kClassAllocationSampleBit, 1> {};
+      : public BitField<uword, bool, kClassAllocationSampleBit, 1> {};
   class ContinuationSampleBit
-      : public BitField<bool, kContinuationSampleBit, 1> {};
+      : public BitField<uword, bool, kContinuationSampleBit, 1> {};
 
   int64_t timestamp_;
   ThreadId tid_;
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index 67520f5..f4b07eb 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -285,7 +285,8 @@
 
    private:
     // The actual unscaled bit field used within the tag field.
-    class SizeBits : public BitField<intptr_t, kSizeTagPos, kSizeTagSize> {};
+    class SizeBits :
+        public BitField<uword, intptr_t, kSizeTagPos, kSizeTagSize> {};
 
     static intptr_t SizeToTagValue(intptr_t size) {
       ASSERT(Utils::IsAligned(size, kObjectAlignment));
@@ -297,7 +298,7 @@
   };
 
   class ClassIdTag :
-      public BitField<intptr_t, kClassIdTagPos, kClassIdTagSize> {};  // NOLINT
+      public BitField<uword, intptr_t, kClassIdTagPos, kClassIdTagSize> {};
 
   bool IsWellFormed() const {
     uword value = reinterpret_cast<uword>(this);
@@ -497,18 +498,18 @@
  private:
   uword tags_;  // Various object tags (bits).
 
-  class WatchedBit : public BitField<bool, kWatchedBit, 1> {};
+  class WatchedBit : public BitField<uword, bool, kWatchedBit, 1> {};
 
-  class MarkBit : public BitField<bool, kMarkBit, 1> {};
+  class MarkBit : public BitField<uword, bool, kMarkBit, 1> {};
 
-  class RememberedBit : public BitField<bool, kRememberedBit, 1> {};
+  class RememberedBit : public BitField<uword, bool, kRememberedBit, 1> {};
 
-  class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {};
+  class CanonicalObjectTag : public BitField<uword, bool, kCanonicalBit, 1> {};
 
-  class VMHeapObjectTag : public BitField<bool, kVMHeapObjectBit, 1> {};
+  class VMHeapObjectTag : public BitField<uword, bool, kVMHeapObjectBit, 1> {};
 
   class ReservedBits : public
-      BitField<intptr_t, kReservedTagPos, kReservedTagSize> {};  // NOLINT
+      BitField<uword, intptr_t, kReservedTagPos, kReservedTagSize> {};
 
   // TODO(koda): After handling tags_, return const*, like Object::raw_ptr().
   RawObject* ptr() const {
@@ -1274,8 +1275,8 @@
     kMaxIndex = (1 << (kIndexSize - 1)) - 1,
   };
 
-  class IndexBits : public BitField<int32_t, kIndexPos, kIndexSize> {};
-  class KindBits : public BitField<int8_t, kKindPos, kKindSize>{};
+  class IndexBits : public BitField<int32_t, int32_t, kIndexPos, kIndexSize> {};
+  class KindBits : public BitField<int32_t, int8_t, kKindPos, kKindSize>{};
 
   struct VarInfo {
     int32_t index_kind;  // Bitfield for slot index on stack or in context,
diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h
index f635618..b1071d6 100644
--- a/runtime/vm/snapshot.h
+++ b/runtime/vm/snapshot.h
@@ -121,16 +121,12 @@
 static const intptr_t kInvalidPatchIndex = -1;
 
 
-class SerializedHeaderTag : public BitField<enum SerializedHeaderType,
-                                            0,
-                                            kHeaderTagBits> {
-};
+class SerializedHeaderTag :
+    public BitField<intptr_t, enum SerializedHeaderType, 0, kHeaderTagBits> {};
 
 
-class SerializedHeaderData : public BitField<intptr_t,
-                                             kHeaderTagBits,
-                                             kObjectIdBits> {
-};
+class SerializedHeaderData :
+    public BitField<intptr_t, intptr_t, kHeaderTagBits, kObjectIdBits> {};
 
 
 enum DeserializeState {
diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h
index 2f1b4df..c5a0c8f 100644
--- a/runtime/vm/thread.h
+++ b/runtime/vm/thread.h
@@ -577,9 +577,9 @@
 #undef REUSABLE_HANDLE_SCOPE_VARIABLE
 #endif  // defined(DEBUG)
 
-  class AtSafepointField : public BitField<bool, 0, 1> {};
-  class SafepointRequestedField : public BitField<bool, 1, 1> {};
-  class BlockedForSafepointField : public BitField<bool, 2, 1> {};
+  class AtSafepointField : public BitField<uint32_t, bool, 0, 1> {};
+  class SafepointRequestedField : public BitField<uint32_t, bool, 1, 1> {};
+  class BlockedForSafepointField : public BitField<uint32_t, bool, 2, 1> {};
   uint32_t safepoint_state_;
   uint32_t execution_state_;
 
diff --git a/runtime/vm/timeline.h b/runtime/vm/timeline.h
index ae714e5..a229acf 100644
--- a/runtime/vm/timeline.h
+++ b/runtime/vm/timeline.h
@@ -282,9 +282,9 @@
     kNextBit = 5,
   };
 
-  class EventTypeField : public BitField<EventType, kEventTypeBit, 4> {};
+  class EventTypeField : public BitField<uword, EventType, kEventTypeBit, 4> {};
   class PreSerializedJSON :
-      public BitField<bool, kPreSerializedJSON, 1> {};
+      public BitField<uword, bool, kPreSerializedJSON, 1> {};
 
   int64_t timestamp0_;
   int64_t timestamp1_;
diff --git a/tools/observatory_tool.py b/tools/observatory_tool.py
index a8595dc..fb3f364 100755
--- a/tools/observatory_tool.py
+++ b/tools/observatory_tool.py
@@ -135,6 +135,7 @@
       # development flow.
       # REMOVE THE FOLLOWING LINE TO USE the dart_bootstrap binary.
       # return False
+    print >> sys.stderr, ('Running command "%s"') % (executable + command)
     return subprocess.call(executable + command,
                            stdout=silent_sink if silent else None,
                            stderr=silent_sink if silent else None)