Import Cobalt 6.16000
diff --git a/src/third_party/mozjs-45/mfbt/Alignment.h b/src/third_party/mozjs-45/mfbt/Alignment.h
new file mode 100644
index 0000000..4098b1d
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Alignment.h
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Functionality related to memory alignment. */
+
+#ifndef mozilla_Alignment_h
+#define mozilla_Alignment_h
+
+#include "mozilla/Attributes.h"
+#include <stddef.h>
+#include <stdint.h>
+
+namespace mozilla {
+
+/*
+ * This class, and the corresponding macro MOZ_ALIGNOF, figures out how many
+ * bytes of alignment a given type needs.
+ */
+template<typename T>
+class AlignmentFinder
+{
+  struct Aligner
+  {
+    char mChar;
+    T mT;
+  };
+
+public:
+  static const size_t alignment = sizeof(Aligner) - sizeof(T);
+};
+
+#define MOZ_ALIGNOF(T) mozilla::AlignmentFinder<T>::alignment
+
+/*
+ * Declare the MOZ_ALIGNED_DECL macro for declaring aligned types.
+ *
+ * For instance,
+ *
+ *   MOZ_ALIGNED_DECL(char arr[2], 8);
+ *
+ * will declare a two-character array |arr| aligned to 8 bytes.
+ */
+
+#if defined(__GNUC__)
+#  define MOZ_ALIGNED_DECL(_type, _align) \
+     _type __attribute__((aligned(_align)))
+#elif defined(_MSC_VER)
+#  define MOZ_ALIGNED_DECL(_type, _align) \
+     __declspec(align(_align)) _type
+#else
+#  warning "We don't know how to align variables on this compiler."
+#  define MOZ_ALIGNED_DECL(_type, _align) _type
+#endif
+
+/*
+ * AlignedElem<N> is a structure whose alignment is guaranteed to be at least N
+ * bytes.
+ *
+ * We support 1, 2, 4, 8, and 16-bit alignment.
+ */
+template<size_t Align>
+struct AlignedElem;
+
+/*
+ * We have to specialize this template because GCC doesn't like
+ * __attribute__((aligned(foo))) where foo is a template parameter.
+ */
+
+template<>
+struct AlignedElem<1>
+{
+  MOZ_ALIGNED_DECL(uint8_t elem, 1);
+};
+
+template<>
+struct AlignedElem<2>
+{
+  MOZ_ALIGNED_DECL(uint8_t elem, 2);
+};
+
+template<>
+struct AlignedElem<4>
+{
+  MOZ_ALIGNED_DECL(uint8_t elem, 4);
+};
+
+template<>
+struct AlignedElem<8>
+{
+  MOZ_ALIGNED_DECL(uint8_t elem, 8);
+};
+
+template<>
+struct AlignedElem<16>
+{
+  MOZ_ALIGNED_DECL(uint8_t elem, 16);
+};
+
+/*
+ * This utility pales in comparison to Boost's aligned_storage. The utility
+ * simply assumes that uint64_t is enough alignment for anyone. This may need
+ * to be extended one day...
+ *
+ * As an important side effect, pulling the storage into this template is
+ * enough obfuscation to confuse gcc's strict-aliasing analysis into not giving
+ * false negatives when we cast from the char buffer to whatever type we've
+ * constructed using the bytes.
+ */
+template<size_t Nbytes>
+struct AlignedStorage
+{
+  union U
+  {
+    char mBytes[Nbytes];
+    uint64_t mDummy;
+  } u;
+
+  const void* addr() const { return u.mBytes; }
+  void* addr() { return u.mBytes; }
+};
+
+template<typename T>
+struct MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS AlignedStorage2
+{
+  union U
+  {
+    char mBytes[sizeof(T)];
+    uint64_t mDummy;
+  } u;
+
+  const T* addr() const { return reinterpret_cast<const T*>(u.mBytes); }
+  T* addr() { return static_cast<T*>(static_cast<void*>(u.mBytes)); }
+};
+
+} /* namespace mozilla */
+
+#endif /* mozilla_Alignment_h */
diff --git a/src/third_party/mozjs-45/mfbt/AllocPolicy.h b/src/third_party/mozjs-45/mfbt/AllocPolicy.h
new file mode 100644
index 0000000..0237ce4
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/AllocPolicy.h
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * An allocation policy concept, usable for structures and algorithms to
+ * control how memory is allocated and how failures are handled.
+ */
+
+#ifndef mozilla_AllocPolicy_h
+#define mozilla_AllocPolicy_h
+
+#include "mozilla/TemplateLib.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+
+namespace mozilla {
+
+/*
+ * Allocation policies are used to implement the standard allocation behaviors
+ * in a customizable way.  Additionally, custom behaviors may be added to these
+ * behaviors, such as additionally reporting an error through an out-of-band
+ * mechanism when OOM occurs.  The concept modeled here is as follows:
+ *
+ *  - public copy constructor, assignment, destructor
+ *  - template <typename T> T* maybe_pod_malloc(size_t)
+ *      Fallible, but doesn't report an error on OOM.
+ *  - template <typename T> T* maybe_pod_calloc(size_t)
+ *      Fallible, but doesn't report an error on OOM.
+ *  - template <typename T> T* maybe_pod_realloc(T*, size_t, size_t)
+ *      Fallible, but doesn't report an error on OOM.  The old allocation
+ *      size is passed in, in addition to the new allocation size requested.
+ *  - template <typename T> T* pod_malloc(size_t)
+ *      Responsible for OOM reporting when null is returned.
+ *  - template <typename T> T* pod_calloc(size_t)
+ *      Responsible for OOM reporting when null is returned.
+ *  - template <typename T> T* pod_realloc(T*, size_t, size_t)
+ *      Responsible for OOM reporting when null is returned.  The old allocation
+ *      size is passed in, in addition to the new allocation size requested.
+ *  - void free_(void*)
+ *  - void reportAllocOverflow() const
+ *      Called on allocation overflow (that is, an allocation implicitly tried
+ *      to allocate more than the available memory space -- think allocating an
+ *      array of large-size objects, where N * size overflows) before null is
+ *      returned.
+ *  - bool checkSimulatedOOM() const
+ *      Some clients generally allocate memory yet in some circumstances won't
+ *      need to do so. For example, appending to a vector with a small amount of
+ *      inline storage generally allocates memory, but no allocation occurs
+ *      unless appending exceeds inline storage. But for testing purposes, it
+ *      can be useful to treat *every* operation as allocating.
+ *      Clients (such as this hypothetical append method implementation) should
+ *      call this method in situations that don't allocate, but could generally,
+ *      to support this. The default behavior should return true; more
+ *      complicated behavior might be to return false only after a certain
+ *      number of allocations-or-check-simulated-OOMs (coordinating with the
+ *      other AllocPolicy methods) have occurred.
+ *
+ * mfbt provides (and typically uses by default) only MallocAllocPolicy, which
+ * does nothing more than delegate to the malloc/alloc/free functions.
+ */
+
+/*
+ * A policy that straightforwardly uses malloc/calloc/realloc/free and adds no
+ * extra behaviors.
+ */
+class MallocAllocPolicy
+{
+public:
+  template <typename T>
+  T* maybe_pod_malloc(size_t aNumElems)
+  {
+    if (aNumElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value) {
+      return nullptr;
+    }
+    return static_cast<T*>(malloc(aNumElems * sizeof(T)));
+  }
+
+  template <typename T>
+  T* maybe_pod_calloc(size_t aNumElems)
+  {
+    return static_cast<T*>(calloc(aNumElems, sizeof(T)));
+  }
+
+  template <typename T>
+  T* maybe_pod_realloc(T* aPtr, size_t aOldSize, size_t aNewSize)
+  {
+    if (aNewSize & mozilla::tl::MulOverflowMask<sizeof(T)>::value) {
+      return nullptr;
+    }
+    return static_cast<T*>(realloc(aPtr, aNewSize * sizeof(T)));
+  }
+
+  template <typename T>
+  T* pod_malloc(size_t aNumElems)
+  {
+    return maybe_pod_malloc<T>(aNumElems);
+  }
+
+  template <typename T>
+  T* pod_calloc(size_t aNumElems)
+  {
+    return maybe_pod_calloc<T>(aNumElems);
+  }
+
+  template <typename T>
+  T* pod_realloc(T* aPtr, size_t aOldSize, size_t aNewSize)
+  {
+    return maybe_pod_realloc<T>(aPtr, aOldSize, aNewSize);
+  }
+
+  void free_(void* aPtr)
+  {
+    free(aPtr);
+  }
+
+  void reportAllocOverflow() const
+  {
+  }
+
+  bool checkSimulatedOOM() const
+  {
+    return true;
+  }
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_AllocPolicy_h */
diff --git a/src/third_party/mozjs-45/mfbt/AlreadyAddRefed.h b/src/third_party/mozjs-45/mfbt/AlreadyAddRefed.h
new file mode 100644
index 0000000..d02e8ae
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/AlreadyAddRefed.h
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Typed temporary pointers for reference-counted smart pointers. */
+
+#ifndef AlreadyAddRefed_h
+#define AlreadyAddRefed_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Move.h"
+
+namespace mozilla {
+
+struct unused_t;
+
+} // namespace mozilla
+
+/**
+ * already_AddRefed cooperates with reference counting smart pointers to enable
+ * you to assign in a pointer _without_ |AddRef|ing it.  You might want to use
+ * this as a return type from a function that returns an already |AddRef|ed
+ * pointer.
+ *
+ * TODO Move already_AddRefed to namespace mozilla.  This has not yet been done
+ * because of the sheer number of usages of already_AddRefed.
+ */
+template<class T>
+struct MOZ_MUST_USE MOZ_NON_AUTOABLE already_AddRefed
+{
+  /*
+   * We want to allow returning nullptr from functions returning
+   * already_AddRefed<T>, for simplicity.  But we also don't want to allow
+   * returning raw T*, instead preferring creation of already_AddRefed<T> from
+   * a reference counting smart pointer.
+   *
+   * We address the latter requirement by making the (T*) constructor explicit.
+   * But |return nullptr| won't consider an explicit constructor, so we need
+   * another constructor to handle it.  Plain old (decltype(nullptr)) doesn't
+   * cut it, because if nullptr is emulated as __null (with type int or long),
+   * passing nullptr to an int/long parameter triggers compiler warnings.  We
+   * need a type that no one can pass accidentally; a pointer-to-member-function
+   * (where no such function exists) does the trick nicely.
+   *
+   * That handles the return-value case.  What about for locals, argument types,
+   * and so on?  |already_AddRefed<T>(nullptr)| considers both overloads (and
+   * the (already_AddRefed<T>&&) overload as well!), so there's an ambiguity.
+   * We can target true nullptr using decltype(nullptr), but we can't target
+   * emulated nullptr the same way, because passing __null to an int/long
+   * parameter triggers compiler warnings.  So just give up on this, and provide
+   * this behavior through the default constructor.
+   *
+   * We can revert to simply explicit (T*) and implicit (decltype(nullptr)) when
+   * nullptr no longer needs to be emulated to support the ancient b2g compiler.
+   * (The () overload could also be removed, if desired, if we changed callers.)
+   */
+  already_AddRefed() : mRawPtr(nullptr) {}
+
+  // The return and argument types here are arbitrarily selected so no
+  // corresponding member function exists.
+  typedef void (already_AddRefed::* MatchNullptr)(double, float);
+  MOZ_IMPLICIT already_AddRefed(MatchNullptr aRawPtr) : mRawPtr(nullptr) {}
+
+  explicit already_AddRefed(T* aRawPtr) : mRawPtr(aRawPtr) {}
+
+  // Disallow copy constructor and copy assignment operator: move semantics used instead.
+  already_AddRefed(const already_AddRefed<T>& aOther) = delete;
+  already_AddRefed<T>& operator=(const already_AddRefed<T>& aOther) = delete;
+
+  already_AddRefed(already_AddRefed<T>&& aOther) : mRawPtr(aOther.take()) {}
+
+  already_AddRefed<T>& operator=(already_AddRefed<T>&& aOther)
+  {
+    mRawPtr = aOther.take();
+    return *this;
+  }
+
+  /**
+   * This helper is useful in cases like
+   *
+   *  already_AddRefed<BaseClass>
+   *  Foo()
+   *  {
+   *    RefPtr<SubClass> x = ...;
+   *    return x.forget();
+   *  }
+   *
+   * The autoconversion allows one to omit the idiom
+   *
+   *    RefPtr<BaseClass> y = x.forget();
+   *    return y.forget();
+   *
+   * Note that nsRefPtr is the XPCOM reference counting smart pointer class.
+   */
+  template <typename U>
+  MOZ_IMPLICIT already_AddRefed(already_AddRefed<U>&& aOther) : mRawPtr(aOther.take()) {}
+
+  ~already_AddRefed() { MOZ_ASSERT(!mRawPtr); }
+
+  // Specialize the unused operator<< for already_AddRefed, to allow
+  // nsCOMPtr<nsIFoo> foo;
+  // Unused << foo.forget();
+  // Note that nsCOMPtr is the XPCOM reference counting smart pointer class.
+  friend void operator<<(const mozilla::unused_t& aUnused,
+                         const already_AddRefed<T>& aRhs)
+  {
+    auto mutableAlreadyAddRefed = const_cast<already_AddRefed<T>*>(&aRhs);
+    aUnused << mutableAlreadyAddRefed->take();
+  }
+
+  MOZ_WARN_UNUSED_RESULT T* take()
+  {
+    T* rawPtr = mRawPtr;
+    mRawPtr = nullptr;
+    return rawPtr;
+  }
+
+  /**
+   * This helper provides a static_cast replacement for already_AddRefed, so
+   * if you have
+   *
+   *   already_AddRefed<Parent> F();
+   *
+   * you can write
+   *
+   *   already_AddRefed<Child>
+   *   G()
+   *   {
+   *     return F().downcast<Child>();
+   *   }
+   */
+  template<class U>
+  already_AddRefed<U> downcast()
+  {
+    U* tmp = static_cast<U*>(mRawPtr);
+    mRawPtr = nullptr;
+    return already_AddRefed<U>(tmp);
+  }
+
+private:
+  T* MOZ_OWNING_REF mRawPtr;
+};
+
+#endif // AlreadyAddRefed_h
diff --git a/src/third_party/mozjs-45/mfbt/Array.h b/src/third_party/mozjs-45/mfbt/Array.h
new file mode 100644
index 0000000..30e183b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Array.h
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A compile-time constant-length array with bounds-checking assertions. */
+
+#ifndef mozilla_Array_h
+#define mozilla_Array_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/ReverseIterator.h"
+
+#include <stddef.h>
+
+namespace mozilla {
+
+template<typename T, size_t Length>
+class Array
+{
+  T mArr[Length];
+
+public:
+  T& operator[](size_t aIndex)
+  {
+    MOZ_ASSERT(aIndex < Length);
+    return mArr[aIndex];
+  }
+
+  const T& operator[](size_t aIndex) const
+  {
+    MOZ_ASSERT(aIndex < Length);
+    return mArr[aIndex];
+  }
+
+  typedef T*                        iterator;
+  typedef const T*                  const_iterator;
+  typedef ReverseIterator<T*>       reverse_iterator;
+  typedef ReverseIterator<const T*> const_reverse_iterator;
+
+  // Methods for range-based for loops.
+  iterator begin() { return mArr; }
+  const_iterator begin() const { return mArr; }
+  const_iterator cbegin() const { return begin(); }
+  iterator end() { return mArr + Length; }
+  const_iterator end() const { return mArr + Length; }
+  const_iterator cend() const { return end(); }
+
+  // Methods for reverse iterating.
+  reverse_iterator rbegin() { return reverse_iterator(end()); }
+  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
+  const_reverse_iterator crbegin() const { return rbegin(); }
+  reverse_iterator rend() { return reverse_iterator(begin()); }
+  const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
+  const_reverse_iterator crend() const { return rend(); }
+};
+
+template<typename T>
+class Array<T, 0>
+{
+public:
+  T& operator[](size_t aIndex)
+  {
+    MOZ_CRASH("indexing into zero-length array");
+  }
+
+  const T& operator[](size_t aIndex) const
+  {
+    MOZ_CRASH("indexing into zero-length array");
+  }
+};
+
+}  /* namespace mozilla */
+
+#endif /* mozilla_Array_h */
diff --git a/src/third_party/mozjs-45/mfbt/ArrayUtils.h b/src/third_party/mozjs-45/mfbt/ArrayUtils.h
new file mode 100644
index 0000000..b572272
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/ArrayUtils.h
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Implements various helper functions related to arrays.
+ */
+
+#ifndef mozilla_ArrayUtils_h
+#define mozilla_ArrayUtils_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+
+#include "mozilla/Alignment.h"
+#include "mozilla/Array.h"
+#include "mozilla/EnumeratedArray.h"
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+/*
+ * Safely subtract two pointers when it is known that aEnd >= aBegin, yielding a
+ * size_t result.
+ *
+ * Ordinary pointer subtraction yields a ptrdiff_t result, which, being signed,
+ * has insufficient range to express the distance between pointers at opposite
+ * ends of the address space. Furthermore, most compilers use ptrdiff_t to
+ * represent the intermediate byte address distance, before dividing by
+ * sizeof(T); if that intermediate result overflows, they'll produce results
+ * with the wrong sign even when the correct scaled distance would fit in a
+ * ptrdiff_t.
+ */
+template<class T>
+MOZ_ALWAYS_INLINE size_t
+PointerRangeSize(T* aBegin, T* aEnd)
+{
+  MOZ_ASSERT(aEnd >= aBegin);
+  return (size_t(aEnd) - size_t(aBegin)) / sizeof(T);
+}
+
+/*
+ * Compute the length of an array with constant length.  (Use of this method
+ * with a non-array pointer will not compile.)
+ *
+ * Beware of the implicit trailing '\0' when using this with string constants.
+ */
+template<typename T, size_t N>
+MOZ_CONSTEXPR size_t
+ArrayLength(T (&aArr)[N])
+{
+  return N;
+}
+
+template<typename T, size_t N>
+MOZ_CONSTEXPR size_t
+ArrayLength(const Array<T, N>& aArr)
+{
+  return N;
+}
+
+template<typename E, E N, typename T>
+MOZ_CONSTEXPR size_t
+ArrayLength(const EnumeratedArray<E, N, T>& aArr)
+{
+  return size_t(N);
+}
+
+/*
+ * Compute the address one past the last element of a constant-length array.
+ *
+ * Beware of the implicit trailing '\0' when using this with string constants.
+ */
+template<typename T, size_t N>
+MOZ_CONSTEXPR T*
+ArrayEnd(T (&aArr)[N])
+{
+  return aArr + ArrayLength(aArr);
+}
+
+template<typename T, size_t N>
+MOZ_CONSTEXPR T*
+ArrayEnd(Array<T, N>& aArr)
+{
+  return &aArr[0] + ArrayLength(aArr);
+}
+
+template<typename T, size_t N>
+MOZ_CONSTEXPR const T*
+ArrayEnd(const Array<T, N>& aArr)
+{
+  return &aArr[0] + ArrayLength(aArr);
+}
+
+namespace detail {
+
+template<typename AlignType, typename Pointee,
+         typename = EnableIf<!IsVoid<AlignType>::value>>
+struct AlignedChecker
+{
+  static void
+  test(const Pointee* aPtr)
+  {
+    MOZ_ASSERT((uintptr_t(aPtr) % MOZ_ALIGNOF(AlignType)) == 0,
+               "performing a range-check with a misaligned pointer");
+  }
+};
+
+template<typename AlignType, typename Pointee>
+struct AlignedChecker<AlignType, Pointee>
+{
+  static void
+  test(const Pointee* aPtr)
+  {
+  }
+};
+
+} // namespace detail
+
+/**
+ * Determines whether |aPtr| points at an object in the range [aBegin, aEnd).
+ *
+ * |aPtr| must have the same alignment as |aBegin| and |aEnd|.  This usually
+ * should be achieved by ensuring |aPtr| points at a |U|, not just that it
+ * points at a |T|.
+ *
+ * It is a usage error for any argument to be misaligned.
+ *
+ * It's okay for T* to be void*, and if so U* may also be void*.  In the latter
+ * case no argument is required to be aligned (obviously, as void* implies no
+ * particular alignment).
+ */
+template<typename T, typename U>
+inline typename EnableIf<IsSame<T, U>::value ||
+                         IsBaseOf<T, U>::value ||
+                         IsVoid<T>::value,
+                         bool>::Type
+IsInRange(const T* aPtr, const U* aBegin, const U* aEnd)
+{
+  MOZ_ASSERT(aBegin <= aEnd);
+  detail::AlignedChecker<U, T>::test(aPtr);
+  detail::AlignedChecker<U, U>::test(aBegin);
+  detail::AlignedChecker<U, U>::test(aEnd);
+  return aBegin <= reinterpret_cast<const U*>(aPtr) &&
+         reinterpret_cast<const U*>(aPtr) < aEnd;
+}
+
+/**
+ * Convenience version of the above method when the valid range is specified as
+ * uintptr_t values.  As above, |aPtr| must be aligned, and |aBegin| and |aEnd|
+ * must be aligned with respect to |T|.
+ */
+template<typename T>
+inline bool
+IsInRange(const T* aPtr, uintptr_t aBegin, uintptr_t aEnd)
+{
+  return IsInRange(aPtr,
+                   reinterpret_cast<const T*>(aBegin),
+                   reinterpret_cast<const T*>(aEnd));
+}
+
+namespace detail {
+
+/*
+ * Helper for the MOZ_ARRAY_LENGTH() macro to make the length a typesafe
+ * compile-time constant even on compilers lacking constexpr support.
+ */
+template <typename T, size_t N>
+char (&ArrayLengthHelper(T (&array)[N]))[N];
+
+} /* namespace detail */
+
+} /* namespace mozilla */
+
+#endif /* __cplusplus */
+
+/*
+ * MOZ_ARRAY_LENGTH() is an alternative to mozilla::ArrayLength() for C files
+ * that can't use C++ template functions and for static_assert() calls that
+ * can't call ArrayLength() when it is not a C++11 constexpr function.
+ */
+#ifdef __cplusplus
+#  define MOZ_ARRAY_LENGTH(array)   sizeof(mozilla::detail::ArrayLengthHelper(array))
+#else
+#  define MOZ_ARRAY_LENGTH(array)   (sizeof(array)/sizeof((array)[0]))
+#endif
+
+#endif /* mozilla_ArrayUtils_h */
diff --git a/src/third_party/mozjs-45/mfbt/Assertions.h b/src/third_party/mozjs-45/mfbt/Assertions.h
new file mode 100644
index 0000000..f138ff9
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Assertions.h
@@ -0,0 +1,526 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implementations of runtime and static assertion macros for C and C++. */
+
+#ifndef mozilla_Assertions_h
+#define mozilla_Assertions_h
+
+#if defined(MOZILLA_INTERNAL_API) && defined(__cplusplus)
+#define MOZ_DUMP_ASSERTION_STACK
+#endif
+
+#include "mozilla/Attributes.h"
+#include "mozilla/Compiler.h"
+#include "mozilla/Likely.h"
+#include "mozilla/MacroArgs.h"
+#ifdef MOZ_DUMP_ASSERTION_STACK
+#include "nsTraceRefcnt.h"
+#endif
+
+#if defined(MOZ_CRASHREPORTER) && defined(MOZILLA_INTERNAL_API) && \
+    !defined(MOZILLA_EXTERNAL_LINKAGE) && defined(__cplusplus)
+namespace CrashReporter {
+// This declaration is present here as well as in nsExceptionHandler.h
+// nsExceptionHandler.h is not directly included in this file as it includes
+// windows.h, which can cause problems when it is imported into some files due
+// to the number of macros defined.
+// XXX If you change this definition - also change the definition in
+// nsExceptionHandler.h
+void AnnotateMozCrashReason(const char* aReason);
+} // namespace CrashReporter
+
+#  define MOZ_CRASH_ANNOTATE(...) CrashReporter::AnnotateMozCrashReason("" __VA_ARGS__)
+#else
+#  define MOZ_CRASH_ANNOTATE(...) do { /* nothing */ } while (0)
+#endif
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef WIN32
+   /*
+    * TerminateProcess and GetCurrentProcess are defined in <winbase.h>, which
+    * further depends on <windef.h>.  We hardcode these few definitions manually
+    * because those headers clutter the global namespace with a significant
+    * number of undesired macros and symbols.
+    */
+#  ifdef __cplusplus
+extern "C" {
+#  endif
+__declspec(dllimport) int __stdcall
+TerminateProcess(void* hProcess, unsigned int uExitCode);
+__declspec(dllimport) void* __stdcall GetCurrentProcess(void);
+#  ifdef __cplusplus
+}
+#  endif
+#else
+#  include <signal.h>
+#endif
+#ifdef ANDROID
+#  include <android/log.h>
+#endif
+
+/*
+ * MOZ_STATIC_ASSERT may be used to assert a condition *at compile time* in C.
+ * In C++11, static_assert is provided by the compiler to the same effect.
+ * This can be useful when you make certain assumptions about what must hold for
+ * optimal, or even correct, behavior.  For example, you might assert that the
+ * size of a struct is a multiple of the target architecture's word size:
+ *
+ *   struct S { ... };
+ *   // C
+ *   MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0,
+ *                     "S should be a multiple of word size for efficiency");
+ *   // C++11
+ *   static_assert(sizeof(S) % sizeof(size_t) == 0,
+ *                 "S should be a multiple of word size for efficiency");
+ *
+ * This macro can be used in any location where both an extern declaration and a
+ * typedef could be used.
+ */
+#ifndef __cplusplus
+   /*
+    * Some of the definitions below create an otherwise-unused typedef.  This
+    * triggers compiler warnings with some versions of gcc, so mark the typedefs
+    * as permissibly-unused to disable the warnings.
+    */
+#  if defined(__GNUC__)
+#    define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused))
+#  else
+#    define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE /* nothing */
+#  endif
+#  define MOZ_STATIC_ASSERT_GLUE1(x, y)          x##y
+#  define MOZ_STATIC_ASSERT_GLUE(x, y)           MOZ_STATIC_ASSERT_GLUE1(x, y)
+#  if defined(__SUNPRO_CC)
+     /*
+      * The Sun Studio C++ compiler is buggy when declaring, inside a function,
+      * another extern'd function with an array argument whose length contains a
+      * sizeof, triggering the error message "sizeof expression not accepted as
+      * size of array parameter".  This bug (6688515, not public yet) would hit
+      * defining moz_static_assert as a function, so we always define an extern
+      * array for Sun Studio.
+      *
+      * We include the line number in the symbol name in a best-effort attempt
+      * to avoid conflicts (see below).
+      */
+#    define MOZ_STATIC_ASSERT(cond, reason) \
+       extern char MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)[(cond) ? 1 : -1]
+#  elif defined(__COUNTER__)
+     /*
+      * If there was no preferred alternative, use a compiler-agnostic version.
+      *
+      * Note that the non-__COUNTER__ version has a bug in C++: it can't be used
+      * in both |extern "C"| and normal C++ in the same translation unit.  (Alas
+      * |extern "C"| isn't allowed in a function.)  The only affected compiler
+      * we really care about is gcc 4.2.  For that compiler and others like it,
+      * we include the line number in the function name to do the best we can to
+      * avoid conflicts.  These should be rare: a conflict would require use of
+      * MOZ_STATIC_ASSERT on the same line in separate files in the same
+      * translation unit, *and* the uses would have to be in code with
+      * different linkage, *and* the first observed use must be in C++-linkage
+      * code.
+      */
+#    define MOZ_STATIC_ASSERT(cond, reason) \
+       typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE
+#  else
+#    define MOZ_STATIC_ASSERT(cond, reason) \
+       extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE
+#  endif
+
+#define MOZ_STATIC_ASSERT_IF(cond, expr, reason)  MOZ_STATIC_ASSERT(!(cond) || (expr), reason)
+#else
+#define MOZ_STATIC_ASSERT_IF(cond, expr, reason)  static_assert(!(cond) || (expr), reason)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Prints |aStr| as an assertion failure (using aFilename and aLine as the
+ * location of the assertion) to the standard debug-output channel.
+ *
+ * Usually you should use MOZ_ASSERT or MOZ_CRASH instead of this method.  This
+ * method is primarily for internal use in this header, and only secondarily
+ * for use in implementing release-build assertions.
+ */
+static MOZ_COLD MOZ_ALWAYS_INLINE void
+MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, int aLine)
+  MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
+{
+#ifdef ANDROID
+  __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert",
+                      "Assertion failure: %s, at %s:%d\n",
+                      aStr, aFilename, aLine);
+#else
+  fprintf(stderr, "Assertion failure: %s, at %s:%d\n", aStr, aFilename, aLine);
+#if defined (MOZ_DUMP_ASSERTION_STACK) && !defined(MOZILLA_XPCOMRT_API)
+  nsTraceRefcnt::WalkTheStack(stderr);
+#endif
+  fflush(stderr);
+#endif
+}
+
+static MOZ_COLD MOZ_ALWAYS_INLINE void
+MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine)
+  MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
+{
+#ifdef ANDROID
+  __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH",
+                      "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine);
+#else
+  fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine);
+#if defined(MOZ_DUMP_ASSERTION_STACK) && !defined(MOZILLA_XPCOMRT_API)
+  nsTraceRefcnt::WalkTheStack(stderr);
+#endif
+  fflush(stderr);
+#endif
+}
+
+/**
+ * MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH().  You should
+ * call MOZ_CRASH instead.
+ */
+#if defined(_MSC_VER)
+   /*
+    * On MSVC use the __debugbreak compiler intrinsic, which produces an inline
+    * (not nested in a system function) breakpoint.  This distinctively invokes
+    * Breakpad without requiring system library symbols on all stack-processing
+    * machines, as a nested breakpoint would require.
+    *
+    * We use TerminateProcess with the exit code aborting would generate
+    * because we don't want to invoke atexit handlers, destructors, library
+    * unload handlers, and so on when our process might be in a compromised
+    * state.
+    *
+    * We don't use abort() because it'd cause Windows to annoyingly pop up the
+    * process error dialog multiple times.  See bug 345118 and bug 426163.
+    *
+    * We follow TerminateProcess() with a call to MOZ_NoReturn() so that the
+    * compiler doesn't hassle us to provide a return statement after a
+    * MOZ_REALLY_CRASH() call.
+    *
+    * (Technically these are Windows requirements, not MSVC requirements.  But
+    * practically you need MSVC for debugging, and we only ship builds created
+    * by MSVC, so doing it this way reduces complexity.)
+    */
+
+__declspec(noreturn) __inline void MOZ_NoReturn() {}
+
+#  ifdef __cplusplus
+#    define MOZ_REALLY_CRASH() \
+       do { \
+         ::__debugbreak(); \
+         *((volatile int*) NULL) = __LINE__; \
+         ::TerminateProcess(::GetCurrentProcess(), 3); \
+         ::MOZ_NoReturn(); \
+       } while (0)
+#  else
+#    define MOZ_REALLY_CRASH() \
+       do { \
+         __debugbreak(); \
+         *((volatile int*) NULL) = __LINE__; \
+         TerminateProcess(GetCurrentProcess(), 3); \
+         MOZ_NoReturn(); \
+       } while (0)
+#  endif
+#else
+#  ifdef __cplusplus
+#    define MOZ_REALLY_CRASH() \
+       do { \
+         *((volatile int*) NULL) = __LINE__; \
+         ::abort(); \
+       } while (0)
+#  else
+#    define MOZ_REALLY_CRASH() \
+       do { \
+         *((volatile int*) NULL) = __LINE__; \
+         abort(); \
+       } while (0)
+#  endif
+#endif
+
+/*
+ * MOZ_CRASH([explanation-string]) crashes the program, plain and simple, in a
+ * Breakpad-compatible way, in both debug and release builds.
+ *
+ * MOZ_CRASH is a good solution for "handling" failure cases when you're
+ * unwilling or unable to handle them more cleanly -- for OOM, for likely memory
+ * corruption, and so on.  It's also a good solution if you need safe behavior
+ * in release builds as well as debug builds.  But if the failure is one that
+ * should be debugged and fixed, MOZ_ASSERT is generally preferable.
+ *
+ * The optional explanation-string, if provided, must be a string literal
+ * explaining why we're crashing.  This argument is intended for use with
+ * MOZ_CRASH() calls whose rationale is non-obvious; don't use it if it's
+ * obvious why we're crashing.
+ *
+ * If we're a DEBUG build and we crash at a MOZ_CRASH which provides an
+ * explanation-string, we print the string to stderr.  Otherwise, we don't
+ * print anything; this is because we want MOZ_CRASH to be 100% safe in release
+ * builds, and it's hard to print to stderr safely when memory might have been
+ * corrupted.
+ */
+#ifndef DEBUG
+#  define MOZ_CRASH(...) \
+     do { \
+       MOZ_CRASH_ANNOTATE("MOZ_CRASH(" __VA_ARGS__ ")"); \
+       MOZ_REALLY_CRASH(); \
+     } while (0)
+#else
+#  define MOZ_CRASH(...) \
+     do { \
+       MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \
+       MOZ_CRASH_ANNOTATE("MOZ_CRASH(" __VA_ARGS__ ")"); \
+       MOZ_REALLY_CRASH(); \
+     } while (0)
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+/*
+ * MOZ_ASSERT(expr [, explanation-string]) asserts that |expr| must be truthy in
+ * debug builds.  If it is, execution continues.  Otherwise, an error message
+ * including the expression and the explanation-string (if provided) is printed,
+ * an attempt is made to invoke any existing debugger, and execution halts.
+ * MOZ_ASSERT is fatal: no recovery is possible.  Do not assert a condition
+ * which can correctly be falsy.
+ *
+ * The optional explanation-string, if provided, must be a string literal
+ * explaining the assertion.  It is intended for use with assertions whose
+ * correctness or rationale is non-obvious, and for assertions where the "real"
+ * condition being tested is best described prosaically.  Don't provide an
+ * explanation if it's not actually helpful.
+ *
+ *   // No explanation needed: pointer arguments often must not be NULL.
+ *   MOZ_ASSERT(arg);
+ *
+ *   // An explanation can be helpful to explain exactly how we know an
+ *   // assertion is valid.
+ *   MOZ_ASSERT(state == WAITING_FOR_RESPONSE,
+ *              "given that <thingA> and <thingB>, we must have...");
+ *
+ *   // Or it might disambiguate multiple identical (save for their location)
+ *   // assertions of the same expression.
+ *   MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(),
+ *              "we already set [[PrimitiveThis]] for this Boolean object");
+ *   MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(),
+ *              "we already set [[PrimitiveThis]] for this String object");
+ *
+ * MOZ_ASSERT has no effect in non-debug builds.  It is designed to catch bugs
+ * *only* during debugging, not "in the field". If you want the latter, use
+ * MOZ_RELEASE_ASSERT, which applies to non-debug builds as well.
+ *
+ * MOZ_DIAGNOSTIC_ASSERT works like MOZ_RELEASE_ASSERT in Nightly/Aurora and
+ * MOZ_ASSERT in Beta/Release - use this when a condition is potentially rare
+ * enough to require real user testing to hit, but is not security-sensitive.
+ * This can cause user pain, so use it sparingly. If a MOZ_DIAGNOSTIC_ASSERT
+ * is firing, it should promptly be converted to a MOZ_ASSERT while the failure
+ * is being investigated, rather than letting users suffer.
+ */
+
+/*
+ * Implement MOZ_VALIDATE_ASSERT_CONDITION_TYPE, which is used to guard against
+ * accidentally passing something unintended in lieu of an assertion condition.
+ */
+
+#ifdef __cplusplus
+#  include "mozilla/TypeTraits.h"
+namespace mozilla {
+namespace detail {
+
+template<typename T>
+struct AssertionConditionType
+{
+  typedef typename RemoveReference<T>::Type ValueT;
+  static_assert(!IsArray<ValueT>::value,
+                "Expected boolean assertion condition, got an array or a "
+                "string!");
+  static_assert(!IsFunction<ValueT>::value,
+                "Expected boolean assertion condition, got a function! Did "
+                "you intend to call that function?");
+  static_assert(!IsFloatingPoint<ValueT>::value,
+                "It's often a bad idea to assert that a floating-point number "
+                "is nonzero, because such assertions tend to intermittently "
+                "fail. Shouldn't your code gracefully handle this case instead "
+                "of asserting? Anyway, if you really want to do that, write an "
+                "explicit boolean condition, like !!x or x!=0.");
+
+  static const bool isValid = true;
+};
+
+} // namespace detail
+} // namespace mozilla
+#  define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x) \
+     static_assert(mozilla::detail::AssertionConditionType<decltype(x)>::isValid, \
+                   "invalid assertion condition")
+#else
+#  define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x)
+#endif
+
+/* First the single-argument form. */
+#define MOZ_ASSERT_HELPER1(expr) \
+  do { \
+    MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \
+    if (MOZ_UNLIKELY(!(expr))) { \
+      MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \
+      MOZ_CRASH_ANNOTATE("MOZ_RELEASE_ASSERT(" #expr ")"); \
+      MOZ_REALLY_CRASH(); \
+    } \
+  } while (0)
+/* Now the two-argument form. */
+#define MOZ_ASSERT_HELPER2(expr, explain) \
+  do { \
+    MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \
+    if (MOZ_UNLIKELY(!(expr))) { \
+      MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \
+      MOZ_CRASH_ANNOTATE("MOZ_RELEASE_ASSERT(" #expr ") (" explain ")"); \
+      MOZ_REALLY_CRASH(); \
+    } \
+  } while (0)
+
+#define MOZ_RELEASE_ASSERT_GLUE(a, b) a b
+#define MOZ_RELEASE_ASSERT(...) \
+  MOZ_RELEASE_ASSERT_GLUE( \
+    MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_ASSERT_HELPER, __VA_ARGS__), \
+    (__VA_ARGS__))
+
+#ifdef DEBUG
+#  define MOZ_ASSERT(...) MOZ_RELEASE_ASSERT(__VA_ARGS__)
+#else
+#  define MOZ_ASSERT(...) do { } while (0)
+#endif /* DEBUG */
+
+#ifdef RELEASE_BUILD
+#  define MOZ_DIAGNOSTIC_ASSERT MOZ_ASSERT
+#else
+#  define MOZ_DIAGNOSTIC_ASSERT MOZ_RELEASE_ASSERT
+#endif
+
+/*
+ * MOZ_ASSERT_IF(cond1, cond2) is equivalent to MOZ_ASSERT(cond2) if cond1 is
+ * true.
+ *
+ *   MOZ_ASSERT_IF(isPrime(num), num == 2 || isOdd(num));
+ *
+ * As with MOZ_ASSERT, MOZ_ASSERT_IF has effect only in debug builds.  It is
+ * designed to catch bugs during debugging, not "in the field".
+ */
+#ifdef DEBUG
+#  define MOZ_ASSERT_IF(cond, expr) \
+     do { \
+       if (cond) { \
+         MOZ_ASSERT(expr); \
+       } \
+     } while (0)
+#else
+#  define MOZ_ASSERT_IF(cond, expr)  do { } while (0)
+#endif
+
+/*
+ * MOZ_ASSUME_UNREACHABLE_MARKER() expands to an expression which states that
+ * it is undefined behavior for execution to reach this point.  No guarantees
+ * are made about what will happen if this is reached at runtime.  Most code
+ * should use MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE because it has extra
+ * asserts.
+ */
+#if defined(__clang__) || defined(__GNUC__)
+#  define MOZ_ASSUME_UNREACHABLE_MARKER() __builtin_unreachable()
+#elif defined(_MSC_VER)
+#  define MOZ_ASSUME_UNREACHABLE_MARKER() __assume(0)
+#else
+#  ifdef __cplusplus
+#    define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort()
+#  else
+#    define MOZ_ASSUME_UNREACHABLE_MARKER() abort()
+#  endif
+#endif
+
+/*
+ * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE([reason]) tells the compiler that it
+ * can assume that the macro call cannot be reached during execution.  This lets
+ * the compiler generate better-optimized code under some circumstances, at the
+ * expense of the program's behavior being undefined if control reaches the
+ * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE.
+ *
+ * In Gecko, you probably should not use this macro outside of performance- or
+ * size-critical code, because it's unsafe.  If you don't care about code size
+ * or performance, you should probably use MOZ_ASSERT or MOZ_CRASH.
+ *
+ * SpiderMonkey is a different beast, and there it's acceptable to use
+ * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE more widely.
+ *
+ * Note that MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE is noreturn, so it's valid
+ * not to return a value following a MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE
+ * call.
+ *
+ * Example usage:
+ *
+ *   enum ValueType {
+ *     VALUE_STRING,
+ *     VALUE_INT,
+ *     VALUE_FLOAT
+ *   };
+ *
+ *   int ptrToInt(ValueType type, void* value) {
+ *   {
+ *     // We know for sure that type is either INT or FLOAT, and we want this
+ *     // code to run as quickly as possible.
+ *     switch (type) {
+ *     case VALUE_INT:
+ *       return *(int*) value;
+ *     case VALUE_FLOAT:
+ *       return (int) *(float*) value;
+ *     default:
+ *       MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected ValueType");
+ *     }
+ *   }
+ */
+
+/*
+ * Unconditional assert in debug builds for (assumed) unreachable code paths
+ * that have a safe return without crashing in release builds.
+ */
+#define MOZ_ASSERT_UNREACHABLE(reason) \
+   MOZ_ASSERT(false, "MOZ_ASSERT_UNREACHABLE: " reason)
+
+#define MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE(reason) \
+   do { \
+     MOZ_ASSERT_UNREACHABLE(reason); \
+     MOZ_ASSUME_UNREACHABLE_MARKER(); \
+   } while (0)
+
+/*
+ * MOZ_ALWAYS_TRUE(expr) and MOZ_ALWAYS_FALSE(expr) always evaluate the provided
+ * expression, in debug builds and in release builds both.  Then, in debug
+ * builds only, the value of the expression is asserted either true or false
+ * using MOZ_ASSERT.
+ */
+#ifdef DEBUG
+#  define MOZ_ALWAYS_TRUE(expr)      MOZ_ASSERT((expr))
+#  define MOZ_ALWAYS_FALSE(expr)     MOZ_ASSERT(!(expr))
+#else
+#  define MOZ_ALWAYS_TRUE(expr) \
+  do { \
+    if ( ( expr ) ) {                       \
+      /* Silence MOZ_WARN_UNUSED_RESULT. */ \
+    } \
+  } while (0)
+#  define MOZ_ALWAYS_FALSE(expr) \
+  do { \
+    if ( ( expr ) ) {                       \
+      /* Silence MOZ_WARN_UNUSED_RESULT. */ \
+    } \
+  } while (0)
+#endif
+
+#undef MOZ_DUMP_ASSERTION_STACK
+#undef MOZ_CRASH_CRASHREPORT
+
+#endif /* mozilla_Assertions_h */
diff --git a/src/third_party/mozjs-45/mfbt/Atomics.h b/src/third_party/mozjs-45/mfbt/Atomics.h
new file mode 100644
index 0000000..6293344
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Atomics.h
@@ -0,0 +1,800 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Implements (almost always) lock-free atomic operations. The operations here
+ * are a subset of that which can be found in C++11's <atomic> header, with a
+ * different API to enforce consistent memory ordering constraints.
+ *
+ * Anyone caught using |volatile| for inter-thread memory safety needs to be
+ * sent a copy of this header and the C++11 standard.
+ */
+
+#ifndef mozilla_Atomics_h
+#define mozilla_Atomics_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Compiler.h"
+#include "mozilla/TypeTraits.h"
+
+#include <stdint.h>
+
+/*
+ * Our minimum deployment target on clang/OS X is OS X 10.6, whose SDK
+ * does not have <atomic>.  So be sure to check for <atomic> support
+ * along with C++0x support.
+ */
+#if defined(_MSC_VER)
+#  define MOZ_HAVE_CXX11_ATOMICS
+#elif defined(__clang__) || defined(__GNUC__)
+   /*
+    * Clang doesn't like <atomic> from libstdc++ before 4.7 due to the
+    * loose typing of the atomic builtins. GCC 4.5 and 4.6 lacks inline
+    * definitions for unspecialized std::atomic and causes linking errors.
+    * Therefore, we require at least 4.7.0 for using libstdc++.
+    *
+    * libc++ <atomic> is only functional with clang.
+    */
+#  if MOZ_USING_LIBSTDCXX && MOZ_LIBSTDCXX_VERSION_AT_LEAST(4, 7, 0)
+#    define MOZ_HAVE_CXX11_ATOMICS
+#  elif MOZ_USING_LIBCXX && defined(__clang__)
+#    define MOZ_HAVE_CXX11_ATOMICS
+#  endif
+#endif
+
+namespace mozilla {
+
+/**
+ * An enum of memory ordering possibilities for atomics.
+ *
+ * Memory ordering is the observable state of distinct values in memory.
+ * (It's a separate concept from atomicity, which concerns whether an
+ * operation can ever be observed in an intermediate state.  Don't
+ * conflate the two!)  Given a sequence of operations in source code on
+ * memory, it is *not* always the case that, at all times and on all
+ * cores, those operations will appear to have occurred in that exact
+ * sequence.  First, the compiler might reorder that sequence, if it
+ * thinks another ordering will be more efficient.  Second, the CPU may
+ * not expose so consistent a view of memory.  CPUs will often perform
+ * their own instruction reordering, above and beyond that performed by
+ * the compiler.  And each core has its own memory caches, and accesses
+ * (reads and writes both) to "memory" may only resolve to out-of-date
+ * cache entries -- not to the "most recently" performed operation in
+ * some global sense.  Any access to a value that may be used by
+ * multiple threads, potentially across multiple cores, must therefore
+ * have a memory ordering imposed on it, for all code on all
+ * threads/cores to have a sufficiently coherent worldview.
+ *
+ * http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync and
+ * http://en.cppreference.com/w/cpp/atomic/memory_order go into more
+ * detail on all this, including examples of how each mode works.
+ *
+ * Note that for simplicity and practicality, not all of the modes in
+ * C++11 are supported.  The missing C++11 modes are either subsumed by
+ * the modes we provide below, or not relevant for the CPUs we support
+ * in Gecko.  These three modes are confusing enough as it is!
+ */
+enum MemoryOrdering {
+  /*
+   * Relaxed ordering is the simplest memory ordering: none at all.
+   * When the result of a write is observed, nothing may be inferred
+   * about other memory.  Writes ostensibly performed "before" on the
+   * writing thread may not yet be visible.  Writes performed "after" on
+   * the writing thread may already be visible, if the compiler or CPU
+   * reordered them.  (The latter can happen if reads and/or writes get
+   * held up in per-processor caches.)  Relaxed ordering means
+   * operations can always use cached values (as long as the actual
+   * updates to atomic values actually occur, correctly, eventually), so
+   * it's usually the fastest sort of atomic access.  For this reason,
+   * *it's also the most dangerous kind of access*.
+   *
+   * Relaxed ordering is good for things like process-wide statistics
+   * counters that don't need to be consistent with anything else, so
+   * long as updates themselves are atomic.  (And so long as any
+   * observations of that value can tolerate being out-of-date -- if you
+   * need some sort of up-to-date value, you need some sort of other
+   * synchronizing operation.)  It's *not* good for locks, mutexes,
+   * reference counts, etc. that mediate access to other memory, or must
+   * be observably consistent with other memory.
+   *
+   * x86 architectures don't take advantage of the optimization
+   * opportunities that relaxed ordering permits.  Thus it's possible
+   * that using relaxed ordering will "work" on x86 but fail elsewhere
+   * (ARM, say, which *does* implement non-sequentially-consistent
+   * relaxed ordering semantics).  Be extra-careful using relaxed
+   * ordering if you can't easily test non-x86 architectures!
+   */
+  Relaxed,
+
+  /*
+   * When an atomic value is updated with ReleaseAcquire ordering, and
+   * that new value is observed with ReleaseAcquire ordering, prior
+   * writes (atomic or not) are also observable.  What ReleaseAcquire
+   * *doesn't* give you is any observable ordering guarantees for
+   * ReleaseAcquire-ordered operations on different objects.  For
+   * example, if there are two cores that each perform ReleaseAcquire
+   * operations on separate objects, each core may or may not observe
+   * the operations made by the other core.  The only way the cores can
+   * be synchronized with ReleaseAcquire is if they both
+   * ReleaseAcquire-access the same object.  This implies that you can't
+   * necessarily describe some global total ordering of ReleaseAcquire
+   * operations.
+   *
+   * ReleaseAcquire ordering is good for (as the name implies) atomic
+   * operations on values controlling ownership of things: reference
+   * counts, mutexes, and the like.  However, if you are thinking about
+   * using these to implement your own locks or mutexes, you should take
+   * a good, hard look at actual lock or mutex primitives first.
+   */
+  ReleaseAcquire,
+
+  /*
+   * When an atomic value is updated with SequentiallyConsistent
+   * ordering, all writes observable when the update is observed, just
+   * as with ReleaseAcquire ordering.  But, furthermore, a global total
+   * ordering of SequentiallyConsistent operations *can* be described.
+   * For example, if two cores perform SequentiallyConsistent operations
+   * on separate objects, one core will observably perform its update
+   * (and all previous operations will have completed), then the other
+   * core will observably perform its update (and all previous
+   * operations will have completed).  (Although those previous
+   * operations aren't themselves ordered -- they could be intermixed,
+   * or ordered if they occur on atomic values with ordering
+   * requirements.)  SequentiallyConsistent is the *simplest and safest*
+   * ordering of atomic operations -- it's always as if one operation
+   * happens, then another, then another, in some order -- and every
+   * core observes updates to happen in that single order.  Because it
+   * has the most synchronization requirements, operations ordered this
+   * way also tend to be slowest.
+   *
+   * SequentiallyConsistent ordering can be desirable when multiple
+   * threads observe objects, and they all have to agree on the
+   * observable order of changes to them.  People expect
+   * SequentiallyConsistent ordering, even if they shouldn't, when
+   * writing code, atomic or otherwise.  SequentiallyConsistent is also
+   * the ordering of choice when designing lockless data structures.  If
+   * you don't know what order to use, use this one.
+   */
+  SequentiallyConsistent,
+};
+
+} // namespace mozilla
+
+// Build up the underlying intrinsics.
+#ifdef MOZ_HAVE_CXX11_ATOMICS
+
+#  include <atomic>
+
+namespace mozilla {
+namespace detail {
+
+/*
+ * We provide CompareExchangeFailureOrder to work around a bug in some
+ * versions of GCC's <atomic> header.  See bug 898491.
+ */
+template<MemoryOrdering Order> struct AtomicOrderConstraints;
+
+template<>
+struct AtomicOrderConstraints<Relaxed>
+{
+  static const std::memory_order AtomicRMWOrder = std::memory_order_relaxed;
+  static const std::memory_order LoadOrder = std::memory_order_relaxed;
+  static const std::memory_order StoreOrder = std::memory_order_relaxed;
+  static const std::memory_order CompareExchangeFailureOrder =
+    std::memory_order_relaxed;
+};
+
+template<>
+struct AtomicOrderConstraints<ReleaseAcquire>
+{
+  static const std::memory_order AtomicRMWOrder = std::memory_order_acq_rel;
+  static const std::memory_order LoadOrder = std::memory_order_acquire;
+  static const std::memory_order StoreOrder = std::memory_order_release;
+  static const std::memory_order CompareExchangeFailureOrder =
+    std::memory_order_acquire;
+};
+
+template<>
+struct AtomicOrderConstraints<SequentiallyConsistent>
+{
+  static const std::memory_order AtomicRMWOrder = std::memory_order_seq_cst;
+  static const std::memory_order LoadOrder = std::memory_order_seq_cst;
+  static const std::memory_order StoreOrder = std::memory_order_seq_cst;
+  static const std::memory_order CompareExchangeFailureOrder =
+    std::memory_order_seq_cst;
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicBase
+{
+  typedef std::atomic<T> ValueType;
+  typedef AtomicOrderConstraints<Order> OrderedOp;
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicMemoryOps : public IntrinsicBase<T, Order>
+{
+  typedef IntrinsicBase<T, Order> Base;
+
+  static T load(const typename Base::ValueType& aPtr)
+  {
+    return aPtr.load(Base::OrderedOp::LoadOrder);
+  }
+
+  static void store(typename Base::ValueType& aPtr, T aVal)
+  {
+    aPtr.store(aVal, Base::OrderedOp::StoreOrder);
+  }
+
+  static T exchange(typename Base::ValueType& aPtr, T aVal)
+  {
+    return aPtr.exchange(aVal, Base::OrderedOp::AtomicRMWOrder);
+  }
+
+  static bool compareExchange(typename Base::ValueType& aPtr,
+                              T aOldVal, T aNewVal)
+  {
+    return aPtr.compare_exchange_strong(aOldVal, aNewVal,
+                                        Base::OrderedOp::AtomicRMWOrder,
+                                        Base::OrderedOp::CompareExchangeFailureOrder);
+  }
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicAddSub : public IntrinsicBase<T, Order>
+{
+  typedef IntrinsicBase<T, Order> Base;
+
+  static T add(typename Base::ValueType& aPtr, T aVal)
+  {
+    return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder);
+  }
+
+  static T sub(typename Base::ValueType& aPtr, T aVal)
+  {
+    return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder);
+  }
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicAddSub<T*, Order> : public IntrinsicBase<T*, Order>
+{
+  typedef IntrinsicBase<T*, Order> Base;
+
+  static T* add(typename Base::ValueType& aPtr, ptrdiff_t aVal)
+  {
+    return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder);
+  }
+
+  static T* sub(typename Base::ValueType& aPtr, ptrdiff_t aVal)
+  {
+    return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder);
+  }
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicIncDec : public IntrinsicAddSub<T, Order>
+{
+  typedef IntrinsicBase<T, Order> Base;
+
+  static T inc(typename Base::ValueType& aPtr)
+  {
+    return IntrinsicAddSub<T, Order>::add(aPtr, 1);
+  }
+
+  static T dec(typename Base::ValueType& aPtr)
+  {
+    return IntrinsicAddSub<T, Order>::sub(aPtr, 1);
+  }
+};
+
+template<typename T, MemoryOrdering Order>
+struct AtomicIntrinsics : public IntrinsicMemoryOps<T, Order>,
+                          public IntrinsicIncDec<T, Order>
+{
+  typedef IntrinsicBase<T, Order> Base;
+
+  static T or_(typename Base::ValueType& aPtr, T aVal)
+  {
+    return aPtr.fetch_or(aVal, Base::OrderedOp::AtomicRMWOrder);
+  }
+
+  static T xor_(typename Base::ValueType& aPtr, T aVal)
+  {
+    return aPtr.fetch_xor(aVal, Base::OrderedOp::AtomicRMWOrder);
+  }
+
+  static T and_(typename Base::ValueType& aPtr, T aVal)
+  {
+    return aPtr.fetch_and(aVal, Base::OrderedOp::AtomicRMWOrder);
+  }
+};
+
+template<typename T, MemoryOrdering Order>
+struct AtomicIntrinsics<T*, Order>
+  : public IntrinsicMemoryOps<T*, Order>, public IntrinsicIncDec<T*, Order>
+{
+};
+
+template<typename T>
+struct ToStorageTypeArgument
+{
+  static T convert (T aT) { return aT; }
+};
+
+} // namespace detail
+} // namespace mozilla
+
+#elif defined(__GNUC__)
+
+namespace mozilla {
+namespace detail {
+
+/*
+ * The __sync_* family of intrinsics is documented here:
+ *
+ * http://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Atomic-Builtins.html
+ *
+ * While these intrinsics are deprecated in favor of the newer __atomic_*
+ * family of intrincs:
+ *
+ * http://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/_005f_005fatomic-Builtins.html
+ *
+ * any GCC version that supports the __atomic_* intrinsics will also support
+ * the <atomic> header and so will be handled above.  We provide a version of
+ * atomics using the __sync_* intrinsics to support older versions of GCC.
+ *
+ * All __sync_* intrinsics that we use below act as full memory barriers, for
+ * both compiler and hardware reordering, except for __sync_lock_test_and_set,
+ * which is a only an acquire barrier.  When we call __sync_lock_test_and_set,
+ * we add a barrier above it as appropriate.
+ */
+
+template<MemoryOrdering Order> struct Barrier;
+
+/*
+ * Some processors (in particular, x86) don't require quite so many calls to
+ * __sync_sychronize as our specializations of Barrier produce.  If
+ * performance turns out to be an issue, defining these specializations
+ * on a per-processor basis would be a good first tuning step.
+ */
+
+template<>
+struct Barrier<Relaxed>
+{
+  static void beforeLoad() {}
+  static void afterLoad() {}
+  static void beforeStore() {}
+  static void afterStore() {}
+};
+
+template<>
+struct Barrier<ReleaseAcquire>
+{
+  static void beforeLoad() {}
+  static void afterLoad() { __sync_synchronize(); }
+  static void beforeStore() { __sync_synchronize(); }
+  static void afterStore() {}
+};
+
+template<>
+struct Barrier<SequentiallyConsistent>
+{
+  static void beforeLoad() { __sync_synchronize(); }
+  static void afterLoad() { __sync_synchronize(); }
+  static void beforeStore() { __sync_synchronize(); }
+  static void afterStore() { __sync_synchronize(); }
+};
+
+template<typename T, bool TIsEnum = IsEnum<T>::value>
+struct AtomicStorageType
+{
+  // For non-enums, just use the type directly.
+  typedef T Type;
+};
+
+template<typename T>
+struct AtomicStorageType<T, true>
+  : Conditional<sizeof(T) == 4, uint32_t, uint64_t>
+{
+  static_assert(sizeof(T) == 4 || sizeof(T) == 8,
+                "wrong type computed in conditional above");
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicMemoryOps
+{
+  typedef typename AtomicStorageType<T>::Type ValueType;
+
+  static T load(const ValueType& aPtr)
+  {
+    Barrier<Order>::beforeLoad();
+    T val = T(aPtr);
+    Barrier<Order>::afterLoad();
+    return val;
+  }
+
+  static void store(ValueType& aPtr, T aVal)
+  {
+    Barrier<Order>::beforeStore();
+    aPtr = ValueType(aVal);
+    Barrier<Order>::afterStore();
+  }
+
+  static T exchange(ValueType& aPtr, T aVal)
+  {
+    // __sync_lock_test_and_set is only an acquire barrier; loads and stores
+    // can't be moved up from after to before it, but they can be moved down
+    // from before to after it.  We may want a stricter ordering, so we need
+    // an explicit barrier.
+    Barrier<Order>::beforeStore();
+    return T(__sync_lock_test_and_set(&aPtr, ValueType(aVal)));
+  }
+
+  static bool compareExchange(ValueType& aPtr, T aOldVal, T aNewVal)
+  {
+    return __sync_bool_compare_and_swap(&aPtr, ValueType(aOldVal), ValueType(aNewVal));
+  }
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicAddSub
+  : public IntrinsicMemoryOps<T, Order>
+{
+  typedef IntrinsicMemoryOps<T, Order> Base;
+  typedef typename Base::ValueType ValueType;
+
+  static T add(ValueType& aPtr, T aVal)
+  {
+    return T(__sync_fetch_and_add(&aPtr, ValueType(aVal)));
+  }
+
+  static T sub(ValueType& aPtr, T aVal)
+  {
+    return T(__sync_fetch_and_sub(&aPtr, ValueType(aVal)));
+  }
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicAddSub<T*, Order>
+  : public IntrinsicMemoryOps<T*, Order>
+{
+  typedef IntrinsicMemoryOps<T*, Order> Base;
+  typedef typename Base::ValueType ValueType;
+
+  /*
+   * The reinterpret_casts are needed so that
+   * __sync_fetch_and_{add,sub} will properly type-check.
+   *
+   * Also, these functions do not provide standard semantics for
+   * pointer types, so we need to adjust the addend.
+   */
+  static ValueType add(ValueType& aPtr, ptrdiff_t aVal)
+  {
+    ValueType amount = reinterpret_cast<ValueType>(aVal * sizeof(T));
+    return __sync_fetch_and_add(&aPtr, amount);
+  }
+
+  static ValueType sub(ValueType& aPtr, ptrdiff_t aVal)
+  {
+    ValueType amount = reinterpret_cast<ValueType>(aVal * sizeof(T));
+    return __sync_fetch_and_sub(&aPtr, amount);
+  }
+};
+
+template<typename T, MemoryOrdering Order>
+struct IntrinsicIncDec : public IntrinsicAddSub<T, Order>
+{
+  typedef IntrinsicAddSub<T, Order> Base;
+  typedef typename Base::ValueType ValueType;
+
+  static T inc(ValueType& aPtr) { return Base::add(aPtr, 1); }
+  static T dec(ValueType& aPtr) { return Base::sub(aPtr, 1); }
+};
+
+template<typename T, MemoryOrdering Order>
+struct AtomicIntrinsics : public IntrinsicIncDec<T, Order>
+{
+  static T or_( T& aPtr, T aVal) { return __sync_fetch_and_or(&aPtr, aVal); }
+  static T xor_(T& aPtr, T aVal) { return __sync_fetch_and_xor(&aPtr, aVal); }
+  static T and_(T& aPtr, T aVal) { return __sync_fetch_and_and(&aPtr, aVal); }
+};
+
+template<typename T, MemoryOrdering Order>
+struct AtomicIntrinsics<T*, Order> : public IntrinsicIncDec<T*, Order>
+{
+};
+
+template<typename T, bool TIsEnum = IsEnum<T>::value>
+struct ToStorageTypeArgument
+{
+  typedef typename AtomicStorageType<T>::Type ResultType;
+
+  static ResultType convert (T aT) { return ResultType(aT); }
+};
+
+template<typename T>
+struct ToStorageTypeArgument<T, false>
+{
+  static T convert (T aT) { return aT; }
+};
+
+} // namespace detail
+} // namespace mozilla
+
+#else
+# error "Atomic compiler intrinsics are not supported on your platform"
+#endif
+
+namespace mozilla {
+
+namespace detail {
+
+template<typename T, MemoryOrdering Order>
+class AtomicBase
+{
+  static_assert(sizeof(T) == 4 || sizeof(T) == 8,
+                "mozilla/Atomics.h only supports 32-bit and 64-bit types");
+
+protected:
+  typedef typename detail::AtomicIntrinsics<T, Order> Intrinsics;
+  typedef typename Intrinsics::ValueType ValueType;
+  ValueType mValue;
+
+public:
+  MOZ_CONSTEXPR AtomicBase() : mValue() {}
+  explicit MOZ_CONSTEXPR AtomicBase(T aInit)
+    : mValue(ToStorageTypeArgument<T>::convert(aInit))
+  {}
+
+  // Note: we can't provide operator T() here because Atomic<bool> inherits
+  // from AtomcBase with T=uint32_t and not T=bool. If we implemented
+  // operator T() here, it would cause errors when comparing Atomic<bool> with
+  // a regular bool.
+
+  T operator=(T aVal)
+  {
+    Intrinsics::store(mValue, aVal);
+    return aVal;
+  }
+
+  /**
+   * Performs an atomic swap operation.  aVal is stored and the previous
+   * value of this variable is returned.
+   */
+  T exchange(T aVal)
+  {
+    return Intrinsics::exchange(mValue, aVal);
+  }
+
+  /**
+   * Performs an atomic compare-and-swap operation and returns true if it
+   * succeeded. This is equivalent to atomically doing
+   *
+   *   if (mValue == aOldValue) {
+   *     mValue = aNewValue;
+   *     return true;
+   *   } else {
+   *     return false;
+   *   }
+   */
+  bool compareExchange(T aOldValue, T aNewValue)
+  {
+    return Intrinsics::compareExchange(mValue, aOldValue, aNewValue);
+  }
+
+private:
+  template<MemoryOrdering AnyOrder>
+  AtomicBase(const AtomicBase<T, AnyOrder>& aCopy) = delete;
+};
+
+template<typename T, MemoryOrdering Order>
+class AtomicBaseIncDec : public AtomicBase<T, Order>
+{
+  typedef typename detail::AtomicBase<T, Order> Base;
+
+public:
+  MOZ_CONSTEXPR AtomicBaseIncDec() : Base() {}
+  explicit MOZ_CONSTEXPR AtomicBaseIncDec(T aInit) : Base(aInit) {}
+
+  using Base::operator=;
+
+  operator T() const { return Base::Intrinsics::load(Base::mValue); }
+  T operator++(int) { return Base::Intrinsics::inc(Base::mValue); }
+  T operator--(int) { return Base::Intrinsics::dec(Base::mValue); }
+  T operator++() { return Base::Intrinsics::inc(Base::mValue) + 1; }
+  T operator--() { return Base::Intrinsics::dec(Base::mValue) - 1; }
+
+private:
+  template<MemoryOrdering AnyOrder>
+  AtomicBaseIncDec(const AtomicBaseIncDec<T, AnyOrder>& aCopy) = delete;
+};
+
+} // namespace detail
+
+/**
+ * A wrapper for a type that enforces that all memory accesses are atomic.
+ *
+ * In general, where a variable |T foo| exists, |Atomic<T> foo| can be used in
+ * its place.  Implementations for integral and pointer types are provided
+ * below.
+ *
+ * Atomic accesses are sequentially consistent by default.  You should
+ * use the default unless you are tall enough to ride the
+ * memory-ordering roller coaster (if you're not sure, you aren't) and
+ * you have a compelling reason to do otherwise.
+ *
+ * There is one exception to the case of atomic memory accesses: providing an
+ * initial value of the atomic value is not guaranteed to be atomic.  This is a
+ * deliberate design choice that enables static atomic variables to be declared
+ * without introducing extra static constructors.
+ */
+template<typename T,
+         MemoryOrdering Order = SequentiallyConsistent,
+         typename Enable = void>
+class Atomic;
+
+/**
+ * Atomic<T> implementation for integral types.
+ *
+ * In addition to atomic store and load operations, compound assignment and
+ * increment/decrement operators are implemented which perform the
+ * corresponding read-modify-write operation atomically.  Finally, an atomic
+ * swap method is provided.
+ */
+template<typename T, MemoryOrdering Order>
+class Atomic<T, Order, typename EnableIf<IsIntegral<T>::value &&
+                       !IsSame<T, bool>::value>::Type>
+  : public detail::AtomicBaseIncDec<T, Order>
+{
+  typedef typename detail::AtomicBaseIncDec<T, Order> Base;
+
+public:
+  MOZ_CONSTEXPR Atomic() : Base() {}
+  explicit MOZ_CONSTEXPR Atomic(T aInit) : Base(aInit) {}
+
+  using Base::operator=;
+
+  T operator+=(T aDelta)
+  {
+    return Base::Intrinsics::add(Base::mValue, aDelta) + aDelta;
+  }
+
+  T operator-=(T aDelta)
+  {
+    return Base::Intrinsics::sub(Base::mValue, aDelta) - aDelta;
+  }
+
+  T operator|=(T aVal)
+  {
+    return Base::Intrinsics::or_(Base::mValue, aVal) | aVal;
+  }
+
+  T operator^=(T aVal)
+  {
+    return Base::Intrinsics::xor_(Base::mValue, aVal) ^ aVal;
+  }
+
+  T operator&=(T aVal)
+  {
+    return Base::Intrinsics::and_(Base::mValue, aVal) & aVal;
+  }
+
+private:
+  Atomic(Atomic<T, Order>& aOther) = delete;
+};
+
+/**
+ * Atomic<T> implementation for pointer types.
+ *
+ * An atomic compare-and-swap primitive for pointer variables is provided, as
+ * are atomic increment and decement operators.  Also provided are the compound
+ * assignment operators for addition and subtraction. Atomic swap (via
+ * exchange()) is included as well.
+ */
+template<typename T, MemoryOrdering Order>
+class Atomic<T*, Order> : public detail::AtomicBaseIncDec<T*, Order>
+{
+  typedef typename detail::AtomicBaseIncDec<T*, Order> Base;
+
+public:
+  MOZ_CONSTEXPR Atomic() : Base() {}
+  explicit MOZ_CONSTEXPR Atomic(T* aInit) : Base(aInit) {}
+
+  using Base::operator=;
+
+  T* operator+=(ptrdiff_t aDelta)
+  {
+    return Base::Intrinsics::add(Base::mValue, aDelta) + aDelta;
+  }
+
+  T* operator-=(ptrdiff_t aDelta)
+  {
+    return Base::Intrinsics::sub(Base::mValue, aDelta) - aDelta;
+  }
+
+private:
+  Atomic(Atomic<T*, Order>& aOther) = delete;
+};
+
+/**
+ * Atomic<T> implementation for enum types.
+ *
+ * The atomic store and load operations and the atomic swap method is provided.
+ */
+template<typename T, MemoryOrdering Order>
+class Atomic<T, Order, typename EnableIf<IsEnum<T>::value>::Type>
+  : public detail::AtomicBase<T, Order>
+{
+  typedef typename detail::AtomicBase<T, Order> Base;
+
+public:
+  MOZ_CONSTEXPR Atomic() : Base() {}
+  explicit MOZ_CONSTEXPR Atomic(T aInit) : Base(aInit) {}
+
+  operator T() const { return T(Base::Intrinsics::load(Base::mValue)); }
+
+  using Base::operator=;
+
+private:
+  Atomic(Atomic<T, Order>& aOther) = delete;
+};
+
+/**
+ * Atomic<T> implementation for boolean types.
+ *
+ * The atomic store and load operations and the atomic swap method is provided.
+ *
+ * Note:
+ *
+ * - sizeof(Atomic<bool>) != sizeof(bool) for some implementations of
+ *   bool and/or some implementations of std::atomic. This is allowed in
+ *   [atomic.types.generic]p9.
+ *
+ * - It's not obvious whether the 8-bit atomic functions on Windows are always
+ *   inlined or not. If they are not inlined, the corresponding functions in the
+ *   runtime library are not available on Windows XP. This is why we implement
+ *   Atomic<bool> with an underlying type of uint32_t.
+ */
+template<MemoryOrdering Order>
+class Atomic<bool, Order>
+  : protected detail::AtomicBase<uint32_t, Order>
+{
+  typedef typename detail::AtomicBase<uint32_t, Order> Base;
+
+public:
+  MOZ_CONSTEXPR Atomic() : Base() {}
+  explicit MOZ_CONSTEXPR Atomic(bool aInit) : Base(aInit) {}
+
+  // We provide boolean wrappers for the underlying AtomicBase methods.
+  MOZ_IMPLICIT operator bool() const
+  {
+    return Base::Intrinsics::load(Base::mValue);
+  }
+
+  bool operator=(bool aVal)
+  {
+    return Base::operator=(aVal);
+  }
+
+  bool exchange(bool aVal)
+  {
+    return Base::exchange(aVal);
+  }
+
+  bool compareExchange(bool aOldValue, bool aNewValue)
+  {
+    return Base::compareExchange(aOldValue, aNewValue);
+  }
+
+private:
+  Atomic(Atomic<bool, Order>& aOther) = delete;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_Atomics_h */
diff --git a/src/third_party/mozjs-45/mfbt/Attributes.h b/src/third_party/mozjs-45/mfbt/Attributes.h
new file mode 100644
index 0000000..cb4bef9
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Attributes.h
@@ -0,0 +1,604 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implementations of various class and method modifier attributes. */
+
+#ifndef mozilla_Attributes_h
+#define mozilla_Attributes_h
+
+#include "mozilla/Compiler.h"
+
+/*
+ * MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the
+ * method decorated with it must be inlined, even if the compiler thinks
+ * otherwise.  This is only a (much) stronger version of the inline hint:
+ * compilers are not guaranteed to respect it (although they're much more likely
+ * to do so).
+ *
+ * The MOZ_ALWAYS_INLINE_EVEN_DEBUG macro is yet stronger. It tells the
+ * compiler to inline even in DEBUG builds. It should be used very rarely.
+ */
+#if defined(_MSC_VER)
+#  define MOZ_ALWAYS_INLINE_EVEN_DEBUG     __forceinline
+#elif defined(__GNUC__)
+#  define MOZ_ALWAYS_INLINE_EVEN_DEBUG     __attribute__((always_inline)) inline
+#else
+#  define MOZ_ALWAYS_INLINE_EVEN_DEBUG     inline
+#endif
+
+#if !defined(DEBUG)
+#  define MOZ_ALWAYS_INLINE     MOZ_ALWAYS_INLINE_EVEN_DEBUG
+#elif defined(_MSC_VER) && !defined(__cplusplus)
+#  define MOZ_ALWAYS_INLINE     __inline
+#else
+#  define MOZ_ALWAYS_INLINE     inline
+#endif
+
+#if defined(_MSC_VER)
+/*
+ * g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
+ * without warnings (functionality used by the macros below).  These modes are
+ * detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, more
+ * standardly, by checking whether __cplusplus has a C++11 or greater value.
+ * Current versions of g++ do not correctly set __cplusplus, so we check both
+ * for forward compatibility.
+ *
+ * Even though some versions of MSVC support explicit conversion operators, we
+ * don't indicate support for them here, due to
+ * http://stackoverflow.com/questions/20498142/visual-studio-2013-explicit-keyword-bug
+ */
+#  define MOZ_HAVE_NEVER_INLINE          __declspec(noinline)
+#  define MOZ_HAVE_NORETURN              __declspec(noreturn)
+#  if _MSC_VER >= 1900
+#    define MOZ_HAVE_CXX11_CONSTEXPR
+#    define MOZ_HAVE_CXX11_CONSTEXPR_IN_TEMPLATES
+#    define MOZ_HAVE_EXPLICIT_CONVERSION
+#  endif
+#  ifdef __clang__
+     /* clang-cl probably supports constexpr and explicit conversions. */
+#    if __has_extension(cxx_constexpr)
+#      define MOZ_HAVE_CXX11_CONSTEXPR
+#    endif
+#    if __has_extension(cxx_explicit_conversions)
+#      define MOZ_HAVE_EXPLICIT_CONVERSION
+#    endif
+#  endif
+#elif defined(__clang__)
+   /*
+    * Per Clang documentation, "Note that marketing version numbers should not
+    * be used to check for language features, as different vendors use different
+    * numbering schemes. Instead, use the feature checking macros."
+    */
+#  ifndef __has_extension
+#    define __has_extension __has_feature /* compatibility, for older versions of clang */
+#  endif
+#  if __has_extension(cxx_constexpr)
+#    define MOZ_HAVE_CXX11_CONSTEXPR
+#  endif
+#  if __has_extension(cxx_explicit_conversions)
+#    define MOZ_HAVE_EXPLICIT_CONVERSION
+#  endif
+#  if __has_attribute(noinline)
+#    define MOZ_HAVE_NEVER_INLINE        __attribute__((noinline))
+#  endif
+#  if __has_attribute(noreturn)
+#    define MOZ_HAVE_NORETURN            __attribute__((noreturn))
+#  endif
+#elif defined(__GNUC__)
+#  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
+#    define MOZ_HAVE_CXX11_CONSTEXPR
+#    if MOZ_GCC_VERSION_AT_LEAST(4, 8, 0)
+#      define MOZ_HAVE_CXX11_CONSTEXPR_IN_TEMPLATES
+#    endif
+#    define MOZ_HAVE_EXPLICIT_CONVERSION
+#  endif
+#  define MOZ_HAVE_NEVER_INLINE          __attribute__((noinline))
+#  define MOZ_HAVE_NORETURN              __attribute__((noreturn))
+#endif
+
+/*
+ * When built with clang analyzer (a.k.a scan-build), define MOZ_HAVE_NORETURN
+ * to mark some false positives
+ */
+#ifdef __clang_analyzer__
+#  if __has_extension(attribute_analyzer_noreturn)
+#    define MOZ_HAVE_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
+#  endif
+#endif
+
+/*
+ * The MOZ_CONSTEXPR specifier declares that a C++11 compiler can evaluate a
+ * function at compile time. A constexpr function cannot examine any values
+ * except its arguments and can have no side effects except its return value.
+ * The MOZ_CONSTEXPR_VAR specifier tells a C++11 compiler that a variable's
+ * value may be computed at compile time.  It should be prefered to just
+ * marking variables as MOZ_CONSTEXPR because if the compiler does not support
+ * constexpr it will fall back to making the variable const, and some compilers
+ * do not accept variables being marked both const and constexpr.
+ */
+#ifdef MOZ_HAVE_CXX11_CONSTEXPR
+#  define MOZ_CONSTEXPR         constexpr
+#  define MOZ_CONSTEXPR_VAR     constexpr
+#  ifdef MOZ_HAVE_CXX11_CONSTEXPR_IN_TEMPLATES
+#    define MOZ_CONSTEXPR_TMPL  constexpr
+#  else
+#    define MOZ_CONSTEXPR_TMPL
+#  endif
+#else
+#  define MOZ_CONSTEXPR         /* no support */
+#  define MOZ_CONSTEXPR_VAR     const
+#  define MOZ_CONSTEXPR_TMPL
+#endif
+
+/*
+ * MOZ_EXPLICIT_CONVERSION is a specifier on a type conversion
+ * overloaded operator that declares that a C++11 compiler should restrict
+ * this operator to allow only explicit type conversions, disallowing
+ * implicit conversions.
+ *
+ * Example:
+ *
+ *   template<typename T>
+ *   class Ptr
+ *   {
+ *     T* mPtr;
+ *     MOZ_EXPLICIT_CONVERSION operator bool() const
+ *     {
+ *       return mPtr != nullptr;
+ *     }
+ *   };
+ *
+ */
+#ifdef MOZ_HAVE_EXPLICIT_CONVERSION
+#  define MOZ_EXPLICIT_CONVERSION explicit
+#else
+#  define MOZ_EXPLICIT_CONVERSION /* no support */
+#endif
+
+/*
+ * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the
+ * method decorated with it must never be inlined, even if the compiler would
+ * otherwise choose to inline the method.  Compilers aren't absolutely
+ * guaranteed to support this, but most do.
+ */
+#if defined(MOZ_HAVE_NEVER_INLINE)
+#  define MOZ_NEVER_INLINE      MOZ_HAVE_NEVER_INLINE
+#else
+#  define MOZ_NEVER_INLINE      /* no support */
+#endif
+
+/*
+ * MOZ_NORETURN, specified at the start of a function declaration, indicates
+ * that the given function does not return.  (The function definition does not
+ * need to be annotated.)
+ *
+ *   MOZ_NORETURN void abort(const char* msg);
+ *
+ * This modifier permits the compiler to optimize code assuming a call to such a
+ * function will never return.  It also enables the compiler to avoid spurious
+ * warnings about not initializing variables, or about any other seemingly-dodgy
+ * operations performed after the function returns.
+ *
+ * This modifier does not affect the corresponding function's linking behavior.
+ */
+#if defined(MOZ_HAVE_NORETURN)
+#  define MOZ_NORETURN          MOZ_HAVE_NORETURN
+#else
+#  define MOZ_NORETURN          /* no support */
+#endif
+
+/**
+ * MOZ_COLD tells the compiler that a function is "cold", meaning infrequently
+ * executed. This may lead it to optimize for size more aggressively than speed,
+ * or to allocate the body of the function in a distant part of the text segment
+ * to help keep it from taking up unnecessary icache when it isn't in use.
+ *
+ * Place this attribute at the very beginning of a function definition. For
+ * example, write
+ *
+ *   MOZ_COLD int foo();
+ *
+ * or
+ *
+ *   MOZ_COLD int foo() { return 42; }
+ */
+#if defined(__GNUC__) || defined(__clang__)
+#  define MOZ_COLD __attribute__ ((cold))
+#else
+#  define MOZ_COLD
+#endif
+
+/**
+ * MOZ_NONNULL tells the compiler that some of the arguments to a function are
+ * known to be non-null. The arguments are a list of 1-based argument indexes
+ * identifying arguments which are known to be non-null.
+ *
+ * Place this attribute at the very beginning of a function definition. For
+ * example, write
+ *
+ *   MOZ_NONNULL(1, 2) int foo(char *p, char *q);
+ */
+#if defined(__GNUC__) || defined(__clang__)
+#  define MOZ_NONNULL(...) __attribute__ ((nonnull(__VA_ARGS__)))
+#else
+#  define MOZ_NONNULL(...)
+#endif
+
+/*
+ * MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS, specified at the end of a function
+ * declaration, indicates that for the purposes of static analysis, this
+ * function does not return.  (The function definition does not need to be
+ * annotated.)
+ *
+ * MOZ_ReportCrash(const char* s, const char* file, int ln)
+ *   MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
+ *
+ * Some static analyzers, like scan-build from clang, can use this information
+ * to eliminate false positives.  From the upstream documentation of scan-build:
+ * "This attribute is useful for annotating assertion handlers that actually
+ * can return, but for the purpose of using the analyzer we want to pretend
+ * that such functions do not return."
+ *
+ */
+#if defined(MOZ_HAVE_ANALYZER_NORETURN)
+#  define MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS          MOZ_HAVE_ANALYZER_NORETURN
+#else
+#  define MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS          /* no support */
+#endif
+
+/*
+ * MOZ_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time
+ * instrumentation shipped with Clang and GCC) to not instrument the annotated
+ * function. Furthermore, it will prevent the compiler from inlining the
+ * function because inlining currently breaks the blacklisting mechanism of
+ * AddressSanitizer.
+ */
+#if defined(__has_feature)
+#  if __has_feature(address_sanitizer)
+#    define MOZ_HAVE_ASAN_BLACKLIST
+#  endif
+#elif defined(__GNUC__)
+#  if defined(__SANITIZE_ADDRESS__)
+#    define MOZ_HAVE_ASAN_BLACKLIST
+#  endif
+#endif
+
+#if defined(MOZ_HAVE_ASAN_BLACKLIST)
+#  define MOZ_ASAN_BLACKLIST MOZ_NEVER_INLINE __attribute__((no_sanitize_address))
+#else
+#  define MOZ_ASAN_BLACKLIST /* nothing */
+#endif
+
+/*
+ * MOZ_TSAN_BLACKLIST is a macro to tell ThreadSanitizer (a compile-time
+ * instrumentation shipped with Clang) to not instrument the annotated function.
+ * Furthermore, it will prevent the compiler from inlining the function because
+ * inlining currently breaks the blacklisting mechanism of ThreadSanitizer.
+ */
+#if defined(__has_feature)
+#  if __has_feature(thread_sanitizer)
+#    define MOZ_TSAN_BLACKLIST MOZ_NEVER_INLINE __attribute__((no_sanitize_thread))
+#  else
+#    define MOZ_TSAN_BLACKLIST /* nothing */
+#  endif
+#else
+#  define MOZ_TSAN_BLACKLIST /* nothing */
+#endif
+
+/**
+ * MOZ_ALLOCATOR tells the compiler that the function it marks returns either a
+ * "fresh", "pointer-free" block of memory, or nullptr. "Fresh" means that the
+ * block is not pointed to by any other reachable pointer in the program.
+ * "Pointer-free" means that the block contains no pointers to any valid object
+ * in the program. It may be initialized with other (non-pointer) values.
+ *
+ * Placing this attribute on appropriate functions helps GCC analyze pointer
+ * aliasing more accurately in their callers.
+ *
+ * GCC warns if a caller ignores the value returned by a function marked with
+ * MOZ_ALLOCATOR: it is hard to imagine cases where dropping the value returned
+ * by a function that meets the criteria above would be intentional.
+ *
+ * Place this attribute after the argument list and 'this' qualifiers of a
+ * function definition. For example, write
+ *
+ *   void *my_allocator(size_t) MOZ_ALLOCATOR;
+ *
+ * or
+ *
+ *   void *my_allocator(size_t bytes) MOZ_ALLOCATOR { ... }
+ */
+#if defined(__GNUC__) || defined(__clang__)
+#  define MOZ_ALLOCATOR __attribute__ ((malloc, warn_unused_result))
+#else
+#  define MOZ_ALLOCATOR
+#endif
+
+/**
+ * MOZ_WARN_UNUSED_RESULT tells the compiler to emit a warning if a function's
+ * return value is not used by the caller.
+ *
+ * Place this attribute at the very beginning of a function definition. For
+ * example, write
+ *
+ *   MOZ_WARN_UNUSED_RESULT int foo();
+ *
+ * or
+ *
+ *   MOZ_WARN_UNUSED_RESULT int foo() { return 42; }
+ */
+#if defined(__GNUC__) || defined(__clang__)
+#  define MOZ_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
+#else
+#  define MOZ_WARN_UNUSED_RESULT
+#endif
+
+/**
+ * MOZ_FALLTHROUGH is an annotation to suppress compiler warnings about switch
+ * cases that fall through without a break or return statement. MOZ_FALLTHROUGH
+ * is only needed on cases that have code:
+ *
+ * switch (foo) {
+ *   case 1: // These cases have no code. No fallthrough annotations are needed.
+ *   case 2:
+ *   case 3:
+ *     foo = 4; // This case has code, so a fallthrough annotation is needed:
+ *     MOZ_FALLTHROUGH;
+ *   default:
+ *     return foo;
+ * }
+ */
+#if defined(__clang__) && __cplusplus >= 201103L
+   /* clang's fallthrough annotations are only available starting in C++11. */
+#  define MOZ_FALLTHROUGH [[clang::fallthrough]]
+#elif defined(_MSC_VER)
+   /*
+    * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis):
+    * https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx
+    */
+#  include <sal.h>
+#  define MOZ_FALLTHROUGH __fallthrough
+#else
+#  define MOZ_FALLTHROUGH /* FALLTHROUGH */
+#endif
+
+#ifdef __cplusplus
+
+/*
+ * The following macros are attributes that support the static analysis plugin
+ * included with Mozilla, and will be implemented (when such support is enabled)
+ * as C++11 attributes. Since such attributes are legal pretty much everywhere
+ * and have subtly different semantics depending on their placement, the
+ * following is a guide on where to place the attributes.
+ *
+ * Attributes that apply to a struct or class precede the name of the class:
+ * (Note that this is different from the placement of final for classes!)
+ *
+ *   class MOZ_CLASS_ATTRIBUTE SomeClass {};
+ *
+ * Attributes that apply to functions follow the parentheses and const
+ * qualifiers but precede final, override and the function body:
+ *
+ *   void DeclaredFunction() MOZ_FUNCTION_ATTRIBUTE;
+ *   void SomeFunction() MOZ_FUNCTION_ATTRIBUTE {}
+ *   void PureFunction() const MOZ_FUNCTION_ATTRIBUTE = 0;
+ *   void OverriddenFunction() MOZ_FUNCTION_ATTIRBUTE override;
+ *
+ * Attributes that apply to variables or parameters follow the variable's name:
+ *
+ *   int variable MOZ_VARIABLE_ATTRIBUTE;
+ *
+ * Attributes that apply to types follow the type name:
+ *
+ *   typedef int MOZ_TYPE_ATTRIBUTE MagicInt;
+ *   int MOZ_TYPE_ATTRIBUTE someVariable;
+ *   int* MOZ_TYPE_ATTRIBUTE magicPtrInt;
+ *   int MOZ_TYPE_ATTRIBUTE* ptrToMagicInt;
+ *
+ * Attributes that apply to statements precede the statement:
+ *
+ *   MOZ_IF_ATTRIBUTE if (x == 0)
+ *   MOZ_DO_ATTRIBUTE do { } while (0);
+ *
+ * Attributes that apply to labels precede the label:
+ *
+ *   MOZ_LABEL_ATTRIBUTE target:
+ *     goto target;
+ *   MOZ_CASE_ATTRIBUTE case 5:
+ *   MOZ_DEFAULT_ATTRIBUTE default:
+ *
+ * The static analyses that are performed by the plugin are as follows:
+ *
+ * MOZ_MUST_OVERRIDE: Applies to all C++ member functions. All immediate
+ *   subclasses must provide an exact override of this method; if a subclass
+ *   does not override this method, the compiler will emit an error. This
+ *   attribute is not limited to virtual methods, so if it is applied to a
+ *   nonvirtual method and the subclass does not provide an equivalent
+ *   definition, the compiler will emit an error.
+ * MOZ_STACK_CLASS: Applies to all classes. Any class with this annotation is
+ *   expected to live on the stack, so it is a compile-time error to use it, or
+ *   an array of such objects, as a global or static variable, or as the type of
+ *   a new expression (unless placement new is being used). If a member of
+ *   another class uses this class, or if another class inherits from this
+ *   class, then it is considered to be a stack class as well, although this
+ *   attribute need not be provided in such cases.
+ * MOZ_NONHEAP_CLASS: Applies to all classes. Any class with this annotation is
+ *   expected to live on the stack or in static storage, so it is a compile-time
+ *   error to use it, or an array of such objects, as the type of a new
+ *   expression. If a member of another class uses this class, or if another
+ *   class inherits from this class, then it is considered to be a non-heap class
+ *   as well, although this attribute need not be provided in such cases.
+ * MOZ_HEAP_CLASS: Applies to all classes. Any class with this annotation is
+ *   expected to live on the heap, so it is a compile-time error to use it, or
+ *   an array of such objects, as the type of a variable declaration, or as a
+ *   temporary object. If a member of another class uses this class, or if
+ *   another class inherits from this class, then it is considered to be a heap
+ *   class as well, although this attribute need not be provided in such cases.
+ * MOZ_NON_TEMPORARY_CLASS: Applies to all classes. Any class with this
+ *   annotation is expected not to live in a temporary. If a member of another
+ *   class uses this class or if another class inherits from this class, then it
+ *   is considered to be a non-temporary class as well, although this attribute
+ *   need not be provided in such cases.
+ * MOZ_RAII: Applies to all classes. Any class with this annotation is assumed
+ *   to be a RAII guard, which is expected to live on the stack in an automatic
+ *   allocation. It is prohibited from being allocated in a temporary, static
+ *   storage, or on the heap. This is a combination of MOZ_STACK_CLASS and
+ *   MOZ_NON_TEMPORARY_CLASS.
+ * MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS: Applies to all classes that are
+ *   intended to prevent introducing static initializers.  This attribute
+ *   currently makes it a compile-time error to instantiate these classes
+ *   anywhere other than at the global scope, or as a static member of a class.
+ * MOZ_TRIVIAL_CTOR_DTOR: Applies to all classes that must have both a trivial
+ *   constructor and a trivial destructor.  Setting this attribute on a class
+ *   makes it a compile-time error for that class to get a non-trivial
+ *   constructor or destructor for any reason.
+ * MOZ_HEAP_ALLOCATOR: Applies to any function. This indicates that the return
+ *   value is allocated on the heap, and will as a result check such allocations
+ *   during MOZ_STACK_CLASS and MOZ_NONHEAP_CLASS annotation checking.
+ * MOZ_IMPLICIT: Applies to constructors. Implicit conversion constructors
+ *   are disallowed by default unless they are marked as MOZ_IMPLICIT. This
+ *   attribute must be used for constructors which intend to provide implicit
+ *   conversions.
+ * MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT: Applies to functions. Makes it a compile
+ *   time error to pass arithmetic expressions on variables to the function.
+ * MOZ_OWNING_REF: Applies to declarations of pointers to reference counted
+ *   types.  This attribute tells the compiler that the raw pointer is a strong
+ *   reference, where ownership through methods such as AddRef and Release is
+ *   managed manually.  This can make the compiler ignore these pointers when
+ *   validating the usage of pointers otherwise.
+ *
+ *   Example uses include owned pointers inside of unions, and pointers stored
+ *   in POD types where a using a smart pointer class would make the object
+ *   non-POD.
+ * MOZ_NON_OWNING_REF: Applies to declarations of pointers to reference counted
+ *   types.  This attribute tells the compiler that the raw pointer is a weak
+ *   reference, which is ensured to be valid by a guarantee that the reference
+ *   will be nulled before the pointer becomes invalid.  This can make the compiler
+ *   ignore these pointers when validating the usage of pointers otherwise.
+ *
+ *   Examples include an mOwner pointer, which is nulled by the owning class's
+ *   destructor, and is null-checked before dereferencing.
+ * MOZ_UNSAFE_REF: Applies to declarations of pointers to reference counted types.
+ *   Occasionally there are non-owning references which are valid, but do not take
+ *   the form of a MOZ_NON_OWNING_REF.  Their safety may be dependent on the behaviour
+ *   of API consumers.  The string argument passed to this macro documents the safety
+ *   conditions.  This can make the compiler ignore these pointers when validating
+ *   the usage of pointers elsewhere.
+ *
+ *   Examples include an nsIAtom* member which is known at compile time to point to a
+ *   static atom which is valid throughout the lifetime of the program, or an API which
+ *   stores a pointer, but doesn't take ownership over it, instead requiring the API
+ *   consumer to correctly null the value before it becomes invalid.
+ *
+ *   Use of this annotation is discouraged when a strong reference or one of the above
+ *   two annotations can be used instead.
+ * MOZ_NO_ADDREF_RELEASE_ON_RETURN: Applies to function declarations.  Makes it
+ *   a compile time error to call AddRef or Release on the return value of a
+ *   function.  This is intended to be used with operator->() of our smart
+ *   pointer classes to ensure that the refcount of an object wrapped in a
+ *   smart pointer is not manipulated directly.
+ * MOZ_MUST_USE: Applies to type declarations.  Makes it a compile time error to not
+ *   use the return value of a function which has this type.  This is intended to be
+ *   used with types which it is an error to not use.
+ * MOZ_NEEDS_NO_VTABLE_TYPE: Applies to template class declarations.  Makes it
+ *   a compile time error to instantiate this template with a type parameter which
+ *   has a VTable.
+ * MOZ_NON_MEMMOVABLE: Applies to class declarations for types that are not safe
+ *   to be moved in memory using memmove().
+ * MOZ_NEEDS_MEMMOVABLE_TYPE: Applies to template class declarations where the
+ *   template arguments are required to be safe to move in memory using
+ *   memmove().  Passing MOZ_NON_MEMMOVABLE types to these templates is a
+ *   compile time error.
+ * MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS: Applies to template class
+ *   declarations where an instance of the template should be considered, for
+ *   static analysis purposes, to inherit any type annotations (such as
+ *   MOZ_MUST_USE and MOZ_STACK_CLASS) from its template arguments.
+ * MOZ_NON_AUTOABLE: Applies to class declarations. Makes it a compile time error to
+ *   use `auto` in place of this type in variable declarations.  This is intended to
+ *   be used with types which are intended to be implicitly constructed into other
+ *   other types before being assigned to variables.
+ */
+#ifdef MOZ_CLANG_PLUGIN
+#  define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
+#  define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))
+#  define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
+#  define MOZ_HEAP_CLASS __attribute__((annotate("moz_heap_class")))
+#  define MOZ_NON_TEMPORARY_CLASS __attribute__((annotate("moz_non_temporary_class")))
+#  define MOZ_TRIVIAL_CTOR_DTOR __attribute__((annotate("moz_trivial_ctor_dtor")))
+#  ifdef DEBUG
+     /* in debug builds, these classes do have non-trivial constructors. */
+#    define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class")))
+#  else
+#    define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class"))) \
+            MOZ_TRIVIAL_CTOR_DTOR
+#  endif
+#  define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
+#  define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg")))
+#  define MOZ_OWNING_REF __attribute__((annotate("moz_strong_ref")))
+#  define MOZ_NON_OWNING_REF __attribute__((annotate("moz_weak_ref")))
+#  define MOZ_UNSAFE_REF(reason) __attribute__((annotate("moz_weak_ref")))
+#  define MOZ_NO_ADDREF_RELEASE_ON_RETURN __attribute__((annotate("moz_no_addref_release_on_return")))
+#  define MOZ_MUST_USE __attribute__((annotate("moz_must_use")))
+#  define MOZ_NEEDS_NO_VTABLE_TYPE __attribute__((annotate("moz_needs_no_vtable_type")))
+#  define MOZ_NON_MEMMOVABLE __attribute__((annotate("moz_non_memmovable")))
+#  define MOZ_NEEDS_MEMMOVABLE_TYPE __attribute__((annotate("moz_needs_memmovable_type")))
+#  define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS \
+    __attribute__((annotate("moz_inherit_type_annotations_from_template_args")))
+#  define MOZ_NON_AUTOABLE __attribute__((annotate("moz_non_autoable")))
+/*
+ * It turns out that clang doesn't like void func() __attribute__ {} without a
+ * warning, so use pragmas to disable the warning. This code won't work on GCC
+ * anyways, so the warning is safe to ignore.
+ */
+#  define MOZ_HEAP_ALLOCATOR \
+    _Pragma("clang diagnostic push") \
+    _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
+    __attribute__((annotate("moz_heap_allocator"))) \
+    _Pragma("clang diagnostic pop")
+#else
+#  define MOZ_MUST_OVERRIDE /* nothing */
+#  define MOZ_STACK_CLASS /* nothing */
+#  define MOZ_NONHEAP_CLASS /* nothing */
+#  define MOZ_HEAP_CLASS /* nothing */
+#  define MOZ_NON_TEMPORARY_CLASS /* nothing */
+#  define MOZ_TRIVIAL_CTOR_DTOR /* nothing */
+#  define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS /* nothing */
+#  define MOZ_IMPLICIT /* nothing */
+#  define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT /* nothing */
+#  define MOZ_HEAP_ALLOCATOR /* nothing */
+#  define MOZ_OWNING_REF /* nothing */
+#  define MOZ_NON_OWNING_REF /* nothing */
+#  define MOZ_UNSAFE_REF(reason) /* nothing */
+#  define MOZ_NO_ADDREF_RELEASE_ON_RETURN /* nothing */
+#  define MOZ_MUST_USE /* nothing */
+#  define MOZ_NEEDS_NO_VTABLE_TYPE /* nothing */
+#  define MOZ_NON_MEMMOVABLE /* nothing */
+#  define MOZ_NEEDS_MEMMOVABLE_TYPE /* nothing */
+#  define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS /* nothing */
+#  define MOZ_NON_AUTOABLE /* nothing */
+#endif /* MOZ_CLANG_PLUGIN */
+
+#define MOZ_RAII MOZ_NON_TEMPORARY_CLASS MOZ_STACK_CLASS
+
+/*
+ * MOZ_HAVE_REF_QUALIFIERS is defined for compilers that support C++11's rvalue
+ * qualifier, "&&".
+ */
+#if defined(_MSC_VER) && _MSC_VER >= 1900
+#  define MOZ_HAVE_REF_QUALIFIERS
+#elif defined(__clang__)
+// All supported Clang versions
+#  define MOZ_HAVE_REF_QUALIFIERS
+#elif defined(__GNUC__)
+#  include "mozilla/Compiler.h"
+#  if MOZ_GCC_VERSION_AT_LEAST(4, 8, 1)
+#    define MOZ_HAVE_REF_QUALIFIERS
+#  endif
+#endif
+
+#endif /* __cplusplus */
+
+#endif /* mozilla_Attributes_h */
diff --git a/src/third_party/mozjs-45/mfbt/BinarySearch.h b/src/third_party/mozjs-45/mfbt/BinarySearch.h
new file mode 100644
index 0000000..e4cebdf
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/BinarySearch.h
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_BinarySearch_h
+#define mozilla_BinarySearch_h
+
+#include "mozilla/Assertions.h"
+
+#include <stddef.h>
+
+namespace mozilla {
+
+/*
+ * The BinarySearch() algorithm searches the given container |aContainer| over
+ * the sorted index range [aBegin, aEnd) for an index |i| where
+ * |aContainer[i] == aTarget|.
+ * If such an index |i| is found, BinarySearch returns |true| and the index is
+ * returned via the outparam |aMatchOrInsertionPoint|. If no index is found,
+ * BinarySearch returns |false| and the outparam returns the first index in
+ * [aBegin, aEnd] where |aTarget| can be inserted to maintain sorted order.
+ *
+ * Example:
+ *
+ *   Vector<int> sortedInts = ...
+ *
+ *   size_t match;
+ *   if (BinarySearch(sortedInts, 0, sortedInts.length(), 13, &match)) {
+ *     printf("found 13 at %lu\n", match);
+ *   }
+ *
+ * The BinarySearchIf() version behaves similar, but takes |aComparator|, a
+ * functor to compare the values with, instead of a value to find.
+ * That functor should take one argument - the value to compare - and return an
+ * |int| with the comparison result:
+ *
+ *   * 0, if the argument is equal to,
+ *   * less than 0, if the argument is greater than,
+ *   * greater than 0, if the argument is less than
+ *
+ * the value.
+ *
+ * Example:
+ *
+ *   struct Comparator {
+ *     int operator()(int val) const {
+ *       if (mTarget < val) return -1;
+ *       if (mValue > val) return 1;
+ *       return 0;
+ *     }
+ *     Comparator(int target) : mTarget(target) {}
+       const int mTarget;
+ *   };
+ *
+ *   Vector<int> sortedInts = ...
+ *
+ *   size_t match;
+ *   if (BinarySearchIf(sortedInts, 0, sortedInts.length(), Comparator(13), &match)) {
+ *     printf("found 13 at %lu\n", match);
+ *   }
+ *
+ */
+
+template<typename Container, typename Comparator>
+bool
+BinarySearchIf(const Container& aContainer, size_t aBegin, size_t aEnd,
+               const Comparator& aCompare, size_t* aMatchOrInsertionPoint)
+{
+  MOZ_ASSERT(aBegin <= aEnd);
+
+  size_t low = aBegin;
+  size_t high = aEnd;
+  while (high != low) {
+    size_t middle = low + (high - low) / 2;
+
+    // Allow any intermediate type so long as it provides a suitable ordering
+    // relation.
+    const int result = aCompare(aContainer[middle]);
+
+    if (result == 0) {
+      *aMatchOrInsertionPoint = middle;
+      return true;
+    }
+
+    if (result < 0) {
+      high = middle;
+    } else {
+      low = middle + 1;
+    }
+  }
+
+  *aMatchOrInsertionPoint = low;
+  return false;
+}
+
+namespace detail {
+
+template<class T>
+class BinarySearchDefaultComparator
+{
+public:
+  explicit BinarySearchDefaultComparator(const T& aTarget)
+    : mTarget(aTarget)
+  {}
+
+  template <class U>
+  int operator()(const U& val) const {
+    if (mTarget == val) {
+      return 0;
+    }
+
+    if (mTarget < val) {
+      return -1;
+    }
+
+    return 1;
+  }
+
+private:
+  const T& mTarget;
+};
+
+} // namespace detail
+
+template <typename Container, typename T>
+bool
+BinarySearch(const Container& aContainer, size_t aBegin, size_t aEnd,
+             T aTarget, size_t* aMatchOrInsertionPoint)
+{
+  return BinarySearchIf(aContainer, aBegin, aEnd,
+                        detail::BinarySearchDefaultComparator<T>(aTarget),
+                        aMatchOrInsertionPoint);
+}
+
+} // namespace mozilla
+
+#endif // mozilla_BinarySearch_h
diff --git a/src/third_party/mozjs-45/mfbt/BloomFilter.h b/src/third_party/mozjs-45/mfbt/BloomFilter.h
new file mode 100644
index 0000000..6757e41
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/BloomFilter.h
@@ -0,0 +1,256 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * A counting Bloom filter implementation.  This allows consumers to
+ * do fast probabilistic "is item X in set Y?" testing which will
+ * never answer "no" when the correct answer is "yes" (but might
+ * incorrectly answer "yes" when the correct answer is "no").
+ */
+
+#ifndef mozilla_BloomFilter_h
+#define mozilla_BloomFilter_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Likely.h"
+
+#include <stdint.h>
+#include <string.h>
+
+namespace mozilla {
+
+/*
+ * This class implements a counting Bloom filter as described at
+ * <http://en.wikipedia.org/wiki/Bloom_filter#Counting_filters>, with
+ * 8-bit counters.  This allows quick probabilistic answers to the
+ * question "is object X in set Y?" where the contents of Y might not
+ * be time-invariant.  The probabilistic nature of the test means that
+ * sometimes the answer will be "yes" when it should be "no".  If the
+ * answer is "no", then X is guaranteed not to be in Y.
+ *
+ * The filter is parametrized on KeySize, which is the size of the key
+ * generated by each of hash functions used by the filter, in bits,
+ * and the type of object T being added and removed.  T must implement
+ * a |uint32_t hash() const| method which returns a uint32_t hash key
+ * that will be used to generate the two separate hash functions for
+ * the Bloom filter.  This hash key MUST be well-distributed for good
+ * results!  KeySize is not allowed to be larger than 16.
+ *
+ * The filter uses exactly 2**KeySize bytes of memory.  From now on we
+ * will refer to the memory used by the filter as M.
+ *
+ * The expected rate of incorrect "yes" answers depends on M and on
+ * the number N of objects in set Y.  As long as N is small compared
+ * to M, the rate of such answers is expected to be approximately
+ * 4*(N/M)**2 for this filter.  In practice, if Y has a few hundred
+ * elements then using a KeySize of 12 gives a reasonably low
+ * incorrect answer rate.  A KeySize of 12 has the additional benefit
+ * of using exactly one page for the filter in typical hardware
+ * configurations.
+ */
+
+template<unsigned KeySize, class T>
+class BloomFilter
+{
+  /*
+   * A counting Bloom filter with 8-bit counters.  For now we assume
+   * that having two hash functions is enough, but we may revisit that
+   * decision later.
+   *
+   * The filter uses an array with 2**KeySize entries.
+   *
+   * Assuming a well-distributed hash function, a Bloom filter with
+   * array size M containing N elements and
+   * using k hash function has expected false positive rate exactly
+   *
+   * $  (1 - (1 - 1/M)^{kN})^k  $
+   *
+   * because each array slot has a
+   *
+   * $  (1 - 1/M)^{kN}  $
+   *
+   * chance of being 0, and the expected false positive rate is the
+   * probability that all of the k hash functions will hit a nonzero
+   * slot.
+   *
+   * For reasonable assumptions (M large, kN large, which should both
+   * hold if we're worried about false positives) about M and kN this
+   * becomes approximately
+   *
+   * $$  (1 - \exp(-kN/M))^k   $$
+   *
+   * For our special case of k == 2, that's $(1 - \exp(-2N/M))^2$,
+   * or in other words
+   *
+   * $$    N/M = -0.5 * \ln(1 - \sqrt(r))   $$
+   *
+   * where r is the false positive rate.  This can be used to compute
+   * the desired KeySize for a given load N and false positive rate r.
+   *
+   * If N/M is assumed small, then the false positive rate can
+   * further be approximated as 4*N^2/M^2.  So increasing KeySize by
+   * 1, which doubles M, reduces the false positive rate by about a
+   * factor of 4, and a false positive rate of 1% corresponds to
+   * about M/N == 20.
+   *
+   * What this means in practice is that for a few hundred keys using a
+   * KeySize of 12 gives false positive rates on the order of 0.25-4%.
+   *
+   * Similarly, using a KeySize of 10 would lead to a 4% false
+   * positive rate for N == 100 and to quite bad false positive
+   * rates for larger N.
+   */
+public:
+  BloomFilter()
+  {
+    static_assert(KeySize <= kKeyShift, "KeySize too big");
+
+    // Should we have a custom operator new using calloc instead and
+    // require that we're allocated via the operator?
+    clear();
+  }
+
+  /*
+   * Clear the filter.  This should be done before reusing it, because
+   * just removing all items doesn't clear counters that hit the upper
+   * bound.
+   */
+  void clear();
+
+  /*
+   * Add an item to the filter.
+   */
+  void add(const T* aValue);
+
+  /*
+   * Remove an item from the filter.
+   */
+  void remove(const T* aValue);
+
+  /*
+   * Check whether the filter might contain an item.  This can
+   * sometimes return true even if the item is not in the filter,
+   * but will never return false for items that are actually in the
+   * filter.
+   */
+  bool mightContain(const T* aValue) const;
+
+  /*
+   * Methods for add/remove/contain when we already have a hash computed
+   */
+  void add(uint32_t aHash);
+  void remove(uint32_t aHash);
+  bool mightContain(uint32_t aHash) const;
+
+private:
+  static const size_t kArraySize = (1 << KeySize);
+  static const uint32_t kKeyMask = (1 << KeySize) - 1;
+  static const uint32_t kKeyShift = 16;
+
+  static uint32_t hash1(uint32_t aHash)
+  {
+    return aHash & kKeyMask;
+  }
+  static uint32_t hash2(uint32_t aHash)
+  {
+    return (aHash >> kKeyShift) & kKeyMask;
+  }
+
+  uint8_t& firstSlot(uint32_t aHash)
+  {
+    return mCounters[hash1(aHash)];
+  }
+  uint8_t& secondSlot(uint32_t aHash)
+  {
+    return mCounters[hash2(aHash)];
+  }
+
+  const uint8_t& firstSlot(uint32_t aHash) const
+  {
+    return mCounters[hash1(aHash)];
+  }
+  const uint8_t& secondSlot(uint32_t aHash) const
+  {
+    return mCounters[hash2(aHash)];
+  }
+
+  static bool full(const uint8_t& aSlot) { return aSlot == UINT8_MAX; }
+
+  uint8_t mCounters[kArraySize];
+};
+
+template<unsigned KeySize, class T>
+inline void
+BloomFilter<KeySize, T>::clear()
+{
+  memset(mCounters, 0, kArraySize);
+}
+
+template<unsigned KeySize, class T>
+inline void
+BloomFilter<KeySize, T>::add(uint32_t aHash)
+{
+  uint8_t& slot1 = firstSlot(aHash);
+  if (MOZ_LIKELY(!full(slot1))) {
+    ++slot1;
+  }
+  uint8_t& slot2 = secondSlot(aHash);
+  if (MOZ_LIKELY(!full(slot2))) {
+    ++slot2;
+  }
+}
+
+template<unsigned KeySize, class T>
+MOZ_ALWAYS_INLINE void
+BloomFilter<KeySize, T>::add(const T* aValue)
+{
+  uint32_t hash = aValue->hash();
+  return add(hash);
+}
+
+template<unsigned KeySize, class T>
+inline void
+BloomFilter<KeySize, T>::remove(uint32_t aHash)
+{
+  // If the slots are full, we don't know whether we bumped them to be
+  // there when we added or not, so just leave them full.
+  uint8_t& slot1 = firstSlot(aHash);
+  if (MOZ_LIKELY(!full(slot1))) {
+    --slot1;
+  }
+  uint8_t& slot2 = secondSlot(aHash);
+  if (MOZ_LIKELY(!full(slot2))) {
+    --slot2;
+  }
+}
+
+template<unsigned KeySize, class T>
+MOZ_ALWAYS_INLINE void
+BloomFilter<KeySize, T>::remove(const T* aValue)
+{
+  uint32_t hash = aValue->hash();
+  remove(hash);
+}
+
+template<unsigned KeySize, class T>
+MOZ_ALWAYS_INLINE bool
+BloomFilter<KeySize, T>::mightContain(uint32_t aHash) const
+{
+  // Check that all the slots for this hash contain something
+  return firstSlot(aHash) && secondSlot(aHash);
+}
+
+template<unsigned KeySize, class T>
+MOZ_ALWAYS_INLINE bool
+BloomFilter<KeySize, T>::mightContain(const T* aValue) const
+{
+  uint32_t hash = aValue->hash();
+  return mightContain(hash);
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_BloomFilter_h */
diff --git a/src/third_party/mozjs-45/mfbt/Casting.h b/src/third_party/mozjs-45/mfbt/Casting.h
new file mode 100644
index 0000000..176e54d
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Casting.h
@@ -0,0 +1,221 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Cast operations to supplement the built-in casting operations. */
+
+#ifndef mozilla_Casting_h
+#define mozilla_Casting_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/TypeTraits.h"
+
+#include <limits.h>
+
+namespace mozilla {
+
+/**
+ * Return a value of type |To|, containing the underlying bit pattern of
+ * |aFrom|.
+ *
+ * |To| and |From| must be types of the same size; be careful of cross-platform
+ * size differences, or this might fail to compile on some but not all
+ * platforms.
+ */
+template<typename To, typename From>
+inline To
+BitwiseCast(const From aFrom)
+{
+  static_assert(sizeof(From) == sizeof(To),
+                "To and From must have the same size");
+  union
+  {
+    From mFrom;
+    To mTo;
+  } u;
+  u.mFrom = aFrom;
+  return u.mTo;
+}
+
+namespace detail {
+
+enum ToSignedness { ToIsSigned, ToIsUnsigned };
+enum FromSignedness { FromIsSigned, FromIsUnsigned };
+
+template<typename From,
+         typename To,
+         FromSignedness = IsSigned<From>::value ? FromIsSigned : FromIsUnsigned,
+         ToSignedness = IsSigned<To>::value ? ToIsSigned : ToIsUnsigned>
+struct BoundsCheckImpl;
+
+// Implicit conversions on operands to binary operations make this all a bit
+// hard to verify.  Attempt to ease the pain below by *only* comparing values
+// that are obviously the same type (and will undergo no further conversions),
+// even when it's not strictly necessary, for explicitness.
+
+enum UUComparison { FromIsBigger, FromIsNotBigger };
+
+// Unsigned-to-unsigned range check
+
+template<typename From, typename To,
+         UUComparison = (sizeof(From) > sizeof(To))
+                        ? FromIsBigger
+                        : FromIsNotBigger>
+struct UnsignedUnsignedCheck;
+
+template<typename From, typename To>
+struct UnsignedUnsignedCheck<From, To, FromIsBigger>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    return aFrom <= From(To(-1));
+  }
+};
+
+template<typename From, typename To>
+struct UnsignedUnsignedCheck<From, To, FromIsNotBigger>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    return true;
+  }
+};
+
+template<typename From, typename To>
+struct BoundsCheckImpl<From, To, FromIsUnsigned, ToIsUnsigned>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    return UnsignedUnsignedCheck<From, To>::checkBounds(aFrom);
+  }
+};
+
+// Signed-to-unsigned range check
+
+template<typename From, typename To>
+struct BoundsCheckImpl<From, To, FromIsSigned, ToIsUnsigned>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    if (aFrom < 0) {
+      return false;
+    }
+    if (sizeof(To) >= sizeof(From)) {
+      return true;
+    }
+    return aFrom <= From(To(-1));
+  }
+};
+
+// Unsigned-to-signed range check
+
+enum USComparison { FromIsSmaller, FromIsNotSmaller };
+
+template<typename From, typename To,
+         USComparison = (sizeof(From) < sizeof(To))
+                        ? FromIsSmaller
+                        : FromIsNotSmaller>
+struct UnsignedSignedCheck;
+
+template<typename From, typename To>
+struct UnsignedSignedCheck<From, To, FromIsSmaller>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    return true;
+  }
+};
+
+template<typename From, typename To>
+struct UnsignedSignedCheck<From, To, FromIsNotSmaller>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1);
+    return aFrom <= From(MaxValue);
+  }
+};
+
+template<typename From, typename To>
+struct BoundsCheckImpl<From, To, FromIsUnsigned, ToIsSigned>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    return UnsignedSignedCheck<From, To>::checkBounds(aFrom);
+  }
+};
+
+// Signed-to-signed range check
+
+template<typename From, typename To>
+struct BoundsCheckImpl<From, To, FromIsSigned, ToIsSigned>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    if (sizeof(From) <= sizeof(To)) {
+      return true;
+    }
+    const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1);
+    const To MinValue = -MaxValue - To(1);
+    return From(MinValue) <= aFrom &&
+           From(aFrom) <= From(MaxValue);
+  }
+};
+
+template<typename From, typename To,
+         bool TypesAreIntegral = IsIntegral<From>::value &&
+                                 IsIntegral<To>::value>
+class BoundsChecker;
+
+template<typename From>
+class BoundsChecker<From, From, true>
+{
+public:
+  static bool checkBounds(const From aFrom) { return true; }
+};
+
+template<typename From, typename To>
+class BoundsChecker<From, To, true>
+{
+public:
+  static bool checkBounds(const From aFrom)
+  {
+    return BoundsCheckImpl<From, To>::checkBounds(aFrom);
+  }
+};
+
+template<typename From, typename To>
+inline bool
+IsInBounds(const From aFrom)
+{
+  return BoundsChecker<From, To>::checkBounds(aFrom);
+}
+
+} // namespace detail
+
+/**
+ * Cast a value of integral type |From| to a value of integral type |To|,
+ * asserting that the cast will be a safe cast per C++ (that is, that |to| is in
+ * the range of values permitted for the type |From|).
+ */
+template<typename To, typename From>
+inline To
+AssertedCast(const From aFrom)
+{
+  MOZ_ASSERT((detail::IsInBounds<From, To>(aFrom)));
+  return static_cast<To>(aFrom);
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_Casting_h */
diff --git a/src/third_party/mozjs-45/mfbt/ChaosMode.cpp b/src/third_party/mozjs-45/mfbt/ChaosMode.cpp
new file mode 100644
index 0000000..48ed093
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/ChaosMode.cpp
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/ChaosMode.h"
+
+namespace mozilla {
+
+namespace detail {
+
+Atomic<uint32_t> gChaosModeCounter(0);
+ChaosFeature gChaosFeatures = None;
+
+} /* namespace detail */
+} /* namespace mozilla */
diff --git a/src/third_party/mozjs-45/mfbt/ChaosMode.h b/src/third_party/mozjs-45/mfbt/ChaosMode.h
new file mode 100644
index 0000000..b5a0b65
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/ChaosMode.h
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_ChaosMode_h
+#define mozilla_ChaosMode_h
+
+#include "mozilla/Atomics.h"
+#include "mozilla/EnumSet.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+
+namespace mozilla {
+
+enum ChaosFeature {
+  None = 0x0,
+  // Altering thread scheduling.
+  ThreadScheduling = 0x1,
+  // Altering network request scheduling.
+  NetworkScheduling = 0x2,
+  // Altering timer scheduling.
+  TimerScheduling = 0x4,
+  // Read and write less-than-requested amounts.
+  IOAmounts = 0x8,
+  // Iterate over hash tables in random order.
+  HashTableIteration = 0x10,
+  Any = 0xffffffff,
+};
+
+namespace detail {
+extern MFBT_DATA Atomic<uint32_t> gChaosModeCounter;
+extern MFBT_DATA ChaosFeature gChaosFeatures;
+} // namespace detail
+
+/**
+ * When "chaos mode" is activated, code that makes implicitly nondeterministic
+ * choices is encouraged to make random and extreme choices, to test more
+ * code paths and uncover bugs.
+ */
+class ChaosMode
+{
+public:
+  static void SetChaosFeature(ChaosFeature aChaosFeature)
+  {
+    detail::gChaosFeatures = aChaosFeature;
+  }
+
+  static bool isActive(ChaosFeature aFeature)
+  {
+    if (detail::gChaosModeCounter > 0) {
+      return true;
+    }
+    return detail::gChaosFeatures & aFeature;
+  }
+
+  /**
+   * Increase the chaos mode activation level. An equivalent number of
+   * calls to leaveChaosMode must be made in order to restore the original
+   * chaos mode state. If the activation level is nonzero all chaos mode
+   * features are activated.
+   */
+  static void enterChaosMode()
+  {
+    detail::gChaosModeCounter++;
+  }
+
+  /**
+   * Decrease the chaos mode activation level. See enterChaosMode().
+   */
+  static void leaveChaosMode()
+  {
+    MOZ_ASSERT(detail::gChaosModeCounter > 0);
+    detail::gChaosModeCounter--;
+  }
+
+  /**
+   * Returns a somewhat (but not uniformly) random uint32_t < aBound.
+   * Not to be used for anything except ChaosMode, since it's not very random.
+   */
+  static uint32_t randomUint32LessThan(uint32_t aBound)
+  {
+    MOZ_ASSERT(aBound != 0);
+    return uint32_t(rand()) % aBound;
+  }
+};
+
+} /* namespace mozilla */
+
+#endif /* mozilla_ChaosMode_h */
diff --git a/src/third_party/mozjs-45/mfbt/Char16.h b/src/third_party/mozjs-45/mfbt/Char16.h
new file mode 100644
index 0000000..91cbc28
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Char16.h
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implements a UTF-16 character type. */
+
+#ifndef mozilla_Char16_h
+#define mozilla_Char16_h
+
+#ifdef __cplusplus
+
+/*
+ * C++11 introduces a char16_t type and support for UTF-16 string and character
+ * literals. C++11's char16_t is a distinct builtin type. Technically, char16_t
+ * is a 16-bit code unit of a Unicode code point, not a "character".
+ */
+
+#if defined(_MSC_VER) && _MSC_VER < 1900
+   /*
+    * C++11 says char16_t is a distinct builtin type, but Windows's yvals.h
+    * typedefs char16_t as an unsigned short prior to MSVC 2015, which
+    * implemented C++11's distinct char16_t type. We would like to alias
+    * char16_t to Windows's 16-bit wchar_t so we can declare UTF-16 literals as
+    * constant expressions (and pass char16_t pointers to Windows APIs). We
+    * #define _CHAR16T here in order to prevent yvals.h from overriding our
+    * char16_t typedefs, which we set to wchar_t for C++ code.
+    *
+    * In addition, #defining _CHAR16T will prevent yvals.h from defining a
+    * char32_t type, so we have to undo that damage here and provide our own,
+    * which is identical to the yvals.h type.
+    */
+#  define MOZ_UTF16_HELPER(s) L##s
+#  define _CHAR16T
+typedef wchar_t char16_t;
+typedef unsigned int char32_t;
+#else
+   /* C++11 has a builtin char16_t type. */
+#  define MOZ_UTF16_HELPER(s) u##s
+   /**
+    * This macro is used to distinguish when char16_t would be a distinct
+    * typedef from wchar_t.
+    */
+#  define MOZ_CHAR16_IS_NOT_WCHAR
+#  ifdef WIN32
+#    define MOZ_USE_CHAR16_WRAPPER
+#  endif
+#endif
+
+#ifdef MOZ_USE_CHAR16_WRAPPER
+# include <cstdint>
+  /**
+   * Win32 API extensively uses wchar_t, which is represented by a separated
+   * builtin type than char16_t per spec. It's not the case for MSVC prior to
+   * MSVC 2015, but other compilers follow the spec. We want to mix wchar_t and
+   * char16_t on Windows builds. This class is supposed to make it easier. It
+   * stores char16_t const pointer, but provides implicit casts for wchar_t as
+   * well. On other platforms, we simply use
+   * |typedef const char16_t* char16ptr_t|. Here, we want to make the class as
+   * similar to this typedef, including providing some casts that are allowed
+   * by the typedef.
+   */
+class char16ptr_t
+{
+private:
+  const char16_t* mPtr;
+  static_assert(sizeof(char16_t) == sizeof(wchar_t),
+                "char16_t and wchar_t sizes differ");
+
+public:
+  char16ptr_t(const char16_t* aPtr) : mPtr(aPtr) {}
+  char16ptr_t(const wchar_t* aPtr) :
+    mPtr(reinterpret_cast<const char16_t*>(aPtr))
+  {}
+
+  /* Without this, nullptr assignment would be ambiguous. */
+  constexpr char16ptr_t(decltype(nullptr)) : mPtr(nullptr) {}
+
+  operator const char16_t*() const
+  {
+    return mPtr;
+  }
+  operator const wchar_t*() const
+  {
+    return reinterpret_cast<const wchar_t*>(mPtr);
+  }
+  operator const void*() const
+  {
+    return mPtr;
+  }
+  operator bool() const
+  {
+    return mPtr != nullptr;
+  }
+
+  /* Explicit cast operators to allow things like (char16_t*)str. */
+  explicit operator char16_t*() const
+  {
+    return const_cast<char16_t*>(mPtr);
+  }
+  explicit operator wchar_t*() const
+  {
+    return const_cast<wchar_t*>(static_cast<const wchar_t*>(*this));
+  }
+  explicit operator int() const
+  {
+    return reinterpret_cast<intptr_t>(mPtr);
+  }
+  explicit operator unsigned int() const
+  {
+    return reinterpret_cast<uintptr_t>(mPtr);
+  }
+  explicit operator long() const
+  {
+    return reinterpret_cast<intptr_t>(mPtr);
+  }
+  explicit operator unsigned long() const
+  {
+    return reinterpret_cast<uintptr_t>(mPtr);
+  }
+  explicit operator long long() const
+  {
+    return reinterpret_cast<intptr_t>(mPtr);
+  }
+  explicit operator unsigned long long() const
+  {
+    return reinterpret_cast<uintptr_t>(mPtr);
+  }
+
+  /**
+   * Some Windows API calls accept BYTE* but require that data actually be
+   * WCHAR*.  Supporting this requires explicit operators to support the
+   * requisite explicit casts.
+   */
+  explicit operator const char*() const
+  {
+    return reinterpret_cast<const char*>(mPtr);
+  }
+  explicit operator const unsigned char*() const
+  {
+    return reinterpret_cast<const unsigned char*>(mPtr);
+  }
+  explicit operator unsigned char*() const
+  {
+    return
+      const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(mPtr));
+  }
+  explicit operator void*() const
+  {
+    return const_cast<char16_t*>(mPtr);
+  }
+
+  /* Some operators used on pointers. */
+  char16_t operator[](size_t aIndex) const
+  {
+    return mPtr[aIndex];
+  }
+  bool operator==(const char16ptr_t& aOther) const
+  {
+    return mPtr == aOther.mPtr;
+  }
+  bool operator==(decltype(nullptr)) const
+  {
+    return mPtr == nullptr;
+  }
+  bool operator!=(const char16ptr_t& aOther) const
+  {
+    return mPtr != aOther.mPtr;
+  }
+  bool operator!=(decltype(nullptr)) const
+  {
+    return mPtr != nullptr;
+  }
+  char16ptr_t operator+(int aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(unsigned int aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(long aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(unsigned long aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(long long aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  char16ptr_t operator+(unsigned long long aValue) const
+  {
+    return char16ptr_t(mPtr + aValue);
+  }
+  ptrdiff_t operator-(const char16ptr_t& aOther) const
+  {
+    return mPtr - aOther.mPtr;
+  }
+};
+
+inline decltype((char*)0-(char*)0)
+operator-(const char16_t* aX, const char16ptr_t aY)
+{
+  return aX - static_cast<const char16_t*>(aY);
+}
+
+#else
+
+typedef const char16_t* char16ptr_t;
+
+#endif
+
+/*
+ * Macro arguments used in concatenation or stringification won't be expanded.
+ * Therefore, in order for |MOZ_UTF16(FOO)| to work as expected (which is to
+ * expand |FOO| before doing whatever |MOZ_UTF16| needs to do to it) a helper
+ * macro, |MOZ_UTF16_HELPER| needs to be inserted in between to allow the macro
+ * argument to expand. See "3.10.6 Separate Expansion of Macro Arguments" of the
+ * CPP manual for a more accurate and precise explanation.
+ */
+#define MOZ_UTF16(s) MOZ_UTF16_HELPER(s)
+
+static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?");
+static_assert(char16_t(-1) > char16_t(0), "Is char16_t type unsigned?");
+static_assert(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?");
+static_assert(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?");
+
+#endif
+
+#endif /* mozilla_Char16_h */
diff --git a/src/third_party/mozjs-45/mfbt/CheckedInt.h b/src/third_party/mozjs-45/mfbt/CheckedInt.h
new file mode 100644
index 0000000..02ef8d5
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/CheckedInt.h
@@ -0,0 +1,791 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Provides checked integers, detecting integer overflow and divide-by-0. */
+
+#ifndef mozilla_CheckedInt_h
+#define mozilla_CheckedInt_h
+
+#include <stdint.h>
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/IntegerTypeTraits.h"
+
+namespace mozilla {
+
+template<typename T> class CheckedInt;
+
+namespace detail {
+
+/*
+ * Step 1: manually record supported types
+ *
+ * What's nontrivial here is that there are different families of integer
+ * types: basic integer types and stdint types. It is merrily undefined which
+ * types from one family may be just typedefs for a type from another family.
+ *
+ * For example, on GCC 4.6, aside from the basic integer types, the only other
+ * type that isn't just a typedef for some of them, is int8_t.
+ */
+
+struct UnsupportedType {};
+
+template<typename IntegerType>
+struct IsSupportedPass2
+{
+  static const bool value = false;
+};
+
+template<typename IntegerType>
+struct IsSupported
+{
+  static const bool value = IsSupportedPass2<IntegerType>::value;
+};
+
+template<>
+struct IsSupported<int8_t>
+{ static const bool value = true; };
+
+template<>
+struct IsSupported<uint8_t>
+{ static const bool value = true; };
+
+template<>
+struct IsSupported<int16_t>
+{ static const bool value = true; };
+
+template<>
+struct IsSupported<uint16_t>
+{ static const bool value = true; };
+
+template<>
+struct IsSupported<int32_t>
+{ static const bool value = true; };
+
+template<>
+struct IsSupported<uint32_t>
+{ static const bool value = true; };
+
+template<>
+struct IsSupported<int64_t>
+{ static const bool value = true; };
+
+template<>
+struct IsSupported<uint64_t>
+{ static const bool value = true; };
+
+
+template<>
+struct IsSupportedPass2<char>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<signed char>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<unsigned char>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<short>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<unsigned short>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<int>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<unsigned int>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<long>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<unsigned long>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<long long>
+{ static const bool value = true; };
+
+template<>
+struct IsSupportedPass2<unsigned long long>
+{ static const bool value = true; };
+
+/*
+ * Step 2: Implement the actual validity checks.
+ *
+ * Ideas taken from IntegerLib, code different.
+ */
+
+template<typename IntegerType, size_t Size = sizeof(IntegerType)>
+struct TwiceBiggerType
+{
+  typedef typename detail::StdintTypeForSizeAndSignedness<
+                     sizeof(IntegerType) * 2,
+                     IsSigned<IntegerType>::value
+                   >::Type Type;
+};
+
+template<typename IntegerType>
+struct TwiceBiggerType<IntegerType, 8>
+{
+  typedef UnsupportedType Type;
+};
+
+template<typename T>
+inline bool
+HasSignBit(T aX)
+{
+  // In C++, right bit shifts on negative values is undefined by the standard.
+  // Notice that signed-to-unsigned conversions are always well-defined in the
+  // standard, as the value congruent modulo 2**n as expected. By contrast,
+  // unsigned-to-signed is only well-defined if the value is representable.
+  return bool(typename MakeUnsigned<T>::Type(aX) >>
+              PositionOfSignBit<T>::value);
+}
+
+// Bitwise ops may return a larger type, so it's good to use this inline
+// helper guaranteeing that the result is really of type T.
+template<typename T>
+inline T
+BinaryComplement(T aX)
+{
+  return ~aX;
+}
+
+template<typename T,
+         typename U,
+         bool IsTSigned = IsSigned<T>::value,
+         bool IsUSigned = IsSigned<U>::value>
+struct DoesRangeContainRange
+{
+};
+
+template<typename T, typename U, bool Signedness>
+struct DoesRangeContainRange<T, U, Signedness, Signedness>
+{
+  static const bool value = sizeof(T) >= sizeof(U);
+};
+
+template<typename T, typename U>
+struct DoesRangeContainRange<T, U, true, false>
+{
+  static const bool value = sizeof(T) > sizeof(U);
+};
+
+template<typename T, typename U>
+struct DoesRangeContainRange<T, U, false, true>
+{
+  static const bool value = false;
+};
+
+template<typename T,
+         typename U,
+         bool IsTSigned = IsSigned<T>::value,
+         bool IsUSigned = IsSigned<U>::value,
+         bool DoesTRangeContainURange = DoesRangeContainRange<T, U>::value>
+struct IsInRangeImpl {};
+
+template<typename T, typename U, bool IsTSigned, bool IsUSigned>
+struct IsInRangeImpl<T, U, IsTSigned, IsUSigned, true>
+{
+  static bool run(U)
+  {
+    return true;
+  }
+};
+
+template<typename T, typename U>
+struct IsInRangeImpl<T, U, true, true, false>
+{
+  static bool run(U aX)
+  {
+    return aX <= MaxValue<T>::value && aX >= MinValue<T>::value;
+  }
+};
+
+template<typename T, typename U>
+struct IsInRangeImpl<T, U, false, false, false>
+{
+  static bool run(U aX)
+  {
+    return aX <= MaxValue<T>::value;
+  }
+};
+
+template<typename T, typename U>
+struct IsInRangeImpl<T, U, true, false, false>
+{
+  static bool run(U aX)
+  {
+    return sizeof(T) > sizeof(U) || aX <= U(MaxValue<T>::value);
+  }
+};
+
+template<typename T, typename U>
+struct IsInRangeImpl<T, U, false, true, false>
+{
+  static bool run(U aX)
+  {
+    return sizeof(T) >= sizeof(U)
+           ? aX >= 0
+           : aX >= 0 && aX <= U(MaxValue<T>::value);
+  }
+};
+
+template<typename T, typename U>
+inline bool
+IsInRange(U aX)
+{
+  return IsInRangeImpl<T, U>::run(aX);
+}
+
+template<typename T>
+inline bool
+IsAddValid(T aX, T aY)
+{
+  // Addition is valid if the sign of aX+aY is equal to either that of aX or
+  // that of aY. Since the value of aX+aY is undefined if we have a signed
+  // type, we compute it using the unsigned type of the same size.  Beware!
+  // These bitwise operations can return a larger integer type, if T was a
+  // small type like int8_t, so we explicitly cast to T.
+
+  typename MakeUnsigned<T>::Type ux = aX;
+  typename MakeUnsigned<T>::Type uy = aY;
+  typename MakeUnsigned<T>::Type result = ux + uy;
+  return IsSigned<T>::value
+         ? HasSignBit(BinaryComplement(T((result ^ aX) & (result ^ aY))))
+         : BinaryComplement(aX) >= aY;
+}
+
+template<typename T>
+inline bool
+IsSubValid(T aX, T aY)
+{
+  // Subtraction is valid if either aX and aY have same sign, or aX-aY and aX
+  // have same sign. Since the value of aX-aY is undefined if we have a signed
+  // type, we compute it using the unsigned type of the same size.
+  typename MakeUnsigned<T>::Type ux = aX;
+  typename MakeUnsigned<T>::Type uy = aY;
+  typename MakeUnsigned<T>::Type result = ux - uy;
+
+  return IsSigned<T>::value
+         ? HasSignBit(BinaryComplement(T((result ^ aX) & (aX ^ aY))))
+         : aX >= aY;
+}
+
+template<typename T,
+         bool IsTSigned = IsSigned<T>::value,
+         bool TwiceBiggerTypeIsSupported =
+           IsSupported<typename TwiceBiggerType<T>::Type>::value>
+struct IsMulValidImpl {};
+
+template<typename T, bool IsTSigned>
+struct IsMulValidImpl<T, IsTSigned, true>
+{
+  static bool run(T aX, T aY)
+  {
+    typedef typename TwiceBiggerType<T>::Type TwiceBiggerType;
+    TwiceBiggerType product = TwiceBiggerType(aX) * TwiceBiggerType(aY);
+    return IsInRange<T>(product);
+  }
+};
+
+template<typename T>
+struct IsMulValidImpl<T, true, false>
+{
+  static bool run(T aX, T aY)
+  {
+    const T max = MaxValue<T>::value;
+    const T min = MinValue<T>::value;
+
+    if (aX == 0 || aY == 0) {
+      return true;
+    }
+    if (aX > 0) {
+      return aY > 0
+             ? aX <= max / aY
+             : aY >= min / aX;
+    }
+
+    // If we reach this point, we know that aX < 0.
+    return aY > 0
+           ? aX >= min / aY
+           : aY >= max / aX;
+  }
+};
+
+template<typename T>
+struct IsMulValidImpl<T, false, false>
+{
+  static bool run(T aX, T aY)
+  {
+    return aY == 0 ||  aX <= MaxValue<T>::value / aY;
+  }
+};
+
+template<typename T>
+inline bool
+IsMulValid(T aX, T aY)
+{
+  return IsMulValidImpl<T>::run(aX, aY);
+}
+
+template<typename T>
+inline bool
+IsDivValid(T aX, T aY)
+{
+  // Keep in mind that in the signed case, min/-1 is invalid because
+  // abs(min)>max.
+  return aY != 0 &&
+         !(IsSigned<T>::value && aX == MinValue<T>::value && aY == T(-1));
+}
+
+template<typename T, bool IsTSigned = IsSigned<T>::value>
+struct IsModValidImpl;
+
+template<typename T>
+inline bool
+IsModValid(T aX, T aY)
+{
+  return IsModValidImpl<T>::run(aX, aY);
+}
+
+/*
+ * Mod is pretty simple.
+ * For now, let's just use the ANSI C definition:
+ * If aX or aY are negative, the results are implementation defined.
+ *   Consider these invalid.
+ * Undefined for aY=0.
+ * The result will never exceed either aX or aY.
+ *
+ * Checking that aX>=0 is a warning when T is unsigned.
+ */
+
+template<typename T>
+struct IsModValidImpl<T, false>
+{
+  static inline bool run(T aX, T aY)
+  {
+    return aY >= 1;
+  }
+};
+
+template<typename T>
+struct IsModValidImpl<T, true>
+{
+  static inline bool run(T aX, T aY)
+  {
+    if (aX < 0) {
+      return false;
+    }
+    return aY >= 1;
+  }
+};
+
+template<typename T, bool IsSigned = IsSigned<T>::value>
+struct NegateImpl;
+
+template<typename T>
+struct NegateImpl<T, false>
+{
+  static CheckedInt<T> negate(const CheckedInt<T>& aVal)
+  {
+    // Handle negation separately for signed/unsigned, for simpler code and to
+    // avoid an MSVC warning negating an unsigned value.
+    return CheckedInt<T>(0, aVal.isValid() && aVal.mValue == 0);
+  }
+};
+
+template<typename T>
+struct NegateImpl<T, true>
+{
+  static CheckedInt<T> negate(const CheckedInt<T>& aVal)
+  {
+    // Watch out for the min-value, which (with twos-complement) can't be
+    // negated as -min-value is then (max-value + 1).
+    if (!aVal.isValid() || aVal.mValue == MinValue<T>::value) {
+      return CheckedInt<T>(aVal.mValue, false);
+    }
+    return CheckedInt<T>(-aVal.mValue, true);
+  }
+};
+
+} // namespace detail
+
+
+/*
+ * Step 3: Now define the CheckedInt class.
+ */
+
+/**
+ * @class CheckedInt
+ * @brief Integer wrapper class checking for integer overflow and other errors
+ * @param T the integer type to wrap. Can be any type among the following:
+ *            - any basic integer type such as |int|
+ *            - any stdint type such as |int8_t|
+ *
+ * This class implements guarded integer arithmetic. Do a computation, check
+ * that isValid() returns true, you then have a guarantee that no problem, such
+ * as integer overflow, happened during this computation, and you can call
+ * value() to get the plain integer value.
+ *
+ * The arithmetic operators in this class are guaranteed not to raise a signal
+ * (e.g. in case of a division by zero).
+ *
+ * For example, suppose that you want to implement a function that computes
+ * (aX+aY)/aZ, that doesn't crash if aZ==0, and that reports on error (divide by
+ * zero or integer overflow). You could code it as follows:
+   @code
+   bool computeXPlusYOverZ(int aX, int aY, int aZ, int* aResult)
+   {
+     CheckedInt<int> checkedResult = (CheckedInt<int>(aX) + aY) / aZ;
+     if (checkedResult.isValid()) {
+       *aResult = checkedResult.value();
+       return true;
+     } else {
+       return false;
+     }
+   }
+   @endcode
+ *
+ * Implicit conversion from plain integers to checked integers is allowed. The
+ * plain integer is checked to be in range before being casted to the
+ * destination type. This means that the following lines all compile, and the
+ * resulting CheckedInts are correctly detected as valid or invalid:
+ * @code
+   // 1 is of type int, is found to be in range for uint8_t, x is valid
+   CheckedInt<uint8_t> x(1);
+   // -1 is of type int, is found not to be in range for uint8_t, x is invalid
+   CheckedInt<uint8_t> x(-1);
+   // -1 is of type int, is found to be in range for int8_t, x is valid
+   CheckedInt<int8_t> x(-1);
+   // 1000 is of type int16_t, is found not to be in range for int8_t,
+   // x is invalid
+   CheckedInt<int8_t> x(int16_t(1000));
+   // 3123456789 is of type uint32_t, is found not to be in range for int32_t,
+   // x is invalid
+   CheckedInt<int32_t> x(uint32_t(3123456789));
+ * @endcode
+ * Implicit conversion from
+ * checked integers to plain integers is not allowed. As shown in the
+ * above example, to get the value of a checked integer as a normal integer,
+ * call value().
+ *
+ * Arithmetic operations between checked and plain integers is allowed; the
+ * result type is the type of the checked integer.
+ *
+ * Checked integers of different types cannot be used in the same arithmetic
+ * expression.
+ *
+ * There are convenience typedefs for all stdint types, of the following form
+ * (these are just 2 examples):
+   @code
+   typedef CheckedInt<int32_t> CheckedInt32;
+   typedef CheckedInt<uint16_t> CheckedUint16;
+   @endcode
+ */
+template<typename T>
+class CheckedInt
+{
+protected:
+  T mValue;
+  bool mIsValid;
+
+  template<typename U>
+  CheckedInt(U aValue, bool aIsValid) : mValue(aValue), mIsValid(aIsValid)
+  {
+    static_assert(detail::IsSupported<T>::value &&
+                  detail::IsSupported<U>::value,
+                  "This type is not supported by CheckedInt");
+  }
+
+  friend struct detail::NegateImpl<T>;
+
+public:
+  /**
+   * Constructs a checked integer with given @a value. The checked integer is
+   * initialized as valid or invalid depending on whether the @a value
+   * is in range.
+   *
+   * This constructor is not explicit. Instead, the type of its argument is a
+   * separate template parameter, ensuring that no conversion is performed
+   * before this constructor is actually called. As explained in the above
+   * documentation for class CheckedInt, this constructor checks that its
+   * argument is valid.
+   */
+  template<typename U>
+  MOZ_IMPLICIT CheckedInt(U aValue) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT
+    : mValue(T(aValue)),
+      mIsValid(detail::IsInRange<T>(aValue))
+  {
+    static_assert(detail::IsSupported<T>::value &&
+                  detail::IsSupported<U>::value,
+                  "This type is not supported by CheckedInt");
+  }
+
+  template<typename U>
+  friend class CheckedInt;
+
+  template<typename U>
+  CheckedInt<U> toChecked() const
+  {
+    CheckedInt<U> ret(mValue);
+    ret.mIsValid = ret.mIsValid && mIsValid;
+    return ret;
+  }
+
+  /** Constructs a valid checked integer with initial value 0 */
+  CheckedInt() : mValue(0), mIsValid(true)
+  {
+    static_assert(detail::IsSupported<T>::value,
+                  "This type is not supported by CheckedInt");
+  }
+
+  /** @returns the actual value */
+  T value() const
+  {
+    MOZ_ASSERT(mIsValid, "Invalid checked integer (division by zero or integer overflow)");
+    return mValue;
+  }
+
+  /**
+   * @returns true if the checked integer is valid, i.e. is not the result
+   * of an invalid operation or of an operation involving an invalid checked
+   * integer
+   */
+  bool isValid() const
+  {
+    return mIsValid;
+  }
+
+  template<typename U>
+  friend CheckedInt<U> operator +(const CheckedInt<U>& aLhs,
+                                  const CheckedInt<U>& aRhs);
+  template<typename U>
+  CheckedInt& operator +=(U aRhs);
+  CheckedInt& operator +=(const CheckedInt<T>& aRhs);
+
+  template<typename U>
+  friend CheckedInt<U> operator -(const CheckedInt<U>& aLhs,
+                                  const CheckedInt<U>& aRhs);
+  template<typename U>
+  CheckedInt& operator -=(U aRhs);
+  CheckedInt& operator -=(const CheckedInt<T>& aRhs);
+
+  template<typename U>
+  friend CheckedInt<U> operator *(const CheckedInt<U>& aLhs,
+                                  const CheckedInt<U>& aRhs);
+  template<typename U>
+  CheckedInt& operator *=(U aRhs);
+  CheckedInt& operator *=(const CheckedInt<T>& aRhs);
+
+  template<typename U>
+  friend CheckedInt<U> operator /(const CheckedInt<U>& aLhs,
+                                  const CheckedInt<U>& aRhs);
+  template<typename U>
+  CheckedInt& operator /=(U aRhs);
+  CheckedInt& operator /=(const CheckedInt<T>& aRhs);
+
+  template<typename U>
+  friend CheckedInt<U> operator %(const CheckedInt<U>& aLhs,
+                                  const CheckedInt<U>& aRhs);
+  template<typename U>
+  CheckedInt& operator %=(U aRhs);
+  CheckedInt& operator %=(const CheckedInt<T>& aRhs);
+
+  CheckedInt operator -() const
+  {
+    return detail::NegateImpl<T>::negate(*this);
+  }
+
+  /**
+   * @returns true if the left and right hand sides are valid
+   * and have the same value.
+   *
+   * Note that these semantics are the reason why we don't offer
+   * a operator!=. Indeed, we'd want to have a!=b be equivalent to !(a==b)
+   * but that would mean that whenever a or b is invalid, a!=b
+   * is always true, which would be very confusing.
+   *
+   * For similar reasons, operators <, >, <=, >= would be very tricky to
+   * specify, so we just avoid offering them.
+   *
+   * Notice that these == semantics are made more reasonable by these facts:
+   *  1. a==b implies equality at the raw data level
+   *     (the converse is false, as a==b is never true among invalids)
+   *  2. This is similar to the behavior of IEEE floats, where a==b
+   *     means that a and b have the same value *and* neither is NaN.
+   */
+  bool operator ==(const CheckedInt& aOther) const
+  {
+    return mIsValid && aOther.mIsValid && mValue == aOther.mValue;
+  }
+
+  /** prefix ++ */
+  CheckedInt& operator++()
+  {
+    *this += 1;
+    return *this;
+  }
+
+  /** postfix ++ */
+  CheckedInt operator++(int)
+  {
+    CheckedInt tmp = *this;
+    *this += 1;
+    return tmp;
+  }
+
+  /** prefix -- */
+  CheckedInt& operator--()
+  {
+    *this -= 1;
+    return *this;
+  }
+
+  /** postfix -- */
+  CheckedInt operator--(int)
+  {
+    CheckedInt tmp = *this;
+    *this -= 1;
+    return tmp;
+  }
+
+private:
+  /**
+   * The !=, <, <=, >, >= operators are disabled:
+   * see the comment on operator==.
+   */
+  template<typename U> bool operator !=(U aOther) const = delete;
+  template<typename U> bool operator < (U aOther) const = delete;
+  template<typename U> bool operator <=(U aOther) const = delete;
+  template<typename U> bool operator > (U aOther) const = delete;
+  template<typename U> bool operator >=(U aOther) const = delete;
+};
+
+#define MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(NAME, OP)                        \
+  template<typename T>                                                        \
+  inline CheckedInt<T>                                                        \
+  operator OP(const CheckedInt<T>& aLhs, const CheckedInt<T>& aRhs)           \
+  {                                                                           \
+    if (!detail::Is##NAME##Valid(aLhs.mValue, aRhs.mValue)) {                 \
+      return CheckedInt<T>(0, false);                                         \
+    }                                                                         \
+    return CheckedInt<T>(aLhs.mValue OP aRhs.mValue,                          \
+                         aLhs.mIsValid && aRhs.mIsValid);                     \
+  }
+
+MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Add, +)
+MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Sub, -)
+MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mul, *)
+MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Div, /)
+MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mod, %)
+
+#undef MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR
+
+// Implement castToCheckedInt<T>(x), making sure that
+//  - it allows x to be either a CheckedInt<T> or any integer type
+//    that can be casted to T
+//  - if x is already a CheckedInt<T>, we just return a reference to it,
+//    instead of copying it (optimization)
+
+namespace detail {
+
+template<typename T, typename U>
+struct CastToCheckedIntImpl
+{
+  typedef CheckedInt<T> ReturnType;
+  static CheckedInt<T> run(U aU) { return aU; }
+};
+
+template<typename T>
+struct CastToCheckedIntImpl<T, CheckedInt<T> >
+{
+  typedef const CheckedInt<T>& ReturnType;
+  static const CheckedInt<T>& run(const CheckedInt<T>& aU) { return aU; }
+};
+
+} // namespace detail
+
+template<typename T, typename U>
+inline typename detail::CastToCheckedIntImpl<T, U>::ReturnType
+castToCheckedInt(U aU)
+{
+  static_assert(detail::IsSupported<T>::value &&
+                detail::IsSupported<U>::value,
+                "This type is not supported by CheckedInt");
+  return detail::CastToCheckedIntImpl<T, U>::run(aU);
+}
+
+#define MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(OP, COMPOUND_OP)            \
+  template<typename T>                                                          \
+  template<typename U>                                                          \
+  CheckedInt<T>& CheckedInt<T>::operator COMPOUND_OP(U aRhs)                    \
+  {                                                                             \
+    *this = *this OP castToCheckedInt<T>(aRhs);                                 \
+    return *this;                                                               \
+  }                                                                             \
+  template<typename T>                                                          \
+  CheckedInt<T>& CheckedInt<T>::operator COMPOUND_OP(const CheckedInt<T>& aRhs) \
+  {                                                                             \
+    *this = *this OP aRhs;                                                      \
+    return *this;                                                               \
+  }                                                                             \
+  template<typename T, typename U>                                              \
+  inline CheckedInt<T> operator OP(const CheckedInt<T>& aLhs, U aRhs)           \
+  {                                                                             \
+    return aLhs OP castToCheckedInt<T>(aRhs);                                   \
+  }                                                                             \
+  template<typename T, typename U>                                              \
+  inline CheckedInt<T> operator OP(U aLhs, const CheckedInt<T>& aRhs)           \
+  {                                                                             \
+    return castToCheckedInt<T>(aLhs) OP aRhs;                                   \
+  }
+
+MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(+, +=)
+MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(*, *=)
+MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(-, -=)
+MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(/, /=)
+MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(%, %=)
+
+#undef MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS
+
+template<typename T, typename U>
+inline bool
+operator ==(const CheckedInt<T>& aLhs, U aRhs)
+{
+  return aLhs == castToCheckedInt<T>(aRhs);
+}
+
+template<typename T, typename U>
+inline bool
+operator ==(U aLhs, const CheckedInt<T>& aRhs)
+{
+  return castToCheckedInt<T>(aLhs) == aRhs;
+}
+
+// Convenience typedefs.
+typedef CheckedInt<int8_t>   CheckedInt8;
+typedef CheckedInt<uint8_t>  CheckedUint8;
+typedef CheckedInt<int16_t>  CheckedInt16;
+typedef CheckedInt<uint16_t> CheckedUint16;
+typedef CheckedInt<int32_t>  CheckedInt32;
+typedef CheckedInt<uint32_t> CheckedUint32;
+typedef CheckedInt<int64_t>  CheckedInt64;
+typedef CheckedInt<uint64_t> CheckedUint64;
+
+} // namespace mozilla
+
+#endif /* mozilla_CheckedInt_h */
diff --git a/src/third_party/mozjs-45/mfbt/Compiler.h b/src/third_party/mozjs-45/mfbt/Compiler.h
new file mode 100644
index 0000000..6d6fcbb
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Compiler.h
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Various compiler checks. */
+
+#ifndef mozilla_Compiler_h
+#define mozilla_Compiler_h
+
+#define MOZ_IS_GCC 0
+#define MOS_IS_MSVC 0
+
+#if !defined(__clang__) && defined(__GNUC__)
+
+#  undef MOZ_IS_GCC
+#  define MOZ_IS_GCC 1
+   /*
+    * This macro should simplify gcc version checking. For example, to check
+    * for gcc 4.7.1 or later, check `#if MOZ_GCC_VERSION_AT_LEAST(4, 7, 1)`.
+    */
+#  define MOZ_GCC_VERSION_AT_LEAST(major, minor, patchlevel)          \
+     ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \
+      >= ((major) * 10000 + (minor) * 100 + (patchlevel)))
+#  if !MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
+#    error "mfbt (and Gecko) require at least gcc 4.7 to build."
+#  endif
+
+#elif defined(_MSC_VER)
+
+#  undef MOZ_IS_MSVC
+#  define MOZ_IS_MSVC 1
+
+#endif
+
+/*
+ * The situation with standard libraries is a lot worse than with compilers,
+ * particularly as clang and gcc could end up using one of three or so standard
+ * libraries, and they may not be up-to-snuff with newer C++11 versions. To
+ * detect the library, we're going to include cstddef (which is a small header
+ * which will be transitively included by everybody else at some point) to grab
+ * the version macros and deduce macros from there.
+ */
+#ifdef __cplusplus
+#  include <cstddef>
+#  ifdef _STLPORT_MAJOR
+#    define MOZ_USING_STLPORT 1
+#    define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) \
+       (_STLPORT_VERSION >= ((major) << 8 | (minor) << 4 | (patch)))
+#  elif defined(_LIBCPP_VERSION)
+   /*
+    * libc++, unfortunately, doesn't appear to have useful versioning macros.
+    * Hopefully, the recommendations of N3694 with respect to standard libraries
+    * will get applied instead and we won't need to worry about version numbers
+    * here.
+    */
+#    define MOZ_USING_LIBCXX 1
+#  elif defined(__GLIBCXX__)
+#    define MOZ_USING_LIBSTDCXX 1
+   /*
+    * libstdc++ is also annoying and doesn't give us useful versioning macros
+    * for the library. If we're using gcc, then assume that libstdc++ matches
+    * the compiler version. If we're using clang, we're going to have to fake
+    * major/minor combinations by looking for newly-defined config macros.
+    */
+#    if MOZ_IS_GCC
+#      define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
+          MOZ_GCC_VERSION_AT_LEAST(major, minor, patch)
+#    elif defined(_GLIBCXX_THROW_OR_ABORT)
+#      define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
+          ((major) < 4 || ((major) == 4 && (minor) <= 8))
+#    elif defined(_GLIBCXX_NOEXCEPT)
+#      define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
+          ((major) < 4 || ((major) == 4 && (minor) <= 7))
+#    elif defined(_GLIBCXX_USE_DEPRECATED)
+#      define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
+          ((major) < 4 || ((major) == 4 && (minor) <= 6))
+#    elif defined(_GLIBCXX_PSEUDO_VISIBILITY)
+#      define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
+          ((major) < 4 || ((major) == 4 && (minor) <= 5))
+#    elif defined(_GLIBCXX_BEGIN_EXTERN_C)
+#      define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
+          ((major) < 4 || ((major) == 4 && (minor) <= 4))
+#    elif defined(_GLIBCXX_VISIBILITY_ATTR)
+#      define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
+          ((major) < 4 || ((major) == 4 && (minor) <= 3))
+#    elif defined(_GLIBCXX_VISIBILITY)
+#      define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \
+          ((major) < 4 || ((major) == 4 && (minor) <= 2))
+#    else
+#      error "Your version of libstdc++ is unknown to us and is likely too old."
+#    endif
+#  endif
+
+   // Flesh out the defines for everyone else
+#  ifndef MOZ_USING_STLPORT
+#    define MOZ_USING_STLPORT 0
+#    define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) 0
+#  endif
+#  ifndef MOZ_USING_LIBCXX
+#    define MOZ_USING_LIBCXX 0
+#  endif
+#  ifndef MOZ_USING_LIBSTDCXX
+#    define MOZ_USING_LIBSTDCXX 0
+#    define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) 0
+#  endif
+#endif /* __cplusplus */
+
+#endif /* mozilla_Compiler_h */
diff --git a/src/third_party/mozjs-45/mfbt/Compression.cpp b/src/third_party/mozjs-45/mfbt/Compression.cpp
new file mode 100644
index 0000000..c114c6c
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Compression.cpp
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Compression.h"
+#include "mozilla/CheckedInt.h"
+
+// Without including <string>, MSVC 2015 complains about e.g. the impossibility
+// to convert `const void* const` to `void*` when calling memchr from
+// corecrt_memory.h.
+#include <string>
+
+using namespace mozilla::Compression;
+
+namespace {
+
+#include "lz4.c"
+
+}/* anonymous namespace */
+
+/* Our wrappers */
+
+size_t
+LZ4::compress(const char* aSource, size_t aInputSize, char* aDest)
+{
+  CheckedInt<int> inputSizeChecked = aInputSize;
+  MOZ_ASSERT(inputSizeChecked.isValid());
+  return LZ4_compress(aSource, aDest, inputSizeChecked.value());
+}
+
+size_t
+LZ4::compressLimitedOutput(const char* aSource, size_t aInputSize, char* aDest,
+                           size_t aMaxOutputSize)
+{
+  CheckedInt<int> inputSizeChecked = aInputSize;
+  MOZ_ASSERT(inputSizeChecked.isValid());
+  CheckedInt<int> maxOutputSizeChecked = aMaxOutputSize;
+  MOZ_ASSERT(maxOutputSizeChecked.isValid());
+  return LZ4_compress_limitedOutput(aSource, aDest, inputSizeChecked.value(),
+                                    maxOutputSizeChecked.value());
+}
+
+bool
+LZ4::decompress(const char* aSource, char* aDest, size_t aOutputSize)
+{
+  CheckedInt<int> outputSizeChecked = aOutputSize;
+  MOZ_ASSERT(outputSizeChecked.isValid());
+  int ret = LZ4_decompress_fast(aSource, aDest, outputSizeChecked.value());
+  return ret >= 0;
+}
+
+bool
+LZ4::decompress(const char* aSource, size_t aInputSize, char* aDest,
+                size_t aMaxOutputSize, size_t* aOutputSize)
+{
+  CheckedInt<int> maxOutputSizeChecked = aMaxOutputSize;
+  MOZ_ASSERT(maxOutputSizeChecked.isValid());
+  CheckedInt<int> inputSizeChecked = aInputSize;
+  MOZ_ASSERT(inputSizeChecked.isValid());
+
+  int ret = LZ4_decompress_safe(aSource, aDest, inputSizeChecked.value(),
+                                maxOutputSizeChecked.value());
+  if (ret >= 0) {
+    *aOutputSize = ret;
+    return true;
+  }
+
+  *aOutputSize = 0;
+  return false;
+}
+
diff --git a/src/third_party/mozjs-45/mfbt/Compression.h b/src/third_party/mozjs-45/mfbt/Compression.h
new file mode 100644
index 0000000..d7bb646
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Compression.h
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Various simple compression/decompression functions. */
+
+#ifndef mozilla_Compression_h_
+#define mozilla_Compression_h_
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Types.h"
+
+namespace mozilla {
+namespace Compression {
+
+/**
+ * LZ4 is a very fast byte-wise compression algorithm.
+ *
+ * Compared to Google's Snappy it is faster to compress and decompress and
+ * generally produces output of about the same size.
+ *
+ * Compared to zlib it compresses at about 10x the speed, decompresses at about
+ * 4x the speed and produces output of about 1.5x the size.
+ */
+
+class LZ4
+{
+public:
+  /**
+   * Compresses |aInputSize| bytes from |aSource| into |aDest|. Destination
+   * buffer must be already allocated, and must be sized to handle worst cases
+   * situations (input data not compressible). Worst case size evaluation is
+   * provided by function maxCompressedSize()
+   *
+   * @param aInputSize is the input size. Max supported value is ~1.9GB
+   * @return the number of bytes written in buffer |aDest|
+   */
+  static MFBT_API size_t
+  compress(const char* aSource, size_t aInputSize, char* aDest);
+
+  /**
+   * Compress |aInputSize| bytes from |aSource| into an output buffer
+   * |aDest| of maximum size |aMaxOutputSize|.  If it cannot achieve it,
+   * compression will stop, and result of the function will be zero,
+   * |aDest| will still be written to, but since the number of input
+   * bytes consumed is not returned the result is not usable.
+   *
+   * This function never writes outside of provided output buffer.
+   *
+   * @param aInputSize is the input size. Max supported value is ~1.9GB
+   * @param aMaxOutputSize is the size of the destination buffer (which must
+   *   be already allocated)
+   * @return the number of bytes written in buffer |aDest| or 0 if the
+   *   compression fails
+   */
+  static MFBT_API size_t
+  compressLimitedOutput(const char* aSource, size_t aInputSize, char* aDest,
+                        size_t aMaxOutputSize);
+
+  /**
+   * If the source stream is malformed, the function will stop decoding
+   * and return a negative result, indicating the byte position of the
+   * faulty instruction
+   *
+   * This function never writes outside of provided buffers, and never
+   * modifies input buffer.
+   *
+   * Note: destination buffer must be already allocated, and its size must be a
+   *       minimum of |aOutputSize| bytes.
+   *
+   * @param aOutputSize is the output size, therefore the original size
+   * @return the number of bytes read in the source buffer
+   */
+  static MFBT_API bool
+  decompress(const char* aSource, char* aDest, size_t aOutputSize);
+
+  /**
+   * If the source stream is malformed, the function will stop decoding
+   * and return false.
+   *
+   * This function never writes beyond aDest + aMaxOutputSize, and is
+   * therefore protected against malicious data packets.
+   *
+   * Note: Destination buffer must be already allocated.  This version is
+   *       slightly slower than the decompress without the aMaxOutputSize.
+   *
+   * @param aInputSize is the length of the input compressed data
+   * @param aMaxOutputSize is the size of the destination buffer (which must be
+   *   already allocated)
+   * @param aOutputSize the actual number of bytes decoded in the destination
+   *   buffer (necessarily <= aMaxOutputSize)
+   */
+  static MFBT_API bool
+  decompress(const char* aSource, size_t aInputSize, char* aDest,
+             size_t aMaxOutputSize, size_t* aOutputSize);
+
+  /*
+   * Provides the maximum size that LZ4 may output in a "worst case"
+   * scenario (input data not compressible) primarily useful for memory
+   * allocation of output buffer.
+   * note : this function is limited by "int" range (2^31-1)
+   *
+   * @param aInputSize is the input size. Max supported value is ~1.9GB
+   * @return maximum output size in a "worst case" scenario
+   */
+  static inline size_t maxCompressedSize(size_t aInputSize)
+  {
+    size_t max = (aInputSize + (aInputSize / 255) + 16);
+    MOZ_ASSERT(max > aInputSize);
+    return max;
+  }
+};
+
+} /* namespace Compression */
+} /* namespace mozilla */
+
+#endif /* mozilla_Compression_h_ */
diff --git a/src/third_party/mozjs-45/mfbt/DebugOnly.h b/src/third_party/mozjs-45/mfbt/DebugOnly.h
new file mode 100644
index 0000000..451d9bc
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/DebugOnly.h
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Provides DebugOnly, a type for variables used only in debug builds (i.e. by
+ * assertions).
+ */
+
+#ifndef mozilla_DebugOnly_h
+#define mozilla_DebugOnly_h
+
+#include "mozilla/Attributes.h"
+
+namespace mozilla {
+
+/**
+ * DebugOnly contains a value of type T, but only in debug builds.  In release
+ * builds, it does not contain a value.  This helper is intended to be used with
+ * MOZ_ASSERT()-style macros, allowing one to write:
+ *
+ *   DebugOnly<bool> check = func();
+ *   MOZ_ASSERT(check);
+ *
+ * more concisely than declaring |check| conditional on #ifdef DEBUG, but also
+ * without allocating storage space for |check| in release builds.
+ *
+ * DebugOnly instances can only be coerced to T in debug builds.  In release
+ * builds they don't have a value, so type coercion is not well defined.
+ *
+ * Note that DebugOnly instances still take up one byte of space, plus padding,
+ * when used as members of structs.
+ */
+template<typename T>
+class DebugOnly
+{
+public:
+#ifdef DEBUG
+  T value;
+
+  DebugOnly() { }
+  MOZ_IMPLICIT DebugOnly(const T& aOther) : value(aOther) { }
+  DebugOnly(const DebugOnly& aOther) : value(aOther.value) { }
+  DebugOnly& operator=(const T& aRhs) {
+    value = aRhs;
+    return *this;
+  }
+
+  void operator++(int) { value++; }
+  void operator--(int) { value--; }
+
+  // Do not define operator+=(), etc. here.  These will coerce via the
+  // implicit cast and built-in operators.  Defining explicit methods here
+  // will create ambiguity the compiler can't deal with.
+
+  T* operator&() { return &value; }
+
+  operator T&() { return value; }
+  operator const T&() const { return value; }
+
+  T& operator->() { return value; }
+  const T& operator->() const { return value; }
+
+#else
+  DebugOnly() { }
+  MOZ_IMPLICIT DebugOnly(const T&) { }
+  DebugOnly(const DebugOnly&) { }
+  DebugOnly& operator=(const T&) { return *this; }
+  void operator++(int) { }
+  void operator--(int) { }
+  DebugOnly& operator+=(const T&) { return *this; }
+  DebugOnly& operator-=(const T&) { return *this; }
+  DebugOnly& operator&=(const T&) { return *this; }
+  DebugOnly& operator|=(const T&) { return *this; }
+  DebugOnly& operator^=(const T&) { return *this; }
+#endif
+
+  /*
+   * DebugOnly must always have a destructor or else it will
+   * generate "unused variable" warnings, exactly what it's intended
+   * to avoid!
+   */
+  ~DebugOnly() {}
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_DebugOnly_h */
diff --git a/src/third_party/mozjs-45/mfbt/Endian.h b/src/third_party/mozjs-45/mfbt/Endian.h
new file mode 100644
index 0000000..3a7932e
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Endian.h
@@ -0,0 +1,697 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Functions for reading and writing integers in various endiannesses. */
+
+/*
+ * The classes LittleEndian and BigEndian expose static methods for
+ * reading and writing 16-, 32-, and 64-bit signed and unsigned integers
+ * in their respective endianness.  The naming scheme is:
+ *
+ * {Little,Big}Endian::{read,write}{Uint,Int}<bitsize>
+ *
+ * For instance, LittleEndian::readInt32 will read a 32-bit signed
+ * integer from memory in little endian format.  Similarly,
+ * BigEndian::writeUint16 will write a 16-bit unsigned integer to memory
+ * in big-endian format.
+ *
+ * The class NativeEndian exposes methods for conversion of existing
+ * data to and from the native endianness.  These methods are intended
+ * for cases where data needs to be transferred, serialized, etc.
+ * swap{To,From}{Little,Big}Endian byteswap a single value if necessary.
+ * Bulk conversion functions are also provided which optimize the
+ * no-conversion-needed case:
+ *
+ * - copyAndSwap{To,From}{Little,Big}Endian;
+ * - swap{To,From}{Little,Big}EndianInPlace.
+ *
+ * The *From* variants are intended to be used for reading data and the
+ * *To* variants for writing data.
+ *
+ * Methods on NativeEndian work with integer data of any type.
+ * Floating-point data is not supported.
+ *
+ * For clarity in networking code, "Network" may be used as a synonym
+ * for "Big" in any of the above methods or class names.
+ *
+ * As an example, reading a file format header whose fields are stored
+ * in big-endian format might look like:
+ *
+ * class ExampleHeader
+ * {
+ * private:
+ *   uint32_t mMagic;
+ *   uint32_t mLength;
+ *   uint32_t mTotalRecords;
+ *   uint64_t mChecksum;
+ *
+ * public:
+ *   ExampleHeader(const void* data)
+ *   {
+ *     const uint8_t* ptr = static_cast<const uint8_t*>(data);
+ *     mMagic = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t);
+ *     mLength = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t);
+ *     mTotalRecords = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t);
+ *     mChecksum = BigEndian::readUint64(ptr);
+ *   }
+ *   ...
+ * };
+ */
+
+#ifndef mozilla_Endian_h
+#define mozilla_Endian_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Compiler.h"
+#include "mozilla/DebugOnly.h"
+#include "mozilla/TypeTraits.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#if defined(_MSC_VER)
+#  include <stdlib.h>
+#  pragma intrinsic(_byteswap_ushort)
+#  pragma intrinsic(_byteswap_ulong)
+#  pragma intrinsic(_byteswap_uint64)
+#endif
+
+#if defined(_WIN64)
+#  if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)
+#    define MOZ_LITTLE_ENDIAN 1
+#  else
+#    error "CPU type is unknown"
+#  endif
+#elif defined(_WIN32)
+#  if defined(_M_IX86)
+#    define MOZ_LITTLE_ENDIAN 1
+#  elif defined(_M_ARM)
+#    define MOZ_LITTLE_ENDIAN 1
+#  else
+#    error "CPU type is unknown"
+#  endif
+#elif defined(__APPLE__) || defined(__powerpc__) || defined(__ppc__)
+#  if __LITTLE_ENDIAN__
+#    define MOZ_LITTLE_ENDIAN 1
+#  elif __BIG_ENDIAN__
+#    define MOZ_BIG_ENDIAN 1
+#  endif
+#elif defined(__GNUC__) && \
+      defined(__BYTE_ORDER__) && \
+      defined(__ORDER_LITTLE_ENDIAN__) && \
+      defined(__ORDER_BIG_ENDIAN__)
+   /*
+    * Some versions of GCC provide architecture-independent macros for
+    * this.  Yes, there are more than two values for __BYTE_ORDER__.
+    */
+#  if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#    define MOZ_LITTLE_ENDIAN 1
+#  elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#    define MOZ_BIG_ENDIAN 1
+#  else
+#    error "Can't handle mixed-endian architectures"
+#  endif
+/*
+ * We can't include useful headers like <endian.h> or <sys/isa_defs.h>
+ * here because they're not present on all platforms.  Instead we have
+ * this big conditional that ideally will catch all the interesting
+ * cases.
+ */
+#elif defined(__sparc) || defined(__sparc__) || \
+      defined(_POWER) || defined(__hppa) || \
+      defined(_MIPSEB) || defined(__ARMEB__) || \
+      defined(__s390__) || defined(__AARCH64EB__) || \
+      (defined(__sh__) && defined(__LITTLE_ENDIAN__)) || \
+      (defined(__ia64) && defined(__BIG_ENDIAN__))
+#  define MOZ_BIG_ENDIAN 1
+#elif defined(__i386) || defined(__i386__) || \
+      defined(__x86_64) || defined(__x86_64__) || \
+      defined(_MIPSEL) || defined(__ARMEL__) || \
+      defined(__alpha__) || defined(__AARCH64EL__) || \
+      (defined(__sh__) && defined(__BIG_ENDIAN__)) || \
+      (defined(__ia64) && !defined(__BIG_ENDIAN__))
+#  define MOZ_LITTLE_ENDIAN 1
+#endif
+
+#if MOZ_BIG_ENDIAN
+#  define MOZ_LITTLE_ENDIAN 0
+#elif MOZ_LITTLE_ENDIAN
+#  define MOZ_BIG_ENDIAN 0
+#else
+#  error "Cannot determine endianness"
+#endif
+
+#if defined(__clang__)
+#  if __has_builtin(__builtin_bswap16)
+#    define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16
+#  endif
+#elif defined(__GNUC__)
+#  if MOZ_GCC_VERSION_AT_LEAST(4, 8, 0)
+#    define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16
+#  endif
+#elif defined(_MSC_VER)
+#    define MOZ_HAVE_BUILTIN_BYTESWAP16 _byteswap_ushort
+#endif
+
+namespace mozilla {
+
+namespace detail {
+
+/*
+ * We need wrappers here because free functions with default template
+ * arguments and/or partial specialization of function templates are not
+ * supported by all the compilers we use.
+ */
+template<typename T, size_t Size = sizeof(T)>
+struct Swapper;
+
+template<typename T>
+struct Swapper<T, 2>
+{
+  static T swap(T aValue)
+  {
+#if defined(MOZ_HAVE_BUILTIN_BYTESWAP16)
+    return MOZ_HAVE_BUILTIN_BYTESWAP16(aValue);
+#else
+    return T(((aValue & 0x00ff) << 8) | ((aValue & 0xff00) >> 8));
+#endif
+  }
+};
+
+template<typename T>
+struct Swapper<T, 4>
+{
+  static T swap(T aValue)
+  {
+#if defined(__clang__) || defined(__GNUC__)
+    return T(__builtin_bswap32(aValue));
+#elif defined(_MSC_VER)
+    return T(_byteswap_ulong(aValue));
+#else
+    return T(((aValue & 0x000000ffU) << 24) |
+             ((aValue & 0x0000ff00U) << 8) |
+             ((aValue & 0x00ff0000U) >> 8) |
+             ((aValue & 0xff000000U) >> 24));
+#endif
+  }
+};
+
+template<typename T>
+struct Swapper<T, 8>
+{
+  static inline T swap(T aValue)
+  {
+#if defined(__clang__) || defined(__GNUC__)
+    return T(__builtin_bswap64(aValue));
+#elif defined(_MSC_VER)
+    return T(_byteswap_uint64(aValue));
+#else
+    return T(((aValue & 0x00000000000000ffULL) << 56) |
+             ((aValue & 0x000000000000ff00ULL) << 40) |
+             ((aValue & 0x0000000000ff0000ULL) << 24) |
+             ((aValue & 0x00000000ff000000ULL) << 8) |
+             ((aValue & 0x000000ff00000000ULL) >> 8) |
+             ((aValue & 0x0000ff0000000000ULL) >> 24) |
+             ((aValue & 0x00ff000000000000ULL) >> 40) |
+             ((aValue & 0xff00000000000000ULL) >> 56));
+#endif
+  }
+};
+
+enum Endianness { Little, Big };
+
+#if MOZ_BIG_ENDIAN
+#  define MOZ_NATIVE_ENDIANNESS detail::Big
+#else
+#  define MOZ_NATIVE_ENDIANNESS detail::Little
+#endif
+
+class EndianUtils
+{
+  /**
+   * Assert that the memory regions [aDest, aDest+aCount) and
+   * [aSrc, aSrc+aCount] do not overlap.  aCount is given in bytes.
+   */
+  static void assertNoOverlap(const void* aDest, const void* aSrc,
+                              size_t aCount)
+  {
+    DebugOnly<const uint8_t*> byteDestPtr = static_cast<const uint8_t*>(aDest);
+    DebugOnly<const uint8_t*> byteSrcPtr = static_cast<const uint8_t*>(aSrc);
+    MOZ_ASSERT((byteDestPtr <= byteSrcPtr &&
+                byteDestPtr + aCount <= byteSrcPtr) ||
+               (byteSrcPtr <= byteDestPtr &&
+                byteSrcPtr + aCount <= byteDestPtr));
+  }
+
+  template<typename T>
+  static void assertAligned(T* aPtr)
+  {
+    MOZ_ASSERT((uintptr_t(aPtr) % sizeof(T)) == 0, "Unaligned pointer!");
+  }
+
+protected:
+  /**
+   * Return |aValue| converted from SourceEndian encoding to DestEndian
+   * encoding.
+   */
+  template<Endianness SourceEndian, Endianness DestEndian, typename T>
+  static inline T maybeSwap(T aValue)
+  {
+    if (SourceEndian == DestEndian) {
+      return aValue;
+    }
+    return Swapper<T>::swap(aValue);
+  }
+
+  /**
+   * Convert |aCount| elements at |aPtr| from SourceEndian encoding to
+   * DestEndian encoding.
+   */
+  template<Endianness SourceEndian, Endianness DestEndian, typename T>
+  static inline void maybeSwapInPlace(T* aPtr, size_t aCount)
+  {
+    assertAligned(aPtr);
+
+    if (SourceEndian == DestEndian) {
+      return;
+    }
+    for (size_t i = 0; i < aCount; i++) {
+      aPtr[i] = Swapper<T>::swap(aPtr[i]);
+    }
+  }
+
+  /**
+   * Write |aCount| elements to the unaligned address |aDest| in DestEndian
+   * format, using elements found at |aSrc| in SourceEndian format.
+   */
+  template<Endianness SourceEndian, Endianness DestEndian, typename T>
+  static void copyAndSwapTo(void* aDest, const T* aSrc, size_t aCount)
+  {
+    assertNoOverlap(aDest, aSrc, aCount * sizeof(T));
+    assertAligned(aSrc);
+
+    if (SourceEndian == DestEndian) {
+      memcpy(aDest, aSrc, aCount * sizeof(T));
+      return;
+    }
+
+    uint8_t* byteDestPtr = static_cast<uint8_t*>(aDest);
+    for (size_t i = 0; i < aCount; ++i) {
+      union
+      {
+        T mVal;
+        uint8_t mBuffer[sizeof(T)];
+      } u;
+      u.mVal = maybeSwap<SourceEndian, DestEndian>(aSrc[i]);
+      memcpy(byteDestPtr, u.mBuffer, sizeof(T));
+      byteDestPtr += sizeof(T);
+    }
+  }
+
+  /**
+   * Write |aCount| elements to |aDest| in DestEndian format, using elements
+   * found at the unaligned address |aSrc| in SourceEndian format.
+   */
+  template<Endianness SourceEndian, Endianness DestEndian, typename T>
+  static void copyAndSwapFrom(T* aDest, const void* aSrc, size_t aCount)
+  {
+    assertNoOverlap(aDest, aSrc, aCount * sizeof(T));
+    assertAligned(aDest);
+
+    if (SourceEndian == DestEndian) {
+      memcpy(aDest, aSrc, aCount * sizeof(T));
+      return;
+    }
+
+    const uint8_t* byteSrcPtr = static_cast<const uint8_t*>(aSrc);
+    for (size_t i = 0; i < aCount; ++i) {
+      union
+      {
+        T mVal;
+        uint8_t mBuffer[sizeof(T)];
+      } u;
+      memcpy(u.mBuffer, byteSrcPtr, sizeof(T));
+      aDest[i] = maybeSwap<SourceEndian, DestEndian>(u.mVal);
+      byteSrcPtr += sizeof(T);
+    }
+  }
+};
+
+template<Endianness ThisEndian>
+class Endian : private EndianUtils
+{
+protected:
+  /** Read a uint16_t in ThisEndian endianness from |aPtr| and return it. */
+  static MOZ_WARN_UNUSED_RESULT uint16_t readUint16(const void* aPtr)
+  {
+    return read<uint16_t>(aPtr);
+  }
+
+  /** Read a uint32_t in ThisEndian endianness from |aPtr| and return it. */
+  static MOZ_WARN_UNUSED_RESULT uint32_t readUint32(const void* aPtr)
+  {
+    return read<uint32_t>(aPtr);
+  }
+
+  /** Read a uint64_t in ThisEndian endianness from |aPtr| and return it. */
+  static MOZ_WARN_UNUSED_RESULT uint64_t readUint64(const void* aPtr)
+  {
+    return read<uint64_t>(aPtr);
+  }
+
+  /** Read an int16_t in ThisEndian endianness from |aPtr| and return it. */
+  static MOZ_WARN_UNUSED_RESULT int16_t readInt16(const void* aPtr)
+  {
+    return read<int16_t>(aPtr);
+  }
+
+  /** Read an int32_t in ThisEndian endianness from |aPtr| and return it. */
+  static MOZ_WARN_UNUSED_RESULT int32_t readInt32(const void* aPtr)
+  {
+    return read<uint32_t>(aPtr);
+  }
+
+  /** Read an int64_t in ThisEndian endianness from |aPtr| and return it. */
+  static MOZ_WARN_UNUSED_RESULT int64_t readInt64(const void* aPtr)
+  {
+    return read<int64_t>(aPtr);
+  }
+
+  /** Write |aValue| to |aPtr| using ThisEndian endianness. */
+  static void writeUint16(void* aPtr, uint16_t aValue)
+  {
+    write(aPtr, aValue);
+  }
+
+  /** Write |aValue| to |aPtr| using ThisEndian endianness. */
+  static void writeUint32(void* aPtr, uint32_t aValue)
+  {
+    write(aPtr, aValue);
+  }
+
+  /** Write |aValue| to |aPtr| using ThisEndian endianness. */
+  static void writeUint64(void* aPtr, uint64_t aValue)
+  {
+    write(aPtr, aValue);
+  }
+
+  /** Write |aValue| to |aPtr| using ThisEndian endianness. */
+  static void writeInt16(void* aPtr, int16_t aValue)
+  {
+    write(aPtr, aValue);
+  }
+
+  /** Write |aValue| to |aPtr| using ThisEndian endianness. */
+  static void writeInt32(void* aPtr, int32_t aValue)
+  {
+    write(aPtr, aValue);
+  }
+
+  /** Write |aValue| to |aPtr| using ThisEndian endianness. */
+  static void writeInt64(void* aPtr, int64_t aValue)
+  {
+    write(aPtr, aValue);
+  }
+
+  /*
+   * Converts a value of type T to little-endian format.
+   *
+   * This function is intended for cases where you have data in your
+   * native-endian format and you need it to appear in little-endian
+   * format for transmission.
+   */
+  template<typename T>
+  MOZ_WARN_UNUSED_RESULT static T swapToLittleEndian(T aValue)
+  {
+    return maybeSwap<ThisEndian, Little>(aValue);
+  }
+
+  /*
+   * Copies |aCount| values of type T starting at |aSrc| to |aDest|, converting
+   * them to little-endian format if ThisEndian is Big.
+   * As with memcpy, |aDest| and |aSrc| must not overlap.
+   */
+  template<typename T>
+  static void copyAndSwapToLittleEndian(void* aDest, const T* aSrc,
+                                        size_t aCount)
+  {
+    copyAndSwapTo<ThisEndian, Little>(aDest, aSrc, aCount);
+  }
+
+  /*
+   * Likewise, but converts values in place.
+   */
+  template<typename T>
+  static void swapToLittleEndianInPlace(T* aPtr, size_t aCount)
+  {
+    maybeSwapInPlace<ThisEndian, Little>(aPtr, aCount);
+  }
+
+  /*
+   * Converts a value of type T to big-endian format.
+   */
+  template<typename T>
+  MOZ_WARN_UNUSED_RESULT static T swapToBigEndian(T aValue)
+  {
+    return maybeSwap<ThisEndian, Big>(aValue);
+  }
+
+  /*
+   * Copies |aCount| values of type T starting at |aSrc| to |aDest|, converting
+   * them to big-endian format if ThisEndian is Little.
+   * As with memcpy, |aDest| and |aSrc| must not overlap.
+   */
+  template<typename T>
+  static void copyAndSwapToBigEndian(void* aDest, const T* aSrc,
+                                     size_t aCount)
+  {
+    copyAndSwapTo<ThisEndian, Big>(aDest, aSrc, aCount);
+  }
+
+  /*
+   * Likewise, but converts values in place.
+   */
+  template<typename T>
+  static void swapToBigEndianInPlace(T* aPtr, size_t aCount)
+  {
+    maybeSwapInPlace<ThisEndian, Big>(aPtr, aCount);
+  }
+
+  /*
+   * Synonyms for the big-endian functions, for better readability
+   * in network code.
+   */
+
+  template<typename T>
+  MOZ_WARN_UNUSED_RESULT static T swapToNetworkOrder(T aValue)
+  {
+    return swapToBigEndian(aValue);
+  }
+
+  template<typename T>
+  static void
+  copyAndSwapToNetworkOrder(void* aDest, const T* aSrc, size_t aCount)
+  {
+    copyAndSwapToBigEndian(aDest, aSrc, aCount);
+  }
+
+  template<typename T>
+  static void
+  swapToNetworkOrderInPlace(T* aPtr, size_t aCount)
+  {
+    swapToBigEndianInPlace(aPtr, aCount);
+  }
+
+  /*
+   * Converts a value of type T from little-endian format.
+   */
+  template<typename T>
+  MOZ_WARN_UNUSED_RESULT static T swapFromLittleEndian(T aValue)
+  {
+    return maybeSwap<Little, ThisEndian>(aValue);
+  }
+
+  /*
+   * Copies |aCount| values of type T starting at |aSrc| to |aDest|, converting
+   * them to little-endian format if ThisEndian is Big.
+   * As with memcpy, |aDest| and |aSrc| must not overlap.
+   */
+  template<typename T>
+  static void copyAndSwapFromLittleEndian(T* aDest, const void* aSrc,
+                                          size_t aCount)
+  {
+    copyAndSwapFrom<Little, ThisEndian>(aDest, aSrc, aCount);
+  }
+
+  /*
+   * Likewise, but converts values in place.
+   */
+  template<typename T>
+  static void swapFromLittleEndianInPlace(T* aPtr, size_t aCount)
+  {
+    maybeSwapInPlace<Little, ThisEndian>(aPtr, aCount);
+  }
+
+  /*
+   * Converts a value of type T from big-endian format.
+   */
+  template<typename T>
+  MOZ_WARN_UNUSED_RESULT static T swapFromBigEndian(T aValue)
+  {
+    return maybeSwap<Big, ThisEndian>(aValue);
+  }
+
+  /*
+   * Copies |aCount| values of type T starting at |aSrc| to |aDest|, converting
+   * them to big-endian format if ThisEndian is Little.
+   * As with memcpy, |aDest| and |aSrc| must not overlap.
+   */
+  template<typename T>
+  static void copyAndSwapFromBigEndian(T* aDest, const void* aSrc,
+                                       size_t aCount)
+  {
+    copyAndSwapFrom<Big, ThisEndian>(aDest, aSrc, aCount);
+  }
+
+  /*
+   * Likewise, but converts values in place.
+   */
+  template<typename T>
+  static void swapFromBigEndianInPlace(T* aPtr, size_t aCount)
+  {
+    maybeSwapInPlace<Big, ThisEndian>(aPtr, aCount);
+  }
+
+  /*
+   * Synonyms for the big-endian functions, for better readability
+   * in network code.
+   */
+  template<typename T>
+  MOZ_WARN_UNUSED_RESULT static T swapFromNetworkOrder(T aValue)
+  {
+    return swapFromBigEndian(aValue);
+  }
+
+  template<typename T>
+  static void copyAndSwapFromNetworkOrder(T* aDest, const void* aSrc,
+                                          size_t aCount)
+  {
+    copyAndSwapFromBigEndian(aDest, aSrc, aCount);
+  }
+
+  template<typename T>
+  static void swapFromNetworkOrderInPlace(T* aPtr, size_t aCount)
+  {
+    swapFromBigEndianInPlace(aPtr, aCount);
+  }
+
+private:
+  /**
+   * Read a value of type T, encoded in endianness ThisEndian from |aPtr|.
+   * Return that value encoded in native endianness.
+   */
+  template<typename T>
+  static T read(const void* aPtr)
+  {
+    union
+    {
+      T mVal;
+      uint8_t mBuffer[sizeof(T)];
+    } u;
+    memcpy(u.mBuffer, aPtr, sizeof(T));
+    return maybeSwap<ThisEndian, MOZ_NATIVE_ENDIANNESS>(u.mVal);
+  }
+
+  /**
+   * Write a value of type T, in native endianness, to |aPtr|, in ThisEndian
+   * endianness.
+   */
+  template<typename T>
+  static void write(void* aPtr, T aValue)
+  {
+    T tmp = maybeSwap<MOZ_NATIVE_ENDIANNESS, ThisEndian>(aValue);
+    memcpy(aPtr, &tmp, sizeof(T));
+  }
+
+  Endian() = delete;
+  Endian(const Endian& aTther) = delete;
+  void operator=(const Endian& aOther) = delete;
+};
+
+template<Endianness ThisEndian>
+class EndianReadWrite : public Endian<ThisEndian>
+{
+private:
+  typedef Endian<ThisEndian> super;
+
+public:
+  using super::readUint16;
+  using super::readUint32;
+  using super::readUint64;
+  using super::readInt16;
+  using super::readInt32;
+  using super::readInt64;
+  using super::writeUint16;
+  using super::writeUint32;
+  using super::writeUint64;
+  using super::writeInt16;
+  using super::writeInt32;
+  using super::writeInt64;
+};
+
+} /* namespace detail */
+
+class LittleEndian final : public detail::EndianReadWrite<detail::Little>
+{};
+
+class BigEndian final : public detail::EndianReadWrite<detail::Big>
+{};
+
+typedef BigEndian NetworkEndian;
+
+class NativeEndian final : public detail::Endian<MOZ_NATIVE_ENDIANNESS>
+{
+private:
+  typedef detail::Endian<MOZ_NATIVE_ENDIANNESS> super;
+
+public:
+  /*
+   * These functions are intended for cases where you have data in your
+   * native-endian format and you need the data to appear in the appropriate
+   * endianness for transmission, serialization, etc.
+   */
+  using super::swapToLittleEndian;
+  using super::copyAndSwapToLittleEndian;
+  using super::swapToLittleEndianInPlace;
+  using super::swapToBigEndian;
+  using super::copyAndSwapToBigEndian;
+  using super::swapToBigEndianInPlace;
+  using super::swapToNetworkOrder;
+  using super::copyAndSwapToNetworkOrder;
+  using super::swapToNetworkOrderInPlace;
+
+  /*
+   * These functions are intended for cases where you have data in the
+   * given endianness (e.g. reading from disk or a file-format) and you
+   * need the data to appear in native-endian format for processing.
+   */
+  using super::swapFromLittleEndian;
+  using super::copyAndSwapFromLittleEndian;
+  using super::swapFromLittleEndianInPlace;
+  using super::swapFromBigEndian;
+  using super::copyAndSwapFromBigEndian;
+  using super::swapFromBigEndianInPlace;
+  using super::swapFromNetworkOrder;
+  using super::copyAndSwapFromNetworkOrder;
+  using super::swapFromNetworkOrderInPlace;
+};
+
+#undef MOZ_NATIVE_ENDIANNESS
+
+} /* namespace mozilla */
+
+#endif /* mozilla_Endian_h */
diff --git a/src/third_party/mozjs-45/mfbt/EnumSet.h b/src/third_party/mozjs-45/mfbt/EnumSet.h
new file mode 100644
index 0000000..a445f97
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/EnumSet.h
@@ -0,0 +1,214 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A set abstraction for enumeration values. */
+
+#ifndef mozilla_EnumSet_h
+#define mozilla_EnumSet_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+
+#include <stdint.h>
+
+namespace mozilla {
+
+/**
+ * EnumSet<T> is a set of values defined by an enumeration. It is implemented
+ * using a 32 bit mask for each value so it will only work for enums with an int
+ * representation less than 32. It works both for enum and enum class types.
+ */
+template<typename T>
+class EnumSet
+{
+public:
+  EnumSet()
+    : mBitField(0)
+  { }
+
+  MOZ_IMPLICIT EnumSet(T aEnum)
+    : mBitField(bitFor(aEnum))
+  { }
+
+  EnumSet(T aEnum1, T aEnum2)
+    : mBitField(bitFor(aEnum1) |
+                bitFor(aEnum2))
+  { }
+
+  EnumSet(T aEnum1, T aEnum2, T aEnum3)
+    : mBitField(bitFor(aEnum1) |
+                bitFor(aEnum2) |
+                bitFor(aEnum3))
+  { }
+
+  EnumSet(T aEnum1, T aEnum2, T aEnum3, T aEnum4)
+   : mBitField(bitFor(aEnum1) |
+               bitFor(aEnum2) |
+               bitFor(aEnum3) |
+               bitFor(aEnum4))
+  { }
+
+  EnumSet(const EnumSet& aEnumSet)
+   : mBitField(aEnumSet.mBitField)
+  { }
+
+  /**
+   * Add an element
+   */
+  void operator+=(T aEnum)
+  {
+    mBitField |= bitFor(aEnum);
+  }
+
+  /**
+   * Add an element
+   */
+  EnumSet<T> operator+(T aEnum) const
+  {
+    EnumSet<T> result(*this);
+    result += aEnum;
+    return result;
+  }
+
+  /**
+   * Union
+   */
+  void operator+=(const EnumSet<T> aEnumSet)
+  {
+    mBitField |= aEnumSet.mBitField;
+  }
+
+  /**
+   * Union
+   */
+  EnumSet<T> operator+(const EnumSet<T> aEnumSet) const
+  {
+    EnumSet<T> result(*this);
+    result += aEnumSet;
+    return result;
+  }
+
+  /**
+   * Remove an element
+   */
+  void operator-=(T aEnum)
+  {
+    mBitField &= ~(bitFor(aEnum));
+  }
+
+  /**
+   * Remove an element
+   */
+  EnumSet<T> operator-(T aEnum) const
+  {
+    EnumSet<T> result(*this);
+    result -= aEnum;
+    return result;
+  }
+
+  /**
+   * Remove a set of elements
+   */
+  void operator-=(const EnumSet<T> aEnumSet)
+  {
+    mBitField &= ~(aEnumSet.mBitField);
+  }
+
+  /**
+   * Remove a set of elements
+   */
+  EnumSet<T> operator-(const EnumSet<T> aEnumSet) const
+  {
+    EnumSet<T> result(*this);
+    result -= aEnumSet;
+    return result;
+  }
+
+  /**
+   * Clear
+   */
+  void clear()
+  {
+    mBitField = 0;
+  }
+
+  /**
+   * Intersection
+   */
+  void operator&=(const EnumSet<T> aEnumSet)
+  {
+    mBitField &= aEnumSet.mBitField;
+  }
+
+  /**
+   * Intersection
+   */
+  EnumSet<T> operator&(const EnumSet<T> aEnumSet) const
+  {
+    EnumSet<T> result(*this);
+    result &= aEnumSet;
+    return result;
+  }
+
+  /**
+   * Equality
+   */
+  bool operator==(const EnumSet<T> aEnumSet) const
+  {
+    return mBitField == aEnumSet.mBitField;
+  }
+
+  /**
+   * Test is an element is contained in the set.
+   */
+  bool contains(T aEnum) const
+  {
+    return mBitField & bitFor(aEnum);
+  }
+
+  /**
+   * Return the number of elements in the set.
+   */
+  uint8_t size()
+  {
+    uint8_t count = 0;
+    for (uint32_t bitField = mBitField; bitField; bitField >>= 1) {
+      if (bitField & 1) {
+        count++;
+      }
+    }
+    return count;
+  }
+
+  bool isEmpty() const
+  {
+    return mBitField == 0;
+  }
+
+  uint32_t serialize() const
+  {
+    return mBitField;
+  }
+
+  void deserialize(uint32_t aValue)
+  {
+    mBitField = aValue;
+  }
+
+private:
+  static uint32_t bitFor(T aEnum)
+  {
+    uint32_t bitNumber = (uint32_t)aEnum;
+    MOZ_ASSERT(bitNumber < 32);
+    return 1U << bitNumber;
+  }
+
+  uint32_t mBitField;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_EnumSet_h_*/
diff --git a/src/third_party/mozjs-45/mfbt/EnumeratedArray.h b/src/third_party/mozjs-45/mfbt/EnumeratedArray.h
new file mode 100644
index 0000000..afd06ea
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/EnumeratedArray.h
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* EnumeratedArray is like Array, but indexed by a typed enum. */
+
+#ifndef mozilla_EnumeratedArray_h
+#define mozilla_EnumeratedArray_h
+
+#include "mozilla/Array.h"
+
+namespace mozilla {
+
+/**
+ * EnumeratedArray is a fixed-size array container for use when an
+ * array is indexed by a specific enum class.
+ *
+ * This provides type safety by guarding at compile time against accidentally
+ * indexing such arrays with unrelated values. This also removes the need
+ * for manual casting when using a typed enum value to index arrays.
+ *
+ * Aside from the typing of indices, EnumeratedArray is similar to Array.
+ *
+ * Example:
+ *
+ *   enum class AnimalSpecies {
+ *     Cow,
+ *     Sheep,
+ *     Count
+ *   };
+ *
+ *   EnumeratedArray<AnimalSpecies, AnimalSpecies::Count, int> headCount;
+ *
+ *   headCount[AnimalSpecies::Cow] = 17;
+ *   headCount[AnimalSpecies::Sheep] = 30;
+ *
+ */
+template<typename IndexType,
+         IndexType SizeAsEnumValue,
+         typename ValueType>
+class EnumeratedArray
+{
+public:
+  static const size_t kSize = size_t(SizeAsEnumValue);
+
+private:
+  typedef Array<ValueType, kSize> ArrayType;
+
+  ArrayType mArray;
+
+public:
+  EnumeratedArray() {}
+
+  explicit EnumeratedArray(const EnumeratedArray& aOther)
+  {
+    for (size_t i = 0; i < kSize; i++) {
+      mArray[i] = aOther.mArray[i];
+    }
+  }
+
+  ValueType& operator[](IndexType aIndex)
+  {
+    return mArray[size_t(aIndex)];
+  }
+
+  const ValueType& operator[](IndexType aIndex) const
+  {
+    return mArray[size_t(aIndex)];
+  }
+
+  typedef typename ArrayType::iterator               iterator;
+  typedef typename ArrayType::const_iterator         const_iterator;
+  typedef typename ArrayType::reverse_iterator       reverse_iterator;
+  typedef typename ArrayType::const_reverse_iterator const_reverse_iterator;
+
+  // Methods for range-based for loops.
+  iterator begin() { return mArray.begin(); }
+  const_iterator begin() const { return mArray.begin(); }
+  const_iterator cbegin() const { return mArray.cbegin(); }
+  iterator end() { return mArray.end(); }
+  const_iterator end() const { return mArray.end(); }
+  const_iterator cend() const { return mArray.cend(); }
+
+  // Methods for reverse iterating.
+  reverse_iterator rbegin() { return mArray.rbegin(); }
+  const_reverse_iterator rbegin() const { return mArray.rbegin(); }
+  const_reverse_iterator crbegin() const { return mArray.crbegin(); }
+  reverse_iterator rend() { return mArray.rend(); }
+  const_reverse_iterator rend() const { return mArray.rend(); }
+  const_reverse_iterator crend() const { return mArray.crend(); }
+};
+
+} // namespace mozilla
+
+#endif // mozilla_EnumeratedArray_h
diff --git a/src/third_party/mozjs-45/mfbt/EnumeratedRange.h b/src/third_party/mozjs-45/mfbt/EnumeratedRange.h
new file mode 100644
index 0000000..fdca956
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/EnumeratedRange.h
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Iterator over contiguous enum values */
+
+/*
+ * Implements generator functions that create a range to iterate over the values
+ * of a scoped or unscoped enum. Unlike IntegerRange, which can only function on
+ * the underlying integral type, the elements of the generated sequence will
+ * have the type of the enum in question.
+ *
+ * Note that the enum values should be contiguous in the iterated range;
+ * unfortunately there exists no way for EnumeratedRange to enforce this
+ * either dynamically or at compile time.
+ */
+
+#ifndef mozilla_EnumeratedRange_h
+#define mozilla_EnumeratedRange_h
+
+#include "mozilla/IntegerTypeTraits.h"
+#include "mozilla/ReverseIterator.h"
+
+namespace mozilla {
+
+namespace detail {
+
+template<typename IntTypeT, typename EnumTypeT>
+class EnumeratedIterator
+{
+public:
+  template<typename EnumType>
+  explicit EnumeratedIterator(EnumType aCurrent)
+    : mCurrent(aCurrent) { }
+
+  template<typename IntType, typename EnumType>
+  explicit EnumeratedIterator(const EnumeratedIterator<IntType, EnumType>& aOther)
+    : mCurrent(aOther.mCurrent) { }
+
+  EnumTypeT operator*() const { return mCurrent; }
+
+  /* Increment and decrement operators */
+
+  EnumeratedIterator& operator++()
+  {
+    mCurrent = EnumTypeT(IntTypeT(mCurrent) + IntTypeT(1));
+    return *this;
+  }
+  EnumeratedIterator& operator--()
+  {
+    mCurrent = EnumTypeT(IntTypeT(mCurrent) - IntTypeT(1));
+    return *this;
+  }
+  EnumeratedIterator operator++(int)
+  {
+    auto ret = *this;
+    mCurrent = EnumTypeT(IntTypeT(mCurrent) + IntTypeT(1));
+    return ret;
+  }
+  EnumeratedIterator operator--(int)
+  {
+    auto ret = *this;
+    mCurrent = EnumTypeT(IntTypeT(mCurrent) - IntTypeT(1));
+    return ret;
+  }
+
+  /* Comparison operators */
+
+  template<typename IntType, typename EnumType>
+  friend bool operator==(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                         const EnumeratedIterator<IntType, EnumType>& aIter2);
+  template<typename IntType, typename EnumType>
+  friend bool operator!=(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                         const EnumeratedIterator<IntType, EnumType>& aIter2);
+  template<typename IntType, typename EnumType>
+  friend bool operator<(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                        const EnumeratedIterator<IntType, EnumType>& aIter2);
+  template<typename IntType, typename EnumType>
+  friend bool operator<=(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                         const EnumeratedIterator<IntType, EnumType>& aIter2);
+  template<typename IntType, typename EnumType>
+  friend bool operator>(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                        const EnumeratedIterator<IntType, EnumType>& aIter2);
+  template<typename IntType, typename EnumType>
+  friend bool operator>=(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                         const EnumeratedIterator<IntType, EnumType>& aIter2);
+
+private:
+  EnumTypeT mCurrent;
+};
+
+template<typename IntType, typename EnumType>
+bool operator==(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                const EnumeratedIterator<IntType, EnumType>& aIter2)
+{
+  return aIter1.mCurrent == aIter2.mCurrent;
+}
+
+template<typename IntType, typename EnumType>
+bool operator!=(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                const EnumeratedIterator<IntType, EnumType>& aIter2)
+{
+  return aIter1.mCurrent != aIter2.mCurrent;
+}
+
+template<typename IntType, typename EnumType>
+bool operator<(const EnumeratedIterator<IntType, EnumType>& aIter1,
+               const EnumeratedIterator<IntType, EnumType>& aIter2)
+{
+  return aIter1.mCurrent < aIter2.mCurrent;
+}
+
+template<typename IntType, typename EnumType>
+bool operator<=(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                const EnumeratedIterator<IntType, EnumType>& aIter2)
+{
+  return aIter1.mCurrent <= aIter2.mCurrent;
+}
+
+template<typename IntType, typename EnumType>
+bool operator>(const EnumeratedIterator<IntType, EnumType>& aIter1,
+               const EnumeratedIterator<IntType, EnumType>& aIter2)
+{
+  return aIter1.mCurrent > aIter2.mCurrent;
+}
+
+template<typename IntType, typename EnumType>
+bool operator>=(const EnumeratedIterator<IntType, EnumType>& aIter1,
+                const EnumeratedIterator<IntType, EnumType>& aIter2)
+{
+  return aIter1.mCurrent >= aIter2.mCurrent;
+}
+
+template<typename IntTypeT, typename EnumTypeT>
+class EnumeratedRange
+{
+public:
+  typedef EnumeratedIterator<IntTypeT, EnumTypeT> iterator;
+  typedef EnumeratedIterator<IntTypeT, EnumTypeT> const_iterator;
+  typedef ReverseIterator<iterator> reverse_iterator;
+  typedef ReverseIterator<const_iterator> const_reverse_iterator;
+
+  template<typename EnumType>
+  EnumeratedRange(EnumType aBegin, EnumType aEnd)
+    : mBegin(aBegin), mEnd(aEnd) { }
+
+  iterator begin() const { return iterator(mBegin); }
+  const_iterator cbegin() const { return begin(); }
+  iterator end() const { return iterator(mEnd); }
+  const_iterator cend() const { return end(); }
+  reverse_iterator rbegin() const { return reverse_iterator(mEnd); }
+  const_reverse_iterator crbegin() const { return rbegin(); }
+  reverse_iterator rend() const { return reverse_iterator(mBegin); }
+  const_reverse_iterator crend() const { return rend(); }
+
+private:
+  EnumTypeT mBegin;
+  EnumTypeT mEnd;
+};
+
+} // namespace detail
+
+#ifdef __GNUC__
+// Enums can have an unsigned underlying type, which makes some of the
+// comparisons below always true or always false. Temporarily disable
+// -Wtype-limits to avoid breaking -Werror builds.
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wtype-limits"
+#endif
+
+// Create a range to iterate from aBegin to aEnd, exclusive.
+//
+// (Once we can rely on std::underlying_type, we can remove the IntType
+// template parameter.)
+template<typename IntType, typename EnumType>
+inline detail::EnumeratedRange<IntType, EnumType>
+MakeEnumeratedRange(EnumType aBegin, EnumType aEnd)
+{
+#ifdef DEBUG
+  typedef typename MakeUnsigned<IntType>::Type UnsignedType;
+#endif
+  static_assert(sizeof(IntType) >= sizeof(EnumType),
+                "IntType should be at least as big as EnumType!");
+  MOZ_ASSERT(aBegin <= aEnd, "Cannot generate invalid, unbounded range!");
+  MOZ_ASSERT_IF(aBegin < EnumType(0), IsSigned<IntType>::value);
+  MOZ_ASSERT_IF(aBegin >= EnumType(0) && IsSigned<IntType>::value,
+                UnsignedType(aEnd) <= UnsignedType(MaxValue<IntType>::value));
+  return detail::EnumeratedRange<IntType, EnumType>(aBegin, aEnd);
+}
+
+// Create a range to iterate from EnumType(0) to aEnd, exclusive. EnumType(0)
+// should exist, but note that there is no way for us to ensure that it does!
+// Since the enumeration starts at EnumType(0), we know for sure that the values
+// will be in range of our deduced IntType.
+template<typename EnumType>
+inline detail::EnumeratedRange<
+  typename UnsignedStdintTypeForSize<sizeof(EnumType)>::Type,
+  EnumType>
+MakeEnumeratedRange(EnumType aEnd)
+{
+  return MakeEnumeratedRange<
+    typename UnsignedStdintTypeForSize<sizeof(EnumType)>::Type>(EnumType(0),
+                                                                aEnd);
+}
+
+#ifdef __GNUC__
+#  pragma GCC diagnostic pop
+#endif
+
+} // namespace mozilla
+
+#endif // mozilla_EnumeratedRange_h
+
diff --git a/src/third_party/mozjs-45/mfbt/FastBernoulliTrial.h b/src/third_party/mozjs-45/mfbt/FastBernoulliTrial.h
new file mode 100644
index 0000000..fbfc34b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/FastBernoulliTrial.h
@@ -0,0 +1,376 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_FastBernoulliTrial_h
+#define mozilla_FastBernoulliTrial_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/XorShift128PlusRNG.h"
+
+#include <cmath>
+#include <stdint.h>
+
+namespace mozilla {
+
+/**
+ * class FastBernoulliTrial: Efficient sampling with uniform probability
+ *
+ * When gathering statistics about a program's behavior, we may be observing
+ * events that occur very frequently (e.g., function calls or memory
+ * allocations) and we may be gathering information that is somewhat expensive
+ * to produce (e.g., call stacks). Sampling all the events could have a
+ * significant impact on the program's performance.
+ *
+ * Why not just sample every N'th event? This technique is called "systematic
+ * sampling"; it's simple and efficient, and it's fine if we imagine a
+ * patternless stream of events. But what if we're sampling allocations, and the
+ * program happens to have a loop where each iteration does exactly N
+ * allocations? You would end up sampling the same allocation every time through
+ * the loop; the entire rest of the loop becomes invisible to your measurements!
+ * More generally, if each iteration does M allocations, and M and N have any
+ * common divisor at all, most allocation sites will never be sampled. If
+ * they're both even, say, the odd-numbered allocations disappear from your
+ * results.
+ *
+ * Ideally, we'd like each event to have some probability P of being sampled,
+ * independent of its neighbors and of its position in the sequence. This is
+ * called "Bernoulli sampling", and it doesn't suffer from any of the problems
+ * mentioned above.
+ *
+ * One disadvantage of Bernoulli sampling is that you can't be sure exactly how
+ * many samples you'll get: technically, it's possible that you might sample
+ * none of them, or all of them. But if the number of events N is large, these
+ * aren't likely outcomes; you can generally expect somewhere around P * N
+ * events to be sampled.
+ *
+ * The other disadvantage of Bernoulli sampling is that you have to generate a
+ * random number for every event, which can be slow.
+ *
+ * [significant pause]
+ *
+ * BUT NOT WITH THIS CLASS! FastBernoulliTrial lets you do true Bernoulli
+ * sampling, while generating a fresh random number only when we do decide to
+ * sample an event, not on every trial. When it decides not to sample, a call to
+ * |FastBernoulliTrial::trial| is nothing but decrementing a counter and
+ * comparing it to zero. So the lower your sampling probability is, the less
+ * overhead FastBernoulliTrial imposes.
+ *
+ * Probabilities of 0 and 1 are handled efficiently. (In neither case need we
+ * ever generate a random number at all.)
+ *
+ * The essential API:
+ *
+ * - FastBernoulliTrial(double P)
+ *   Construct an instance that selects events with probability P.
+ *
+ * - FastBernoulliTrial::trial()
+ *   Return true with probability P. Call this each time an event occurs, to
+ *   decide whether to sample it or not.
+ *
+ * - FastBernoulliTrial::trial(size_t n)
+ *   Equivalent to calling trial() |n| times, and returning true if any of those
+ *   calls do. However, like trial, this runs in fast constant time.
+ *
+ *   What is this good for? In some applications, some events are "bigger" than
+ *   others. For example, large allocations are more significant than small
+ *   allocations. Perhaps we'd like to imagine that we're drawing allocations
+ *   from a stream of bytes, and performing a separate Bernoulli trial on every
+ *   byte from the stream. We can accomplish this by calling |t.trial(S)| for
+ *   the number of bytes S, and sampling the event if that returns true.
+ *
+ *   Of course, this style of sampling needs to be paired with analysis and
+ *   presentation that makes the size of the event apparent, lest trials with
+ *   large values for |n| appear to be indistinguishable from those with small
+ *   values for |n|.
+ */
+class FastBernoulliTrial {
+  /*
+   * This comment should just read, "Generate skip counts with a geometric
+   * distribution", and leave everyone to go look that up and see why it's the
+   * right thing to do, if they don't know already.
+   *
+   * BUT IF YOU'RE CURIOUS, COMMENTS ARE FREE...
+   *
+   * Instead of generating a fresh random number for every trial, we can
+   * randomly generate a count of how many times we should return false before
+   * the next time we return true. We call this a "skip count". Once we've
+   * returned true, we generate a fresh skip count, and begin counting down
+   * again.
+   *
+   * Here's an awesome fact: by exercising a little care in the way we generate
+   * skip counts, we can produce results indistinguishable from those we would
+   * get "rolling the dice" afresh for every trial.
+   *
+   * In short, skip counts in Bernoulli trials of probability P obey a geometric
+   * distribution. If a random variable X is uniformly distributed from [0..1),
+   * then std::floor(std::log(X) / std::log(1-P)) has the appropriate geometric
+   * distribution for the skip counts.
+   *
+   * Why that formula?
+   *
+   * Suppose we're to return |true| with some probability P, say, 0.3. Spread
+   * all possible futures along a line segment of length 1. In portion P of
+   * those cases, we'll return true on the next call to |trial|; the skip count
+   * is 0. For the remaining portion 1-P of cases, the skip count is 1 or more.
+   *
+   * skip:                0                         1 or more
+   *             |------------------^-----------------------------------------|
+   * portion:            0.3                            0.7
+   *                      P                             1-P
+   *
+   * But the "1 or more" section of the line is subdivided the same way: *within
+   * that section*, in portion P the second call to |trial()| returns true, and in
+   * portion 1-P it returns false a second time; the skip count is two or more.
+   * So we return true on the second call in proportion 0.7 * 0.3, and skip at
+   * least the first two in proportion 0.7 * 0.7.
+   *
+   * skip:                0                1              2 or more
+   *             |------------------^------------^----------------------------|
+   * portion:            0.3           0.7 * 0.3          0.7 * 0.7
+   *                      P             (1-P)*P            (1-P)^2
+   *
+   * We can continue to subdivide:
+   *
+   * skip >= 0:  |------------------------------------------------- (1-P)^0 --|
+   * skip >= 1:  |                  ------------------------------- (1-P)^1 --|
+   * skip >= 2:  |                               ------------------ (1-P)^2 --|
+   * skip >= 3:  |                                 ^     ---------- (1-P)^3 --|
+   * skip >= 4:  |                                 .            --- (1-P)^4 --|
+   *                                               .
+   *                                               ^X, see below
+   *
+   * In other words, the likelihood of the next n calls to |trial| returning
+   * false is (1-P)^n. The longer a run we require, the more the likelihood
+   * drops. Further calls may return false too, but this is the probability
+   * we'll skip at least n.
+   *
+   * This is interesting, because we can pick a point along this line segment
+   * and see which skip count's range it falls within; the point X above, for
+   * example, is within the ">= 2" range, but not within the ">= 3" range, so it
+   * designates a skip count of 2. So if we pick points on the line at random
+   * and use the skip counts they fall under, that will be indistinguishable
+   * from generating a fresh random number between 0 and 1 for each trial and
+   * comparing it to P.
+   *
+   * So to find the skip count for a point X, we must ask: To what whole power
+   * must we raise 1-P such that we include X, but the next power would exclude
+   * it? This is exactly std::floor(std::log(X) / std::log(1-P)).
+   *
+   * Our algorithm is then, simply: When constructed, compute an initial skip
+   * count. Return false from |trial| that many times, and then compute a new skip
+   * count.
+   *
+   * For a call to |trial(n)|, if the skip count is greater than n, return false
+   * and subtract n from the skip count. If the skip count is less than n,
+   * return true and compute a new skip count. Since each trial is independent,
+   * it doesn't matter by how much n overshoots the skip count; we can actually
+   * compute a new skip count at *any* time without affecting the distribution.
+   * This is really beautiful.
+   */
+ public:
+  /**
+   * Construct a fast Bernoulli trial generator. Calls to |trial()| return true
+   * with probability |aProbability|. Use |aState0| and |aState1| to seed the
+   * random number generator; both may not be zero.
+   */
+  FastBernoulliTrial(double aProbability, uint64_t aState0, uint64_t aState1)
+   : mGenerator(aState0, aState1)
+  {
+    setProbability(aProbability);
+  }
+
+  /**
+   * Return true with probability |mProbability|. Call this each time an event
+   * occurs, to decide whether to sample it or not. The lower |mProbability| is,
+   * the faster this function runs.
+   */
+  bool trial() {
+    if (mSkipCount) {
+      mSkipCount--;
+      return false;
+    }
+
+    return chooseSkipCount();
+  }
+
+  /**
+   * Equivalent to calling trial() |n| times, and returning true if any of those
+   * calls do. However, like trial, this runs in fast constant time.
+   *
+   * What is this good for? In some applications, some events are "bigger" than
+   * others. For example, large allocations are more significant than small
+   * allocations. Perhaps we'd like to imagine that we're drawing allocations
+   * from a stream of bytes, and performing a separate Bernoulli trial on every
+   * byte from the stream. We can accomplish this by calling |t.trial(S)| for
+   * the number of bytes S, and sampling the event if that returns true.
+   *
+   * Of course, this style of sampling needs to be paired with analysis and
+   * presentation that makes the "size" of the event apparent, lest trials with
+   * large values for |n| appear to be indistinguishable from those with small
+   * values for |n|, despite being potentially much more likely to be sampled.
+   */
+  bool trial(size_t aCount) {
+    if (mSkipCount > aCount) {
+      mSkipCount -= aCount;
+      return false;
+    }
+
+    return chooseSkipCount();
+  }
+
+  void setRandomState(uint64_t aState0, uint64_t aState1) {
+    mGenerator.setState(aState0, aState1);
+  }
+
+  void setProbability(double aProbability) {
+    MOZ_ASSERT(0 <= aProbability && aProbability <= 1);
+    mProbability = aProbability;
+    if (0 < mProbability && mProbability < 1) {
+      /*
+       * Let's look carefully at how this calculation plays out in floating-
+       * point arithmetic. We'll assume IEEE, but the final C++ code we arrive
+       * at would still be fine if our numbers were mathematically perfect. So,
+       * while we've considered IEEE's edge cases, we haven't done anything that
+       * should be actively bad when using other representations.
+       *
+       * (In the below, read comparisons as exact mathematical comparisons: when
+       * we say something "equals 1", that means it's exactly equal to 1. We
+       * treat approximation using intervals with open boundaries: saying a
+       * value is in (0,1) doesn't specify how close to 0 or 1 the value gets.
+       * When we use closed boundaries like [2**-53, 1], we're careful to ensure
+       * the boundary values are actually representable.)
+       *
+       * - After the comparison above, we know mProbability is in (0,1).
+       *
+       * - The gaps below 1 are 2**-53, so that interval is (0, 1-2**-53].
+       *
+       * - Because the floating-point gaps near 1 are wider than those near
+       *   zero, there are many small positive doubles ε such that 1-ε rounds to
+       *   exactly 1. However, 2**-53 can be represented exactly. So
+       *   1-mProbability is in [2**-53, 1].
+       *
+       * - log(1 - mProbability) is thus in (-37, 0].
+       *
+       *   That range includes zero, but when we use mInvLogNotProbability, it
+       *   would be helpful if we could trust that it's negative. So when log(1
+       *   - mProbability) is 0, we'll just set mProbability to 0, so that
+       *   mInvLogNotProbability is not used in chooseSkipCount.
+       *
+       * - How much of the range of mProbability does this cause us to ignore?
+       *   The only value for which log returns 0 is exactly 1; the slope of log
+       *   at 1 is 1, so for small ε such that 1 - ε != 1, log(1 - ε) is -ε,
+       *   never 0. The gaps near one are larger than the gaps near zero, so if
+       *   1 - ε wasn't 1, then -ε is representable. So if log(1 - mProbability)
+       *   isn't 0, then 1 - mProbability isn't 1, which means that mProbability
+       *   is at least 2**-53, as discussed earlier. This is a sampling
+       *   likelihood of roughly one in ten trillion, which is unlikely to be
+       *   distinguishable from zero in practice.
+       *
+       *   So by forbidding zero, we've tightened our range to (-37, -2**-53].
+       *
+       * - Finally, 1 / log(1 - mProbability) is in [-2**53, -1/37). This all
+       *   falls readily within the range of an IEEE double.
+       *
+       * ALL THAT HAVING BEEN SAID: here are the five lines of actual code:
+       */
+      double logNotProbability = std::log(1 - mProbability);
+      if (logNotProbability == 0.0)
+        mProbability = 0.0;
+      else
+        mInvLogNotProbability = 1 / logNotProbability;
+    }
+
+    chooseSkipCount();
+  }
+
+ private:
+  /* The likelihood that any given call to |trial| should return true. */
+  double mProbability;
+
+  /*
+   * The value of 1/std::log(1 - mProbability), cached for repeated use.
+   *
+   * If mProbability is exactly 0 or exactly 1, we don't use this value.
+   * Otherwise, we guarantee this value is in the range [-2**53, -1/37), i.e.
+   * definitely negative, as required by chooseSkipCount. See setProbability for
+   * the details.
+   */
+  double mInvLogNotProbability;
+
+  /* Our random number generator. */
+  non_crypto::XorShift128PlusRNG mGenerator;
+
+  /* The number of times |trial| should return false before next returning true. */
+  size_t mSkipCount;
+
+  /*
+   * Choose the next skip count. This also returns the value that |trial| should
+   * return, since we have to check for the extreme values for mProbability
+   * anyway, and |trial| should never return true at all when mProbability is 0.
+   */
+  bool chooseSkipCount() {
+    /*
+     * If the probability is 1.0, every call to |trial| returns true. Make sure
+     * mSkipCount is 0.
+     */
+    if (mProbability == 1.0) {
+      mSkipCount = 0;
+      return true;
+    }
+
+    /*
+     * If the probabilility is zero, |trial| never returns true. Don't bother us
+     * for a while.
+     */
+    if (mProbability == 0.0) {
+      mSkipCount = SIZE_MAX;
+      return false;
+    }
+
+    /*
+     * What sorts of values can this call to std::floor produce?
+     *
+     * Since mGenerator.nextDouble returns a value in [0, 1-2**-53], std::log
+     * returns a value in the range [-infinity, -2**-53], all negative. Since
+     * mInvLogNotProbability is negative (see its comments), the product is
+     * positive and possibly infinite. std::floor returns +infinity unchanged.
+     * So the result will always be positive.
+     *
+     * Converting a double to an integer that is out of range for that integer
+     * is undefined behavior, so we must clamp our result to SIZE_MAX, to ensure
+     * we get an acceptable value for mSkipCount.
+     *
+     * The clamp is written carefully. Note that if we had said:
+     *
+     *    if (skipCount > SIZE_MAX)
+     *       skipCount = SIZE_MAX;
+     *
+     * that leads to undefined behavior 64-bit machines: SIZE_MAX coerced to
+     * double is 2^64, not 2^64-1, so this doesn't actually set skipCount to a
+     * value that can be safely assigned to mSkipCount.
+     *
+     * Jakub Oleson cleverly suggested flipping the sense of the comparison: if
+     * we require that skipCount < SIZE_MAX, then because of the gaps (2048)
+     * between doubles at that magnitude, the highest double less than 2^64 is
+     * 2^64 - 2048, which is fine to store in a size_t.
+     *
+     * (On 32-bit machines, all size_t values can be represented exactly in
+     * double, so all is well.)
+     */
+    double skipCount = std::floor(std::log(mGenerator.nextDouble())
+                                  * mInvLogNotProbability);
+    if (skipCount < SIZE_MAX)
+      mSkipCount = skipCount;
+    else
+      mSkipCount = SIZE_MAX;
+
+    return true;
+  }
+};
+
+}  /* namespace mozilla */
+
+#endif /* mozilla_FastBernoulliTrial_h */
diff --git a/src/third_party/mozjs-45/mfbt/FloatingPoint.cpp b/src/third_party/mozjs-45/mfbt/FloatingPoint.cpp
new file mode 100644
index 0000000..1ccae46
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/FloatingPoint.cpp
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implementations of FloatingPoint functions */
+
+#include "mozilla/FloatingPoint.h"
+
+namespace mozilla {
+
+bool
+IsFloat32Representable(double aFloat32)
+{
+  float asFloat = static_cast<float>(aFloat32);
+  double floatAsDouble = static_cast<double>(asFloat);
+  return floatAsDouble == aFloat32;
+}
+
+} /* namespace mozilla */
diff --git a/src/third_party/mozjs-45/mfbt/FloatingPoint.h b/src/third_party/mozjs-45/mfbt/FloatingPoint.h
new file mode 100644
index 0000000..2793638
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/FloatingPoint.h
@@ -0,0 +1,430 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Various predicates and operations on IEEE-754 floating point types. */
+
+#ifndef mozilla_FloatingPoint_h
+#define mozilla_FloatingPoint_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Casting.h"
+#include "mozilla/MathAlgorithms.h"
+#include "mozilla/Types.h"
+
+#include <stdint.h>
+
+namespace mozilla {
+
+/*
+ * It's reasonable to ask why we have this header at all.  Don't isnan,
+ * copysign, the built-in comparison operators, and the like solve these
+ * problems?  Unfortunately, they don't.  We've found that various compilers
+ * (MSVC, MSVC when compiling with PGO, and GCC on OS X, at least) miscompile
+ * the standard methods in various situations, so we can't use them.  Some of
+ * these compilers even have problems compiling seemingly reasonable bitwise
+ * algorithms!  But with some care we've found algorithms that seem to not
+ * trigger those compiler bugs.
+ *
+ * For the aforementioned reasons, be very wary of making changes to any of
+ * these algorithms.  If you must make changes, keep a careful eye out for
+ * compiler bustage, particularly PGO-specific bustage.
+ */
+
+struct FloatTypeTraits
+{
+  typedef uint32_t Bits;
+
+  static const unsigned kExponentBias = 127;
+  static const unsigned kExponentShift = 23;
+
+  static const Bits kSignBit         = 0x80000000UL;
+  static const Bits kExponentBits    = 0x7F800000UL;
+  static const Bits kSignificandBits = 0x007FFFFFUL;
+};
+
+struct DoubleTypeTraits
+{
+  typedef uint64_t Bits;
+
+  static const unsigned kExponentBias = 1023;
+  static const unsigned kExponentShift = 52;
+
+  static const Bits kSignBit         = 0x8000000000000000ULL;
+  static const Bits kExponentBits    = 0x7ff0000000000000ULL;
+  static const Bits kSignificandBits = 0x000fffffffffffffULL;
+};
+
+template<typename T> struct SelectTrait;
+template<> struct SelectTrait<float> : public FloatTypeTraits {};
+template<> struct SelectTrait<double> : public DoubleTypeTraits {};
+
+/*
+ *  This struct contains details regarding the encoding of floating-point
+ *  numbers that can be useful for direct bit manipulation. As of now, the
+ *  template parameter has to be float or double.
+ *
+ *  The nested typedef |Bits| is the unsigned integral type with the same size
+ *  as T: uint32_t for float and uint64_t for double (static assertions
+ *  double-check these assumptions).
+ *
+ *  kExponentBias is the offset that is subtracted from the exponent when
+ *  computing the value, i.e. one plus the opposite of the mininum possible
+ *  exponent.
+ *  kExponentShift is the shift that one needs to apply to retrieve the
+ *  exponent component of the value.
+ *
+ *  kSignBit contains a bits mask. Bit-and-ing with this mask will result in
+ *  obtaining the sign bit.
+ *  kExponentBits contains the mask needed for obtaining the exponent bits and
+ *  kSignificandBits contains the mask needed for obtaining the significand
+ *  bits.
+ *
+ *  Full details of how floating point number formats are encoded are beyond
+ *  the scope of this comment. For more information, see
+ *  http://en.wikipedia.org/wiki/IEEE_floating_point
+ *  http://en.wikipedia.org/wiki/Floating_point#IEEE_754:_floating_point_in_modern_computers
+ */
+template<typename T>
+struct FloatingPoint : public SelectTrait<T>
+{
+  typedef SelectTrait<T> Base;
+  typedef typename Base::Bits Bits;
+
+  static_assert((Base::kSignBit & Base::kExponentBits) == 0,
+                "sign bit shouldn't overlap exponent bits");
+  static_assert((Base::kSignBit & Base::kSignificandBits) == 0,
+                "sign bit shouldn't overlap significand bits");
+  static_assert((Base::kExponentBits & Base::kSignificandBits) == 0,
+                "exponent bits shouldn't overlap significand bits");
+
+  static_assert((Base::kSignBit | Base::kExponentBits | Base::kSignificandBits) ==
+                ~Bits(0),
+                "all bits accounted for");
+
+  /*
+   * These implementations assume float/double are 32/64-bit single/double
+   * format number types compatible with the IEEE-754 standard.  C++ don't
+   * require this to be the case.  But we required this in implementations of
+   * these algorithms that preceded this header, so we shouldn't break anything
+   * if we keep doing so.
+   */
+  static_assert(sizeof(T) == sizeof(Bits), "Bits must be same size as T");
+};
+
+/** Determines whether a float/double is NaN. */
+template<typename T>
+static MOZ_ALWAYS_INLINE MOZ_CONSTEXPR bool
+IsNaN(T aValue)
+{
+  /*
+   * A float/double is NaN if all exponent bits are 1 and the significand
+   * contains at least one non-zero bit.
+   */
+  typedef FloatingPoint<T> Traits;
+  typedef typename Traits::Bits Bits;
+  return (BitwiseCast<Bits>(aValue) & Traits::kExponentBits) == Traits::kExponentBits &&
+         (BitwiseCast<Bits>(aValue) & Traits::kSignificandBits) != 0;
+}
+
+/** Determines whether a float/double is +Infinity or -Infinity. */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+IsInfinite(T aValue)
+{
+  /* Infinities have all exponent bits set to 1 and an all-0 significand. */
+  typedef FloatingPoint<T> Traits;
+  typedef typename Traits::Bits Bits;
+  Bits bits = BitwiseCast<Bits>(aValue);
+  return (bits & ~Traits::kSignBit) == Traits::kExponentBits;
+}
+
+/** Determines whether a float/double is not NaN or infinite. */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+IsFinite(T aValue)
+{
+  /*
+   * NaN and Infinities are the only non-finite floats/doubles, and both have
+   * all exponent bits set to 1.
+   */
+  typedef FloatingPoint<T> Traits;
+  typedef typename Traits::Bits Bits;
+  Bits bits = BitwiseCast<Bits>(aValue);
+  return (bits & Traits::kExponentBits) != Traits::kExponentBits;
+}
+
+/**
+ * Determines whether a float/double is negative or -0.  It is an error
+ * to call this method on a float/double which is NaN.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+IsNegative(T aValue)
+{
+  MOZ_ASSERT(!IsNaN(aValue), "NaN does not have a sign");
+
+  /* The sign bit is set if the double is negative. */
+  typedef FloatingPoint<T> Traits;
+  typedef typename Traits::Bits Bits;
+  Bits bits = BitwiseCast<Bits>(aValue);
+  return (bits & Traits::kSignBit) != 0;
+}
+
+/** Determines whether a float/double represents -0. */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+IsNegativeZero(T aValue)
+{
+  /* Only the sign bit is set if the value is -0. */
+  typedef FloatingPoint<T> Traits;
+  typedef typename Traits::Bits Bits;
+  Bits bits = BitwiseCast<Bits>(aValue);
+  return bits == Traits::kSignBit;
+}
+
+/**
+ * Returns 0 if a float/double is NaN or infinite;
+ * otherwise, the float/double is returned.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE T
+ToZeroIfNonfinite(T aValue)
+{
+  return IsFinite(aValue) ? aValue : 0;
+}
+
+/**
+ * Returns the exponent portion of the float/double.
+ *
+ * Zero is not special-cased, so ExponentComponent(0.0) is
+ * -int_fast16_t(Traits::kExponentBias).
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE int_fast16_t
+ExponentComponent(T aValue)
+{
+  /*
+   * The exponent component of a float/double is an unsigned number, biased
+   * from its actual value.  Subtract the bias to retrieve the actual exponent.
+   */
+  typedef FloatingPoint<T> Traits;
+  typedef typename Traits::Bits Bits;
+  Bits bits = BitwiseCast<Bits>(aValue);
+  return int_fast16_t((bits & Traits::kExponentBits) >> Traits::kExponentShift) -
+         int_fast16_t(Traits::kExponentBias);
+}
+
+/** Returns +Infinity. */
+template<typename T>
+static MOZ_ALWAYS_INLINE T
+PositiveInfinity()
+{
+  /*
+   * Positive infinity has all exponent bits set, sign bit set to 0, and no
+   * significand.
+   */
+  typedef FloatingPoint<T> Traits;
+  return BitwiseCast<T>(Traits::kExponentBits);
+}
+
+/** Returns -Infinity. */
+template<typename T>
+static MOZ_ALWAYS_INLINE T
+NegativeInfinity()
+{
+  /*
+   * Negative infinity has all exponent bits set, sign bit set to 1, and no
+   * significand.
+   */
+  typedef FloatingPoint<T> Traits;
+  return BitwiseCast<T>(Traits::kSignBit | Traits::kExponentBits);
+}
+
+
+/** Constructs a NaN value with the specified sign bit and significand bits. */
+template<typename T>
+static MOZ_ALWAYS_INLINE T
+SpecificNaN(int signbit, typename FloatingPoint<T>::Bits significand)
+{
+  typedef FloatingPoint<T> Traits;
+  MOZ_ASSERT(signbit == 0 || signbit == 1);
+  MOZ_ASSERT((significand & ~Traits::kSignificandBits) == 0);
+  MOZ_ASSERT(significand & Traits::kSignificandBits);
+
+  T t = BitwiseCast<T>((signbit ? Traits::kSignBit : 0) |
+                       Traits::kExponentBits |
+                       significand);
+  MOZ_ASSERT(IsNaN(t));
+  return t;
+}
+
+/** Computes the smallest non-zero positive float/double value. */
+template<typename T>
+static MOZ_ALWAYS_INLINE T
+MinNumberValue()
+{
+  typedef FloatingPoint<T> Traits;
+  typedef typename Traits::Bits Bits;
+  return BitwiseCast<T>(Bits(1));
+}
+
+/**
+ * If aValue is equal to some int32_t value, set *aInt32 to that value and
+ * return true; otherwise return false.
+ *
+ * Note that negative zero is "equal" to zero here. To test whether a value can
+ * be losslessly converted to int32_t and back, use NumberIsInt32 instead.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+NumberEqualsInt32(T aValue, int32_t* aInt32)
+{
+  /*
+   * XXX Casting a floating-point value that doesn't truncate to int32_t, to
+   *     int32_t, induces undefined behavior.  We should definitely fix this
+   *     (bug 744965), but as apparently it "works" in practice, it's not a
+   *     pressing concern now.
+   */
+  return aValue == (*aInt32 = int32_t(aValue));
+}
+
+/**
+ * If d can be converted to int32_t and back to an identical double value,
+ * set *aInt32 to that value and return true; otherwise return false.
+ *
+ * The difference between this and NumberEqualsInt32 is that this method returns
+ * false for negative zero.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+NumberIsInt32(T aValue, int32_t* aInt32)
+{
+  return !IsNegativeZero(aValue) && NumberEqualsInt32(aValue, aInt32);
+}
+
+/**
+ * Computes a NaN value.  Do not use this method if you depend upon a particular
+ * NaN value being returned.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE T
+UnspecifiedNaN()
+{
+  /*
+   * If we can use any quiet NaN, we might as well use the all-ones NaN,
+   * since it's cheap to materialize on common platforms (such as x64, where
+   * this value can be represented in a 32-bit signed immediate field, allowing
+   * it to be stored to memory in a single instruction).
+   */
+  typedef FloatingPoint<T> Traits;
+  return SpecificNaN<T>(1, Traits::kSignificandBits);
+}
+
+/**
+ * Compare two doubles for equality, *without* equating -0 to +0, and equating
+ * any NaN value to any other NaN value.  (The normal equality operators equate
+ * -0 with +0, and they equate NaN to no other value.)
+ */
+template<typename T>
+static inline bool
+NumbersAreIdentical(T aValue1, T aValue2)
+{
+  typedef FloatingPoint<T> Traits;
+  typedef typename Traits::Bits Bits;
+  if (IsNaN(aValue1)) {
+    return IsNaN(aValue2);
+  }
+  return BitwiseCast<Bits>(aValue1) == BitwiseCast<Bits>(aValue2);
+}
+
+namespace detail {
+
+template<typename T>
+struct FuzzyEqualsEpsilon;
+
+template<>
+struct FuzzyEqualsEpsilon<float>
+{
+  // A number near 1e-5 that is exactly representable in a float.
+  static float value() { return 1.0f / (1 << 17); }
+};
+
+template<>
+struct FuzzyEqualsEpsilon<double>
+{
+  // A number near 1e-12 that is exactly representable in a double.
+  static double value() { return 1.0 / (1LL << 40); }
+};
+
+} // namespace detail
+
+/**
+ * Compare two floating point values for equality, modulo rounding error. That
+ * is, the two values are considered equal if they are both not NaN and if they
+ * are less than or equal to aEpsilon apart. The default value of aEpsilon is
+ * near 1e-5.
+ *
+ * For most scenarios you will want to use FuzzyEqualsMultiplicative instead,
+ * as it is more reasonable over the entire range of floating point numbers.
+ * This additive version should only be used if you know the range of the
+ * numbers you are dealing with is bounded and stays around the same order of
+ * magnitude.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+FuzzyEqualsAdditive(T aValue1, T aValue2,
+                    T aEpsilon = detail::FuzzyEqualsEpsilon<T>::value())
+{
+  static_assert(IsFloatingPoint<T>::value, "floating point type required");
+  return Abs(aValue1 - aValue2) <= aEpsilon;
+}
+
+/**
+ * Compare two floating point values for equality, allowing for rounding error
+ * relative to the magnitude of the values. That is, the two values are
+ * considered equal if they are both not NaN and they are less than or equal to
+ * some aEpsilon apart, where the aEpsilon is scaled by the smaller of the two
+ * argument values.
+ *
+ * In most cases you will want to use this rather than FuzzyEqualsAdditive, as
+ * this function effectively masks out differences in the bottom few bits of
+ * the floating point numbers being compared, regardless of what order of
+ * magnitude those numbers are at.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+FuzzyEqualsMultiplicative(T aValue1, T aValue2,
+                          T aEpsilon = detail::FuzzyEqualsEpsilon<T>::value())
+{
+  static_assert(IsFloatingPoint<T>::value, "floating point type required");
+
+  // Short-circuit the common case in order to avoid the expensive operations
+  // below.
+  if (aValue1 == aValue2) {
+    return true;
+  }
+
+  // can't use std::min because of bug 965340
+  T smaller = Abs(aValue1) < Abs(aValue2) ? Abs(aValue1) : Abs(aValue2);
+  return Abs(aValue1 - aValue2) <= aEpsilon * smaller;
+}
+
+/**
+ * Returns true if the given value can be losslessly represented as an IEEE-754
+ * single format number, false otherwise.  All NaN values are considered
+ * representable (notwithstanding that the exact bit pattern of a double format
+ * NaN value can't be exactly represented in single format).
+ *
+ * This function isn't inlined to avoid buggy optimizations by MSVC.
+ */
+MOZ_WARN_UNUSED_RESULT
+extern MFBT_API bool
+IsFloat32Representable(double aFloat32);
+
+} /* namespace mozilla */
+
+#endif /* mozilla_FloatingPoint_h */
diff --git a/src/third_party/mozjs-45/mfbt/Function.h b/src/third_party/mozjs-45/mfbt/Function.h
new file mode 100644
index 0000000..1cc3a56
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Function.h
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A type-erased callable wrapper. */
+
+#ifndef mozilla_Function_h
+#define mozilla_Function_h
+
+#include "mozilla/Attributes.h"  // for MOZ_IMPLICIT
+#include "mozilla/Move.h"
+#include "mozilla/UniquePtr.h"
+
+// |Function<Signature>| is a wrapper that can hold any type of callable
+// object that can be invoked in a way that's compatible with |Signature|.
+// The standard "type erasure" technique is used to avoid the type of the
+// wrapper depending on the concrete type of the wrapped callable.
+//
+// Supported callable types include non-member functions, static member
+// functions, and function objects (that is to say, objects with an overloaded
+// call operator; this includes C++11 lambdas). Member functions aren't
+// directly supported; they first need to be wrapped into a function object
+// using |std::mem_fn()| or an equivalent.
+//
+// |Signature| is a type of the form |ReturnType(Arguments...)|. Syntactically,
+// this is a function type; it's not used in any way other than serving as a
+// vehicle to encode the return and argument types into a single type.
+//
+// |Function| is default-constructible. A default-constructed instance is
+// considered "empty". Invoking an empty instance is undefined behaviour.
+// An empty instance can be populated with a callable by assigning to it.
+//
+// This class is intended to provide functionality similar to the C++11
+// standard library class |std::function|.
+
+namespace mozilla {
+
+namespace detail {
+
+template<typename ReturnType, typename... Arguments>
+class FunctionImplBase
+{
+public:
+  virtual ~FunctionImplBase() {}
+  virtual ReturnType call(Arguments... aArguments) = 0;
+};
+
+// Normal Callable Object.
+template <typename Callable, typename ReturnType, typename... Arguments>
+class FunctionImpl : public FunctionImplBase<ReturnType, Arguments...>
+{
+  public:
+    explicit FunctionImpl(const Callable& aCallable)
+      : mCallable(aCallable) {}
+
+    ReturnType call(Arguments... aArguments) override
+    {
+      return mCallable(Forward<Arguments>(aArguments)...);
+    }
+  private:
+    Callable mCallable;
+};
+
+// Base class for passing pointer to member function.
+template <typename Callable, typename ReturnType, typename... Arguments>
+class MemberFunctionImplBase : public FunctionImplBase<ReturnType, Arguments...>
+{
+public:
+  explicit MemberFunctionImplBase(const Callable& aCallable)
+    : mCallable(aCallable) {}
+
+  ReturnType call(Arguments... aArguments) override
+  {
+    return callInternal(Forward<Arguments>(aArguments)...);
+  }
+private:
+  template<typename ThisType, typename... Args>
+  ReturnType callInternal(ThisType* aThis, Args&&... aArguments)
+  {
+    return (aThis->*mCallable)(Forward<Args>(aArguments)...);
+  }
+
+  template<typename ThisType, typename... Args>
+  ReturnType callInternal(ThisType&& aThis, Args&&... aArguments)
+  {
+    return (aThis.*mCallable)(Forward<Args>(aArguments)...);
+  }
+  Callable mCallable;
+};
+
+// For non-const member function specialization of FunctionImpl.
+template <typename ThisType, typename... Args, typename ReturnType, typename... Arguments>
+class FunctionImpl<ReturnType(ThisType::*)(Args...),
+                   ReturnType, Arguments...>
+  : public MemberFunctionImplBase<ReturnType(ThisType::*)(Args...),
+                                  ReturnType, Arguments...>
+{
+public:
+  explicit FunctionImpl(ReturnType(ThisType::*aMemberFunc)(Args...))
+    : MemberFunctionImplBase<ReturnType(ThisType::*)(Args...),
+                             ReturnType, Arguments...>(aMemberFunc)
+  {}
+};
+
+// For const member function specialization of FunctionImpl.
+template <typename ThisType, typename... Args, typename ReturnType, typename... Arguments>
+class FunctionImpl<ReturnType(ThisType::*)(Args...) const,
+                   ReturnType, Arguments...>
+  : public MemberFunctionImplBase<ReturnType(ThisType::*)(Args...) const,
+                                  ReturnType, Arguments...>
+{
+public:
+  explicit FunctionImpl(ReturnType(ThisType::*aConstMemberFunc)(Args...) const)
+    : MemberFunctionImplBase<ReturnType(ThisType::*)(Args...) const,
+                             ReturnType, Arguments...>(aConstMemberFunc)
+  {}
+};
+
+} // namespace detail
+
+// The primary template is never defined. As |Signature| is required to be
+// of the form |ReturnType(Arguments...)|, we only define a partial
+// specialization that matches this form. This allows us to use |ReturnType|
+// and |Arguments| in the definition of the specialization without having to
+// introspect |Signature|.
+template<typename Signature>
+class Function;
+
+template<typename ReturnType, typename... Arguments>
+class Function<ReturnType(Arguments...)>
+{
+public:
+  Function() {}
+
+  // This constructor is implicit to match the interface of |std::function|.
+  template <typename Callable>
+  MOZ_IMPLICIT Function(const Callable& aCallable)
+    : mImpl(MakeUnique<detail::FunctionImpl<Callable, ReturnType, Arguments...>>(aCallable))
+  {}
+
+  // Move constructor and move assingment operator.
+  // These should be generated automatically, but MSVC doesn't do that yet.
+  Function(Function&& aOther) : mImpl(Move(aOther.mImpl)) {}
+  Function& operator=(Function&& aOther) {
+    mImpl = Move(aOther.mImpl);
+    return *this;
+  }
+
+  template <typename Callable>
+  Function& operator=(const Callable& aCallable)
+  {
+    mImpl = MakeUnique<detail::FunctionImpl<Callable, ReturnType, Arguments...>>(aCallable);
+    return *this;
+  }
+
+  template<typename... Args>
+  ReturnType operator()(Args&&... aArguments) const
+  {
+    MOZ_ASSERT(mImpl);
+    return mImpl->call(Forward<Args>(aArguments)...);
+  }
+private:
+  // TODO: Consider implementing a small object optimization.
+  UniquePtr<detail::FunctionImplBase<ReturnType, Arguments...>> mImpl;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_Function_h */
diff --git a/src/third_party/mozjs-45/mfbt/GuardObjects.h b/src/third_party/mozjs-45/mfbt/GuardObjects.h
new file mode 100644
index 0000000..9440c71
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/GuardObjects.h
@@ -0,0 +1,167 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implementation of macros to ensure correct use of RAII Auto* objects. */
+
+#ifndef mozilla_GuardObjects_h
+#define mozilla_GuardObjects_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Move.h"
+#include "mozilla/Types.h"
+
+#ifdef __cplusplus
+
+#ifdef DEBUG
+
+/**
+ * A custom define is used rather than |mozPoisonValue()| due to cascading
+ * build failures relating to how mfbt is linked on different operating
+ * systems. See bug 1160253.
+ */
+#define MOZ_POISON uintptr_t(-1)
+
+namespace mozilla {
+namespace detail {
+
+/*
+ * The following classes are designed to cause assertions to detect
+ * inadvertent use of guard objects as temporaries. In other words,
+ * when we have a guard object whose only purpose is its constructor and
+ * destructor (and is never otherwise referenced), the intended use
+ * might be:
+ *
+ *   AutoRestore savePainting(mIsPainting);
+ *
+ * but is is easy to accidentally write:
+ *
+ *   AutoRestore(mIsPainting);
+ *
+ * which compiles just fine, but runs the destructor well before the
+ * intended time.
+ *
+ * They work by adding (#ifdef DEBUG) an additional parameter to the
+ * guard object's constructor, with a default value, so that users of
+ * the guard object's API do not need to do anything. The default value
+ * of this parameter is a temporary object. C++ (ISO/IEC 14882:1998),
+ * section 12.2 [class.temporary], clauses 4 and 5 seem to assume a
+ * guarantee that temporaries are destroyed in the reverse of their
+ * construction order, but I actually can't find a statement that that
+ * is true in the general case (beyond the two specific cases mentioned
+ * there). However, it seems to be true.
+ *
+ * These classes are intended to be used only via the macros immediately
+ * below them:
+ *
+ *   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER declares (ifdef DEBUG) a member
+ *     variable, and should be put where a declaration of a private
+ *     member variable would be placed.
+ *   MOZ_GUARD_OBJECT_NOTIFIER_PARAM should be placed at the end of the
+ *     parameters to each constructor of the guard object; it declares
+ *     (ifdef DEBUG) an additional parameter. (But use the *_ONLY_PARAM
+ *     variant for constructors that take no other parameters.)
+ *   MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL should likewise be used in
+ *     the implementation of such constructors when they are not inline.
+ *   MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT should be used in
+ *     the implementation of such constructors to pass the parameter to
+ *     a base class that also uses these macros
+ *   MOZ_GUARD_OBJECT_NOTIFIER_INIT is a statement that belongs in each
+ *     constructor. It uses the parameter declared by
+ *     MOZ_GUARD_OBJECT_NOTIFIER_PARAM.
+ *
+ * For more details, and examples of using these macros, see
+ * https://developer.mozilla.org/en/Using_RAII_classes_in_Mozilla
+ */
+class GuardObjectNotifier
+{
+private:
+  bool* mStatementDone;
+
+public:
+  GuardObjectNotifier()
+    : mStatementDone(reinterpret_cast<bool*>(MOZ_POISON))
+  {
+  }
+
+  ~GuardObjectNotifier()
+  {
+    // Assert that the GuardObjectNotifier has been properly initialized by
+    // using the |MOZ_GUARD_OBJECT_NOTIFIER_INIT| macro. A poison value is
+    // used rather than a null check to appease static analyzers that were
+    // (incorrectly) detecting null pointer dereferences.
+    MOZ_ASSERT(mStatementDone != reinterpret_cast<bool*>(MOZ_POISON));
+    *mStatementDone = true;
+  }
+
+  void setStatementDone(bool* aStatementIsDone)
+  {
+    mStatementDone = aStatementIsDone;
+  }
+};
+
+class GuardObjectNotificationReceiver
+{
+private:
+  bool mStatementDone;
+
+public:
+  GuardObjectNotificationReceiver() : mStatementDone(false) { }
+
+  ~GuardObjectNotificationReceiver() {
+    /*
+     * Assert that the guard object was not used as a temporary.  (Note that
+     * this assert might also fire if init is not called because the guard
+     * object's implementation is not using the above macros correctly.)
+     */
+    MOZ_ASSERT(mStatementDone);
+  }
+
+  void init(GuardObjectNotifier& aNotifier)
+  {
+    aNotifier.setStatementDone(&mStatementDone);
+  }
+};
+
+} /* namespace detail */
+} /* namespace mozilla */
+
+#undef MOZ_POISON
+
+#endif /* DEBUG */
+
+#ifdef DEBUG
+#  define MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER \
+     mozilla::detail::GuardObjectNotificationReceiver _mCheckNotUsedAsTemporary;
+#  define MOZ_GUARD_OBJECT_NOTIFIER_PARAM \
+     , mozilla::detail::GuardObjectNotifier&& _notifier = \
+         mozilla::detail::GuardObjectNotifier()
+#  define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM \
+     mozilla::detail::GuardObjectNotifier&& _notifier = \
+         mozilla::detail::GuardObjectNotifier()
+#  define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL \
+     , mozilla::detail::GuardObjectNotifier&& _notifier
+#  define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL \
+     mozilla::detail::GuardObjectNotifier&& _notifier
+#  define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT \
+     , mozilla::Move(_notifier)
+#  define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT \
+       mozilla::Move(_notifier)
+#  define MOZ_GUARD_OBJECT_NOTIFIER_INIT \
+     do { _mCheckNotUsedAsTemporary.init(_notifier); } while (0)
+#else
+#  define MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+#  define MOZ_GUARD_OBJECT_NOTIFIER_PARAM
+#  define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM
+#  define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL
+#  define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL
+#  define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT
+#  define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT
+#  define MOZ_GUARD_OBJECT_NOTIFIER_INIT do { } while (0)
+#endif
+
+#endif /* __cplusplus */
+
+#endif /* mozilla_GuardObjects_h */
diff --git a/src/third_party/mozjs-45/mfbt/HashFunctions.cpp b/src/third_party/mozjs-45/mfbt/HashFunctions.cpp
new file mode 100644
index 0000000..3273e17
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/HashFunctions.cpp
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implementations of hash functions. */
+
+#include "mozilla/HashFunctions.h"
+#include "mozilla/Types.h"
+
+#include <string.h>
+
+namespace mozilla {
+
+uint32_t
+HashBytes(const void* aBytes, size_t aLength)
+{
+  uint32_t hash = 0;
+  const char* b = reinterpret_cast<const char*>(aBytes);
+
+  /* Walk word by word. */
+  size_t i = 0;
+  for (; i < aLength - (aLength % sizeof(size_t)); i += sizeof(size_t)) {
+    /* Do an explicitly unaligned load of the data. */
+    size_t data;
+    memcpy(&data, b + i, sizeof(size_t));
+
+    hash = AddToHash(hash, data, sizeof(data));
+  }
+
+  /* Get the remaining bytes. */
+  for (; i < aLength; i++) {
+    hash = AddToHash(hash, b[i]);
+  }
+  return hash;
+}
+
+} /* namespace mozilla */
diff --git a/src/third_party/mozjs-45/mfbt/HashFunctions.h b/src/third_party/mozjs-45/mfbt/HashFunctions.h
new file mode 100644
index 0000000..f490a28
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/HashFunctions.h
@@ -0,0 +1,318 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Utilities for hashing. */
+
+/*
+ * This file exports functions for hashing data down to a 32-bit value,
+ * including:
+ *
+ *  - HashString    Hash a char* or uint16_t/wchar_t* of known or unknown
+ *                  length.
+ *
+ *  - HashBytes     Hash a byte array of known length.
+ *
+ *  - HashGeneric   Hash one or more values.  Currently, we support uint32_t,
+ *                  types which can be implicitly cast to uint32_t, data
+ *                  pointers, and function pointers.
+ *
+ *  - AddToHash     Add one or more values to the given hash.  This supports the
+ *                  same list of types as HashGeneric.
+ *
+ *
+ * You can chain these functions together to hash complex objects.  For example:
+ *
+ *  class ComplexObject
+ *  {
+ *    char* mStr;
+ *    uint32_t mUint1, mUint2;
+ *    void (*mCallbackFn)();
+ *
+ *  public:
+ *    uint32_t hash()
+ *    {
+ *      uint32_t hash = HashString(mStr);
+ *      hash = AddToHash(hash, mUint1, mUint2);
+ *      return AddToHash(hash, mCallbackFn);
+ *    }
+ *  };
+ *
+ * If you want to hash an nsAString or nsACString, use the HashString functions
+ * in nsHashKeys.h.
+ */
+
+#ifndef mozilla_HashFunctions_h
+#define mozilla_HashFunctions_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Char16.h"
+#include "mozilla/Types.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+namespace mozilla {
+
+/**
+ * The golden ratio as a 32-bit fixed-point value.
+ */
+static const uint32_t kGoldenRatioU32 = 0x9E3779B9U;
+
+inline uint32_t
+RotateBitsLeft32(uint32_t aValue, uint8_t aBits)
+{
+  MOZ_ASSERT(aBits < 32);
+  return (aValue << aBits) | (aValue >> (32 - aBits));
+}
+
+namespace detail {
+
+inline uint32_t
+AddU32ToHash(uint32_t aHash, uint32_t aValue)
+{
+  /*
+   * This is the meat of all our hash routines.  This hash function is not
+   * particularly sophisticated, but it seems to work well for our mostly
+   * plain-text inputs.  Implementation notes follow.
+   *
+   * Our use of the golden ratio here is arbitrary; we could pick almost any
+   * number which:
+   *
+   *  * is odd (because otherwise, all our hash values will be even)
+   *
+   *  * has a reasonably-even mix of 1's and 0's (consider the extreme case
+   *    where we multiply by 0x3 or 0xeffffff -- this will not produce good
+   *    mixing across all bits of the hash).
+   *
+   * The rotation length of 5 is also arbitrary, although an odd number is again
+   * preferable so our hash explores the whole universe of possible rotations.
+   *
+   * Finally, we multiply by the golden ratio *after* xor'ing, not before.
+   * Otherwise, if |aHash| is 0 (as it often is for the beginning of a
+   * message), the expression
+   *
+   *   (kGoldenRatioU32 * RotateBitsLeft(aHash, 5)) |xor| aValue
+   *
+   * evaluates to |aValue|.
+   *
+   * (Number-theoretic aside: Because any odd number |m| is relatively prime to
+   * our modulus (2^32), the list
+   *
+   *    [x * m (mod 2^32) for 0 <= x < 2^32]
+   *
+   * has no duplicate elements.  This means that multiplying by |m| does not
+   * cause us to skip any possible hash values.
+   *
+   * It's also nice if |m| has large-ish order mod 2^32 -- that is, if the
+   * smallest k such that m^k == 1 (mod 2^32) is large -- so we can safely
+   * multiply our hash value by |m| a few times without negating the
+   * multiplicative effect.  Our golden ratio constant has order 2^29, which is
+   * more than enough for our purposes.)
+   */
+  return kGoldenRatioU32 * (RotateBitsLeft32(aHash, 5) ^ aValue);
+}
+
+/**
+ * AddUintptrToHash takes sizeof(uintptr_t) as a template parameter.
+ */
+template<size_t PtrSize>
+inline uint32_t
+AddUintptrToHash(uint32_t aHash, uintptr_t aValue);
+
+template<>
+inline uint32_t
+AddUintptrToHash<4>(uint32_t aHash, uintptr_t aValue)
+{
+  return AddU32ToHash(aHash, static_cast<uint32_t>(aValue));
+}
+
+template<>
+inline uint32_t
+AddUintptrToHash<8>(uint32_t aHash, uintptr_t aValue)
+{
+  /*
+   * The static cast to uint64_t below is necessary because this function
+   * sometimes gets compiled on 32-bit platforms (yes, even though it's a
+   * template and we never call this particular override in a 32-bit build).  If
+   * we do aValue >> 32 on a 32-bit machine, we're shifting a 32-bit uintptr_t
+   * right 32 bits, and the compiler throws an error.
+   */
+  uint32_t v1 = static_cast<uint32_t>(aValue);
+  uint32_t v2 = static_cast<uint32_t>(static_cast<uint64_t>(aValue) >> 32);
+  return AddU32ToHash(AddU32ToHash(aHash, v1), v2);
+}
+
+} /* namespace detail */
+
+/**
+ * AddToHash takes a hash and some values and returns a new hash based on the
+ * inputs.
+ *
+ * Currently, we support hashing uint32_t's, values which we can implicitly
+ * convert to uint32_t, data pointers, and function pointers.
+ */
+template<typename A>
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+AddToHash(uint32_t aHash, A aA)
+{
+  /*
+   * Try to convert |A| to uint32_t implicitly.  If this works, great.  If not,
+   * we'll error out.
+   */
+  return detail::AddU32ToHash(aHash, aA);
+}
+
+template<typename A>
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+AddToHash(uint32_t aHash, A* aA)
+{
+  /*
+   * You might think this function should just take a void*.  But then we'd only
+   * catch data pointers and couldn't handle function pointers.
+   */
+
+  static_assert(sizeof(aA) == sizeof(uintptr_t), "Strange pointer!");
+
+  return detail::AddUintptrToHash<sizeof(uintptr_t)>(aHash, uintptr_t(aA));
+}
+
+template<>
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+AddToHash(uint32_t aHash, uintptr_t aA)
+{
+  return detail::AddUintptrToHash<sizeof(uintptr_t)>(aHash, aA);
+}
+
+template<typename A, typename... Args>
+MOZ_WARN_UNUSED_RESULT uint32_t
+AddToHash(uint32_t aHash, A aArg, Args... aArgs)
+{
+  return AddToHash(AddToHash(aHash, aArg), aArgs...);
+}
+
+/**
+ * The HashGeneric class of functions let you hash one or more values.
+ *
+ * If you want to hash together two values x and y, calling HashGeneric(x, y) is
+ * much better than calling AddToHash(x, y), because AddToHash(x, y) assumes
+ * that x has already been hashed.
+ */
+template<typename... Args>
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashGeneric(Args... aArgs)
+{
+  return AddToHash(0, aArgs...);
+}
+
+namespace detail {
+
+template<typename T>
+uint32_t
+HashUntilZero(const T* aStr)
+{
+  uint32_t hash = 0;
+  for (T c; (c = *aStr); aStr++) {
+    hash = AddToHash(hash, c);
+  }
+  return hash;
+}
+
+template<typename T>
+uint32_t
+HashKnownLength(const T* aStr, size_t aLength)
+{
+  uint32_t hash = 0;
+  for (size_t i = 0; i < aLength; i++) {
+    hash = AddToHash(hash, aStr[i]);
+  }
+  return hash;
+}
+
+} /* namespace detail */
+
+/**
+ * The HashString overloads below do just what you'd expect.
+ *
+ * If you have the string's length, you might as well call the overload which
+ * includes the length.  It may be marginally faster.
+ */
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashString(const char* aStr)
+{
+  return detail::HashUntilZero(reinterpret_cast<const unsigned char*>(aStr));
+}
+
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashString(const char* aStr, size_t aLength)
+{
+  return detail::HashKnownLength(reinterpret_cast<const unsigned char*>(aStr), aLength);
+}
+
+MOZ_WARN_UNUSED_RESULT
+inline uint32_t
+HashString(const unsigned char* aStr, size_t aLength)
+{
+  return detail::HashKnownLength(aStr, aLength);
+}
+
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashString(const uint16_t* aStr)
+{
+  return detail::HashUntilZero(aStr);
+}
+
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashString(const uint16_t* aStr, size_t aLength)
+{
+  return detail::HashKnownLength(aStr, aLength);
+}
+
+#ifdef MOZ_CHAR16_IS_NOT_WCHAR
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashString(const char16_t* aStr)
+{
+  return detail::HashUntilZero(aStr);
+}
+
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashString(const char16_t* aStr, size_t aLength)
+{
+  return detail::HashKnownLength(aStr, aLength);
+}
+#endif
+
+/*
+ * On Windows, wchar_t (char16_t) is not the same as uint16_t, even though it's
+ * the same width!
+ */
+#ifdef WIN32
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashString(const wchar_t* aStr)
+{
+  return detail::HashUntilZero(aStr);
+}
+
+MOZ_WARN_UNUSED_RESULT inline uint32_t
+HashString(const wchar_t* aStr, size_t aLength)
+{
+  return detail::HashKnownLength(aStr, aLength);
+}
+#endif
+
+/**
+ * Hash some number of bytes.
+ *
+ * This hash walks word-by-word, rather than byte-by-byte, so you won't get the
+ * same result out of HashBytes as you would out of HashString.
+ */
+MOZ_WARN_UNUSED_RESULT extern MFBT_API uint32_t
+HashBytes(const void* bytes, size_t aLength);
+
+} /* namespace mozilla */
+#endif /* __cplusplus */
+
+#endif /* mozilla_HashFunctions_h */
diff --git a/src/third_party/mozjs-45/mfbt/IndexSequence.h b/src/third_party/mozjs-45/mfbt/IndexSequence.h
new file mode 100644
index 0000000..b6e00d9
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/IndexSequence.h
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A utility for expanding a tuple into a variadic argument list.
+ * Based on std::index_sequence. */
+
+/**
+ * Example usage:
+ *
+ * Problem:
+ *
+ *   You have a variadic function Foo:
+ *
+ *     template <typename... Args> void Foo(Args...);
+ *
+ *   And a variadic function Bar, which contains a tuple:
+ *
+ *     template <typename... Args>
+ *     void Bar() {
+ *       // ...
+ *       Tuple<Args...> t;
+ *     }
+ *
+ *   And inside Bar, you want to call Foo with the elements of the tuple as
+ *   arguments to Foo.
+ *
+ *   You want to write:
+ *
+ *     Foo(Get<0>(t), Get<1>(t), ..., Get<N>(t))
+ *
+ *   but you can't literally write that, because N is different for different
+ *   instantiations of Bar.
+ *
+ * Solution:
+ *
+ *   Write a helper function which takes the tuple, and an index sequence
+ *   containing indices corresponding to the tuple indices.
+ *
+ *     template <typename... Args, size_t... Indices>
+ *     void Helper(const Tuple<Args...>& t, IndexSequence<Indices>)
+ *     {
+ *       Foo(Get<Indices>(t)...);
+ *     }
+ *
+ *   Assuming 'Indices...' are 0, 1, ..., N - 1, where N is the size of the
+ *   tuple, pack expansion will expand the pack 'Get<Indices>(t)...' to
+ *   'Get<0>(t), Get<1>(t), ..., Get<N>(t)'.
+ *
+ *   Finally, call the helper, creating the index sequence to pass in like so:
+ *
+ *     template <typename... Args>
+ *     void Bar() {
+ *       // ...
+ *       Tuple<Args...> t;
+ *       Helper(t, typename IndexSequenceFor<Args...>::Type());
+ *     }
+ */
+
+#ifndef mozilla_IndexSequence_h
+#define mozilla_IndexSequence_h
+
+#include "mozilla/Attributes.h"
+
+#include <stddef.h>
+
+namespace mozilla {
+
+/**
+ * Represents a compile-time sequence of integer indices.
+ */
+template<size_t... Indices>
+struct IndexSequence
+{
+  static MOZ_CONSTEXPR size_t Size() { return sizeof...(Indices); }
+};
+
+namespace detail {
+
+// Helpers used by MakeIndexSequence.
+
+template<size_t... Indices>
+struct IndexTuple
+{
+  typedef IndexTuple<Indices..., sizeof...(Indices)> Next;
+};
+
+// Builds IndexTuple<0, 1, ..., N - 1>.
+template<size_t N>
+struct BuildIndexTuple
+{
+  typedef typename BuildIndexTuple<N - 1>::Type::Next Type;
+};
+
+template<>
+struct BuildIndexTuple<0>
+{
+  typedef IndexTuple<> Type;
+};
+
+template<size_t N, typename IndexTuple>
+struct MakeIndexSequenceImpl;
+
+template<size_t N, size_t... Indices>
+struct MakeIndexSequenceImpl<N, IndexTuple<Indices...>>
+{
+  typedef IndexSequence<Indices...> Type;
+};
+
+} // namespace detail
+
+/**
+ * A utility for building an IndexSequence of consecutive indices.
+ * MakeIndexSequence<N>::Type evaluates to IndexSequence<0, 1, .., N - 1>.
+ * Note: unlike std::make_index_sequence, this is not an alias template
+ * to work around bugs in MSVC 2013.
+ */
+template<size_t N>
+struct MakeIndexSequence
+{
+  typedef typename detail::MakeIndexSequenceImpl<N,
+    typename detail::BuildIndexTuple<N>::Type>::Type Type;
+};
+
+/**
+ * A utility for building an IndexSequence of consecutive indices
+ * corresponding to a variadic argument list.
+ * IndexSequenceFor<Types...> evaluates to IndexSequence<0, 1, ..., N - 1>
+ * where N is the number of types in Types.
+ * Note: unlike std::index_sequence_for, this is not an alias template
+ * to work around bugs in MSVC 2013.
+ */
+template<typename... Types>
+struct IndexSequenceFor
+{
+  typedef typename MakeIndexSequence<sizeof...(Types)>::Type Type;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_IndexSequence_h */
diff --git a/src/third_party/mozjs-45/mfbt/IntegerPrintfMacros.h b/src/third_party/mozjs-45/mfbt/IntegerPrintfMacros.h
new file mode 100644
index 0000000..c534a0b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/IntegerPrintfMacros.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implements the C99 <inttypes.h> interface. */
+
+#ifndef mozilla_IntegerPrintfMacros_h_
+#define mozilla_IntegerPrintfMacros_h_
+
+/*
+ * These macros should not be used with the NSPR printf-like functions or their
+ * users, e.g. mozilla/Logging.h.  If you need to use NSPR's facilities, see the
+ * comment on supported formats at the top of nsprpub/pr/include/prprf.h.
+ */
+
+/*
+ * scanf is a footgun: if the input number exceeds the bounds of the target
+ * type, behavior is undefined (in the compiler sense: that is, this code
+ * could overwrite your hard drive with zeroes):
+ *
+ *   uint8_t u;
+ *   sscanf("256", "%" SCNu8, &u); // BAD
+ *
+ * For this reason, *never* use the SCN* macros provided by this header!
+ */
+
+#include <inttypes.h>
+
+/*
+ * Fix up Android's broken [u]intptr_t inttype macros. Android's PRI*PTR
+ * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t)
+ * is 4 on 32-bit Android. TestTypeTraits.cpp asserts that these new macro
+ * definitions match the actual type sizes seen at compile time.
+ */
+#if defined(ANDROID) && !defined(__LP64__)
+#  undef  PRIdPTR      /* intptr_t  */
+#  define PRIdPTR "d"  /* intptr_t  */
+#  undef  PRIiPTR      /* intptr_t  */
+#  define PRIiPTR "i"  /* intptr_t  */
+#  undef  PRIoPTR      /* uintptr_t */
+#  define PRIoPTR "o"  /* uintptr_t */
+#  undef  PRIuPTR      /* uintptr_t */
+#  define PRIuPTR "u"  /* uintptr_t */
+#  undef  PRIxPTR      /* uintptr_t */
+#  define PRIxPTR "x"  /* uintptr_t */
+#  undef  PRIXPTR      /* uintptr_t */
+#  define PRIXPTR "X"  /* uintptr_t */
+#endif
+
+#endif  /* mozilla_IntegerPrintfMacros_h_ */
diff --git a/src/third_party/mozjs-45/mfbt/IntegerRange.h b/src/third_party/mozjs-45/mfbt/IntegerRange.h
new file mode 100644
index 0000000..8d5d2e4
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/IntegerRange.h
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Iterator over ranges of integers */
+
+#ifndef mozilla_IntegerRange_h
+#define mozilla_IntegerRange_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/ReverseIterator.h"
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+namespace detail {
+
+template<typename IntTypeT>
+class IntegerIterator
+{
+public:
+  template<typename IntType>
+  explicit IntegerIterator(IntType aCurrent)
+    : mCurrent(aCurrent) { }
+
+  template<typename IntType>
+  explicit IntegerIterator(const IntegerIterator<IntType>& aOther)
+    : mCurrent(aOther.mCurrent) { }
+
+  IntTypeT operator*() const { return mCurrent; }
+
+  /* Increment and decrement operators */
+
+  IntegerIterator& operator++() { ++mCurrent; return *this; }
+  IntegerIterator& operator--() { --mCurrent; return *this; }
+  IntegerIterator operator++(int) { auto ret = *this; ++mCurrent; return ret; }
+  IntegerIterator operator--(int) { auto ret = *this; --mCurrent; return ret; }
+
+  /* Comparison operators */
+
+  template<typename IntType1, typename IntType2>
+  friend bool operator==(const IntegerIterator<IntType1>& aIter1,
+                         const IntegerIterator<IntType2>& aIter2);
+  template<typename IntType1, typename IntType2>
+  friend bool operator!=(const IntegerIterator<IntType1>& aIter1,
+                         const IntegerIterator<IntType2>& aIter2);
+  template<typename IntType1, typename IntType2>
+  friend bool operator<(const IntegerIterator<IntType1>& aIter1,
+                        const IntegerIterator<IntType2>& aIter2);
+  template<typename IntType1, typename IntType2>
+  friend bool operator<=(const IntegerIterator<IntType1>& aIter1,
+                         const IntegerIterator<IntType2>& aIter2);
+  template<typename IntType1, typename IntType2>
+  friend bool operator>(const IntegerIterator<IntType1>& aIter1,
+                        const IntegerIterator<IntType2>& aIter2);
+  template<typename IntType1, typename IntType2>
+  friend bool operator>=(const IntegerIterator<IntType1>& aIter1,
+                         const IntegerIterator<IntType2>& aIter2);
+
+private:
+  IntTypeT mCurrent;
+};
+
+template<typename IntType1, typename IntType2>
+bool operator==(const IntegerIterator<IntType1>& aIter1,
+                const IntegerIterator<IntType2>& aIter2)
+{
+  return aIter1.mCurrent == aIter2.mCurrent;
+}
+
+template<typename IntType1, typename IntType2>
+bool operator!=(const IntegerIterator<IntType1>& aIter1,
+                const IntegerIterator<IntType2>& aIter2)
+{
+  return aIter1.mCurrent != aIter2.mCurrent;
+}
+
+template<typename IntType1, typename IntType2>
+bool operator<(const IntegerIterator<IntType1>& aIter1,
+               const IntegerIterator<IntType2>& aIter2)
+{
+  return aIter1.mCurrent < aIter2.mCurrent;
+}
+
+template<typename IntType1, typename IntType2>
+bool operator<=(const IntegerIterator<IntType1>& aIter1,
+                const IntegerIterator<IntType2>& aIter2)
+{
+  return aIter1.mCurrent <= aIter2.mCurrent;
+}
+
+template<typename IntType1, typename IntType2>
+bool operator>(const IntegerIterator<IntType1>& aIter1,
+               const IntegerIterator<IntType2>& aIter2)
+{
+  return aIter1.mCurrent > aIter2.mCurrent;
+}
+
+template<typename IntType1, typename IntType2>
+bool operator>=(const IntegerIterator<IntType1>& aIter1,
+                const IntegerIterator<IntType2>& aIter2)
+{
+  return aIter1.mCurrent >= aIter2.mCurrent;
+}
+
+template<typename IntTypeT>
+class IntegerRange
+{
+public:
+  typedef IntegerIterator<IntTypeT> iterator;
+  typedef IntegerIterator<IntTypeT> const_iterator;
+  typedef ReverseIterator<IntegerIterator<IntTypeT>> reverse_iterator;
+  typedef ReverseIterator<IntegerIterator<IntTypeT>> const_reverse_iterator;
+
+  template<typename IntType>
+  explicit IntegerRange(IntType aEnd)
+    : mBegin(0), mEnd(aEnd) { }
+
+  template<typename IntType1, typename IntType2>
+  IntegerRange(IntType1 aBegin, IntType2 aEnd)
+    : mBegin(aBegin), mEnd(aEnd) { }
+
+  iterator begin() const { return iterator(mBegin); }
+  const_iterator cbegin() const { return begin(); }
+  iterator end() const { return iterator(mEnd); }
+  const_iterator cend() const { return end(); }
+  reverse_iterator rbegin() const { return reverse_iterator(mEnd); }
+  const_reverse_iterator crbegin() const { return rbegin(); }
+  reverse_iterator rend() const { return reverse_iterator(mBegin); }
+  const_reverse_iterator crend() const { return rend(); }
+
+private:
+  IntTypeT mBegin;
+  IntTypeT mEnd;
+};
+
+template<typename T, bool = IsUnsigned<T>::value>
+struct GeqZero
+{
+  static bool check(T t) {
+    return t >= 0;
+  }
+};
+
+template<typename T>
+struct GeqZero<T, true>
+{
+  static bool check(T t) {
+    return true;
+  }
+};
+
+} // namespace detail
+
+template<typename IntType>
+detail::IntegerRange<IntType>
+MakeRange(IntType aEnd)
+{
+  static_assert(IsIntegral<IntType>::value, "value must be integral");
+  MOZ_ASSERT(detail::GeqZero<IntType>::check(aEnd),
+             "Should never have negative value here");
+  return detail::IntegerRange<IntType>(aEnd);
+}
+
+template<typename IntType1, typename IntType2>
+detail::IntegerRange<IntType2>
+MakeRange(IntType1 aBegin, IntType2 aEnd)
+{
+  static_assert(IsIntegral<IntType1>::value && IsIntegral<IntType2>::value,
+                "values must both be integral");
+  static_assert(IsSigned<IntType1>::value == IsSigned<IntType2>::value,
+                "signed/unsigned mismatch");
+  MOZ_ASSERT(aEnd >= aBegin, "End value should be larger than begin value");
+  return detail::IntegerRange<IntType2>(aBegin, aEnd);
+}
+
+} // namespace mozilla
+
+#endif // mozilla_IntegerRange_h
diff --git a/src/third_party/mozjs-45/mfbt/IntegerTypeTraits.h b/src/third_party/mozjs-45/mfbt/IntegerTypeTraits.h
new file mode 100644
index 0000000..6144d20
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/IntegerTypeTraits.h
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Helpers to manipulate integer types that don't fit in TypeTraits.h */
+
+#ifndef mozilla_IntegerTypeTraits_h
+#define mozilla_IntegerTypeTraits_h
+
+#include "mozilla/TypeTraits.h"
+#include <stdint.h>
+
+namespace mozilla {
+
+namespace detail {
+
+/**
+ * StdintTypeForSizeAndSignedness returns the stdint integer type
+ * of given size (can be 1, 2, 4 or 8) and given signedness
+ * (false means unsigned, true means signed).
+ */
+template<size_t Size, bool Signedness>
+struct StdintTypeForSizeAndSignedness;
+
+template<>
+struct StdintTypeForSizeAndSignedness<1, true>
+{
+  typedef int8_t Type;
+};
+
+template<>
+struct StdintTypeForSizeAndSignedness<1, false>
+{
+  typedef uint8_t Type;
+};
+
+template<>
+struct StdintTypeForSizeAndSignedness<2, true>
+{
+  typedef int16_t Type;
+};
+
+template<>
+struct StdintTypeForSizeAndSignedness<2, false>
+{
+  typedef uint16_t Type;
+};
+
+template<>
+struct StdintTypeForSizeAndSignedness<4, true>
+{
+  typedef int32_t Type;
+};
+
+template<>
+struct StdintTypeForSizeAndSignedness<4, false>
+{
+  typedef uint32_t Type;
+};
+
+template<>
+struct StdintTypeForSizeAndSignedness<8, true>
+{
+  typedef int64_t Type;
+};
+
+template<>
+struct StdintTypeForSizeAndSignedness<8, false>
+{
+  typedef uint64_t Type;
+};
+
+} // namespace detail
+
+template<size_t Size>
+struct UnsignedStdintTypeForSize
+  : detail::StdintTypeForSizeAndSignedness<Size, false>
+{};
+
+template<size_t Size>
+struct SignedStdintTypeForSize
+  : detail::StdintTypeForSizeAndSignedness<Size, true>
+{};
+
+template<typename IntegerType>
+struct PositionOfSignBit
+{
+  static_assert(IsIntegral<IntegerType>::value,
+                "PositionOfSignBit is only for integral types");
+  // 8 here should be CHAR_BIT from limits.h, but the world has moved on.
+  static const size_t value = 8 * sizeof(IntegerType) - 1;
+};
+
+/**
+ * MinValue returns the minimum value of the given integer type as a
+ * compile-time constant, which std::numeric_limits<IntegerType>::min()
+ * cannot do in c++98.
+ */
+template<typename IntegerType>
+struct MinValue
+{
+private:
+  static_assert(IsIntegral<IntegerType>::value,
+                "MinValue is only for integral types");
+
+  typedef typename MakeUnsigned<IntegerType>::Type UnsignedIntegerType;
+  static const size_t PosOfSignBit = PositionOfSignBit<IntegerType>::value;
+
+public:
+  // Bitwise ops may return a larger type, that's why we cast explicitly.
+  // In C++, left bit shifts on signed values is undefined by the standard
+  // unless the shifted value is representable.
+  // Notice that signed-to-unsigned conversions are always well-defined in
+  // the standard as the value congruent to 2**n, as expected. By contrast,
+  // unsigned-to-signed is only well-defined if the value is representable.
+  static const IntegerType value =
+      IsSigned<IntegerType>::value
+      ? IntegerType(UnsignedIntegerType(1) << PosOfSignBit)
+      : IntegerType(0);
+};
+
+/**
+ * MaxValue returns the maximum value of the given integer type as a
+ * compile-time constant, which std::numeric_limits<IntegerType>::max()
+ * cannot do in c++98.
+ */
+template<typename IntegerType>
+struct MaxValue
+{
+  static_assert(IsIntegral<IntegerType>::value,
+                "MaxValue is only for integral types");
+
+  // Tricksy, but covered by the CheckedInt unit test.
+  // Relies on the type of MinValue<IntegerType>::value
+  // being IntegerType.
+  static const IntegerType value = ~MinValue<IntegerType>::value;
+};
+
+} // namespace mozilla
+
+#endif // mozilla_IntegerTypeTraits_h
diff --git a/src/third_party/mozjs-45/mfbt/JSONWriter.cpp b/src/third_party/mozjs-45/mfbt/JSONWriter.cpp
new file mode 100644
index 0000000..fc48979
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/JSONWriter.cpp
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/JSONWriter.h"
+
+namespace mozilla {
+namespace detail {
+
+// The chars with non-'___' entries in this table are those that can be
+// represented with a two-char escape sequence. The value is the second char in
+// the sequence, that which follows the initial backslash.
+#define ___ 0
+const char gTwoCharEscapes[256] = {
+/*          0    1    2    3    4    5    6    7    8    9 */
+/*   0+ */ ___, ___, ___, ___, ___, ___, ___, ___, 'b', 't',
+/*  10+ */ 'n', ___, 'f', 'r', ___, ___, ___, ___, ___, ___,
+/*  20+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/*  30+ */ ___, ___, ___, ___, '"', ___, ___, ___, ___, ___,
+/*  40+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/*  50+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/*  60+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/*  70+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/*  80+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/*  90+ */ ___, ___,'\\', ___, ___, ___, ___, ___, ___, ___,
+/* 100+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 110+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 120+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 130+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 140+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 150+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 160+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 170+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 180+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 190+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 200+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 210+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 220+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 230+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 240+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
+/* 250+ */ ___, ___, ___, ___, ___, ___
+};
+#undef ___
+
+} // namespace detail
+} // namespace mozilla
+
diff --git a/src/third_party/mozjs-45/mfbt/JSONWriter.h b/src/third_party/mozjs-45/mfbt/JSONWriter.h
new file mode 100644
index 0000000..da6e0c4
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/JSONWriter.h
@@ -0,0 +1,460 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A JSON pretty-printer class. */
+
+// A typical JSON-writing library requires you to first build up a data
+// structure that represents a JSON object and then serialize it (to file, or
+// somewhere else). This approach makes for a clean API, but building the data
+// structure takes up memory. Sometimes that isn't desirable, such as when the
+// JSON data is produced for memory reporting.
+//
+// The JSONWriter class instead allows JSON data to be written out
+// incrementally without building up large data structures.
+//
+// The API is slightly uglier than you would see in a typical JSON-writing
+// library, but still fairly easy to use. It's possible to generate invalid
+// JSON with JSONWriter, but typically the most basic testing will identify any
+// such problems.
+//
+// Similarly, there are no RAII facilities for automatically closing objects
+// and arrays. These would be nice if you are generating all your code within
+// nested functions, but in other cases you'd have to maintain an explicit
+// stack of RAII objects and manually unwind it, which is no better than just
+// calling "end" functions. Furthermore, the consequences of forgetting to
+// close an object or array are obvious and, again, will be identified via
+// basic testing, unlike other cases where RAII is typically used (e.g. smart
+// pointers) and the consequences of defects are more subtle.
+//
+// Importantly, the class does solve the two hard problems of JSON
+// pretty-printing, which are (a) correctly escaping strings, and (b) adding
+// appropriate indentation and commas between items.
+//
+// By default, every property is placed on its own line. However, it is
+// possible to request that objects and arrays be placed entirely on a single
+// line, which can reduce output size significantly in some cases.
+//
+// Strings used (for property names and string property values) are |const
+// char*| throughout, and can be ASCII or UTF-8.
+//
+// EXAMPLE
+// -------
+// Assume that |MyWriteFunc| is a class that implements |JSONWriteFunc|. The
+// following code:
+//
+//   JSONWriter w(MakeUnique<MyWriteFunc>());
+//   w.Start();
+//   {
+//     w.NullProperty("null");
+//     w.BoolProperty("bool", true);
+//     w.IntProperty("int", 1);
+//     w.StartArrayProperty("array");
+//     {
+//       w.StringElement("string");
+//       w.StartObjectElement();
+//       {
+//         w.DoubleProperty("double", 3.4);
+//         w.StartArrayProperty("single-line array", w.SingleLineStyle);
+//         {
+//           w.IntElement(1);
+//           w.StartObjectElement();  // SingleLineStyle is inherited from
+//           w.EndObjectElement();    //   above for this collection
+//         }
+//         w.EndArray();
+//       }
+//       w.EndObjectElement();
+//     }
+//     w.EndArrayProperty();
+//   }
+//   w.End();
+//
+// will produce pretty-printed output for the following JSON object:
+//
+//  {
+//   "null": null,
+//   "bool": true,
+//   "int": 1,
+//   "array": [
+//    "string",
+//    {
+//     "double": 3.4,
+//     "single-line array": [1, {}]
+//    }
+//   ]
+//  }
+//
+// The nesting in the example code is obviously optional, but can aid
+// readability.
+
+#ifndef mozilla_JSONWriter_h
+#define mozilla_JSONWriter_h
+
+#include "mozilla/double-conversion.h"
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/PodOperations.h"
+#include "mozilla/Snprintf.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/Vector.h"
+
+#include <stdio.h>
+
+namespace mozilla {
+
+// A quasi-functor for JSONWriter. We don't use a true functor because that
+// requires templatizing JSONWriter, and the templatization seeps to lots of
+// places we don't want it to.
+class JSONWriteFunc
+{
+public:
+  virtual void Write(const char* aStr) = 0;
+  virtual ~JSONWriteFunc() {}
+};
+
+// Ideally this would be within |EscapedString| but when compiling with GCC
+// on Linux that caused link errors, whereas this formulation didn't.
+namespace detail {
+extern MFBT_DATA const char gTwoCharEscapes[256];
+} // namespace detail
+
+class JSONWriter
+{
+  // From http://www.ietf.org/rfc/rfc4627.txt:
+  //
+  //   "All Unicode characters may be placed within the quotation marks except
+  //   for the characters that must be escaped: quotation mark, reverse
+  //   solidus, and the control characters (U+0000 through U+001F)."
+  //
+  // This implementation uses two-char escape sequences where possible, namely:
+  //
+  //   \", \\, \b, \f, \n, \r, \t
+  //
+  // All control characters not in the above list are represented with a
+  // six-char escape sequence, e.g. '\u000b' (a.k.a. '\v').
+  //
+  class EscapedString
+  {
+    // Only one of |mUnownedStr| and |mOwnedStr| are ever non-null. |mIsOwned|
+    // indicates which one is in use. They're not within a union because that
+    // wouldn't work with UniquePtr.
+    bool mIsOwned;
+    const char* mUnownedStr;
+    UniquePtr<char[]> mOwnedStr;
+
+    void SanityCheck() const
+    {
+      MOZ_ASSERT_IF( mIsOwned,  mOwnedStr.get() && !mUnownedStr);
+      MOZ_ASSERT_IF(!mIsOwned, !mOwnedStr.get() &&  mUnownedStr);
+    }
+
+    static char hexDigitToAsciiChar(uint8_t u)
+    {
+      u = u & 0xf;
+      return u < 10 ? '0' + u : 'a' + (u - 10);
+    }
+
+  public:
+    explicit EscapedString(const char* aStr)
+      : mUnownedStr(nullptr)
+      , mOwnedStr(nullptr)
+    {
+      const char* p;
+
+      // First, see if we need to modify the string.
+      size_t nExtra = 0;
+      p = aStr;
+      while (true) {
+        uint8_t u = *p;   // ensure it can't be interpreted as negative
+        if (u == 0) {
+          break;
+        }
+        if (detail::gTwoCharEscapes[u]) {
+          nExtra += 1;
+        } else if (u <= 0x1f) {
+          nExtra += 5;
+        }
+        p++;
+      }
+
+      if (nExtra == 0) {
+        // No escapes needed. Easy.
+        mIsOwned = false;
+        mUnownedStr = aStr;
+        return;
+      }
+
+      // Escapes are needed. We'll create a new string.
+      mIsOwned = true;
+      size_t len = (p - aStr) + nExtra;
+      mOwnedStr = MakeUnique<char[]>(len + 1);
+
+      p = aStr;
+      size_t i = 0;
+
+      while (true) {
+        uint8_t u = *p;   // ensure it can't be interpreted as negative
+        if (u == 0) {
+          mOwnedStr[i] = 0;
+          break;
+        }
+        if (detail::gTwoCharEscapes[u]) {
+          mOwnedStr[i++] = '\\';
+          mOwnedStr[i++] = detail::gTwoCharEscapes[u];
+        } else if (u <= 0x1f) {
+          mOwnedStr[i++] = '\\';
+          mOwnedStr[i++] = 'u';
+          mOwnedStr[i++] = '0';
+          mOwnedStr[i++] = '0';
+          mOwnedStr[i++] = hexDigitToAsciiChar((u & 0x00f0) >> 4);
+          mOwnedStr[i++] = hexDigitToAsciiChar(u & 0x000f);
+        } else {
+          mOwnedStr[i++] = u;
+        }
+        p++;
+      }
+    }
+
+    ~EscapedString()
+    {
+      SanityCheck();
+    }
+
+    const char* get() const
+    {
+      SanityCheck();
+      return mIsOwned ? mOwnedStr.get() : mUnownedStr;
+    }
+  };
+
+public:
+  // Collections (objects and arrays) are printed in a multi-line style by
+  // default. This can be changed to a single-line style if SingleLineStyle is
+  // specified. If a collection is printed in single-line style, every nested
+  // collection within it is also printed in single-line style, even if
+  // multi-line style is requested.
+  enum CollectionStyle {
+    MultiLineStyle,   // the default
+    SingleLineStyle
+  };
+
+protected:
+  const UniquePtr<JSONWriteFunc> mWriter;
+  Vector<bool, 8> mNeedComma;     // do we need a comma at depth N?
+  Vector<bool, 8> mNeedNewlines;  // do we need newlines at depth N?
+  size_t mDepth;                  // the current nesting depth
+
+  void Indent()
+  {
+    for (size_t i = 0; i < mDepth; i++) {
+      mWriter->Write(" ");
+    }
+  }
+
+  // Adds whatever is necessary (maybe a comma, and then a newline and
+  // whitespace) to separate an item (property or element) from what's come
+  // before.
+  void Separator()
+  {
+    if (mNeedComma[mDepth]) {
+      mWriter->Write(",");
+    }
+    if (mDepth > 0 && mNeedNewlines[mDepth]) {
+      mWriter->Write("\n");
+      Indent();
+    } else if (mNeedComma[mDepth]) {
+      mWriter->Write(" ");
+    }
+  }
+
+  void PropertyNameAndColon(const char* aName)
+  {
+    EscapedString escapedName(aName);
+    mWriter->Write("\"");
+    mWriter->Write(escapedName.get());
+    mWriter->Write("\": ");
+  }
+
+  void Scalar(const char* aMaybePropertyName, const char* aStringValue)
+  {
+    Separator();
+    if (aMaybePropertyName) {
+      PropertyNameAndColon(aMaybePropertyName);
+    }
+    mWriter->Write(aStringValue);
+    mNeedComma[mDepth] = true;
+  }
+
+  void QuotedScalar(const char* aMaybePropertyName, const char* aStringValue)
+  {
+    Separator();
+    if (aMaybePropertyName) {
+      PropertyNameAndColon(aMaybePropertyName);
+    }
+    mWriter->Write("\"");
+    mWriter->Write(aStringValue);
+    mWriter->Write("\"");
+    mNeedComma[mDepth] = true;
+  }
+
+  void NewVectorEntries()
+  {
+    // If these tiny allocations OOM we might as well just crash because we
+    // must be in serious memory trouble.
+    MOZ_RELEASE_ASSERT(mNeedComma.resizeUninitialized(mDepth + 1));
+    MOZ_RELEASE_ASSERT(mNeedNewlines.resizeUninitialized(mDepth + 1));
+    mNeedComma[mDepth] = false;
+    mNeedNewlines[mDepth] = true;
+  }
+
+  void StartCollection(const char* aMaybePropertyName, const char* aStartChar,
+                       CollectionStyle aStyle = MultiLineStyle)
+  {
+    Separator();
+    if (aMaybePropertyName) {
+      mWriter->Write("\"");
+      mWriter->Write(aMaybePropertyName);
+      mWriter->Write("\": ");
+    }
+    mWriter->Write(aStartChar);
+    mNeedComma[mDepth] = true;
+    mDepth++;
+    NewVectorEntries();
+    mNeedNewlines[mDepth] =
+      mNeedNewlines[mDepth - 1] && aStyle == MultiLineStyle;
+  }
+
+  // Adds the whitespace and closing char necessary to end a collection.
+  void EndCollection(const char* aEndChar)
+  {
+    if (mNeedNewlines[mDepth]) {
+      mWriter->Write("\n");
+      mDepth--;
+      Indent();
+    } else {
+      mDepth--;
+    }
+    mWriter->Write(aEndChar);
+  }
+
+public:
+  explicit JSONWriter(UniquePtr<JSONWriteFunc> aWriter)
+    : mWriter(Move(aWriter))
+    , mNeedComma()
+    , mNeedNewlines()
+    , mDepth(0)
+  {
+    NewVectorEntries();
+  }
+
+  // Returns the JSONWriteFunc passed in at creation, for temporary use. The
+  // JSONWriter object still owns the JSONWriteFunc.
+  JSONWriteFunc* WriteFunc() const { return mWriter.get(); }
+
+  // For all the following functions, the "Prints:" comment indicates what the
+  // basic output looks like. However, it doesn't indicate the whitespace and
+  // trailing commas, which are automatically added as required.
+  //
+  // All property names and string properties are escaped as necessary.
+
+  // Prints: {
+  void Start(CollectionStyle aStyle = MultiLineStyle)
+  {
+    StartCollection(nullptr, "{", aStyle);
+  }
+
+  // Prints: }
+  void End() { EndCollection("}\n"); }
+
+  // Prints: "<aName>": null
+  void NullProperty(const char* aName)
+  {
+    Scalar(aName, "null");
+  }
+
+  // Prints: null
+  void NullElement() { NullProperty(nullptr); }
+
+  // Prints: "<aName>": <aBool>
+  void BoolProperty(const char* aName, bool aBool)
+  {
+    Scalar(aName, aBool ? "true" : "false");
+  }
+
+  // Prints: <aBool>
+  void BoolElement(bool aBool) { BoolProperty(nullptr, aBool); }
+
+  // Prints: "<aName>": <aInt>
+  void IntProperty(const char* aName, int64_t aInt)
+  {
+    char buf[64];
+    snprintf_literal(buf, "%" PRId64, aInt);
+    Scalar(aName, buf);
+  }
+
+  // Prints: <aInt>
+  void IntElement(int64_t aInt) { IntProperty(nullptr, aInt); }
+
+  // Prints: "<aName>": <aDouble>
+  void DoubleProperty(const char* aName, double aDouble)
+  {
+    static const size_t buflen = 64;
+    char buf[buflen];
+    const double_conversion::DoubleToStringConverter &converter =
+      double_conversion::DoubleToStringConverter::EcmaScriptConverter();
+    double_conversion::StringBuilder builder(buf, buflen);
+    converter.ToShortest(aDouble, &builder);
+    Scalar(aName, builder.Finalize());
+  }
+
+  // Prints: <aDouble>
+  void DoubleElement(double aDouble) { DoubleProperty(nullptr, aDouble); }
+
+  // Prints: "<aName>": "<aStr>"
+  void StringProperty(const char* aName, const char* aStr)
+  {
+    EscapedString escapedStr(aStr);
+    QuotedScalar(aName, escapedStr.get());
+  }
+
+  // Prints: "<aStr>"
+  void StringElement(const char* aStr) { StringProperty(nullptr, aStr); }
+
+  // Prints: "<aName>": [
+  void StartArrayProperty(const char* aName,
+                          CollectionStyle aStyle = MultiLineStyle)
+  {
+    StartCollection(aName, "[", aStyle);
+  }
+
+  // Prints: [
+  void StartArrayElement(CollectionStyle aStyle = MultiLineStyle)
+  {
+    StartArrayProperty(nullptr, aStyle);
+  }
+
+  // Prints: ]
+  void EndArray() { EndCollection("]"); }
+
+  // Prints: "<aName>": {
+  void StartObjectProperty(const char* aName,
+                           CollectionStyle aStyle = MultiLineStyle)
+  {
+    StartCollection(aName, "{", aStyle);
+  }
+
+  // Prints: {
+  void StartObjectElement(CollectionStyle aStyle = MultiLineStyle)
+  {
+    StartObjectProperty(nullptr, aStyle);
+  }
+
+  // Prints: }
+  void EndObject() { EndCollection("}"); }
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_JSONWriter_h */
+
diff --git a/src/third_party/mozjs-45/mfbt/Likely.h b/src/third_party/mozjs-45/mfbt/Likely.h
new file mode 100644
index 0000000..4f21609
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Likely.h
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * MOZ_LIKELY and MOZ_UNLIKELY macros to hint to the compiler how a
+ * boolean predicate should be branch-predicted.
+ */
+
+#ifndef mozilla_Likely_h
+#define mozilla_Likely_h
+
+#if defined(__clang__) || defined(__GNUC__)
+#  define MOZ_LIKELY(x)   (__builtin_expect(!!(x), 1))
+#  define MOZ_UNLIKELY(x) (__builtin_expect(!!(x), 0))
+#else
+#  define MOZ_LIKELY(x)   (!!(x))
+#  define MOZ_UNLIKELY(x) (!!(x))
+#endif
+
+#endif /* mozilla_Likely_h */
diff --git a/src/third_party/mozjs-45/mfbt/LinkedList.h b/src/third_party/mozjs-45/mfbt/LinkedList.h
new file mode 100644
index 0000000..6eb4c63
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/LinkedList.h
@@ -0,0 +1,533 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A type-safe doubly-linked list class. */
+
+/*
+ * The classes LinkedList<T> and LinkedListElement<T> together form a
+ * convenient, type-safe doubly-linked list implementation.
+ *
+ * The class T which will be inserted into the linked list must inherit from
+ * LinkedListElement<T>.  A given object may be in only one linked list at a
+ * time.
+ *
+ * A LinkedListElement automatically removes itself from the list upon
+ * destruction, and a LinkedList will fatally assert in debug builds if it's
+ * non-empty when it's destructed.
+ *
+ * For example, you might use LinkedList in a simple observer list class as
+ * follows.
+ *
+ *   class Observer : public LinkedListElement<Observer>
+ *   {
+ *   public:
+ *     void observe(char* aTopic) { ... }
+ *   };
+ *
+ *   class ObserverContainer
+ *   {
+ *   private:
+ *     LinkedList<Observer> list;
+ *
+ *   public:
+ *     void addObserver(Observer* aObserver)
+ *     {
+ *       // Will assert if |aObserver| is part of another list.
+ *       list.insertBack(aObserver);
+ *     }
+ *
+ *     void removeObserver(Observer* aObserver)
+ *     {
+ *       // Will assert if |aObserver| is not part of some list.
+ *       aObserver.remove();
+ *       // Or, will assert if |aObserver| is not part of |list| specifically.
+ *       // aObserver.removeFrom(list);
+ *     }
+ *
+ *     void notifyObservers(char* aTopic)
+ *     {
+ *       for (Observer* o = list.getFirst(); o != nullptr; o = o->getNext()) {
+ *         o->observe(aTopic);
+ *       }
+ *     }
+ *   };
+ *
+ * Additionally, the class AutoCleanLinkedList<T> is a LinkedList<T> that will
+ * remove and delete each element still within itself upon destruction. Note
+ * that because each element is deleted, elements must have been allocated
+ * using |new|.
+ */
+
+#ifndef mozilla_LinkedList_h
+#define mozilla_LinkedList_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/MemoryReporting.h"
+#include "mozilla/Move.h"
+
+#ifdef __cplusplus
+
+namespace mozilla {
+
+template<typename T>
+class LinkedList;
+
+template<typename T>
+class LinkedListElement
+{
+  /*
+   * It's convenient that we return nullptr when getNext() or getPrevious()
+   * hits the end of the list, but doing so costs an extra word of storage in
+   * each linked list node (to keep track of whether |this| is the sentinel
+   * node) and a branch on this value in getNext/getPrevious.
+   *
+   * We could get rid of the extra word of storage by shoving the "is
+   * sentinel" bit into one of the pointers, although this would, of course,
+   * have performance implications of its own.
+   *
+   * But the goal here isn't to win an award for the fastest or slimmest
+   * linked list; rather, we want a *convenient* linked list.  So we won't
+   * waste time guessing which micro-optimization strategy is best.
+   *
+   *
+   * Speaking of unnecessary work, it's worth addressing here why we wrote
+   * mozilla::LinkedList in the first place, instead of using stl::list.
+   *
+   * The key difference between mozilla::LinkedList and stl::list is that
+   * mozilla::LinkedList stores the mPrev/mNext pointers in the object itself,
+   * while stl::list stores the mPrev/mNext pointers in a list element which
+   * itself points to the object being stored.
+   *
+   * mozilla::LinkedList's approach makes it harder to store an object in more
+   * than one list.  But the upside is that you can call next() / prev() /
+   * remove() directly on the object.  With stl::list, you'd need to store a
+   * pointer to its iterator in the object in order to accomplish this.  Not
+   * only would this waste space, but you'd have to remember to update that
+   * pointer every time you added or removed the object from a list.
+   *
+   * In-place, constant-time removal is a killer feature of doubly-linked
+   * lists, and supporting this painlessly was a key design criterion.
+   */
+
+private:
+  LinkedListElement* mNext;
+  LinkedListElement* mPrev;
+  const bool mIsSentinel;
+
+public:
+  LinkedListElement()
+    : mNext(this),
+      mPrev(this),
+      mIsSentinel(false)
+  { }
+
+  LinkedListElement(LinkedListElement<T>&& other)
+    : mIsSentinel(other.mIsSentinel)
+  {
+    if (!other.isInList()) {
+      mNext = this;
+      mPrev = this;
+      return;
+    }
+
+    MOZ_ASSERT(other.mNext->mPrev == &other);
+    MOZ_ASSERT(other.mPrev->mNext == &other);
+
+    /*
+     * Initialize |this| with |other|'s mPrev/mNext pointers, and adjust those
+     * element to point to this one.
+     */
+    mNext = other.mNext;
+    mPrev = other.mPrev;
+
+    mNext->mPrev = this;
+    mPrev->mNext = this;
+
+    /*
+     * Adjust |other| so it doesn't think it's in a list.  This makes it
+     * safely destructable.
+     */
+    other.mNext = &other;
+    other.mPrev = &other;
+  }
+
+  ~LinkedListElement()
+  {
+    if (!mIsSentinel && isInList()) {
+      remove();
+    }
+  }
+
+  /*
+   * Get the next element in the list, or nullptr if this is the last element
+   * in the list.
+   */
+  T* getNext()             { return mNext->asT(); }
+  const T* getNext() const { return mNext->asT(); }
+
+  /*
+   * Get the previous element in the list, or nullptr if this is the first
+   * element in the list.
+   */
+  T* getPrevious()             { return mPrev->asT(); }
+  const T* getPrevious() const { return mPrev->asT(); }
+
+  /*
+   * Insert aElem after this element in the list.  |this| must be part of a
+   * linked list when you call setNext(); otherwise, this method will assert.
+   */
+  void setNext(T* aElem)
+  {
+    MOZ_ASSERT(isInList());
+    setNextUnsafe(aElem);
+  }
+
+  /*
+   * Insert aElem before this element in the list.  |this| must be part of a
+   * linked list when you call setPrevious(); otherwise, this method will
+   * assert.
+   */
+  void setPrevious(T* aElem)
+  {
+    MOZ_ASSERT(isInList());
+    setPreviousUnsafe(aElem);
+  }
+
+  /*
+   * Remove this element from the list which contains it.  If this element is
+   * not currently part of a linked list, this method asserts.
+   */
+  void remove()
+  {
+    MOZ_ASSERT(isInList());
+
+    mPrev->mNext = mNext;
+    mNext->mPrev = mPrev;
+    mNext = this;
+    mPrev = this;
+  }
+
+  /*
+   * Identical to remove(), but also asserts in debug builds that this element
+   * is in aList.
+   */
+  void removeFrom(const LinkedList<T>& aList)
+  {
+    aList.assertContains(asT());
+    remove();
+  }
+
+  /*
+   * Return true if |this| part is of a linked list, and false otherwise.
+   */
+  bool isInList() const
+  {
+    MOZ_ASSERT((mNext == this) == (mPrev == this));
+    return mNext != this;
+  }
+
+private:
+  friend class LinkedList<T>;
+
+  enum NodeKind {
+    NODE_KIND_NORMAL,
+    NODE_KIND_SENTINEL
+  };
+
+  explicit LinkedListElement(NodeKind nodeKind)
+    : mNext(this),
+      mPrev(this),
+      mIsSentinel(nodeKind == NODE_KIND_SENTINEL)
+  { }
+
+  /*
+   * Return |this| cast to T* if we're a normal node, or return nullptr if
+   * we're a sentinel node.
+   */
+  T* asT()
+  {
+    return mIsSentinel ? nullptr : static_cast<T*>(this);
+  }
+  const T* asT() const
+  {
+    return mIsSentinel ? nullptr : static_cast<const T*>(this);
+  }
+
+  /*
+   * Insert aElem after this element, but don't check that this element is in
+   * the list.  This is called by LinkedList::insertFront().
+   */
+  void setNextUnsafe(T* aElem)
+  {
+    LinkedListElement *listElem = static_cast<LinkedListElement*>(aElem);
+    MOZ_ASSERT(!listElem->isInList());
+
+    listElem->mNext = this->mNext;
+    listElem->mPrev = this;
+    this->mNext->mPrev = listElem;
+    this->mNext = listElem;
+  }
+
+  /*
+   * Insert aElem before this element, but don't check that this element is in
+   * the list.  This is called by LinkedList::insertBack().
+   */
+  void setPreviousUnsafe(T* aElem)
+  {
+    LinkedListElement<T>* listElem = static_cast<LinkedListElement<T>*>(aElem);
+    MOZ_ASSERT(!listElem->isInList());
+
+    listElem->mNext = this;
+    listElem->mPrev = this->mPrev;
+    this->mPrev->mNext = listElem;
+    this->mPrev = listElem;
+  }
+
+private:
+  LinkedListElement& operator=(const LinkedListElement<T>& aOther) = delete;
+  LinkedListElement(const LinkedListElement<T>& aOther) = delete;
+};
+
+template<typename T>
+class LinkedList
+{
+private:
+  LinkedListElement<T> sentinel;
+
+public:
+  class Iterator {
+    T* mCurrent;
+
+  public:
+    explicit Iterator(T* aCurrent) : mCurrent(aCurrent) {}
+
+    T* operator *() const {
+      return mCurrent;
+    }
+
+    const Iterator& operator++() {
+      mCurrent = mCurrent->getNext();
+      return *this;
+    }
+
+    bool operator!=(Iterator& aOther) const {
+      return mCurrent != aOther.mCurrent;
+    }
+  };
+
+  LinkedList() : sentinel(LinkedListElement<T>::NODE_KIND_SENTINEL) { }
+
+  LinkedList(LinkedList<T>&& aOther)
+    : sentinel(mozilla::Move(aOther.sentinel))
+  { }
+
+  ~LinkedList() { MOZ_ASSERT(isEmpty()); }
+
+  /*
+   * Add aElem to the front of the list.
+   */
+  void insertFront(T* aElem)
+  {
+    /* Bypass setNext()'s this->isInList() assertion. */
+    sentinel.setNextUnsafe(aElem);
+  }
+
+  /*
+   * Add aElem to the back of the list.
+   */
+  void insertBack(T* aElem)
+  {
+    sentinel.setPreviousUnsafe(aElem);
+  }
+
+  /*
+   * Get the first element of the list, or nullptr if the list is empty.
+   */
+  T* getFirst()             { return sentinel.getNext(); }
+  const T* getFirst() const { return sentinel.getNext(); }
+
+  /*
+   * Get the last element of the list, or nullptr if the list is empty.
+   */
+  T* getLast()             { return sentinel.getPrevious(); }
+  const T* getLast() const { return sentinel.getPrevious(); }
+
+  /*
+   * Get and remove the first element of the list.  If the list is empty,
+   * return nullptr.
+   */
+  T* popFirst()
+  {
+    T* ret = sentinel.getNext();
+    if (ret) {
+      static_cast<LinkedListElement<T>*>(ret)->remove();
+    }
+    return ret;
+  }
+
+  /*
+   * Get and remove the last element of the list.  If the list is empty,
+   * return nullptr.
+   */
+  T* popLast()
+  {
+    T* ret = sentinel.getPrevious();
+    if (ret) {
+      static_cast<LinkedListElement<T>*>(ret)->remove();
+    }
+    return ret;
+  }
+
+  /*
+   * Return true if the list is empty, or false otherwise.
+   */
+  bool isEmpty() const
+  {
+    return !sentinel.isInList();
+  }
+
+  /*
+   * Remove all the elements from the list.
+   *
+   * This runs in time linear to the list's length, because we have to mark
+   * each element as not in the list.
+   */
+  void clear()
+  {
+    while (popFirst()) {
+      continue;
+    }
+  }
+
+  /*
+   * Allow range-based iteration:
+   *
+   *     for (MyElementType* elt : myList) { ... }
+   */
+  Iterator begin() {
+    return Iterator(getFirst());
+  }
+  Iterator end() {
+    return Iterator(nullptr);
+  }
+
+  /*
+   * Measures the memory consumption of the list excluding |this|.  Note that
+   * it only measures the list elements themselves.  If the list elements
+   * contain pointers to other memory blocks, those blocks must be measured
+   * separately during a subsequent iteration over the list.
+   */
+  size_t sizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
+  {
+    size_t n = 0;
+    for (const T* t = getFirst(); t; t = t->getNext()) {
+      n += aMallocSizeOf(t);
+    }
+    return n;
+  }
+
+  /*
+   * Like sizeOfExcludingThis(), but measures |this| as well.
+   */
+  size_t sizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+  {
+    return aMallocSizeOf(this) + sizeOfExcludingThis(aMallocSizeOf);
+  }
+
+  /*
+   * In a debug build, make sure that the list is sane (no cycles, consistent
+   * mNext/mPrev pointers, only one sentinel).  Has no effect in release builds.
+   */
+  void debugAssertIsSane() const
+  {
+#ifdef DEBUG
+    const LinkedListElement<T>* slow;
+    const LinkedListElement<T>* fast1;
+    const LinkedListElement<T>* fast2;
+
+    /*
+     * Check for cycles in the forward singly-linked list using the
+     * tortoise/hare algorithm.
+     */
+    for (slow = sentinel.mNext,
+         fast1 = sentinel.mNext->mNext,
+         fast2 = sentinel.mNext->mNext->mNext;
+         slow != &sentinel && fast1 != &sentinel && fast2 != &sentinel;
+         slow = slow->mNext, fast1 = fast2->mNext, fast2 = fast1->mNext) {
+      MOZ_ASSERT(slow != fast1);
+      MOZ_ASSERT(slow != fast2);
+    }
+
+    /* Check for cycles in the backward singly-linked list. */
+    for (slow = sentinel.mPrev,
+         fast1 = sentinel.mPrev->mPrev,
+         fast2 = sentinel.mPrev->mPrev->mPrev;
+         slow != &sentinel && fast1 != &sentinel && fast2 != &sentinel;
+         slow = slow->mPrev, fast1 = fast2->mPrev, fast2 = fast1->mPrev) {
+      MOZ_ASSERT(slow != fast1);
+      MOZ_ASSERT(slow != fast2);
+    }
+
+    /*
+     * Check that |sentinel| is the only node in the list with
+     * mIsSentinel == true.
+     */
+    for (const LinkedListElement<T>* elem = sentinel.mNext;
+         elem != &sentinel;
+         elem = elem->mNext) {
+      MOZ_ASSERT(!elem->mIsSentinel);
+    }
+
+    /* Check that the mNext/mPrev pointers match up. */
+    const LinkedListElement<T>* prev = &sentinel;
+    const LinkedListElement<T>* cur = sentinel.mNext;
+    do {
+        MOZ_ASSERT(cur->mPrev == prev);
+        MOZ_ASSERT(prev->mNext == cur);
+
+        prev = cur;
+        cur = cur->mNext;
+    } while (cur != &sentinel);
+#endif /* ifdef DEBUG */
+  }
+
+private:
+  friend class LinkedListElement<T>;
+
+  void assertContains(const T* aValue) const
+  {
+#ifdef DEBUG
+    for (const T* elem = getFirst(); elem; elem = elem->getNext()) {
+      if (elem == aValue) {
+        return;
+      }
+    }
+    MOZ_CRASH("element wasn't found in this list!");
+#endif
+  }
+
+  LinkedList& operator=(const LinkedList<T>& aOther) = delete;
+  LinkedList(const LinkedList<T>& aOther) = delete;
+};
+
+template <typename T>
+class AutoCleanLinkedList : public LinkedList<T>
+{
+public:
+  ~AutoCleanLinkedList()
+  {
+    while (T* element = this->popFirst()) {
+      delete element;
+    }
+  }
+};
+
+} /* namespace mozilla */
+
+#endif /* __cplusplus */
+
+#endif /* mozilla_LinkedList_h */
diff --git a/src/third_party/mozjs-45/mfbt/LinuxSignal.h b/src/third_party/mozjs-45/mfbt/LinuxSignal.h
new file mode 100644
index 0000000..9b8e1bb
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/LinuxSignal.h
@@ -0,0 +1,48 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_LinuxSignal_h
+#define mozilla_LinuxSignal_h
+
+namespace mozilla {
+
+#if defined(__arm__)
+
+// Some (old) Linux kernels on ARM have a bug where a signal handler
+// can be called without clearing the IT bits in CPSR first. The result
+// is that the first few instructions of the handler could be skipped,
+// ultimately resulting in crashes. To workaround this bug, the handler
+// on ARM is a trampoline that starts with enough NOP instructions, so
+// that even if the IT bits are not cleared, only the NOP instructions
+// will be skipped over.
+
+template <void (*H)(int, siginfo_t*, void*)>
+__attribute__((naked)) void
+SignalTrampoline(int aSignal, siginfo_t* aInfo, void* aContext)
+{
+  asm volatile (
+    "nop; nop; nop; nop"
+    : : : "memory");
+
+  // Because the assembler may generate additional insturctions below, we
+  // need to ensure NOPs are inserted first by separating them out above.
+
+  asm volatile (
+    "bx %0"
+    :
+    : "r"(H), "l"(aSignal), "l"(aInfo), "l"(aContext)
+    : "memory");
+}
+
+# define MOZ_SIGNAL_TRAMPOLINE(h) (mozilla::SignalTrampoline<h>)
+
+#else // __arm__
+
+# define MOZ_SIGNAL_TRAMPOLINE(h) (h)
+
+#endif // __arm__
+
+} // namespace mozilla
+
+#endif // mozilla_LinuxSignal_h
diff --git a/src/third_party/mozjs-45/mfbt/MacroArgs.h b/src/third_party/mozjs-45/mfbt/MacroArgs.h
new file mode 100644
index 0000000..c8b7338
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/MacroArgs.h
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Implements various macros meant to ease the use of variadic macros.
+ */
+
+#ifndef mozilla_MacroArgs_h
+#define mozilla_MacroArgs_h
+
+/*
+ * MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) counts the number of variadic
+ * arguments and prefixes it with |aPrefix|. For example:
+ *
+ *   MOZ_PASTE_PREFIX_AND_ARG_COUNT(, foo, 42) expands to 2
+ *   MOZ_PASTE_PREFIX_AND_ARG_COUNT(A, foo, 42, bar) expands to A3
+ *
+ * You must pass in between 1 and 50 (inclusive) variadic arguments, past
+ * |aPrefix|. It is not legal to do
+ *
+ *   MOZ_PASTE_PREFIX_AND_ARG_COUNT(prefix)
+ *
+ * (that is, pass in 0 variadic arguments). To ensure that a compile-time
+ * error occurs when these constraints are violated, use the
+ * MOZ_STATIC_ASSERT_VALID_ARG_COUNT macro with the same variaidc arguments
+ * wherever this macro is used.
+ *
+ * Passing (__VA_ARGS__, <rest of arguments>) rather than simply calling
+ * MOZ_MACROARGS_ARG_COUNT_HELPER2(__VA_ARGS__, <rest of arguments>) very
+ * carefully tiptoes around a MSVC bug where it improperly expands __VA_ARGS__
+ * as a single token in argument lists. For details, see:
+ *
+ *   http://connect.microsoft.com/VisualStudio/feedback/details/380090/variadic-macro-replacement
+ *   http://cplusplus.co.il/2010/07/17/variadic-macro-to-count-number-of-arguments/#comment-644
+ */
+#define MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) \
+  MOZ_MACROARGS_ARG_COUNT_HELPER((__VA_ARGS__, \
+    aPrefix##50, aPrefix##49, aPrefix##48, aPrefix##47, aPrefix##46, \
+    aPrefix##45, aPrefix##44, aPrefix##43, aPrefix##42, aPrefix##41, \
+    aPrefix##40, aPrefix##39, aPrefix##38, aPrefix##37, aPrefix##36, \
+    aPrefix##35, aPrefix##34, aPrefix##33, aPrefix##32, aPrefix##31, \
+    aPrefix##30, aPrefix##29, aPrefix##28, aPrefix##27, aPrefix##26, \
+    aPrefix##25, aPrefix##24, aPrefix##23, aPrefix##22, aPrefix##21, \
+    aPrefix##20, aPrefix##19, aPrefix##18, aPrefix##17, aPrefix##16, \
+    aPrefix##15, aPrefix##14, aPrefix##13, aPrefix##12, aPrefix##11, \
+    aPrefix##10, aPrefix##9,  aPrefix##8,  aPrefix##7,  aPrefix##6,  \
+    aPrefix##5,  aPrefix##4,  aPrefix##3,  aPrefix##2,  aPrefix##1, aPrefix##0))
+
+#define MOZ_MACROARGS_ARG_COUNT_HELPER(aArgs) \
+  MOZ_MACROARGS_ARG_COUNT_HELPER2 aArgs
+
+#define MOZ_MACROARGS_ARG_COUNT_HELPER2( \
+   a1,  a2,  a3,  a4,  a5,  a6,  a7,  a8,  a9, a10, \
+  a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, \
+  a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, \
+  a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, \
+  a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, \
+  a51, ...) a51
+
+/*
+ * MOZ_STATIC_ASSERT_VALID_ARG_COUNT ensures that a compile-time error occurs
+ * when the argument count constraints of MOZ_PASTE_PREFIX_AND_ARG_COUNT are
+ * violated. Use this macro wherever MOZ_PASTE_PREFIX_AND_ARG_COUNT is used
+ * and pass it the same variadic arguments.
+ *
+ * This macro employs a few dirty tricks to function. To detect the zero
+ * argument case, |(__VA_ARGS__)| is stringified, sizeof-ed, and compared to
+ * what it should be in the absence of arguments.
+ *
+ * Detecting too many arguments is a little trickier. With a valid argument
+ * count and a prefix of 1, MOZ_PASTE_PREFIX_AND_ARG_COUNT expands to e.g. 14.
+ * With a prefix of 0.0, it expands to e.g. 0.04. If there are too many
+ * arguments, it expands to the first argument over the limit. If this
+ * exceeding argument is a number, the assertion will fail as there is no
+ * number than can simultaneously be both > 10 and == 0. If the exceeding
+ * argument is not a number, a compile-time error should still occur due to
+ * the operations performed on it.
+ */
+#define MOZ_MACROARGS_STRINGIFY_HELPER(x) #x
+#define MOZ_STATIC_ASSERT_VALID_ARG_COUNT(...) \
+  static_assert( \
+    sizeof(MOZ_MACROARGS_STRINGIFY_HELPER((__VA_ARGS__))) != sizeof("()") && \
+      (MOZ_PASTE_PREFIX_AND_ARG_COUNT(1, __VA_ARGS__)) > 10 && \
+      (int)(MOZ_PASTE_PREFIX_AND_ARG_COUNT(0.0, __VA_ARGS__)) == 0, \
+    "MOZ_STATIC_ASSERT_VALID_ARG_COUNT requires 1 to 50 arguments") /* ; */
+
+/*
+ * MOZ_ARGS_AFTER_N expands to its arguments excluding the first |N|
+ * arguments. For example:
+ *
+ *   MOZ_ARGS_AFTER_2(a, b, c, d) expands to: c, d
+ */
+#define MOZ_ARGS_AFTER_1(a1, ...) __VA_ARGS__
+#define MOZ_ARGS_AFTER_2(a1, a2, ...) __VA_ARGS__
+
+/*
+ * MOZ_ARG_N expands to its |N|th argument.
+ */
+#define MOZ_ARG_1(a1, ...) a1
+#define MOZ_ARG_2(a1, a2, ...) a2
+
+#endif /* mozilla_MacroArgs_h */
diff --git a/src/third_party/mozjs-45/mfbt/MacroForEach.h b/src/third_party/mozjs-45/mfbt/MacroForEach.h
new file mode 100644
index 0000000..7c0e3cf
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/MacroForEach.h
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Implements a higher-order macro for iteratively calling another macro with
+ * fixed leading arguments, plus a trailing element picked from a second list
+ * of arguments.
+ */
+
+#ifndef mozilla_MacroForEach_h
+#define mozilla_MacroForEach_h
+
+#include "mozilla/MacroArgs.h"
+
+/*
+ * MOZ_FOR_EACH(aMacro, aFixedArgs, aArgs) expands to N calls to the macro
+ * |aMacro| where N is equal the number of items in the list |aArgs|. The
+ * arguments for each |aMacro| call are composed of *all* arguments in the list
+ * |aFixedArgs| as well as a single argument in the list |aArgs|. For example:
+ *
+ *   #define MACRO_A(x) x +
+ *   int a = MOZ_FOR_EACH(MACRO_A, (), (1, 2, 3)) 0;
+ *   // Expands to:     MACRO_A(1) MACRO_A(2) MACRO_A(3) 0;
+ *   // And further to: 1 + 2 + 3 + 0;
+ *
+ *   #define MACRO_B(k, x) (k + x) +
+ *   int b = MOZ_FOR_EACH(MACRO_B, (5,), (1, 2)) 0;
+ *   // Expands to: MACRO_B(5, 1) MACRO_B(5, 2) 0;
+ *
+ *   #define MACRO_C(k1, k2, x) (k1 + k2 + x) +
+ *   int c = MOZ_FOR_EACH(MACRO_C, (5, 8,), (1, 2)) 0;
+ *   // Expands to: MACRO_B(5, 8, 1) MACRO_B(5, 8, 2) 0;
+ *
+ * If the |aFixedArgs| list is not empty, a trailing comma must be included.
+ *
+ * The |aArgs| list must be not be empty and may be up to 50 items long. Use
+ * MOZ_STATIC_ASSERT_VALID_ARG_COUNT to ensure that violating this constraint
+ * results in a compile-time error.
+ */
+#define MOZ_FOR_EACH_EXPAND_HELPER(...) __VA_ARGS__
+#define MOZ_FOR_EACH_GLUE(a, b) a b
+#define MOZ_FOR_EACH(aMacro, aFixedArgs, aArgs) \
+  MOZ_FOR_EACH_GLUE( \
+    MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_FOR_EACH_, \
+                                   MOZ_FOR_EACH_EXPAND_HELPER aArgs), \
+    (aMacro, aFixedArgs, aArgs))
+
+#define MOZ_FOR_EACH_HELPER_GLUE(a, b) a b
+#define MOZ_FOR_EACH_HELPER(aMacro, aFixedArgs, aArgs) \
+  MOZ_FOR_EACH_HELPER_GLUE( \
+    aMacro, \
+    (MOZ_FOR_EACH_EXPAND_HELPER aFixedArgs MOZ_ARG_1 aArgs))
+
+#define MOZ_FOR_EACH_1(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a)
+#define MOZ_FOR_EACH_2(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_1(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_3(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_2(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_4(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_3(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_5(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_4(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_6(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_5(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_7(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_6(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_8(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_7(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_9(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_8(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_10(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_9(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_11(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_10(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_12(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_11(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_13(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_12(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_14(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_13(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_15(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_14(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_16(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_15(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_17(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_16(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_18(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_17(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_19(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_18(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_20(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_19(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_21(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_20(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_22(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_21(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_23(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_22(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_24(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_23(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_25(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_24(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_26(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_25(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_27(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_26(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_28(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_27(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_29(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_28(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_30(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_29(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_31(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_30(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_32(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_31(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_33(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_32(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_34(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_33(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_35(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_34(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_36(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_35(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_37(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_36(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_38(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_37(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_39(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_38(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_40(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_39(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_41(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_40(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_42(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_41(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_43(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_42(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_44(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_43(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_45(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_44(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_46(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_45(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_47(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_46(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_48(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_47(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_49(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_48(m, fa, (MOZ_ARGS_AFTER_1 a))
+#define MOZ_FOR_EACH_50(m, fa, a) \
+  MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_49(m, fa, (MOZ_ARGS_AFTER_1 a))
+
+#endif /* mozilla_MacroForEach_h */
diff --git a/src/third_party/mozjs-45/mfbt/MathAlgorithms.h b/src/third_party/mozjs-45/mfbt/MathAlgorithms.h
new file mode 100644
index 0000000..28e4182
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/MathAlgorithms.h
@@ -0,0 +1,547 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* mfbt maths algorithms. */
+
+#ifndef mozilla_MathAlgorithms_h
+#define mozilla_MathAlgorithms_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/TypeTraits.h"
+
+#include <cmath>
+#include <limits.h>
+#include <stdint.h>
+
+namespace mozilla {
+
+// Greatest Common Divisor
+template<typename IntegerType>
+MOZ_ALWAYS_INLINE IntegerType
+EuclidGCD(IntegerType aA, IntegerType aB)
+{
+  // Euclid's algorithm; O(N) in the worst case.  (There are better
+  // ways, but we don't need them for the current use of this algo.)
+  MOZ_ASSERT(aA > IntegerType(0));
+  MOZ_ASSERT(aB > IntegerType(0));
+
+  while (aA != aB) {
+    if (aA > aB) {
+      aA = aA - aB;
+    } else {
+      aB = aB - aA;
+    }
+  }
+
+  return aA;
+}
+
+// Least Common Multiple
+template<typename IntegerType>
+MOZ_ALWAYS_INLINE IntegerType
+EuclidLCM(IntegerType aA, IntegerType aB)
+{
+  // Divide first to reduce overflow risk.
+  return (aA / EuclidGCD(aA, aB)) * aB;
+}
+
+namespace detail {
+
+template<typename T>
+struct AllowDeprecatedAbsFixed : FalseType {};
+
+template<> struct AllowDeprecatedAbsFixed<int32_t> : TrueType {};
+template<> struct AllowDeprecatedAbsFixed<int64_t> : TrueType {};
+
+template<typename T>
+struct AllowDeprecatedAbs : AllowDeprecatedAbsFixed<T> {};
+
+template<> struct AllowDeprecatedAbs<int> : TrueType {};
+template<> struct AllowDeprecatedAbs<long> : TrueType {};
+
+} // namespace detail
+
+// DO NOT USE DeprecatedAbs.  It exists only until its callers can be converted
+// to Abs below, and it will be removed when all callers have been changed.
+template<typename T>
+inline typename mozilla::EnableIf<detail::AllowDeprecatedAbs<T>::value, T>::Type
+DeprecatedAbs(const T aValue)
+{
+  // The absolute value of the smallest possible value of a signed-integer type
+  // won't fit in that type (on twos-complement systems -- and we're blithely
+  // assuming we're on such systems, for the non-<stdint.h> types listed above),
+  // so assert that the input isn't that value.
+  //
+  // This is the case if: the value is non-negative; or if adding one (giving a
+  // value in the range [-maxvalue, 0]), then negating (giving a value in the
+  // range [0, maxvalue]), doesn't produce maxvalue (because in twos-complement,
+  // (minvalue + 1) == -maxvalue).
+  MOZ_ASSERT(aValue >= 0 ||
+             -(aValue + 1) != T((1ULL << (CHAR_BIT * sizeof(T) - 1)) - 1),
+             "You can't negate the smallest possible negative integer!");
+  return aValue >= 0 ? aValue : -aValue;
+}
+
+namespace detail {
+
+// For now mozilla::Abs only takes intN_T, the signed natural types, and
+// float/double/long double.  Feel free to add overloads for other standard,
+// signed types if you need them.
+
+template<typename T>
+struct AbsReturnTypeFixed;
+
+template<> struct AbsReturnTypeFixed<int8_t> { typedef uint8_t Type; };
+template<> struct AbsReturnTypeFixed<int16_t> { typedef uint16_t Type; };
+template<> struct AbsReturnTypeFixed<int32_t> { typedef uint32_t Type; };
+template<> struct AbsReturnTypeFixed<int64_t> { typedef uint64_t Type; };
+
+template<typename T>
+struct AbsReturnType : AbsReturnTypeFixed<T> {};
+
+template<> struct AbsReturnType<char> :
+  EnableIf<char(-1) < char(0), unsigned char> {};
+template<> struct AbsReturnType<signed char> { typedef unsigned char Type; };
+template<> struct AbsReturnType<short> { typedef unsigned short Type; };
+template<> struct AbsReturnType<int> { typedef unsigned int Type; };
+template<> struct AbsReturnType<long> { typedef unsigned long Type; };
+template<> struct AbsReturnType<long long> { typedef unsigned long long Type; };
+template<> struct AbsReturnType<float> { typedef float Type; };
+template<> struct AbsReturnType<double> { typedef double Type; };
+template<> struct AbsReturnType<long double> { typedef long double Type; };
+
+} // namespace detail
+
+template<typename T>
+inline typename detail::AbsReturnType<T>::Type
+Abs(const T aValue)
+{
+  typedef typename detail::AbsReturnType<T>::Type ReturnType;
+  return aValue >= 0 ? ReturnType(aValue) : ~ReturnType(aValue) + 1;
+}
+
+template<>
+inline float
+Abs<float>(const float aFloat)
+{
+  return std::fabs(aFloat);
+}
+
+template<>
+inline double
+Abs<double>(const double aDouble)
+{
+  return std::fabs(aDouble);
+}
+
+template<>
+inline long double
+Abs<long double>(const long double aLongDouble)
+{
+  return std::fabs(aLongDouble);
+}
+
+} // namespace mozilla
+
+#if defined(_MSC_VER) && \
+    (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
+#  define MOZ_BITSCAN_WINDOWS
+
+#  include <intrin.h>
+#  pragma intrinsic(_BitScanForward, _BitScanReverse)
+
+#  if defined(_M_AMD64) || defined(_M_X64)
+#    define MOZ_BITSCAN_WINDOWS64
+#   pragma intrinsic(_BitScanForward64, _BitScanReverse64)
+#  endif
+
+#endif
+
+namespace mozilla {
+
+namespace detail {
+
+#if defined(MOZ_BITSCAN_WINDOWS)
+
+inline uint_fast8_t
+CountLeadingZeroes32(uint32_t aValue)
+{
+  unsigned long index;
+  if (!_BitScanReverse(&index, static_cast<unsigned long>(aValue)))
+      return 32;
+  return uint_fast8_t(31 - index);
+}
+
+
+inline uint_fast8_t
+CountTrailingZeroes32(uint32_t aValue)
+{
+  unsigned long index;
+  if (!_BitScanForward(&index, static_cast<unsigned long>(aValue)))
+      return 32;
+  return uint_fast8_t(index);
+}
+
+inline uint_fast8_t
+CountPopulation32(uint32_t aValue)
+{
+  uint32_t x = aValue - ((aValue >> 1) & 0x55555555);
+  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
+  return (((x + (x >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;
+}
+inline uint_fast8_t
+CountPopulation64(uint64_t aValue)
+{
+  return uint_fast8_t(CountPopulation32(aValue & 0xffffffff) +
+                      CountPopulation32(aValue >> 32));
+}
+
+inline uint_fast8_t
+CountLeadingZeroes64(uint64_t aValue)
+{
+#if defined(MOZ_BITSCAN_WINDOWS64)
+  unsigned long index;
+  if (!_BitScanReverse64(&index, static_cast<unsigned __int64>(aValue)))
+      return 64;
+  return uint_fast8_t(63 - index);
+#else
+  uint32_t hi = uint32_t(aValue >> 32);
+  if (hi != 0) {
+    return CountLeadingZeroes32(hi);
+  }
+  return 32u + CountLeadingZeroes32(uint32_t(aValue));
+#endif
+}
+
+inline uint_fast8_t
+CountTrailingZeroes64(uint64_t aValue)
+{
+#if defined(MOZ_BITSCAN_WINDOWS64)
+  unsigned long index;
+  if (!_BitScanForward64(&index, static_cast<unsigned __int64>(aValue)))
+      return 64;
+  return uint_fast8_t(index);
+#else
+  uint32_t lo = uint32_t(aValue);
+  if (lo != 0) {
+    return CountTrailingZeroes32(lo);
+  }
+  return 32u + CountTrailingZeroes32(uint32_t(aValue >> 32));
+#endif
+}
+
+#  ifdef MOZ_HAVE_BITSCAN64
+#    undef MOZ_HAVE_BITSCAN64
+#  endif
+
+#elif defined(__clang__) || defined(__GNUC__)
+
+#  if defined(__clang__)
+#    if !__has_builtin(__builtin_ctz) || !__has_builtin(__builtin_clz)
+#      error "A clang providing __builtin_c[lt]z is required to build"
+#    endif
+#  else
+     // gcc has had __builtin_clz and friends since 3.4: no need to check.
+#  endif
+
+inline uint_fast8_t
+CountLeadingZeroes32(uint32_t aValue)
+{
+  return __builtin_clz(aValue);
+}
+
+inline uint_fast8_t
+CountTrailingZeroes32(uint32_t aValue)
+{
+  return __builtin_ctz(aValue);
+}
+
+inline uint_fast8_t
+CountPopulation32(uint32_t aValue)
+{
+  return __builtin_popcount(aValue);
+}
+
+inline uint_fast8_t
+CountPopulation64(uint64_t aValue)
+{
+  return __builtin_popcountll(aValue);
+}
+
+inline uint_fast8_t
+CountLeadingZeroes64(uint64_t aValue)
+{
+  return __builtin_clzll(aValue);
+}
+
+inline uint_fast8_t
+CountTrailingZeroes64(uint64_t aValue)
+{
+  return __builtin_ctzll(aValue);
+}
+
+#else
+#  error "Implement these!"
+inline uint_fast8_t CountLeadingZeroes32(uint32_t aValue) = delete;
+inline uint_fast8_t CountTrailingZeroes32(uint32_t aValue) = delete;
+inline uint_fast8_t CountPopulation32(uint32_t aValue) = delete;
+inline uint_fast8_t CountPopulation64(uint64_t aValue) = delete;
+inline uint_fast8_t CountLeadingZeroes64(uint64_t aValue) = delete;
+inline uint_fast8_t CountTrailingZeroes64(uint64_t aValue) = delete;
+#endif
+
+} // namespace detail
+
+/**
+ * Compute the number of high-order zero bits in the NON-ZERO number |aValue|.
+ * That is, looking at the bitwise representation of the number, with the
+ * highest- valued bits at the start, return the number of zeroes before the
+ * first one is observed.
+ *
+ * CountLeadingZeroes32(0xF0FF1000) is 0;
+ * CountLeadingZeroes32(0x7F8F0001) is 1;
+ * CountLeadingZeroes32(0x3FFF0100) is 2;
+ * CountLeadingZeroes32(0x1FF50010) is 3; and so on.
+ */
+inline uint_fast8_t
+CountLeadingZeroes32(uint32_t aValue)
+{
+  MOZ_ASSERT(aValue != 0);
+  return detail::CountLeadingZeroes32(aValue);
+}
+
+/**
+ * Compute the number of low-order zero bits in the NON-ZERO number |aValue|.
+ * That is, looking at the bitwise representation of the number, with the
+ * lowest- valued bits at the start, return the number of zeroes before the
+ * first one is observed.
+ *
+ * CountTrailingZeroes32(0x0100FFFF) is 0;
+ * CountTrailingZeroes32(0x7000FFFE) is 1;
+ * CountTrailingZeroes32(0x0080FFFC) is 2;
+ * CountTrailingZeroes32(0x0080FFF8) is 3; and so on.
+ */
+inline uint_fast8_t
+CountTrailingZeroes32(uint32_t aValue)
+{
+  MOZ_ASSERT(aValue != 0);
+  return detail::CountTrailingZeroes32(aValue);
+}
+
+/**
+ * Compute the number of one bits in the number |aValue|,
+ */
+inline uint_fast8_t
+CountPopulation32(uint32_t aValue)
+{
+  return detail::CountPopulation32(aValue);
+}
+
+/** Analogous to CoutPopulation32, but for 64-bit numbers */
+inline uint_fast8_t
+CountPopulation64(uint64_t aValue)
+{
+  return detail::CountPopulation64(aValue);
+}
+
+/** Analogous to CountLeadingZeroes32, but for 64-bit numbers. */
+inline uint_fast8_t
+CountLeadingZeroes64(uint64_t aValue)
+{
+  MOZ_ASSERT(aValue != 0);
+  return detail::CountLeadingZeroes64(aValue);
+}
+
+/** Analogous to CountTrailingZeroes32, but for 64-bit numbers. */
+inline uint_fast8_t
+CountTrailingZeroes64(uint64_t aValue)
+{
+  MOZ_ASSERT(aValue != 0);
+  return detail::CountTrailingZeroes64(aValue);
+}
+
+namespace detail {
+
+template<typename T, size_t Size = sizeof(T)>
+class CeilingLog2;
+
+template<typename T>
+class CeilingLog2<T, 4>
+{
+public:
+  static uint_fast8_t compute(const T aValue)
+  {
+    // Check for <= 1 to avoid the == 0 undefined case.
+    return aValue <= 1 ? 0u : 32u - CountLeadingZeroes32(aValue - 1);
+  }
+};
+
+template<typename T>
+class CeilingLog2<T, 8>
+{
+public:
+  static uint_fast8_t compute(const T aValue)
+  {
+    // Check for <= 1 to avoid the == 0 undefined case.
+    return aValue <= 1 ? 0u : 64u - CountLeadingZeroes64(aValue - 1);
+  }
+};
+
+} // namespace detail
+
+/**
+ * Compute the log of the least power of 2 greater than or equal to |aValue|.
+ *
+ * CeilingLog2(0..1) is 0;
+ * CeilingLog2(2) is 1;
+ * CeilingLog2(3..4) is 2;
+ * CeilingLog2(5..8) is 3;
+ * CeilingLog2(9..16) is 4; and so on.
+ */
+template<typename T>
+inline uint_fast8_t
+CeilingLog2(const T aValue)
+{
+  return detail::CeilingLog2<T>::compute(aValue);
+}
+
+/** A CeilingLog2 variant that accepts only size_t. */
+inline uint_fast8_t
+CeilingLog2Size(size_t aValue)
+{
+  return CeilingLog2(aValue);
+}
+
+namespace detail {
+
+template<typename T, size_t Size = sizeof(T)>
+class FloorLog2;
+
+template<typename T>
+class FloorLog2<T, 4>
+{
+public:
+  static uint_fast8_t compute(const T aValue)
+  {
+    return 31u - CountLeadingZeroes32(aValue | 1);
+  }
+};
+
+template<typename T>
+class FloorLog2<T, 8>
+{
+public:
+  static uint_fast8_t compute(const T aValue)
+  {
+    return 63u - CountLeadingZeroes64(aValue | 1);
+  }
+};
+
+} // namespace detail
+
+/**
+ * Compute the log of the greatest power of 2 less than or equal to |aValue|.
+ *
+ * FloorLog2(0..1) is 0;
+ * FloorLog2(2..3) is 1;
+ * FloorLog2(4..7) is 2;
+ * FloorLog2(8..15) is 3; and so on.
+ */
+template<typename T>
+inline uint_fast8_t
+FloorLog2(const T aValue)
+{
+  return detail::FloorLog2<T>::compute(aValue);
+}
+
+/** A FloorLog2 variant that accepts only size_t. */
+inline uint_fast8_t
+FloorLog2Size(size_t aValue)
+{
+  return FloorLog2(aValue);
+}
+
+/*
+ * Compute the smallest power of 2 greater than or equal to |x|.  |x| must not
+ * be so great that the computed value would overflow |size_t|.
+ */
+inline size_t
+RoundUpPow2(size_t aValue)
+{
+  MOZ_ASSERT(aValue <= (size_t(1) << (sizeof(size_t) * CHAR_BIT - 1)),
+             "can't round up -- will overflow!");
+  return size_t(1) << CeilingLog2(aValue);
+}
+
+/**
+ * Rotates the bits of the given value left by the amount of the shift width.
+ */
+template<typename T>
+inline T
+RotateLeft(const T aValue, uint_fast8_t aShift)
+{
+  MOZ_ASSERT(aShift < sizeof(T) * CHAR_BIT, "Shift value is too large!");
+  MOZ_ASSERT(aShift > 0,
+             "Rotation by value length is undefined behavior, but compilers "
+             "do not currently fold a test into the rotate instruction. "
+             "Please remove this restriction when compilers optimize the "
+             "zero case (http://blog.regehr.org/archives/1063).");
+  static_assert(IsUnsigned<T>::value, "Rotates require unsigned values");
+  return (aValue << aShift) | (aValue >> (sizeof(T) * CHAR_BIT - aShift));
+}
+
+/**
+ * Rotates the bits of the given value right by the amount of the shift width.
+ */
+template<typename T>
+inline T
+RotateRight(const T aValue, uint_fast8_t aShift)
+{
+  MOZ_ASSERT(aShift < sizeof(T) * CHAR_BIT, "Shift value is too large!");
+  MOZ_ASSERT(aShift > 0,
+             "Rotation by value length is undefined behavior, but compilers "
+             "do not currently fold a test into the rotate instruction. "
+             "Please remove this restriction when compilers optimize the "
+             "zero case (http://blog.regehr.org/archives/1063).");
+  static_assert(IsUnsigned<T>::value, "Rotates require unsigned values");
+  return (aValue >> aShift) | (aValue << (sizeof(T) * CHAR_BIT - aShift));
+}
+
+/**
+ * Returns true if |x| is a power of two.
+ * Zero is not an integer power of two. (-Inf is not an integer)
+ */
+template<typename T>
+inline bool
+IsPowerOfTwo(T x)
+{
+    static_assert(IsUnsigned<T>::value,
+                  "IsPowerOfTwo requires unsigned values");
+    return x && (x & (x - 1)) == 0;
+}
+
+template<typename T>
+inline T
+Clamp(const T aValue, const T aMin, const T aMax)
+{
+    static_assert(IsIntegral<T>::value,
+                  "Clamp accepts only integral types, so that it doesn't have"
+                  " to distinguish differently-signed zeroes (which users may"
+                  " or may not care to distinguish, likely at a perf cost) or"
+                  " to decide how to clamp NaN or a range with a NaN"
+                  " endpoint.");
+    MOZ_ASSERT(aMin <= aMax);
+
+    if (aValue <= aMin)
+        return aMin;
+    if (aValue >= aMax)
+        return aMax;
+    return aValue;
+}
+
+} /* namespace mozilla */
+
+#endif /* mozilla_MathAlgorithms_h */
diff --git a/src/third_party/mozjs-45/mfbt/Maybe.h b/src/third_party/mozjs-45/mfbt/Maybe.h
new file mode 100644
index 0000000..6c2ddf6
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Maybe.h
@@ -0,0 +1,505 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A class for optional values and in-place lazy construction. */
+
+#ifndef mozilla_Maybe_h
+#define mozilla_Maybe_h
+
+#include "mozilla/Alignment.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Move.h"
+#include "mozilla/TypeTraits.h"
+
+#include <new>  // for placement new
+
+namespace mozilla {
+
+struct Nothing { };
+
+/*
+ * Maybe is a container class which contains either zero or one elements. It
+ * serves two roles. It can represent values which are *semantically* optional,
+ * augmenting a type with an explicit 'Nothing' value. In this role, it provides
+ * methods that make it easy to work with values that may be missing, along with
+ * equality and comparison operators so that Maybe values can be stored in
+ * containers. Maybe values can be constructed conveniently in expressions using
+ * type inference, as follows:
+ *
+ *   void doSomething(Maybe<Foo> aFoo) {
+ *     if (aFoo)                  // Make sure that aFoo contains a value...
+ *       aFoo->takeAction();      // and then use |aFoo->| to access it.
+ *   }                            // |*aFoo| also works!
+ *
+ *   doSomething(Nothing());      // Passes a Maybe<Foo> containing no value.
+ *   doSomething(Some(Foo(100))); // Passes a Maybe<Foo> containing |Foo(100)|.
+ *
+ * You'll note that it's important to check whether a Maybe contains a value
+ * before using it, using conversion to bool, |isSome()|, or |isNothing()|. You
+ * can avoid these checks, and sometimes write more readable code, using
+ * |valueOr()|, |ptrOr()|, and |refOr()|, which allow you to retrieve the value
+ * in the Maybe and provide a default for the 'Nothing' case.  You can also use
+ * |apply()| to call a function only if the Maybe holds a value, and |map()| to
+ * transform the value in the Maybe, returning another Maybe with a possibly
+ * different type.
+ *
+ * Maybe's other role is to support lazily constructing objects without using
+ * dynamic storage. A Maybe directly contains storage for a value, but it's
+ * empty by default. |emplace()|, as mentioned above, can be used to construct a
+ * value in Maybe's storage.  The value a Maybe contains can be destroyed by
+ * calling |reset()|; this will happen automatically if a Maybe is destroyed
+ * while holding a value.
+ *
+ * It's a common idiom in C++ to use a pointer as a 'Maybe' type, with a null
+ * value meaning 'Nothing' and any other value meaning 'Some'. You can convert
+ * from such a pointer to a Maybe value using 'ToMaybe()'.
+ *
+ * Maybe is inspired by similar types in the standard library of many other
+ * languages (e.g. Haskell's Maybe and Rust's Option). In the C++ world it's
+ * very similar to std::optional, which was proposed for C++14 and originated in
+ * Boost. The most important differences between Maybe and std::optional are:
+ *
+ *   - std::optional<T> may be compared with T. We deliberately forbid that.
+ *   - std::optional allows in-place construction without a separate call to
+ *     |emplace()| by using a dummy |in_place_t| value to tag the appropriate
+ *     constructor.
+ *   - std::optional has |valueOr()|, equivalent to Maybe's |valueOr()|, but
+ *     lacks corresponding methods for |refOr()| and |ptrOr()|.
+ *   - std::optional lacks |map()| and |apply()|, making it less suitable for
+ *     functional-style code.
+ *   - std::optional lacks many convenience functions that Maybe has. Most
+ *     unfortunately, it lacks equivalents of the type-inferred constructor
+ *     functions |Some()| and |Nothing()|.
+ *
+ * N.B. GCC has missed optimizations with Maybe in the past and may generate
+ * extra branches/loads/stores. Use with caution on hot paths; it's not known
+ * whether or not this is still a problem.
+ */
+template<class T>
+class Maybe
+{
+  bool mIsSome;
+  AlignedStorage2<T> mStorage;
+
+public:
+  typedef T ValueType;
+
+  Maybe() : mIsSome(false) { }
+  ~Maybe() { reset(); }
+
+  MOZ_IMPLICIT Maybe(Nothing) : mIsSome(false) { }
+
+  Maybe(const Maybe& aOther)
+    : mIsSome(false)
+  {
+    if (aOther.mIsSome) {
+      emplace(*aOther);
+    }
+  }
+
+  Maybe(Maybe&& aOther)
+    : mIsSome(false)
+  {
+    if (aOther.mIsSome) {
+      emplace(Move(*aOther));
+      aOther.reset();
+    }
+  }
+
+  Maybe& operator=(const Maybe& aOther)
+  {
+    if (&aOther != this) {
+      if (aOther.mIsSome) {
+        if (mIsSome) {
+          // XXX(seth): The correct code for this branch, below, can't be used
+          // due to a bug in Visual Studio 2010. See bug 1052940.
+          /*
+          ref() = aOther.ref();
+          */
+          reset();
+          emplace(*aOther);
+        } else {
+          emplace(*aOther);
+        }
+      } else {
+        reset();
+      }
+    }
+    return *this;
+  }
+
+  Maybe& operator=(Maybe&& aOther)
+  {
+    MOZ_ASSERT(this != &aOther, "Self-moves are prohibited");
+
+    if (aOther.mIsSome) {
+      if (mIsSome) {
+        ref() = Move(aOther.ref());
+      } else {
+        emplace(Move(*aOther));
+      }
+      aOther.reset();
+    } else {
+      reset();
+    }
+
+    return *this;
+  }
+
+  /* Methods that check whether this Maybe contains a value */
+  explicit operator bool() const { return isSome(); }
+  bool isSome() const { return mIsSome; }
+  bool isNothing() const { return !mIsSome; }
+
+  /* Returns the contents of this Maybe<T> by value. Unsafe unless |isSome()|. */
+  T value() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
+
+  /*
+   * Returns the contents of this Maybe<T> by value. If |isNothing()|, returns
+   * the default value provided.
+   */
+  template<typename V>
+  T valueOr(V&& aDefault) const
+  {
+    if (isSome()) {
+      return ref();
+    }
+    return Forward<V>(aDefault);
+  }
+
+  /*
+   * Returns the contents of this Maybe<T> by value. If |isNothing()|, returns
+   * the value returned from the function or functor provided.
+   */
+  template<typename F>
+  T valueOrFrom(F&& aFunc) const
+  {
+    if (isSome()) {
+      return ref();
+    }
+    return aFunc();
+  }
+
+  /* Returns the contents of this Maybe<T> by pointer. Unsafe unless |isSome()|. */
+  T* ptr()
+  {
+    MOZ_ASSERT(mIsSome);
+    return &ref();
+  }
+
+  const T* ptr() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return &ref();
+  }
+
+  /*
+   * Returns the contents of this Maybe<T> by pointer. If |isNothing()|,
+   * returns the default value provided.
+   */
+  T* ptrOr(T* aDefault)
+  {
+    if (isSome()) {
+      return ptr();
+    }
+    return aDefault;
+  }
+
+  const T* ptrOr(const T* aDefault) const
+  {
+    if (isSome()) {
+      return ptr();
+    }
+    return aDefault;
+  }
+
+  /*
+   * Returns the contents of this Maybe<T> by pointer. If |isNothing()|,
+   * returns the value returned from the function or functor provided.
+   */
+  template<typename F>
+  T* ptrOrFrom(F&& aFunc)
+  {
+    if (isSome()) {
+      return ptr();
+    }
+    return aFunc();
+  }
+
+  template<typename F>
+  const T* ptrOrFrom(F&& aFunc) const
+  {
+    if (isSome()) {
+      return ptr();
+    }
+    return aFunc();
+  }
+
+  T* operator->()
+  {
+    MOZ_ASSERT(mIsSome);
+    return ptr();
+  }
+
+  const T* operator->() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ptr();
+  }
+
+  /* Returns the contents of this Maybe<T> by ref. Unsafe unless |isSome()|. */
+  T& ref()
+  {
+    MOZ_ASSERT(mIsSome);
+    return *mStorage.addr();
+  }
+
+  const T& ref() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return *mStorage.addr();
+  }
+
+  /*
+   * Returns the contents of this Maybe<T> by ref. If |isNothing()|, returns
+   * the default value provided.
+   */
+  T& refOr(T& aDefault)
+  {
+    if (isSome()) {
+      return ref();
+    }
+    return aDefault;
+  }
+
+  const T& refOr(const T& aDefault) const
+  {
+    if (isSome()) {
+      return ref();
+    }
+    return aDefault;
+  }
+
+  /*
+   * Returns the contents of this Maybe<T> by ref. If |isNothing()|, returns the
+   * value returned from the function or functor provided.
+   */
+  template<typename F>
+  T& refOrFrom(F&& aFunc)
+  {
+    if (isSome()) {
+      return ref();
+    }
+    return aFunc();
+  }
+
+  template<typename F>
+  const T& refOrFrom(F&& aFunc) const
+  {
+    if (isSome()) {
+      return ref();
+    }
+    return aFunc();
+  }
+
+  T& operator*()
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
+
+  const T& operator*() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
+
+  /* If |isSome()|, runs the provided function or functor on the contents of
+   * this Maybe. */
+  template<typename F, typename... Args>
+  void apply(F&& aFunc, Args&&... aArgs)
+  {
+    if (isSome()) {
+      aFunc(ref(), Forward<Args>(aArgs)...);
+    }
+  }
+
+  template<typename F, typename... Args>
+  void apply(F&& aFunc, Args&&... aArgs) const
+  {
+    if (isSome()) {
+      aFunc(ref(), Forward<Args>(aArgs)...);
+    }
+  }
+
+  /*
+   * If |isSome()|, runs the provided function and returns the result wrapped
+   * in a Maybe. If |isNothing()|, returns an empty Maybe value.
+   */
+  template<typename R, typename... FArgs, typename... Args>
+  Maybe<R> map(R (*aFunc)(T&, FArgs...), Args&&... aArgs)
+  {
+    if (isSome()) {
+      Maybe<R> val;
+      val.emplace(aFunc(ref(), Forward<Args>(aArgs)...));
+      return val;
+    }
+    return Maybe<R>();
+  }
+
+  template<typename R, typename... FArgs, typename... Args>
+  Maybe<R> map(R (*aFunc)(const T&, FArgs...), Args&&... aArgs) const
+  {
+    if (isSome()) {
+      Maybe<R> val;
+      val.emplace(aFunc(ref(), Forward<Args>(aArgs)...));
+      return val;
+    }
+    return Maybe<R>();
+  }
+
+  /* If |isSome()|, empties this Maybe and destroys its contents. */
+  void reset()
+  {
+    if (isSome()) {
+      ref().~T();
+      mIsSome = false;
+    }
+  }
+
+  /*
+   * Constructs a T value in-place in this empty Maybe<T>'s storage. The
+   * arguments to |emplace()| are the parameters to T's constructor.
+   */
+  template<typename... Args>
+  void emplace(Args&&... aArgs)
+  {
+    MOZ_ASSERT(!mIsSome);
+    ::new (mStorage.addr()) T(Forward<Args>(aArgs)...);
+    mIsSome = true;
+  }
+};
+
+/*
+ * Some() creates a Maybe<T> value containing the provided T value. If T has a
+ * move constructor, it's used to make this as efficient as possible.
+ *
+ * Some() selects the type of Maybe it returns by removing any const, volatile,
+ * or reference qualifiers from the type of the value you pass to it. This gives
+ * it more intuitive behavior when used in expressions, but it also means that
+ * if you need to construct a Maybe value that holds a const, volatile, or
+ * reference value, you need to use emplace() instead.
+ */
+template<typename T>
+Maybe<typename RemoveCV<typename RemoveReference<T>::Type>::Type>
+Some(T&& aValue)
+{
+  typedef typename RemoveCV<typename RemoveReference<T>::Type>::Type U;
+  Maybe<U> value;
+  value.emplace(Forward<T>(aValue));
+  return value;
+}
+
+template<typename T>
+Maybe<typename RemoveCV<typename RemoveReference<T>::Type>::Type>
+ToMaybe(T* aPtr)
+{
+  if (aPtr) {
+    return Some(*aPtr);
+  }
+  return Nothing();
+}
+
+/*
+ * Two Maybe<T> values are equal if
+ * - both are Nothing, or
+ * - both are Some, and the values they contain are equal.
+ */
+template<typename T> bool
+operator==(const Maybe<T>& aLHS, const Maybe<T>& aRHS)
+{
+  if (aLHS.isNothing() != aRHS.isNothing()) {
+    return false;
+  }
+  return aLHS.isNothing() || *aLHS == *aRHS;
+}
+
+template<typename T> bool
+operator!=(const Maybe<T>& aLHS, const Maybe<T>& aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
+/*
+ * We support comparison to Nothing to allow reasonable expressions like:
+ *   if (maybeValue == Nothing()) { ... }
+ */
+template<typename T> bool
+operator==(const Maybe<T>& aLHS, const Nothing& aRHS)
+{
+  return aLHS.isNothing();
+}
+
+template<typename T> bool
+operator!=(const Maybe<T>& aLHS, const Nothing& aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
+template<typename T> bool
+operator==(const Nothing& aLHS, const Maybe<T>& aRHS)
+{
+  return aRHS.isNothing();
+}
+
+template<typename T> bool
+operator!=(const Nothing& aLHS, const Maybe<T>& aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
+/*
+ * Maybe<T> values are ordered in the same way T values are ordered, except that
+ * Nothing comes before anything else.
+ */
+template<typename T> bool
+operator<(const Maybe<T>& aLHS, const Maybe<T>& aRHS)
+{
+  if (aLHS.isNothing()) {
+    return aRHS.isSome();
+  }
+  if (aRHS.isNothing()) {
+    return false;
+  }
+  return *aLHS < *aRHS;
+}
+
+template<typename T> bool
+operator>(const Maybe<T>& aLHS, const Maybe<T>& aRHS)
+{
+  return !(aLHS < aRHS || aLHS == aRHS);
+}
+
+template<typename T> bool
+operator<=(const Maybe<T>& aLHS, const Maybe<T>& aRHS)
+{
+  return aLHS < aRHS || aLHS == aRHS;
+}
+
+template<typename T> bool
+operator>=(const Maybe<T>& aLHS, const Maybe<T>& aRHS)
+{
+  return !(aLHS < aRHS);
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_Maybe_h */
diff --git a/src/third_party/mozjs-45/mfbt/MaybeOneOf.h b/src/third_party/mozjs-45/mfbt/MaybeOneOf.h
new file mode 100644
index 0000000..9c38ff8
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/MaybeOneOf.h
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_MaybeOneOf_h
+#define mozilla_MaybeOneOf_h
+
+#include "mozilla/Alignment.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Move.h"
+#include "mozilla/TemplateLib.h"
+
+#include <new>    // For placement new
+
+namespace mozilla {
+
+/*
+ * MaybeOneOf<T1, T2> is like Maybe, but it supports constructing either T1
+ * or T2. When a MaybeOneOf<T1, T2> is constructed, it is |empty()|, i.e.,
+ * no value has been constructed and no destructor will be called when the
+ * MaybeOneOf<T1, T2> is destroyed. Upon calling |construct<T1>()| or
+ * |construct<T2>()|, a T1 or T2 object will be constructed with the given
+ * arguments and that object will be destroyed when the owning MaybeOneOf is
+ * destroyed.
+ */
+template<class T1, class T2>
+class MaybeOneOf
+{
+  AlignedStorage<tl::Max<sizeof(T1), sizeof(T2)>::value> storage;
+
+  enum State { None, SomeT1, SomeT2 } state;
+  template <class T, class Ignored = void> struct Type2State {};
+
+  template <class T>
+  T& as()
+  {
+    MOZ_ASSERT(state == Type2State<T>::result);
+    return *(T*)storage.addr();
+  }
+
+  template <class T>
+  const T& as() const
+  {
+    MOZ_ASSERT(state == Type2State<T>::result);
+    return *(T*)storage.addr();
+  }
+
+public:
+  MaybeOneOf() : state(None) {}
+  ~MaybeOneOf() { destroyIfConstructed(); }
+
+  MaybeOneOf(MaybeOneOf&& rhs)
+    : state(None)
+  {
+    if (!rhs.empty()) {
+      if (rhs.constructed<T1>()) {
+        construct<T1>(Move(rhs.as<T1>()));
+        rhs.as<T1>().~T1();
+      } else {
+        construct<T2>(Move(rhs.as<T2>()));
+        rhs.as<T2>().~T2();
+      }
+      rhs.state = None;
+    }
+  }
+
+  MaybeOneOf &operator=(MaybeOneOf&& rhs)
+  {
+    MOZ_ASSERT(this != &rhs, "Self-move is prohibited");
+    this->~MaybeOneOf();
+    new(this) MaybeOneOf(Move(rhs));
+    return *this;
+  }
+
+  bool empty() const { return state == None; }
+
+  template <class T>
+  bool constructed() const { return state == Type2State<T>::result; }
+
+  template <class T, class... Args>
+  void construct(Args&&... aArgs)
+  {
+    MOZ_ASSERT(state == None);
+    state = Type2State<T>::result;
+    ::new (storage.addr()) T(Forward<Args>(aArgs)...);
+  }
+
+  template <class T>
+  T& ref()
+  {
+    return as<T>();
+  }
+
+  template <class T>
+  const T& ref() const
+  {
+    return as<T>();
+  }
+
+  void destroy()
+  {
+    MOZ_ASSERT(state == SomeT1 || state == SomeT2);
+    if (state == SomeT1) {
+      as<T1>().~T1();
+    } else if (state == SomeT2) {
+      as<T2>().~T2();
+    }
+    state = None;
+  }
+
+  void destroyIfConstructed()
+  {
+    if (!empty()) {
+      destroy();
+    }
+  }
+
+private:
+  MaybeOneOf(const MaybeOneOf& aOther) = delete;
+  const MaybeOneOf& operator=(const MaybeOneOf& aOther) = delete;
+};
+
+template <class T1, class T2>
+template <class Ignored>
+struct MaybeOneOf<T1, T2>::Type2State<T1, Ignored>
+{
+  typedef MaybeOneOf<T1, T2> Enclosing;
+  static const typename Enclosing::State result = Enclosing::SomeT1;
+};
+
+template <class T1, class T2>
+template <class Ignored>
+struct MaybeOneOf<T1, T2>::Type2State<T2, Ignored>
+{
+  typedef MaybeOneOf<T1, T2> Enclosing;
+  static const typename Enclosing::State result = Enclosing::SomeT2;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_MaybeOneOf_h */
diff --git a/src/third_party/mozjs-45/mfbt/MemoryChecking.h b/src/third_party/mozjs-45/mfbt/MemoryChecking.h
new file mode 100644
index 0000000..ff42d7f
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/MemoryChecking.h
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Provides a common interface to the ASan (AddressSanitizer) and Valgrind
+ * functions used to mark memory in certain ways. In detail, the following
+ * three macros are provided:
+ *
+ *   MOZ_MAKE_MEM_NOACCESS  - Mark memory as unsafe to access (e.g. freed)
+ *   MOZ_MAKE_MEM_UNDEFINED - Mark memory as accessible, with content undefined
+ *   MOZ_MAKE_MEM_DEFINED - Mark memory as accessible, with content defined
+ *
+ * With Valgrind in use, these directly map to the three respective Valgrind
+ * macros. With ASan in use, the NOACCESS macro maps to poisoning the memory,
+ * while the UNDEFINED/DEFINED macros unpoison memory.
+ *
+ * With no memory checker available, all macros expand to the empty statement.
+ */
+
+#ifndef mozilla_MemoryChecking_h
+#define mozilla_MemoryChecking_h
+
+#if defined(MOZ_VALGRIND)
+#include "valgrind/memcheck.h"
+#endif
+
+#if defined(MOZ_ASAN) || defined(MOZ_VALGRIND)
+#define MOZ_HAVE_MEM_CHECKS 1
+#endif
+
+#if defined(MOZ_ASAN)
+#include <stddef.h>
+
+#include "mozilla/Attributes.h"
+#include "mozilla/Types.h"
+
+#ifdef _MSC_VER
+// In clang-cl based ASAN, we link against the memory poisoning functions
+// statically.
+#define MOZ_ASAN_VISIBILITY
+#else
+#define MOZ_ASAN_VISIBILITY MOZ_EXPORT
+#endif
+
+extern "C" {
+/* These definitions are usually provided through the
+ * sanitizer/asan_interface.h header installed by ASan.
+ */
+void MOZ_ASAN_VISIBILITY
+__asan_poison_memory_region(void const volatile *addr, size_t size);
+void MOZ_ASAN_VISIBILITY
+__asan_unpoison_memory_region(void const volatile *addr, size_t size);
+
+#define MOZ_MAKE_MEM_NOACCESS(addr, size) \
+  __asan_poison_memory_region((addr), (size))
+
+#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \
+  __asan_unpoison_memory_region((addr), (size))
+
+#define MOZ_MAKE_MEM_DEFINED(addr, size) \
+  __asan_unpoison_memory_region((addr), (size))
+
+/*
+ * These definitions are usually provided through the
+ * sanitizer/lsan_interface.h header installed by LSan.
+ */
+void MOZ_EXPORT
+__lsan_ignore_object(const void *p);
+
+}
+#elif defined(MOZ_MSAN)
+#include <stddef.h>
+
+#include "mozilla/Types.h"
+
+extern "C" {
+/* These definitions are usually provided through the
+ * sanitizer/msan_interface.h header installed by MSan.
+ */
+void MOZ_EXPORT
+__msan_poison(void const volatile *addr, size_t size);
+void MOZ_EXPORT
+__msan_unpoison(void const volatile *addr, size_t size);
+
+#define MOZ_MAKE_MEM_NOACCESS(addr, size) \
+  __msan_poison((addr), (size))
+
+#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \
+  __msan_poison((addr), (size))
+
+#define MOZ_MAKE_MEM_DEFINED(addr, size) \
+  __msan_unpoison((addr), (size))
+}
+#elif defined(MOZ_VALGRIND)
+#define MOZ_MAKE_MEM_NOACCESS(addr, size) \
+  VALGRIND_MAKE_MEM_NOACCESS((addr), (size))
+
+#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \
+  VALGRIND_MAKE_MEM_UNDEFINED((addr), (size))
+
+#define MOZ_MAKE_MEM_DEFINED(addr, size) \
+  VALGRIND_MAKE_MEM_DEFINED((addr), (size))
+#else
+
+#define MOZ_MAKE_MEM_NOACCESS(addr, size) do {} while (0)
+#define MOZ_MAKE_MEM_UNDEFINED(addr, size) do {} while (0)
+#define MOZ_MAKE_MEM_DEFINED(addr, size) do {} while (0)
+
+#endif
+
+/*
+ * MOZ_LSAN_INTENTIONAL_LEAK(X) is a macro to tell LeakSanitizer that X
+ * points to a value that will intentionally never be deallocated during
+ * the execution of the process.
+ *
+ * Additional uses of this macro should be reviewed by people
+ * conversant in leak-checking and/or MFBT peers.
+ */
+#if defined(MOZ_ASAN)
+#  define MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(X) __lsan_ignore_object(X)
+#else
+#  define MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(X) /* nothing */
+#endif // defined(MOZ_ASAN)
+
+
+#endif /* mozilla_MemoryChecking_h */
diff --git a/src/third_party/mozjs-45/mfbt/MemoryReporting.h b/src/third_party/mozjs-45/mfbt/MemoryReporting.h
new file mode 100644
index 0000000..d2340ec
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/MemoryReporting.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Memory reporting infrastructure. */
+
+#ifndef mozilla_MemoryReporting_h
+#define mozilla_MemoryReporting_h
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+
+namespace mozilla {
+
+/*
+ * This is for functions that are like malloc_usable_size.  Such functions are
+ * used for measuring the size of data structures.
+ */
+typedef size_t (*MallocSizeOf)(const void* p);
+
+} /* namespace mozilla */
+
+#endif /* __cplusplus */
+
+typedef size_t (*MozMallocSizeOf)(const void* p);
+
+#endif /* mozilla_MemoryReporting_h */
diff --git a/src/third_party/mozjs-45/mfbt/Move.h b/src/third_party/mozjs-45/mfbt/Move.h
new file mode 100644
index 0000000..f6d0bfc
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Move.h
@@ -0,0 +1,238 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* C++11-style, but C++98-usable, "move references" implementation. */
+
+#ifndef mozilla_Move_h
+#define mozilla_Move_h
+
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+/*
+ * "Move" References
+ *
+ * Some types can be copied much more efficiently if we know the original's
+ * value need not be preserved --- that is, if we are doing a "move", not a
+ * "copy". For example, if we have:
+ *
+ *   Vector<T> u;
+ *   Vector<T> v(u);
+ *
+ * the constructor for v must apply a copy constructor to each element of u ---
+ * taking time linear in the length of u. However, if we know we will not need u
+ * any more once v has been initialized, then we could initialize v very
+ * efficiently simply by stealing u's dynamically allocated buffer and giving it
+ * to v --- a constant-time operation, regardless of the size of u.
+ *
+ * Moves often appear in container implementations. For example, when we append
+ * to a vector, we may need to resize its buffer. This entails moving each of
+ * its extant elements from the old, smaller buffer to the new, larger buffer.
+ * But once the elements have been migrated, we're just going to throw away the
+ * old buffer; we don't care if they still have their values. So if the vector's
+ * element type can implement "move" more efficiently than "copy", the vector
+ * resizing should by all means use a "move" operation. Hash tables should also
+ * use moves when resizing their internal array as entries are added and
+ * removed.
+ *
+ * The details of the optimization, and whether it's worth applying, vary
+ * from one type to the next: copying an 'int' is as cheap as moving it, so
+ * there's no benefit in distinguishing 'int' moves from copies. And while
+ * some constructor calls for complex types are moves, many really have to
+ * be copies, and can't be optimized this way. So we need:
+ *
+ * 1) a way for a type (like Vector) to announce that it can be moved more
+ *    efficiently than it can be copied, and provide an implementation of that
+ *    move operation; and
+ *
+ * 2) a way for a particular invocation of a copy constructor to say that it's
+ *    really a move, not a copy, and that the value of the original isn't
+ *    important afterwards (although it must still be safe to destroy).
+ *
+ * If a constructor has a single argument of type 'T&&' (an 'rvalue reference
+ * to T'), that indicates that it is a 'move constructor'. That's 1). It should
+ * move, not copy, its argument into the object being constructed. It may leave
+ * the original in any safely-destructible state.
+ *
+ * If a constructor's argument is an rvalue, as in 'C(f(x))' or 'C(x + y)', as
+ * opposed to an lvalue, as in 'C(x)', then overload resolution will prefer the
+ * move constructor, if there is one. The 'mozilla::Move' function, defined in
+ * this file, is an identity function you can use in a constructor invocation to
+ * make any argument into an rvalue, like this: C(Move(x)). That's 2). (You
+ * could use any function that works, but 'Move' indicates your intention
+ * clearly.)
+ *
+ * Where we might define a copy constructor for a class C like this:
+ *
+ *   C(const C& rhs) { ... copy rhs to this ... }
+ *
+ * we would declare a move constructor like this:
+ *
+ *   C(C&& rhs) { .. move rhs to this ... }
+ *
+ * And where we might perform a copy like this:
+ *
+ *   C c2(c1);
+ *
+ * we would perform a move like this:
+ *
+ *   C c2(Move(c1));
+ *
+ * Note that 'T&&' implicitly converts to 'T&'. So you can pass a 'T&&' to an
+ * ordinary copy constructor for a type that doesn't support a special move
+ * constructor, and you'll just get a copy. This means that templates can use
+ * Move whenever they know they won't use the original value any more, even if
+ * they're not sure whether the type at hand has a specialized move constructor.
+ * If it doesn't, the 'T&&' will just convert to a 'T&', and the ordinary copy
+ * constructor will apply.
+ *
+ * A class with a move constructor can also provide a move assignment operator.
+ * A generic definition would run this's destructor, and then apply the move
+ * constructor to *this's memory. A typical definition:
+ *
+ *   C& operator=(C&& rhs) {
+ *     MOZ_ASSERT(&rhs != this, "self-moves are prohibited");
+ *     this->~C();
+ *     new(this) C(Move(rhs));
+ *     return *this;
+ *   }
+ *
+ * With that in place, one can write move assignments like this:
+ *
+ *   c2 = Move(c1);
+ *
+ * This destroys c2, moves c1's value to c2, and leaves c1 in an undefined but
+ * destructible state.
+ *
+ * As we say, a move must leave the original in a "destructible" state. The
+ * original's destructor will still be called, so if a move doesn't
+ * actually steal all its resources, that's fine. We require only that the
+ * move destination must take on the original's value; and that destructing
+ * the original must not break the move destination.
+ *
+ * (Opinions differ on whether move assignment operators should deal with move
+ * assignment of an object onto itself. It seems wise to either handle that
+ * case, or assert that it does not occur.)
+ *
+ * Forwarding:
+ *
+ * Sometimes we want copy construction or assignment if we're passed an ordinary
+ * value, but move construction if passed an rvalue reference. For example, if
+ * our constructor takes two arguments and either could usefully be a move, it
+ * seems silly to write out all four combinations:
+ *
+ *   C::C(X&  x, Y&  y) : x(x),       y(y)       { }
+ *   C::C(X&  x, Y&& y) : x(x),       y(Move(y)) { }
+ *   C::C(X&& x, Y&  y) : x(Move(x)), y(y)       { }
+ *   C::C(X&& x, Y&& y) : x(Move(x)), y(Move(y)) { }
+ *
+ * To avoid this, C++11 has tweaks to make it possible to write what you mean.
+ * The four constructor overloads above can be written as one constructor
+ * template like so[0]:
+ *
+ *   template <typename XArg, typename YArg>
+ *   C::C(XArg&& x, YArg&& y) : x(Forward<XArg>(x)), y(Forward<YArg>(y)) { }
+ *
+ * ("'Don't Repeat Yourself'? What's that?")
+ *
+ * This takes advantage of two new rules in C++11:
+ *
+ * - First, when a function template takes an argument that is an rvalue
+ *   reference to a template argument (like 'XArg&& x' and 'YArg&& y' above),
+ *   then when the argument is applied to an lvalue, the template argument
+ *   resolves to 'T&'; and when it is applied to an rvalue, the template
+ *   argument resolves to 'T'. Thus, in a call to C::C like:
+ *
+ *      X foo(int);
+ *      Y yy;
+ *
+ *      C(foo(5), yy)
+ *
+ *   XArg would resolve to 'X', and YArg would resolve to 'Y&'.
+ *
+ * - Second, Whereas C++ used to forbid references to references, C++11 defines
+ *   'collapsing rules': 'T& &', 'T&& &', and 'T& &&' (that is, any combination
+ *   involving an lvalue reference) now collapse to simply 'T&'; and 'T&& &&'
+ *   collapses to 'T&&'.
+ *
+ *   Thus, in the call above, 'XArg&&' is 'X&&'; and 'YArg&&' is 'Y& &&', which
+ *   collapses to 'Y&'. Because the arguments are declared as rvalue references
+ *   to template arguments, the lvalue-ness "shines through" where present.
+ *
+ * Then, the 'Forward<T>' function --- you must invoke 'Forward' with its type
+ * argument --- returns an lvalue reference or an rvalue reference to its
+ * argument, depending on what T is. In our unified constructor definition, that
+ * means that we'll invoke either the copy or move constructors for x and y,
+ * depending on what we gave C's constructor. In our call, we'll move 'foo()'
+ * into 'x', but copy 'yy' into 'y'.
+ *
+ * This header file defines Move and Forward in the mozilla namespace. It's up
+ * to individual containers to annotate moves as such, by calling Move; and it's
+ * up to individual types to define move constructors and assignment operators
+ * when valuable.
+ *
+ * (C++11 says that the <utility> header file should define 'std::move' and
+ * 'std::forward', which are just like our 'Move' and 'Forward'; but those
+ * definitions aren't available in that header on all our platforms, so we
+ * define them ourselves here.)
+ *
+ * 0. This pattern is known as "perfect forwarding".  Interestingly, it is not
+ *    actually perfect, and it can't forward all possible argument expressions!
+ *    There is a C++11 issue: you can't form a reference to a bit-field.  As a
+ *    workaround, assign the bit-field to a local variable and use that:
+ *
+ *      // C is as above
+ *      struct S { int x : 1; } s;
+ *      C(s.x, 0); // BAD: s.x is a reference to a bit-field, can't form those
+ *      int tmp = s.x;
+ *      C(tmp, 0); // OK: tmp not a bit-field
+ */
+
+/**
+ * Identical to std::Move(); this is necessary until our stlport supports
+ * std::move().
+ */
+template<typename T>
+inline typename RemoveReference<T>::Type&&
+Move(T&& aX)
+{
+  return static_cast<typename RemoveReference<T>::Type&&>(aX);
+}
+
+/**
+ * These two overloads are identical to std::forward(); they are necessary until
+ * our stlport supports std::forward().
+ */
+template<typename T>
+inline T&&
+Forward(typename RemoveReference<T>::Type& aX)
+{
+  return static_cast<T&&>(aX);
+}
+
+template<typename T>
+inline T&&
+Forward(typename RemoveReference<T>::Type&& aX)
+{
+  static_assert(!IsLvalueReference<T>::value,
+                "misuse of Forward detected!  try the other overload");
+  return static_cast<T&&>(aX);
+}
+
+/** Swap |aX| and |aY| using move-construction if possible. */
+template<typename T>
+inline void
+Swap(T& aX, T& aY)
+{
+  T tmp(Move(aX));
+  aX = Move(aY);
+  aY = Move(tmp);
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_Move_h */
diff --git a/src/third_party/mozjs-45/mfbt/NullPtr.h b/src/third_party/mozjs-45/mfbt/NullPtr.h
new file mode 100644
index 0000000..d2248f4
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/NullPtr.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implements a mozilla::IsNullPointer<T> type trait. */
+
+#ifndef mozilla_NullPtr_h
+#define mozilla_NullPtr_h
+
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+/**
+ * IsNullPointer<T>::value is true iff T is decltype(nullptr).
+ *
+ * Ideally this would be in TypeTraits.h, but C++11 omitted std::is_null_pointer
+ * (fixed in C++14), so in the interests of easing a switch to <type_traits>,
+ * this trait lives elsewhere.
+ */
+template<typename T>
+struct IsNullPointer : FalseType {};
+
+template<>
+struct IsNullPointer<decltype(nullptr)> : TrueType {};
+
+} // namespace mozilla
+
+#endif /* mozilla_NullPtr_h */
diff --git a/src/third_party/mozjs-45/mfbt/NumericLimits.h b/src/third_party/mozjs-45/mfbt/NumericLimits.h
new file mode 100644
index 0000000..730fcb4
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/NumericLimits.h
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Compatibility with std::numeric_limits<char16_t>. */
+
+#ifndef mozilla_NumericLimits_h
+#define mozilla_NumericLimits_h
+
+#include "mozilla/Char16.h"
+
+#include <limits>
+#include <stdint.h>
+
+namespace mozilla {
+
+/**
+ * The NumericLimits class provides a compatibility layer with
+ * std::numeric_limits for char16_t, otherwise it is exactly the same as
+ * std::numeric_limits.  Code which does not need std::numeric_limits<char16_t>
+ * should avoid using NumericLimits.
+ */
+template<typename T>
+class NumericLimits : public std::numeric_limits<T>
+{
+};
+
+#ifdef MOZ_CHAR16_IS_NOT_WCHAR
+template<>
+class NumericLimits<char16_t> : public std::numeric_limits<uint16_t>
+{
+  // char16_t and uint16_t numeric limits should be exactly the same.
+};
+#endif
+
+} // namespace mozilla
+
+#endif /* mozilla_NumericLimits_h */
diff --git a/src/third_party/mozjs-45/mfbt/Opaque.h b/src/third_party/mozjs-45/mfbt/Opaque.h
new file mode 100644
index 0000000..d7239ee
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Opaque.h
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* An opaque integral type supporting only comparison operators. */
+
+#ifndef mozilla_Opaque_h
+#define mozilla_Opaque_h
+
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+/**
+ * Opaque<T> is a replacement for integral T in cases where only comparisons
+ * must be supported, and it's desirable to prevent accidental dependency on
+ * exact values.
+ */
+template<typename T>
+class Opaque final
+{
+  static_assert(mozilla::IsIntegral<T>::value,
+                "mozilla::Opaque only supports integral types");
+
+  T mValue;
+
+public:
+  Opaque() {}
+  explicit Opaque(T aValue) : mValue(aValue) {}
+
+  bool operator==(const Opaque& aOther) const {
+    return mValue == aOther.mValue;
+  }
+
+  bool operator!=(const Opaque& aOther) const {
+    return !(*this == aOther);
+  }
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_Opaque_h */
diff --git a/src/third_party/mozjs-45/mfbt/Pair.h b/src/third_party/mozjs-45/mfbt/Pair.h
new file mode 100644
index 0000000..ad7b86a
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Pair.h
@@ -0,0 +1,219 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A class holding a pair of objects that tries to conserve storage space. */
+
+#ifndef mozilla_Pair_h
+#define mozilla_Pair_h
+
+#include "mozilla/Attributes.h"
+#include "mozilla/Move.h"
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+namespace detail {
+
+enum StorageType { AsBase, AsMember };
+
+// Optimize storage using the Empty Base Optimization -- that empty base classes
+// don't take up space -- to optimize size when one or the other class is
+// stateless and can be used as a base class.
+//
+// The extra conditions on storage for B are necessary so that PairHelper won't
+// ambiguously inherit from either A or B, such that one or the other base class
+// would be inaccessible.
+template<typename A, typename B,
+         detail::StorageType =
+           IsEmpty<A>::value ? detail::AsBase : detail::AsMember,
+         detail::StorageType =
+           IsEmpty<B>::value && !IsBaseOf<A, B>::value && !IsBaseOf<B, A>::value
+           ? detail::AsBase
+           : detail::AsMember>
+struct PairHelper;
+
+template<typename A, typename B>
+struct PairHelper<A, B, AsMember, AsMember>
+{
+protected:
+  template<typename AArg, typename BArg>
+  PairHelper(AArg&& aA, BArg&& aB)
+    : mFirstA(Forward<AArg>(aA)),
+      mSecondB(Forward<BArg>(aB))
+  {}
+
+  A& first() { return mFirstA; }
+  const A& first() const { return mFirstA; }
+  B& second() { return mSecondB; }
+  const B& second() const { return mSecondB; }
+
+  void swap(PairHelper& aOther)
+  {
+    Swap(mFirstA, aOther.mFirstA);
+    Swap(mSecondB, aOther.mSecondB);
+  }
+
+private:
+  A mFirstA;
+  B mSecondB;
+};
+
+template<typename A, typename B>
+struct PairHelper<A, B, AsMember, AsBase> : private B
+{
+protected:
+  template<typename AArg, typename BArg>
+  PairHelper(AArg&& aA, BArg&& aB)
+    : B(Forward<BArg>(aB)),
+      mFirstA(Forward<AArg>(aA))
+  {}
+
+  A& first() { return mFirstA; }
+  const A& first() const { return mFirstA; }
+  B& second() { return *this; }
+  const B& second() const { return *this; }
+
+  void swap(PairHelper& aOther)
+  {
+    Swap(mFirstA, aOther.mFirstA);
+    Swap(static_cast<B&>(*this), static_cast<B&>(aOther));
+  }
+
+private:
+  A mFirstA;
+};
+
+template<typename A, typename B>
+struct PairHelper<A, B, AsBase, AsMember> : private A
+{
+protected:
+  template<typename AArg, typename BArg>
+  PairHelper(AArg&& aA, BArg&& aB)
+    : A(Forward<AArg>(aA)),
+      mSecondB(Forward<BArg>(aB))
+  {}
+
+  A& first() { return *this; }
+  const A& first() const { return *this; }
+  B& second() { return mSecondB; }
+  const B& second() const { return mSecondB; }
+
+  void swap(PairHelper& aOther)
+  {
+    Swap(static_cast<A&>(*this), static_cast<A&>(aOther));
+    Swap(mSecondB, aOther.mSecondB);
+  }
+
+private:
+  B mSecondB;
+};
+
+template<typename A, typename B>
+struct PairHelper<A, B, AsBase, AsBase> : private A, private B
+{
+protected:
+  template<typename AArg, typename BArg>
+  PairHelper(AArg&& aA, BArg&& aB)
+    : A(Forward<AArg>(aA)),
+      B(Forward<BArg>(aB))
+  {}
+
+  A& first() { return static_cast<A&>(*this); }
+  const A& first() const { return static_cast<A&>(*this); }
+  B& second() { return static_cast<B&>(*this); }
+  const B& second() const { return static_cast<B&>(*this); }
+
+  void swap(PairHelper& aOther)
+  {
+    Swap(static_cast<A&>(*this), static_cast<A&>(aOther));
+    Swap(static_cast<B&>(*this), static_cast<B&>(aOther));
+  }
+};
+
+} // namespace detail
+
+/**
+ * Pair is the logical concatenation of an instance of A with an instance B.
+ * Space is conserved when possible.  Neither A nor B may be a final class.
+ *
+ * It's typically clearer to have individual A and B member fields.  Except if
+ * you want the space-conserving qualities of Pair, you're probably better off
+ * not using this!
+ *
+ * No guarantees are provided about the memory layout of A and B, the order of
+ * initialization or destruction of A and B, and so on.  (This is approximately
+ * required to optimize space usage.)  The first/second names are merely
+ * conceptual!
+ */
+template<typename A, typename B>
+struct Pair
+  : private detail::PairHelper<A, B>
+{
+  typedef typename detail::PairHelper<A, B> Base;
+
+public:
+  template<typename AArg, typename BArg>
+  Pair(AArg&& aA, BArg&& aB)
+    : Base(Forward<AArg>(aA), Forward<BArg>(aB))
+  {}
+
+  Pair(Pair&& aOther)
+    : Base(Move(aOther.first()), Move(aOther.second()))
+  { }
+
+  Pair(const Pair& aOther) = default;
+
+  Pair& operator=(Pair&& aOther)
+  {
+    MOZ_ASSERT(this != &aOther, "Self-moves are prohibited");
+
+    first() = Move(aOther.first());
+    second() = Move(aOther.second());
+
+    return *this;
+  }
+
+  Pair& operator=(const Pair& aOther) = default;
+
+  /** The A instance. */
+  using Base::first;
+  /** The B instance. */
+  using Base::second;
+
+  /** Swap this pair with another pair. */
+  void swap(Pair& aOther) { Base::swap(aOther); }
+};
+
+template<typename A, class B>
+void
+Swap(Pair<A, B>& aX, Pair<A, B>& aY)
+{
+  aX.swap(aY);
+}
+
+/**
+ * MakePair allows you to construct a Pair instance using type inference. A call
+ * like this:
+ *
+ *   MakePair(Foo(), Bar())
+ *
+ * will return a Pair<Foo, Bar>.
+ */
+template<typename A, typename B>
+Pair<typename RemoveCV<typename RemoveReference<A>::Type>::Type,
+     typename RemoveCV<typename RemoveReference<B>::Type>::Type>
+MakePair(A&& aA, B&& aB)
+{
+  return
+    Pair<typename RemoveCV<typename RemoveReference<A>::Type>::Type,
+         typename RemoveCV<typename RemoveReference<B>::Type>::Type>(
+             Forward<A>(aA),
+             Forward<B>(aB));
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_Pair_h */
diff --git a/src/third_party/mozjs-45/mfbt/PodOperations.h b/src/third_party/mozjs-45/mfbt/PodOperations.h
new file mode 100644
index 0000000..e6f4df2
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/PodOperations.h
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Operations for zeroing POD types, arrays, and so on.
+ *
+ * These operations are preferable to memset, memcmp, and the like because they
+ * don't require remembering to multiply by sizeof(T), array lengths, and so on
+ * everywhere.
+ */
+
+#ifndef mozilla_PodOperations_h
+#define mozilla_PodOperations_h
+
+#include "mozilla/Array.h"
+#include "mozilla/ArrayUtils.h"
+#include "mozilla/Attributes.h"
+
+#include <stdint.h>
+#include <string.h>
+
+namespace mozilla {
+
+/** Set the contents of |aT| to 0. */
+template<typename T>
+static MOZ_ALWAYS_INLINE void
+PodZero(T* aT)
+{
+  memset(aT, 0, sizeof(T));
+}
+
+/** Set the contents of |aNElem| elements starting at |aT| to 0. */
+template<typename T>
+static MOZ_ALWAYS_INLINE void
+PodZero(T* aT, size_t aNElem)
+{
+  /*
+   * This function is often called with 'aNElem' small; we use an inline loop
+   * instead of calling 'memset' with a non-constant length.  The compiler
+   * should inline the memset call with constant size, though.
+   */
+  for (T* end = aT + aNElem; aT < end; aT++) {
+    memset(aT, 0, sizeof(T));
+  }
+}
+
+/*
+ * Arrays implicitly convert to pointers to their first element, which is
+ * dangerous when combined with the above PodZero definitions.  Adding an
+ * overload for arrays is ambiguous, so we need another identifier.  The
+ * ambiguous overload is left to catch mistaken uses of PodZero; if you get a
+ * compile error involving PodZero and array types, use PodArrayZero instead.
+ */
+template<typename T, size_t N>
+static void PodZero(T (&aT)[N]) = delete;
+template<typename T, size_t N>
+static void PodZero(T (&aT)[N], size_t aNElem) = delete;
+
+/** Set the contents of the array |aT| to zero. */
+template <class T, size_t N>
+static MOZ_ALWAYS_INLINE void
+PodArrayZero(T (&aT)[N])
+{
+  memset(aT, 0, N * sizeof(T));
+}
+
+template <typename T, size_t N>
+static MOZ_ALWAYS_INLINE void
+PodArrayZero(Array<T, N>& aArr)
+{
+  memset(&aArr[0], 0, N * sizeof(T));
+}
+
+/**
+ * Assign |*aSrc| to |*aDst|.  The locations must not be the same and must not
+ * overlap.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE void
+PodAssign(T* aDst, const T* aSrc)
+{
+  MOZ_ASSERT(aDst + 1 <= aSrc || aSrc + 1 <= aDst,
+             "destination and source must not overlap");
+  memcpy(reinterpret_cast<char*>(aDst), reinterpret_cast<const char*>(aSrc),
+         sizeof(T));
+}
+
+/**
+ * Copy |aNElem| T elements from |aSrc| to |aDst|.  The two memory ranges must
+ * not overlap!
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE void
+PodCopy(T* aDst, const T* aSrc, size_t aNElem)
+{
+  MOZ_ASSERT(aDst + aNElem <= aSrc || aSrc + aNElem <= aDst,
+             "destination and source must not overlap");
+  if (aNElem < 128) {
+    /*
+     * Avoid using operator= in this loop, as it may have been
+     * intentionally deleted by the POD type.
+     */
+    for (const T* srcend = aSrc + aNElem; aSrc < srcend; aSrc++, aDst++) {
+      PodAssign(aDst, aSrc);
+    }
+  } else {
+    memcpy(aDst, aSrc, aNElem * sizeof(T));
+  }
+}
+
+template<typename T>
+static MOZ_ALWAYS_INLINE void
+PodCopy(volatile T* aDst, const volatile T* aSrc, size_t aNElem)
+{
+  MOZ_ASSERT(aDst + aNElem <= aSrc || aSrc + aNElem <= aDst,
+             "destination and source must not overlap");
+
+  /*
+   * Volatile |aDst| requires extra work, because it's undefined behavior to
+   * modify volatile objects using the mem* functions.  Just write out the
+   * loops manually, using operator= rather than memcpy for the same reason,
+   * and let the compiler optimize to the extent it can.
+   */
+  for (const volatile T* srcend = aSrc + aNElem;
+       aSrc < srcend;
+       aSrc++, aDst++) {
+    *aDst = *aSrc;
+  }
+}
+
+/*
+ * Copy the contents of the array |aSrc| into the array |aDst|, both of size N.
+ * The arrays must not overlap!
+ */
+template <class T, size_t N>
+static MOZ_ALWAYS_INLINE void
+PodArrayCopy(T (&aDst)[N], const T (&aSrc)[N])
+{
+  PodCopy(aDst, aSrc, N);
+}
+
+/**
+ * Copy the memory for |aNElem| T elements from |aSrc| to |aDst|.  If the two
+ * memory ranges overlap, then the effect is as if the |aNElem| elements are
+ * first copied from |aSrc| to a temporary array, and then from the temporary
+ * array to |aDst|.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE void
+PodMove(T* aDst, const T* aSrc, size_t aNElem)
+{
+  MOZ_ASSERT(aNElem <= SIZE_MAX / sizeof(T),
+             "trying to move an impossible number of elements");
+  memmove(aDst, aSrc, aNElem * sizeof(T));
+}
+
+/**
+ * Determine whether the |len| elements at |one| are memory-identical to the
+ * |len| elements at |two|.
+ */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+PodEqual(const T* one, const T* two, size_t len)
+{
+  if (len < 128) {
+    const T* p1end = one + len;
+    const T* p1 = one;
+    const T* p2 = two;
+    for (; p1 < p1end; p1++, p2++) {
+      if (*p1 != *p2) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  return !memcmp(one, two, len * sizeof(T));
+}
+
+/*
+ * Determine whether the |N| elements at |one| are memory-identical to the
+ * |N| elements at |two|.
+ */
+template <class T, size_t N>
+static MOZ_ALWAYS_INLINE bool
+PodEqual(const T (&one)[N], const T (&two)[N])
+{
+  return PodEqual(one, two, N);
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_PodOperations_h */
diff --git a/src/third_party/mozjs-45/mfbt/Poison.cpp b/src/third_party/mozjs-45/mfbt/Poison.cpp
new file mode 100644
index 0000000..1e1c3f2
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Poison.cpp
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * A poison value that can be used to fill a memory space with
+ * an address that leads to a safe crash when dereferenced.
+ */
+
+#include "mozilla/Poison.h"
+
+#include "mozilla/Assertions.h"
+#ifdef _WIN32
+# include <windows.h>
+#elif !defined(__OS2__)
+# include <unistd.h>
+# include <sys/mman.h>
+# ifndef MAP_ANON
+#  ifdef MAP_ANONYMOUS
+#   define MAP_ANON MAP_ANONYMOUS
+#  else
+#   error "Don't know how to get anonymous memory"
+#  endif
+# endif
+#endif
+
+extern "C" {
+uintptr_t gMozillaPoisonValue;
+uintptr_t gMozillaPoisonBase;
+uintptr_t gMozillaPoisonSize;
+}
+
+// Freed memory is filled with a poison value, which we arrange to
+// form a pointer either to an always-unmapped region of the address
+// space, or to a page that has been reserved and rendered
+// inaccessible via OS primitives.  See tests/TestPoisonArea.cpp for
+// extensive discussion of the requirements for this page.  The code
+// from here to 'class FreeList' needs to be kept in sync with that
+// file.
+
+#ifdef _WIN32
+static void*
+ReserveRegion(uintptr_t aRegion, uintptr_t aSize)
+{
+  return VirtualAlloc((void*)aRegion, aSize, MEM_RESERVE, PAGE_NOACCESS);
+}
+
+static void
+ReleaseRegion(void* aRegion, uintptr_t aSize)
+{
+  VirtualFree(aRegion, aSize, MEM_RELEASE);
+}
+
+static bool
+ProbeRegion(uintptr_t aRegion, uintptr_t aSize)
+{
+  SYSTEM_INFO sinfo;
+  GetSystemInfo(&sinfo);
+  if (aRegion >= (uintptr_t)sinfo.lpMaximumApplicationAddress &&
+      aRegion + aSize >= (uintptr_t)sinfo.lpMaximumApplicationAddress) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+static uintptr_t
+GetDesiredRegionSize()
+{
+  SYSTEM_INFO sinfo;
+  GetSystemInfo(&sinfo);
+  return sinfo.dwAllocationGranularity;
+}
+
+#define RESERVE_FAILED 0
+
+#elif defined(__OS2__)
+static void*
+ReserveRegion(uintptr_t aRegion, uintptr_t aSize)
+{
+  // OS/2 doesn't support allocation at an arbitrary address,
+  // so return an address that is known to be invalid.
+  return (void*)0xFFFD0000;
+}
+
+static void
+ReleaseRegion(void* aRegion, uintptr_t aSize)
+{
+  return;
+}
+
+static bool
+ProbeRegion(uintptr_t aRegion, uintptr_t aSize)
+{
+  // There's no reliable way to probe an address in the system
+  // arena other than by touching it and seeing if a trap occurs.
+  return false;
+}
+
+static uintptr_t
+GetDesiredRegionSize()
+{
+  // Page size is fixed at 4k.
+  return 0x1000;
+}
+
+#define RESERVE_FAILED 0
+
+#else // Unix
+
+#include "mozilla/TaggedAnonymousMemory.h"
+
+static void*
+ReserveRegion(uintptr_t aRegion, uintptr_t aSize)
+{
+  return MozTaggedAnonymousMmap(reinterpret_cast<void*>(aRegion), aSize,
+                                PROT_NONE, MAP_PRIVATE|MAP_ANON, -1, 0,
+                                "poison");
+}
+
+static void
+ReleaseRegion(void* aRegion, uintptr_t aSize)
+{
+  munmap(aRegion, aSize);
+}
+
+static bool
+ProbeRegion(uintptr_t aRegion, uintptr_t aSize)
+{
+  if (madvise(reinterpret_cast<void*>(aRegion), aSize, MADV_NORMAL)) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+static uintptr_t
+GetDesiredRegionSize()
+{
+  return sysconf(_SC_PAGESIZE);
+}
+
+#define RESERVE_FAILED MAP_FAILED
+
+#endif // system dependencies
+
+static_assert(sizeof(uintptr_t) == 4 || sizeof(uintptr_t) == 8, "");
+static_assert(sizeof(uintptr_t) == sizeof(void*), "");
+
+static uintptr_t
+ReservePoisonArea(uintptr_t rgnsize)
+{
+  if (sizeof(uintptr_t) == 8) {
+    // Use the hardware-inaccessible region.
+    // We have to avoid 64-bit constants and shifts by 32 bits, since this
+    // code is compiled in 32-bit mode, although it is never executed there.
+    return
+      (((uintptr_t(0x7FFFFFFFu) << 31) << 1 | uintptr_t(0xF0DEAFFFu))
+       & ~(rgnsize-1));
+  }
+
+  // First see if we can allocate the preferred poison address from the OS.
+  uintptr_t candidate = (0xF0DEAFFF & ~(rgnsize-1));
+  void* result = ReserveRegion(candidate, rgnsize);
+  if (result == (void*)candidate) {
+    // success - inaccessible page allocated
+    return candidate;
+  }
+
+  // That didn't work, so see if the preferred address is within a range
+  // of permanently inacessible memory.
+  if (ProbeRegion(candidate, rgnsize)) {
+    // success - selected page cannot be usable memory
+    if (result != RESERVE_FAILED) {
+      ReleaseRegion(result, rgnsize);
+    }
+    return candidate;
+  }
+
+  // The preferred address is already in use.  Did the OS give us a
+  // consolation prize?
+  if (result != RESERVE_FAILED) {
+    return uintptr_t(result);
+  }
+
+  // It didn't, so try to allocate again, without any constraint on
+  // the address.
+  result = ReserveRegion(0, rgnsize);
+  if (result != RESERVE_FAILED) {
+    return uintptr_t(result);
+  }
+
+  // no usable poison region identified
+  MOZ_CRASH();
+  return 0;
+}
+
+void
+mozPoisonValueInit()
+{
+  gMozillaPoisonSize = GetDesiredRegionSize();
+  gMozillaPoisonBase = ReservePoisonArea(gMozillaPoisonSize);
+
+  if (gMozillaPoisonSize == 0) { // can't happen
+    return;
+  }
+  gMozillaPoisonValue = gMozillaPoisonBase + gMozillaPoisonSize / 2 - 1;
+}
diff --git a/src/third_party/mozjs-45/mfbt/Poison.h b/src/third_party/mozjs-45/mfbt/Poison.h
new file mode 100644
index 0000000..75e0f08
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Poison.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * A poison value that can be used to fill a memory space with
+ * an address that leads to a safe crash when dereferenced.
+ */
+
+#ifndef mozilla_Poison_h
+#define mozilla_Poison_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Types.h"
+
+#include <stdint.h>
+
+MOZ_BEGIN_EXTERN_C
+
+extern MFBT_DATA uintptr_t gMozillaPoisonValue;
+
+/**
+ * @return the poison value.
+ */
+inline uintptr_t mozPoisonValue()
+{
+  return gMozillaPoisonValue;
+}
+
+/**
+ * Overwrite the memory block of aSize bytes at aPtr with the poison value.
+ * aPtr MUST be aligned at a sizeof(uintptr_t) boundary.
+ * Only an even number of sizeof(uintptr_t) bytes are overwritten, the last
+ * few bytes (if any) is not overwritten.
+ */
+inline void mozWritePoison(void* aPtr, size_t aSize)
+{
+  const uintptr_t POISON = mozPoisonValue();
+  char* p = (char*)aPtr;
+  char* limit = p + aSize;
+  MOZ_ASSERT((uintptr_t)aPtr % sizeof(uintptr_t) == 0, "bad alignment");
+  MOZ_ASSERT(aSize >= sizeof(uintptr_t), "poisoning this object has no effect");
+  for (; p < limit; p += sizeof(uintptr_t)) {
+    *((uintptr_t*)p) = POISON;
+  }
+}
+
+/**
+ * Initialize the poison value.
+ * This should only be called once.
+ */
+extern MFBT_API void mozPoisonValueInit();
+
+/* Values annotated by CrashReporter */
+extern MFBT_DATA uintptr_t gMozillaPoisonBase;
+extern MFBT_DATA uintptr_t gMozillaPoisonSize;
+
+MOZ_END_EXTERN_C
+
+#endif /* mozilla_Poison_h */
diff --git a/src/third_party/mozjs-45/mfbt/Range.h b/src/third_party/mozjs-45/mfbt/Range.h
new file mode 100644
index 0000000..149870f
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Range.h
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_Range_h
+#define mozilla_Range_h
+
+#include "mozilla/RangedPtr.h"
+
+#include <stddef.h>
+
+namespace mozilla {
+
+// Range<T> is a tuple containing a pointer and a length.
+template <typename T>
+class Range
+{
+  const RangedPtr<T> mStart;
+  const RangedPtr<T> mEnd;
+
+public:
+  Range() : mStart(nullptr, 0), mEnd(nullptr, 0) {}
+  Range(T* aPtr, size_t aLength)
+    : mStart(aPtr, aPtr, aPtr + aLength),
+      mEnd(aPtr + aLength, aPtr, aPtr + aLength)
+  {}
+
+  RangedPtr<T> start() const { return mStart; }
+  RangedPtr<T> end() const { return mEnd; }
+  size_t length() const { return mEnd - mStart; }
+
+  T& operator[](size_t aOffset) const { return mStart[aOffset]; }
+
+  explicit operator bool() const { return mStart != nullptr; }
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_Range_h */
diff --git a/src/third_party/mozjs-45/mfbt/RangedArray.h b/src/third_party/mozjs-45/mfbt/RangedArray.h
new file mode 100644
index 0000000..afe6267
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/RangedArray.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * A compile-time constant-length array, with bounds-checking assertions -- but
+ * unlike mozilla::Array, with indexes biased by a constant.
+ *
+ * Thus where mozilla::Array<int, 3> is a three-element array indexed by [0, 3),
+ * mozilla::RangedArray<int, 8, 3> is a three-element array indexed by [8, 11).
+ */
+
+#ifndef mozilla_RangedArray_h
+#define mozilla_RangedArray_h
+
+#include "mozilla/Array.h"
+
+namespace mozilla {
+
+template<typename T, size_t MinIndex, size_t Length>
+class RangedArray
+{
+private:
+  typedef Array<T, Length> ArrayType;
+  ArrayType mArr;
+
+public:
+  T& operator[](size_t aIndex)
+  {
+    MOZ_ASSERT(aIndex == MinIndex || aIndex > MinIndex);
+    return mArr[aIndex - MinIndex];
+  }
+
+  const T& operator[](size_t aIndex) const
+  {
+    MOZ_ASSERT(aIndex == MinIndex || aIndex > MinIndex);
+    return mArr[aIndex - MinIndex];
+  }
+
+  typedef typename ArrayType::iterator               iterator;
+  typedef typename ArrayType::const_iterator         const_iterator;
+  typedef typename ArrayType::reverse_iterator       reverse_iterator;
+  typedef typename ArrayType::const_reverse_iterator const_reverse_iterator;
+
+  // Methods for range-based for loops.
+  iterator begin() { return mArr.begin(); }
+  const_iterator begin() const { return mArr.begin(); }
+  const_iterator cbegin() const { return mArr.cbegin(); }
+  iterator end() { return mArr.end(); }
+  const_iterator end() const { return mArr.end(); }
+  const_iterator cend() const { return mArr.cend(); }
+
+  // Methods for reverse iterating.
+  reverse_iterator rbegin() { return mArr.rbegin(); }
+  const_reverse_iterator rbegin() const { return mArr.rbegin(); }
+  const_reverse_iterator crbegin() const { return mArr.crbegin(); }
+  reverse_iterator rend() { return mArr.rend(); }
+  const_reverse_iterator rend() const { return mArr.rend(); }
+  const_reverse_iterator crend() const { return mArr.crend(); }
+};
+
+} // namespace mozilla
+
+#endif // mozilla_RangedArray_h
diff --git a/src/third_party/mozjs-45/mfbt/RangedPtr.h b/src/third_party/mozjs-45/mfbt/RangedPtr.h
new file mode 100644
index 0000000..4071041
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/RangedPtr.h
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Implements a smart pointer asserted to remain within a range specified at
+ * construction.
+ */
+
+#ifndef mozilla_RangedPtr_h
+#define mozilla_RangedPtr_h
+
+#include "mozilla/ArrayUtils.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+
+#include <stdint.h>
+
+namespace mozilla {
+
+/*
+ * RangedPtr is a smart pointer restricted to an address range specified at
+ * creation.  The pointer (and any smart pointers derived from it) must remain
+ * within the range [start, end] (inclusive of end to facilitate use as
+ * sentinels).  Dereferencing or indexing into the pointer (or pointers derived
+ * from it) must remain within the range [start, end).  All the standard pointer
+ * operators are defined on it; in debug builds these operations assert that the
+ * range specified at construction is respected.
+ *
+ * In theory passing a smart pointer instance as an argument can be slightly
+ * slower than passing a T* (due to ABI requirements for passing structs versus
+ * passing pointers), if the method being called isn't inlined.  If you are in
+ * extremely performance-critical code, you may want to be careful using this
+ * smart pointer as an argument type.
+ *
+ * RangedPtr<T> intentionally does not implicitly convert to T*.  Use get() to
+ * explicitly convert to T*.  Keep in mind that the raw pointer of course won't
+ * implement bounds checking in debug builds.
+ */
+template<typename T>
+class RangedPtr
+{
+  T* mPtr;
+
+#ifdef DEBUG
+  T* const mRangeStart;
+  T* const mRangeEnd;
+#endif
+
+  void checkSanity()
+  {
+    MOZ_ASSERT(mRangeStart <= mPtr);
+    MOZ_ASSERT(mPtr <= mRangeEnd);
+  }
+
+  /* Creates a new pointer for |aPtr|, restricted to this pointer's range. */
+  RangedPtr<T> create(T* aPtr) const
+  {
+#ifdef DEBUG
+    return RangedPtr<T>(aPtr, mRangeStart, mRangeEnd);
+#else
+    return RangedPtr<T>(aPtr, nullptr, size_t(0));
+#endif
+  }
+
+  uintptr_t asUintptr() const { return reinterpret_cast<uintptr_t>(mPtr); }
+
+public:
+  RangedPtr(T* aPtr, T* aStart, T* aEnd)
+    : mPtr(aPtr)
+#ifdef DEBUG
+    , mRangeStart(aStart), mRangeEnd(aEnd)
+#endif
+  {
+    MOZ_ASSERT(mRangeStart <= mRangeEnd);
+    checkSanity();
+  }
+  RangedPtr(T* aPtr, T* aStart, size_t aLength)
+    : mPtr(aPtr)
+#ifdef DEBUG
+    , mRangeStart(aStart), mRangeEnd(aStart + aLength)
+#endif
+  {
+    MOZ_ASSERT(aLength <= size_t(-1) / sizeof(T));
+    MOZ_ASSERT(reinterpret_cast<uintptr_t>(mRangeStart) + aLength * sizeof(T) >=
+               reinterpret_cast<uintptr_t>(mRangeStart));
+    checkSanity();
+  }
+
+  /* Equivalent to RangedPtr(aPtr, aPtr, aLength). */
+  RangedPtr(T* aPtr, size_t aLength)
+    : mPtr(aPtr)
+#ifdef DEBUG
+    , mRangeStart(aPtr), mRangeEnd(aPtr + aLength)
+#endif
+  {
+    MOZ_ASSERT(aLength <= size_t(-1) / sizeof(T));
+    MOZ_ASSERT(reinterpret_cast<uintptr_t>(mRangeStart) + aLength * sizeof(T) >=
+               reinterpret_cast<uintptr_t>(mRangeStart));
+    checkSanity();
+  }
+
+  /* Equivalent to RangedPtr(aArr, aArr, N). */
+  template<size_t N>
+  explicit RangedPtr(T (&aArr)[N])
+    : mPtr(aArr)
+#ifdef DEBUG
+    , mRangeStart(aArr), mRangeEnd(aArr + N)
+#endif
+  {
+    checkSanity();
+  }
+
+  T* get() const { return mPtr; }
+
+  explicit operator bool() const { return mPtr != nullptr; }
+
+  /*
+   * You can only assign one RangedPtr into another if the two pointers have
+   * the same valid range:
+   *
+   *   char arr1[] = "hi";
+   *   char arr2[] = "bye";
+   *   RangedPtr<char> p1(arr1, 2);
+   *   p1 = RangedPtr<char>(arr1 + 1, arr1, arr1 + 2); // works
+   *   p1 = RangedPtr<char>(arr2, 3);                  // asserts
+   */
+  RangedPtr<T>& operator=(const RangedPtr<T>& aOther)
+  {
+    MOZ_ASSERT(mRangeStart == aOther.mRangeStart);
+    MOZ_ASSERT(mRangeEnd == aOther.mRangeEnd);
+    mPtr = aOther.mPtr;
+    checkSanity();
+    return *this;
+  }
+
+  RangedPtr<T> operator+(size_t aInc)
+  {
+    MOZ_ASSERT(aInc <= size_t(-1) / sizeof(T));
+    MOZ_ASSERT(asUintptr() + aInc * sizeof(T) >= asUintptr());
+    return create(mPtr + aInc);
+  }
+
+  RangedPtr<T> operator-(size_t aDec)
+  {
+    MOZ_ASSERT(aDec <= size_t(-1) / sizeof(T));
+    MOZ_ASSERT(asUintptr() - aDec * sizeof(T) <= asUintptr());
+    return create(mPtr - aDec);
+  }
+
+  /*
+   * You can assign a raw pointer into a RangedPtr if the raw pointer is
+   * within the range specified at creation.
+   */
+  template <typename U>
+  RangedPtr<T>& operator=(U* aPtr)
+  {
+    *this = create(aPtr);
+    return *this;
+  }
+
+  template <typename U>
+  RangedPtr<T>& operator=(const RangedPtr<U>& aPtr)
+  {
+    MOZ_ASSERT(mRangeStart <= aPtr.mPtr);
+    MOZ_ASSERT(aPtr.mPtr <= mRangeEnd);
+    mPtr = aPtr.mPtr;
+    checkSanity();
+    return *this;
+  }
+
+  RangedPtr<T>& operator++()
+  {
+    return (*this += 1);
+  }
+
+  RangedPtr<T> operator++(int)
+  {
+    RangedPtr<T> rcp = *this;
+    ++*this;
+    return rcp;
+  }
+
+  RangedPtr<T>& operator--()
+  {
+    return (*this -= 1);
+  }
+
+  RangedPtr<T> operator--(int)
+  {
+    RangedPtr<T> rcp = *this;
+    --*this;
+    return rcp;
+  }
+
+  RangedPtr<T>& operator+=(size_t aInc)
+  {
+    *this = *this + aInc;
+    return *this;
+  }
+
+  RangedPtr<T>& operator-=(size_t aDec)
+  {
+    *this = *this - aDec;
+    return *this;
+  }
+
+  T& operator[](int aIndex) const
+  {
+    MOZ_ASSERT(size_t(aIndex > 0 ? aIndex : -aIndex) <= size_t(-1) / sizeof(T));
+    return *create(mPtr + aIndex);
+  }
+
+  T& operator*() const
+  {
+    MOZ_ASSERT(mPtr >= mRangeStart);
+    MOZ_ASSERT(mPtr < mRangeEnd);
+    return *mPtr;
+  }
+
+  template <typename U>
+  bool operator==(const RangedPtr<U>& aOther) const
+  {
+    return mPtr == aOther.mPtr;
+  }
+  template <typename U>
+  bool operator!=(const RangedPtr<U>& aOther) const
+  {
+    return !(*this == aOther);
+  }
+
+  template<typename U>
+  bool operator==(const U* u) const
+  {
+    return mPtr == u;
+  }
+  template<typename U>
+  bool operator!=(const U* u) const
+  {
+    return !(*this == u);
+  }
+
+  template <typename U>
+  bool operator<(const RangedPtr<U>& aOther) const
+  {
+    return mPtr < aOther.mPtr;
+  }
+  template <typename U>
+  bool operator<=(const RangedPtr<U>& aOther) const
+  {
+    return mPtr <= aOther.mPtr;
+  }
+
+  template <typename U>
+  bool operator>(const RangedPtr<U>& aOther) const
+  {
+    return mPtr > aOther.mPtr;
+  }
+  template <typename U>
+  bool operator>=(const RangedPtr<U>& aOther) const
+  {
+    return mPtr >= aOther.mPtr;
+  }
+
+  size_t operator-(const RangedPtr<T>& aOther) const
+  {
+    MOZ_ASSERT(mPtr >= aOther.mPtr);
+    return PointerRangeSize(aOther.mPtr, mPtr);
+  }
+
+private:
+  RangedPtr() = delete;
+  T* operator&() = delete;
+};
+
+} /* namespace mozilla */
+
+#endif /* mozilla_RangedPtr_h */
diff --git a/src/third_party/mozjs-45/mfbt/ReentrancyGuard.h b/src/third_party/mozjs-45/mfbt/ReentrancyGuard.h
new file mode 100644
index 0000000..9963974
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/ReentrancyGuard.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Small helper class for asserting uses of a class are non-reentrant. */
+
+#ifndef mozilla_ReentrancyGuard_h
+#define mozilla_ReentrancyGuard_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/GuardObjects.h"
+
+namespace mozilla {
+
+/* Useful for implementing containers that assert non-reentrancy */
+class MOZ_RAII ReentrancyGuard
+{
+  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+#ifdef DEBUG
+  bool& mEntered;
+#endif
+
+public:
+  template<class T>
+#ifdef DEBUG
+  explicit ReentrancyGuard(T& aObj
+                           MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+    : mEntered(aObj.mEntered)
+#else
+  explicit ReentrancyGuard(T&
+                           MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+#endif
+  {
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+#ifdef DEBUG
+    MOZ_ASSERT(!mEntered);
+    mEntered = true;
+#endif
+  }
+  ~ReentrancyGuard()
+  {
+#ifdef DEBUG
+    mEntered = false;
+#endif
+  }
+
+private:
+  ReentrancyGuard(const ReentrancyGuard&) = delete;
+  void operator=(const ReentrancyGuard&) = delete;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_ReentrancyGuard_h */
diff --git a/src/third_party/mozjs-45/mfbt/RefCountType.h b/src/third_party/mozjs-45/mfbt/RefCountType.h
new file mode 100644
index 0000000..e95a22a
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/RefCountType.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_RefCountType_h
+#define mozilla_RefCountType_h
+
+#include <stdint.h>
+
+/**
+ * MozRefCountType is Mozilla's reference count type.
+ *
+ * We use the same type to represent the refcount of RefCounted objects
+ * as well, in order to be able to use the leak detection facilities
+ * that are implemented by XPCOM.
+ *
+ * Note that this type is not in the mozilla namespace so that it is
+ * usable for both C and C++ code.
+ */
+typedef uintptr_t MozRefCountType;
+
+/*
+ * This is the return type for AddRef() and Release() in nsISupports.
+ * IUnknown of COM returns an unsigned long from equivalent functions.
+ *
+ * The following ifdef exists to maintain binary compatibility with
+ * IUnknown, the base interface in Microsoft COM.
+ */
+#ifdef XP_WIN
+typedef unsigned long MozExternalRefCountType;
+#else
+typedef uint32_t MozExternalRefCountType;
+#endif
+
+#endif
diff --git a/src/third_party/mozjs-45/mfbt/RefCounted.h b/src/third_party/mozjs-45/mfbt/RefCounted.h
new file mode 100644
index 0000000..873e40e
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/RefCounted.h
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* CRTP refcounting templates.  Do not use unless you are an Expert. */
+
+#ifndef mozilla_RefCounted_h
+#define mozilla_RefCounted_h
+
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Atomics.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Move.h"
+#include "mozilla/RefCountType.h"
+#include "mozilla/TypeTraits.h"
+
+#if defined(MOZILLA_INTERNAL_API)
+#include "nsXPCOM.h"
+#endif
+
+#if defined(MOZILLA_INTERNAL_API) && \
+    !defined(MOZILLA_XPCOMRT_API) && \
+    (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
+#define MOZ_REFCOUNTED_LEAK_CHECKING
+#endif
+
+namespace mozilla {
+
+/**
+ * RefCounted<T> is a sort of a "mixin" for a class T.  RefCounted
+ * manages, well, refcounting for T, and because RefCounted is
+ * parameterized on T, RefCounted<T> can call T's destructor directly.
+ * This means T doesn't need to have a virtual dtor and so doesn't
+ * need a vtable.
+ *
+ * RefCounted<T> is created with refcount == 0.  Newly-allocated
+ * RefCounted<T> must immediately be assigned to a RefPtr to make the
+ * refcount > 0.  It's an error to allocate and free a bare
+ * RefCounted<T>, i.e. outside of the RefPtr machinery.  Attempts to
+ * do so will abort DEBUG builds.
+ *
+ * Live RefCounted<T> have refcount > 0.  The lifetime (refcounts) of
+ * live RefCounted<T> are controlled by RefPtr<T> and
+ * RefPtr<super/subclass of T>.  Upon a transition from refcounted==1
+ * to 0, the RefCounted<T> "dies" and is destroyed.  The "destroyed"
+ * state is represented in DEBUG builds by refcount==0xffffdead.  This
+ * state distinguishes use-before-ref (refcount==0) from
+ * use-after-destroy (refcount==0xffffdead).
+ *
+ * Note that when deriving from RefCounted or AtomicRefCounted, you
+ * should add MOZ_DECLARE_REFCOUNTED_TYPENAME(ClassName) to the public
+ * section of your class, where ClassName is the name of your class.
+ */
+namespace detail {
+const MozRefCountType DEAD = 0xffffdead;
+
+// When building code that gets compiled into Gecko, try to use the
+// trace-refcount leak logging facilities.
+#ifdef MOZ_REFCOUNTED_LEAK_CHECKING
+class RefCountLogger
+{
+public:
+  static void logAddRef(const void* aPointer, MozRefCountType aRefCount,
+                        const char* aTypeName, uint32_t aInstanceSize)
+  {
+    MOZ_ASSERT(aRefCount != DEAD);
+    NS_LogAddRef(const_cast<void*>(aPointer), aRefCount, aTypeName,
+                 aInstanceSize);
+  }
+
+  static void logRelease(const void* aPointer, MozRefCountType aRefCount,
+                         const char* aTypeName)
+  {
+    MOZ_ASSERT(aRefCount != DEAD);
+    NS_LogRelease(const_cast<void*>(aPointer), aRefCount, aTypeName);
+  }
+};
+#endif
+
+// This is used WeakPtr.h as well as this file.
+enum RefCountAtomicity
+{
+  AtomicRefCount,
+  NonAtomicRefCount
+};
+
+template<typename T, RefCountAtomicity Atomicity>
+class RefCounted
+{
+protected:
+  RefCounted() : mRefCnt(0) {}
+  ~RefCounted() { MOZ_ASSERT(mRefCnt == detail::DEAD); }
+
+public:
+  // Compatibility with nsRefPtr.
+  void AddRef() const
+  {
+    // Note: this method must be thread safe for AtomicRefCounted.
+    MOZ_ASSERT(int32_t(mRefCnt) >= 0);
+#ifndef MOZ_REFCOUNTED_LEAK_CHECKING
+    ++mRefCnt;
+#else
+    const char* type = static_cast<const T*>(this)->typeName();
+    uint32_t size = static_cast<const T*>(this)->typeSize();
+    const void* ptr = static_cast<const T*>(this);
+    MozRefCountType cnt = ++mRefCnt;
+    detail::RefCountLogger::logAddRef(ptr, cnt, type, size);
+#endif
+  }
+
+  void Release() const
+  {
+    // Note: this method must be thread safe for AtomicRefCounted.
+    MOZ_ASSERT(int32_t(mRefCnt) > 0);
+#ifndef MOZ_REFCOUNTED_LEAK_CHECKING
+    MozRefCountType cnt = --mRefCnt;
+#else
+    const char* type = static_cast<const T*>(this)->typeName();
+    const void* ptr = static_cast<const T*>(this);
+    MozRefCountType cnt = --mRefCnt;
+    // Note: it's not safe to touch |this| after decrementing the refcount,
+    // except for below.
+    detail::RefCountLogger::logRelease(ptr, cnt, type);
+#endif
+    if (0 == cnt) {
+      // Because we have atomically decremented the refcount above, only
+      // one thread can get a 0 count here, so as long as we can assume that
+      // everything else in the system is accessing this object through
+      // RefPtrs, it's safe to access |this| here.
+#ifdef DEBUG
+      mRefCnt = detail::DEAD;
+#endif
+      delete static_cast<const T*>(this);
+    }
+  }
+
+  // Compatibility with wtf::RefPtr.
+  void ref() { AddRef(); }
+  void deref() { Release(); }
+  MozRefCountType refCount() const { return mRefCnt; }
+  bool hasOneRef() const
+  {
+    MOZ_ASSERT(mRefCnt > 0);
+    return mRefCnt == 1;
+  }
+
+private:
+  mutable typename Conditional<Atomicity == AtomicRefCount,
+                               Atomic<MozRefCountType>,
+                               MozRefCountType>::Type mRefCnt;
+};
+
+#ifdef MOZ_REFCOUNTED_LEAK_CHECKING
+// Passing override for the optional argument marks the typeName and
+// typeSize functions defined by this macro as overrides.
+#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T, ...) \
+  virtual const char* typeName() const __VA_ARGS__ { return #T; } \
+  virtual size_t typeSize() const __VA_ARGS__ { return sizeof(*this); }
+#else
+#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T, ...)
+#endif
+
+// Note that this macro is expanded unconditionally because it declares only
+// two small inline functions which will hopefully get eliminated by the linker
+// in non-leak-checking builds.
+#define MOZ_DECLARE_REFCOUNTED_TYPENAME(T) \
+  const char* typeName() const { return #T; } \
+  size_t typeSize() const { return sizeof(*this); }
+
+} // namespace detail
+
+template<typename T>
+class RefCounted : public detail::RefCounted<T, detail::NonAtomicRefCount>
+{
+public:
+  ~RefCounted()
+  {
+    static_assert(IsBaseOf<RefCounted, T>::value,
+                  "T must derive from RefCounted<T>");
+  }
+};
+
+namespace external {
+
+/**
+ * AtomicRefCounted<T> is like RefCounted<T>, with an atomically updated
+ * reference counter.
+ *
+ * NOTE: Please do not use this class, use NS_INLINE_DECL_THREADSAFE_REFCOUNTING
+ * instead.
+ */
+template<typename T>
+class AtomicRefCounted :
+  public mozilla::detail::RefCounted<T, mozilla::detail::AtomicRefCount>
+{
+public:
+  ~AtomicRefCounted()
+  {
+    static_assert(IsBaseOf<AtomicRefCounted, T>::value,
+                  "T must derive from AtomicRefCounted<T>");
+  }
+};
+
+} // namespace external
+
+} // namespace mozilla
+
+#endif // mozilla_RefCounted_h
diff --git a/src/third_party/mozjs-45/mfbt/RefPtr.h b/src/third_party/mozjs-45/mfbt/RefPtr.h
new file mode 100644
index 0000000..4798d43
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/RefPtr.h
@@ -0,0 +1,621 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_RefPtr_h
+#define mozilla_RefPtr_h
+
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+
+/*****************************************************************************/
+
+// template <class T> class RefPtrGetterAddRefs;
+
+class nsCOMPtr_helper;
+
+namespace mozilla {
+template<class T> class OwningNonNull;
+} // namespace mozilla
+
+template <class T>
+class RefPtr
+{
+private:
+  void
+  assign_with_AddRef(T* aRawPtr)
+  {
+    if (aRawPtr) {
+      AddRefTraits<T>::AddRef(aRawPtr);
+    }
+    assign_assuming_AddRef(aRawPtr);
+  }
+
+  void
+  assign_assuming_AddRef(T* aNewPtr)
+  {
+    T* oldPtr = mRawPtr;
+    mRawPtr = aNewPtr;
+    if (oldPtr) {
+      AddRefTraits<T>::Release(oldPtr);
+    }
+  }
+
+private:
+  T* MOZ_OWNING_REF mRawPtr;
+
+public:
+  typedef T element_type;
+
+  ~RefPtr()
+  {
+    if (mRawPtr) {
+      AddRefTraits<T>::Release(mRawPtr);
+    }
+  }
+
+  // Constructors
+
+  RefPtr()
+    : mRawPtr(0)
+    // default constructor
+  {
+  }
+
+  RefPtr(const RefPtr<T>& aSmartPtr)
+    : mRawPtr(aSmartPtr.mRawPtr)
+    // copy-constructor
+  {
+    if (mRawPtr) {
+      AddRefTraits<T>::AddRef(mRawPtr);
+    }
+  }
+
+  RefPtr(RefPtr<T>&& aRefPtr)
+    : mRawPtr(aRefPtr.mRawPtr)
+  {
+    aRefPtr.mRawPtr = nullptr;
+  }
+
+  // construct from a raw pointer (of the right type)
+
+  MOZ_IMPLICIT RefPtr(T* aRawPtr)
+    : mRawPtr(aRawPtr)
+  {
+    if (mRawPtr) {
+      AddRefTraits<T>::AddRef(mRawPtr);
+    }
+  }
+
+  template <typename I>
+  MOZ_IMPLICIT RefPtr(already_AddRefed<I>& aSmartPtr)
+    : mRawPtr(aSmartPtr.take())
+    // construct from |already_AddRefed|
+  {
+  }
+
+  template <typename I>
+  MOZ_IMPLICIT RefPtr(already_AddRefed<I>&& aSmartPtr)
+    : mRawPtr(aSmartPtr.take())
+    // construct from |otherRefPtr.forget()|
+  {
+  }
+
+  template <typename I>
+  MOZ_IMPLICIT RefPtr(const RefPtr<I>& aSmartPtr)
+    : mRawPtr(aSmartPtr.get())
+    // copy-construct from a smart pointer with a related pointer type
+  {
+    if (mRawPtr) {
+      AddRefTraits<T>::AddRef(mRawPtr);
+    }
+  }
+
+  template <typename I>
+  MOZ_IMPLICIT RefPtr(RefPtr<I>&& aSmartPtr)
+    : mRawPtr(aSmartPtr.forget().take())
+    // construct from |Move(RefPtr<SomeSubclassOfT>)|.
+  {
+  }
+
+  MOZ_IMPLICIT RefPtr(const nsCOMPtr_helper& aHelper);
+
+  // Defined in OwningNonNull.h
+  template<class U>
+  MOZ_IMPLICIT RefPtr(const mozilla::OwningNonNull<U>& aOther);
+
+  // Assignment operators
+
+  RefPtr<T>&
+  operator=(const RefPtr<T>& aRhs)
+  // copy assignment operator
+  {
+    assign_with_AddRef(aRhs.mRawPtr);
+    return *this;
+  }
+
+  template <typename I>
+  RefPtr<T>&
+  operator=(const RefPtr<I>& aRhs)
+  // assign from an RefPtr of a related pointer type
+  {
+    assign_with_AddRef(aRhs.get());
+    return *this;
+  }
+
+  RefPtr<T>&
+  operator=(T* aRhs)
+  // assign from a raw pointer (of the right type)
+  {
+    assign_with_AddRef(aRhs);
+    return *this;
+  }
+
+  template <typename I>
+  RefPtr<T>&
+  operator=(already_AddRefed<I>& aRhs)
+  // assign from |already_AddRefed|
+  {
+    assign_assuming_AddRef(aRhs.take());
+    return *this;
+  }
+
+  template <typename I>
+  RefPtr<T>&
+  operator=(already_AddRefed<I> && aRhs)
+  // assign from |otherRefPtr.forget()|
+  {
+    assign_assuming_AddRef(aRhs.take());
+    return *this;
+  }
+
+  RefPtr<T>& operator=(const nsCOMPtr_helper& aHelper);
+
+  RefPtr<T>&
+  operator=(RefPtr<T> && aRefPtr)
+  {
+    assign_assuming_AddRef(aRefPtr.mRawPtr);
+    aRefPtr.mRawPtr = nullptr;
+    return *this;
+  }
+
+  // Defined in OwningNonNull.h
+  template<class U>
+  RefPtr<T>&
+  operator=(const mozilla::OwningNonNull<U>& aOther);
+
+  // Other pointer operators
+
+  void
+  swap(RefPtr<T>& aRhs)
+  // ...exchange ownership with |aRhs|; can save a pair of refcount operations
+  {
+    T* temp = aRhs.mRawPtr;
+    aRhs.mRawPtr = mRawPtr;
+    mRawPtr = temp;
+  }
+
+  void
+  swap(T*& aRhs)
+  // ...exchange ownership with |aRhs|; can save a pair of refcount operations
+  {
+    T* temp = aRhs;
+    aRhs = mRawPtr;
+    mRawPtr = temp;
+  }
+
+  already_AddRefed<T>
+  forget()
+  // return the value of mRawPtr and null out mRawPtr. Useful for
+  // already_AddRefed return values.
+  {
+    T* temp = 0;
+    swap(temp);
+    return already_AddRefed<T>(temp);
+  }
+
+  template <typename I>
+  void
+  forget(I** aRhs)
+  // Set the target of aRhs to the value of mRawPtr and null out mRawPtr.
+  // Useful to avoid unnecessary AddRef/Release pairs with "out"
+  // parameters where aRhs bay be a T** or an I** where I is a base class
+  // of T.
+  {
+    MOZ_ASSERT(aRhs, "Null pointer passed to forget!");
+    *aRhs = mRawPtr;
+    mRawPtr = 0;
+  }
+
+  T*
+  get() const
+  /*
+    Prefer the implicit conversion provided automatically by |operator T*() const|.
+    Use |get()| to resolve ambiguity or to get a castable pointer.
+  */
+  {
+    return const_cast<T*>(mRawPtr);
+  }
+
+  operator T*() const
+#ifdef MOZ_HAVE_REF_QUALIFIERS
+  &
+#endif
+  /*
+    ...makes an |RefPtr| act like its underlying raw pointer type whenever it
+    is used in a context where a raw pointer is expected.  It is this operator
+    that makes an |RefPtr| substitutable for a raw pointer.
+
+    Prefer the implicit use of this operator to calling |get()|, except where
+    necessary to resolve ambiguity.
+  */
+  {
+    return get();
+  }
+
+#ifdef MOZ_HAVE_REF_QUALIFIERS
+  // Don't allow implicit conversion of temporary RefPtr to raw pointer,
+  // because the refcount might be one and the pointer will immediately become
+  // invalid.
+  operator T*() const && = delete;
+
+  // These are needed to avoid the deleted operator above.  XXX Why is operator!
+  // needed separately?  Shouldn't the compiler prefer using the non-deleted
+  // operator bool instead of the deleted operator T*?
+  explicit operator bool() const { return !!mRawPtr; }
+  bool operator!() const { return !mRawPtr; }
+#endif
+
+  T*
+  operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
+  {
+    MOZ_ASSERT(mRawPtr != 0,
+               "You can't dereference a NULL RefPtr with operator->().");
+    return get();
+  }
+
+  template <typename R, typename... Args>
+  class Proxy
+  {
+    typedef R (T::*member_function)(Args...);
+    T* mRawPtr;
+    member_function mFunction;
+  public:
+    Proxy(T* aRawPtr, member_function aFunction)
+      : mRawPtr(aRawPtr),
+        mFunction(aFunction)
+    {
+    }
+    template<typename... ActualArgs>
+    R operator()(ActualArgs&&... aArgs)
+    {
+      return ((*mRawPtr).*mFunction)(mozilla::Forward<ActualArgs>(aArgs)...);
+    }
+  };
+
+  template <typename R, typename... Args>
+  Proxy<R, Args...> operator->*(R (T::*aFptr)(Args...)) const
+  {
+    MOZ_ASSERT(mRawPtr != 0,
+               "You can't dereference a NULL RefPtr with operator->*().");
+    return Proxy<R, Args...>(get(), aFptr);
+  }
+
+  RefPtr<T>*
+  get_address()
+  // This is not intended to be used by clients.  See |address_of|
+  // below.
+  {
+    return this;
+  }
+
+  const RefPtr<T>*
+  get_address() const
+  // This is not intended to be used by clients.  See |address_of|
+  // below.
+  {
+    return this;
+  }
+
+public:
+  T&
+  operator*() const
+  {
+    MOZ_ASSERT(mRawPtr != 0,
+               "You can't dereference a NULL RefPtr with operator*().");
+    return *get();
+  }
+
+  T**
+  StartAssignment()
+  {
+    assign_assuming_AddRef(0);
+    return reinterpret_cast<T**>(&mRawPtr);
+  }
+private:
+  // This helper class makes |RefPtr<const T>| possible by casting away
+  // the constness from the pointer when calling AddRef() and Release().
+  //
+  // This is necessary because AddRef() and Release() implementations can't
+  // generally expected to be const themselves (without heavy use of |mutable|
+  // and |const_cast| in their own implementations).
+  //
+  // This should be sound because while |RefPtr<const T>| provides a
+  // const view of an object, the object itself should not be const (it
+  // would have to be allocated as |new const T| or similar to be const).
+
+  // Because some classes make their AddRef/Release implementations private
+  // and then friend RefPtr to make them visible, we redirect AddRefTraits's
+  // calls to static helper functions in RefPtr so we don't have to figure
+  // out how to make AddRefTraits visible to *those* classes.
+  static MOZ_ALWAYS_INLINE void
+  AddRefTraitsAddRefHelper(typename mozilla::RemoveConst<T>::Type* aPtr)
+  {
+    aPtr->AddRef();
+  }
+  static MOZ_ALWAYS_INLINE void
+  AddRefTraitsReleaseHelper(typename mozilla::RemoveConst<T>::Type* aPtr)
+  {
+    aPtr->Release();
+  }
+
+  template<class U>
+  struct AddRefTraits
+  {
+    static void AddRef(U* aPtr) {
+      RefPtr<T>::AddRefTraitsAddRefHelper(aPtr);
+    }
+    static void Release(U* aPtr) {
+      RefPtr<T>::AddRefTraitsReleaseHelper(aPtr);
+    }
+  };
+  template<class U>
+  struct AddRefTraits<const U>
+  {
+    static void AddRef(const U* aPtr) {
+      RefPtr<T>::AddRefTraitsAddRefHelper(const_cast<U*>(aPtr));
+    }
+    static void Release(const U* aPtr) {
+      RefPtr<T>::AddRefTraitsReleaseHelper(const_cast<U*>(aPtr));
+    }
+  };
+};
+
+class nsCycleCollectionTraversalCallback;
+template <typename T>
+void
+CycleCollectionNoteChild(nsCycleCollectionTraversalCallback& aCallback,
+                         T* aChild, const char* aName, uint32_t aFlags);
+
+template <typename T>
+inline void
+ImplCycleCollectionUnlink(RefPtr<T>& aField)
+{
+  aField = nullptr;
+}
+
+template <typename T>
+inline void
+ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
+                            RefPtr<T>& aField,
+                            const char* aName,
+                            uint32_t aFlags = 0)
+{
+  CycleCollectionNoteChild(aCallback, aField.get(), aName, aFlags);
+}
+
+template <class T>
+inline RefPtr<T>*
+address_of(RefPtr<T>& aPtr)
+{
+  return aPtr.get_address();
+}
+
+template <class T>
+inline const RefPtr<T>*
+address_of(const RefPtr<T>& aPtr)
+{
+  return aPtr.get_address();
+}
+
+template <class T>
+class RefPtrGetterAddRefs
+/*
+  ...
+
+  This class is designed to be used for anonymous temporary objects in the
+  argument list of calls that return COM interface pointers, e.g.,
+
+    RefPtr<IFoo> fooP;
+    ...->GetAddRefedPointer(getter_AddRefs(fooP))
+
+  DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE.  Use |getter_AddRefs()| instead.
+
+  When initialized with a |RefPtr|, as in the example above, it returns
+  a |void**|, a |T**|, or an |nsISupports**| as needed, that the
+  outer call (|GetAddRefedPointer| in this case) can fill in.
+
+  This type should be a nested class inside |RefPtr<T>|.
+*/
+{
+public:
+  explicit
+  RefPtrGetterAddRefs(RefPtr<T>& aSmartPtr)
+    : mTargetSmartPtr(aSmartPtr)
+  {
+    // nothing else to do
+  }
+
+  operator void**()
+  {
+    return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment());
+  }
+
+  operator T**()
+  {
+    return mTargetSmartPtr.StartAssignment();
+  }
+
+  T*&
+  operator*()
+  {
+    return *(mTargetSmartPtr.StartAssignment());
+  }
+
+private:
+  RefPtr<T>& mTargetSmartPtr;
+};
+
+template <class T>
+inline RefPtrGetterAddRefs<T>
+getter_AddRefs(RefPtr<T>& aSmartPtr)
+/*
+  Used around a |RefPtr| when
+  ...makes the class |RefPtrGetterAddRefs<T>| invisible.
+*/
+{
+  return RefPtrGetterAddRefs<T>(aSmartPtr);
+}
+
+
+// Comparing two |RefPtr|s
+
+template <class T, class U>
+inline bool
+operator==(const RefPtr<T>& aLhs, const RefPtr<U>& aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs.get());
+}
+
+
+template <class T, class U>
+inline bool
+operator!=(const RefPtr<T>& aLhs, const RefPtr<U>& aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs.get());
+}
+
+
+// Comparing an |RefPtr| to a raw pointer
+
+template <class T, class U>
+inline bool
+operator==(const RefPtr<T>& aLhs, const U* aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs);
+}
+
+template <class T, class U>
+inline bool
+operator==(const U* aLhs, const RefPtr<T>& aRhs)
+{
+  return static_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
+}
+
+template <class T, class U>
+inline bool
+operator!=(const RefPtr<T>& aLhs, const U* aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs);
+}
+
+template <class T, class U>
+inline bool
+operator!=(const U* aLhs, const RefPtr<T>& aRhs)
+{
+  return static_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
+}
+
+template <class T, class U>
+inline bool
+operator==(const RefPtr<T>& aLhs, U* aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) == const_cast<const U*>(aRhs);
+}
+
+template <class T, class U>
+inline bool
+operator==(U* aLhs, const RefPtr<T>& aRhs)
+{
+  return const_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
+}
+
+template <class T, class U>
+inline bool
+operator!=(const RefPtr<T>& aLhs, U* aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) != const_cast<const U*>(aRhs);
+}
+
+template <class T, class U>
+inline bool
+operator!=(U* aLhs, const RefPtr<T>& aRhs)
+{
+  return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
+}
+
+// Comparing an |RefPtr| to |nullptr|
+
+template <class T>
+inline bool
+operator==(const RefPtr<T>& aLhs, decltype(nullptr))
+{
+  return aLhs.get() == nullptr;
+}
+
+template <class T>
+inline bool
+operator==(decltype(nullptr), const RefPtr<T>& aRhs)
+{
+  return nullptr == aRhs.get();
+}
+
+template <class T>
+inline bool
+operator!=(const RefPtr<T>& aLhs, decltype(nullptr))
+{
+  return aLhs.get() != nullptr;
+}
+
+template <class T>
+inline bool
+operator!=(decltype(nullptr), const RefPtr<T>& aRhs)
+{
+  return nullptr != aRhs.get();
+}
+
+/*****************************************************************************/
+
+template <class T>
+inline already_AddRefed<T>
+do_AddRef(T*&& aObj)
+{
+  RefPtr<T> ref(aObj);
+  return ref.forget();
+}
+
+namespace mozilla {
+
+/**
+ * Helper function to be able to conveniently write things like:
+ *
+ *   already_AddRefed<T>
+ *   f(...)
+ *   {
+ *     return MakeAndAddRef<T>(...);
+ *   }
+ */
+template<typename T, typename... Args>
+already_AddRefed<T>
+MakeAndAddRef(Args&&... aArgs)
+{
+  RefPtr<T> p(new T(Forward<Args>(aArgs)...));
+  return p.forget();
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_RefPtr_h */
diff --git a/src/third_party/mozjs-45/mfbt/ReverseIterator.h b/src/third_party/mozjs-45/mfbt/ReverseIterator.h
new file mode 100644
index 0000000..49c2e27
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/ReverseIterator.h
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* An iterator that acts like another iterator, but iterating in
+ * the negative direction. (Note that not all iterators can iterate
+ * in the negative direction.) */
+
+#ifndef mozilla_ReverseIterator_h
+#define mozilla_ReverseIterator_h
+
+#include "mozilla/Attributes.h"
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+template<typename IteratorT>
+class ReverseIterator
+{
+public:
+  template<typename Iterator>
+  explicit ReverseIterator(Iterator aIter)
+    : mCurrent(aIter) { }
+
+  template<typename Iterator>
+  MOZ_IMPLICIT ReverseIterator(const ReverseIterator<Iterator>& aOther)
+    : mCurrent(aOther.mCurrent) { }
+
+  decltype(*DeclVal<IteratorT>()) operator*() const
+  {
+    IteratorT tmp = mCurrent;
+    return *--tmp;
+  }
+
+  /* Increments and decrements operators */
+
+  ReverseIterator& operator++() { --mCurrent; return *this; }
+  ReverseIterator& operator--() { ++mCurrent; return *this; }
+  ReverseIterator operator++(int) { auto ret = *this; mCurrent--; return ret; }
+  ReverseIterator operator--(int) { auto ret = *this; mCurrent++; return ret; }
+
+  /* Comparison operators */
+
+  template<typename Iterator1, typename Iterator2>
+  friend bool operator==(const ReverseIterator<Iterator1>& aIter1,
+                         const ReverseIterator<Iterator2>& aIter2);
+  template<typename Iterator1, typename Iterator2>
+  friend bool operator!=(const ReverseIterator<Iterator1>& aIter1,
+                         const ReverseIterator<Iterator2>& aIter2);
+  template<typename Iterator1, typename Iterator2>
+  friend bool operator<(const ReverseIterator<Iterator1>& aIter1,
+                        const ReverseIterator<Iterator2>& aIter2);
+  template<typename Iterator1, typename Iterator2>
+  friend bool operator<=(const ReverseIterator<Iterator1>& aIter1,
+                         const ReverseIterator<Iterator2>& aIter2);
+  template<typename Iterator1, typename Iterator2>
+  friend bool operator>(const ReverseIterator<Iterator1>& aIter1,
+                        const ReverseIterator<Iterator2>& aIter2);
+  template<typename Iterator1, typename Iterator2>
+  friend bool operator>=(const ReverseIterator<Iterator1>& aIter1,
+                         const ReverseIterator<Iterator2>& aIter2);
+
+private:
+  IteratorT mCurrent;
+};
+
+template<typename Iterator1, typename Iterator2>
+bool
+operator==(const ReverseIterator<Iterator1>& aIter1,
+           const ReverseIterator<Iterator2>& aIter2)
+{
+  return aIter1.mCurrent == aIter2.mCurrent;
+}
+
+template<typename Iterator1, typename Iterator2>
+bool
+operator!=(const ReverseIterator<Iterator1>& aIter1,
+           const ReverseIterator<Iterator2>& aIter2)
+{
+  return aIter1.mCurrent != aIter2.mCurrent;
+}
+
+template<typename Iterator1, typename Iterator2>
+bool
+operator<(const ReverseIterator<Iterator1>& aIter1,
+          const ReverseIterator<Iterator2>& aIter2)
+{
+  return aIter1.mCurrent > aIter2.mCurrent;
+}
+
+template<typename Iterator1, typename Iterator2>
+bool
+operator<=(const ReverseIterator<Iterator1>& aIter1,
+           const ReverseIterator<Iterator2>& aIter2)
+{
+  return aIter1.mCurrent >= aIter2.mCurrent;
+}
+
+template<typename Iterator1, typename Iterator2>
+bool
+operator>(const ReverseIterator<Iterator1>& aIter1,
+          const ReverseIterator<Iterator2>& aIter2)
+{
+  return aIter1.mCurrent < aIter2.mCurrent;
+}
+
+template<typename Iterator1, typename Iterator2>
+bool
+operator>=(const ReverseIterator<Iterator1>& aIter1,
+           const ReverseIterator<Iterator2>& aIter2)
+{
+  return aIter1.mCurrent <= aIter2.mCurrent;
+}
+
+namespace detail {
+
+template<typename IteratorT>
+class IteratorRange
+{
+public:
+  typedef IteratorT iterator;
+  typedef IteratorT const_iterator;
+  typedef ReverseIterator<IteratorT> reverse_iterator;
+  typedef ReverseIterator<IteratorT> const_reverse_iterator;
+
+  template<typename Iterator1, typename Iterator2>
+  MOZ_IMPLICIT IteratorRange(Iterator1 aIterBegin, Iterator2 aIterEnd)
+    : mIterBegin(aIterBegin), mIterEnd(aIterEnd) { }
+
+  template<typename Iterator>
+  MOZ_IMPLICIT IteratorRange(const IteratorRange<Iterator>& aOther)
+    : mIterBegin(aOther.mIterBegin), mIterEnd(aOther.mIterEnd) { }
+
+  iterator begin() const { return mIterBegin; }
+  const_iterator cbegin() const { return begin(); }
+  iterator end() const { return mIterEnd; }
+  const_iterator cend() const { return end(); }
+  reverse_iterator rbegin() const { return reverse_iterator(mIterEnd); }
+  const_reverse_iterator crbegin() const { return rbegin(); }
+  reverse_iterator rend() const { return reverse_iterator(mIterBegin); }
+  const_reverse_iterator crend() const { return rend(); }
+
+private:
+  IteratorT mIterBegin;
+  IteratorT mIterEnd;
+};
+
+} // namespace detail
+
+template<typename Range>
+detail::IteratorRange<typename Range::reverse_iterator>
+Reversed(Range& aRange)
+{
+  return {aRange.rbegin(), aRange.rend()};
+}
+
+template<typename Range>
+detail::IteratorRange<typename Range::const_reverse_iterator>
+Reversed(const Range& aRange)
+{
+  return {aRange.rbegin(), aRange.rend()};
+}
+
+} // namespace mozilla
+
+#endif // mozilla_ReverseIterator_h
diff --git a/src/third_party/mozjs-45/mfbt/RollingMean.h b/src/third_party/mozjs-45/mfbt/RollingMean.h
new file mode 100644
index 0000000..8cc3148
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/RollingMean.h
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A set abstraction for enumeration values. */
+
+#ifndef mozilla_RollingMean_h_
+#define mozilla_RollingMean_h_
+
+#include "mozilla/Assertions.h"
+#include "mozilla/TypeTraits.h"
+#include "mozilla/Vector.h"
+
+#include <stddef.h>
+
+namespace mozilla {
+
+/**
+ * RollingMean<T> calculates a rolling mean of the values it is given. It
+ * accumulates the total as values are added and removed. The second type
+ * argument S specifies the type of the total. This may need to be a bigger
+ * type in order to maintain that the sum of all values in the average doesn't
+ * exceed the maximum input value.
+ *
+ * WARNING: Float types are not supported due to rounding errors.
+ */
+template<typename T, typename S>
+class RollingMean
+{
+private:
+  size_t mInsertIndex;
+  size_t mMaxValues;
+  Vector<T> mValues;
+  S mTotal;
+
+public:
+  static_assert(!IsFloatingPoint<T>::value,
+                "floating-point types are unsupported due to rounding "
+                "errors");
+
+  explicit RollingMean(size_t aMaxValues)
+    : mInsertIndex(0),
+      mMaxValues(aMaxValues),
+      mTotal(0)
+  {
+    MOZ_ASSERT(aMaxValues > 0);
+  }
+
+  RollingMean& operator=(RollingMean&& aOther)
+  {
+    MOZ_ASSERT(this != &aOther, "self-assignment is forbidden");
+    this->~RollingMean();
+    new(this) RollingMean(aOther.mMaxValues);
+    mInsertIndex = aOther.mInsertIndex;
+    mTotal = aOther.mTotal;
+    mValues.swap(aOther.mValues);
+    return *this;
+  }
+
+  /**
+   * Insert a value into the rolling mean.
+   */
+  bool insert(T aValue)
+  {
+    MOZ_ASSERT(mValues.length() <= mMaxValues);
+
+    if (mValues.length() == mMaxValues) {
+      mTotal = mTotal - mValues[mInsertIndex] + aValue;
+      mValues[mInsertIndex] = aValue;
+    } else {
+      if (!mValues.append(aValue)) {
+        return false;
+      }
+      mTotal = mTotal + aValue;
+    }
+
+    mInsertIndex = (mInsertIndex + 1) % mMaxValues;
+    return true;
+  }
+
+  /**
+   * Calculate the rolling mean.
+   */
+  T mean()
+  {
+    MOZ_ASSERT(!empty());
+    return T(mTotal / int64_t(mValues.length()));
+  }
+
+  bool empty()
+  {
+    return mValues.empty();
+  }
+
+  /**
+   * Remove all values from the rolling mean.
+   */
+  void clear()
+  {
+    mValues.clear();
+    mInsertIndex = 0;
+    mTotal = T(0);
+  }
+
+  size_t maxValues()
+  {
+    return mMaxValues;
+  }
+};
+
+} // namespace mozilla
+
+#endif // mozilla_RollingMean_h_
diff --git a/src/third_party/mozjs-45/mfbt/SHA1.cpp b/src/third_party/mozjs-45/mfbt/SHA1.cpp
new file mode 100644
index 0000000..da4cb16
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/SHA1.cpp
@@ -0,0 +1,333 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Endian.h"
+#include "mozilla/SHA1.h"
+
+#include <string.h>
+
+using mozilla::NativeEndian;
+using mozilla::SHA1Sum;
+
+static inline uint32_t
+SHA_ROTL(uint32_t aT, uint32_t aN)
+{
+  MOZ_ASSERT(aN < 32);
+  return (aT << aN) | (aT >> (32 - aN));
+}
+
+static void
+shaCompress(volatile unsigned* aX, const uint32_t* aBuf);
+
+#define SHA_F1(X, Y, Z) ((((Y) ^ (Z)) & (X)) ^ (Z))
+#define SHA_F2(X, Y, Z) ((X) ^ (Y) ^ (Z))
+#define SHA_F3(X, Y, Z) (((X) & (Y)) | ((Z) & ((X) | (Y))))
+#define SHA_F4(X, Y, Z) ((X) ^ (Y) ^ (Z))
+
+#define SHA_MIX(n, a, b, c)    XW(n) = SHA_ROTL(XW(a) ^ XW(b) ^ XW(c) ^XW(n), 1)
+
+SHA1Sum::SHA1Sum()
+  : mSize(0), mDone(false)
+{
+  // Initialize H with constants from FIPS180-1.
+  mH[0] = 0x67452301L;
+  mH[1] = 0xefcdab89L;
+  mH[2] = 0x98badcfeL;
+  mH[3] = 0x10325476L;
+  mH[4] = 0xc3d2e1f0L;
+}
+
+/*
+ * Explanation of H array and index values:
+ *
+ * The context's H array is actually the concatenation of two arrays
+ * defined by SHA1, the H array of state variables (5 elements),
+ * and the W array of intermediate values, of which there are 16 elements.
+ * The W array starts at H[5], that is W[0] is H[5].
+ * Although these values are defined as 32-bit values, we use 64-bit
+ * variables to hold them because the AMD64 stores 64 bit values in
+ * memory MUCH faster than it stores any smaller values.
+ *
+ * Rather than passing the context structure to shaCompress, we pass
+ * this combined array of H and W values.  We do not pass the address
+ * of the first element of this array, but rather pass the address of an
+ * element in the middle of the array, element X.  Presently X[0] is H[11].
+ * So we pass the address of H[11] as the address of array X to shaCompress.
+ * Then shaCompress accesses the members of the array using positive AND
+ * negative indexes.
+ *
+ * Pictorially: (each element is 8 bytes)
+ * H | H0 H1 H2 H3 H4 W0 W1 W2 W3 W4 W5 W6 W7 W8 W9 Wa Wb Wc Wd We Wf |
+ * X |-11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 |
+ *
+ * The byte offset from X[0] to any member of H and W is always
+ * representable in a signed 8-bit value, which will be encoded
+ * as a single byte offset in the X86-64 instruction set.
+ * If we didn't pass the address of H[11], and instead passed the
+ * address of H[0], the offsets to elements H[16] and above would be
+ * greater than 127, not representable in a signed 8-bit value, and the
+ * x86-64 instruction set would encode every such offset as a 32-bit
+ * signed number in each instruction that accessed element H[16] or
+ * higher.  This results in much bigger and slower code.
+ */
+#define H2X 11 /* X[0] is H[11], and H[0] is X[-11] */
+#define W2X  6 /* X[0] is W[6],  and W[0] is X[-6]  */
+
+/*
+ *  SHA: Add data to context.
+ */
+void
+SHA1Sum::update(const void* aData, uint32_t aLen)
+{
+  MOZ_ASSERT(!mDone, "SHA1Sum can only be used to compute a single hash.");
+
+  const uint8_t* data = static_cast<const uint8_t*>(aData);
+
+  if (aLen == 0) {
+    return;
+  }
+
+  /* Accumulate the byte count. */
+  unsigned int lenB = static_cast<unsigned int>(mSize) & 63U;
+
+  mSize += aLen;
+
+  /* Read the data into W and process blocks as they get full. */
+  unsigned int togo;
+  if (lenB > 0) {
+    togo = 64U - lenB;
+    if (aLen < togo) {
+      togo = aLen;
+    }
+    memcpy(mU.mB + lenB, data, togo);
+    aLen -= togo;
+    data += togo;
+    lenB = (lenB + togo) & 63U;
+    if (!lenB) {
+      shaCompress(&mH[H2X], mU.mW);
+    }
+  }
+
+  while (aLen >= 64U) {
+    aLen -= 64U;
+    shaCompress(&mH[H2X], reinterpret_cast<const uint32_t*>(data));
+    data += 64U;
+  }
+
+  if (aLen > 0) {
+    memcpy(mU.mB, data, aLen);
+  }
+}
+
+
+/*
+ *  SHA: Generate hash value
+ */
+void
+SHA1Sum::finish(SHA1Sum::Hash& aHashOut)
+{
+  MOZ_ASSERT(!mDone, "SHA1Sum can only be used to compute a single hash.");
+
+  uint64_t size = mSize;
+  uint32_t lenB = uint32_t(size) & 63;
+
+  static const uint8_t bulk_pad[64] =
+    { 0x80,0,0,0,0,0,0,0,0,0,
+      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
+
+  /* Pad with a binary 1 (e.g. 0x80), then zeroes, then length in bits. */
+  update(bulk_pad, (((55 + 64) - lenB) & 63) + 1);
+  MOZ_ASSERT((uint32_t(mSize) & 63) == 56);
+
+  /* Convert size from bytes to bits. */
+  size <<= 3;
+  mU.mW[14] = NativeEndian::swapToBigEndian(uint32_t(size >> 32));
+  mU.mW[15] = NativeEndian::swapToBigEndian(uint32_t(size));
+  shaCompress(&mH[H2X], mU.mW);
+
+  /* Output hash. */
+  mU.mW[0] = NativeEndian::swapToBigEndian(mH[0]);
+  mU.mW[1] = NativeEndian::swapToBigEndian(mH[1]);
+  mU.mW[2] = NativeEndian::swapToBigEndian(mH[2]);
+  mU.mW[3] = NativeEndian::swapToBigEndian(mH[3]);
+  mU.mW[4] = NativeEndian::swapToBigEndian(mH[4]);
+  memcpy(aHashOut, mU.mW, 20);
+  mDone = true;
+}
+
+/*
+ *  SHA: Compression function, unrolled.
+ *
+ * Some operations in shaCompress are done as 5 groups of 16 operations.
+ * Others are done as 4 groups of 20 operations.
+ * The code below shows that structure.
+ *
+ * The functions that compute the new values of the 5 state variables
+ * A-E are done in 4 groups of 20 operations (or you may also think
+ * of them as being done in 16 groups of 5 operations).  They are
+ * done by the SHA_RNDx macros below, in the right column.
+ *
+ * The functions that set the 16 values of the W array are done in
+ * 5 groups of 16 operations.  The first group is done by the
+ * LOAD macros below, the latter 4 groups are done by SHA_MIX below,
+ * in the left column.
+ *
+ * gcc's optimizer observes that each member of the W array is assigned
+ * a value 5 times in this code.  It reduces the number of store
+ * operations done to the W array in the context (that is, in the X array)
+ * by creating a W array on the stack, and storing the W values there for
+ * the first 4 groups of operations on W, and storing the values in the
+ * context's W array only in the fifth group.  This is undesirable.
+ * It is MUCH bigger code than simply using the context's W array, because
+ * all the offsets to the W array in the stack are 32-bit signed offsets,
+ * and it is no faster than storing the values in the context's W array.
+ *
+ * The original code for sha_fast.c prevented this creation of a separate
+ * W array in the stack by creating a W array of 80 members, each of
+ * whose elements is assigned only once. It also separated the computations
+ * of the W array values and the computations of the values for the 5
+ * state variables into two separate passes, W's, then A-E's so that the
+ * second pass could be done all in registers (except for accessing the W
+ * array) on machines with fewer registers.  The method is suboptimal
+ * for machines with enough registers to do it all in one pass, and it
+ * necessitates using many instructions with 32-bit offsets.
+ *
+ * This code eliminates the separate W array on the stack by a completely
+ * different means: by declaring the X array volatile.  This prevents
+ * the optimizer from trying to reduce the use of the X array by the
+ * creation of a MORE expensive W array on the stack. The result is
+ * that all instructions use signed 8-bit offsets and not 32-bit offsets.
+ *
+ * The combination of this code and the -O3 optimizer flag on GCC 3.4.3
+ * results in code that is 3 times faster than the previous NSS sha_fast
+ * code on AMD64.
+ */
+static void
+shaCompress(volatile unsigned* aX, const uint32_t* aBuf)
+{
+  unsigned A, B, C, D, E;
+
+#define XH(n) aX[n - H2X]
+#define XW(n) aX[n - W2X]
+
+#define K0 0x5a827999L
+#define K1 0x6ed9eba1L
+#define K2 0x8f1bbcdcL
+#define K3 0xca62c1d6L
+
+#define SHA_RND1(a, b, c, d, e, n) \
+  a = SHA_ROTL(b, 5) + SHA_F1(c, d, e) + a + XW(n) + K0; c = SHA_ROTL(c, 30)
+#define SHA_RND2(a, b, c, d, e, n) \
+  a = SHA_ROTL(b, 5) + SHA_F2(c, d, e) + a + XW(n) + K1; c = SHA_ROTL(c, 30)
+#define SHA_RND3(a, b, c, d, e, n) \
+  a = SHA_ROTL(b, 5) + SHA_F3(c, d, e) + a + XW(n) + K2; c = SHA_ROTL(c, 30)
+#define SHA_RND4(a, b, c, d, e, n) \
+  a = SHA_ROTL(b ,5) + SHA_F4(c, d, e) + a + XW(n) + K3; c = SHA_ROTL(c, 30)
+
+#define LOAD(n) XW(n) = NativeEndian::swapToBigEndian(aBuf[n])
+
+  A = XH(0);
+  B = XH(1);
+  C = XH(2);
+  D = XH(3);
+  E = XH(4);
+
+  LOAD(0);		   SHA_RND1(E,A,B,C,D, 0);
+  LOAD(1);		   SHA_RND1(D,E,A,B,C, 1);
+  LOAD(2);		   SHA_RND1(C,D,E,A,B, 2);
+  LOAD(3);		   SHA_RND1(B,C,D,E,A, 3);
+  LOAD(4);		   SHA_RND1(A,B,C,D,E, 4);
+  LOAD(5);		   SHA_RND1(E,A,B,C,D, 5);
+  LOAD(6);		   SHA_RND1(D,E,A,B,C, 6);
+  LOAD(7);		   SHA_RND1(C,D,E,A,B, 7);
+  LOAD(8);		   SHA_RND1(B,C,D,E,A, 8);
+  LOAD(9);		   SHA_RND1(A,B,C,D,E, 9);
+  LOAD(10);		   SHA_RND1(E,A,B,C,D,10);
+  LOAD(11);		   SHA_RND1(D,E,A,B,C,11);
+  LOAD(12);		   SHA_RND1(C,D,E,A,B,12);
+  LOAD(13);		   SHA_RND1(B,C,D,E,A,13);
+  LOAD(14);		   SHA_RND1(A,B,C,D,E,14);
+  LOAD(15);		   SHA_RND1(E,A,B,C,D,15);
+
+  SHA_MIX( 0, 13,  8,  2); SHA_RND1(D,E,A,B,C, 0);
+  SHA_MIX( 1, 14,  9,  3); SHA_RND1(C,D,E,A,B, 1);
+  SHA_MIX( 2, 15, 10,  4); SHA_RND1(B,C,D,E,A, 2);
+  SHA_MIX( 3,  0, 11,  5); SHA_RND1(A,B,C,D,E, 3);
+
+  SHA_MIX( 4,  1, 12,  6); SHA_RND2(E,A,B,C,D, 4);
+  SHA_MIX( 5,  2, 13,  7); SHA_RND2(D,E,A,B,C, 5);
+  SHA_MIX( 6,  3, 14,  8); SHA_RND2(C,D,E,A,B, 6);
+  SHA_MIX( 7,  4, 15,  9); SHA_RND2(B,C,D,E,A, 7);
+  SHA_MIX( 8,  5,  0, 10); SHA_RND2(A,B,C,D,E, 8);
+  SHA_MIX( 9,  6,  1, 11); SHA_RND2(E,A,B,C,D, 9);
+  SHA_MIX(10,  7,  2, 12); SHA_RND2(D,E,A,B,C,10);
+  SHA_MIX(11,  8,  3, 13); SHA_RND2(C,D,E,A,B,11);
+  SHA_MIX(12,  9,  4, 14); SHA_RND2(B,C,D,E,A,12);
+  SHA_MIX(13, 10,  5, 15); SHA_RND2(A,B,C,D,E,13);
+  SHA_MIX(14, 11,  6,  0); SHA_RND2(E,A,B,C,D,14);
+  SHA_MIX(15, 12,  7,  1); SHA_RND2(D,E,A,B,C,15);
+
+  SHA_MIX( 0, 13,  8,  2); SHA_RND2(C,D,E,A,B, 0);
+  SHA_MIX( 1, 14,  9,  3); SHA_RND2(B,C,D,E,A, 1);
+  SHA_MIX( 2, 15, 10,  4); SHA_RND2(A,B,C,D,E, 2);
+  SHA_MIX( 3,  0, 11,  5); SHA_RND2(E,A,B,C,D, 3);
+  SHA_MIX( 4,  1, 12,  6); SHA_RND2(D,E,A,B,C, 4);
+  SHA_MIX( 5,  2, 13,  7); SHA_RND2(C,D,E,A,B, 5);
+  SHA_MIX( 6,  3, 14,  8); SHA_RND2(B,C,D,E,A, 6);
+  SHA_MIX( 7,  4, 15,  9); SHA_RND2(A,B,C,D,E, 7);
+
+  SHA_MIX( 8,  5,  0, 10); SHA_RND3(E,A,B,C,D, 8);
+  SHA_MIX( 9,  6,  1, 11); SHA_RND3(D,E,A,B,C, 9);
+  SHA_MIX(10,  7,  2, 12); SHA_RND3(C,D,E,A,B,10);
+  SHA_MIX(11,  8,  3, 13); SHA_RND3(B,C,D,E,A,11);
+  SHA_MIX(12,  9,  4, 14); SHA_RND3(A,B,C,D,E,12);
+  SHA_MIX(13, 10,  5, 15); SHA_RND3(E,A,B,C,D,13);
+  SHA_MIX(14, 11,  6,  0); SHA_RND3(D,E,A,B,C,14);
+  SHA_MIX(15, 12,  7,  1); SHA_RND3(C,D,E,A,B,15);
+
+  SHA_MIX( 0, 13,  8,  2); SHA_RND3(B,C,D,E,A, 0);
+  SHA_MIX( 1, 14,  9,  3); SHA_RND3(A,B,C,D,E, 1);
+  SHA_MIX( 2, 15, 10,  4); SHA_RND3(E,A,B,C,D, 2);
+  SHA_MIX( 3,  0, 11,  5); SHA_RND3(D,E,A,B,C, 3);
+  SHA_MIX( 4,  1, 12,  6); SHA_RND3(C,D,E,A,B, 4);
+  SHA_MIX( 5,  2, 13,  7); SHA_RND3(B,C,D,E,A, 5);
+  SHA_MIX( 6,  3, 14,  8); SHA_RND3(A,B,C,D,E, 6);
+  SHA_MIX( 7,  4, 15,  9); SHA_RND3(E,A,B,C,D, 7);
+  SHA_MIX( 8,  5,  0, 10); SHA_RND3(D,E,A,B,C, 8);
+  SHA_MIX( 9,  6,  1, 11); SHA_RND3(C,D,E,A,B, 9);
+  SHA_MIX(10,  7,  2, 12); SHA_RND3(B,C,D,E,A,10);
+  SHA_MIX(11,  8,  3, 13); SHA_RND3(A,B,C,D,E,11);
+
+  SHA_MIX(12,  9,  4, 14); SHA_RND4(E,A,B,C,D,12);
+  SHA_MIX(13, 10,  5, 15); SHA_RND4(D,E,A,B,C,13);
+  SHA_MIX(14, 11,  6,  0); SHA_RND4(C,D,E,A,B,14);
+  SHA_MIX(15, 12,  7,  1); SHA_RND4(B,C,D,E,A,15);
+
+  SHA_MIX( 0, 13,  8,  2); SHA_RND4(A,B,C,D,E, 0);
+  SHA_MIX( 1, 14,  9,  3); SHA_RND4(E,A,B,C,D, 1);
+  SHA_MIX( 2, 15, 10,  4); SHA_RND4(D,E,A,B,C, 2);
+  SHA_MIX( 3,  0, 11,  5); SHA_RND4(C,D,E,A,B, 3);
+  SHA_MIX( 4,  1, 12,  6); SHA_RND4(B,C,D,E,A, 4);
+  SHA_MIX( 5,  2, 13,  7); SHA_RND4(A,B,C,D,E, 5);
+  SHA_MIX( 6,  3, 14,  8); SHA_RND4(E,A,B,C,D, 6);
+  SHA_MIX( 7,  4, 15,  9); SHA_RND4(D,E,A,B,C, 7);
+  SHA_MIX( 8,  5,  0, 10); SHA_RND4(C,D,E,A,B, 8);
+  SHA_MIX( 9,  6,  1, 11); SHA_RND4(B,C,D,E,A, 9);
+  SHA_MIX(10,  7,  2, 12); SHA_RND4(A,B,C,D,E,10);
+  SHA_MIX(11,  8,  3, 13); SHA_RND4(E,A,B,C,D,11);
+  SHA_MIX(12,  9,  4, 14); SHA_RND4(D,E,A,B,C,12);
+  SHA_MIX(13, 10,  5, 15); SHA_RND4(C,D,E,A,B,13);
+  SHA_MIX(14, 11,  6,  0); SHA_RND4(B,C,D,E,A,14);
+  SHA_MIX(15, 12,  7,  1); SHA_RND4(A,B,C,D,E,15);
+
+  XH(0) += A;
+  XH(1) += B;
+  XH(2) += C;
+  XH(3) += D;
+  XH(4) += E;
+}
diff --git a/src/third_party/mozjs-45/mfbt/SHA1.h b/src/third_party/mozjs-45/mfbt/SHA1.h
new file mode 100644
index 0000000..ddccaa6
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/SHA1.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Simple class for computing SHA1. */
+
+#ifndef mozilla_SHA1_h
+#define mozilla_SHA1_h
+
+#include "mozilla/Types.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+namespace mozilla {
+
+/**
+ * This class computes the SHA1 hash of a byte sequence, or of the concatenation
+ * of multiple sequences.  For example, computing the SHA1 of two sequences of
+ * bytes could be done as follows:
+ *
+ *   void SHA1(const uint8_t* buf1, uint32_t size1,
+ *             const uint8_t* buf2, uint32_t size2,
+ *             SHA1Sum::Hash& hash)
+ *   {
+ *     SHA1Sum s;
+ *     s.update(buf1, size1);
+ *     s.update(buf2, size2);
+ *     s.finish(hash);
+ *   }
+ *
+ * The finish method may only be called once and cannot be followed by calls
+ * to update.
+ */
+class SHA1Sum
+{
+  union
+  {
+    uint32_t mW[16]; /* input buffer */
+    uint8_t mB[64];
+  } mU;
+  uint64_t mSize; /* count of hashed bytes. */
+  unsigned mH[22]; /* 5 state variables, 16 tmp values, 1 extra */
+  bool mDone;
+
+public:
+  MFBT_API SHA1Sum();
+
+  static const size_t kHashSize = 20;
+  typedef uint8_t Hash[kHashSize];
+
+  /* Add len bytes of dataIn to the data sequence being hashed. */
+  MFBT_API void update(const void* aData, uint32_t aLength);
+
+  /* Compute the final hash of all data into hashOut. */
+  MFBT_API void finish(SHA1Sum::Hash& aHashOut);
+};
+
+} /* namespace mozilla */
+
+#endif /* mozilla_SHA1_h */
diff --git a/src/third_party/mozjs-45/mfbt/STYLE b/src/third_party/mozjs-45/mfbt/STYLE
new file mode 100644
index 0000000..d16be61
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/STYLE
@@ -0,0 +1,11 @@
+MFBT uses standard Mozilla style, with the following exceptions.
+
+- Some of the files use a lower-case letter at the start of function names.
+  This is because MFBT used to use a different style, and was later converted
+  to standard Mozilla style. These functions have not been changed to use an
+  upper-case letter because it would cause a lot of churn in other parts of the
+  codebase. However, new files should follow standard Mozilla style and use an
+  upper-case letter at the start of function names.
+
+- Imported third-party code (such as decimal/*, double-conversion/*, and lz4*)
+  remains in its original style.
diff --git a/src/third_party/mozjs-45/mfbt/ScopeExit.h b/src/third_party/mozjs-45/mfbt/ScopeExit.h
new file mode 100644
index 0000000..7aff82d
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/ScopeExit.h
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* RAII class for executing arbitrary actions at scope end. */
+
+#ifndef mozilla_ScopeExit_h
+#define mozilla_ScopeExit_h
+
+/*
+ * See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189.pdf for a
+ * standards-track version of this.
+ *
+ * Error handling can be complex when various actions need to be performed that
+ * need to be undone if an error occurs midway. This can be handled with a
+ * collection of boolean state variables and gotos, which can get clunky and
+ * error-prone:
+ *
+ * {
+ *   if (!a.setup())
+ *       goto fail;
+ *   isASetup = true;
+ *
+ *   if (!b.setup())
+ *       goto fail;
+ *   isBSetup = true;
+ *
+ *   ...
+ *   return true;
+ *
+ *   fail:
+ *     if (isASetup)
+ *         a.teardown();
+ *     if (isBSetup)
+ *         b.teardown();
+ *     return false;
+ *  }
+ *
+ * ScopeExit is a mechanism to simplify this pattern by keeping an RAII guard
+ * class that will perform the teardown on destruction, unless released. So the
+ * above would become:
+ *
+ * {
+ *   if (!a.setup()) {
+ *       return false;
+ *   }
+ *   auto guardA = MakeScopeExit([&] {
+ *       a.teardown();
+ *   });
+ *
+ *   if (!b.setup()) {
+ *       return false;
+ *   }
+ *   auto guardB = MakeScopeExit([&] {
+ *       b.teardown();
+ *   });
+ *
+ *   ...
+ *   guardA.release();
+ *   guardB.release();
+ *   return true;
+ * }
+ *
+ * This header provides:
+ *
+ * - |ScopeExit| - a container for a cleanup call, automically called at the
+ *   end of the scope;
+ * - |MakeScopeExit| - a convenience function for constructing a |ScopeExit|
+ *   with a given cleanup routine, commonly used with a lambda function.
+ *
+ * Note that the RAII classes defined in this header do _not_ perform any form
+ * of reference-counting or garbage-collection. These classes have exactly two
+ * behaviors:
+ *
+ * - if |release()| has not been called, the cleanup is always performed at
+ *   the end of the scope;
+ * - if |release()| has been called, nothing will happen at the end of the
+ *   scope.
+ */
+
+#include "mozilla/GuardObjects.h"
+#include "mozilla/Move.h"
+
+namespace mozilla {
+
+template <typename ExitFunction>
+class MOZ_STACK_CLASS ScopeExit {
+  ExitFunction mExitFunction;
+  bool mExecuteOnDestruction;
+  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+
+public:
+  explicit ScopeExit(ExitFunction&& cleanup
+                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+   : mExitFunction(cleanup)
+   , mExecuteOnDestruction(true)
+  {
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+  }
+
+  ScopeExit(ScopeExit&& rhs)
+   : mExitFunction(mozilla::Move(rhs.mExitFunction))
+   , mExecuteOnDestruction(rhs.mExecuteOnDestruction)
+  {
+    rhs.release();
+  }
+
+  ~ScopeExit() {
+    if (mExecuteOnDestruction) {
+      mExitFunction();
+    }
+  }
+
+  void release() {
+    mExecuteOnDestruction = false;
+  }
+
+private:
+  explicit ScopeExit(const ScopeExit&) = delete;
+  ScopeExit& operator=(const ScopeExit&) = delete;
+  ScopeExit& operator=(ScopeExit&&) = delete;
+};
+
+template <typename ExitFunction>
+ScopeExit<ExitFunction>
+MakeScopeExit(ExitFunction&& exitFunction)
+{
+  return ScopeExit<ExitFunction>(mozilla::Move(exitFunction));
+}
+
+} /* namespace mozilla */
+
+#endif /* mozilla_ScopeExit_h */
diff --git a/src/third_party/mozjs-45/mfbt/Scoped.h b/src/third_party/mozjs-45/mfbt/Scoped.h
new file mode 100644
index 0000000..de8a166
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Scoped.h
@@ -0,0 +1,296 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* DEPRECATED: Use UniquePtr.h instead. */
+
+#ifndef mozilla_Scoped_h
+#define mozilla_Scoped_h
+
+/*
+ * DEPRECATED: Use UniquePtr.h instead.
+ *
+ * Resource Acquisition Is Initialization is a programming idiom used
+ * to write robust code that is able to deallocate resources properly,
+ * even in presence of execution errors or exceptions that need to be
+ * propagated.  The Scoped* classes defined in this header perform the
+ * deallocation of the resource they hold once program execution
+ * reaches the end of the scope for which they have been defined.
+ *
+ * This header provides the following RAII classes:
+ *
+ * - |ScopedFreePtr| - a container for a pointer, that automatically calls
+ *   |free()| at the end of the scope;
+ * - |ScopedDeletePtr| - a container for a pointer, that automatically calls
+ *   |delete| at the end of the scope;
+ *
+ * |ScopedDeleteArray| is removed in favor of |UniquePtr<T[]>|.
+ *
+ * The general scenario for each of the RAII classes is the following:
+ *
+ * ScopedClass foo(create_value());
+ * // ... In this scope, |foo| is defined. Use |foo.get()| or |foo.rwget()|
+ *        to access the value.
+ * // ... In case of |return| or |throw|, |foo| is deallocated automatically.
+ * // ... If |foo| needs to be returned or stored, use |foo.forget()|
+ *
+ * Note that the RAII classes defined in this header do _not_ perform any form
+ * of reference-counting or garbage-collection. These classes have exactly two
+ * behaviors:
+ *
+ * - if |forget()| has not been called, the resource is always deallocated at
+ *   the end of the scope;
+ * - if |forget()| has been called, any control on the resource is unbound
+ *   and the resource is not deallocated by the class.
+ *
+ * Extension:
+ *
+ * In addition, this header provides class |Scoped| and macros |SCOPED_TEMPLATE|
+ * and |MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE|  to simplify the definition
+ * of RAII classes for other scenarios. These macros have been used to
+ * automatically close file descriptors/file handles when reaching the end of
+ * the scope, graphics contexts, etc.
+ */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/GuardObjects.h"
+#include "mozilla/Move.h"
+
+namespace mozilla {
+
+/*
+ * Scoped is a helper to create RAII wrappers
+ * Type argument |Traits| is expected to have the following structure:
+ *
+ *   struct Traits
+ *   {
+ *     // Define the type of the value stored in the wrapper
+ *     typedef value_type type;
+ *     // Returns the value corresponding to the uninitialized or freed state
+ *     const static type empty();
+ *     // Release resources corresponding to the wrapped value
+ *     // This function is responsible for not releasing an |empty| value
+ *     const static void release(type);
+ *   }
+ */
+template<typename Traits>
+class MOZ_NON_TEMPORARY_CLASS Scoped
+{
+public:
+  typedef typename Traits::type Resource;
+
+  explicit Scoped(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
+    : mValue(Traits::empty())
+  {
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+  }
+
+  explicit Scoped(const Resource& aValue
+                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+    : mValue(aValue)
+  {
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+  }
+
+  /* Move constructor. */
+  Scoped(Scoped&& aOther
+         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+    : mValue(Move(aOther.mValue))
+  {
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+    aOther.mValue = Traits::empty();
+  }
+
+  ~Scoped() { Traits::release(mValue); }
+
+  // Constant getter
+  operator const Resource&() const { return mValue; }
+  const Resource& operator->() const { return mValue; }
+  const Resource& get() const { return mValue; }
+  // Non-constant getter.
+  Resource& rwget() { return mValue; }
+
+  /*
+   * Forget the resource.
+   *
+   * Once |forget| has been called, the |Scoped| is neutralized, i.e. it will
+   * have no effect at destruction (unless it is reset to another resource by
+   * |operator=|).
+   *
+   * @return The original resource.
+   */
+  Resource forget()
+  {
+    Resource tmp = mValue;
+    mValue = Traits::empty();
+    return tmp;
+  }
+
+  /*
+   * Perform immediate clean-up of this |Scoped|.
+   *
+   * If this |Scoped| is currently empty, this method has no effect.
+   */
+  void dispose()
+  {
+    Traits::release(mValue);
+    mValue = Traits::empty();
+  }
+
+  bool operator==(const Resource& aOther) const { return mValue == aOther; }
+
+  /*
+   * Replace the resource with another resource.
+   *
+   * Calling |operator=| has the side-effect of triggering clean-up. If you do
+   * not want to trigger clean-up, you should first invoke |forget|.
+   *
+   * @return this
+   */
+  Scoped& operator=(const Resource& aOther) { return reset(aOther); }
+
+  Scoped& reset(const Resource& aOther)
+  {
+    Traits::release(mValue);
+    mValue = aOther;
+    return *this;
+  }
+
+  /* Move assignment operator. */
+  Scoped& operator=(Scoped&& aRhs)
+  {
+    MOZ_ASSERT(&aRhs != this, "self-move-assignment not allowed");
+    this->~Scoped();
+    new(this) Scoped(Move(aRhs));
+    return *this;
+  }
+
+private:
+  explicit Scoped(const Scoped& aValue) = delete;
+  Scoped& operator=(const Scoped& aValue) = delete;
+
+private:
+  Resource mValue;
+  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+};
+
+/*
+ * SCOPED_TEMPLATE defines a templated class derived from Scoped
+ * This allows to implement templates such as ScopedFreePtr.
+ *
+ * @param name The name of the class to define.
+ * @param Traits A struct implementing clean-up. See the implementations
+ * for more details.
+ */
+#define SCOPED_TEMPLATE(name, Traits)                                         \
+template<typename Type>                                                       \
+struct MOZ_NON_TEMPORARY_CLASS name : public mozilla::Scoped<Traits<Type> >   \
+{                                                                             \
+  typedef mozilla::Scoped<Traits<Type> > Super;                               \
+  typedef typename Super::Resource Resource;                                  \
+  name& operator=(Resource aRhs)                                              \
+  {                                                                           \
+    Super::operator=(aRhs);                                                   \
+    return *this;                                                             \
+  }                                                                           \
+  name& operator=(name&& aRhs)                                                \
+  {                                                                           \
+    Super::operator=(Move(aRhs));                                             \
+    return *this;                                                             \
+  }                                                                           \
+  explicit name(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)                         \
+    : Super(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT)                   \
+  {}                                                                          \
+  explicit name(Resource aRhs                                                 \
+                MOZ_GUARD_OBJECT_NOTIFIER_PARAM)                              \
+    : Super(aRhs                                                              \
+            MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)                        \
+  {}                                                                          \
+  name(name&& aRhs                                                            \
+       MOZ_GUARD_OBJECT_NOTIFIER_PARAM)                                       \
+    : Super(Move(aRhs)                                                        \
+            MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)                        \
+  {}                                                                          \
+private:                                                                      \
+  explicit name(name&) = delete;                                              \
+  name& operator=(name&) = delete;                                            \
+};
+
+/*
+ * ScopedFreePtr is a RAII wrapper for pointers that need to be free()d.
+ *
+ *   struct S { ... };
+ *   ScopedFreePtr<S> foo = malloc(sizeof(S));
+ *   ScopedFreePtr<char> bar = strdup(str);
+ */
+template<typename T>
+struct ScopedFreePtrTraits
+{
+  typedef T* type;
+  static T* empty() { return nullptr; }
+  static void release(T* aPtr) { free(aPtr); }
+};
+SCOPED_TEMPLATE(ScopedFreePtr, ScopedFreePtrTraits)
+
+/*
+ * ScopedDeletePtr is a RAII wrapper for pointers that need to be deleted.
+ *
+ *   struct S { ... };
+ *   ScopedDeletePtr<S> foo = new S();
+ */
+template<typename T>
+struct ScopedDeletePtrTraits : public ScopedFreePtrTraits<T>
+{
+  static void release(T* aPtr) { delete aPtr; }
+};
+SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits)
+
+/*
+ * MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE makes it easy to create scoped
+ * pointers for types with custom deleters; just overload
+ * TypeSpecificDelete(T*) in the same namespace as T to call the deleter for
+ * type T.
+ *
+ * @param name The name of the class to define.
+ * @param Type A struct implementing clean-up. See the implementations
+ * for more details.
+ * *param Deleter The function that is used to delete/destroy/free a
+ *        non-null value of Type*.
+ *
+ * Example:
+ *
+ *   MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc, \
+ *                                             PR_Close)
+ *   ...
+ *   {
+ *       ScopedPRFileDesc file(PR_OpenFile(...));
+ *       ...
+ *   } // file is closed with PR_Close here
+ */
+#define MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(name, Type, Deleter) \
+template <> inline void TypeSpecificDelete(Type* aValue) { Deleter(aValue); } \
+typedef ::mozilla::TypeSpecificScopedPointer<Type> name;
+
+template <typename T> void TypeSpecificDelete(T* aValue);
+
+template <typename T>
+struct TypeSpecificScopedPointerTraits
+{
+  typedef T* type;
+  static type empty() { return nullptr; }
+  static void release(type aValue)
+  {
+    if (aValue) {
+      TypeSpecificDelete(aValue);
+    }
+  }
+};
+
+SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits)
+
+} /* namespace mozilla */
+
+#endif /* mozilla_Scoped_h */
diff --git a/src/third_party/mozjs-45/mfbt/SegmentedVector.h b/src/third_party/mozjs-45/mfbt/SegmentedVector.h
new file mode 100644
index 0000000..c626e89
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/SegmentedVector.h
@@ -0,0 +1,289 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// A simple segmented vector class.
+//
+// This class should be used in preference to mozilla::Vector or nsTArray when
+// you are simply gathering items in order to later iterate over them.
+//
+// - In the case where you don't know the final size in advance, using
+//   SegmentedVector avoids the need to repeatedly allocate increasingly large
+//   buffers and copy the data into them.
+//
+// - In the case where you know the final size in advance and so can set the
+//   capacity appropriately, using SegmentedVector still avoids the need for
+//   large allocations (which can trigger OOMs).
+
+#ifndef mozilla_SegmentedVector_h
+#define mozilla_SegmentedVector_h
+
+#include "mozilla/Alignment.h"
+#include "mozilla/AllocPolicy.h"
+#include "mozilla/Array.h"
+#include "mozilla/LinkedList.h"
+#include "mozilla/MemoryReporting.h"
+#include "mozilla/Move.h"
+#include "mozilla/TypeTraits.h"
+
+#include <new>  // for placement new
+
+namespace mozilla {
+
+// |IdealSegmentSize| specifies how big each segment will be in bytes (or as
+// close as is possible). Use the following guidelines to choose a size.
+//
+// - It should be a power-of-two, to avoid slop.
+//
+// - It should not be too small, so that segment allocations are infrequent,
+//   and so that per-segment bookkeeping overhead is low. Typically each
+//   segment should be able to hold hundreds of elements, at least.
+//
+// - It should not be too large, so that OOMs are unlikely when allocating
+//   segments, and so that not too much space is wasted when the final segment
+//   is not full.
+//
+// The ideal size depends on how the SegmentedVector is used and the size of
+// |T|, but reasonable sizes include 1024, 4096 (the default), 8192, and 16384.
+//
+template<typename T,
+         size_t IdealSegmentSize = 4096,
+         typename AllocPolicy = MallocAllocPolicy>
+class SegmentedVector : private AllocPolicy
+{
+  template<size_t SegmentCapacity>
+  struct SegmentImpl
+    : public mozilla::LinkedListElement<SegmentImpl<SegmentCapacity>>
+  {
+    SegmentImpl() : mLength(0) {}
+
+    ~SegmentImpl()
+    {
+      for (uint32_t i = 0; i < mLength; i++) {
+        (*this)[i].~T();
+      }
+    }
+
+    uint32_t Length() const { return mLength; }
+
+    T* Elems() { return reinterpret_cast<T*>(&mStorage.mBuf); }
+
+    T& operator[](size_t aIndex)
+    {
+      MOZ_ASSERT(aIndex < mLength);
+      return Elems()[aIndex];
+    }
+
+    const T& operator[](size_t aIndex) const
+    {
+      MOZ_ASSERT(aIndex < mLength);
+      return Elems()[aIndex];
+    }
+
+    template<typename U>
+    void Append(U&& aU)
+    {
+      MOZ_ASSERT(mLength < SegmentCapacity);
+      // Pre-increment mLength so that the bounds-check in operator[] passes.
+      mLength++;
+      T* elem = &(*this)[mLength - 1];
+      new (elem) T(mozilla::Forward<U>(aU));
+    }
+
+    void PopLast()
+    {
+      MOZ_ASSERT(mLength > 0);
+      (*this)[mLength - 1].~T();
+      mLength--;
+    }
+
+    uint32_t mLength;
+
+    // The union ensures that the elements are appropriately aligned.
+    union Storage
+    {
+      char mBuf[sizeof(T) * SegmentCapacity];
+      mozilla::AlignedElem<MOZ_ALIGNOF(T)> mAlign;
+    } mStorage;
+
+    static_assert(MOZ_ALIGNOF(T) == MOZ_ALIGNOF(Storage),
+                  "SegmentedVector provides incorrect alignment");
+  };
+
+  // See how many we elements we can fit in a segment of IdealSegmentSize. If
+  // IdealSegmentSize is too small, it'll be just one. The +1 is because
+  // kSingleElementSegmentSize already accounts for one element.
+  static const size_t kSingleElementSegmentSize = sizeof(SegmentImpl<1>);
+  static const size_t kSegmentCapacity =
+    kSingleElementSegmentSize <= IdealSegmentSize
+    ? (IdealSegmentSize - kSingleElementSegmentSize) / sizeof(T) + 1
+    : 1;
+
+  typedef SegmentImpl<kSegmentCapacity> Segment;
+
+public:
+  // The |aIdealSegmentSize| is only for sanity checking. If it's specified, we
+  // check that the actual segment size is as close as possible to it. This
+  // serves as a sanity check for SegmentedVectorCapacity's capacity
+  // computation.
+  explicit SegmentedVector(size_t aIdealSegmentSize = 0)
+  {
+    // The difference between the actual segment size and the ideal segment
+    // size should be less than the size of a single element... unless the
+    // ideal size was too small, in which case the capacity should be one.
+    MOZ_ASSERT_IF(
+      aIdealSegmentSize != 0,
+      (sizeof(Segment) > aIdealSegmentSize && kSegmentCapacity == 1) ||
+      aIdealSegmentSize - sizeof(Segment) < sizeof(T));
+  }
+
+  ~SegmentedVector() { Clear(); }
+
+  bool IsEmpty() const { return !mSegments.getFirst(); }
+
+  // Note that this is O(n) rather than O(1), but the constant factor is very
+  // small because it only has to do one addition per segment.
+  size_t Length() const
+  {
+    size_t n = 0;
+    for (auto segment = mSegments.getFirst();
+         segment;
+         segment = segment->getNext()) {
+      n += segment->Length();
+    }
+    return n;
+  }
+
+  // Returns false if the allocation failed. (If you are using an infallible
+  // allocation policy, use InfallibleAppend() instead.)
+  template<typename U>
+  MOZ_WARN_UNUSED_RESULT bool Append(U&& aU)
+  {
+    Segment* last = mSegments.getLast();
+    if (!last || last->Length() == kSegmentCapacity) {
+      last = this->template pod_malloc<Segment>(1);
+      if (!last) {
+        return false;
+      }
+      new (last) Segment();
+      mSegments.insertBack(last);
+    }
+    last->Append(mozilla::Forward<U>(aU));
+    return true;
+  }
+
+  // You should probably only use this instead of Append() if you are using an
+  // infallible allocation policy. It will crash if the allocation fails.
+  template<typename U>
+  void InfallibleAppend(U&& aU)
+  {
+    bool ok = Append(mozilla::Forward<U>(aU));
+    MOZ_RELEASE_ASSERT(ok);
+  }
+
+  void Clear()
+  {
+    Segment* segment;
+    while ((segment = mSegments.popFirst())) {
+      segment->~Segment();
+      this->free_(segment);
+    }
+  }
+
+  T& GetLast()
+  {
+    MOZ_ASSERT(!IsEmpty());
+    Segment* last = mSegments.getLast();
+    return (*last)[last->Length() - 1];
+  }
+
+  const T& GetLast() const
+  {
+    MOZ_ASSERT(!IsEmpty());
+    Segment* last = mSegments.getLast();
+    return (*last)[last->Length() - 1];
+  }
+
+  void PopLast()
+  {
+    MOZ_ASSERT(!IsEmpty());
+    Segment* last = mSegments.getLast();
+    last->PopLast();
+    if (!last->Length()) {
+      mSegments.popLast();
+      last->~Segment();
+      this->free_(last);
+    }
+  }
+
+  // Use this class to iterate over a SegmentedVector, like so:
+  //
+  //  for (auto iter = v.Iter(); !iter.Done(); iter.Next()) {
+  //    MyElem& elem = iter.Get();
+  //    f(elem);
+  //  }
+  //
+  class IterImpl
+  {
+    friend class SegmentedVector;
+
+    Segment* mSegment;
+    size_t mIndex;
+
+    explicit IterImpl(SegmentedVector* aVector)
+      : mSegment(aVector->mSegments.getFirst())
+      , mIndex(0)
+    {}
+
+  public:
+    bool Done() const { return !mSegment; }
+
+    T& Get()
+    {
+      MOZ_ASSERT(!Done());
+      return (*mSegment)[mIndex];
+    }
+
+    const T& Get() const
+    {
+      MOZ_ASSERT(!Done());
+      return (*mSegment)[mIndex];
+    }
+
+    void Next()
+    {
+      MOZ_ASSERT(!Done());
+      mIndex++;
+      if (mIndex == mSegment->Length()) {
+        mSegment = mSegment->getNext();
+        mIndex = 0;
+      }
+    }
+  };
+
+  IterImpl Iter() { return IterImpl(this); }
+
+  // Measure the memory consumption of the vector excluding |this|. Note that
+  // it only measures the vector itself. If the vector elements contain
+  // pointers to other memory blocks, those blocks must be measured separately
+  // during a subsequent iteration over the vector.
+  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
+  {
+    return mSegments.sizeOfExcludingThis(aMallocSizeOf);
+  }
+
+  // Like sizeOfExcludingThis(), but measures |this| as well.
+  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
+  {
+    return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
+  }
+
+private:
+  mozilla::LinkedList<Segment> mSegments;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_SegmentedVector_h */
diff --git a/src/third_party/mozjs-45/mfbt/SizePrintfMacros.h b/src/third_party/mozjs-45/mfbt/SizePrintfMacros.h
new file mode 100644
index 0000000..ec55c62
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/SizePrintfMacros.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Implements (nonstandard) PRI{ouxX}SIZE format macros for size_t types. */
+
+#ifndef mozilla_SizePrintfMacros_h_
+#define mozilla_SizePrintfMacros_h_
+
+/*
+ * MSVC's libc does not support C99's %z format length modifier for size_t
+ * types. Instead, we use Microsoft's nonstandard %I modifier for size_t, which
+ * is unsigned __int32 on 32-bit platforms and unsigned __int64 on 64-bit
+ * platforms:
+ *
+ * http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx
+ */
+
+#if defined(XP_WIN)
+#  define PRIoSIZE  "Io"
+#  define PRIuSIZE  "Iu"
+#  define PRIxSIZE  "Ix"
+#  define PRIXSIZE  "IX"
+#else
+#  define PRIoSIZE  "zo"
+#  define PRIuSIZE  "zu"
+#  define PRIxSIZE  "zx"
+#  define PRIXSIZE  "zX"
+#endif
+
+#endif  /* mozilla_SizePrintfMacros_h_ */
diff --git a/src/third_party/mozjs-45/mfbt/Snprintf.h b/src/third_party/mozjs-45/mfbt/Snprintf.h
new file mode 100644
index 0000000..864f7c2
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Snprintf.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Polyfills snprintf() on platforms that don't provide it, and provides
+ * related utilities. */
+
+#ifndef mozilla_Snprintf_h_
+#define mozilla_Snprintf_h_
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+// Older MSVC versions do not provide snprintf(), but they do provide
+// vsnprintf(), which has the same semantics except that if the number of
+// characters written equals the buffer size, it does not write a null
+// terminator, so we wrap it to do so.
+#if defined(_MSC_VER) && _MSC_VER < 1900
+#include "mozilla/Attributes.h"
+MOZ_ALWAYS_INLINE int snprintf(char* buffer, size_t n, const char* format, ...)
+{
+  va_list args;
+  va_start(args, format);
+  int result = vsnprintf(buffer, n, format, args);
+  va_end(args);
+  buffer[n - 1] = '\0';
+  return result;
+}
+#endif
+
+// In addition, in C++ code, on all platforms, provide an snprintf_literal()
+// function which uses template argument deduction to deduce the size of the
+// buffer, avoiding the need for the user to pass it in explicitly.
+#ifdef __cplusplus
+template <size_t N>
+int snprintf_literal(char (&buffer)[N], const char* format, ...)
+{
+  va_list args;
+  va_start(args, format);
+  int result = vsnprintf(buffer, N, format, args);
+  va_end(args);
+  buffer[N - 1] = '\0';
+  return result;
+}
+#endif
+
+#endif  /* mozilla_Snprintf_h_ */
diff --git a/src/third_party/mozjs-45/mfbt/SplayTree.h b/src/third_party/mozjs-45/mfbt/SplayTree.h
new file mode 100644
index 0000000..1a7e031
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/SplayTree.h
@@ -0,0 +1,329 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * A sorted tree with optimal access times, where recently-accessed elements
+ * are faster to access again.
+ */
+
+#ifndef mozilla_SplayTree_h
+#define mozilla_SplayTree_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+
+namespace mozilla {
+
+template<class T, class C>
+class SplayTree;
+
+template<typename T>
+class SplayTreeNode
+{
+public:
+  template<class A, class B>
+  friend class SplayTree;
+
+  SplayTreeNode()
+    : mLeft(nullptr)
+    , mRight(nullptr)
+    , mParent(nullptr)
+  {}
+
+private:
+  T* mLeft;
+  T* mRight;
+  T* mParent;
+};
+
+
+/**
+ * Class which represents a splay tree.
+ * Splay trees are balanced binary search trees for which search, insert and
+ * remove are all amortized O(log n), but where accessing a node makes it
+ * faster to access that node in the future.
+ *
+ * T indicates the type of tree elements, Comparator must have a static
+ * compare(const T&, const T&) method ordering the elements. The compare
+ * method must be free from side effects.
+ */
+template<typename T, class Comparator>
+class SplayTree
+{
+  T* mRoot;
+
+public:
+  MOZ_CONSTEXPR SplayTree()
+    : mRoot(nullptr)
+  {}
+
+  bool empty() const
+  {
+    return !mRoot;
+  }
+
+  T* find(const T& aValue)
+  {
+    if (empty()) {
+      return nullptr;
+    }
+
+    T* last = lookup(aValue);
+    splay(last);
+    return Comparator::compare(aValue, *last) == 0 ? last : nullptr;
+  }
+
+  bool insert(T* aValue)
+  {
+    MOZ_ASSERT(!find(*aValue), "Duplicate elements are not allowed.");
+
+    if (!mRoot) {
+      mRoot = aValue;
+      return true;
+    }
+    T* last = lookup(*aValue);
+    int cmp = Comparator::compare(*aValue, *last);
+
+    finishInsertion(last, cmp, aValue);
+    return true;
+  }
+
+  T* findOrInsert(const T& aValue);
+
+  T* remove(const T& aValue)
+  {
+    T* last = lookup(aValue);
+    MOZ_ASSERT(last, "This tree must contain the element being removed.");
+    MOZ_ASSERT(Comparator::compare(aValue, *last) == 0);
+
+    // Splay the tree so that the item to remove is the root.
+    splay(last);
+    MOZ_ASSERT(last == mRoot);
+
+    // Find another node which can be swapped in for the root: either the
+    // rightmost child of the root's left, or the leftmost child of the
+    // root's right.
+    T* swap;
+    T* swapChild;
+    if (mRoot->mLeft) {
+      swap = mRoot->mLeft;
+      while (swap->mRight) {
+        swap = swap->mRight;
+      }
+      swapChild = swap->mLeft;
+    } else if (mRoot->mRight) {
+      swap = mRoot->mRight;
+      while (swap->mLeft) {
+        swap = swap->mLeft;
+      }
+      swapChild = swap->mRight;
+    } else {
+      T* result = mRoot;
+      mRoot = nullptr;
+      return result;
+    }
+
+    // The selected node has at most one child, in swapChild. Detach it
+    // from the subtree by replacing it with that child.
+    if (swap == swap->mParent->mLeft) {
+      swap->mParent->mLeft = swapChild;
+    } else {
+      swap->mParent->mRight = swapChild;
+    }
+    if (swapChild) {
+      swapChild->mParent = swap->mParent;
+    }
+
+    // Make the selected node the new root.
+    mRoot = swap;
+    mRoot->mParent = nullptr;
+    mRoot->mLeft = last->mLeft;
+    mRoot->mRight = last->mRight;
+    if (mRoot->mLeft) {
+      mRoot->mLeft->mParent = mRoot;
+    }
+    if (mRoot->mRight) {
+      mRoot->mRight->mParent = mRoot;
+    }
+
+    return last;
+  }
+
+  T* removeMin()
+  {
+    MOZ_ASSERT(mRoot, "No min to remove!");
+
+    T* min = mRoot;
+    while (min->mLeft) {
+      min = min->mLeft;
+    }
+    return remove(*min);
+  }
+
+  // For testing purposes only.
+  void checkCoherency()
+  {
+    checkCoherency(mRoot, nullptr);
+  }
+
+private:
+  /**
+   * Returns the node in this comparing equal to |aValue|, or a node just
+   * greater or just less than |aValue| if there is no such node.
+   */
+  T* lookup(const T& aValue)
+  {
+    MOZ_ASSERT(!empty());
+
+    T* node = mRoot;
+    T* parent;
+    do {
+      parent = node;
+      int c = Comparator::compare(aValue, *node);
+      if (c == 0) {
+        return node;
+      } else if (c < 0) {
+        node = node->mLeft;
+      } else {
+        node = node->mRight;
+      }
+    } while (node);
+    return parent;
+  }
+
+  T* finishInsertion(T* aLast, int32_t aCmp, T* aNew)
+  {
+    MOZ_ASSERT(aCmp, "Nodes shouldn't be equal!");
+
+    T** parentPointer = (aCmp < 0) ? &aLast->mLeft : &aLast->mRight;
+    MOZ_ASSERT(!*parentPointer);
+    *parentPointer = aNew;
+    aNew->mParent = aLast;
+
+    splay(aNew);
+    return aNew;
+  }
+
+  /**
+   * Rotate the tree until |node| is at the root of the tree. Performing
+   * the rotations in this fashion preserves the amortized balancing of
+   * the tree.
+   */
+  void splay(T* aNode)
+  {
+    MOZ_ASSERT(aNode);
+
+    while (aNode != mRoot) {
+      T* parent = aNode->mParent;
+      if (parent == mRoot) {
+        // Zig rotation.
+        rotate(aNode);
+        MOZ_ASSERT(aNode == mRoot);
+        return;
+      }
+      T* grandparent = parent->mParent;
+      if ((parent->mLeft == aNode) == (grandparent->mLeft == parent)) {
+        // Zig-zig rotation.
+        rotate(parent);
+        rotate(aNode);
+      } else {
+        // Zig-zag rotation.
+        rotate(aNode);
+        rotate(aNode);
+      }
+    }
+  }
+
+  void rotate(T* aNode)
+  {
+    // Rearrange nodes so that aNode becomes the parent of its current
+    // parent, while preserving the sortedness of the tree.
+    T* parent = aNode->mParent;
+    if (parent->mLeft == aNode) {
+      //     x          y
+      //   y  c  ==>  a  x
+      //  a b           b c
+      parent->mLeft = aNode->mRight;
+      if (aNode->mRight) {
+        aNode->mRight->mParent = parent;
+      }
+      aNode->mRight = parent;
+    } else {
+      MOZ_ASSERT(parent->mRight == aNode);
+      //   x             y
+      //  a  y   ==>   x  c
+      //    b c       a b
+      parent->mRight = aNode->mLeft;
+      if (aNode->mLeft) {
+        aNode->mLeft->mParent = parent;
+      }
+      aNode->mLeft = parent;
+    }
+    aNode->mParent = parent->mParent;
+    parent->mParent = aNode;
+    if (T* grandparent = aNode->mParent) {
+      if (grandparent->mLeft == parent) {
+        grandparent->mLeft = aNode;
+      } else {
+        grandparent->mRight = aNode;
+      }
+    } else {
+      mRoot = aNode;
+    }
+  }
+
+  T* checkCoherency(T* aNode, T* aMinimum)
+  {
+    if (mRoot) {
+      MOZ_RELEASE_ASSERT(!mRoot->mParent);
+    }
+    if (!aNode) {
+      MOZ_RELEASE_ASSERT(!mRoot);
+      return nullptr;
+    }
+    if (!aNode->mParent) {
+      MOZ_RELEASE_ASSERT(aNode == mRoot);
+    }
+    if (aMinimum) {
+      MOZ_RELEASE_ASSERT(Comparator::compare(*aMinimum, *aNode) < 0);
+    }
+    if (aNode->mLeft) {
+      MOZ_RELEASE_ASSERT(aNode->mLeft->mParent == aNode);
+      T* leftMaximum = checkCoherency(aNode->mLeft, aMinimum);
+      MOZ_RELEASE_ASSERT(Comparator::compare(*leftMaximum, *aNode) < 0);
+    }
+    if (aNode->mRight) {
+      MOZ_RELEASE_ASSERT(aNode->mRight->mParent == aNode);
+      return checkCoherency(aNode->mRight, aNode);
+    }
+    return aNode;
+  }
+
+  SplayTree(const SplayTree&) = delete;
+  void operator=(const SplayTree&) = delete;
+};
+
+template<typename T, class Comparator>
+T*
+SplayTree<T, Comparator>::findOrInsert(const T& aValue)
+{
+  if (!mRoot) {
+    mRoot = new T(aValue);
+    return mRoot;
+  }
+
+  T* last = lookup(aValue);
+  int cmp = Comparator::compare(aValue, *last);
+  if (!cmp) {
+    return last;
+  }
+
+  return finishInsertion(last, cmp, new T(aValue));
+}
+
+}  /* namespace mozilla */
+
+#endif /* mozilla_SplayTree_h */
diff --git a/src/third_party/mozjs-45/mfbt/TaggedAnonymousMemory.cpp b/src/third_party/mozjs-45/mfbt/TaggedAnonymousMemory.cpp
new file mode 100644
index 0000000..a2ba9ee
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/TaggedAnonymousMemory.cpp
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifdef ANDROID
+
+#include "mozilla/TaggedAnonymousMemory.h"
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/prctl.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#include "mozilla/Assertions.h"
+
+// These constants are copied from <sys/prctl.h>, because the headers
+// used for building may not have them even though the running kernel
+// supports them.
+#ifndef PR_SET_VMA
+#define PR_SET_VMA		0x53564d41
+#endif
+#ifndef PR_SET_VMA_ANON_NAME
+#define PR_SET_VMA_ANON_NAME		0
+#endif
+
+namespace mozilla {
+
+// Returns 0 for success and -1 (with errno) for error.
+static int
+TagAnonymousMemoryAligned(const void* aPtr, size_t aLength, const char* aTag)
+{
+  return prctl(PR_SET_VMA,
+               PR_SET_VMA_ANON_NAME,
+               reinterpret_cast<unsigned long>(aPtr),
+               aLength,
+               reinterpret_cast<unsigned long>(aTag));
+}
+
+// On some architectures, it's possible for the page size to be larger
+// than the PAGE_SIZE we were compiled with.  This computes the
+// equivalent of PAGE_MASK.
+static uintptr_t
+GetPageMask()
+{
+  static uintptr_t mask = 0;
+
+  if (mask == 0) {
+    uintptr_t pageSize = sysconf(_SC_PAGESIZE);
+    mask = ~(pageSize - 1);
+    MOZ_ASSERT((pageSize & (pageSize - 1)) == 0,
+               "Page size must be a power of 2!");
+  }
+  return mask;
+}
+
+} // namespace mozilla
+
+int
+MozTaggedMemoryIsSupported(void)
+{
+  static int supported = -1;
+
+  if (supported == -1) {
+    // Tagging an empty range always "succeeds" if the feature is supported,
+    // regardless of the start pointer.
+    supported = mozilla::TagAnonymousMemoryAligned(nullptr, 0, nullptr) == 0;
+  }
+  return supported;
+}
+
+void
+MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag)
+{
+  if (MozTaggedMemoryIsSupported()) {
+    // The kernel will round up the end of the range to the next page
+    // boundary if it's not aligned (comments indicate this behavior
+    // is based on that of madvise), but it will reject the request if
+    // the start is not aligned.  We therefore round down the start
+    // address and adjust the length accordingly.
+    uintptr_t addr = reinterpret_cast<uintptr_t>(aPtr);
+    uintptr_t end = addr + aLength;
+    uintptr_t addrRounded = addr & mozilla::GetPageMask();
+    const void* ptrRounded = reinterpret_cast<const void*>(addrRounded);
+
+    mozilla::TagAnonymousMemoryAligned(ptrRounded, end - addrRounded, aTag);
+  }
+}
+
+void*
+MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags,
+                       int aFd, off_t aOffset, const char* aTag)
+{
+  void* mapped = mmap(aAddr, aLength, aProt, aFlags, aFd, aOffset);
+  if (MozTaggedMemoryIsSupported() &&
+      (aFlags & MAP_ANONYMOUS) == MAP_ANONYMOUS &&
+      mapped != MAP_FAILED) {
+    mozilla::TagAnonymousMemoryAligned(mapped, aLength, aTag);
+  }
+  return mapped;
+}
+
+#endif // ANDROID
diff --git a/src/third_party/mozjs-45/mfbt/TaggedAnonymousMemory.h b/src/third_party/mozjs-45/mfbt/TaggedAnonymousMemory.h
new file mode 100644
index 0000000..d26b06d
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/TaggedAnonymousMemory.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Some Linux kernels -- specifically, newer versions of Android and
+// some B2G devices -- have a feature for assigning names to ranges of
+// anonymous memory (i.e., memory that doesn't have a "name" in the
+// form of an underlying mapped file).  These names are reported in
+// /proc/<pid>/smaps alongside system-level memory usage information
+// such as Proportional Set Size (memory usage adjusted for sharing
+// between processes), which allows reporting this information at a
+// finer granularity than would otherwise be possible (e.g.,
+// separating malloc() heap from JS heap).
+//
+// Existing memory can be tagged with MozTagAnonymousMemory(); it will
+// tag the range of complete pages containing the given interval, so
+// the results may be inexact if the range isn't page-aligned.
+// MozTaggedAnonymousMmap() can be used like mmap() with an extra
+// parameter, and will tag the returned memory if the mapping was
+// successful (and if it was in fact anonymous).
+//
+// NOTE: The pointer given as the "tag" argument MUST remain valid as
+// long as the mapping exists.  The referenced string is read when
+// /proc/<pid>/smaps or /proc/<pid>/maps is read, not when the tag is
+// established, so freeing it or changing its contents will have
+// unexpected results.  Using a static string is probably best.
+//
+// Also note that this header can be used by both C and C++ code.
+
+#ifndef mozilla_TaggedAnonymousMemory_h
+#define mozilla_TaggedAnonymousMemory_h
+
+#ifndef XP_WIN
+
+#include <sys/types.h>
+#include <sys/mman.h>
+
+#include "mozilla/Types.h"
+
+#ifdef ANDROID
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+MFBT_API void
+MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag);
+
+MFBT_API void*
+MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags,
+                         int aFd, off_t aOffset, const char* aTag);
+
+MFBT_API int
+MozTaggedMemoryIsSupported(void);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#else // ANDROID
+
+static inline void
+MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag)
+{
+}
+
+static inline void*
+MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags,
+                       int aFd, off_t aOffset, const char* aTag)
+{
+  return mmap(aAddr, aLength, aProt, aFlags, aFd, aOffset);
+}
+
+static inline int
+MozTaggedMemoryIsSupported(void)
+{
+  return 0;
+}
+
+#endif // ANDROID
+
+#endif // !XP_WIN
+
+#endif // mozilla_TaggedAnonymousMemory_h
diff --git a/src/third_party/mozjs-45/mfbt/TemplateLib.h b/src/third_party/mozjs-45/mfbt/TemplateLib.h
new file mode 100644
index 0000000..6286452
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/TemplateLib.h
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Reusable template meta-functions on types and compile-time values.  Meta-
+ * functions are placed inside the 'tl' namespace to avoid conflict with non-
+ * meta functions of the same name (e.g., mozilla::tl::FloorLog2 vs.
+ * mozilla::FloorLog2).
+ *
+ * When constexpr support becomes universal, we should probably use that instead
+ * of some of these templates, for simplicity.
+ */
+
+#ifndef mozilla_TemplateLib_h
+#define mozilla_TemplateLib_h
+
+#include <limits.h>
+#include <stddef.h>
+
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+namespace tl {
+
+/** Compute min/max. */
+template<size_t I, size_t J>
+struct Min
+{
+  static const size_t value = I < J ? I : J;
+};
+template<size_t I, size_t J>
+struct Max
+{
+  static const size_t value = I > J ? I : J;
+};
+
+/** Compute floor(log2(i)). */
+template<size_t I>
+struct FloorLog2
+{
+  static const size_t value = 1 + FloorLog2<I / 2>::value;
+};
+template<> struct FloorLog2<0> { /* Error */ };
+template<> struct FloorLog2<1> { static const size_t value = 0; };
+
+/** Compute ceiling(log2(i)). */
+template<size_t I>
+struct CeilingLog2
+{
+  static const size_t value = FloorLog2<2 * I - 1>::value;
+};
+
+/** Round up to the nearest power of 2. */
+template<size_t I>
+struct RoundUpPow2
+{
+  static const size_t value = size_t(1) << CeilingLog2<I>::value;
+};
+template<>
+struct RoundUpPow2<0>
+{
+  static const size_t value = 1;
+};
+
+/** Compute the number of bits in the given unsigned type. */
+template<typename T>
+struct BitSize
+{
+  static const size_t value = sizeof(T) * CHAR_BIT;
+};
+
+/**
+ * Produce an N-bit mask, where N <= BitSize<size_t>::value.  Handle the
+ * language-undefined edge case when N = BitSize<size_t>::value.
+ */
+template<size_t N>
+struct NBitMask
+{
+  // Assert the precondition.  On success this evaluates to 0.  Otherwise it
+  // triggers divide-by-zero at compile time: a guaranteed compile error in
+  // C++11, and usually one in C++98.  Add this value to |value| to assure
+  // its computation.
+  static const size_t checkPrecondition =
+    0 / size_t(N < BitSize<size_t>::value);
+  static const size_t value = (size_t(1) << N) - 1 + checkPrecondition;
+};
+template<>
+struct NBitMask<BitSize<size_t>::value>
+{
+  static const size_t value = size_t(-1);
+};
+
+/**
+ * For the unsigned integral type size_t, compute a mask M for N such that
+ * for all X, !(X & M) implies X * N will not overflow (w.r.t size_t)
+ */
+template<size_t N>
+struct MulOverflowMask
+{
+  static const size_t value =
+    ~NBitMask<BitSize<size_t>::value - CeilingLog2<N>::value>::value;
+};
+template<> struct MulOverflowMask<0> { /* Error */ };
+template<> struct MulOverflowMask<1> { static const size_t value = 0; };
+
+/**
+ * And<bool...> computes the logical 'and' of its argument booleans.
+ *
+ * Examples:
+ *   mozilla::t1::And<true, true>::value is true.
+ *   mozilla::t1::And<true, false>::value is false.
+ *   mozilla::t1::And<>::value is true.
+ */
+
+template<bool...>
+struct And;
+
+template<>
+struct And<> : public TrueType { };
+
+template<bool C1, bool... Cn>
+struct And<C1, Cn...>
+  : public Conditional<C1, And<Cn...>, FalseType>::Type { };
+
+} // namespace tl
+
+} // namespace mozilla
+
+#endif /* mozilla_TemplateLib_h */
diff --git a/src/third_party/mozjs-45/mfbt/ThreadLocal.h b/src/third_party/mozjs-45/mfbt/ThreadLocal.h
new file mode 100644
index 0000000..79da298
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/ThreadLocal.h
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Cross-platform lightweight thread local data wrappers. */
+
+#ifndef mozilla_ThreadLocal_h
+#define mozilla_ThreadLocal_h
+
+#if defined(XP_WIN)
+// This file will get included in any file that wants to add a profiler mark.
+// In order to not bring <windows.h> together we could include windef.h and
+// winbase.h which are sufficient to get the prototypes for the Tls* functions.
+// # include <windef.h>
+// # include <winbase.h>
+// Unfortunately, even including these headers causes us to add a bunch of ugly
+// stuff to our namespace e.g #define CreateEvent CreateEventW
+extern "C" {
+__declspec(dllimport) void* __stdcall TlsGetValue(unsigned long);
+__declspec(dllimport) int __stdcall TlsSetValue(unsigned long, void*);
+__declspec(dllimport) unsigned long __stdcall TlsAlloc();
+}
+#else
+#  include <pthread.h>
+#  include <signal.h>
+#endif
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+// sig_safe_t denotes an atomic type which can be read or stored in a single
+// instruction.  This means that data of this type is safe to be manipulated
+// from a signal handler, or other similar asynchronous execution contexts.
+#if defined(XP_WIN)
+typedef unsigned long sig_safe_t;
+#else
+typedef sig_atomic_t sig_safe_t;
+#endif
+
+/*
+ * Thread Local Storage helpers.
+ *
+ * Usage:
+ *
+ * Only static-storage-duration (e.g. global variables, or static class members)
+ * objects of this class should be instantiated. This class relies on
+ * zero-initialization, which is implicit for static-storage-duration objects.
+ * It doesn't have a custom default constructor, to avoid static initializers.
+ *
+ * API usage:
+ *
+ * // Create a TLS item.
+ * //
+ * // Note that init() should be invoked exactly once, before any usage of set()
+ * // or get().
+ * mozilla::ThreadLocal<int> tlsKey;
+ * if (!tlsKey.init()) {
+ *   // deal with the error
+ * }
+ *
+ * // Set the TLS value
+ * tlsKey.set(123);
+ *
+ * // Get the TLS value
+ * int value = tlsKey.get();
+ */
+template<typename T>
+class ThreadLocal
+{
+#if defined(XP_WIN)
+  typedef unsigned long key_t;
+#else
+  typedef pthread_key_t key_t;
+#endif
+
+  // Integral types narrower than void* must be extended to avoid
+  // warnings from valgrind on some platforms.  This helper type
+  // achieves that without penalizing the common case of ThreadLocals
+  // instantiated using a pointer type.
+  template<typename S>
+  struct Helper
+  {
+    typedef uintptr_t Type;
+  };
+
+  template<typename S>
+  struct Helper<S *>
+  {
+    typedef S *Type;
+  };
+
+public:
+  MOZ_WARN_UNUSED_RESULT inline bool init();
+
+  inline T get() const;
+
+  inline void set(const T aValue);
+
+  bool initialized() const { return mInited; }
+
+private:
+  key_t mKey;
+  bool mInited;
+};
+
+template<typename T>
+inline bool
+ThreadLocal<T>::init()
+{
+  static_assert(mozilla::IsPointer<T>::value || mozilla::IsIntegral<T>::value,
+                "mozilla::ThreadLocal must be used with a pointer or "
+                "integral type");
+  static_assert(sizeof(T) <= sizeof(void*),
+                "mozilla::ThreadLocal can't be used for types larger than "
+                "a pointer");
+  MOZ_ASSERT(!initialized());
+#ifdef XP_WIN
+  mKey = TlsAlloc();
+  mInited = mKey != 0xFFFFFFFFUL; // TLS_OUT_OF_INDEXES
+#else
+  mInited = !pthread_key_create(&mKey, nullptr);
+#endif
+  return mInited;
+}
+
+template<typename T>
+inline T
+ThreadLocal<T>::get() const
+{
+  MOZ_ASSERT(initialized());
+  void* h;
+#ifdef XP_WIN
+  h = TlsGetValue(mKey);
+#else
+  h = pthread_getspecific(mKey);
+#endif
+  return static_cast<T>(reinterpret_cast<typename Helper<T>::Type>(h));
+}
+
+template<typename T>
+inline void
+ThreadLocal<T>::set(const T aValue)
+{
+  MOZ_ASSERT(initialized());
+  void* h = reinterpret_cast<void*>(static_cast<typename Helper<T>::Type>(aValue));
+#ifdef XP_WIN
+  bool succeeded = TlsSetValue(mKey, h);
+#else
+  bool succeeded = !pthread_setspecific(mKey, h);
+#endif
+  if (!succeeded) {
+    MOZ_CRASH();
+  }
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_ThreadLocal_h */
diff --git a/src/third_party/mozjs-45/mfbt/ToString.h b/src/third_party/mozjs-45/mfbt/ToString.h
new file mode 100644
index 0000000..f11cad5
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/ToString.h
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Utilities for converting an object to a string representation. */
+
+#ifndef mozilla_ToString_h
+#define mozilla_ToString_h
+
+#include <string>
+#include <sstream>
+
+namespace mozilla {
+
+/**
+ * A convenience function for converting an object to a string representation.
+ * Supports any object which can be streamed to an std::ostream.
+ */
+template<typename T>
+std::string
+ToString(const T& aValue)
+{
+  std::ostringstream stream;
+  stream << aValue;
+  return stream.str();
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_ToString_h */
diff --git a/src/third_party/mozjs-45/mfbt/Tuple.h b/src/third_party/mozjs-45/mfbt/Tuple.h
new file mode 100644
index 0000000..c1f39c1
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Tuple.h
@@ -0,0 +1,448 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A variadic tuple class. */
+
+#ifndef mozilla_Tuple_h
+#define mozilla_Tuple_h
+
+#include "mozilla/Move.h"
+#include "mozilla/Pair.h"
+#include "mozilla/TemplateLib.h"
+#include "mozilla/TypeTraits.h"
+
+#include <stddef.h>
+#include <utility>
+
+namespace mozilla {
+
+namespace detail {
+
+/*
+ * A helper class that allows passing around multiple variadic argument lists
+ * by grouping them.
+ */
+template<typename... Ts>
+struct Group;
+
+/*
+ * CheckConvertibility checks whether each type in a source pack of types
+ * is convertible to the corresponding type in a target pack of types.
+ *
+ * It is intended to be invoked like this:
+ *   CheckConvertibility<Group<SourceTypes...>, Group<TargetTypes...>>
+ * 'Group' is used to separate types in the two packs (otherwise if we just
+ * wrote 'CheckConvertibility<SourceTypes..., TargetTypes...', it couldn't
+ * know where the first pack ends and the second begins).
+ *
+ * Note that we need to check explicitly that the two packs are of the same
+ * size, because attempting to simultaneously expand two parameter packs
+ * is an error (and it would be a hard error, because it wouldn't be in the
+ * immediate context of the caller).
+ */
+
+template<typename Source, typename Target, bool SameSize>
+struct CheckConvertibilityImpl;
+
+template<typename Source, typename Target>
+struct CheckConvertibilityImpl<Source, Target, false>
+  : FalseType {};
+
+template<typename... SourceTypes, typename... TargetTypes>
+struct CheckConvertibilityImpl<Group<SourceTypes...>, Group<TargetTypes...>, true>
+  : IntegralConstant<bool, tl::And<IsConvertible<SourceTypes, TargetTypes>::value...>::value> { };
+
+template<typename Source, typename Target>
+struct CheckConvertibility;
+
+template<typename... SourceTypes, typename... TargetTypes>
+struct CheckConvertibility<Group<SourceTypes...>, Group<TargetTypes...>>
+  : CheckConvertibilityImpl<Group<SourceTypes...>, Group<TargetTypes...>,
+        sizeof...(SourceTypes) == sizeof...(TargetTypes)> { };
+
+/*
+ * TupleImpl is a helper class used to implement mozilla::Tuple.
+ * It represents one node in a recursive inheritance hierarchy.
+ * 'Index' is the 0-based index of the tuple element stored in this node;
+ * 'Elements...' are the types of the elements stored in this node and its
+ * base classes.
+ *
+ * Example:
+ *   Tuple<int, float, char> inherits from
+ *   TupleImpl<0, int, float, char>, which stores the 'int' and inherits from
+ *   TupleImpl<1, float, char>, which stores the 'float' and inherits from
+ *   TupleImpl<2, char>, which stores the 'char' and inherits from
+ *   TupleImpl<3>, which stores nothing and terminates the recursion.
+ *
+ * The purpose of the 'Index' parameter is to allow efficient index-based
+ * access to a tuple element: given a tuple, and an index 'I' that we wish to
+ * access, we can cast the tuple to the base which stores the I'th element
+ * by performing template argument deduction against 'TupleImpl<I, E...>',
+ * where 'I' is specified explicitly and 'E...' is deduced (this is what the
+ * non-member 'Get<N>(t)' function does).
+ *
+ * This implementation strategy is borrowed from libstdc++'s std::tuple
+ * implementation.
+ */
+template<std::size_t Index, typename... Elements>
+struct TupleImpl;
+
+/*
+ * The base case of the inheritance recursion (and also the implementation
+ * of an empty tuple).
+ */
+template<std::size_t Index>
+struct TupleImpl<Index> {};
+
+/*
+ * One node of the recursive inheritance hierarchy. It stores the element at
+ * index 'Index' of a tuple, of type 'HeadT', and inherits from the nodes
+ * that store the remaining elements, of types 'TailT...'.
+ */
+template<std::size_t Index, typename HeadT, typename... TailT>
+struct TupleImpl<Index, HeadT, TailT...>
+  : public TupleImpl<Index + 1, TailT...>
+{
+  typedef TupleImpl<Index + 1, TailT...> Base;
+
+  // Accessors for the head and the tail.
+  // These are static, because the intended usage is for the caller to,
+  // given a tuple, obtain the type B of the base class which stores the
+  // element of interest, and then call B::Head(tuple) to access it.
+  // (Tail() is mostly for internal use, but is exposed for consistency.)
+  static HeadT& Head(TupleImpl& aTuple) { return aTuple.mHead; }
+  static const HeadT& Head(const TupleImpl& aTuple) { return aTuple.mHead; }
+  static Base& Tail(TupleImpl& aTuple) { return aTuple; }
+  static const Base& Tail(const TupleImpl& aTuple) { return aTuple; }
+
+  TupleImpl() : Base(), mHead() { }
+
+  // Construct from const references to the elements.
+  explicit TupleImpl(const HeadT& aHead, const TailT&... aTail)
+    : Base(aTail...), mHead(aHead) { }
+
+  // Construct from objects that are convertible to the elements.
+  // This constructor is enabled only when the argument types are actually
+  // convertible to the element types, otherwise it could become a better
+  // match for certain invocations than the copy constructor.
+  template <typename OtherHeadT, typename... OtherTailT,
+            typename = typename EnableIf<
+                CheckConvertibility<
+                    Group<OtherHeadT, OtherTailT...>,
+                    Group<HeadT, TailT...>>::value>::Type>
+  explicit TupleImpl(OtherHeadT&& aHead, OtherTailT&&... aTail)
+    : Base(Forward<OtherTailT>(aTail)...), mHead(Forward<OtherHeadT>(aHead)) { }
+
+  // Copy and move constructors.
+  // We'd like to use '= default' to implement these, but MSVC 2013's support
+  // for '= default' is incomplete and this doesn't work.
+  TupleImpl(const TupleImpl& aOther)
+    : Base(Tail(aOther))
+    , mHead(Head(aOther)) {}
+  TupleImpl(TupleImpl&& aOther)
+    : Base(Move(Tail(aOther)))
+    , mHead(Forward<HeadT>(Head(aOther))) {}
+
+  // Assign from a tuple whose elements are convertible to the elements
+  // of this tuple.
+  template <typename... OtherElements,
+            typename = typename EnableIf<
+                sizeof...(OtherElements) == sizeof...(TailT) + 1>::Type>
+  TupleImpl& operator=(const TupleImpl<Index, OtherElements...>& aOther)
+  {
+    typedef TupleImpl<Index, OtherElements...> OtherT;
+    Head(*this) = OtherT::Head(aOther);
+    Tail(*this) = OtherT::Tail(aOther);
+    return *this;
+  }
+  template <typename... OtherElements,
+            typename = typename EnableIf<
+                sizeof...(OtherElements) == sizeof...(TailT) + 1>::Type>
+  TupleImpl& operator=(TupleImpl<Index, OtherElements...>&& aOther)
+  {
+    typedef TupleImpl<Index, OtherElements...> OtherT;
+    Head(*this) = Move(OtherT::Head(aOther));
+    Tail(*this) = Move(OtherT::Tail(aOther));
+    return *this;
+  }
+
+  // Copy and move assignment operators.
+  TupleImpl& operator=(const TupleImpl& aOther)
+  {
+    Head(*this) = Head(aOther);
+    Tail(*this) = Tail(aOther);
+    return *this;
+  }
+  TupleImpl& operator=(TupleImpl&& aOther)
+  {
+    Head(*this) = Move(Head(aOther));
+    Tail(*this) = Move(Tail(aOther));
+    return *this;
+  }
+private:
+  HeadT mHead;  // The element stored at this index in the tuple.
+};
+
+} // namespace detail
+
+/**
+ * Tuple is a class that stores zero or more objects, whose types are specified
+ * as template parameters. It can be thought of as a generalization of Pair,
+ * (which can be thought of as a 2-tuple).
+ *
+ * Tuple allows index-based access to its elements (with the index having to be
+ * known at compile time) via the non-member function 'Get<N>(tuple)'.
+ */
+template<typename... Elements>
+class Tuple : public detail::TupleImpl<0, Elements...>
+{
+  typedef detail::TupleImpl<0, Elements...> Impl;
+public:
+  // The constructors and assignment operators here are simple wrappers
+  // around those in TupleImpl.
+
+  Tuple() : Impl() { }
+  explicit Tuple(const Elements&... aElements) : Impl(aElements...) { }
+  // Here, we can't just use 'typename... OtherElements' because MSVC will give
+  // a warning "C4520: multiple default constructors specified" (even if no one
+  // actually instantiates the constructor with an empty parameter pack -
+  // that's probably a bug) and we compile with warnings-as-errors.
+  template <typename OtherHead, typename... OtherTail,
+            typename = typename EnableIf<
+                detail::CheckConvertibility<
+                    detail::Group<OtherHead, OtherTail...>,
+                    detail::Group<Elements...>>::value>::Type>
+  explicit Tuple(OtherHead&& aHead, OtherTail&&... aTail)
+    : Impl(Forward<OtherHead>(aHead), Forward<OtherTail>(aTail)...) { }
+  Tuple(const Tuple& aOther) : Impl(aOther) { }
+  Tuple(Tuple&& aOther) : Impl(Move(aOther)) { }
+
+  template <typename... OtherElements,
+            typename = typename EnableIf<
+                sizeof...(OtherElements) == sizeof...(Elements)>::Type>
+  Tuple& operator=(const Tuple<OtherElements...>& aOther)
+  {
+    static_cast<Impl&>(*this) = aOther;
+    return *this;
+  }
+  template <typename... OtherElements,
+            typename = typename EnableIf<
+                sizeof...(OtherElements) == sizeof...(Elements)>::Type>
+  Tuple& operator=(Tuple<OtherElements...>&& aOther)
+  {
+    static_cast<Impl&>(*this) = Move(aOther);
+    return *this;
+  }
+  Tuple& operator=(const Tuple& aOther)
+  {
+    static_cast<Impl&>(*this) = aOther;
+    return *this;
+  }
+  Tuple& operator=(Tuple&& aOther)
+  {
+    static_cast<Impl&>(*this) = Move(aOther);
+    return *this;
+  }
+};
+
+/**
+ * Specialization of Tuple for two elements.
+ * This is created to support construction and assignment from a Pair or std::pair.
+ */
+template <typename A, typename B>
+class Tuple<A, B> : public detail::TupleImpl<0, A, B>
+{
+  typedef detail::TupleImpl<0, A, B> Impl;
+
+public:
+  // The constructors and assignment operators here are simple wrappers
+  // around those in TupleImpl.
+
+  Tuple() : Impl() { }
+  explicit Tuple(const A& aA, const B& aB) : Impl(aA, aB) { }
+  template <typename AArg, typename BArg,
+            typename = typename EnableIf<
+                detail::CheckConvertibility<
+                    detail::Group<AArg, BArg>,
+                    detail::Group<A, B>>::value>::Type>
+  explicit Tuple(AArg&& aA, BArg&& aB)
+    : Impl(Forward<AArg>(aA), Forward<BArg>(aB)) { }
+  Tuple(const Tuple& aOther) : Impl(aOther) { }
+  Tuple(Tuple&& aOther) : Impl(Move(aOther)) { }
+  explicit Tuple(const Pair<A, B>& aOther)
+    : Impl(aOther.first(), aOther.second()) { }
+  explicit Tuple(Pair<A, B>&& aOther) : Impl(Forward<A>(aOther.first()),
+                                    Forward<B>(aOther.second())) { }
+  explicit Tuple(const std::pair<A, B>& aOther)
+    : Impl(aOther.first, aOther.second) { }
+  explicit Tuple(std::pair<A, B>&& aOther) : Impl(Forward<A>(aOther.first),
+                                    Forward<B>(aOther.second)) { }
+
+  template <typename AArg, typename BArg>
+  Tuple& operator=(const Tuple<AArg, BArg>& aOther)
+  {
+    static_cast<Impl&>(*this) = aOther;
+    return *this;
+  }
+  template <typename AArg, typename BArg>
+  Tuple& operator=(Tuple<AArg, BArg>&& aOther)
+  {
+    static_cast<Impl&>(*this) = Move(aOther);
+    return *this;
+  }
+  Tuple& operator=(const Tuple& aOther)
+  {
+    static_cast<Impl&>(*this) = aOther;
+    return *this;
+  }
+  Tuple& operator=(Tuple&& aOther)
+  {
+    static_cast<Impl&>(*this) = Move(aOther);
+    return *this;
+  }
+  template <typename AArg, typename BArg>
+  Tuple& operator=(const Pair<AArg, BArg>& aOther)
+  {
+    Impl::Head(*this) = aOther.first();
+    Impl::Tail(*this).Head(*this) = aOther.second();
+    return *this;
+  }
+  template <typename AArg, typename BArg>
+  Tuple& operator=(Pair<AArg, BArg>&& aOther)
+  {
+    Impl::Head(*this) = Forward<AArg>(aOther.first());
+    Impl::Tail(*this).Head(*this) = Forward<BArg>(aOther.second());
+    return *this;
+  }
+  template <typename AArg, typename BArg>
+  Tuple& operator=(const std::pair<AArg, BArg>& aOther)
+  {
+    Impl::Head(*this) = aOther.first;
+    Impl::Tail(*this).Head(*this) = aOther.second;
+    return *this;
+  }
+  template <typename AArg, typename BArg>
+  Tuple& operator=(std::pair<AArg, BArg>&& aOther)
+  {
+    Impl::Head(*this) = Forward<AArg>(aOther.first);
+    Impl::Tail(*this).Head(*this) = Forward<BArg>(aOther.second);
+    return *this;
+  }
+};
+
+/**
+ * Specialization of Tuple for zero arguments.
+ * This is necessary because if the primary template were instantiated with
+ * an empty parameter pack, the 'Tuple(Elements...)' constructors would
+ * become illegal overloads of the default constructor.
+ */
+template <>
+class Tuple<> {};
+
+namespace detail {
+
+/*
+ * Helper functions for implementing Get<N>(tuple).
+ * These functions take a TupleImpl<Index, Elements...>, with Index being
+ * explicitly specified, and Elements being deduced. By passing a Tuple
+ * object as argument, template argument deduction will do its magic and
+ * cast the tuple to the base class which stores the element at Index.
+ */
+
+// Const reference version.
+template<std::size_t Index, typename... Elements>
+auto TupleGetHelper(TupleImpl<Index, Elements...>& aTuple)
+    -> decltype(TupleImpl<Index, Elements...>::Head(aTuple))
+{
+  return TupleImpl<Index, Elements...>::Head(aTuple);
+}
+
+// Non-const reference version.
+template<std::size_t Index, typename... Elements>
+auto TupleGetHelper(const TupleImpl<Index, Elements...>& aTuple)
+    -> decltype(TupleImpl<Index, Elements...>::Head(aTuple))
+{
+  return TupleImpl<Index, Elements...>::Head(aTuple);
+}
+
+} // namespace detail
+
+/**
+ * Index-based access to an element of a tuple.
+ * The syntax is Get<Index>(tuple). The index is zero-based.
+ *
+ * Example:
+ *
+ * Tuple<int, float, char> t;
+ * ...
+ * float f = Get<1>(t);
+ */
+
+// Non-const reference version.
+template<std::size_t Index, typename... Elements>
+auto Get(Tuple<Elements...>& aTuple)
+    -> decltype(detail::TupleGetHelper<Index>(aTuple))
+{
+  return detail::TupleGetHelper<Index>(aTuple);
+}
+
+// Const reference version.
+template<std::size_t Index, typename... Elements>
+auto Get(const Tuple<Elements...>& aTuple)
+    -> decltype(detail::TupleGetHelper<Index>(aTuple))
+{
+  return detail::TupleGetHelper<Index>(aTuple);
+}
+
+// Rvalue reference version.
+template<std::size_t Index, typename... Elements>
+auto Get(Tuple<Elements...>&& aTuple)
+    -> decltype(Move(mozilla::Get<Index>(aTuple)))
+{
+  // We need a 'mozilla::' qualification here to avoid
+  // name lookup only finding the current function.
+  return Move(mozilla::Get<Index>(aTuple));
+}
+
+/**
+ * A convenience function for constructing a tuple out of a sequence of
+ * values without specifying the type of the tuple.
+ * The type of the tuple is deduced from the types of its elements.
+ *
+ * Example:
+ *
+ * auto tuple = MakeTuple(42, 0.5f, 'c');  // has type Tuple<int, float, char>
+ */
+template<typename... Elements>
+inline Tuple<typename Decay<Elements>::Type...>
+MakeTuple(Elements&&... aElements)
+{
+  return Tuple<typename Decay<Elements>::Type...>(Forward<Elements>(aElements)...);
+}
+
+/**
+ * A convenience function for constructing a tuple of references to a
+ * sequence of variables. Since assignments to the elements of the tuple
+ * "go through" to the referenced variables, this can be used to "unpack"
+ * a tuple into individual variables.
+ *
+ * Example:
+ *
+ * int i;
+ * float f;
+ * char c;
+ * Tie(i, f, c) = FunctionThatReturnsATuple();
+ */
+template<typename... Elements>
+inline Tuple<Elements&...>
+Tie(Elements&... aVariables)
+{
+  return Tuple<Elements&...>(aVariables...);
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_Tuple_h */
diff --git a/src/third_party/mozjs-45/mfbt/TypeTraits.h b/src/third_party/mozjs-45/mfbt/TypeTraits.h
new file mode 100644
index 0000000..2952b54
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/TypeTraits.h
@@ -0,0 +1,1216 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Template-based metaprogramming and type-testing facilities. */
+
+#ifndef mozilla_TypeTraits_h
+#define mozilla_TypeTraits_h
+
+#include "mozilla/Types.h"
+
+/*
+ * These traits are approximate copies of the traits and semantics from C++11's
+ * <type_traits> header.  Don't add traits not in that header!  When all
+ * platforms provide that header, we can convert all users and remove this one.
+ */
+
+#include <wchar.h>
+
+namespace mozilla {
+
+/* Forward declarations. */
+
+template<typename> struct RemoveCV;
+template<typename> struct AddRvalueReference;
+
+/* 20.2.4 Function template declval [declval] */
+
+/**
+ * DeclVal simplifies the definition of expressions which occur as unevaluated
+ * operands. It converts T to a reference type, making it possible to use in
+ * decltype expressions even if T does not have a default constructor, e.g.:
+ * decltype(DeclVal<TWithNoDefaultConstructor>().foo())
+ */
+template<typename T>
+typename AddRvalueReference<T>::Type DeclVal();
+
+/* 20.9.3 Helper classes [meta.help] */
+
+/**
+ * Helper class used as a base for various type traits, exposed publicly
+ * because <type_traits> exposes it as well.
+ */
+template<typename T, T Value>
+struct IntegralConstant
+{
+  static const T value = Value;
+  typedef T ValueType;
+  typedef IntegralConstant<T, Value> Type;
+};
+
+/** Convenient aliases. */
+typedef IntegralConstant<bool, true> TrueType;
+typedef IntegralConstant<bool, false> FalseType;
+
+/* 20.9.4 Unary type traits [meta.unary] */
+
+/* 20.9.4.1 Primary type categories [meta.unary.cat] */
+
+namespace detail {
+
+template<typename T>
+struct IsVoidHelper : FalseType {};
+
+template<>
+struct IsVoidHelper<void> : TrueType {};
+
+} // namespace detail
+
+/**
+ * IsVoid determines whether a type is void.
+ *
+ * mozilla::IsVoid<int>::value is false;
+ * mozilla::IsVoid<void>::value is true;
+ * mozilla::IsVoid<void*>::value is false;
+ * mozilla::IsVoid<volatile void>::value is true.
+ */
+template<typename T>
+struct IsVoid : detail::IsVoidHelper<typename RemoveCV<T>::Type> {};
+
+namespace detail {
+
+template <typename T>
+struct IsIntegralHelper : FalseType {};
+
+template<> struct IsIntegralHelper<char>               : TrueType {};
+template<> struct IsIntegralHelper<signed char>        : TrueType {};
+template<> struct IsIntegralHelper<unsigned char>      : TrueType {};
+template<> struct IsIntegralHelper<short>              : TrueType {};
+template<> struct IsIntegralHelper<unsigned short>     : TrueType {};
+template<> struct IsIntegralHelper<int>                : TrueType {};
+template<> struct IsIntegralHelper<unsigned int>       : TrueType {};
+template<> struct IsIntegralHelper<long>               : TrueType {};
+template<> struct IsIntegralHelper<unsigned long>      : TrueType {};
+template<> struct IsIntegralHelper<long long>          : TrueType {};
+template<> struct IsIntegralHelper<unsigned long long> : TrueType {};
+template<> struct IsIntegralHelper<bool>               : TrueType {};
+template<> struct IsIntegralHelper<wchar_t>            : TrueType {};
+#ifdef MOZ_CHAR16_IS_NOT_WCHAR
+template<> struct IsIntegralHelper<char16_t>           : TrueType {};
+#endif
+
+} /* namespace detail */
+
+/**
+ * IsIntegral determines whether a type is an integral type.
+ *
+ * mozilla::IsIntegral<int>::value is true;
+ * mozilla::IsIntegral<unsigned short>::value is true;
+ * mozilla::IsIntegral<const long>::value is true;
+ * mozilla::IsIntegral<int*>::value is false;
+ * mozilla::IsIntegral<double>::value is false;
+ *
+ * Note that the behavior of IsIntegral on char16_t and char32_t is
+ * unspecified.
+ */
+template<typename T>
+struct IsIntegral : detail::IsIntegralHelper<typename RemoveCV<T>::Type>
+{};
+
+template<typename T, typename U>
+struct IsSame;
+
+namespace detail {
+
+template<typename T>
+struct IsFloatingPointHelper
+  : IntegralConstant<bool,
+                     IsSame<T, float>::value ||
+                     IsSame<T, double>::value ||
+                     IsSame<T, long double>::value>
+{};
+
+} // namespace detail
+
+/**
+ * IsFloatingPoint determines whether a type is a floating point type (float,
+ * double, long double).
+ *
+ * mozilla::IsFloatingPoint<int>::value is false;
+ * mozilla::IsFloatingPoint<const float>::value is true;
+ * mozilla::IsFloatingPoint<long double>::value is true;
+ * mozilla::IsFloatingPoint<double*>::value is false.
+ */
+template<typename T>
+struct IsFloatingPoint
+  : detail::IsFloatingPointHelper<typename RemoveCV<T>::Type>
+{};
+
+namespace detail {
+
+template<typename T>
+struct IsArrayHelper : FalseType {};
+
+template<typename T, decltype(sizeof(1)) N>
+struct IsArrayHelper<T[N]> : TrueType {};
+
+template<typename T>
+struct IsArrayHelper<T[]> : TrueType {};
+
+} // namespace detail
+
+/**
+ * IsArray determines whether a type is an array type, of known or unknown
+ * length.
+ *
+ * mozilla::IsArray<int>::value is false;
+ * mozilla::IsArray<int[]>::value is true;
+ * mozilla::IsArray<int[5]>::value is true.
+ */
+template<typename T>
+struct IsArray : detail::IsArrayHelper<typename RemoveCV<T>::Type>
+{};
+
+namespace detail {
+
+template<typename T>
+struct IsFunPtr;
+
+template<typename>
+struct IsFunPtr
+  : public FalseType
+{};
+
+template<typename Result, typename... ArgTypes>
+struct IsFunPtr<Result(*)(ArgTypes...)>
+  : public TrueType
+{};
+
+}; // namespace detail
+
+/**
+ * IsFunction determines whether a type is a function type. Function pointers
+ * don't qualify here--only the type of an actual function symbol. We do not
+ * correctly handle varags function types because of a bug in MSVC.
+ *
+ * Given the function:
+ *   void f(int) {}
+ *
+ * mozilla::IsFunction<void(int)> is true;
+ * mozilla::IsFunction<void(*)(int)> is false;
+ * mozilla::IsFunction<decltype(f)> is true.
+ */
+template<typename T>
+struct IsFunction
+  : public detail::IsFunPtr<typename RemoveCV<T>::Type *>
+{};
+
+namespace detail {
+
+template<typename T>
+struct IsPointerHelper : FalseType {};
+
+template<typename T>
+struct IsPointerHelper<T*> : TrueType {};
+
+} // namespace detail
+
+/**
+ * IsPointer determines whether a type is a possibly-CV-qualified pointer type
+ * (but not a pointer-to-member type).
+ *
+ * mozilla::IsPointer<struct S*>::value is true;
+ * mozilla::IsPointer<int*>::value is true;
+ * mozilla::IsPointer<int**>::value is true;
+ * mozilla::IsPointer<const int*>::value is true;
+ * mozilla::IsPointer<int* const>::value is true;
+ * mozilla::IsPointer<int* volatile>::value is true;
+ * mozilla::IsPointer<void (*)(void)>::value is true;
+ * mozilla::IsPointer<int>::value is false;
+ * mozilla::IsPointer<struct S>::value is false.
+ * mozilla::IsPointer<int(struct S::*)>::value is false
+ */
+template<typename T>
+struct IsPointer : detail::IsPointerHelper<typename RemoveCV<T>::Type>
+{};
+
+/**
+ * IsLvalueReference determines whether a type is an lvalue reference.
+ *
+ * mozilla::IsLvalueReference<struct S*>::value is false;
+ * mozilla::IsLvalueReference<int**>::value is false;
+ * mozilla::IsLvalueReference<void (*)(void)>::value is false;
+ * mozilla::IsLvalueReference<int>::value is false;
+ * mozilla::IsLvalueReference<struct S>::value is false;
+ * mozilla::IsLvalueReference<struct S*&>::value is true;
+ * mozilla::IsLvalueReference<struct S&&>::value is false.
+ */
+template<typename T>
+struct IsLvalueReference : FalseType {};
+
+template<typename T>
+struct IsLvalueReference<T&> : TrueType {};
+
+/**
+ * IsRvalueReference determines whether a type is an rvalue reference.
+ *
+ * mozilla::IsRvalueReference<struct S*>::value is false;
+ * mozilla::IsRvalueReference<int**>::value is false;
+ * mozilla::IsRvalueReference<void (*)(void)>::value is false;
+ * mozilla::IsRvalueReference<int>::value is false;
+ * mozilla::IsRvalueReference<struct S>::value is false;
+ * mozilla::IsRvalueReference<struct S*&>::value is false;
+ * mozilla::IsRvalueReference<struct S&&>::value is true.
+ */
+template<typename T>
+struct IsRvalueReference : FalseType {};
+
+template<typename T>
+struct IsRvalueReference<T&&> : TrueType {};
+
+namespace detail {
+
+// __is_enum is a supported extension across all of our supported compilers.
+template<typename T>
+struct IsEnumHelper
+  : IntegralConstant<bool, __is_enum(T)>
+{};
+
+} // namespace detail
+
+/**
+ * IsEnum determines whether a type is an enum type.
+ *
+ * mozilla::IsEnum<enum S>::value is true;
+ * mozilla::IsEnum<enum S*>::value is false;
+ * mozilla::IsEnum<int>::value is false;
+ */
+template<typename T>
+struct IsEnum
+  : detail::IsEnumHelper<typename RemoveCV<T>::Type>
+{};
+
+namespace detail {
+
+// __is_class is a supported extension across all of our supported compilers:
+// http://llvm.org/releases/3.0/docs/ClangReleaseNotes.html
+// http://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Type-Traits.html#Type-Traits
+// http://msdn.microsoft.com/en-us/library/ms177194%28v=vs.100%29.aspx
+template<typename T>
+struct IsClassHelper
+  : IntegralConstant<bool, __is_class(T)>
+{};
+
+} // namespace detail
+
+/**
+ * IsClass determines whether a type is a class type (but not a union).
+ *
+ * struct S {};
+ * union U {};
+ * mozilla::IsClass<int>::value is false;
+ * mozilla::IsClass<const S>::value is true;
+ * mozilla::IsClass<U>::value is false;
+ */
+template<typename T>
+struct IsClass
+  : detail::IsClassHelper<typename RemoveCV<T>::Type>
+{};
+
+/* 20.9.4.2 Composite type traits [meta.unary.comp] */
+
+/**
+ * IsReference determines whether a type is an lvalue or rvalue reference.
+ *
+ * mozilla::IsReference<struct S*>::value is false;
+ * mozilla::IsReference<int**>::value is false;
+ * mozilla::IsReference<int&>::value is true;
+ * mozilla::IsReference<void (*)(void)>::value is false;
+ * mozilla::IsReference<const int&>::value is true;
+ * mozilla::IsReference<int>::value is false;
+ * mozilla::IsReference<struct S>::value is false;
+ * mozilla::IsReference<struct S&>::value is true;
+ * mozilla::IsReference<struct S*&>::value is true;
+ * mozilla::IsReference<struct S&&>::value is true.
+ */
+template<typename T>
+struct IsReference
+  : IntegralConstant<bool,
+                     IsLvalueReference<T>::value || IsRvalueReference<T>::value>
+{};
+
+/**
+ * IsArithmetic determines whether a type is arithmetic.  A type is arithmetic
+ * iff it is an integral type or a floating point type.
+ *
+ * mozilla::IsArithmetic<int>::value is true;
+ * mozilla::IsArithmetic<double>::value is true;
+ * mozilla::IsArithmetic<long double*>::value is false.
+ */
+template<typename T>
+struct IsArithmetic
+  : IntegralConstant<bool, IsIntegral<T>::value || IsFloatingPoint<T>::value>
+{};
+
+/* 20.9.4.3 Type properties [meta.unary.prop] */
+
+/**
+ * IsConst determines whether a type is const or not.
+ *
+ * mozilla::IsConst<int>::value is false;
+ * mozilla::IsConst<void* const>::value is true;
+ * mozilla::IsConst<const char*>::value is false.
+ */
+template<typename T>
+struct IsConst : FalseType {};
+
+template<typename T>
+struct IsConst<const T> : TrueType {};
+
+/**
+ * IsVolatile determines whether a type is volatile or not.
+ *
+ * mozilla::IsVolatile<int>::value is false;
+ * mozilla::IsVolatile<void* volatile>::value is true;
+ * mozilla::IsVolatile<volatile char*>::value is false.
+ */
+template<typename T>
+struct IsVolatile : FalseType {};
+
+template<typename T>
+struct IsVolatile<volatile T> : TrueType {};
+
+/**
+ * Traits class for identifying POD types.  Until C++11 there's no automatic
+ * way to detect PODs, so for the moment this is done manually.  Users may
+ * define specializations of this class that inherit from mozilla::TrueType and
+ * mozilla::FalseType (or equivalently mozilla::IntegralConstant<bool, true or
+ * false>, or conveniently from mozilla::IsPod for composite types) as needed to
+ * ensure correct IsPod behavior.
+ */
+template<typename T>
+struct IsPod : public FalseType {};
+
+template<> struct IsPod<char>               : TrueType {};
+template<> struct IsPod<signed char>        : TrueType {};
+template<> struct IsPod<unsigned char>      : TrueType {};
+template<> struct IsPod<short>              : TrueType {};
+template<> struct IsPod<unsigned short>     : TrueType {};
+template<> struct IsPod<int>                : TrueType {};
+template<> struct IsPod<unsigned int>       : TrueType {};
+template<> struct IsPod<long>               : TrueType {};
+template<> struct IsPod<unsigned long>      : TrueType {};
+template<> struct IsPod<long long>          : TrueType {};
+template<> struct IsPod<unsigned long long> : TrueType {};
+template<> struct IsPod<bool>               : TrueType {};
+template<> struct IsPod<float>              : TrueType {};
+template<> struct IsPod<double>             : TrueType {};
+template<> struct IsPod<wchar_t>            : TrueType {};
+#ifdef MOZ_CHAR16_IS_NOT_WCHAR
+template<> struct IsPod<char16_t>           : TrueType {};
+#endif
+template<typename T> struct IsPod<T*>       : TrueType {};
+
+namespace detail {
+
+// __is_empty is a supported extension across all of our supported compilers:
+// http://llvm.org/releases/3.0/docs/ClangReleaseNotes.html
+// http://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Type-Traits.html#Type-Traits
+// http://msdn.microsoft.com/en-us/library/ms177194%28v=vs.100%29.aspx
+template<typename T>
+struct IsEmptyHelper
+  : IntegralConstant<bool, IsClass<T>::value && __is_empty(T)>
+{};
+
+} // namespace detail
+
+/**
+ * IsEmpty determines whether a type is a class (but not a union) that is empty.
+ *
+ * A class is empty iff it and all its base classes have no non-static data
+ * members (except bit-fields of length 0) and no virtual member functions, and
+ * no base class is empty or a virtual base class.
+ *
+ * Intuitively, empty classes don't have any data that has to be stored in
+ * instances of those classes.  (The size of the class must still be non-zero,
+ * because distinct array elements of any type must have different addresses.
+ * However, if the Empty Base Optimization is implemented by the compiler [most
+ * compilers implement it, and in certain cases C++11 requires it], the size of
+ * a class inheriting from an empty |Base| class need not be inflated by
+ * |sizeof(Base)|.)  And intuitively, non-empty classes have data members and/or
+ * vtable pointers that must be stored in each instance for proper behavior.
+ *
+ *   static_assert(!mozilla::IsEmpty<int>::value, "not a class => not empty");
+ *   union U1 { int x; };
+ *   static_assert(!mozilla::IsEmpty<U1>::value, "not a class => not empty");
+ *   struct E1 {};
+ *   struct E2 { int : 0 };
+ *   struct E3 : E1 {};
+ *   struct E4 : E2 {};
+ *   static_assert(mozilla::IsEmpty<E1>::value &&
+ *                 mozilla::IsEmpty<E2>::value &&
+ *                 mozilla::IsEmpty<E3>::value &&
+ *                 mozilla::IsEmpty<E4>::value,
+ *                 "all empty");
+ *   union U2 { E1 e1; };
+ *   static_assert(!mozilla::IsEmpty<U2>::value, "not a class => not empty");
+ *   struct NE1 { int x; };
+ *   struct NE2 : virtual E1 {};
+ *   struct NE3 : E2 { virtual ~NE3() {} };
+ *   struct NE4 { virtual void f() {} };
+ *   static_assert(!mozilla::IsEmpty<NE1>::value &&
+ *                 !mozilla::IsEmpty<NE2>::value &&
+ *                 !mozilla::IsEmpty<NE3>::value &&
+ *                 !mozilla::IsEmpty<NE4>::value,
+ *                 "all empty");
+ */
+template<typename T>
+struct IsEmpty : detail::IsEmptyHelper<typename RemoveCV<T>::Type>
+{};
+
+
+namespace detail {
+
+template<typename T,
+         bool = IsFloatingPoint<T>::value,
+         bool = IsIntegral<T>::value,
+         typename NoCV = typename RemoveCV<T>::Type>
+struct IsSignedHelper;
+
+// Floating point is signed.
+template<typename T, typename NoCV>
+struct IsSignedHelper<T, true, false, NoCV> : TrueType {};
+
+// Integral is conditionally signed.
+template<typename T, typename NoCV>
+struct IsSignedHelper<T, false, true, NoCV>
+  : IntegralConstant<bool, bool(NoCV(-1) < NoCV(1))>
+{};
+
+// Non-floating point, non-integral is not signed.
+template<typename T, typename NoCV>
+struct IsSignedHelper<T, false, false, NoCV> : FalseType {};
+
+} // namespace detail
+
+/**
+ * IsSigned determines whether a type is a signed arithmetic type.  |char| is
+ * considered a signed type if it has the same representation as |signed char|.
+ *
+ * mozilla::IsSigned<int>::value is true;
+ * mozilla::IsSigned<const unsigned int>::value is false;
+ * mozilla::IsSigned<unsigned char>::value is false;
+ * mozilla::IsSigned<float>::value is true.
+ */
+template<typename T>
+struct IsSigned : detail::IsSignedHelper<T> {};
+
+namespace detail {
+
+template<typename T,
+         bool = IsFloatingPoint<T>::value,
+         bool = IsIntegral<T>::value,
+         typename NoCV = typename RemoveCV<T>::Type>
+struct IsUnsignedHelper;
+
+// Floating point is not unsigned.
+template<typename T, typename NoCV>
+struct IsUnsignedHelper<T, true, false, NoCV> : FalseType {};
+
+// Integral is conditionally unsigned.
+template<typename T, typename NoCV>
+struct IsUnsignedHelper<T, false, true, NoCV>
+  : IntegralConstant<bool,
+                     (IsSame<NoCV, bool>::value || bool(NoCV(1) < NoCV(-1)))>
+{};
+
+// Non-floating point, non-integral is not unsigned.
+template<typename T, typename NoCV>
+struct IsUnsignedHelper<T, false, false, NoCV> : FalseType {};
+
+} // namespace detail
+
+/**
+ * IsUnsigned determines whether a type is an unsigned arithmetic type.
+ *
+ * mozilla::IsUnsigned<int>::value is false;
+ * mozilla::IsUnsigned<const unsigned int>::value is true;
+ * mozilla::IsUnsigned<unsigned char>::value is true;
+ * mozilla::IsUnsigned<float>::value is false.
+ */
+template<typename T>
+struct IsUnsigned : detail::IsUnsignedHelper<T> {};
+
+/* 20.9.5 Type property queries [meta.unary.prop.query] */
+
+/* 20.9.6 Relationships between types [meta.rel] */
+
+/**
+ * IsSame tests whether two types are the same type.
+ *
+ * mozilla::IsSame<int, int>::value is true;
+ * mozilla::IsSame<int*, int*>::value is true;
+ * mozilla::IsSame<int, unsigned int>::value is false;
+ * mozilla::IsSame<void, void>::value is true;
+ * mozilla::IsSame<const int, int>::value is false;
+ * mozilla::IsSame<struct S, struct S>::value is true.
+ */
+template<typename T, typename U>
+struct IsSame : FalseType {};
+
+template<typename T>
+struct IsSame<T, T> : TrueType {};
+
+namespace detail {
+
+#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
+
+template<class Base, class Derived>
+struct BaseOfTester : IntegralConstant<bool, __is_base_of(Base, Derived)> {};
+
+#else
+
+// The trickery used to implement IsBaseOf here makes it possible to use it for
+// the cases of private and multiple inheritance.  This code was inspired by the
+// sample code here:
+//
+// http://stackoverflow.com/questions/2910979/how-is-base-of-works
+template<class Base, class Derived>
+struct BaseOfHelper
+{
+public:
+  operator Base*() const;
+  operator Derived*();
+};
+
+template<class Base, class Derived>
+struct BaseOfTester
+{
+private:
+  template<class T>
+  static char test(Derived*, T);
+  static int test(Base*, int);
+
+public:
+  static const bool value =
+    sizeof(test(BaseOfHelper<Base, Derived>(), int())) == sizeof(char);
+};
+
+template<class Base, class Derived>
+struct BaseOfTester<Base, const Derived>
+{
+private:
+  template<class T>
+  static char test(Derived*, T);
+  static int test(Base*, int);
+
+public:
+  static const bool value =
+    sizeof(test(BaseOfHelper<Base, Derived>(), int())) == sizeof(char);
+};
+
+template<class Base, class Derived>
+struct BaseOfTester<Base&, Derived&> : FalseType {};
+
+template<class Type>
+struct BaseOfTester<Type, Type> : TrueType {};
+
+template<class Type>
+struct BaseOfTester<Type, const Type> : TrueType {};
+
+#endif
+
+} /* namespace detail */
+
+/*
+ * IsBaseOf allows to know whether a given class is derived from another.
+ *
+ * Consider the following class definitions:
+ *
+ *   class A {};
+ *   class B : public A {};
+ *   class C {};
+ *
+ * mozilla::IsBaseOf<A, B>::value is true;
+ * mozilla::IsBaseOf<A, C>::value is false;
+ */
+template<class Base, class Derived>
+struct IsBaseOf
+  : IntegralConstant<bool, detail::BaseOfTester<Base, Derived>::value>
+{};
+
+namespace detail {
+
+// This belongs inside ConvertibleTester, but it's pulled out to
+// work around a bug in the compiler used for hazard builds.
+template <typename To>
+static void ConvertibleTestHelper(To);
+
+template<typename From, typename To>
+struct ConvertibleTester
+{
+private:
+  template<typename From1, typename To1,
+           typename = decltype(ConvertibleTestHelper<To1>(DeclVal<From>()))>
+  static char test(int);
+
+  template<typename From1, typename To1>
+  static int test(...);
+
+public:
+  static const bool value =
+    sizeof(test<From, To>(0)) == sizeof(char);
+};
+
+} // namespace detail
+
+/**
+ * IsConvertible determines whether a value of type From will implicitly convert
+ * to a value of type To.  For example:
+ *
+ *   struct A {};
+ *   struct B : public A {};
+ *   struct C {};
+ *
+ * mozilla::IsConvertible<A, A>::value is true;
+ * mozilla::IsConvertible<A*, A*>::value is true;
+ * mozilla::IsConvertible<B, A>::value is true;
+ * mozilla::IsConvertible<B*, A*>::value is true;
+ * mozilla::IsConvertible<C, A>::value is false;
+ * mozilla::IsConvertible<A, C>::value is false;
+ * mozilla::IsConvertible<A*, C*>::value is false;
+ * mozilla::IsConvertible<C*, A*>::value is false.
+ *
+ * For obscure reasons, you can't use IsConvertible when the types being tested
+ * are related through private inheritance, and you'll get a compile error if
+ * you try.  Just don't do it!
+ *
+ * Note - we need special handling for void, which ConvertibleTester doesn't
+ * handle. The void handling here doesn't handle const/volatile void correctly,
+ * which could be easily fixed if the need arises.
+ */
+template<typename From, typename To>
+struct IsConvertible
+  : IntegralConstant<bool, detail::ConvertibleTester<From, To>::value>
+{};
+
+template<typename B>
+struct IsConvertible<void, B>
+  : IntegralConstant<bool, IsVoid<B>::value>
+{};
+
+template<typename A>
+struct IsConvertible<A, void>
+  : IntegralConstant<bool, IsVoid<A>::value>
+{};
+
+template<>
+struct IsConvertible<void, void>
+  : TrueType
+{};
+
+/* 20.9.7 Transformations between types [meta.trans] */
+
+/* 20.9.7.1 Const-volatile modifications [meta.trans.cv] */
+
+/**
+ * RemoveConst removes top-level const qualifications on a type.
+ *
+ * mozilla::RemoveConst<int>::Type is int;
+ * mozilla::RemoveConst<const int>::Type is int;
+ * mozilla::RemoveConst<const int*>::Type is const int*;
+ * mozilla::RemoveConst<int* const>::Type is int*.
+ */
+template<typename T>
+struct RemoveConst
+{
+  typedef T Type;
+};
+
+template<typename T>
+struct RemoveConst<const T>
+{
+  typedef T Type;
+};
+
+/**
+ * RemoveVolatile removes top-level volatile qualifications on a type.
+ *
+ * mozilla::RemoveVolatile<int>::Type is int;
+ * mozilla::RemoveVolatile<volatile int>::Type is int;
+ * mozilla::RemoveVolatile<volatile int*>::Type is volatile int*;
+ * mozilla::RemoveVolatile<int* volatile>::Type is int*.
+ */
+template<typename T>
+struct RemoveVolatile
+{
+  typedef T Type;
+};
+
+template<typename T>
+struct RemoveVolatile<volatile T>
+{
+  typedef T Type;
+};
+
+/**
+ * RemoveCV removes top-level const and volatile qualifications on a type.
+ *
+ * mozilla::RemoveCV<int>::Type is int;
+ * mozilla::RemoveCV<const int>::Type is int;
+ * mozilla::RemoveCV<volatile int>::Type is int;
+ * mozilla::RemoveCV<int* const volatile>::Type is int*.
+ */
+template<typename T>
+struct RemoveCV
+{
+  typedef typename RemoveConst<typename RemoveVolatile<T>::Type>::Type Type;
+};
+
+/* 20.9.7.2 Reference modifications [meta.trans.ref] */
+
+/**
+ * Converts reference types to the underlying types.
+ *
+ * mozilla::RemoveReference<T>::Type is T;
+ * mozilla::RemoveReference<T&>::Type is T;
+ * mozilla::RemoveReference<T&&>::Type is T;
+ */
+
+template<typename T>
+struct RemoveReference
+{
+  typedef T Type;
+};
+
+template<typename T>
+struct RemoveReference<T&>
+{
+  typedef T Type;
+};
+
+template<typename T>
+struct RemoveReference<T&&>
+{
+  typedef T Type;
+};
+
+template<bool Condition, typename A, typename B>
+struct Conditional;
+
+namespace detail {
+
+enum Voidness { TIsVoid, TIsNotVoid };
+
+template<typename T, Voidness V = IsVoid<T>::value ? TIsVoid : TIsNotVoid>
+struct AddLvalueReferenceHelper;
+
+template<typename T>
+struct AddLvalueReferenceHelper<T, TIsVoid>
+{
+  typedef void Type;
+};
+
+template<typename T>
+struct AddLvalueReferenceHelper<T, TIsNotVoid>
+{
+  typedef T& Type;
+};
+
+} // namespace detail
+
+/**
+ * AddLvalueReference adds an lvalue & reference to T if one isn't already
+ * present. (Note: adding an lvalue reference to an rvalue && reference in
+ * essence replaces the && with a &&, per C+11 reference collapsing rules. For
+ * example, int&& would become int&.)
+ *
+ * The final computed type will only *not* be an lvalue reference if T is void.
+ *
+ * mozilla::AddLvalueReference<int>::Type is int&;
+ * mozilla::AddLvalueRference<volatile int&>::Type is volatile int&;
+ * mozilla::AddLvalueReference<void*>::Type is void*&;
+ * mozilla::AddLvalueReference<void>::Type is void;
+ * mozilla::AddLvalueReference<struct S&&>::Type is struct S&.
+ */
+template<typename T>
+struct AddLvalueReference
+  : detail::AddLvalueReferenceHelper<T>
+{};
+
+namespace detail {
+
+template<typename T, Voidness V = IsVoid<T>::value ? TIsVoid : TIsNotVoid>
+struct AddRvalueReferenceHelper;
+
+template<typename T>
+struct AddRvalueReferenceHelper<T, TIsVoid>
+{
+  typedef void Type;
+};
+
+template<typename T>
+struct AddRvalueReferenceHelper<T, TIsNotVoid>
+{
+  typedef T&& Type;
+};
+
+} // namespace detail
+
+/**
+ * AddRvalueReference adds an rvalue && reference to T if one isn't already
+ * present. (Note: adding an rvalue reference to an lvalue & reference in
+ * essence keeps the &, per C+11 reference collapsing rules. For example,
+ * int& would remain int&.)
+ *
+ * The final computed type will only *not* be a reference if T is void.
+ *
+ * mozilla::AddRvalueReference<int>::Type is int&&;
+ * mozilla::AddRvalueRference<volatile int&>::Type is volatile int&;
+ * mozilla::AddRvalueRference<const int&&>::Type is const int&&;
+ * mozilla::AddRvalueReference<void*>::Type is void*&&;
+ * mozilla::AddRvalueReference<void>::Type is void;
+ * mozilla::AddRvalueReference<struct S&>::Type is struct S&.
+ */
+template<typename T>
+struct AddRvalueReference
+  : detail::AddRvalueReferenceHelper<T>
+{};
+
+/* 20.9.7.3 Sign modifications [meta.trans.sign] */
+
+template<bool B, typename T = void>
+struct EnableIf;
+
+namespace detail {
+
+template<bool MakeConst, typename T>
+struct WithC : Conditional<MakeConst, const T, T>
+{};
+
+template<bool MakeVolatile, typename T>
+struct WithV : Conditional<MakeVolatile, volatile T, T>
+{};
+
+
+template<bool MakeConst, bool MakeVolatile, typename T>
+struct WithCV : WithC<MakeConst, typename WithV<MakeVolatile, T>::Type>
+{};
+
+template<typename T>
+struct CorrespondingSigned;
+
+template<>
+struct CorrespondingSigned<char> { typedef signed char Type; };
+template<>
+struct CorrespondingSigned<unsigned char> { typedef signed char Type; };
+template<>
+struct CorrespondingSigned<unsigned short> { typedef short Type; };
+template<>
+struct CorrespondingSigned<unsigned int> { typedef int Type; };
+template<>
+struct CorrespondingSigned<unsigned long> { typedef long Type; };
+template<>
+struct CorrespondingSigned<unsigned long long> { typedef long long Type; };
+
+template<typename T,
+         typename CVRemoved = typename RemoveCV<T>::Type,
+         bool IsSignedIntegerType = IsSigned<CVRemoved>::value &&
+                                    !IsSame<char, CVRemoved>::value>
+struct MakeSigned;
+
+template<typename T, typename CVRemoved>
+struct MakeSigned<T, CVRemoved, true>
+{
+  typedef T Type;
+};
+
+template<typename T, typename CVRemoved>
+struct MakeSigned<T, CVRemoved, false>
+  : WithCV<IsConst<T>::value, IsVolatile<T>::value,
+           typename CorrespondingSigned<CVRemoved>::Type>
+{};
+
+} // namespace detail
+
+/**
+ * MakeSigned produces the corresponding signed integer type for a given
+ * integral type T, with the const/volatile qualifiers of T.  T must be a
+ * possibly-const/volatile-qualified integral type that isn't bool.
+ *
+ * If T is already a signed integer type (not including char!), then T is
+ * produced.
+ *
+ * Otherwise, if T is an unsigned integer type, the signed variety of T, with
+ * T's const/volatile qualifiers, is produced.
+ *
+ * Otherwise, the integral type of the same size as T, with the lowest rank,
+ * with T's const/volatile qualifiers, is produced.  (This basically only acts
+ * to produce signed char when T = char.)
+ *
+ * mozilla::MakeSigned<unsigned long>::Type is signed long;
+ * mozilla::MakeSigned<volatile int>::Type is volatile int;
+ * mozilla::MakeSigned<const unsigned short>::Type is const signed short;
+ * mozilla::MakeSigned<const char>::Type is const signed char;
+ * mozilla::MakeSigned<bool> is an error;
+ * mozilla::MakeSigned<void*> is an error.
+ */
+template<typename T>
+struct MakeSigned
+  : EnableIf<IsIntegral<T>::value &&
+             !IsSame<bool, typename RemoveCV<T>::Type>::value,
+             typename detail::MakeSigned<T>
+            >::Type
+{};
+
+namespace detail {
+
+template<typename T>
+struct CorrespondingUnsigned;
+
+template<>
+struct CorrespondingUnsigned<char> { typedef unsigned char Type; };
+template<>
+struct CorrespondingUnsigned<signed char> { typedef unsigned char Type; };
+template<>
+struct CorrespondingUnsigned<short> { typedef unsigned short Type; };
+template<>
+struct CorrespondingUnsigned<int> { typedef unsigned int Type; };
+template<>
+struct CorrespondingUnsigned<long> { typedef unsigned long Type; };
+template<>
+struct CorrespondingUnsigned<long long> { typedef unsigned long long Type; };
+
+
+template<typename T,
+         typename CVRemoved = typename RemoveCV<T>::Type,
+         bool IsUnsignedIntegerType = IsUnsigned<CVRemoved>::value &&
+                                      !IsSame<char, CVRemoved>::value>
+struct MakeUnsigned;
+
+template<typename T, typename CVRemoved>
+struct MakeUnsigned<T, CVRemoved, true>
+{
+  typedef T Type;
+};
+
+template<typename T, typename CVRemoved>
+struct MakeUnsigned<T, CVRemoved, false>
+  : WithCV<IsConst<T>::value, IsVolatile<T>::value,
+           typename CorrespondingUnsigned<CVRemoved>::Type>
+{};
+
+} // namespace detail
+
+/**
+ * MakeUnsigned produces the corresponding unsigned integer type for a given
+ * integral type T, with the const/volatile qualifiers of T.  T must be a
+ * possibly-const/volatile-qualified integral type that isn't bool.
+ *
+ * If T is already an unsigned integer type (not including char!), then T is
+ * produced.
+ *
+ * Otherwise, if T is an signed integer type, the unsigned variety of T, with
+ * T's const/volatile qualifiers, is produced.
+ *
+ * Otherwise, the unsigned integral type of the same size as T, with the lowest
+ * rank, with T's const/volatile qualifiers, is produced.  (This basically only
+ * acts to produce unsigned char when T = char.)
+ *
+ * mozilla::MakeUnsigned<signed long>::Type is unsigned long;
+ * mozilla::MakeUnsigned<volatile unsigned int>::Type is volatile unsigned int;
+ * mozilla::MakeUnsigned<const signed short>::Type is const unsigned short;
+ * mozilla::MakeUnsigned<const char>::Type is const unsigned char;
+ * mozilla::MakeUnsigned<bool> is an error;
+ * mozilla::MakeUnsigned<void*> is an error.
+ */
+template<typename T>
+struct MakeUnsigned
+  : EnableIf<IsIntegral<T>::value &&
+             !IsSame<bool, typename RemoveCV<T>::Type>::value,
+             typename detail::MakeUnsigned<T>
+            >::Type
+{};
+
+/* 20.9.7.4 Array modifications [meta.trans.arr] */
+
+/**
+ * RemoveExtent produces either the type of the elements of the array T, or T
+ * itself.
+ *
+ * mozilla::RemoveExtent<int>::Type is int;
+ * mozilla::RemoveExtent<const int[]>::Type is const int;
+ * mozilla::RemoveExtent<volatile int[5]>::Type is volatile int;
+ * mozilla::RemoveExtent<long[][17]>::Type is long[17].
+ */
+template<typename T>
+struct RemoveExtent
+{
+  typedef T Type;
+};
+
+template<typename T>
+struct RemoveExtent<T[]>
+{
+  typedef T Type;
+};
+
+template<typename T, decltype(sizeof(1)) N>
+struct RemoveExtent<T[N]>
+{
+  typedef T Type;
+};
+
+/* 20.9.7.5 Pointer modifications [meta.trans.ptr] */
+
+namespace detail {
+
+template<typename T, typename CVRemoved>
+struct RemovePointerHelper
+{
+  typedef T Type;
+};
+
+template<typename T, typename Pointee>
+struct RemovePointerHelper<T, Pointee*>
+{
+  typedef Pointee Type;
+};
+
+} // namespace detail
+
+/**
+ * Produces the pointed-to type if a pointer is provided, else returns the input
+ * type.  Note that this does not dereference pointer-to-member pointers.
+ *
+ * struct S { bool m; void f(); };
+ * mozilla::RemovePointer<int>::Type is int;
+ * mozilla::RemovePointer<int*>::Type is int;
+ * mozilla::RemovePointer<int* const>::Type is int;
+ * mozilla::RemovePointer<int* volatile>::Type is int;
+ * mozilla::RemovePointer<const long*>::Type is const long;
+ * mozilla::RemovePointer<void* const>::Type is void;
+ * mozilla::RemovePointer<void (S::*)()>::Type is void (S::*)();
+ * mozilla::RemovePointer<void (*)()>::Type is void();
+ * mozilla::RemovePointer<bool S::*>::Type is bool S::*.
+ */
+template<typename T>
+struct RemovePointer
+  : detail::RemovePointerHelper<T, typename RemoveCV<T>::Type>
+{};
+
+/**
+ * Converts T& to T*. Otherwise returns T* given T. Note that C++17 wants
+ * std::add_pointer to work differently for function types. We don't implement
+ * that behavior here.
+ *
+ * mozilla::AddPointer<int> is int*;
+ * mozilla::AddPointer<int*> is int**;
+ * mozilla::AddPointer<int&> is int*;
+ * mozilla::AddPointer<int* const> is int** const.
+ */
+template<typename T>
+struct AddPointer
+{
+  typedef typename RemoveReference<T>::Type* Type;
+};
+
+/* 20.9.7.6 Other transformations [meta.trans.other] */
+
+/**
+ * EnableIf is a struct containing a typedef of T if and only if B is true.
+ *
+ * mozilla::EnableIf<true, int>::Type is int;
+ * mozilla::EnableIf<false, int>::Type is a compile-time error.
+ *
+ * Use this template to implement SFINAE-style (Substitution Failure Is not An
+ * Error) requirements.  For example, you might use it to impose a restriction
+ * on a template parameter:
+ *
+ *   template<typename T>
+ *   class PodVector // vector optimized to store POD (memcpy-able) types
+ *   {
+ *      EnableIf<IsPod<T>::value, T>::Type* vector;
+ *      size_t length;
+ *      ...
+ *   };
+ */
+template<bool B, typename T>
+struct EnableIf
+{};
+
+template<typename T>
+struct EnableIf<true, T>
+{
+  typedef T Type;
+};
+
+/**
+ * Conditional selects a class between two, depending on a given boolean value.
+ *
+ * mozilla::Conditional<true, A, B>::Type is A;
+ * mozilla::Conditional<false, A, B>::Type is B;
+ */
+template<bool Condition, typename A, typename B>
+struct Conditional
+{
+  typedef A Type;
+};
+
+template<class A, class B>
+struct Conditional<false, A, B>
+{
+  typedef B Type;
+};
+
+namespace detail {
+
+template<typename U,
+         bool IsArray = IsArray<U>::value,
+         bool IsFunction = IsFunction<U>::value>
+struct DecaySelector;
+
+template<typename U>
+struct DecaySelector<U, false, false>
+{
+  typedef typename RemoveCV<U>::Type Type;
+};
+
+template<typename U>
+struct DecaySelector<U, true, false>
+{
+  typedef typename RemoveExtent<U>::Type* Type;
+};
+
+template<typename U>
+struct DecaySelector<U, false, true>
+{
+  typedef typename AddPointer<U>::Type Type;
+};
+
+}; // namespace detail
+
+/**
+ * Strips const/volatile off a type and decays it from an lvalue to an
+ * rvalue. So function types are converted to function pointers, arrays to
+ * pointers, and references are removed.
+ *
+ * mozilla::Decay<int>::Type is int
+ * mozilla::Decay<int&>::Type is int
+ * mozilla::Decay<int&&>::Type is int
+ * mozilla::Decay<const int&>::Type is int
+ * mozilla::Decay<int[2]>::Type is int*
+ * mozilla::Decay<int(int)>::Type is int(*)(int)
+ */
+template<typename T>
+class Decay
+  : public detail::DecaySelector<typename RemoveReference<T>::Type>
+{
+};
+
+} /* namespace mozilla */
+
+#endif /* mozilla_TypeTraits_h */
diff --git a/src/third_party/mozjs-45/mfbt/TypedEnumBits.h b/src/third_party/mozjs-45/mfbt/TypedEnumBits.h
new file mode 100644
index 0000000..642630c
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/TypedEnumBits.h
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS allows using a typed enum as bit flags.
+ */
+
+#ifndef mozilla_TypedEnumBits_h
+#define mozilla_TypedEnumBits_h
+
+#include "mozilla/Attributes.h"
+#include "mozilla/IntegerTypeTraits.h"
+
+namespace mozilla {
+
+/*
+ * The problem that CastableTypedEnumResult aims to solve is that
+ * typed enums are not convertible to bool, and there is no way to make them
+ * be, yet user code wants to be able to write
+ *
+ *   if (myFlags & Flags::SOME_PARTICULAR_FLAG)              (1)
+ *
+ * There are different approaches to solving this. Most of them require
+ * adapting user code. For example, we could implement operator! and have
+ * the user write
+ *
+ *   if (!!(myFlags & Flags::SOME_PARTICULAR_FLAG))          (2)
+ *
+ * Or we could supply a IsNonZero() or Any() function returning whether
+ * an enum value is nonzero, and have the user write
+ *
+ *   if (Any(Flags & Flags::SOME_PARTICULAR_FLAG))           (3)
+ *
+ * But instead, we choose to preserve the original user syntax (1) as it
+ * is inherently more readable, and to ease porting existing code to typed
+ * enums. We achieve this by having operator& and other binary bitwise
+ * operators have as return type a class, CastableTypedEnumResult,
+ * that wraps a typed enum but adds bool convertibility.
+ */
+template<typename E>
+class CastableTypedEnumResult
+{
+private:
+  const E mValue;
+
+public:
+  explicit MOZ_CONSTEXPR CastableTypedEnumResult(E aValue)
+    : mValue(aValue)
+  {}
+
+  MOZ_CONSTEXPR operator E() const { return mValue; }
+
+  template<typename DestinationType>
+  MOZ_EXPLICIT_CONVERSION MOZ_CONSTEXPR
+  operator DestinationType() const { return DestinationType(mValue); }
+
+  MOZ_CONSTEXPR bool operator !() const { return !bool(mValue); }
+};
+
+#define MOZ_CASTABLETYPEDENUMRESULT_BINOP(Op, OtherType, ReturnType) \
+template<typename E> \
+MOZ_CONSTEXPR ReturnType \
+operator Op(const OtherType& aE, const CastableTypedEnumResult<E>& aR) \
+{ \
+  return ReturnType(aE Op OtherType(aR)); \
+} \
+template<typename E> \
+MOZ_CONSTEXPR ReturnType \
+operator Op(const CastableTypedEnumResult<E>& aR, const OtherType& aE) \
+{ \
+  return ReturnType(OtherType(aR) Op aE); \
+} \
+template<typename E> \
+MOZ_CONSTEXPR ReturnType \
+operator Op(const CastableTypedEnumResult<E>& aR1, \
+            const CastableTypedEnumResult<E>& aR2) \
+{ \
+  return ReturnType(OtherType(aR1) Op OtherType(aR2)); \
+}
+
+MOZ_CASTABLETYPEDENUMRESULT_BINOP(|, E, CastableTypedEnumResult<E>)
+MOZ_CASTABLETYPEDENUMRESULT_BINOP(&, E, CastableTypedEnumResult<E>)
+MOZ_CASTABLETYPEDENUMRESULT_BINOP(^, E, CastableTypedEnumResult<E>)
+MOZ_CASTABLETYPEDENUMRESULT_BINOP(==, E, bool)
+MOZ_CASTABLETYPEDENUMRESULT_BINOP(!=, E, bool)
+MOZ_CASTABLETYPEDENUMRESULT_BINOP(||, bool, bool)
+MOZ_CASTABLETYPEDENUMRESULT_BINOP(&&, bool, bool)
+
+template <typename E>
+MOZ_CONSTEXPR CastableTypedEnumResult<E>
+operator ~(const CastableTypedEnumResult<E>& aR)
+{
+  return CastableTypedEnumResult<E>(~(E(aR)));
+}
+
+#define MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(Op) \
+template<typename E> \
+E& \
+operator Op(E& aR1, \
+            const CastableTypedEnumResult<E>& aR2) \
+{ \
+  return aR1 Op E(aR2); \
+}
+
+MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(&=)
+MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(|=)
+MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(^=)
+
+#undef MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP
+
+#undef MOZ_CASTABLETYPEDENUMRESULT_BINOP
+
+namespace detail {
+template<typename E>
+struct UnsignedIntegerTypeForEnum
+  : UnsignedStdintTypeForSize<sizeof(E)>
+{};
+} // namespace detail
+
+} // namespace mozilla
+
+#define MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, Op) \
+   inline MOZ_CONSTEXPR mozilla::CastableTypedEnumResult<Name> \
+   operator Op(Name a, Name b) \
+   { \
+     typedef mozilla::CastableTypedEnumResult<Name> Result; \
+     typedef mozilla::detail::UnsignedIntegerTypeForEnum<Name>::Type U; \
+     return Result(Name(U(a) Op U(b))); \
+   } \
+ \
+   inline Name& \
+   operator Op##=(Name& a, Name b) \
+   { \
+     return a = a Op b; \
+   }
+
+/**
+ * MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS generates standard bitwise operators
+ * for the given enum type. Use this to enable using an enum type as bit-field.
+ */
+#define MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Name) \
+   MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, |) \
+   MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, &) \
+   MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, ^) \
+   inline MOZ_CONSTEXPR mozilla::CastableTypedEnumResult<Name> \
+   operator~(Name a) \
+   { \
+     typedef mozilla::CastableTypedEnumResult<Name> Result; \
+     typedef mozilla::detail::UnsignedIntegerTypeForEnum<Name>::Type U; \
+     return Result(Name(~(U(a)))); \
+   }
+
+#endif // mozilla_TypedEnumBits_h
diff --git a/src/third_party/mozjs-45/mfbt/Types.h b/src/third_party/mozjs-45/mfbt/Types.h
new file mode 100644
index 0000000..a5d9363
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Types.h
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* mfbt foundational types and macros. */
+
+#ifndef mozilla_Types_h
+#define mozilla_Types_h
+
+/*
+ * This header must be valid C and C++, includable by code embedding either
+ * SpiderMonkey or Gecko.
+ */
+
+/* Expose all <stdint.h> types and size_t. */
+#include <stddef.h>
+#include <stdint.h>
+
+/* Implement compiler and linker macros needed for APIs. */
+
+/*
+ * MOZ_EXPORT is used to declare and define a symbol or type which is externally
+ * visible to users of the current library.  It encapsulates various decorations
+ * needed to properly export the method's symbol.
+ *
+ *   api.h:
+ *     extern MOZ_EXPORT int MeaningOfLife(void);
+ *     extern MOZ_EXPORT int LuggageCombination;
+ *
+ *   api.c:
+ *     int MeaningOfLife(void) { return 42; }
+ *     int LuggageCombination = 12345;
+ *
+ * If you are merely sharing a method across files, just use plain |extern|.
+ * These macros are designed for use by library interfaces -- not for normal
+ * methods or data used cross-file.
+ */
+#if defined(WIN32)
+#  define MOZ_EXPORT   __declspec(dllexport)
+#else /* Unix */
+#  ifdef HAVE_VISIBILITY_ATTRIBUTE
+#    define MOZ_EXPORT       __attribute__((visibility("default")))
+#  elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+#    define MOZ_EXPORT      __global
+#  else
+#    define MOZ_EXPORT /* nothing */
+#  endif
+#endif
+
+
+/*
+ * Whereas implementers use MOZ_EXPORT to declare and define library symbols,
+ * users use MOZ_IMPORT_API and MOZ_IMPORT_DATA to access them.  Most often the
+ * implementer of the library will expose an API macro which expands to either
+ * the export or import version of the macro, depending upon the compilation
+ * mode.
+ */
+#ifdef _WIN32
+#  if defined(__MWERKS__)
+#    define MOZ_IMPORT_API /* nothing */
+#  else
+#    define MOZ_IMPORT_API __declspec(dllimport)
+#  endif
+#else
+#  define MOZ_IMPORT_API MOZ_EXPORT
+#endif
+
+#if defined(_WIN32) && !defined(__MWERKS__)
+#  define MOZ_IMPORT_DATA  __declspec(dllimport)
+#else
+#  define MOZ_IMPORT_DATA  MOZ_EXPORT
+#endif
+
+/*
+ * Consistent with the above comment, the MFBT_API and MFBT_DATA macros expose
+ * export mfbt declarations when building mfbt, and they expose import mfbt
+ * declarations when using mfbt.
+ */
+#if defined(IMPL_MFBT)
+#  define MFBT_API     MOZ_EXPORT
+#  define MFBT_DATA    MOZ_EXPORT
+#else
+  /*
+   * On linux mozglue is linked in the program and we link libxul.so with
+   * -z,defs. Normally that causes the linker to reject undefined references in
+   * libxul.so, but as a loophole it allows undefined references to weak
+   * symbols. We add the weak attribute to the import version of the MFBT API
+   * macros to exploit this.
+   */
+#  if defined(MOZ_GLUE_IN_PROGRAM) && !defined(MOZILLA_XPCOMRT_API)
+#    define MFBT_API   __attribute__((weak)) MOZ_IMPORT_API
+#    define MFBT_DATA  __attribute__((weak)) MOZ_IMPORT_DATA
+#  else
+#    define MFBT_API   MOZ_IMPORT_API
+#    define MFBT_DATA  MOZ_IMPORT_DATA
+#  endif
+#endif
+
+/*
+ * C symbols in C++ code must be declared immediately within |extern "C"|
+ * blocks.  However, in C code, they need not be declared specially.  This
+ * difference is abstracted behind the MOZ_BEGIN_EXTERN_C and MOZ_END_EXTERN_C
+ * macros, so that the user need not know whether he is being used in C or C++
+ * code.
+ *
+ *   MOZ_BEGIN_EXTERN_C
+ *
+ *   extern MOZ_EXPORT int MostRandomNumber(void);
+ *   ...other declarations...
+ *
+ *   MOZ_END_EXTERN_C
+ *
+ * This said, it is preferable to just use |extern "C"| in C++ header files for
+ * its greater clarity.
+ */
+#ifdef __cplusplus
+#  define MOZ_BEGIN_EXTERN_C    extern "C" {
+#  define MOZ_END_EXTERN_C      }
+#else
+#  define MOZ_BEGIN_EXTERN_C
+#  define MOZ_END_EXTERN_C
+#endif
+
+/*
+ * GCC's typeof is available when decltype is not.
+ */
+#if defined(__GNUC__) && defined(__cplusplus) && \
+  !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
+#  define decltype __typeof__
+#endif
+
+#endif /* mozilla_Types_h */
diff --git a/src/third_party/mozjs-45/mfbt/UniquePtr.h b/src/third_party/mozjs-45/mfbt/UniquePtr.h
new file mode 100644
index 0000000..525426c
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/UniquePtr.h
@@ -0,0 +1,651 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Smart pointer managing sole ownership of a resource. */
+
+#ifndef mozilla_UniquePtr_h
+#define mozilla_UniquePtr_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Compiler.h"
+#include "mozilla/Move.h"
+#include "mozilla/Pair.h"
+#include "mozilla/TypeTraits.h"
+
+namespace mozilla {
+
+template<typename T> class DefaultDelete;
+template<typename T, class D = DefaultDelete<T>> class UniquePtr;
+
+} // namespace mozilla
+
+namespace mozilla {
+
+/**
+ * UniquePtr is a smart pointer that wholly owns a resource.  Ownership may be
+ * transferred out of a UniquePtr through explicit action, but otherwise the
+ * resource is destroyed when the UniquePtr is destroyed.
+ *
+ * UniquePtr is similar to C++98's std::auto_ptr, but it improves upon auto_ptr
+ * in one crucial way: it's impossible to copy a UniquePtr.  Copying an auto_ptr
+ * obviously *can't* copy ownership of its singly-owned resource.  So what
+ * happens if you try to copy one?  Bizarrely, ownership is implicitly
+ * *transferred*, preserving single ownership but breaking code that assumes a
+ * copy of an object is identical to the original.  (This is why auto_ptr is
+ * prohibited in STL containers.)
+ *
+ * UniquePtr solves this problem by being *movable* rather than copyable.
+ * Instead of passing a |UniquePtr u| directly to the constructor or assignment
+ * operator, you pass |Move(u)|.  In doing so you indicate that you're *moving*
+ * ownership out of |u|, into the target of the construction/assignment.  After
+ * the transfer completes, |u| contains |nullptr| and may be safely destroyed.
+ * This preserves single ownership but also allows UniquePtr to be moved by
+ * algorithms that have been made move-safe.  (Note: if |u| is instead a
+ * temporary expression, don't use |Move()|: just pass the expression, because
+ * it's already move-ready.  For more information see Move.h.)
+ *
+ * UniquePtr is also better than std::auto_ptr in that the deletion operation is
+ * customizable.  An optional second template parameter specifies a class that
+ * (through its operator()(T*)) implements the desired deletion policy.  If no
+ * policy is specified, mozilla::DefaultDelete<T> is used -- which will either
+ * |delete| or |delete[]| the resource, depending whether the resource is an
+ * array.  Custom deletion policies ideally should be empty classes (no member
+ * fields, no member fields in base classes, no virtual methods/inheritance),
+ * because then UniquePtr can be just as efficient as a raw pointer.
+ *
+ * Use of UniquePtr proceeds like so:
+ *
+ *   UniquePtr<int> g1; // initializes to nullptr
+ *   g1.reset(new int); // switch resources using reset()
+ *   g1 = nullptr; // clears g1, deletes the int
+ *
+ *   UniquePtr<int> g2(new int); // owns that int
+ *   int* p = g2.release(); // g2 leaks its int -- still requires deletion
+ *   delete p; // now freed
+ *
+ *   struct S { int x; S(int x) : x(x) {} };
+ *   UniquePtr<S> g3, g4(new S(5));
+ *   g3 = Move(g4); // g3 owns the S, g4 cleared
+ *   S* p = g3.get(); // g3 still owns |p|
+ *   assert(g3->x == 5); // operator-> works (if .get() != nullptr)
+ *   assert((*g3).x == 5); // also operator* (again, if not cleared)
+ *   Swap(g3, g4); // g4 now owns the S, g3 cleared
+ *   g3.swap(g4);  // g3 now owns the S, g4 cleared
+ *   UniquePtr<S> g5(Move(g3)); // g5 owns the S, g3 cleared
+ *   g5.reset(); // deletes the S, g5 cleared
+ *
+ *   struct FreePolicy { void operator()(void* p) { free(p); } };
+ *   UniquePtr<int, FreePolicy> g6(static_cast<int*>(malloc(sizeof(int))));
+ *   int* ptr = g6.get();
+ *   g6 = nullptr; // calls free(ptr)
+ *
+ * Now, carefully note a few things you *can't* do:
+ *
+ *   UniquePtr<int> b1;
+ *   b1 = new int; // BAD: can only assign another UniquePtr
+ *   int* ptr = b1; // BAD: no auto-conversion to pointer, use get()
+ *
+ *   UniquePtr<int> b2(b1); // BAD: can't copy a UniquePtr
+ *   UniquePtr<int> b3 = b1; // BAD: can't copy-assign a UniquePtr
+ *
+ * (Note that changing a UniquePtr to store a direct |new| expression is
+ * permitted, but usually you should use MakeUnique, defined at the end of this
+ * header.)
+ *
+ * A few miscellaneous notes:
+ *
+ * UniquePtr, when not instantiated for an array type, can be move-constructed
+ * and move-assigned, not only from itself but from "derived" UniquePtr<U, E>
+ * instantiations where U converts to T and E converts to D.  If you want to use
+ * this, you're going to have to specify a deletion policy for both UniquePtr
+ * instantations, and T pretty much has to have a virtual destructor.  In other
+ * words, this doesn't work:
+ *
+ *   struct Base { virtual ~Base() {} };
+ *   struct Derived : Base {};
+ *
+ *   UniquePtr<Base> b1;
+ *   // BAD: DefaultDelete<Base> and DefaultDelete<Derived> don't interconvert
+ *   UniquePtr<Derived> d1(Move(b));
+ *
+ *   UniquePtr<Base> b2;
+ *   UniquePtr<Derived, DefaultDelete<Base>> d2(Move(b2)); // okay
+ *
+ * UniquePtr is specialized for array types.  Specializing with an array type
+ * creates a smart-pointer version of that array -- not a pointer to such an
+ * array.
+ *
+ *   UniquePtr<int[]> arr(new int[5]);
+ *   arr[0] = 4;
+ *
+ * What else is different?  Deletion of course uses |delete[]|.  An operator[]
+ * is provided.  Functionality that doesn't make sense for arrays is removed.
+ * The constructors and mutating methods only accept array pointers (not T*, U*
+ * that converts to T*, or UniquePtr<U[]> or UniquePtr<U>) or |nullptr|.
+ *
+ * It's perfectly okay to return a UniquePtr from a method to assure the related
+ * resource is properly deleted.  You'll need to use |Move()| when returning a
+ * local UniquePtr.  Otherwise you can return |nullptr|, or you can return
+ * |UniquePtr(ptr)|.
+ *
+ * UniquePtr will commonly be a member of a class, with lifetime equivalent to
+ * that of that class.  If you want to expose the related resource, you could
+ * expose a raw pointer via |get()|, but ownership of a raw pointer is
+ * inherently unclear.  So it's better to expose a |const UniquePtr&| instead.
+ * This prohibits mutation but still allows use of |get()| when needed (but
+ * operator-> is preferred).  Of course, you can only use this smart pointer as
+ * long as the enclosing class instance remains live -- no different than if you
+ * exposed the |get()| raw pointer.
+ *
+ * To pass a UniquePtr-managed resource as a pointer, use a |const UniquePtr&|
+ * argument.  To specify an inout parameter (where the method may or may not
+ * take ownership of the resource, or reset it), or to specify an out parameter
+ * (where simply returning a |UniquePtr| isn't possible), use a |UniquePtr&|
+ * argument.  To unconditionally transfer ownership of a UniquePtr
+ * into a method, use a |UniquePtr| argument.  To conditionally transfer
+ * ownership of a resource into a method, should the method want it, use a
+ * |UniquePtr&&| argument.
+ */
+template<typename T, class D>
+class UniquePtr
+{
+public:
+  typedef T* Pointer;
+  typedef T ElementType;
+  typedef D DeleterType;
+
+private:
+  Pair<Pointer, DeleterType> mTuple;
+
+  Pointer& ptr() { return mTuple.first(); }
+  const Pointer& ptr() const { return mTuple.first(); }
+
+  DeleterType& del() { return mTuple.second(); }
+  const DeleterType& del() const { return mTuple.second(); }
+
+public:
+  /**
+   * Construct a UniquePtr containing |nullptr|.
+   */
+  MOZ_CONSTEXPR UniquePtr()
+    : mTuple(static_cast<Pointer>(nullptr), DeleterType())
+  {
+    static_assert(!IsPointer<D>::value, "must provide a deleter instance");
+    static_assert(!IsReference<D>::value, "must provide a deleter instance");
+  }
+
+  /**
+   * Construct a UniquePtr containing |aPtr|.
+   */
+  explicit UniquePtr(Pointer aPtr)
+    : mTuple(aPtr, DeleterType())
+  {
+    static_assert(!IsPointer<D>::value, "must provide a deleter instance");
+    static_assert(!IsReference<D>::value, "must provide a deleter instance");
+  }
+
+  UniquePtr(Pointer aPtr,
+            typename Conditional<IsReference<D>::value,
+                                 D,
+                                 const D&>::Type aD1)
+    : mTuple(aPtr, aD1)
+  {}
+
+  // If you encounter an error with MSVC10 about RemoveReference below, along
+  // the lines that "more than one partial specialization matches the template
+  // argument list": don't use UniquePtr<T, reference to function>!  Ideally
+  // you should make deletion use the same function every time, using a
+  // deleter policy:
+  //
+  //   // BAD, won't compile with MSVC10, deleter doesn't need to be a
+  //   // variable at all
+  //   typedef void (&FreeSignature)(void*);
+  //   UniquePtr<int, FreeSignature> ptr((int*) malloc(sizeof(int)), free);
+  //
+  //   // GOOD, compiles with MSVC10, deletion behavior statically known and
+  //   // optimizable
+  //   struct DeleteByFreeing
+  //   {
+  //     void operator()(void* aPtr) { free(aPtr); }
+  //   };
+  //
+  // If deletion really, truly, must be a variable: you might be able to work
+  // around this with a deleter class that contains the function reference.
+  // But this workaround is untried and untested, because variable deletion
+  // behavior really isn't something you should use.
+  UniquePtr(Pointer aPtr,
+            typename RemoveReference<D>::Type&& aD2)
+    : mTuple(aPtr, Move(aD2))
+  {
+    static_assert(!IsReference<D>::value,
+                  "rvalue deleter can't be stored by reference");
+  }
+
+  UniquePtr(UniquePtr&& aOther)
+    : mTuple(aOther.release(), Forward<DeleterType>(aOther.getDeleter()))
+  {}
+
+  MOZ_IMPLICIT
+  UniquePtr(decltype(nullptr))
+    : mTuple(nullptr, DeleterType())
+  {
+    static_assert(!IsPointer<D>::value, "must provide a deleter instance");
+    static_assert(!IsReference<D>::value, "must provide a deleter instance");
+  }
+
+  template<typename U, class E>
+  MOZ_IMPLICIT
+  UniquePtr(UniquePtr<U, E>&& aOther,
+            typename EnableIf<IsConvertible<typename UniquePtr<U, E>::Pointer,
+                                            Pointer>::value &&
+                              !IsArray<U>::value &&
+                              (IsReference<D>::value
+                               ? IsSame<D, E>::value
+                               : IsConvertible<E, D>::value),
+                              int>::Type aDummy = 0)
+    : mTuple(aOther.release(), Forward<E>(aOther.getDeleter()))
+  {
+  }
+
+  ~UniquePtr() { reset(nullptr); }
+
+  UniquePtr& operator=(UniquePtr&& aOther)
+  {
+    reset(aOther.release());
+    getDeleter() = Forward<DeleterType>(aOther.getDeleter());
+    return *this;
+  }
+
+  template<typename U, typename E>
+  UniquePtr& operator=(UniquePtr<U, E>&& aOther)
+  {
+    static_assert(IsConvertible<typename UniquePtr<U, E>::Pointer,
+                                Pointer>::value,
+                  "incompatible UniquePtr pointees");
+    static_assert(!IsArray<U>::value,
+                  "can't assign from UniquePtr holding an array");
+
+    reset(aOther.release());
+    getDeleter() = Forward<E>(aOther.getDeleter());
+    return *this;
+  }
+
+  UniquePtr& operator=(decltype(nullptr))
+  {
+    reset(nullptr);
+    return *this;
+  }
+
+  T& operator*() const { return *get(); }
+  Pointer operator->() const
+  {
+    MOZ_ASSERT(get(), "dereferencing a UniquePtr containing nullptr");
+    return get();
+  }
+
+  explicit operator bool() const { return get() != nullptr; }
+
+  Pointer get() const { return ptr(); }
+
+  DeleterType& getDeleter() { return del(); }
+  const DeleterType& getDeleter() const { return del(); }
+
+  Pointer release()
+  {
+    Pointer p = ptr();
+    ptr() = nullptr;
+    return p;
+  }
+
+  void reset(Pointer aPtr = Pointer())
+  {
+    Pointer old = ptr();
+    ptr() = aPtr;
+    if (old != nullptr) {
+      getDeleter()(old);
+    }
+  }
+
+  void swap(UniquePtr& aOther)
+  {
+    mTuple.swap(aOther.mTuple);
+  }
+
+  UniquePtr(const UniquePtr& aOther) = delete; // construct using Move()!
+  void operator=(const UniquePtr& aOther) = delete; // assign using Move()!
+};
+
+// In case you didn't read the comment by the main definition (you should!): the
+// UniquePtr<T[]> specialization exists to manage array pointers.  It deletes
+// such pointers using delete[], it will reject construction and modification
+// attempts using U* or U[].  Otherwise it works like the normal UniquePtr.
+template<typename T, class D>
+class UniquePtr<T[], D>
+{
+public:
+  typedef T* Pointer;
+  typedef T ElementType;
+  typedef D DeleterType;
+
+private:
+  Pair<Pointer, DeleterType> mTuple;
+
+public:
+  /**
+   * Construct a UniquePtr containing nullptr.
+   */
+  MOZ_CONSTEXPR UniquePtr()
+    : mTuple(static_cast<Pointer>(nullptr), DeleterType())
+  {
+    static_assert(!IsPointer<D>::value, "must provide a deleter instance");
+    static_assert(!IsReference<D>::value, "must provide a deleter instance");
+  }
+
+  /**
+   * Construct a UniquePtr containing |aPtr|.
+   */
+  explicit UniquePtr(Pointer aPtr)
+    : mTuple(aPtr, DeleterType())
+  {
+    static_assert(!IsPointer<D>::value, "must provide a deleter instance");
+    static_assert(!IsReference<D>::value, "must provide a deleter instance");
+  }
+
+  // delete[] knows how to handle *only* an array of a single class type.  For
+  // delete[] to work correctly, it must know the size of each element, the
+  // fields and base classes of each element requiring destruction, and so on.
+  // So forbid all overloads which would end up invoking delete[] on a pointer
+  // of the wrong type.
+  template<typename U>
+  UniquePtr(U&& aU,
+            typename EnableIf<IsPointer<U>::value &&
+                              IsConvertible<U, Pointer>::value,
+                              int>::Type aDummy = 0)
+  = delete;
+
+  UniquePtr(Pointer aPtr,
+            typename Conditional<IsReference<D>::value,
+                                 D,
+                                 const D&>::Type aD1)
+    : mTuple(aPtr, aD1)
+  {}
+
+  // If you encounter an error with MSVC10 about RemoveReference below, along
+  // the lines that "more than one partial specialization matches the template
+  // argument list": don't use UniquePtr<T[], reference to function>!  See the
+  // comment by this constructor in the non-T[] specialization above.
+  UniquePtr(Pointer aPtr,
+            typename RemoveReference<D>::Type&& aD2)
+    : mTuple(aPtr, Move(aD2))
+  {
+    static_assert(!IsReference<D>::value,
+                  "rvalue deleter can't be stored by reference");
+  }
+
+  // Forbidden for the same reasons as stated above.
+  template<typename U, typename V>
+  UniquePtr(U&& aU, V&& aV,
+            typename EnableIf<IsPointer<U>::value &&
+                              IsConvertible<U, Pointer>::value,
+                              int>::Type aDummy = 0)
+  = delete;
+
+  UniquePtr(UniquePtr&& aOther)
+    : mTuple(aOther.release(), Forward<DeleterType>(aOther.getDeleter()))
+  {}
+
+  MOZ_IMPLICIT
+  UniquePtr(decltype(nullptr))
+    : mTuple(nullptr, DeleterType())
+  {
+    static_assert(!IsPointer<D>::value, "must provide a deleter instance");
+    static_assert(!IsReference<D>::value, "must provide a deleter instance");
+  }
+
+  ~UniquePtr() { reset(nullptr); }
+
+  UniquePtr& operator=(UniquePtr&& aOther)
+  {
+    reset(aOther.release());
+    getDeleter() = Forward<DeleterType>(aOther.getDeleter());
+    return *this;
+  }
+
+  UniquePtr& operator=(decltype(nullptr))
+  {
+    reset();
+    return *this;
+  }
+
+  explicit operator bool() const { return get() != nullptr; }
+
+  T& operator[](decltype(sizeof(int)) aIndex) const { return get()[aIndex]; }
+  Pointer get() const { return mTuple.first(); }
+
+  DeleterType& getDeleter() { return mTuple.second(); }
+  const DeleterType& getDeleter() const { return mTuple.second(); }
+
+  Pointer release()
+  {
+    Pointer p = mTuple.first();
+    mTuple.first() = nullptr;
+    return p;
+  }
+
+  void reset(Pointer aPtr = Pointer())
+  {
+    Pointer old = mTuple.first();
+    mTuple.first() = aPtr;
+    if (old != nullptr) {
+      mTuple.second()(old);
+    }
+  }
+
+  void reset(decltype(nullptr))
+  {
+    Pointer old = mTuple.first();
+    mTuple.first() = nullptr;
+    if (old != nullptr) {
+      mTuple.second()(old);
+    }
+  }
+
+  template<typename U>
+  void reset(U) = delete;
+
+  void swap(UniquePtr& aOther) { mTuple.swap(aOther.mTuple); }
+
+  UniquePtr(const UniquePtr& aOther) = delete; // construct using Move()!
+  void operator=(const UniquePtr& aOther) = delete; // assign using Move()!
+};
+
+/** A default deletion policy using plain old operator delete. */
+template<typename T>
+class DefaultDelete
+{
+public:
+  MOZ_CONSTEXPR DefaultDelete() {}
+
+  template<typename U>
+  MOZ_IMPLICIT DefaultDelete(const DefaultDelete<U>& aOther,
+                             typename EnableIf<mozilla::IsConvertible<U*, T*>::value,
+                                               int>::Type aDummy = 0)
+  {}
+
+  void operator()(T* aPtr) const
+  {
+    static_assert(sizeof(T) > 0, "T must be complete");
+    delete aPtr;
+  }
+};
+
+/** A default deletion policy using operator delete[]. */
+template<typename T>
+class DefaultDelete<T[]>
+{
+public:
+  MOZ_CONSTEXPR DefaultDelete() {}
+
+  void operator()(T* aPtr) const
+  {
+    static_assert(sizeof(T) > 0, "T must be complete");
+    delete[] aPtr;
+  }
+
+  template<typename U>
+  void operator()(U* aPtr) const = delete;
+};
+
+template<typename T, class D>
+void
+Swap(UniquePtr<T, D>& aX, UniquePtr<T, D>& aY)
+{
+  aX.swap(aY);
+}
+
+template<typename T, class D, typename U, class E>
+bool
+operator==(const UniquePtr<T, D>& aX, const UniquePtr<U, E>& aY)
+{
+  return aX.get() == aY.get();
+}
+
+template<typename T, class D, typename U, class E>
+bool
+operator!=(const UniquePtr<T, D>& aX, const UniquePtr<U, E>& aY)
+{
+  return aX.get() != aY.get();
+}
+
+template<typename T, class D>
+bool
+operator==(const UniquePtr<T, D>& aX, decltype(nullptr))
+{
+  return !aX;
+}
+
+template<typename T, class D>
+bool
+operator==(decltype(nullptr), const UniquePtr<T, D>& aX)
+{
+  return !aX;
+}
+
+template<typename T, class D>
+bool
+operator!=(const UniquePtr<T, D>& aX, decltype(nullptr))
+{
+  return bool(aX);
+}
+
+template<typename T, class D>
+bool
+operator!=(decltype(nullptr), const UniquePtr<T, D>& aX)
+{
+  return bool(aX);
+}
+
+// No operator<, operator>, operator<=, operator>= for now because simplicity.
+
+namespace detail {
+
+template<typename T>
+struct UniqueSelector
+{
+  typedef UniquePtr<T> SingleObject;
+};
+
+template<typename T>
+struct UniqueSelector<T[]>
+{
+  typedef UniquePtr<T[]> UnknownBound;
+};
+
+template<typename T, decltype(sizeof(int)) N>
+struct UniqueSelector<T[N]>
+{
+  typedef UniquePtr<T[N]> KnownBound;
+};
+
+} // namespace detail
+
+/**
+ * MakeUnique is a helper function for allocating new'd objects and arrays,
+ * returning a UniquePtr containing the resulting pointer.  The semantics of
+ * MakeUnique<Type>(...) are as follows.
+ *
+ *   If Type is an array T[n]:
+ *     Disallowed, deleted, no overload for you!
+ *   If Type is an array T[]:
+ *     MakeUnique<T[]>(size_t) is the only valid overload.  The pointer returned
+ *     is as if by |new T[n]()|, which value-initializes each element.  (If T
+ *     isn't a class type, this will zero each element.  If T is a class type,
+ *     then roughly speaking, each element will be constructed using its default
+ *     constructor.  See C++11 [dcl.init]p7 for the full gory details.)
+ *   If Type is non-array T:
+ *     The arguments passed to MakeUnique<T>(...) are forwarded into a
+ *     |new T(...)| call, initializing the T as would happen if executing
+ *     |T(...)|.
+ *
+ * There are various benefits to using MakeUnique instead of |new| expressions.
+ *
+ * First, MakeUnique eliminates use of |new| from code entirely.  If objects are
+ * only created through UniquePtr, then (assuming all explicit release() calls
+ * are safe, including transitively, and no type-safety casting funniness)
+ * correctly maintained ownership of the UniquePtr guarantees no leaks are
+ * possible.  (This pays off best if a class is only ever created through a
+ * factory method on the class, using a private constructor.)
+ *
+ * Second, initializing a UniquePtr using a |new| expression requires repeating
+ * the name of the new'd type, whereas MakeUnique in concert with the |auto|
+ * keyword names it only once:
+ *
+ *   UniquePtr<char> ptr1(new char()); // repetitive
+ *   auto ptr2 = MakeUnique<char>();   // shorter
+ *
+ * Of course this assumes the reader understands the operation MakeUnique
+ * performs.  In the long run this is probably a reasonable assumption.  In the
+ * short run you'll have to use your judgment about what readers can be expected
+ * to know, or to quickly look up.
+ *
+ * Third, a call to MakeUnique can be assigned directly to a UniquePtr.  In
+ * contrast you can't assign a pointer into a UniquePtr without using the
+ * cumbersome reset().
+ *
+ *   UniquePtr<char> p;
+ *   p = new char;           // ERROR
+ *   p.reset(new char);      // works, but fugly
+ *   p = MakeUnique<char>(); // preferred
+ *
+ * (And third, although not relevant to Mozilla: MakeUnique is exception-safe.
+ * An exception thrown after |new T| succeeds will leak that memory, unless the
+ * pointer is assigned to an object that will manage its ownership.  UniquePtr
+ * ably serves this function.)
+ */
+
+template<typename T, typename... Args>
+typename detail::UniqueSelector<T>::SingleObject
+MakeUnique(Args&&... aArgs)
+{
+  return UniquePtr<T>(new T(Forward<Args>(aArgs)...));
+}
+
+template<typename T>
+typename detail::UniqueSelector<T>::UnknownBound
+MakeUnique(decltype(sizeof(int)) aN)
+{
+  typedef typename RemoveExtent<T>::Type ArrayType;
+  return UniquePtr<T>(new ArrayType[aN]());
+}
+
+template<typename T, typename... Args>
+typename detail::UniqueSelector<T>::KnownBound
+MakeUnique(Args&&... aArgs) = delete;
+
+} // namespace mozilla
+
+#endif /* mozilla_UniquePtr_h */
diff --git a/src/third_party/mozjs-45/mfbt/UniquePtrExtensions.h b/src/third_party/mozjs-45/mfbt/UniquePtrExtensions.h
new file mode 100644
index 0000000..65b07ed
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/UniquePtrExtensions.h
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Useful extensions to UniquePtr. */
+
+#ifndef mozilla_UniquePtrExtensions_h
+#define mozilla_UniquePtrExtensions_h
+
+#include "mozilla/fallible.h"
+#include "mozilla/UniquePtr.h"
+
+namespace mozilla {
+
+/**
+ * MakeUniqueFallible works exactly like MakeUnique, except that the memory
+ * allocation performed is done fallibly, i.e. it can return nullptr.
+ */
+template<typename T, typename... Args>
+typename detail::UniqueSelector<T>::SingleObject
+MakeUniqueFallible(Args&&... aArgs)
+{
+  return UniquePtr<T>(new (fallible) T(Forward<Args>(aArgs)...));
+}
+
+template<typename T>
+typename detail::UniqueSelector<T>::UnknownBound
+MakeUniqueFallible(decltype(sizeof(int)) aN)
+{
+  typedef typename RemoveExtent<T>::Type ArrayType;
+  return UniquePtr<T>(new (fallible) ArrayType[aN]());
+}
+
+template<typename T, typename... Args>
+typename detail::UniqueSelector<T>::KnownBound
+MakeUniqueFallible(Args&&... aArgs) = delete;
+
+} // namespace mozilla
+
+#endif // mozilla_UniquePtrExtensions_h
diff --git a/src/third_party/mozjs-45/mfbt/Variant.h b/src/third_party/mozjs-45/mfbt/Variant.h
new file mode 100644
index 0000000..9857553
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Variant.h
@@ -0,0 +1,460 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A template class for tagged unions. */
+
+#include <new>
+
+#include "mozilla/Alignment.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Move.h"
+
+#ifndef mozilla_Variant_h
+#define mozilla_Variant_h
+
+namespace mozilla {
+
+template<typename... Ts>
+class Variant;
+
+namespace detail {
+
+// MaxSizeOf computes the maximum sizeof(T) for each T in Ts.
+
+template<typename T, typename... Ts>
+struct MaxSizeOf
+{
+  static const size_t size = sizeof(T) > MaxSizeOf<Ts...>::size
+    ? sizeof(T)
+    : MaxSizeOf<Ts...>::size;
+};
+
+template<typename T>
+struct MaxSizeOf<T>
+{
+  static const size_t size = sizeof(T);
+};
+
+// The `IsVariant` helper is used in conjunction with static_assert and
+// `mozilla::EnableIf` to catch passing non-variant types to `Variant::is<T>()`
+// and friends at compile time, rather than at runtime. It ensures that the
+// given type `Needle` is one of the types in the set of types `Haystack`.
+
+template<typename Needle, typename... Haystack>
+struct IsVariant;
+
+template<typename Needle>
+struct IsVariant<Needle>
+{
+  static const bool value = false;
+};
+
+template<typename Needle, typename... Haystack>
+struct IsVariant<Needle, Needle, Haystack...>
+{
+  static const bool value = true;
+};
+
+template<typename Needle, typename T, typename... Haystack>
+struct IsVariant<Needle, T, Haystack...> : public IsVariant<Needle, Haystack...> { };
+
+// TagHelper gets the given sentinel tag value for the given type T. This has to
+// be split out from VariantImplementation because you can't nest a partial template
+// specialization within a template class.
+
+template<size_t N, typename T, typename U, typename Next, bool isMatch>
+struct TagHelper;
+
+// In the case where T != U, we continue recursion.
+template<size_t N, typename T, typename U, typename Next>
+struct TagHelper<N, T, U, Next, false>
+{
+  static size_t tag() { return Next::template tag<U>(); }
+};
+
+// In the case where T == U, return the tag number.
+template<size_t N, typename T, typename U, typename Next>
+struct TagHelper<N, T, U, Next, true>
+{
+  static size_t tag() { return N; }
+};
+
+// The VariantImplementation template provides the guts of mozilla::Variant. We create
+// an VariantImplementation for each T in Ts... which handles construction,
+// destruction, etc for when the Variant's type is T. If the Variant's type is
+// not T, it punts the request on to the next VariantImplementation.
+
+template<size_t N, typename... Ts>
+struct VariantImplementation;
+
+// The singly typed Variant / recursion base case.
+template<size_t N, typename T>
+struct VariantImplementation<N, T> {
+  template<typename U>
+  static size_t tag() {
+    static_assert(mozilla::IsSame<T, U>::value,
+                  "mozilla::Variant: tag: bad type!");
+    return N;
+  }
+
+  template<typename Variant>
+  static void copyConstruct(void* aLhs, const Variant& aRhs) {
+    new (aLhs) T(aRhs.template as<T>());
+  }
+
+  template<typename Variant>
+  static void moveConstruct(void* aLhs, Variant&& aRhs) {
+    new (aLhs) T(aRhs.template extract<T>());
+  }
+
+  template<typename Variant>
+  static void destroy(Variant& aV) {
+    aV.template as<T>().~T();
+  }
+
+  template<typename Variant>
+  static bool
+  equal(const Variant& aLhs, const Variant& aRhs) {
+      return aLhs.template as<T>() == aRhs.template as<T>();
+  }
+
+  template<typename Matcher, typename ConcreteVariant>
+  static typename Matcher::ReturnType
+  match(Matcher& aMatcher, ConcreteVariant& aV) {
+    return aMatcher.match(aV.template as<T>());
+  }
+};
+
+// VariantImplementation for some variant type T.
+template<size_t N, typename T, typename... Ts>
+struct VariantImplementation<N, T, Ts...>
+{
+  // The next recursive VariantImplementation.
+  using Next = VariantImplementation<N + 1, Ts...>;
+
+  template<typename U>
+  static size_t tag() {
+    return TagHelper<N, T, U, Next, IsSame<T, U>::value>::tag();
+  }
+
+  template<typename Variant>
+  static void copyConstruct(void* aLhs, const Variant& aRhs) {
+    if (aRhs.template is<T>()) {
+      new (aLhs) T(aRhs.template as<T>());
+    } else {
+      Next::copyConstruct(aLhs, aRhs);
+    }
+  }
+
+  template<typename Variant>
+  static void moveConstruct(void* aLhs, Variant&& aRhs) {
+    if (aRhs.template is<T>()) {
+      new (aLhs) T(aRhs.template extract<T>());
+    } else {
+      Next::moveConstruct(aLhs, aRhs);
+    }
+  }
+
+  template<typename Variant>
+  static void destroy(Variant& aV) {
+    if (aV.template is<T>()) {
+      aV.template as<T>().~T();
+    } else {
+      Next::destroy(aV);
+    }
+  }
+
+  template<typename Variant>
+  static bool equal(const Variant& aLhs, const Variant& aRhs) {
+    if (aLhs.template is<T>()) {
+      MOZ_ASSERT(aRhs.template is<T>());
+      return aLhs.template as<T>() == aRhs.template as<T>();
+    } else {
+      return Next::equal(aLhs, aRhs);
+    }
+  }
+
+  template<typename Matcher, typename ConcreteVariant>
+  static typename Matcher::ReturnType
+  match(Matcher& aMatcher, ConcreteVariant& aV)
+  {
+    if (aV.template is<T>()) {
+      return aMatcher.match(aV.template as<T>());
+    } else {
+      // If you're seeing compilation errors here like "no matching
+      // function for call to 'match'" then that means that the
+      // Matcher doesn't exhaust all variant types. There must exist a
+      // Matcher::match(T&) for every variant type T.
+      //
+      // If you're seeing compilation errors here like "cannot
+      // initialize return object of type <...> with an rvalue of type
+      // <...>" then that means that the Matcher::match(T&) overloads
+      // are returning different types. They must all return the same
+      // Matcher::ReturnType type.
+      return Next::match(aMatcher, aV);
+    }
+  }
+};
+
+} // namespace detail
+
+/**
+ * # mozilla::Variant
+ *
+ * A variant / tagged union / heterogenous disjoint union / sum-type template
+ * class. Similar in concept to (but not derived from) `boost::variant`.
+ *
+ * Sometimes, you may wish to use a C union with non-POD types. However, this is
+ * forbidden in C++ because it is not clear which type in the union should have
+ * its constructor and destructor run on creation and deletion
+ * respectively. This is the problem that `mozilla::Variant` solves.
+ *
+ * ## Usage
+ *
+ * A `mozilla::Variant` instance is constructed (via move or copy) from one of
+ * its variant types (ignoring const and references). It does *not* support
+ * construction from subclasses of variant types or types that coerce to one of
+ * the variant types.
+ *
+ *     Variant<char, uint32_t> v1('a');
+ *     Variant<UniquePtr<A>, B, C> v2(MakeUnique<A>());
+ *
+ * All access to the contained value goes through type-safe accessors.
+ *
+ *     void
+ *     Foo(Variant<A, B, C> v)
+ *     {
+ *       if (v.is<A>()) {
+ *         A& ref = v.as<A>();
+ *         ...
+ *       } else {
+ *         ...
+ *       }
+ *     }
+ *
+ * Attempting to use the contained value as type `T1` when the `Variant`
+ * instance contains a value of type `T2` causes an assertion failure.
+ *
+ *     A a;
+ *     Variant<A, B, C> v(a);
+ *     v.as<B>(); // <--- Assertion failure!
+ *
+ * Trying to use a `Variant<Ts...>` instance as some type `U` that is not a
+ * member of the set of `Ts...` is a compiler error.
+ *
+ *     A a;
+ *     Variant<A, B, C> v(a);
+ *     v.as<SomeRandomType>(); // <--- Compiler error!
+ *
+ * Additionally, you can turn a `Variant` that `is<T>` into a `T` by moving it
+ * out of the containing `Variant` instance with the `extract<T>` method:
+ *
+ *     Variant<UniquePtr<A>, B, C> v(MakeUnique<A>());
+ *     auto ptr = v.extract<UniquePtr<A>>();
+ *
+ * Finally, you can exhaustively match on the contained variant and branch into
+ * different code paths depending which type is contained. This is preferred to
+ * manually checking every variant type T with is<T>() because it provides
+ * compile-time checking that you handled every type, rather than runtime
+ * assertion failures.
+ *
+ *     // Bad!
+ *     char* foo(Variant<A, B, C, D>& v) {
+ *       if (v.is<A>()) {
+ *         return ...;
+ *       } else if (v.is<B>()) {
+ *         return ...;
+ *       } else {
+ *         return doSomething(v.as<C>()); // Forgot about case D!
+ *       }
+ *     }
+ *
+ *     // Good!
+ *     struct FooMatcher
+ *     {
+ *       using ReturnType = char*;
+ *       ReturnType match(A& a) { ... }
+ *       ReturnType match(B& b) { ... }
+ *       ReturnType match(C& c) { ... }
+ *       ReturnType match(D& d) { ... } // Compile-time error to forget D!
+ *     }
+ *     char* foo(Variant<A, B, C, D>& v) {
+ *       return v.match(FooMatcher());
+ *     }
+ *
+ * ## Examples
+ *
+ * A tree is either an empty leaf, or a node with a value and two children:
+ *
+ *     struct Leaf { };
+ *
+ *     template<typename T>
+ *     struct Node
+ *     {
+ *       T value;
+ *       Tree<T>* left;
+ *       Tree<T>* right;
+ *     };
+ *
+ *     template<typename T>
+ *     using Tree = Variant<Leaf, Node<T>>;
+ *
+ * A copy-on-write string is either a non-owning reference to some existing
+ * string, or an owning reference to our copy:
+ *
+ *     class CopyOnWriteString
+ *     {
+ *       Variant<const char*, UniquePtr<char[]>> string;
+ *
+ *       ...
+ *     };
+ */
+template<typename... Ts>
+class Variant
+{
+  using Impl = detail::VariantImplementation<0, Ts...>;
+  using RawData = AlignedStorage<detail::MaxSizeOf<Ts...>::size>;
+
+  // Each type is given a unique size_t sentinel. This tag lets us keep track of
+  // the contained variant value's type.
+  size_t tag;
+
+  // Raw storage for the contained variant value.
+  RawData raw;
+
+  void* ptr() {
+    return reinterpret_cast<void*>(&raw);
+  }
+
+public:
+  /** Perfect forwarding construction for some variant type T. */
+  template<typename RefT,
+           // RefT captures both const& as well as && (as intended, to support
+           // perfect forwarding), so we have to remove those qualifiers here
+           // when ensuring that T is a variant of this type, and getting T's
+           // tag, etc.
+           typename T = typename RemoveReference<typename RemoveConst<RefT>::Type>::Type,
+           typename = typename EnableIf<detail::IsVariant<T, Ts...>::value, void>::Type>
+  explicit Variant(RefT&& aT)
+    : tag(Impl::template tag<T>())
+  {
+    new (ptr()) T(Forward<T>(aT));
+  }
+
+  /** Copy construction. */
+  Variant(const Variant& aRhs)
+    : tag(aRhs.tag)
+  {
+    Impl::copyConstruct(ptr(), aRhs);
+  }
+
+  /** Move construction. */
+  Variant(Variant&& aRhs)
+    : tag(aRhs.tag)
+  {
+    Impl::moveConstruct(ptr(), Move(aRhs));
+  }
+
+  /** Copy assignment. */
+  Variant& operator=(const Variant& aRhs) {
+    MOZ_ASSERT(&aRhs != this, "self-assign disallowed");
+    this->~Variant();
+    new (this) Variant(aRhs);
+    return *this;
+  }
+
+  /** Move assignment. */
+  Variant& operator=(Variant&& aRhs) {
+    MOZ_ASSERT(&aRhs != this, "self-assign disallowed");
+    this->~Variant();
+    new (this) Variant(Move(aRhs));
+    return *this;
+  }
+
+  ~Variant()
+  {
+    Impl::destroy(*this);
+  }
+
+  /** Check which variant type is currently contained. */
+  template<typename T>
+  bool is() const {
+    static_assert(detail::IsVariant<T, Ts...>::value,
+                  "provided a type not found in this Variant's type list");
+    return Impl::template tag<T>() == tag;
+  }
+
+  /**
+   * Operator == overload that defers to the variant type's operator==
+   * implementation if the rhs is tagged as the same type as this one.
+   */
+  bool operator==(const Variant& aRhs) const {
+    return tag == aRhs.tag && Impl::equal(*this, aRhs);
+  }
+
+  /**
+   * Operator != overload that defers to the negation of the variant type's
+   * operator== implementation if the rhs is tagged as the same type as this
+   * one.
+   */
+  bool operator!=(const Variant& aRhs) const {
+    return !(*this == aRhs);
+  }
+
+  // Accessors for working with the contained variant value.
+
+  /** Mutable reference. */
+  template<typename T>
+  T& as() {
+    static_assert(detail::IsVariant<T, Ts...>::value,
+                  "provided a type not found in this Variant's type list");
+    MOZ_ASSERT(is<T>());
+    return *reinterpret_cast<T*>(&raw);
+  }
+
+  /** Immutable const reference. */
+  template<typename T>
+  const T& as() const {
+    static_assert(detail::IsVariant<T, Ts...>::value,
+                  "provided a type not found in this Variant's type list");
+    MOZ_ASSERT(is<T>());
+    return *reinterpret_cast<const T*>(&raw);
+  }
+
+  /**
+   * Extract the contained variant value from this container into a temporary
+   * value.  On completion, the value in the variant will be in a
+   * safely-destructible state, as determined by the behavior of T's move
+   * constructor when provided the variant's internal value.
+   */
+  template<typename T>
+  T extract() {
+    static_assert(detail::IsVariant<T, Ts...>::value,
+                  "provided a type not found in this Variant's type list");
+    MOZ_ASSERT(is<T>());
+    return T(Move(as<T>()));
+  }
+
+  // Exhaustive matching of all variant types no the contained value.
+
+  /** Match on an immutable const reference. */
+  template<typename Matcher>
+  typename Matcher::ReturnType
+  match(Matcher& aMatcher) const {
+    return Impl::match(aMatcher, *this);
+  }
+
+  /**  Match on a mutable non-const reference. */
+  template<typename Matcher>
+  typename Matcher::ReturnType
+  match(Matcher& aMatcher) {
+    return Impl::match(aMatcher, *this);
+  }
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_Variant_h */
diff --git a/src/third_party/mozjs-45/mfbt/Vector.h b/src/third_party/mozjs-45/mfbt/Vector.h
new file mode 100644
index 0000000..c801ef1
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/Vector.h
@@ -0,0 +1,1370 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* A type/length-parametrized vector class. */
+
+#ifndef mozilla_Vector_h
+#define mozilla_Vector_h
+
+#include "mozilla/Alignment.h"
+#include "mozilla/AllocPolicy.h"
+#include "mozilla/ArrayUtils.h" // for PointerRangeSize
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/MathAlgorithms.h"
+#include "mozilla/MemoryReporting.h"
+#include "mozilla/Move.h"
+#include "mozilla/ReentrancyGuard.h"
+#include "mozilla/TemplateLib.h"
+#include "mozilla/TypeTraits.h"
+
+#include <new> // for placement new
+
+/* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4345)
+#endif
+
+namespace mozilla {
+
+template<typename T, size_t N, class AllocPolicy>
+class Vector;
+
+namespace detail {
+
+/*
+ * Check that the given capacity wastes the minimal amount of space if
+ * allocated on the heap. This means that aCapacity*sizeof(T) is as close to a
+ * power-of-two as possible. growStorageBy() is responsible for ensuring this.
+ */
+template<typename T>
+static bool CapacityHasExcessSpace(size_t aCapacity)
+{
+  size_t size = aCapacity * sizeof(T);
+  return RoundUpPow2(size) - size >= sizeof(T);
+}
+
+/*
+ * This template class provides a default implementation for vector operations
+ * when the element type is not known to be a POD, as judged by IsPod.
+ */
+template<typename T, size_t N, class AP, bool IsPod>
+struct VectorImpl
+{
+  /*
+   * Constructs a default object in the uninitialized memory at *aDst.
+   */
+  MOZ_NONNULL(1)
+  static inline void new_(T* aDst)
+  {
+    new(aDst) T();
+  }
+
+  /*
+   * Constructs an object in the uninitialized memory at *aDst from aSrc.
+   */
+  template<typename U>
+  MOZ_NONNULL(1)
+  static inline void new_(T* aDst, U&& aU)
+  {
+    new(aDst) T(Forward<U>(aU));
+  }
+
+  /* Destroys constructed objects in the range [aBegin, aEnd). */
+  static inline void destroy(T* aBegin, T* aEnd)
+  {
+    MOZ_ASSERT(aBegin <= aEnd);
+    for (T* p = aBegin; p < aEnd; ++p) {
+      p->~T();
+    }
+  }
+
+  /* Constructs objects in the uninitialized range [aBegin, aEnd). */
+  static inline void initialize(T* aBegin, T* aEnd)
+  {
+    MOZ_ASSERT(aBegin <= aEnd);
+    for (T* p = aBegin; p < aEnd; ++p) {
+      new_(p);
+    }
+  }
+
+  /*
+   * Copy-constructs objects in the uninitialized range
+   * [aDst, aDst+(aSrcEnd-aSrcStart)) from the range [aSrcStart, aSrcEnd).
+   */
+  template<typename U>
+  static inline void copyConstruct(T* aDst,
+                                   const U* aSrcStart, const U* aSrcEnd)
+  {
+    MOZ_ASSERT(aSrcStart <= aSrcEnd);
+    for (const U* p = aSrcStart; p < aSrcEnd; ++p, ++aDst) {
+      new_(aDst, *p);
+    }
+  }
+
+  /*
+   * Move-constructs objects in the uninitialized range
+   * [aDst, aDst+(aSrcEnd-aSrcStart)) from the range [aSrcStart, aSrcEnd).
+   */
+  template<typename U>
+  static inline void moveConstruct(T* aDst, U* aSrcStart, U* aSrcEnd)
+  {
+    MOZ_ASSERT(aSrcStart <= aSrcEnd);
+    for (U* p = aSrcStart; p < aSrcEnd; ++p, ++aDst) {
+      new_(aDst, Move(*p));
+    }
+  }
+
+  /*
+   * Copy-constructs objects in the uninitialized range [aDst, aDst+aN) from
+   * the same object aU.
+   */
+  template<typename U>
+  static inline void copyConstructN(T* aDst, size_t aN, const U& aU)
+  {
+    for (T* end = aDst + aN; aDst < end; ++aDst) {
+      new_(aDst, aU);
+    }
+  }
+
+  /*
+   * Grows the given buffer to have capacity aNewCap, preserving the objects
+   * constructed in the range [begin, end) and updating aV. Assumes that (1)
+   * aNewCap has not overflowed, and (2) multiplying aNewCap by sizeof(T) will
+   * not overflow.
+   */
+  static inline bool
+  growTo(Vector<T, N, AP>& aV, size_t aNewCap)
+  {
+    MOZ_ASSERT(!aV.usingInlineStorage());
+    MOZ_ASSERT(!CapacityHasExcessSpace<T>(aNewCap));
+    T* newbuf = aV.template pod_malloc<T>(aNewCap);
+    if (MOZ_UNLIKELY(!newbuf)) {
+      return false;
+    }
+    T* dst = newbuf;
+    T* src = aV.beginNoCheck();
+    for (; src < aV.endNoCheck(); ++dst, ++src) {
+      new_(dst, Move(*src));
+    }
+    VectorImpl::destroy(aV.beginNoCheck(), aV.endNoCheck());
+    aV.free_(aV.mBegin);
+    aV.mBegin = newbuf;
+    /* aV.mLength is unchanged. */
+    aV.mCapacity = aNewCap;
+    return true;
+  }
+};
+
+/*
+ * This partial template specialization provides a default implementation for
+ * vector operations when the element type is known to be a POD, as judged by
+ * IsPod.
+ */
+template<typename T, size_t N, class AP>
+struct VectorImpl<T, N, AP, true>
+{
+  static inline void new_(T* aDst)
+  {
+    *aDst = T();
+  }
+
+  template<typename U>
+  static inline void new_(T* aDst, U&& aU)
+  {
+    *aDst = Forward<U>(aU);
+  }
+
+  static inline void destroy(T*, T*) {}
+
+  static inline void initialize(T* aBegin, T* aEnd)
+  {
+    /*
+     * You would think that memset would be a big win (or even break even)
+     * when we know T is a POD. But currently it's not. This is probably
+     * because |append| tends to be given small ranges and memset requires
+     * a function call that doesn't get inlined.
+     *
+     * memset(aBegin, 0, sizeof(T) * (aEnd - aBegin));
+     */
+    MOZ_ASSERT(aBegin <= aEnd);
+    for (T* p = aBegin; p < aEnd; ++p) {
+      new_(p);
+    }
+  }
+
+  template<typename U>
+  static inline void copyConstruct(T* aDst,
+                                   const U* aSrcStart, const U* aSrcEnd)
+  {
+    /*
+     * See above memset comment. Also, notice that copyConstruct is
+     * currently templated (T != U), so memcpy won't work without
+     * requiring T == U.
+     *
+     * memcpy(aDst, aSrcStart, sizeof(T) * (aSrcEnd - aSrcStart));
+     */
+    MOZ_ASSERT(aSrcStart <= aSrcEnd);
+    for (const U* p = aSrcStart; p < aSrcEnd; ++p, ++aDst) {
+      new_(aDst, *p);
+    }
+  }
+
+  template<typename U>
+  static inline void moveConstruct(T* aDst,
+                                   const U* aSrcStart, const U* aSrcEnd)
+  {
+    copyConstruct(aDst, aSrcStart, aSrcEnd);
+  }
+
+  static inline void copyConstructN(T* aDst, size_t aN, const T& aT)
+  {
+    for (T* end = aDst + aN; aDst < end; ++aDst) {
+      new_(aDst, aT);
+    }
+  }
+
+  static inline bool
+  growTo(Vector<T, N, AP>& aV, size_t aNewCap)
+  {
+    MOZ_ASSERT(!aV.usingInlineStorage());
+    MOZ_ASSERT(!CapacityHasExcessSpace<T>(aNewCap));
+    T* newbuf = aV.template pod_realloc<T>(aV.mBegin, aV.mCapacity, aNewCap);
+    if (MOZ_UNLIKELY(!newbuf)) {
+      return false;
+    }
+    aV.mBegin = newbuf;
+    /* aV.mLength is unchanged. */
+    aV.mCapacity = aNewCap;
+    return true;
+  }
+};
+
+// A struct for TestVector.cpp to access private internal fields.
+// DO NOT DEFINE IN YOUR OWN CODE.
+struct VectorTesting;
+
+} // namespace detail
+
+/*
+ * STL-like container providing a short-lived, dynamic buffer.  Vector calls the
+ * constructors/destructors of all elements stored in its internal buffer, so
+ * non-PODs may be safely used.  Additionally, Vector will store the first N
+ * elements in-place before resorting to dynamic allocation.
+ *
+ * T requirements:
+ *  - default and copy constructible, assignable, destructible
+ *  - operations do not throw
+ * MinInlineCapacity requirements:
+ *  - any value, however, MinInlineCapacity is clamped to min/max values
+ * AllocPolicy:
+ *  - see "Allocation policies" in AllocPolicy.h (defaults to
+ *    mozilla::MallocAllocPolicy)
+ *
+ * Vector is not reentrant: T member functions called during Vector member
+ * functions must not call back into the same object!
+ */
+template<typename T,
+         size_t MinInlineCapacity = 0,
+         class AllocPolicy = MallocAllocPolicy>
+class Vector final : private AllocPolicy
+{
+  /* utilities */
+
+  static const bool kElemIsPod = IsPod<T>::value;
+  typedef detail::VectorImpl<T, MinInlineCapacity, AllocPolicy, kElemIsPod> Impl;
+  friend struct detail::VectorImpl<T, MinInlineCapacity, AllocPolicy, kElemIsPod>;
+
+  friend struct detail::VectorTesting;
+
+  bool growStorageBy(size_t aIncr);
+  bool convertToHeapStorage(size_t aNewCap);
+
+  /* magic constants */
+
+  static const int kMaxInlineBytes = 1024;
+
+  /* compute constants */
+
+  /*
+   * Consider element size to be 1 for buffer sizing if there are 0 inline
+   * elements.  This allows us to compile when the definition of the element
+   * type is not visible here.
+   *
+   * Explicit specialization is only allowed at namespace scope, so in order
+   * to keep everything here, we use a dummy template parameter with partial
+   * specialization.
+   */
+  template<int M, int Dummy>
+  struct ElemSize
+  {
+    static const size_t value = sizeof(T);
+  };
+  template<int Dummy>
+  struct ElemSize<0, Dummy>
+  {
+    static const size_t value = 1;
+  };
+
+  static const size_t kInlineCapacity =
+    tl::Min<MinInlineCapacity, kMaxInlineBytes / ElemSize<MinInlineCapacity, 0>::value>::value;
+
+  /* Calculate inline buffer size; avoid 0-sized array. */
+  static const size_t kInlineBytes =
+    tl::Max<1, kInlineCapacity * ElemSize<MinInlineCapacity, 0>::value>::value;
+
+  /* member data */
+
+  /*
+   * Pointer to the buffer, be it inline or heap-allocated. Only [mBegin,
+   * mBegin + mLength) hold valid constructed T objects. The range [mBegin +
+   * mLength, mBegin + mCapacity) holds uninitialized memory. The range
+   * [mBegin + mLength, mBegin + mReserved) also holds uninitialized memory
+   * previously allocated by a call to reserve().
+   */
+  T* mBegin;
+
+  /* Number of elements in the vector. */
+  size_t mLength;
+
+  /* Max number of elements storable in the vector without resizing. */
+  size_t mCapacity;
+
+#ifdef DEBUG
+  /* Max elements of reserved or used space in this vector. */
+  size_t mReserved;
+#endif
+
+  /* Memory used for inline storage. */
+  AlignedStorage<kInlineBytes> mStorage;
+
+#ifdef DEBUG
+  friend class ReentrancyGuard;
+  bool mEntered;
+#endif
+
+  /* private accessors */
+
+  bool usingInlineStorage() const
+  {
+    return mBegin == const_cast<Vector*>(this)->inlineStorage();
+  }
+
+  T* inlineStorage()
+  {
+    return static_cast<T*>(mStorage.addr());
+  }
+
+  T* beginNoCheck() const
+  {
+    return mBegin;
+  }
+
+  T* endNoCheck()
+  {
+    return mBegin + mLength;
+  }
+
+  const T* endNoCheck() const
+  {
+    return mBegin + mLength;
+  }
+
+#ifdef DEBUG
+  /**
+   * The amount of explicitly allocated space in this vector that is immediately
+   * available to be filled by appending additional elements.  This value is
+   * always greater than or equal to |length()| -- the vector's actual elements
+   * are implicitly reserved.  This value is always less than or equal to
+   * |capacity()|.  It may be explicitly increased using the |reserve()| method.
+   */
+  size_t reserved() const
+  {
+    MOZ_ASSERT(mLength <= mReserved);
+    MOZ_ASSERT(mReserved <= mCapacity);
+    return mReserved;
+  }
+#endif
+
+  /* Append operations guaranteed to succeed due to pre-reserved space. */
+  template<typename U> void internalAppend(U&& aU);
+  template<typename U, size_t O, class BP>
+  void internalAppendAll(const Vector<U, O, BP>& aU);
+  void internalAppendN(const T& aT, size_t aN);
+  template<typename U> void internalAppend(const U* aBegin, size_t aLength);
+
+public:
+  static const size_t sMaxInlineStorage = MinInlineCapacity;
+
+  typedef T ElementType;
+
+  explicit Vector(AllocPolicy = AllocPolicy());
+  Vector(Vector&&); /* Move constructor. */
+  Vector& operator=(Vector&&); /* Move assignment. */
+  ~Vector();
+
+  /* accessors */
+
+  const AllocPolicy& allocPolicy() const { return *this; }
+
+  AllocPolicy& allocPolicy() { return *this; }
+
+  enum { InlineLength = MinInlineCapacity };
+
+  size_t length() const { return mLength; }
+
+  bool empty() const { return mLength == 0; }
+
+  size_t capacity() const { return mCapacity; }
+
+  T* begin()
+  {
+    MOZ_ASSERT(!mEntered);
+    return mBegin;
+  }
+
+  const T* begin() const
+  {
+    MOZ_ASSERT(!mEntered);
+    return mBegin;
+  }
+
+  T* end()
+  {
+    MOZ_ASSERT(!mEntered);
+    return mBegin + mLength;
+  }
+
+  const T* end() const
+  {
+    MOZ_ASSERT(!mEntered);
+    return mBegin + mLength;
+  }
+
+  T& operator[](size_t aIndex)
+  {
+    MOZ_ASSERT(!mEntered);
+    MOZ_ASSERT(aIndex < mLength);
+    return begin()[aIndex];
+  }
+
+  const T& operator[](size_t aIndex) const
+  {
+    MOZ_ASSERT(!mEntered);
+    MOZ_ASSERT(aIndex < mLength);
+    return begin()[aIndex];
+  }
+
+  T& back()
+  {
+    MOZ_ASSERT(!mEntered);
+    MOZ_ASSERT(!empty());
+    return *(end() - 1);
+  }
+
+  const T& back() const
+  {
+    MOZ_ASSERT(!mEntered);
+    MOZ_ASSERT(!empty());
+    return *(end() - 1);
+  }
+
+  class Range
+  {
+    friend class Vector;
+    T* mCur;
+    T* mEnd;
+    Range(T* aCur, T* aEnd)
+      : mCur(aCur)
+      , mEnd(aEnd)
+    {
+      MOZ_ASSERT(aCur <= aEnd);
+    }
+
+  public:
+    bool empty() const { return mCur == mEnd; }
+    size_t remain() const { return PointerRangeSize(mCur, mEnd); }
+    T& front() const { MOZ_ASSERT(!empty()); return *mCur; }
+    void popFront() { MOZ_ASSERT(!empty()); ++mCur; }
+    T popCopyFront() { MOZ_ASSERT(!empty()); return *mCur++; }
+  };
+
+  class ConstRange
+  {
+    friend class Vector;
+    const T* mCur;
+    const T* mEnd;
+    ConstRange(const T* aCur, const T* aEnd)
+      : mCur(aCur)
+      , mEnd(aEnd)
+    {
+      MOZ_ASSERT(aCur <= aEnd);
+    }
+
+  public:
+    bool empty() const { return mCur == mEnd; }
+    size_t remain() const { return PointerRangeSize(mCur, mEnd); }
+    const T& front() const { MOZ_ASSERT(!empty()); return *mCur; }
+    void popFront() { MOZ_ASSERT(!empty()); ++mCur; }
+    T popCopyFront() { MOZ_ASSERT(!empty()); return *mCur++; }
+  };
+
+  Range all() { return Range(begin(), end()); }
+  ConstRange all() const { return ConstRange(begin(), end()); }
+
+  /* mutators */
+
+  /**
+   * Given that the vector is empty and has no inline storage, grow to
+   * |capacity|.
+   */
+  bool initCapacity(size_t aRequest);
+
+  /**
+   * If reserve(aRequest) succeeds and |aRequest >= length()|, then appending
+   * |aRequest - length()| elements, in any sequence of append/appendAll calls,
+   * is guaranteed to succeed.
+   *
+   * A request to reserve an amount less than the current length does not affect
+   * reserved space.
+   */
+  bool reserve(size_t aRequest);
+
+  /**
+   * Destroy elements in the range [end() - aIncr, end()). Does not deallocate
+   * or unreserve storage for those elements.
+   */
+  void shrinkBy(size_t aIncr);
+
+  /** Grow the vector by aIncr elements. */
+  bool growBy(size_t aIncr);
+
+  /** Call shrinkBy or growBy based on whether newSize > length(). */
+  bool resize(size_t aNewLength);
+
+  /**
+   * Increase the length of the vector, but don't initialize the new elements
+   * -- leave them as uninitialized memory.
+   */
+  bool growByUninitialized(size_t aIncr);
+  void infallibleGrowByUninitialized(size_t aIncr);
+  bool resizeUninitialized(size_t aNewLength);
+
+  /** Shorthand for shrinkBy(length()). */
+  void clear();
+
+  /** Clears and releases any heap-allocated storage. */
+  void clearAndFree();
+
+  /**
+   * If true, appending |aNeeded| elements won't reallocate elements storage.
+   * This *doesn't* mean that infallibleAppend may be used!  You still must
+   * reserve the extra space, even if this method indicates that appends won't
+   * need to reallocate elements storage.
+   */
+  bool canAppendWithoutRealloc(size_t aNeeded) const;
+
+  /** Potentially fallible append operations. */
+
+  /**
+   * This can take either a T& or a T&&. Given a T&&, it moves |aU| into the
+   * vector, instead of copying it. If it fails, |aU| is left unmoved. ("We are
+   * not amused.")
+   */
+  template<typename U> bool append(U&& aU);
+
+  /**
+   * Construct a T in-place as a new entry at the end of this vector.
+   */
+  template<typename... Args>
+  bool emplaceBack(Args&&... aArgs)
+  {
+    if (!growByUninitialized(1))
+      return false;
+    new (&back()) T(Forward<Args>(aArgs)...);
+    return true;
+  }
+
+  template<typename U, size_t O, class BP>
+  bool appendAll(const Vector<U, O, BP>& aU);
+  bool appendN(const T& aT, size_t aN);
+  template<typename U> bool append(const U* aBegin, const U* aEnd);
+  template<typename U> bool append(const U* aBegin, size_t aLength);
+
+  /*
+   * Guaranteed-infallible append operations for use upon vectors whose
+   * memory has been pre-reserved.  Don't use this if you haven't reserved the
+   * memory!
+   */
+  template<typename U> void infallibleAppend(U&& aU)
+  {
+    internalAppend(Forward<U>(aU));
+  }
+  void infallibleAppendN(const T& aT, size_t aN)
+  {
+    internalAppendN(aT, aN);
+  }
+  template<typename U> void infallibleAppend(const U* aBegin, const U* aEnd)
+  {
+    internalAppend(aBegin, PointerRangeSize(aBegin, aEnd));
+  }
+  template<typename U> void infallibleAppend(const U* aBegin, size_t aLength)
+  {
+    internalAppend(aBegin, aLength);
+  }
+  template<typename... Args>
+  void infallibleEmplaceBack(Args&&... aArgs)
+  {
+    infallibleGrowByUninitialized(1);
+    new (&back()) T(Forward<Args>(aArgs)...);
+  }
+
+  void popBack();
+
+  T popCopy();
+
+  /**
+   * Transfers ownership of the internal buffer used by this vector to the
+   * caller.  (It's the caller's responsibility to properly deallocate this
+   * buffer, in accordance with this vector's AllocPolicy.)  After this call,
+   * the vector is empty.  Since the returned buffer may need to be allocated
+   * (if the elements are currently stored in-place), the call can fail,
+   * returning nullptr.
+   *
+   * N.B. Although a T*, only the range [0, length()) is constructed.
+   */
+  T* extractRawBuffer();
+
+  /**
+   * Transfer ownership of an array of objects into the vector.  The caller
+   * must have allocated the array in accordance with this vector's
+   * AllocPolicy.
+   *
+   * N.B. This call assumes that there are no uninitialized elements in the
+   *      passed array.
+   */
+  void replaceRawBuffer(T* aP, size_t aLength);
+
+  /**
+   * Places |aVal| at position |aP|, shifting existing elements from |aP| onward
+   * one position higher.  On success, |aP| should not be reused because it'll
+   * be a dangling pointer if reallocation of the vector storage occurred; the
+   * return value should be used instead.  On failure, nullptr is returned.
+   *
+   * Example usage:
+   *
+   *   if (!(p = vec.insert(p, val))) {
+   *     <handle failure>
+   *   }
+   *   <keep working with p>
+   *
+   * This is inherently a linear-time operation.  Be careful!
+   */
+  template<typename U>
+  T* insert(T* aP, U&& aVal);
+
+  /**
+   * Removes the element |aT|, which must fall in the bounds [begin, end),
+   * shifting existing elements from |aT + 1| onward one position lower.
+   */
+  void erase(T* aT);
+
+  /**
+   * Removes the elements [|aBegin|, |aEnd|), which must fall in the bounds
+   * [begin, end), shifting existing elements from |aEnd + 1| onward to aBegin's
+   * old position.
+   */
+  void erase(T* aBegin, T* aEnd);
+
+  /**
+   * Measure the size of the vector's heap-allocated storage.
+   */
+  size_t sizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
+
+  /**
+   * Like sizeOfExcludingThis, but also measures the size of the vector
+   * object (which must be heap-allocated) itself.
+   */
+  size_t sizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
+
+  void swap(Vector& aOther);
+
+private:
+  Vector(const Vector&) = delete;
+  void operator=(const Vector&) = delete;
+};
+
+/* This does the re-entrancy check plus several other sanity checks. */
+#define MOZ_REENTRANCY_GUARD_ET_AL \
+  ReentrancyGuard g(*this); \
+  MOZ_ASSERT_IF(usingInlineStorage(), mCapacity == kInlineCapacity); \
+  MOZ_ASSERT(reserved() <= mCapacity); \
+  MOZ_ASSERT(mLength <= reserved()); \
+  MOZ_ASSERT(mLength <= mCapacity)
+
+/* Vector Implementation */
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE
+Vector<T, N, AP>::Vector(AP aAP)
+  : AP(aAP)
+  , mLength(0)
+  , mCapacity(kInlineCapacity)
+#ifdef DEBUG
+  , mReserved(0)
+  , mEntered(false)
+#endif
+{
+  mBegin = static_cast<T*>(mStorage.addr());
+}
+
+/* Move constructor. */
+template<typename T, size_t N, class AllocPolicy>
+MOZ_ALWAYS_INLINE
+Vector<T, N, AllocPolicy>::Vector(Vector&& aRhs)
+  : AllocPolicy(Move(aRhs))
+#ifdef DEBUG
+  , mEntered(false)
+#endif
+{
+  mLength = aRhs.mLength;
+  mCapacity = aRhs.mCapacity;
+#ifdef DEBUG
+  mReserved = aRhs.mReserved;
+#endif
+
+  if (aRhs.usingInlineStorage()) {
+    /* We can't move the buffer over in this case, so copy elements. */
+    mBegin = static_cast<T*>(mStorage.addr());
+    Impl::moveConstruct(mBegin, aRhs.beginNoCheck(), aRhs.endNoCheck());
+    /*
+     * Leave aRhs's mLength, mBegin, mCapacity, and mReserved as they are.
+     * The elements in its in-line storage still need to be destroyed.
+     */
+  } else {
+    /*
+     * Take src's buffer, and turn src into an empty vector using
+     * in-line storage.
+     */
+    mBegin = aRhs.mBegin;
+    aRhs.mBegin = static_cast<T*>(aRhs.mStorage.addr());
+    aRhs.mCapacity = kInlineCapacity;
+    aRhs.mLength = 0;
+#ifdef DEBUG
+    aRhs.mReserved = 0;
+#endif
+  }
+}
+
+/* Move assignment. */
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE Vector<T, N, AP>&
+Vector<T, N, AP>::operator=(Vector&& aRhs)
+{
+  MOZ_ASSERT(this != &aRhs, "self-move assignment is prohibited");
+  this->~Vector();
+  new(this) Vector(Move(aRhs));
+  return *this;
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE
+Vector<T, N, AP>::~Vector()
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  Impl::destroy(beginNoCheck(), endNoCheck());
+  if (!usingInlineStorage()) {
+    this->free_(beginNoCheck());
+  }
+}
+
+/*
+ * This function will create a new heap buffer with capacity aNewCap,
+ * move all elements in the inline buffer to this new buffer,
+ * and fail on OOM.
+ */
+template<typename T, size_t N, class AP>
+inline bool
+Vector<T, N, AP>::convertToHeapStorage(size_t aNewCap)
+{
+  MOZ_ASSERT(usingInlineStorage());
+
+  /* Allocate buffer. */
+  MOZ_ASSERT(!detail::CapacityHasExcessSpace<T>(aNewCap));
+  T* newBuf = this->template pod_malloc<T>(aNewCap);
+  if (MOZ_UNLIKELY(!newBuf)) {
+    return false;
+  }
+
+  /* Copy inline elements into heap buffer. */
+  Impl::moveConstruct(newBuf, beginNoCheck(), endNoCheck());
+  Impl::destroy(beginNoCheck(), endNoCheck());
+
+  /* Switch in heap buffer. */
+  mBegin = newBuf;
+  /* mLength is unchanged. */
+  mCapacity = aNewCap;
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+MOZ_NEVER_INLINE bool
+Vector<T, N, AP>::growStorageBy(size_t aIncr)
+{
+  MOZ_ASSERT(mLength + aIncr > mCapacity);
+
+  /*
+   * When choosing a new capacity, its size should is as close to 2**N bytes
+   * as possible.  2**N-sized requests are best because they are unlikely to
+   * be rounded up by the allocator.  Asking for a 2**N number of elements
+   * isn't as good, because if sizeof(T) is not a power-of-two that would
+   * result in a non-2**N request size.
+   */
+
+  size_t newCap;
+
+  if (aIncr == 1) {
+    if (usingInlineStorage()) {
+      /* This case occurs in ~70--80% of the calls to this function. */
+      size_t newSize =
+        tl::RoundUpPow2<(kInlineCapacity + 1) * sizeof(T)>::value;
+      newCap = newSize / sizeof(T);
+      goto convert;
+    }
+
+    if (mLength == 0) {
+      /* This case occurs in ~0--10% of the calls to this function. */
+      newCap = 1;
+      goto grow;
+    }
+
+    /* This case occurs in ~15--20% of the calls to this function. */
+
+    /*
+     * Will mLength * 4 *sizeof(T) overflow?  This condition limits a vector
+     * to 1GB of memory on a 32-bit system, which is a reasonable limit.  It
+     * also ensures that
+     *
+     *   static_cast<char*>(end()) - static_cast<char*>(begin())
+     *
+     * doesn't overflow ptrdiff_t (see bug 510319).
+     */
+    if (MOZ_UNLIKELY(mLength & tl::MulOverflowMask<4 * sizeof(T)>::value)) {
+      this->reportAllocOverflow();
+      return false;
+    }
+
+    /*
+     * If we reach here, the existing capacity will have a size that is already
+     * as close to 2^N as sizeof(T) will allow.  Just double the capacity, and
+     * then there might be space for one more element.
+     */
+    newCap = mLength * 2;
+    if (detail::CapacityHasExcessSpace<T>(newCap)) {
+      newCap += 1;
+    }
+  } else {
+    /* This case occurs in ~2% of the calls to this function. */
+    size_t newMinCap = mLength + aIncr;
+
+    /* Did mLength + aIncr overflow?  Will newCap * sizeof(T) overflow? */
+    if (MOZ_UNLIKELY(newMinCap < mLength ||
+                     newMinCap & tl::MulOverflowMask<2 * sizeof(T)>::value))
+    {
+      this->reportAllocOverflow();
+      return false;
+    }
+
+    size_t newMinSize = newMinCap * sizeof(T);
+    size_t newSize = RoundUpPow2(newMinSize);
+    newCap = newSize / sizeof(T);
+  }
+
+  if (usingInlineStorage()) {
+convert:
+    return convertToHeapStorage(newCap);
+  }
+
+grow:
+  return Impl::growTo(*this, newCap);
+}
+
+template<typename T, size_t N, class AP>
+inline bool
+Vector<T, N, AP>::initCapacity(size_t aRequest)
+{
+  MOZ_ASSERT(empty());
+  MOZ_ASSERT(usingInlineStorage());
+  if (aRequest == 0) {
+    return true;
+  }
+  T* newbuf = this->template pod_malloc<T>(aRequest);
+  if (MOZ_UNLIKELY(!newbuf)) {
+    return false;
+  }
+  mBegin = newbuf;
+  mCapacity = aRequest;
+#ifdef DEBUG
+  mReserved = aRequest;
+#endif
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+inline bool
+Vector<T, N, AP>::reserve(size_t aRequest)
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  if (aRequest > mCapacity) {
+    if (MOZ_UNLIKELY(!growStorageBy(aRequest - mLength))) {
+      return false;
+    }
+  } else if (aRequest > N) {
+    if (!allocPolicy().checkSimulatedOOM()) {
+      return false;
+    }
+  }
+#ifdef DEBUG
+  if (aRequest > mReserved) {
+    mReserved = aRequest;
+  }
+  MOZ_ASSERT(mLength <= mReserved);
+  MOZ_ASSERT(mReserved <= mCapacity);
+#endif
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+inline void
+Vector<T, N, AP>::shrinkBy(size_t aIncr)
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  MOZ_ASSERT(aIncr <= mLength);
+  Impl::destroy(endNoCheck() - aIncr, endNoCheck());
+  mLength -= aIncr;
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE bool
+Vector<T, N, AP>::growBy(size_t aIncr)
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  if (aIncr > mCapacity - mLength) {
+    if (MOZ_UNLIKELY(!growStorageBy(aIncr))) {
+      return false;
+    }
+  } else if (aIncr + mLength > N) {
+    if (!allocPolicy().checkSimulatedOOM()) {
+      return false;
+    }
+  }
+  MOZ_ASSERT(mLength + aIncr <= mCapacity);
+  T* newend = endNoCheck() + aIncr;
+  Impl::initialize(endNoCheck(), newend);
+  mLength += aIncr;
+#ifdef DEBUG
+  if (mLength > mReserved) {
+    mReserved = mLength;
+  }
+#endif
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE bool
+Vector<T, N, AP>::growByUninitialized(size_t aIncr)
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  if (aIncr > mCapacity - mLength) {
+    if (MOZ_UNLIKELY(!growStorageBy(aIncr))) {
+      return false;
+    }
+  } else if (aIncr + mLength > N) {
+    if (!allocPolicy().checkSimulatedOOM()) {
+      return false;
+    }
+  }
+  infallibleGrowByUninitialized(aIncr);
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE void
+Vector<T, N, AP>::infallibleGrowByUninitialized(size_t aIncr)
+{
+  MOZ_ASSERT(mLength + aIncr <= mCapacity);
+  mLength += aIncr;
+#ifdef DEBUG
+  if (mLength > mReserved) {
+    mReserved = mLength;
+  }
+#endif
+}
+
+template<typename T, size_t N, class AP>
+inline bool
+Vector<T, N, AP>::resize(size_t aNewLength)
+{
+  size_t curLength = mLength;
+  if (aNewLength > curLength) {
+    return growBy(aNewLength - curLength);
+  }
+  shrinkBy(curLength - aNewLength);
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE bool
+Vector<T, N, AP>::resizeUninitialized(size_t aNewLength)
+{
+  size_t curLength = mLength;
+  if (aNewLength > curLength) {
+    return growByUninitialized(aNewLength - curLength);
+  }
+  shrinkBy(curLength - aNewLength);
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+inline void
+Vector<T, N, AP>::clear()
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  Impl::destroy(beginNoCheck(), endNoCheck());
+  mLength = 0;
+}
+
+template<typename T, size_t N, class AP>
+inline void
+Vector<T, N, AP>::clearAndFree()
+{
+  clear();
+
+  if (usingInlineStorage()) {
+    return;
+  }
+  this->free_(beginNoCheck());
+  mBegin = static_cast<T*>(mStorage.addr());
+  mCapacity = kInlineCapacity;
+#ifdef DEBUG
+  mReserved = 0;
+#endif
+}
+
+template<typename T, size_t N, class AP>
+inline bool
+Vector<T, N, AP>::canAppendWithoutRealloc(size_t aNeeded) const
+{
+  return mLength + aNeeded <= mCapacity;
+}
+
+template<typename T, size_t N, class AP>
+template<typename U, size_t O, class BP>
+MOZ_ALWAYS_INLINE void
+Vector<T, N, AP>::internalAppendAll(const Vector<U, O, BP>& aOther)
+{
+  internalAppend(aOther.begin(), aOther.length());
+}
+
+template<typename T, size_t N, class AP>
+template<typename U>
+MOZ_ALWAYS_INLINE void
+Vector<T, N, AP>::internalAppend(U&& aU)
+{
+  MOZ_ASSERT(mLength + 1 <= mReserved);
+  MOZ_ASSERT(mReserved <= mCapacity);
+  Impl::new_(endNoCheck(), Forward<U>(aU));
+  ++mLength;
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE bool
+Vector<T, N, AP>::appendN(const T& aT, size_t aNeeded)
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  if (mLength + aNeeded > mCapacity) {
+    if (MOZ_UNLIKELY(!growStorageBy(aNeeded))) {
+      return false;
+    }
+  } else if (mLength + aNeeded > N) {
+    if (!allocPolicy().checkSimulatedOOM())
+      return false;
+  }
+#ifdef DEBUG
+  if (mLength + aNeeded > mReserved) {
+    mReserved = mLength + aNeeded;
+  }
+#endif
+  internalAppendN(aT, aNeeded);
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE void
+Vector<T, N, AP>::internalAppendN(const T& aT, size_t aNeeded)
+{
+  MOZ_ASSERT(mLength + aNeeded <= mReserved);
+  MOZ_ASSERT(mReserved <= mCapacity);
+  Impl::copyConstructN(endNoCheck(), aNeeded, aT);
+  mLength += aNeeded;
+}
+
+template<typename T, size_t N, class AP>
+template<typename U>
+inline T*
+Vector<T, N, AP>::insert(T* aP, U&& aVal)
+{
+  MOZ_ASSERT(begin() <= aP);
+  MOZ_ASSERT(aP <= end());
+  size_t pos = aP - begin();
+  MOZ_ASSERT(pos <= mLength);
+  size_t oldLength = mLength;
+  if (pos == oldLength) {
+    if (!append(Forward<U>(aVal))) {
+      return nullptr;
+    }
+  } else {
+    T oldBack = Move(back());
+    if (!append(Move(oldBack))) { /* Dup the last element. */
+      return nullptr;
+    }
+    for (size_t i = oldLength; i > pos; --i) {
+      (*this)[i] = Move((*this)[i - 1]);
+    }
+    (*this)[pos] = Forward<U>(aVal);
+  }
+  return begin() + pos;
+}
+
+template<typename T, size_t N, class AP>
+inline void
+Vector<T, N, AP>::erase(T* aIt)
+{
+  MOZ_ASSERT(begin() <= aIt);
+  MOZ_ASSERT(aIt < end());
+  while (aIt + 1 < end()) {
+    *aIt = Move(*(aIt + 1));
+    ++aIt;
+  }
+  popBack();
+}
+
+template<typename T, size_t N, class AP>
+inline void
+Vector<T, N, AP>::erase(T* aBegin, T* aEnd)
+{
+  MOZ_ASSERT(begin() <= aBegin);
+  MOZ_ASSERT(aBegin <= aEnd);
+  MOZ_ASSERT(aEnd <= end());
+  while (aEnd < end()) {
+    *aBegin++ = Move(*aEnd++);
+  }
+  shrinkBy(aEnd - aBegin);
+}
+
+template<typename T, size_t N, class AP>
+template<typename U>
+MOZ_ALWAYS_INLINE bool
+Vector<T, N, AP>::append(const U* aInsBegin, const U* aInsEnd)
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  size_t aNeeded = PointerRangeSize(aInsBegin, aInsEnd);
+  if (mLength + aNeeded > mCapacity) {
+    if (MOZ_UNLIKELY(!growStorageBy(aNeeded))) {
+      return false;
+    }
+  } else if (mLength + aNeeded > N) {
+    if (!allocPolicy().checkSimulatedOOM())
+      return false;
+  }
+#ifdef DEBUG
+  if (mLength + aNeeded > mReserved) {
+    mReserved = mLength + aNeeded;
+  }
+#endif
+  internalAppend(aInsBegin, aNeeded);
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+template<typename U>
+MOZ_ALWAYS_INLINE void
+Vector<T, N, AP>::internalAppend(const U* aInsBegin, size_t aInsLength)
+{
+  MOZ_ASSERT(mLength + aInsLength <= mReserved);
+  MOZ_ASSERT(mReserved <= mCapacity);
+  Impl::copyConstruct(endNoCheck(), aInsBegin, aInsBegin + aInsLength);
+  mLength += aInsLength;
+}
+
+template<typename T, size_t N, class AP>
+template<typename U>
+MOZ_ALWAYS_INLINE bool
+Vector<T, N, AP>::append(U&& aU)
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  if (mLength == mCapacity) {
+    if (MOZ_UNLIKELY(!growStorageBy(1))) {
+      return false;
+    }
+  } else if (mLength + 1 > N) {
+    if (!allocPolicy().checkSimulatedOOM())
+      return false;
+  }
+#ifdef DEBUG
+  if (mLength + 1 > mReserved) {
+    mReserved = mLength + 1;
+  }
+#endif
+  internalAppend(Forward<U>(aU));
+  return true;
+}
+
+template<typename T, size_t N, class AP>
+template<typename U, size_t O, class BP>
+MOZ_ALWAYS_INLINE bool
+Vector<T, N, AP>::appendAll(const Vector<U, O, BP>& aOther)
+{
+  return append(aOther.begin(), aOther.length());
+}
+
+template<typename T, size_t N, class AP>
+template<class U>
+MOZ_ALWAYS_INLINE bool
+Vector<T, N, AP>::append(const U* aInsBegin, size_t aInsLength)
+{
+  return append(aInsBegin, aInsBegin + aInsLength);
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE void
+Vector<T, N, AP>::popBack()
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+  MOZ_ASSERT(!empty());
+  --mLength;
+  endNoCheck()->~T();
+}
+
+template<typename T, size_t N, class AP>
+MOZ_ALWAYS_INLINE T
+Vector<T, N, AP>::popCopy()
+{
+  T ret = back();
+  popBack();
+  return ret;
+}
+
+template<typename T, size_t N, class AP>
+inline T*
+Vector<T, N, AP>::extractRawBuffer()
+{
+  T* ret;
+  if (usingInlineStorage()) {
+    ret = this->template pod_malloc<T>(mLength);
+    if (!ret) {
+      return nullptr;
+    }
+    Impl::copyConstruct(ret, beginNoCheck(), endNoCheck());
+    Impl::destroy(beginNoCheck(), endNoCheck());
+    /* mBegin, mCapacity are unchanged. */
+    mLength = 0;
+  } else {
+    ret = mBegin;
+    mBegin = static_cast<T*>(mStorage.addr());
+    mLength = 0;
+    mCapacity = kInlineCapacity;
+#ifdef DEBUG
+    mReserved = 0;
+#endif
+  }
+  return ret;
+}
+
+template<typename T, size_t N, class AP>
+inline void
+Vector<T, N, AP>::replaceRawBuffer(T* aP, size_t aLength)
+{
+  MOZ_REENTRANCY_GUARD_ET_AL;
+
+  /* Destroy what we have. */
+  Impl::destroy(beginNoCheck(), endNoCheck());
+  if (!usingInlineStorage()) {
+    this->free_(beginNoCheck());
+  }
+
+  /* Take in the new buffer. */
+  if (aLength <= kInlineCapacity) {
+    /*
+     * We convert to inline storage if possible, even though aP might
+     * otherwise be acceptable.  Maybe this behaviour should be
+     * specifiable with an argument to this function.
+     */
+    mBegin = static_cast<T*>(mStorage.addr());
+    mLength = aLength;
+    mCapacity = kInlineCapacity;
+    Impl::moveConstruct(mBegin, aP, aP + aLength);
+    Impl::destroy(aP, aP + aLength);
+    this->free_(aP);
+  } else {
+    mBegin = aP;
+    mLength = aLength;
+    mCapacity = aLength;
+  }
+#ifdef DEBUG
+  mReserved = aLength;
+#endif
+}
+
+template<typename T, size_t N, class AP>
+inline size_t
+Vector<T, N, AP>::sizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  return usingInlineStorage() ? 0 : aMallocSizeOf(beginNoCheck());
+}
+
+template<typename T, size_t N, class AP>
+inline size_t
+Vector<T, N, AP>::sizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  return aMallocSizeOf(this) + sizeOfExcludingThis(aMallocSizeOf);
+}
+
+template<typename T, size_t N, class AP>
+inline void
+Vector<T, N, AP>::swap(Vector& aOther)
+{
+  static_assert(N == 0,
+                "still need to implement this for N != 0");
+
+  // This only works when inline storage is always empty.
+  if (!usingInlineStorage() && aOther.usingInlineStorage()) {
+    aOther.mBegin = mBegin;
+    mBegin = inlineStorage();
+  } else if (usingInlineStorage() && !aOther.usingInlineStorage()) {
+    mBegin = aOther.mBegin;
+    aOther.mBegin = aOther.inlineStorage();
+  } else if (!usingInlineStorage() && !aOther.usingInlineStorage()) {
+    Swap(mBegin, aOther.mBegin);
+  } else {
+    // This case is a no-op, since we'd set both to use their inline storage.
+  }
+
+  Swap(mLength, aOther.mLength);
+  Swap(mCapacity, aOther.mCapacity);
+#ifdef DEBUG
+  Swap(mReserved, aOther.mReserved);
+#endif
+}
+
+} // namespace mozilla
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+#endif /* mozilla_Vector_h */
diff --git a/src/third_party/mozjs-45/mfbt/WeakPtr.h b/src/third_party/mozjs-45/mfbt/WeakPtr.h
new file mode 100644
index 0000000..8b1ee0e
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/WeakPtr.h
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Weak pointer functionality, implemented as a mixin for use with any class. */
+
+/**
+ * SupportsWeakPtr lets you have a pointer to an object 'Foo' without affecting
+ * its lifetime. It works by creating a single shared reference counted object
+ * (WeakReference) that each WeakPtr will access 'Foo' through. This lets 'Foo'
+ * clear the pointer in the WeakReference without having to know about all of
+ * the WeakPtrs to it and allows the WeakReference to live beyond the lifetime
+ * of 'Foo'.
+ *
+ * PLEASE NOTE: This weak pointer implementation is not thread-safe.
+ *
+ * Note that when deriving from SupportsWeakPtr you should add
+ * MOZ_DECLARE_WEAKREFERENCE_TYPENAME(ClassName) to the public section of your
+ * class, where ClassName is the name of your class.
+ *
+ * The overhead of WeakPtr is that accesses to 'Foo' becomes an additional
+ * dereference, and an additional heap allocated pointer sized object shared
+ * between all of the WeakPtrs.
+ *
+ * Example of usage:
+ *
+ *   // To have a class C support weak pointers, inherit from
+ *   // SupportsWeakPtr<C>.
+ *   class C : public SupportsWeakPtr<C>
+ *   {
+ *   public:
+ *     MOZ_DECLARE_WEAKREFERENCE_TYPENAME(C)
+ *     int mNum;
+ *     void act();
+ *   };
+ *
+ *   C* ptr = new C();
+ *
+ *   // Get weak pointers to ptr. The first time a weak pointer
+ *   // is obtained, a reference counted WeakReference object is created that
+ *   // can live beyond the lifetime of 'ptr'. The WeakReference
+ *   // object will be notified of 'ptr's destruction.
+ *   WeakPtr<C> weak = ptr;
+ *   WeakPtr<C> other = ptr;
+ *
+ *   // Test a weak pointer for validity before using it.
+ *   if (weak) {
+ *     weak->mNum = 17;
+ *     weak->act();
+ *   }
+ *
+ *   // Destroying the underlying object clears weak pointers to it.
+ *   delete ptr;
+ *
+ *   MOZ_ASSERT(!weak, "Deleting |ptr| clears weak pointers to it.");
+ *   MOZ_ASSERT(!other, "Deleting |ptr| clears all weak pointers to it.");
+ *
+ * WeakPtr is typesafe and may be used with any class. It is not required that
+ * the class be reference-counted or allocated in any particular way.
+ *
+ * The API was loosely inspired by Chromium's weak_ptr.h:
+ * http://src.chromium.org/svn/trunk/src/base/memory/weak_ptr.h
+ */
+
+#ifndef mozilla_WeakPtr_h
+#define mozilla_WeakPtr_h
+
+#include "mozilla/ArrayUtils.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/RefCounted.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/TypeTraits.h"
+
+#include <string.h>
+
+namespace mozilla {
+
+template <typename T> class WeakPtr;
+template <typename T> class SupportsWeakPtr;
+
+#ifdef MOZ_REFCOUNTED_LEAK_CHECKING
+#define MOZ_DECLARE_WEAKREFERENCE_TYPENAME(T) \
+  static const char* weakReferenceTypeName() { return "WeakReference<" #T ">"; }
+#else
+#define MOZ_DECLARE_WEAKREFERENCE_TYPENAME(T)
+#endif
+
+namespace detail {
+
+// This can live beyond the lifetime of the class derived from
+// SupportsWeakPtr.
+template<class T>
+class WeakReference : public ::mozilla::RefCounted<WeakReference<T> >
+{
+public:
+  explicit WeakReference(T* p) : mPtr(p) {}
+
+  T* get() const { return mPtr; }
+
+#ifdef MOZ_REFCOUNTED_LEAK_CHECKING
+  const char* typeName() const
+  {
+    // The first time this is called mPtr is null, so don't
+    // invoke any methods on mPtr.
+    return T::weakReferenceTypeName();
+  }
+  size_t typeSize() const { return sizeof(*this); }
+#endif
+
+private:
+  friend class mozilla::SupportsWeakPtr<T>;
+
+  void detach() { mPtr = nullptr; }
+
+  T* MOZ_NON_OWNING_REF mPtr;
+};
+
+} // namespace detail
+
+template <typename T>
+class SupportsWeakPtr
+{
+protected:
+  ~SupportsWeakPtr()
+  {
+    static_assert(IsBaseOf<SupportsWeakPtr<T>, T>::value,
+                  "T must derive from SupportsWeakPtr<T>");
+    if (mSelfReferencingWeakPtr) {
+      mSelfReferencingWeakPtr.mRef->detach();
+    }
+  }
+
+private:
+  const WeakPtr<T>& SelfReferencingWeakPtr()
+  {
+    if (!mSelfReferencingWeakPtr) {
+      mSelfReferencingWeakPtr.mRef = new detail::WeakReference<T>(static_cast<T*>(this));
+    }
+    return mSelfReferencingWeakPtr;
+  }
+
+  const WeakPtr<const T>& SelfReferencingWeakPtr() const
+  {
+    const WeakPtr<T>& p = const_cast<SupportsWeakPtr*>(this)->SelfReferencingWeakPtr();
+    return reinterpret_cast<const WeakPtr<const T>&>(p);
+  }
+
+  friend class WeakPtr<T>;
+  friend class WeakPtr<const T>;
+
+  WeakPtr<T> mSelfReferencingWeakPtr;
+};
+
+template <typename T>
+class WeakPtr
+{
+  typedef detail::WeakReference<T> WeakReference;
+
+public:
+  WeakPtr& operator=(const WeakPtr& aOther)
+  {
+    mRef = aOther.mRef;
+    return *this;
+  }
+
+  WeakPtr(const WeakPtr& aOther)
+  {
+    *this = aOther;
+  }
+
+  WeakPtr& operator=(T* aOther)
+  {
+    if (aOther) {
+      *this = aOther->SelfReferencingWeakPtr();
+    } else if (!mRef || mRef->get()) {
+      // Ensure that mRef is dereferenceable in the uninitialized state.
+      mRef = new WeakReference(nullptr);
+    }
+    return *this;
+  }
+
+  MOZ_IMPLICIT WeakPtr(T* aOther)
+  {
+    *this = aOther;
+  }
+
+  // Ensure that mRef is dereferenceable in the uninitialized state.
+  WeakPtr() : mRef(new WeakReference(nullptr)) {}
+
+  operator T*() const { return mRef->get(); }
+  T& operator*() const { return *mRef->get(); }
+
+  T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mRef->get(); }
+
+  T* get() const { return mRef->get(); }
+
+private:
+  friend class SupportsWeakPtr<T>;
+
+  explicit WeakPtr(const RefPtr<WeakReference>& aOther) : mRef(aOther) {}
+
+  RefPtr<WeakReference> mRef;
+};
+
+} // namespace mozilla
+
+#endif /* mozilla_WeakPtr_h */
diff --git a/src/third_party/mozjs-45/mfbt/WindowsVersion.h b/src/third_party/mozjs-45/mfbt/WindowsVersion.h
new file mode 100644
index 0000000..72eda2c
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/WindowsVersion.h
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_WindowsVersion_h
+#define mozilla_WindowsVersion_h
+
+#include "mozilla/Attributes.h"
+#include <stdint.h>
+#include <windows.h>
+
+namespace mozilla {
+
+inline bool
+IsWindowsVersionOrLater(uint32_t aVersion)
+{
+  static uint32_t minVersion = 0;
+  static uint32_t maxVersion = UINT32_MAX;
+
+  if (minVersion >= aVersion) {
+    return true;
+  }
+
+  if (aVersion >= maxVersion) {
+    return false;
+  }
+
+  OSVERSIONINFOEX info;
+  ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
+  info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+  info.dwMajorVersion = aVersion >> 24;
+  info.dwMinorVersion = (aVersion >> 16) & 0xFF;
+  info.wServicePackMajor = (aVersion >> 8) & 0xFF;
+  info.wServicePackMinor = aVersion & 0xFF;
+
+  DWORDLONG conditionMask = 0;
+  VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
+  VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
+  VER_SET_CONDITION(conditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
+  VER_SET_CONDITION(conditionMask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
+
+  if (VerifyVersionInfo(&info,
+                        VER_MAJORVERSION | VER_MINORVERSION |
+                        VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
+                        conditionMask)) {
+    minVersion = aVersion;
+    return true;
+  }
+
+  maxVersion = aVersion;
+  return false;
+}
+
+inline bool
+IsWindowsBuildOrLater(uint32_t aBuild)
+{
+  static uint32_t minBuild = 0;
+  static uint32_t maxBuild = UINT32_MAX;
+
+  if (minBuild >= aBuild) {
+    return true;
+  }
+
+  if (aBuild >= maxBuild) {
+    return false;
+  }
+
+  OSVERSIONINFOEX info;
+  ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
+  info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+  info.dwBuildNumber = aBuild;
+
+  DWORDLONG conditionMask = 0;
+  VER_SET_CONDITION(conditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
+
+  if (VerifyVersionInfo(&info, VER_BUILDNUMBER, conditionMask)) {
+    minBuild = aBuild;
+    return true;
+  }
+
+  maxBuild = aBuild;
+  return false;
+}
+
+#if defined(_M_X64) || defined(_M_AMD64)
+// We support only Win7 or later on Win64.
+MOZ_ALWAYS_INLINE bool
+IsXPSP3OrLater()
+{
+  return true;
+}
+
+MOZ_ALWAYS_INLINE bool
+IsWin2003OrLater()
+{
+  return true;
+}
+
+MOZ_ALWAYS_INLINE bool
+IsWin2003SP2OrLater()
+{
+  return true;
+}
+
+MOZ_ALWAYS_INLINE bool
+IsVistaOrLater()
+{
+  return true;
+}
+
+MOZ_ALWAYS_INLINE bool
+IsVistaSP1OrLater()
+{
+  return true;
+}
+
+MOZ_ALWAYS_INLINE bool
+IsWin7OrLater()
+{
+  return true;
+}
+#else
+MOZ_ALWAYS_INLINE bool
+IsXPSP3OrLater()
+{
+  return IsWindowsVersionOrLater(0x05010300ul);
+}
+
+MOZ_ALWAYS_INLINE bool
+IsWin2003OrLater()
+{
+  return IsWindowsVersionOrLater(0x05020000ul);
+}
+
+MOZ_ALWAYS_INLINE bool
+IsWin2003SP2OrLater()
+{
+  return IsWindowsVersionOrLater(0x05020200ul);
+}
+
+MOZ_ALWAYS_INLINE bool
+IsVistaOrLater()
+{
+  return IsWindowsVersionOrLater(0x06000000ul);
+}
+
+MOZ_ALWAYS_INLINE bool
+IsVistaSP1OrLater()
+{
+  return IsWindowsVersionOrLater(0x06000100ul);
+}
+
+MOZ_ALWAYS_INLINE bool
+IsWin7OrLater()
+{
+  return IsWindowsVersionOrLater(0x06010000ul);
+}
+#endif
+
+MOZ_ALWAYS_INLINE bool
+IsWin7SP1OrLater()
+{
+  return IsWindowsVersionOrLater(0x06010100ul);
+}
+
+MOZ_ALWAYS_INLINE bool
+IsWin8OrLater()
+{
+  return IsWindowsVersionOrLater(0x06020000ul);
+}
+
+MOZ_ALWAYS_INLINE bool
+IsWin10OrLater()
+{
+  return IsWindowsVersionOrLater(0x0a000000ul);
+}
+
+MOZ_ALWAYS_INLINE bool
+IsNotWin7PreRTM()
+{
+  return IsWin7SP1OrLater() || !IsWin7OrLater() ||
+         IsWindowsBuildOrLater(7600);
+}
+
+} // namespace mozilla
+
+#endif /* mozilla_WindowsVersion_h */
diff --git a/src/third_party/mozjs-45/mfbt/XorShift128PlusRNG.h b/src/third_party/mozjs-45/mfbt/XorShift128PlusRNG.h
new file mode 100644
index 0000000..d38fe11
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/XorShift128PlusRNG.h
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* The xorshift128+ pseudo-random number generator. */
+
+#ifndef mozilla_XorShift128Plus_h
+#define mozilla_XorShift128Plus_h
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/FloatingPoint.h"
+
+#include <inttypes.h>
+
+namespace mozilla {
+namespace non_crypto {
+
+/*
+ * A stream of pseudo-random numbers generated using the xorshift+ technique
+ * described here:
+ *
+ * Vigna, Sebastiano (2014). "Further scramblings of Marsaglia's xorshift
+ * generators". arXiv:1404.0390 (http://arxiv.org/abs/1404.0390)
+ *
+ * That paper says:
+ *
+ *     In particular, we propose a tightly coded xorshift128+ generator that
+ *     does not fail systematically any test from the BigCrush suite of TestU01
+ *     (even reversed) and generates 64 pseudorandom bits in 1.10 ns on an
+ *     Intel(R) Core(TM) i7-4770 CPU @3.40GHz (Haswell). It is the fastest
+ *     generator we are aware of with such empirical statistical properties.
+ *
+ * This generator is not suitable as a cryptographically secure random number
+ * generator.
+ */
+class XorShift128PlusRNG {
+  uint64_t mState[2];
+
+ public:
+  /*
+   * Construct a xorshift128+ pseudo-random number stream using |aInitial0| and
+   * |aInitial1| as the initial state. These may not both be zero; ideally, they
+   * should have an almost even mix of zero and one bits.
+   */
+  XorShift128PlusRNG(uint64_t aInitial0, uint64_t aInitial1) {
+    setState(aInitial0, aInitial1);
+  }
+
+  /* Return a pseudo-random 64-bit number. */
+  uint64_t next() {
+    /*
+     * The offsetOfState*() methods below are provided so that exceedingly-rare
+     * callers that want to observe or poke at RNG state in C++ type-system-
+     * ignoring means can do so. Don't change the next() or nextDouble()
+     * algorithms without altering code that uses offsetOfState*()!
+     */
+    uint64_t s1 = mState[0];
+    const uint64_t s0 = mState[1];
+    mState[0] = s0;
+    s1 ^= s1 << 23;
+    mState[1] = s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26);
+    return mState[1] + s0;
+  }
+
+  /*
+   * Return a pseudo-random floating-point value in the range [0, 1).
+   * More precisely, choose an integer in the range [0, 2**53) and
+   * divide it by 2**53.
+   */
+  double nextDouble() {
+    /*
+     * Because the IEEE 64-bit floating point format stores the leading '1' bit
+     * of the mantissa implicitly, it effectively represents a mantissa in the
+     * range [0, 2**53) in only 52 bits. FloatingPoint<double>::kExponentShift
+     * is the width of the bitfield in the in-memory format, so we must add one
+     * to get the mantissa's range.
+     */
+    static MOZ_CONSTEXPR_VAR int kMantissaBits =
+      mozilla::FloatingPoint<double>::kExponentShift + 1;
+    uint64_t mantissa = next() & ((UINT64_C(1) << kMantissaBits) - 1);
+    return double(mantissa) / (UINT64_C(1) << kMantissaBits);
+  }
+
+  /*
+   * Set the stream's current state to |aState0| and |aState1|. These must not
+   * both be zero; ideally, they should have an almost even mix of zero and one
+   * bits.
+   */
+  void setState(uint64_t aState0, uint64_t aState1) {
+    MOZ_ASSERT(aState0 || aState1);
+    mState[0] = aState0;
+    mState[1] = aState1;
+  }
+
+  static size_t offsetOfState0() {
+    return offsetof(XorShift128PlusRNG, mState[0]);
+  }
+  static size_t offsetOfState1() {
+    return offsetof(XorShift128PlusRNG, mState[1]);
+  }
+};
+
+} // namespace non_crypto
+} // namespace mozilla
+
+#endif // mozilla_XorShift128Plus_h
diff --git a/src/third_party/mozjs-45/mfbt/decimal/Decimal.cpp b/src/third_party/mozjs-45/mfbt/decimal/Decimal.cpp
new file mode 100644
index 0000000..bf0b7db
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/Decimal.cpp
@@ -0,0 +1,1056 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "Decimal.h"
+#include "moz-decimal-utils.h"
+
+#include <algorithm>
+#include <float.h>
+
+using namespace moz_decimal_utils;
+
+namespace WebCore {
+
+namespace DecimalPrivate {
+
+static int const ExponentMax = 1023;
+static int const ExponentMin = -1023;
+static int const Precision = 18;
+
+static const uint64_t MaxCoefficient = UINT64_C(0x16345785D89FFFF); // 999999999999999999 == 18 9's
+
+// This class handles Decimal special values.
+class SpecialValueHandler {
+    WTF_MAKE_NONCOPYABLE(SpecialValueHandler);
+public:
+    enum HandleResult {
+        BothFinite,
+        BothInfinity,
+        EitherNaN,
+        LHSIsInfinity,
+        RHSIsInfinity,
+    };
+
+    SpecialValueHandler(const Decimal& lhs, const Decimal& rhs);
+    HandleResult handle();
+    Decimal value() const;
+
+private:
+    enum Result {
+        ResultIsLHS,
+        ResultIsRHS,
+        ResultIsUnknown,
+    };
+
+    const Decimal& m_lhs;
+    const Decimal& m_rhs;
+    Result m_result;
+};
+
+SpecialValueHandler::SpecialValueHandler(const Decimal& lhs, const Decimal& rhs)
+    : m_lhs(lhs), m_rhs(rhs), m_result(ResultIsUnknown)
+{
+}
+
+SpecialValueHandler::HandleResult SpecialValueHandler::handle()
+{
+    if (m_lhs.isFinite() && m_rhs.isFinite())
+        return BothFinite;
+
+    const Decimal::EncodedData::FormatClass lhsClass = m_lhs.value().formatClass();
+    const Decimal::EncodedData::FormatClass rhsClass = m_rhs.value().formatClass();
+    if (lhsClass == Decimal::EncodedData::ClassNaN) {
+        m_result = ResultIsLHS;
+        return EitherNaN;
+     }
+
+    if (rhsClass == Decimal::EncodedData::ClassNaN) {
+        m_result = ResultIsRHS;
+        return EitherNaN;
+     }
+
+    if (lhsClass == Decimal::EncodedData::ClassInfinity)
+        return rhsClass == Decimal::EncodedData::ClassInfinity ? BothInfinity : LHSIsInfinity;
+
+    if (rhsClass == Decimal::EncodedData::ClassInfinity)
+        return RHSIsInfinity;
+
+    ASSERT_NOT_REACHED();
+    return BothFinite;
+}
+
+Decimal SpecialValueHandler::value() const
+{
+    switch (m_result) {
+    case ResultIsLHS:
+        return m_lhs;
+    case ResultIsRHS:
+        return m_rhs;
+    case ResultIsUnknown:
+    default:
+        ASSERT_NOT_REACHED();
+        return m_lhs;
+    }
+}
+
+// This class is used for 128 bit unsigned integer arithmetic.
+class UInt128 {
+public:
+    UInt128(uint64_t aLow, uint64_t aHigh)
+        : m_high(aHigh), m_low(aLow)
+    {
+    }
+
+    UInt128& operator/=(uint32_t);
+
+    uint64_t high() const { return m_high; }
+    uint64_t low() const { return m_low; }
+
+    static UInt128 multiply(uint64_t u, uint64_t v) { return UInt128(u * v, multiplyHigh(u, v)); }
+
+private:
+    static uint32_t highUInt32(uint64_t x) { return static_cast<uint32_t>(x >> 32); }
+    static uint32_t lowUInt32(uint64_t x) { return static_cast<uint32_t>(x & ((static_cast<uint64_t>(1) << 32) - 1)); }
+    bool isZero() const { return !m_low && !m_high; }
+    static uint64_t makeUInt64(uint32_t low, uint32_t high) { return low | (static_cast<uint64_t>(high) << 32); }
+
+    static uint64_t multiplyHigh(uint64_t, uint64_t);
+
+    uint64_t m_high;
+    uint64_t m_low;
+};
+
+UInt128& UInt128::operator/=(const uint32_t divisor)
+{
+    ASSERT(divisor);
+
+    if (!m_high) {
+        m_low /= divisor;
+        return *this;
+    }
+
+    uint32_t dividend[4];
+    dividend[0] = lowUInt32(m_low);
+    dividend[1] = highUInt32(m_low);
+    dividend[2] = lowUInt32(m_high);
+    dividend[3] = highUInt32(m_high);
+
+    uint32_t quotient[4];
+    uint32_t remainder = 0;
+    for (int i = 3; i >= 0; --i) {
+        const uint64_t work = makeUInt64(dividend[i], remainder);
+        remainder = static_cast<uint32_t>(work % divisor);
+        quotient[i] = static_cast<uint32_t>(work / divisor);
+    }
+    m_low = makeUInt64(quotient[0], quotient[1]);
+    m_high = makeUInt64(quotient[2], quotient[3]);
+    return *this;
+}
+
+// Returns high 64bit of 128bit product.
+uint64_t UInt128::multiplyHigh(uint64_t u, uint64_t v)
+{
+    const uint64_t uLow = lowUInt32(u);
+    const uint64_t uHigh = highUInt32(u);
+    const uint64_t vLow = lowUInt32(v);
+    const uint64_t vHigh = highUInt32(v);
+    const uint64_t partialProduct = uHigh * vLow + highUInt32(uLow * vLow);
+    return uHigh * vHigh + highUInt32(partialProduct) + highUInt32(uLow * vHigh + lowUInt32(partialProduct));
+}
+
+static int countDigits(uint64_t x)
+{
+    int numberOfDigits = 0;
+    for (uint64_t powerOfTen = 1; x >= powerOfTen; powerOfTen *= 10) {
+        ++numberOfDigits;
+        if (powerOfTen >= std::numeric_limits<uint64_t>::max() / 10)
+            break;
+    }
+    return numberOfDigits;
+}
+
+static uint64_t scaleDown(uint64_t x, int n)
+{
+    ASSERT(n >= 0);
+    while (n > 0 && x) {
+        x /= 10;
+        --n;
+    }
+    return x;
+}
+
+static uint64_t scaleUp(uint64_t x, int n)
+{
+    ASSERT(n >= 0);
+    ASSERT(n < Precision);
+
+    uint64_t y = 1;
+    uint64_t z = 10;
+    for (;;) {
+        if (n & 1)
+            y = y * z;
+
+        n >>= 1;
+        if (!n)
+            return x * y;
+
+        z = z * z;
+    }
+}
+
+} // namespace DecimalPrivate
+
+using namespace DecimalPrivate;
+
+Decimal::EncodedData::EncodedData(Sign aSign, FormatClass aFormatClass)
+    : m_coefficient(0)
+    , m_exponent(0)
+    , m_formatClass(aFormatClass)
+    , m_sign(aSign)
+{
+}
+
+Decimal::EncodedData::EncodedData(Sign aSign, int aExponent, uint64_t aCoefficient)
+    : m_formatClass(aCoefficient ? ClassNormal : ClassZero)
+    , m_sign(aSign)
+{
+    if (aExponent >= ExponentMin && aExponent <= ExponentMax) {
+        while (aCoefficient > MaxCoefficient) {
+            aCoefficient /= 10;
+            ++aExponent;
+        }
+    }
+
+    if (aExponent > ExponentMax) {
+        m_coefficient = 0;
+        m_exponent = 0;
+        m_formatClass = ClassInfinity;
+        return;
+    }
+
+    if (aExponent < ExponentMin) {
+        m_coefficient = 0;
+        m_exponent = 0;
+        m_formatClass = ClassZero;
+        return;
+    }
+
+    m_coefficient = aCoefficient;
+    m_exponent = static_cast<int16_t>(aExponent);
+}
+
+bool Decimal::EncodedData::operator==(const EncodedData& another) const
+{
+    return m_sign == another.m_sign
+        && m_formatClass == another.m_formatClass
+        && m_exponent == another.m_exponent
+        && m_coefficient == another.m_coefficient;
+}
+
+Decimal::Decimal(int32_t i32)
+    : m_data(i32 < 0 ? Negative : Positive, 0, i32 < 0 ? static_cast<uint64_t>(-static_cast<int64_t>(i32)) : static_cast<uint64_t>(i32))
+{
+}
+
+Decimal::Decimal(Sign aSign, int aExponent, uint64_t aCoefficient)
+    : m_data(aSign, aCoefficient ? aExponent : 0, aCoefficient)
+{
+}
+
+Decimal::Decimal(const EncodedData& data)
+    : m_data(data)
+{
+}
+
+Decimal::Decimal(const Decimal& other)
+    : m_data(other.m_data)
+{
+}
+
+Decimal& Decimal::operator=(const Decimal& other)
+{
+    m_data = other.m_data;
+    return *this;
+}
+
+Decimal& Decimal::operator+=(const Decimal& other)
+{
+    m_data = (*this + other).m_data;
+    return *this;
+}
+
+Decimal& Decimal::operator-=(const Decimal& other)
+{
+    m_data = (*this - other).m_data;
+    return *this;
+}
+
+Decimal& Decimal::operator*=(const Decimal& other)
+{
+    m_data = (*this * other).m_data;
+    return *this;
+}
+
+Decimal& Decimal::operator/=(const Decimal& other)
+{
+    m_data = (*this / other).m_data;
+    return *this;
+}
+
+Decimal Decimal::operator-() const
+{
+    if (isNaN())
+        return *this;
+
+    Decimal result(*this);
+    result.m_data.setSign(invertSign(m_data.sign()));
+    return result;
+}
+
+Decimal Decimal::operator+(const Decimal& rhs) const
+{
+    const Decimal& lhs = *this;
+    const Sign lhsSign = lhs.sign();
+    const Sign rhsSign = rhs.sign();
+
+    SpecialValueHandler handler(lhs, rhs);
+    switch (handler.handle()) {
+    case SpecialValueHandler::BothFinite:
+        break;
+
+    case SpecialValueHandler::BothInfinity:
+        return lhsSign == rhsSign ? lhs : nan();
+
+    case SpecialValueHandler::EitherNaN:
+        return handler.value();
+
+    case SpecialValueHandler::LHSIsInfinity:
+        return lhs;
+
+    case SpecialValueHandler::RHSIsInfinity:
+        return rhs;
+    }
+
+    const AlignedOperands alignedOperands = alignOperands(lhs, rhs);
+
+    const uint64_t result = lhsSign == rhsSign
+        ? alignedOperands.lhsCoefficient + alignedOperands.rhsCoefficient
+        : alignedOperands.lhsCoefficient - alignedOperands.rhsCoefficient;
+
+    if (lhsSign == Negative && rhsSign == Positive && !result)
+        return Decimal(Positive, alignedOperands.exponent, 0);
+
+    return static_cast<int64_t>(result) >= 0
+        ? Decimal(lhsSign, alignedOperands.exponent, result)
+        : Decimal(invertSign(lhsSign), alignedOperands.exponent, -static_cast<int64_t>(result));
+}
+
+Decimal Decimal::operator-(const Decimal& rhs) const
+{
+    const Decimal& lhs = *this;
+    const Sign lhsSign = lhs.sign();
+    const Sign rhsSign = rhs.sign();
+
+    SpecialValueHandler handler(lhs, rhs);
+    switch (handler.handle()) {
+    case SpecialValueHandler::BothFinite:
+        break;
+
+    case SpecialValueHandler::BothInfinity:
+        return lhsSign == rhsSign ? nan() : lhs;
+
+    case SpecialValueHandler::EitherNaN:
+        return handler.value();
+
+    case SpecialValueHandler::LHSIsInfinity:
+        return lhs;
+
+    case SpecialValueHandler::RHSIsInfinity:
+        return infinity(invertSign(rhsSign));
+    }
+
+    const AlignedOperands alignedOperands = alignOperands(lhs, rhs);
+
+    const uint64_t result = lhsSign == rhsSign
+        ? alignedOperands.lhsCoefficient - alignedOperands.rhsCoefficient
+        : alignedOperands.lhsCoefficient + alignedOperands.rhsCoefficient;
+
+    if (lhsSign == Negative && rhsSign == Negative && !result)
+        return Decimal(Positive, alignedOperands.exponent, 0);
+
+    return static_cast<int64_t>(result) >= 0
+        ? Decimal(lhsSign, alignedOperands.exponent, result)
+        : Decimal(invertSign(lhsSign), alignedOperands.exponent, -static_cast<int64_t>(result));
+}
+
+Decimal Decimal::operator*(const Decimal& rhs) const
+{
+    const Decimal& lhs = *this;
+    const Sign lhsSign = lhs.sign();
+    const Sign rhsSign = rhs.sign();
+    const Sign resultSign = lhsSign == rhsSign ? Positive : Negative;
+
+    SpecialValueHandler handler(lhs, rhs);
+    switch (handler.handle()) {
+    case SpecialValueHandler::BothFinite: {
+        const uint64_t lhsCoefficient = lhs.m_data.coefficient();
+        const uint64_t rhsCoefficient = rhs.m_data.coefficient();
+        int resultExponent = lhs.exponent() + rhs.exponent();
+        UInt128 work(UInt128::multiply(lhsCoefficient, rhsCoefficient));
+        while (work.high()) {
+            work /= 10;
+            ++resultExponent;
+        }
+        return Decimal(resultSign, resultExponent, work.low());
+    }
+
+    case SpecialValueHandler::BothInfinity:
+        return infinity(resultSign);
+
+    case SpecialValueHandler::EitherNaN:
+        return handler.value();
+
+    case SpecialValueHandler::LHSIsInfinity:
+        return rhs.isZero() ? nan() : infinity(resultSign);
+
+    case SpecialValueHandler::RHSIsInfinity:
+        return lhs.isZero() ? nan() : infinity(resultSign);
+    }
+
+    ASSERT_NOT_REACHED();
+    return nan();
+}
+
+Decimal Decimal::operator/(const Decimal& rhs) const
+{
+    const Decimal& lhs = *this;
+    const Sign lhsSign = lhs.sign();
+    const Sign rhsSign = rhs.sign();
+    const Sign resultSign = lhsSign == rhsSign ? Positive : Negative;
+
+    SpecialValueHandler handler(lhs, rhs);
+    switch (handler.handle()) {
+    case SpecialValueHandler::BothFinite:
+        break;
+
+    case SpecialValueHandler::BothInfinity:
+        return nan();
+
+    case SpecialValueHandler::EitherNaN:
+        return handler.value();
+
+    case SpecialValueHandler::LHSIsInfinity:
+        return infinity(resultSign);
+
+    case SpecialValueHandler::RHSIsInfinity:
+        return zero(resultSign);
+    }
+
+    ASSERT(lhs.isFinite());
+    ASSERT(rhs.isFinite());
+
+    if (rhs.isZero())
+        return lhs.isZero() ? nan() : infinity(resultSign);
+
+    int resultExponent = lhs.exponent() - rhs.exponent();
+
+    if (lhs.isZero())
+        return Decimal(resultSign, resultExponent, 0);
+
+    uint64_t lhsRemainder = lhs.m_data.coefficient();
+    const uint64_t divisor = rhs.m_data.coefficient();
+    uint64_t result = 0;
+    while (result < MaxCoefficient / 100) {
+        while (lhsRemainder < divisor) {
+            lhsRemainder *= 10;
+            result *= 10;
+            --resultExponent;
+        }
+        result += lhsRemainder / divisor;
+        lhsRemainder %= divisor;
+        if (!lhsRemainder)
+            break;
+    }
+
+    if (lhsRemainder > divisor / 2)
+        ++result;
+
+    return Decimal(resultSign, resultExponent, result);
+}
+
+bool Decimal::operator==(const Decimal& rhs) const
+{
+    if (isNaN() || rhs.isNaN())
+        return false;
+    return m_data == rhs.m_data || compareTo(rhs).isZero();
+}
+
+bool Decimal::operator!=(const Decimal& rhs) const
+{
+    if (isNaN() || rhs.isNaN())
+        return true;
+    if (m_data == rhs.m_data)
+        return false;
+    const Decimal result = compareTo(rhs);
+    if (result.isNaN())
+        return false;
+    return !result.isZero();
+}
+
+bool Decimal::operator<(const Decimal& rhs) const
+{
+    const Decimal result = compareTo(rhs);
+    if (result.isNaN())
+        return false;
+    return !result.isZero() && result.isNegative();
+}
+
+bool Decimal::operator<=(const Decimal& rhs) const
+{
+    if (isNaN() || rhs.isNaN())
+        return false;
+    if (m_data == rhs.m_data)
+        return true;
+    const Decimal result = compareTo(rhs);
+    if (result.isNaN())
+        return false;
+    return result.isZero() || result.isNegative();
+}
+
+bool Decimal::operator>(const Decimal& rhs) const
+{
+    const Decimal result = compareTo(rhs);
+    if (result.isNaN())
+        return false;
+    return !result.isZero() && result.isPositive();
+}
+
+bool Decimal::operator>=(const Decimal& rhs) const
+{
+    if (isNaN() || rhs.isNaN())
+        return false;
+    if (m_data == rhs.m_data)
+        return true;
+    const Decimal result = compareTo(rhs);
+    if (result.isNaN())
+        return false;
+    return result.isZero() || !result.isNegative();
+}
+
+Decimal Decimal::abs() const
+{
+    Decimal result(*this);
+    result.m_data.setSign(Positive);
+    return result;
+}
+
+Decimal::AlignedOperands Decimal::alignOperands(const Decimal& lhs, const Decimal& rhs)
+{
+    ASSERT(lhs.isFinite());
+    ASSERT(rhs.isFinite());
+
+    const int lhsExponent = lhs.exponent();
+    const int rhsExponent = rhs.exponent();
+    int exponent = std::min(lhsExponent, rhsExponent);
+    uint64_t lhsCoefficient = lhs.m_data.coefficient();
+    uint64_t rhsCoefficient = rhs.m_data.coefficient();
+
+    if (lhsExponent > rhsExponent) {
+        const int numberOfLHSDigits = countDigits(lhsCoefficient);
+        if (numberOfLHSDigits) {
+            const int lhsShiftAmount = lhsExponent - rhsExponent;
+            const int overflow = numberOfLHSDigits + lhsShiftAmount - Precision;
+            if (overflow <= 0)
+                lhsCoefficient = scaleUp(lhsCoefficient, lhsShiftAmount);
+            else {
+                lhsCoefficient = scaleUp(lhsCoefficient, lhsShiftAmount - overflow);
+                rhsCoefficient = scaleDown(rhsCoefficient, overflow);
+                exponent += overflow;
+            }
+        }
+
+    } else if (lhsExponent < rhsExponent) {
+        const int numberOfRHSDigits = countDigits(rhsCoefficient);
+        if (numberOfRHSDigits) {
+            const int rhsShiftAmount = rhsExponent - lhsExponent;
+            const int overflow = numberOfRHSDigits + rhsShiftAmount - Precision;
+            if (overflow <= 0)
+                rhsCoefficient = scaleUp(rhsCoefficient, rhsShiftAmount);
+            else {
+                rhsCoefficient = scaleUp(rhsCoefficient, rhsShiftAmount - overflow);
+                lhsCoefficient = scaleDown(lhsCoefficient, overflow);
+                exponent += overflow;
+            }
+        }
+    }
+
+    AlignedOperands alignedOperands;
+    alignedOperands.exponent = exponent;
+    alignedOperands.lhsCoefficient = lhsCoefficient;
+    alignedOperands.rhsCoefficient = rhsCoefficient;
+    return alignedOperands;
+}
+
+// Round toward positive infinity.
+// Note: Mac ports defines ceil(x) as wtf_ceil(x), so we can't use name "ceil" here.
+Decimal Decimal::ceiling() const
+{
+    if (isSpecial())
+        return *this;
+
+    if (exponent() >= 0)
+        return *this;
+
+    uint64_t coefficient = m_data.coefficient();
+    const int numberOfDigits = countDigits(coefficient);
+    const int numberOfDropDigits = -exponent();
+    if (numberOfDigits < numberOfDropDigits)
+        return isPositive() ? Decimal(1) : zero(Positive);
+
+    uint64_t result = scaleDown(coefficient, numberOfDropDigits);
+    uint64_t droppedDigits = coefficient - scaleUp(result, numberOfDropDigits);
+    if (droppedDigits && isPositive())
+        result += 1;
+    return Decimal(sign(), 0, result);
+}
+
+Decimal Decimal::compareTo(const Decimal& rhs) const
+{
+    const Decimal result(*this - rhs);
+    switch (result.m_data.formatClass()) {
+    case EncodedData::ClassInfinity:
+        return result.isNegative() ? Decimal(-1) : Decimal(1);
+
+    case EncodedData::ClassNaN:
+    case EncodedData::ClassNormal:
+        return result;
+
+    case EncodedData::ClassZero:
+        return zero(Positive);
+
+    default:
+        ASSERT_NOT_REACHED();
+        return nan();
+    }
+}
+
+// Round toward negative infinity.
+Decimal Decimal::floor() const
+{
+    if (isSpecial())
+        return *this;
+
+    if (exponent() >= 0)
+        return *this;
+
+    uint64_t coefficient = m_data.coefficient();
+    const int numberOfDigits = countDigits(coefficient);
+    const int numberOfDropDigits = -exponent();
+    if (numberOfDigits < numberOfDropDigits)
+        return isPositive() ? zero(Positive) : Decimal(-1);
+
+    uint64_t result = scaleDown(coefficient, numberOfDropDigits);
+    uint64_t droppedDigits = coefficient - scaleUp(result, numberOfDropDigits);
+    if (droppedDigits && isNegative()) {
+        result += 1;
+    }
+    return Decimal(sign(), 0, result);
+}
+
+Decimal Decimal::fromDouble(double doubleValue)
+{
+    if (std::isfinite(doubleValue))
+        return fromString(mozToString(doubleValue));
+
+    if (std::isinf(doubleValue))
+        return infinity(doubleValue < 0 ? Negative : Positive);
+
+    return nan();
+}
+
+Decimal Decimal::fromString(const String& str)
+{
+    int exponent = 0;
+    Sign exponentSign = Positive;
+    int numberOfDigits = 0;
+    int numberOfDigitsAfterDot = 0;
+    int numberOfExtraDigits = 0;
+    Sign sign = Positive;
+
+    enum {
+        StateDigit,
+        StateDot,
+        StateDotDigit,
+        StateE,
+        StateEDigit,
+        StateESign,
+        StateSign,
+        StateStart,
+        StateZero,
+    } state = StateStart;
+
+#define HandleCharAndBreak(expected, nextState) \
+    if (ch == expected) { \
+        state = nextState; \
+        break; \
+    }
+
+#define HandleTwoCharsAndBreak(expected1, expected2, nextState) \
+    if (ch == expected1 || ch == expected2) { \
+        state = nextState; \
+        break; \
+    }
+
+    uint64_t accumulator = 0;
+    for (unsigned index = 0; index < str.length(); ++index) {
+        const int ch = str[index];
+        switch (state) {
+        case StateDigit:
+            if (ch >= '0' && ch <= '9') {
+                if (numberOfDigits < Precision) {
+                    ++numberOfDigits;
+                    accumulator *= 10;
+                    accumulator += ch - '0';
+                } else
+                    ++numberOfExtraDigits;
+                break;
+            }
+
+            HandleCharAndBreak('.', StateDot);
+            HandleTwoCharsAndBreak('E', 'e', StateE);
+            return nan();
+
+        case StateDot:
+            if (ch >= '0' && ch <= '9') {
+                if (numberOfDigits < Precision) {
+                    ++numberOfDigits;
+                    ++numberOfDigitsAfterDot;
+                    accumulator *= 10;
+                    accumulator += ch - '0';
+                }
+                state = StateDotDigit;
+                break;
+            }
+
+        case StateDotDigit:
+            if (ch >= '0' && ch <= '9') {
+                if (numberOfDigits < Precision) {
+                    ++numberOfDigits;
+                    ++numberOfDigitsAfterDot;
+                    accumulator *= 10;
+                    accumulator += ch - '0';
+                }
+                break;
+            }
+
+            HandleTwoCharsAndBreak('E', 'e', StateE);
+            return nan();
+
+        case StateE:
+            if (ch == '+') {
+                exponentSign = Positive;
+                state = StateESign;
+                break;
+            }
+
+            if (ch == '-') {
+                exponentSign = Negative;
+                state = StateESign;
+                break;
+            }
+
+            if (ch >= '0' && ch <= '9') {
+                exponent = ch - '0';
+                state = StateEDigit;
+                break;
+            }
+
+            return nan();
+
+        case StateEDigit:
+            if (ch >= '0' && ch <= '9') {
+                exponent *= 10;
+                exponent += ch - '0';
+                if (exponent > ExponentMax + Precision) {
+                    if (accumulator)
+                        return exponentSign == Negative ? zero(Positive) : infinity(sign);
+                    return zero(sign);
+                }
+                state = StateEDigit;
+                break;
+            }
+
+            return nan();
+
+        case StateESign:
+            if (ch >= '0' && ch <= '9') {
+                exponent = ch - '0';
+                state = StateEDigit;
+                break;
+            }
+
+            return nan();
+
+        case StateSign:
+            if (ch >= '1' && ch <= '9') {
+                accumulator = ch - '0';
+                numberOfDigits = 1;
+                state = StateDigit;
+                break;
+            }
+
+            HandleCharAndBreak('0', StateZero);
+            return nan();
+
+        case StateStart:
+            if (ch >= '1' && ch <= '9') {
+                accumulator = ch - '0';
+                numberOfDigits = 1;
+                state = StateDigit;
+                break;
+            }
+
+            if (ch == '-') {
+                sign = Negative;
+                state = StateSign;
+                break;
+            }
+
+            if (ch == '+') {
+                sign = Positive;
+                state = StateSign;
+                break;
+            }
+
+            HandleCharAndBreak('0', StateZero);
+            HandleCharAndBreak('.', StateDot);
+            return nan();
+
+        case StateZero:
+            if (ch == '0')
+                break;
+
+            if (ch >= '1' && ch <= '9') {
+                accumulator = ch - '0';
+                numberOfDigits = 1;
+                state = StateDigit;
+                break;
+            }
+
+            HandleCharAndBreak('.', StateDot);
+            HandleTwoCharsAndBreak('E', 'e', StateE);
+            return nan();
+
+        default:
+            ASSERT_NOT_REACHED();
+            return nan();
+        }
+    }
+
+    if (state == StateZero)
+        return zero(sign);
+
+    if (state == StateDigit || state == StateEDigit || state == StateDotDigit) {
+        int resultExponent = exponent * (exponentSign == Negative ? -1 : 1) - numberOfDigitsAfterDot + numberOfExtraDigits;
+        if (resultExponent < ExponentMin)
+            return zero(Positive);
+
+        const int overflow = resultExponent - ExponentMax + 1;
+        if (overflow > 0) {
+            if (overflow + numberOfDigits - numberOfDigitsAfterDot > Precision)
+                return infinity(sign);
+            accumulator = scaleUp(accumulator, overflow);
+            resultExponent -= overflow;
+        }
+
+        return Decimal(sign, resultExponent, accumulator);
+    }
+
+    return nan();
+}
+
+Decimal Decimal::infinity(const Sign sign)
+{
+    return Decimal(EncodedData(sign, EncodedData::ClassInfinity));
+}
+
+Decimal Decimal::nan()
+{
+    return Decimal(EncodedData(Positive, EncodedData::ClassNaN));
+}
+
+Decimal Decimal::remainder(const Decimal& rhs) const
+{
+    const Decimal quotient = *this / rhs;
+    return quotient.isSpecial() ? quotient : *this - (quotient.isNegative() ? quotient.ceiling() : quotient.floor()) * rhs;
+}
+
+Decimal Decimal::round() const
+{
+    if (isSpecial())
+        return *this;
+
+    if (exponent() >= 0)
+        return *this;
+
+    uint64_t result = m_data.coefficient();
+    const int numberOfDigits = countDigits(result);
+    const int numberOfDropDigits = -exponent();
+    if (numberOfDigits < numberOfDropDigits)
+        return zero(Positive);
+
+    // We're implementing round-half-away-from-zero, so we only need the one
+    // (the most significant) fractional digit:
+    result = scaleDown(result, numberOfDropDigits - 1);
+    if (result % 10 >= 5)
+        result += 10;
+    result /= 10;
+    return Decimal(sign(), 0, result);
+}
+
+double Decimal::toDouble() const
+{
+    if (isFinite()) {
+        bool valid;
+        const double doubleValue = mozToDouble(toString(), &valid);
+        return valid ? doubleValue : std::numeric_limits<double>::quiet_NaN();
+    }
+
+    if (isInfinity())
+        return isNegative() ? -std::numeric_limits<double>::infinity() : std::numeric_limits<double>::infinity();
+
+    return std::numeric_limits<double>::quiet_NaN();
+}
+
+String Decimal::toString() const
+{
+    switch (m_data.formatClass()) {
+    case EncodedData::ClassInfinity:
+        return sign() ? "-Infinity" : "Infinity";
+
+    case EncodedData::ClassNaN:
+        return "NaN";
+
+    case EncodedData::ClassNormal:
+    case EncodedData::ClassZero:
+        break;
+
+    default:
+        ASSERT_NOT_REACHED();
+        return "";
+    }
+
+    StringBuilder builder;
+    if (sign())
+        builder.append('-');
+
+    int originalExponent = exponent();
+    uint64_t coefficient = m_data.coefficient();
+
+    if (originalExponent < 0) {
+        const int maxDigits = DBL_DIG;
+        uint64_t lastDigit = 0;
+        while (countDigits(coefficient) > maxDigits) {
+            lastDigit = coefficient % 10;
+            coefficient /= 10;
+            ++originalExponent;
+        }
+
+        if (lastDigit >= 5)
+            ++coefficient;
+
+        while (originalExponent < 0 && coefficient && !(coefficient % 10)) {
+            coefficient /= 10;
+            ++originalExponent;
+        }
+    }
+
+    const String digits = mozToString(coefficient);
+    int coefficientLength = static_cast<int>(digits.length());
+    const int adjustedExponent = originalExponent + coefficientLength - 1;
+    if (originalExponent <= 0 && adjustedExponent >= -6) {
+        if (!originalExponent) {
+            builder.append(digits);
+            return builder.toString();
+        }
+
+        if (adjustedExponent >= 0) {
+            for (int i = 0; i < coefficientLength; ++i) {
+                builder.append(digits[i]);
+                if (i == adjustedExponent)
+                    builder.append('.');
+            }
+            return builder.toString();
+        }
+
+        builder.appendLiteral("0.");
+        for (int i = adjustedExponent + 1; i < 0; ++i)
+            builder.append('0');
+
+        builder.append(digits);
+
+    } else {
+        builder.append(digits[0]);
+        while (coefficientLength >= 2 && digits[coefficientLength - 1] == '0')
+            --coefficientLength;
+        if (coefficientLength >= 2) {
+            builder.append('.');
+            for (int i = 1; i < coefficientLength; ++i)
+                builder.append(digits[i]);
+        }
+
+        if (adjustedExponent) {
+            builder.append(adjustedExponent < 0 ? "e" : "e+");
+            builder.appendNumber(adjustedExponent);
+        }
+    }
+    return builder.toString();
+}
+
+bool Decimal::toString(char* strBuf, size_t bufLength) const
+{
+  ASSERT(bufLength > 0);
+  String str = toString();
+  size_t length = str.copy(strBuf, bufLength);
+  if (length < bufLength) {
+    strBuf[length] = '\0';
+    return true;
+  }
+  strBuf[bufLength - 1] = '\0';
+  return false;
+}
+
+Decimal Decimal::zero(Sign sign)
+{
+    return Decimal(EncodedData(sign, EncodedData::ClassZero));
+}
+
+} // namespace WebCore
+
diff --git a/src/third_party/mozjs-45/mfbt/decimal/Decimal.h b/src/third_party/mozjs-45/mfbt/decimal/Decimal.h
new file mode 100644
index 0000000..38af01b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/Decimal.h
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Imported from:
+ * http://src.chromium.org/viewvc/blink/trunk/Source/core/platform/Decimal.h
+ * Check hg log for the svn rev of the last update from Blink core.
+ */
+
+#ifndef Decimal_h
+#define Decimal_h
+
+#include "mozilla/Assertions.h"
+#include <stdint.h>
+#include "mozilla/Types.h"
+
+#include <string>
+
+#ifndef ASSERT
+#define DEFINED_ASSERT_FOR_DECIMAL_H 1
+#define ASSERT MOZ_ASSERT
+#endif
+
+// To use WTF_MAKE_FAST_ALLOCATED we'd need:
+// http://src.chromium.org/viewvc/blink/trunk/Source/wtf/FastMalloc.h
+// Since we don't allocate Decimal objects, no need.
+#define WTF_MAKE_FAST_ALLOCATED \
+  void ignore_this_dummy_method() = delete
+
+namespace WebCore {
+
+namespace DecimalPrivate {
+class SpecialValueHandler;
+} // namespace DecimalPrivate
+
+// This class represents decimal base floating point number.
+//
+// FIXME: Once all C++ compiler support decimal type, we should replace this
+// class to compiler supported one. See below URI for current status of decimal
+// type for C++: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1977.html
+class Decimal {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    enum Sign {
+        Positive,
+        Negative,
+    };
+
+    // You should not use EncodedData other than unit testing.
+    class EncodedData {
+        // For accessing FormatClass.
+        friend class Decimal;
+        friend class DecimalPrivate::SpecialValueHandler;
+    public:
+        EncodedData(Sign, int exponent, uint64_t coefficient);
+
+        bool operator==(const EncodedData&) const;
+        bool operator!=(const EncodedData& another) const { return !operator==(another); }
+
+        uint64_t coefficient() const { return m_coefficient; }
+        int countDigits() const;
+        int exponent() const { return m_exponent; }
+        bool isFinite() const { return !isSpecial(); }
+        bool isInfinity() const { return m_formatClass == ClassInfinity; }
+        bool isNaN() const { return m_formatClass == ClassNaN; }
+        bool isSpecial() const { return m_formatClass == ClassInfinity || m_formatClass == ClassNaN; }
+        bool isZero() const { return m_formatClass == ClassZero; }
+        Sign sign() const { return m_sign; }
+        void setSign(Sign aSign) { m_sign = aSign; }
+
+    private:
+        enum FormatClass {
+            ClassInfinity,
+            ClassNormal,
+            ClassNaN,
+            ClassZero,
+        };
+
+        EncodedData(Sign, FormatClass);
+        FormatClass formatClass() const { return m_formatClass; }
+
+        uint64_t m_coefficient;
+        int16_t m_exponent;
+        FormatClass m_formatClass;
+        Sign m_sign;
+    };
+
+    MFBT_API explicit Decimal(int32_t = 0);
+    MFBT_API Decimal(Sign, int exponent, uint64_t coefficient);
+    MFBT_API Decimal(const Decimal&);
+
+    MFBT_API Decimal& operator=(const Decimal&);
+    MFBT_API Decimal& operator+=(const Decimal&);
+    MFBT_API Decimal& operator-=(const Decimal&);
+    MFBT_API Decimal& operator*=(const Decimal&);
+    MFBT_API Decimal& operator/=(const Decimal&);
+
+    MFBT_API Decimal operator-() const;
+
+    MFBT_API bool operator==(const Decimal&) const;
+    MFBT_API bool operator!=(const Decimal&) const;
+    MFBT_API bool operator<(const Decimal&) const;
+    MFBT_API bool operator<=(const Decimal&) const;
+    MFBT_API bool operator>(const Decimal&) const;
+    MFBT_API bool operator>=(const Decimal&) const;
+
+    MFBT_API Decimal operator+(const Decimal&) const;
+    MFBT_API Decimal operator-(const Decimal&) const;
+    MFBT_API Decimal operator*(const Decimal&) const;
+    MFBT_API Decimal operator/(const Decimal&) const;
+
+    int exponent() const
+    {
+        ASSERT(isFinite());
+        return m_data.exponent();
+    }
+
+    bool isFinite() const { return m_data.isFinite(); }
+    bool isInfinity() const { return m_data.isInfinity(); }
+    bool isNaN() const { return m_data.isNaN(); }
+    bool isNegative() const { return sign() == Negative; }
+    bool isPositive() const { return sign() == Positive; }
+    bool isSpecial() const { return m_data.isSpecial(); }
+    bool isZero() const { return m_data.isZero(); }
+
+    MFBT_API Decimal abs() const;
+    MFBT_API Decimal ceiling() const;
+    MFBT_API Decimal floor() const;
+    MFBT_API Decimal remainder(const Decimal&) const;
+    MFBT_API Decimal round() const;
+
+    MFBT_API double toDouble() const;
+    // Note: toString method supports infinity and nan but fromString not.
+    MFBT_API std::string toString() const;
+    MFBT_API bool toString(char* strBuf, size_t bufLength) const;
+
+    static MFBT_API Decimal fromDouble(double);
+    // fromString supports following syntax EBNF:
+    //  number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)?
+    //          | sign? '.' digit+ (exponent-marker sign? digit+)?
+    //  sign ::= '+' | '-'
+    //  exponent-marker ::= 'e' | 'E'
+    //  digit ::= '0' | '1' | ... | '9'
+    // Note: fromString doesn't support "infinity" and "nan".
+    static MFBT_API Decimal fromString(const std::string& aValue);
+    static MFBT_API Decimal infinity(Sign);
+    static MFBT_API Decimal nan();
+    static MFBT_API Decimal zero(Sign);
+
+    // You should not use below methods. We expose them for unit testing.
+    MFBT_API explicit Decimal(const EncodedData&);
+    const EncodedData& value() const { return m_data; }
+
+private:
+    struct AlignedOperands {
+        uint64_t lhsCoefficient;
+        uint64_t rhsCoefficient;
+        int exponent;
+    };
+
+    MFBT_API explicit Decimal(double);
+    MFBT_API Decimal compareTo(const Decimal&) const;
+
+    static MFBT_API AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs);
+    static inline Sign invertSign(Sign sign) { return sign == Negative ? Positive : Negative; }
+
+    Sign sign() const { return m_data.sign(); }
+
+    EncodedData m_data;
+};
+
+} // namespace WebCore
+
+namespace mozilla {
+  typedef WebCore::Decimal Decimal;
+} // namespace mozilla
+
+#undef WTF_MAKE_FAST_ALLOCATED
+
+#ifdef DEFINED_ASSERT_FOR_DECIMAL_H
+#undef DEFINED_ASSERT_FOR_DECIMAL_H
+#undef ASSERT
+#endif
+
+#endif // Decimal_h
+
diff --git a/src/third_party/mozjs-45/mfbt/decimal/LICENSE-APPLE b/src/third_party/mozjs-45/mfbt/decimal/LICENSE-APPLE
new file mode 100644
index 0000000..f29b41c
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/LICENSE-APPLE
@@ -0,0 +1,21 @@
+Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1.  Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+2.  Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/third_party/mozjs-45/mfbt/decimal/LICENSE-LGPL-2 b/src/third_party/mozjs-45/mfbt/decimal/LICENSE-LGPL-2
new file mode 100644
index 0000000..0e1187b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/LICENSE-LGPL-2
@@ -0,0 +1,481 @@
+                  GNU LIBRARY GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+                  GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/src/third_party/mozjs-45/mfbt/decimal/LICENSE-LGPL-2.1 b/src/third_party/mozjs-45/mfbt/decimal/LICENSE-LGPL-2.1
new file mode 100644
index 0000000..b2787a6
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/LICENSE-LGPL-2.1
@@ -0,0 +1,502 @@
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/src/third_party/mozjs-45/mfbt/decimal/comparison-with-nan.patch b/src/third_party/mozjs-45/mfbt/decimal/comparison-with-nan.patch
new file mode 100644
index 0000000..72afc9a
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/comparison-with-nan.patch
@@ -0,0 +1,67 @@
+diff --git a/mfbt/decimal/Decimal.cpp b/mfbt/decimal/Decimal.cpp
+--- a/mfbt/decimal/Decimal.cpp
++++ b/mfbt/decimal/Decimal.cpp
+@@ -505,21 +505,25 @@ Decimal Decimal::operator/(const Decimal
+     if (remainder > divisor / 2)
+         ++result;
+ 
+     return Decimal(resultSign, resultExponent, result);
+ }
+ 
+ bool Decimal::operator==(const Decimal& rhs) const
+ {
++    if (isNaN() || rhs.isNaN())
++        return false;
+     return m_data == rhs.m_data || compareTo(rhs).isZero();
+ }
+ 
+ bool Decimal::operator!=(const Decimal& rhs) const
+ {
++    if (isNaN() || rhs.isNaN())
++        return true;
+     if (m_data == rhs.m_data)
+         return false;
+     const Decimal result = compareTo(rhs);
+     if (result.isNaN())
+         return false;
+     return !result.isZero();
+ }
+ 
+@@ -528,16 +532,18 @@ bool Decimal::operator<(const Decimal& r
+     const Decimal result = compareTo(rhs);
+     if (result.isNaN())
+         return false;
+     return !result.isZero() && result.isNegative();
+ }
+ 
+ bool Decimal::operator<=(const Decimal& rhs) const
+ {
++    if (isNaN() || rhs.isNaN())
++        return false;
+     if (m_data == rhs.m_data)
+         return true;
+     const Decimal result = compareTo(rhs);
+     if (result.isNaN())
+         return false;
+     return result.isZero() || result.isNegative();
+ }
+ 
+@@ -546,16 +552,18 @@ bool Decimal::operator>(const Decimal& r
+     const Decimal result = compareTo(rhs);
+     if (result.isNaN())
+         return false;
+     return !result.isZero() && result.isPositive();
+ }
+ 
+ bool Decimal::operator>=(const Decimal& rhs) const
+ {
++    if (isNaN() || rhs.isNaN())
++        return false;
+     if (m_data == rhs.m_data)
+         return true;
+     const Decimal result = compareTo(rhs);
+     if (result.isNaN())
+         return false;
+     return result.isZero() || !result.isNegative();
+ }
+ 
diff --git a/src/third_party/mozjs-45/mfbt/decimal/fix-wshadow-warnings.patch b/src/third_party/mozjs-45/mfbt/decimal/fix-wshadow-warnings.patch
new file mode 100644
index 0000000..eed7b60
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/fix-wshadow-warnings.patch
@@ -0,0 +1,171 @@
+diff --git a/mfbt/decimal/Decimal.cpp b/mfbt/decimal/Decimal.cpp
+--- a/mfbt/decimal/Decimal.cpp
++++ b/mfbt/decimal/Decimal.cpp
+@@ -118,18 +118,18 @@ Decimal SpecialValueHandler::value() con
+         ASSERT_NOT_REACHED();
+         return m_lhs;
+     }
+ }
+ 
+ // This class is used for 128 bit unsigned integer arithmetic.
+ class UInt128 {
+ public:
+-    UInt128(uint64_t low, uint64_t high)
+-        : m_high(high), m_low(low)
++    UInt128(uint64_t aLow, uint64_t aHigh)
++        : m_high(aHigh), m_low(aLow)
+     {
+     }
+ 
+     UInt128& operator/=(uint32_t);
+ 
+     uint64_t high() const { return m_high; }
+     uint64_t low() const { return m_low; }
+ 
+@@ -224,68 +224,68 @@ static uint64_t scaleUp(uint64_t x, int 
+         z = z * z;
+     }
+ }
+ 
+ } // namespace DecimalPrivate
+ 
+ using namespace DecimalPrivate;
+ 
+-Decimal::EncodedData::EncodedData(Sign sign, FormatClass formatClass)
++Decimal::EncodedData::EncodedData(Sign aSign, FormatClass aFormatClass)
+     : m_coefficient(0)
+     , m_exponent(0)
+-    , m_formatClass(formatClass)
+-    , m_sign(sign)
++    , m_formatClass(aFormatClass)
++    , m_sign(aSign)
+ {
+ }
+ 
+-Decimal::EncodedData::EncodedData(Sign sign, int exponent, uint64_t coefficient)
+-    : m_formatClass(coefficient ? ClassNormal : ClassZero)
+-    , m_sign(sign)
++Decimal::EncodedData::EncodedData(Sign aSign, int aExponent, uint64_t aCoefficient)
++    : m_formatClass(aCoefficient ? ClassNormal : ClassZero)
++    , m_sign(aSign)
+ {
+-    if (exponent >= ExponentMin && exponent <= ExponentMax) {
+-        while (coefficient > MaxCoefficient) {
+-            coefficient /= 10;
+-            ++exponent;
++    if (aExponent >= ExponentMin && aExponent <= ExponentMax) {
++        while (aCoefficient > MaxCoefficient) {
++            aCoefficient /= 10;
++            ++aExponent;
+         }
+     }
+ 
+-    if (exponent > ExponentMax) {
++    if (aExponent > ExponentMax) {
+         m_coefficient = 0;
+         m_exponent = 0;
+         m_formatClass = ClassInfinity;
+         return;
+     }
+ 
+-    if (exponent < ExponentMin) {
++    if (aExponent < ExponentMin) {
+         m_coefficient = 0;
+         m_exponent = 0;
+         m_formatClass = ClassZero;
+         return;
+     }
+ 
+-    m_coefficient = coefficient;
+-    m_exponent = static_cast<int16_t>(exponent);
++    m_coefficient = aCoefficient;
++    m_exponent = static_cast<int16_t>(aExponent);
+ }
+ 
+ bool Decimal::EncodedData::operator==(const EncodedData& another) const
+ {
+     return m_sign == another.m_sign
+         && m_formatClass == another.m_formatClass
+         && m_exponent == another.m_exponent
+         && m_coefficient == another.m_coefficient;
+ }
+ 
+ Decimal::Decimal(int32_t i32)
+     : m_data(i32 < 0 ? Negative : Positive, 0, i32 < 0 ? static_cast<uint64_t>(-static_cast<int64_t>(i32)) : static_cast<uint64_t>(i32))
+ {
+ }
+ 
+-Decimal::Decimal(Sign sign, int exponent, uint64_t coefficient)
+-    : m_data(sign, coefficient ? exponent : 0, coefficient)
++Decimal::Decimal(Sign aSign, int aExponent, uint64_t aCoefficient)
++    : m_data(aSign, aCoefficient ? aExponent : 0, aCoefficient)
+ {
+ }
+ 
+ Decimal::Decimal(const EncodedData& data)
+     : m_data(data)
+ {
+ }
+ 
+@@ -479,32 +479,32 @@ Decimal Decimal::operator/(const Decimal
+     if (rhs.isZero())
+         return lhs.isZero() ? nan() : infinity(resultSign);
+ 
+     int resultExponent = lhs.exponent() - rhs.exponent();
+ 
+     if (lhs.isZero())
+         return Decimal(resultSign, resultExponent, 0);
+ 
+-    uint64_t remainder = lhs.m_data.coefficient();
++    uint64_t lhsRemainder = lhs.m_data.coefficient();
+     const uint64_t divisor = rhs.m_data.coefficient();
+     uint64_t result = 0;
+     while (result < MaxCoefficient / 100) {
+-        while (remainder < divisor) {
+-            remainder *= 10;
++        while (lhsRemainder < divisor) {
++            lhsRemainder *= 10;
+             result *= 10;
+             --resultExponent;
+         }
+-        result += remainder / divisor;
+-        remainder %= divisor;
+-        if (!remainder)
++        result += lhsRemainder / divisor;
++        lhsRemainder %= divisor;
++        if (!lhsRemainder)
+             break;
+     }
+ 
+-    if (remainder > divisor / 2)
++    if (lhsRemainder > divisor / 2)
+         ++result;
+ 
+     return Decimal(resultSign, resultExponent, result);
+ }
+ 
+ bool Decimal::operator==(const Decimal& rhs) const
+ {
+     if (isNaN() || rhs.isNaN())
+diff --git a/mfbt/decimal/Decimal.h b/mfbt/decimal/Decimal.h
+--- a/mfbt/decimal/Decimal.h
++++ b/mfbt/decimal/Decimal.h
+@@ -88,17 +88,17 @@ public:
+         int countDigits() const;
+         int exponent() const { return m_exponent; }
+         bool isFinite() const { return !isSpecial(); }
+         bool isInfinity() const { return m_formatClass == ClassInfinity; }
+         bool isNaN() const { return m_formatClass == ClassNaN; }
+         bool isSpecial() const { return m_formatClass == ClassInfinity || m_formatClass == ClassNaN; }
+         bool isZero() const { return m_formatClass == ClassZero; }
+         Sign sign() const { return m_sign; }
+-        void setSign(Sign sign) { m_sign = sign; }
++        void setSign(Sign aSign) { m_sign = aSign; }
+ 
+     private:
+         enum FormatClass {
+             ClassInfinity,
+             ClassNormal,
+             ClassNaN,
+             ClassZero,
+         };
diff --git a/src/third_party/mozjs-45/mfbt/decimal/floor-ceiling.patch b/src/third_party/mozjs-45/mfbt/decimal/floor-ceiling.patch
new file mode 100644
index 0000000..9e26787
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/floor-ceiling.patch
@@ -0,0 +1,89 @@
+diff --git a/mfbt/decimal/Decimal.cpp b/mfbt/decimal/Decimal.cpp
+--- a/mfbt/decimal/Decimal.cpp
++++ b/mfbt/decimal/Decimal.cpp
+@@ -618,26 +618,26 @@ Decimal::AlignedOperands Decimal::alignO
+ Decimal Decimal::ceiling() const
+ {
+     if (isSpecial())
+         return *this;
+ 
+     if (exponent() >= 0)
+         return *this;
+ 
+-    uint64_t result = m_data.coefficient();
+-    const int numberOfDigits = countDigits(result);
++    uint64_t coefficient = m_data.coefficient();
++    const int numberOfDigits = countDigits(coefficient);
+     const int numberOfDropDigits = -exponent();
+     if (numberOfDigits < numberOfDropDigits)
+         return isPositive() ? Decimal(1) : zero(Positive);
+ 
+-    result = scaleDown(result, numberOfDropDigits - 1);
+-    if (sign() == Positive && result % 10 > 0)
+-        result += 10;
+-    result /= 10;
++    uint64_t result = scaleDown(coefficient, numberOfDropDigits);
++    uint64_t droppedDigits = coefficient - scaleUp(result, numberOfDropDigits);
++    if (droppedDigits && isPositive())
++        result += 1;
+     return Decimal(sign(), 0, result);
+ }
+ 
+ Decimal Decimal::compareTo(const Decimal& rhs) const
+ {
+     const Decimal result(*this - rhs);
+     switch (result.m_data.formatClass()) {
+     case EncodedData::ClassInfinity:
+@@ -660,26 +660,27 @@ Decimal Decimal::compareTo(const Decimal
+ Decimal Decimal::floor() const
+ {
+     if (isSpecial())
+         return *this;
+ 
+     if (exponent() >= 0)
+         return *this;
+ 
+-    uint64_t result = m_data.coefficient();
+-    const int numberOfDigits = countDigits(result);
++    uint64_t coefficient = m_data.coefficient();
++    const int numberOfDigits = countDigits(coefficient);
+     const int numberOfDropDigits = -exponent();
+     if (numberOfDigits < numberOfDropDigits)
+         return isPositive() ? zero(Positive) : Decimal(-1);
+ 
+-    result = scaleDown(result, numberOfDropDigits - 1);
+-    if (isNegative() && result % 10 > 0)
+-        result += 10;
+-    result /= 10;
++    uint64_t result = scaleDown(coefficient, numberOfDropDigits);
++    uint64_t droppedDigits = coefficient - scaleUp(result, numberOfDropDigits);
++    if (droppedDigits && isNegative()) {
++        result += 1;
++    }
+     return Decimal(sign(), 0, result);
+ }
+ 
+ Decimal Decimal::fromDouble(double doubleValue)
+ {
+     if (std::isfinite(doubleValue))
+         return fromString(String::numberToStringECMAScript(doubleValue));
+ 
+@@ -915,16 +916,18 @@ Decimal Decimal::round() const
+         return *this;
+ 
+     uint64_t result = m_data.coefficient();
+     const int numberOfDigits = countDigits(result);
+     const int numberOfDropDigits = -exponent();
+     if (numberOfDigits < numberOfDropDigits)
+         return zero(Positive);
+ 
++    // We're implementing round-half-away-from-zero, so we only need the one
++    // (the most significant) fractional digit:
+     result = scaleDown(result, numberOfDropDigits - 1);
+     if (result % 10 >= 5)
+         result += 10;
+     result /= 10;
+     return Decimal(sign(), 0, result);
+ }
+ 
+ double Decimal::toDouble() const
diff --git a/src/third_party/mozjs-45/mfbt/decimal/mfbt-abi-markers.patch b/src/third_party/mozjs-45/mfbt/decimal/mfbt-abi-markers.patch
new file mode 100644
index 0000000..834ee4b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/mfbt-abi-markers.patch
@@ -0,0 +1,150 @@
+diff --git a/mfbt/decimal/Decimal.h b/mfbt/decimal/Decimal.h
+--- a/mfbt/decimal/Decimal.h
++++ b/mfbt/decimal/Decimal.h
+@@ -26,16 +26,18 @@
+  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  */
+ 
+ #ifndef Decimal_h
+ #define Decimal_h
+ 
++#include "mozilla/Types.h"
++
+ #include <stdint.h>
+ #include <wtf/Assertions.h>
+ #include <wtf/text/WTFString.h>
+ 
+ namespace WebCore {
+ 
+ namespace DecimalPrivate {
+ class SpecialValueHandler;
+@@ -88,92 +90,92 @@ public:
+         FormatClass formatClass() const { return m_formatClass; }
+ 
+         uint64_t m_coefficient;
+         int16_t m_exponent;
+         FormatClass m_formatClass;
+         Sign m_sign;
+     };
+ 
+-    Decimal(int32_t = 0);
+-    Decimal(Sign, int exponent, uint64_t coefficient);
+-    Decimal(const Decimal&);
++    MFBT_API Decimal(int32_t = 0);
++    MFBT_API Decimal(Sign, int exponent, uint64_t coefficient);
++    MFBT_API Decimal(const Decimal&);
+ 
+-    Decimal& operator=(const Decimal&);
+-    Decimal& operator+=(const Decimal&);
+-    Decimal& operator-=(const Decimal&);
+-    Decimal& operator*=(const Decimal&);
+-    Decimal& operator/=(const Decimal&);
++    MFBT_API Decimal& operator=(const Decimal&);
++    MFBT_API Decimal& operator+=(const Decimal&);
++    MFBT_API Decimal& operator-=(const Decimal&);
++    MFBT_API Decimal& operator*=(const Decimal&);
++    MFBT_API Decimal& operator/=(const Decimal&);
+ 
+-    Decimal operator-() const;
++    MFBT_API Decimal operator-() const;
+ 
+-    bool operator==(const Decimal&) const;
+-    bool operator!=(const Decimal&) const;
+-    bool operator<(const Decimal&) const;
+-    bool operator<=(const Decimal&) const;
+-    bool operator>(const Decimal&) const;
+-    bool operator>=(const Decimal&) const;
++    MFBT_API bool operator==(const Decimal&) const;
++    MFBT_API bool operator!=(const Decimal&) const;
++    MFBT_API bool operator<(const Decimal&) const;
++    MFBT_API bool operator<=(const Decimal&) const;
++    MFBT_API bool operator>(const Decimal&) const;
++    MFBT_API bool operator>=(const Decimal&) const;
+ 
+-    Decimal operator+(const Decimal&) const;
+-    Decimal operator-(const Decimal&) const;
+-    Decimal operator*(const Decimal&) const;
+-    Decimal operator/(const Decimal&) const;
++    MFBT_API Decimal operator+(const Decimal&) const;
++    MFBT_API Decimal operator-(const Decimal&) const;
++    MFBT_API Decimal operator*(const Decimal&) const;
++    MFBT_API Decimal operator/(const Decimal&) const;
+ 
+     int exponent() const
+     {
+         ASSERT(isFinite());
+         return m_data.exponent();
+     }
+ 
+     bool isFinite() const { return m_data.isFinite(); }
+     bool isInfinity() const { return m_data.isInfinity(); }
+     bool isNaN() const { return m_data.isNaN(); }
+     bool isNegative() const { return sign() == Negative; }
+     bool isPositive() const { return sign() == Positive; }
+     bool isSpecial() const { return m_data.isSpecial(); }
+     bool isZero() const { return m_data.isZero(); }
+ 
+-    Decimal abs() const;
+-    Decimal ceiling() const;
+-    Decimal floor() const;
+-    Decimal remainder(const Decimal&) const;
+-    Decimal round() const;
++    MFBT_API Decimal abs() const;
++    MFBT_API Decimal ceiling() const;
++    MFBT_API Decimal floor() const;
++    MFBT_API Decimal remainder(const Decimal&) const;
++    MFBT_API Decimal round() const;
+ 
+-    double toDouble() const;
++    MFBT_API double toDouble() const;
+     // Note: toString method supports infinity and nan but fromString not.
+-    String toString() const;
++    MFBT_API String toString() const;
+ 
+-    static Decimal fromDouble(double);
++    static MFBT_API Decimal fromDouble(double);
+     // fromString supports following syntax EBNF:
+     //  number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)?
+     //          | sign? '.' digit+ (exponent-marker sign? digit+)?
+     //  sign ::= '+' | '-'
+     //  exponent-marker ::= 'e' | 'E'
+     //  digit ::= '0' | '1' | ... | '9'
+     // Note: fromString doesn't support "infinity" and "nan".
+-    static Decimal fromString(const String&);
+-    static Decimal infinity(Sign);
+-    static Decimal nan();
+-    static Decimal zero(Sign);
++    static MFBT_API Decimal fromString(const String&);
++    static MFBT_API Decimal infinity(Sign);
++    static MFBT_API Decimal nan();
++    static MFBT_API Decimal zero(Sign);
+ 
+     // You should not use below methods. We expose them for unit testing.
+-    explicit Decimal(const EncodedData&);
++    MFBT_API explicit Decimal(const EncodedData&);
+     const EncodedData& value() const { return m_data; }
+ 
+ private:
+     struct AlignedOperands {
+         uint64_t lhsCoefficient;
+         uint64_t rhsCoefficient;
+         int exponent;
+     };
+ 
+-    Decimal(double);
+-    Decimal compareTo(const Decimal&) const;
++    MFBT_API Decimal(double);
++    MFBT_API Decimal compareTo(const Decimal&) const;
+ 
+-    static AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs);
++    static MFBT_API AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs);
+     static inline Sign invertSign(Sign sign) { return sign == Negative ? Positive : Negative; }
+ 
+     Sign sign() const { return m_data.sign(); }
+ 
+     EncodedData m_data;
+ };
+ 
+ } // namespace WebCore
diff --git a/src/third_party/mozjs-45/mfbt/decimal/moz-decimal-utils.h b/src/third_party/mozjs-45/mfbt/decimal/moz-decimal-utils.h
new file mode 100644
index 0000000..6a9d803
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/moz-decimal-utils.h
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef MOZ_DECIMAL_UTILS_H
+#define MOZ_DECIMAL_UTILS_H
+
+// This file contains extra includes, defines and typedefs to allow compilation
+// of Decimal.cpp under the Mozilla source without blink core dependencies. Do
+// not include it into any file other than Decimal.cpp.
+
+#include "../double-conversion/double-conversion.h"
+#include "mozilla/ArrayUtils.h"
+#include "mozilla/Casting.h"
+#include "mozilla/FloatingPoint.h"
+
+#include <cmath>
+#include <cstring>
+#include <iomanip>
+#include <limits>
+#include <sstream>
+
+#ifndef UINT64_C
+// For Android toolchain
+#define UINT64_C(c) (c ## ULL)
+#endif
+
+#ifdef ASSERT
+#undef ASSERT
+#endif
+#define ASSERT MOZ_ASSERT
+
+#define ASSERT_NOT_REACHED() MOZ_ASSERT_UNREACHABLE("moz-decimal-utils.h")
+
+#define WTF_MAKE_NONCOPYABLE(ClassName) \
+  private: \
+    ClassName(const ClassName&) = delete; \
+    void operator=(const ClassName&) = delete;
+
+typedef std::string String;
+
+double mozToDouble(const String &aStr, bool *valid) {
+  double_conversion::StringToDoubleConverter converter(
+    double_conversion::StringToDoubleConverter::NO_FLAGS,
+    mozilla::UnspecifiedNaN<double>(), mozilla::UnspecifiedNaN<double>(), nullptr, nullptr);
+  const char* str = aStr.c_str();
+  int length = mozilla::AssertedCast<int>(strlen(str));
+  int processed_char_count; // unused - NO_FLAGS requires the whole string to parse
+  double result = converter.StringToDouble(str, length, &processed_char_count);
+  *valid = mozilla::IsFinite(result);
+  return result;
+}
+
+String mozToString(double aNum) {
+  char buffer[64];
+  int buffer_length = mozilla::ArrayLength(buffer);
+  const double_conversion::DoubleToStringConverter& converter =
+    double_conversion::DoubleToStringConverter::EcmaScriptConverter();
+  double_conversion::StringBuilder builder(buffer, buffer_length);
+  converter.ToShortest(aNum, &builder);
+  return String(builder.Finalize());
+}
+
+String mozToString(int64_t aNum) {
+  std::ostringstream o;
+  o << std::setprecision(std::numeric_limits<int64_t>::digits10) << aNum;
+  return o.str();
+}
+
+String mozToString(uint64_t aNum) {
+  std::ostringstream o;
+  o << std::setprecision(std::numeric_limits<uint64_t>::digits10) << aNum;
+  return o.str();
+}
+
+namespace moz_decimal_utils {
+
+class StringBuilder
+{
+public:
+  void append(char c) {
+    mStr += c;
+  }
+  void appendLiteral(const char *aStr) {
+    mStr += aStr;
+  }
+  void appendNumber(int aNum) {
+    mStr += mozToString(int64_t(aNum));
+  }
+  void append(const String& aStr) {
+    mStr += aStr;
+  }
+  std::string toString() const {
+    return mStr;
+  }
+private:
+  std::string mStr;
+};
+
+} // namespace moz_decimal_utils
+
+#endif
+
diff --git a/src/third_party/mozjs-45/mfbt/decimal/to-moz-dependencies.patch b/src/third_party/mozjs-45/mfbt/decimal/to-moz-dependencies.patch
new file mode 100644
index 0000000..769efd8
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/to-moz-dependencies.patch
@@ -0,0 +1,219 @@
+diff --git a/mfbt/decimal/Decimal.cpp b/mfbt/decimal/Decimal.cpp
+--- a/mfbt/decimal/Decimal.cpp
++++ b/mfbt/decimal/Decimal.cpp
+@@ -23,26 +23,23 @@
+  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  */
+ 
+-#include "config.h"
+ #include "Decimal.h"
++#include "moz-decimal-utils.h"
+ 
+ #include <algorithm>
+ #include <float.h>
+ 
+-#include <wtf/Assertions.h>
+-#include <wtf/MathExtras.h>
+-#include <wtf/Noncopyable.h>
+-#include <wtf/text/StringBuilder.h>
++using namespace moz_decimal_utils;
+ 
+ namespace WebCore {
+ 
+ namespace DecimalPrivate {
+ 
+ static int const ExponentMax = 1023;
+ static int const ExponentMin = -1023;
+ static int const Precision = 18;
+@@ -685,17 +682,17 @@ Decimal Decimal::floor() const
+         result += 1;
+     }
+     return Decimal(sign(), 0, result);
+ }
+ 
+ Decimal Decimal::fromDouble(double doubleValue)
+ {
+     if (std::isfinite(doubleValue))
+-        return fromString(String::numberToStringECMAScript(doubleValue));
++        return fromString(mozToString(doubleValue));
+ 
+     if (std::isinf(doubleValue))
+         return infinity(doubleValue < 0 ? Negative : Positive);
+ 
+     return nan();
+ }
+ 
+ Decimal Decimal::fromString(const String& str)
+@@ -937,17 +934,17 @@ Decimal Decimal::round() const
+     result /= 10;
+     return Decimal(sign(), 0, result);
+ }
+ 
+ double Decimal::toDouble() const
+ {
+     if (isFinite()) {
+         bool valid;
+-        const double doubleValue = toString().toDouble(&valid);
++        const double doubleValue = mozToDouble(toString(), &valid);
+         return valid ? doubleValue : std::numeric_limits<double>::quiet_NaN();
+     }
+ 
+     if (isInfinity())
+         return isNegative() ? -std::numeric_limits<double>::infinity() : std::numeric_limits<double>::infinity();
+ 
+     return std::numeric_limits<double>::quiet_NaN();
+ }
+@@ -990,17 +987,17 @@ String Decimal::toString() const
+             ++coefficient;
+ 
+         while (originalExponent < 0 && coefficient && !(coefficient % 10)) {
+             coefficient /= 10;
+             ++originalExponent;
+         }
+     }
+ 
+-    const String digits = String::number(coefficient);
++    const String digits = mozToString(coefficient);
+     int coefficientLength = static_cast<int>(digits.length());
+     const int adjustedExponent = originalExponent + coefficientLength - 1;
+     if (originalExponent <= 0 && adjustedExponent >= -6) {
+         if (!originalExponent) {
+             builder.append(digits);
+             return builder.toString();
+         }
+ 
+@@ -1032,15 +1029,28 @@ String Decimal::toString() const
+         if (adjustedExponent) {
+             builder.append(adjustedExponent < 0 ? "e" : "e+");
+             builder.appendNumber(adjustedExponent);
+         }
+     }
+     return builder.toString();
+ }
+ 
++bool Decimal::toString(char* strBuf, size_t bufLength) const
++{
++  ASSERT(bufLength > 0);
++  String str = toString();
++  size_t length = str.copy(strBuf, bufLength);
++  if (length < bufLength) {
++    strBuf[length] = '\0';
++    return true;
++  }
++  strBuf[bufLength - 1] = '\0';
++  return false;
++}
++
+ Decimal Decimal::zero(Sign sign)
+ {
+     return Decimal(EncodedData(sign, EncodedData::ClassZero));
+ }
+ 
+ } // namespace WebCore
+ 
+diff --git a/mfbt/decimal/Decimal.h b/mfbt/decimal/Decimal.h
+--- a/mfbt/decimal/Decimal.h
++++ b/mfbt/decimal/Decimal.h
+@@ -23,24 +23,41 @@
+  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  */
+ 
++/**
++ * Imported from:
++ * http://src.chromium.org/viewvc/blink/trunk/Source/core/platform/Decimal.h
++ * Check hg log for the svn rev of the last update from Blink core.
++ */
++
+ #ifndef Decimal_h
+ #define Decimal_h
+ 
++#include "mozilla/Assertions.h"
++#include <stdint.h>
+ #include "mozilla/Types.h"
+ 
+-#include <stdint.h>
+-#include <wtf/Assertions.h>
+-#include <wtf/text/WTFString.h>
++#include <string>
++
++#ifndef ASSERT
++#define DEFINED_ASSERT_FOR_DECIMAL_H 1
++#define ASSERT MOZ_ASSERT
++#endif
++
++// To use WTF_MAKE_FAST_ALLOCATED we'd need:
++// http://src.chromium.org/viewvc/blink/trunk/Source/wtf/FastMalloc.h
++// Since we don't allocate Decimal objects, no need.
++#define WTF_MAKE_FAST_ALLOCATED \
++  void ignore_this_dummy_method() = delete
+ 
+ namespace WebCore {
+ 
+ namespace DecimalPrivate {
+ class SpecialValueHandler;
+ }
+ 
+ // This class represents decimal base floating point number.
+@@ -136,27 +153,28 @@ public:
+     MFBT_API Decimal abs() const;
+     MFBT_API Decimal ceiling() const;
+     MFBT_API Decimal floor() const;
+     MFBT_API Decimal remainder(const Decimal&) const;
+     MFBT_API Decimal round() const;
+ 
+     MFBT_API double toDouble() const;
+     // Note: toString method supports infinity and nan but fromString not.
+-    MFBT_API String toString() const;
++    MFBT_API std::string toString() const;
++    MFBT_API bool toString(char* strBuf, size_t bufLength) const;
+ 
+     static MFBT_API Decimal fromDouble(double);
+     // fromString supports following syntax EBNF:
+     //  number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)?
+     //          | sign? '.' digit+ (exponent-marker sign? digit+)?
+     //  sign ::= '+' | '-'
+     //  exponent-marker ::= 'e' | 'E'
+     //  digit ::= '0' | '1' | ... | '9'
+     // Note: fromString doesn't support "infinity" and "nan".
+-    static MFBT_API Decimal fromString(const String&);
++    static MFBT_API Decimal fromString(const std::string& aValue);
+     static MFBT_API Decimal infinity(Sign);
+     static MFBT_API Decimal nan();
+     static MFBT_API Decimal zero(Sign);
+ 
+     // You should not use below methods. We expose them for unit testing.
+     MFBT_API explicit Decimal(const EncodedData&);
+     const EncodedData& value() const { return m_data; }
+ 
+@@ -175,10 +193,21 @@ private:
+ 
+     Sign sign() const { return m_data.sign(); }
+ 
+     EncodedData m_data;
+ };
+ 
+ } // namespace WebCore
+ 
++namespace mozilla {
++  typedef WebCore::Decimal Decimal;
++}
++
++#undef WTF_MAKE_FAST_ALLOCATED
++
++#ifdef DEFINED_ASSERT_FOR_DECIMAL_H
++#undef DEFINED_ASSERT_FOR_DECIMAL_H
++#undef ASSERT
++#endif
++
+ #endif // Decimal_h
+ 
diff --git a/src/third_party/mozjs-45/mfbt/decimal/update.sh b/src/third_party/mozjs-45/mfbt/decimal/update.sh
new file mode 100755
index 0000000..2f70942
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/update.sh
@@ -0,0 +1,66 @@
+# Usage: ./update.sh [blink-core-source-directory]
+#
+# Copies the needed files from a directory containing the original
+# Decimal.h and Decimal.cpp source that we need.
+# If [blink-core-source-directory] is not specified, this script will
+# attempt to download the latest versions using svn.
+
+# This was last updated with svn r148833
+
+set -e
+
+FILES=(
+  "LICENSE-APPLE"
+  "LICENSE-LGPL-2"
+  "LICENSE-LGPL-2.1"
+  "platform/Decimal.h"
+  "platform/Decimal.cpp"
+)
+
+OWN_NAME=`basename $0`
+
+if [ $# -gt 1 ]; then
+  echo "$OWN_NAME: Too many arguments">&2
+  exit 1
+fi
+
+if [ $# -eq 1 ]; then
+  BLINK_CORE_DIR="$1"
+  for F in "${FILES[@]}"
+  do
+    P="$BLINK_CORE_DIR/$F"
+    if [ ! -f "$P" ]; then
+      echo "$OWN_NAME: Couldn't find file: $P">&2
+      exit 1
+    fi
+  done
+  for F in "${FILES[@]}"
+  do
+    P="$BLINK_CORE_DIR/$F"
+    cp "$P" .
+  done
+else
+  SVN="svn --non-interactive --trust-server-cert"
+  REPO_PATH="https://src.chromium.org/blink/trunk/Source/core"
+  #REPO_PATH="https://svn.webkit.org/repository/webkit/trunk/Source/WebCore"
+
+  printf "Looking up latest Blink revision number..."
+  LATEST_REV=`$SVN info $REPO_PATH | grep '^Revision: ' | cut -c11-`
+  echo done.
+
+  for F in "${FILES[@]}"
+  do
+    printf "Exporting r$LATEST_REV of `basename $F`..."
+    $SVN export -r $LATEST_REV $REPO_PATH/$F 2>/dev/null 1>&2
+    echo done.
+  done
+fi
+
+# Apply patches:
+
+patch -p3 < floor-ceiling.patch
+patch -p3 < zero-serialization.patch
+patch -p3 < comparison-with-nan.patch
+patch -p3 < mfbt-abi-markers.patch
+patch -p3 < to-moz-dependencies.patch
+patch -p3 < fix-wshadow-warnings.patch
diff --git a/src/third_party/mozjs-45/mfbt/decimal/zero-serialization.patch b/src/third_party/mozjs-45/mfbt/decimal/zero-serialization.patch
new file mode 100644
index 0000000..b058e09
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/decimal/zero-serialization.patch
@@ -0,0 +1,22 @@
+diff --git a/mfbt/decimal/Decimal.cpp b/mfbt/decimal/Decimal.cpp
+--- a/mfbt/decimal/Decimal.cpp
++++ b/mfbt/decimal/Decimal.cpp
+@@ -278,17 +278,17 @@ bool Decimal::EncodedData::operator==(co
+ }
+ 
+ Decimal::Decimal(int32_t i32)
+     : m_data(i32 < 0 ? Negative : Positive, 0, i32 < 0 ? static_cast<uint64_t>(-static_cast<int64_t>(i32)) : static_cast<uint64_t>(i32))
+ {
+ }
+ 
+ Decimal::Decimal(Sign sign, int exponent, uint64_t coefficient)
+-    : m_data(sign, exponent, coefficient)
++    : m_data(sign, coefficient ? exponent : 0, coefficient)
+ {
+ }
+ 
+ Decimal::Decimal(const EncodedData& data)
+     : m_data(data)
+ {
+ }
+ 
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/LICENSE b/src/third_party/mozjs-45/mfbt/double-conversion/LICENSE
new file mode 100644
index 0000000..933718a
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/LICENSE
@@ -0,0 +1,26 @@
+Copyright 2006-2011, the V8 project authors. All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of Google Inc. nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/README b/src/third_party/mozjs-45/mfbt/double-conversion/README
new file mode 100644
index 0000000..f186b42
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/README
@@ -0,0 +1,11 @@
+http://code.google.com/p/double-conversion
+
+This project (double-conversion) provides binary-decimal and decimal-binary
+routines for IEEE doubles.
+
+The library consists of efficient conversion routines that have been extracted
+from the V8 JavaScript engine. The code has been refactored and improved so that
+it can be used more easily in other projects.
+
+There is extensive documentation in src/double-conversion.h. Other examples can
+be found in test/cctest/test-conversions.cc.
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/ToPrecision-exponential.patch b/src/third_party/mozjs-45/mfbt/double-conversion/ToPrecision-exponential.patch
new file mode 100644
index 0000000..202b29b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/ToPrecision-exponential.patch
@@ -0,0 +1,35 @@
+1e7bf0c636b8cca54dd83456a0f8fa219343e2a1 Bug 608195 - part 2 - extend ToPrecision to tell use whether exponential notation was used
+diff --git a/mfbt/double-conversion/double-conversion.cc b/mfbt/double-conversion/double-conversion.cc
+index febba6c..394b6a0 100644
+--- a/mfbt/double-conversion/double-conversion.cc
++++ b/mfbt/double-conversion/double-conversion.cc
+@@ -283,7 +283,9 @@ bool DoubleToStringConverter::ToExponential(
+ 
+ bool DoubleToStringConverter::ToPrecision(double value,
+                                           int precision,
++                                          bool* used_exponential_notation,
+                                           StringBuilder* result_builder) const {
++  *used_exponential_notation = false;
+   if (Double(value).IsSpecial()) {
+     return HandleSpecialValues(value, result_builder);
+   }
+@@ -325,6 +327,7 @@ bool DoubleToStringConverter::ToPrecision(double value,
+       decimal_rep[i] = '0';
+     }
+ 
++    *used_exponential_notation = true;
+     CreateExponentialRepresentation(decimal_rep,
+                                     precision,
+                                     exponent,
+diff --git a/mfbt/double-conversion/double-conversion.h b/mfbt/double-conversion/double-conversion.h
+index 0900ba0..957575c 100644
+--- a/mfbt/double-conversion/double-conversion.h
++++ b/mfbt/double-conversion/double-conversion.h
+@@ -270,6 +270,7 @@ class DoubleToStringConverter {
+   // exponent character, the exponent's sign, and at most 3 exponent digits).
+   MFBT_API bool ToPrecision(double value,
+                    int precision,
++                   bool* used_exponential_notation,
+                    StringBuilder* result_builder) const;
+ 
+   enum DtoaMode {
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/add-mfbt-api-markers.patch b/src/third_party/mozjs-45/mfbt/double-conversion/add-mfbt-api-markers.patch
new file mode 100644
index 0000000..bbb50f6
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/add-mfbt-api-markers.patch
@@ -0,0 +1,94 @@
+diff --git a/mfbt/double-conversion/double-conversion.h b/mfbt/double-conversion/double-conversion.h
+index f98edae..c62b16b 100644
+--- a/mfbt/double-conversion/double-conversion.h
++++ b/mfbt/double-conversion/double-conversion.h
+@@ -28,6 +28,7 @@
+ #ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
+ #define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
+ 
++#include "mozilla/Types.h"
+ #include "utils.h"
+ 
+ namespace double_conversion {
+@@ -129,7 +130,7 @@ class DoubleToStringConverter {
+   }
+ 
+   // Returns a converter following the EcmaScript specification.
+-  static const DoubleToStringConverter& EcmaScriptConverter();
++  static MFBT_API const DoubleToStringConverter& EcmaScriptConverter();
+ 
+   // Computes the shortest string of digits that correctly represent the input
+   // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high
+@@ -197,7 +198,7 @@ class DoubleToStringConverter {
+   // The last two conditions imply that the result will never contain more than
+   // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters
+   // (one additional character for the sign, and one for the decimal point).
+-  bool ToFixed(double value,
++  MFBT_API bool ToFixed(double value,
+                int requested_digits,
+                StringBuilder* result_builder) const;
+ 
+@@ -229,7 +230,7 @@ class DoubleToStringConverter {
+   // kMaxExponentialDigits + 8 characters (the sign, the digit before the
+   // decimal point, the decimal point, the exponent character, the
+   // exponent's sign, and at most 3 exponent digits).
+-  bool ToExponential(double value,
++  MFBT_API bool ToExponential(double value,
+                      int requested_digits,
+                      StringBuilder* result_builder) const;
+ 
+@@ -267,7 +268,7 @@ class DoubleToStringConverter {
+   // The last condition implies that the result will never contain more than
+   // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
+   // exponent character, the exponent's sign, and at most 3 exponent digits).
+-  bool ToPrecision(double value,
++  MFBT_API bool ToPrecision(double value,
+                    int precision,
+                    StringBuilder* result_builder) const;
+ 
+@@ -292,7 +293,7 @@ class DoubleToStringConverter {
+   // kBase10MaximalLength.
+   // Note that DoubleToAscii null-terminates its input. So the given buffer
+   // should be at least kBase10MaximalLength + 1 characters long.
+-  static const int kBase10MaximalLength = 17;
++  static const MFBT_DATA int kBase10MaximalLength = 17;
+ 
+   // Converts the given double 'v' to ascii. 'v' must not be NaN, +Infinity, or
+   // -Infinity. In SHORTEST_SINGLE-mode this restriction also applies to 'v'
+@@ -332,7 +333,7 @@ class DoubleToStringConverter {
+   // terminating null-character when computing the maximal output size.
+   // The given length is only used in debug mode to ensure the buffer is big
+   // enough.
+-  static void DoubleToAscii(double v,
++  static MFBT_API void DoubleToAscii(double v,
+                             DtoaMode mode,
+                             int requested_digits,
+                             char* buffer,
+@@ -343,7 +344,7 @@ class DoubleToStringConverter {
+ 
+  private:
+   // Implementation for ToShortest and ToShortestSingle.
+-  bool ToShortestIeeeNumber(double value,
++  MFBT_API bool ToShortestIeeeNumber(double value,
+                             StringBuilder* result_builder,
+                             DtoaMode mode) const;
+ 
+@@ -351,15 +352,15 @@ class DoubleToStringConverter {
+   // corresponding string using the configured infinity/nan-symbol.
+   // If either of them is NULL or the value is not special then the
+   // function returns false.
+-  bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
++  MFBT_API bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
+   // Constructs an exponential representation (i.e. 1.234e56).
+   // The given exponent assumes a decimal point after the first decimal digit.
+-  void CreateExponentialRepresentation(const char* decimal_digits,
++  MFBT_API void CreateExponentialRepresentation(const char* decimal_digits,
+                                        int length,
+                                        int exponent,
+                                        StringBuilder* result_builder) const;
+   // Creates a decimal representation (i.e 1234.5678).
+-  void CreateDecimalRepresentation(const char* decimal_digits,
++  MFBT_API void CreateDecimalRepresentation(const char* decimal_digits,
+                                    int length,
+                                    int decimal_point,
+                                    int digits_after_point,
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/bignum-dtoa.cc b/src/third_party/mozjs-45/mfbt/double-conversion/bignum-dtoa.cc
new file mode 100644
index 0000000..b6c2e85
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/bignum-dtoa.cc
@@ -0,0 +1,640 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <math.h>
+
+#include "bignum-dtoa.h"
+
+#include "bignum.h"
+#include "ieee.h"
+
+namespace double_conversion {
+
+static int NormalizedExponent(uint64_t significand, int exponent) {
+  ASSERT(significand != 0);
+  while ((significand & Double::kHiddenBit) == 0) {
+    significand = significand << 1;
+    exponent = exponent - 1;
+  }
+  return exponent;
+}
+
+
+// Forward declarations:
+// Returns an estimation of k such that 10^(k-1) <= v < 10^k.
+static int EstimatePower(int exponent);
+// Computes v / 10^estimated_power exactly, as a ratio of two bignums, numerator
+// and denominator.
+static void InitialScaledStartValues(uint64_t significand,
+                                     int exponent,
+                                     bool lower_boundary_is_closer,
+                                     int estimated_power,
+                                     bool need_boundary_deltas,
+                                     Bignum* numerator,
+                                     Bignum* denominator,
+                                     Bignum* delta_minus,
+                                     Bignum* delta_plus);
+// Multiplies numerator/denominator so that its values lies in the range 1-10.
+// Returns decimal_point s.t.
+//  v = numerator'/denominator' * 10^(decimal_point-1)
+//     where numerator' and denominator' are the values of numerator and
+//     denominator after the call to this function.
+static void FixupMultiply10(int estimated_power, bool is_even,
+                            int* decimal_point,
+                            Bignum* numerator, Bignum* denominator,
+                            Bignum* delta_minus, Bignum* delta_plus);
+// Generates digits from the left to the right and stops when the generated
+// digits yield the shortest decimal representation of v.
+static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator,
+                                   Bignum* delta_minus, Bignum* delta_plus,
+                                   bool is_even,
+                                   Vector<char> buffer, int* length);
+// Generates 'requested_digits' after the decimal point.
+static void BignumToFixed(int requested_digits, int* decimal_point,
+                          Bignum* numerator, Bignum* denominator,
+                          Vector<char>(buffer), int* length);
+// Generates 'count' digits of numerator/denominator.
+// Once 'count' digits have been produced rounds the result depending on the
+// remainder (remainders of exactly .5 round upwards). Might update the
+// decimal_point when rounding up (for example for 0.9999).
+static void GenerateCountedDigits(int count, int* decimal_point,
+                                  Bignum* numerator, Bignum* denominator,
+                                  Vector<char>(buffer), int* length);
+
+
+void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits,
+                Vector<char> buffer, int* length, int* decimal_point) {
+  ASSERT(v > 0);
+  ASSERT(!Double(v).IsSpecial());
+  uint64_t significand;
+  int exponent;
+  bool lower_boundary_is_closer;
+  if (mode == BIGNUM_DTOA_SHORTEST_SINGLE) {
+    float f = static_cast<float>(v);
+    ASSERT(f == v);
+    significand = Single(f).Significand();
+    exponent = Single(f).Exponent();
+    lower_boundary_is_closer = Single(f).LowerBoundaryIsCloser();
+  } else {
+    significand = Double(v).Significand();
+    exponent = Double(v).Exponent();
+    lower_boundary_is_closer = Double(v).LowerBoundaryIsCloser();
+  }
+  bool need_boundary_deltas =
+      (mode == BIGNUM_DTOA_SHORTEST || mode == BIGNUM_DTOA_SHORTEST_SINGLE);
+
+  bool is_even = (significand & 1) == 0;
+  int normalized_exponent = NormalizedExponent(significand, exponent);
+  // estimated_power might be too low by 1.
+  int estimated_power = EstimatePower(normalized_exponent);
+
+  // Shortcut for Fixed.
+  // The requested digits correspond to the digits after the point. If the
+  // number is much too small, then there is no need in trying to get any
+  // digits.
+  if (mode == BIGNUM_DTOA_FIXED && -estimated_power - 1 > requested_digits) {
+    buffer[0] = '\0';
+    *length = 0;
+    // Set decimal-point to -requested_digits. This is what Gay does.
+    // Note that it should not have any effect anyways since the string is
+    // empty.
+    *decimal_point = -requested_digits;
+    return;
+  }
+
+  Bignum numerator;
+  Bignum denominator;
+  Bignum delta_minus;
+  Bignum delta_plus;
+  // Make sure the bignum can grow large enough. The smallest double equals
+  // 4e-324. In this case the denominator needs fewer than 324*4 binary digits.
+  // The maximum double is 1.7976931348623157e308 which needs fewer than
+  // 308*4 binary digits.
+  ASSERT(Bignum::kMaxSignificantBits >= 324*4);
+  InitialScaledStartValues(significand, exponent, lower_boundary_is_closer,
+                           estimated_power, need_boundary_deltas,
+                           &numerator, &denominator,
+                           &delta_minus, &delta_plus);
+  // We now have v = (numerator / denominator) * 10^estimated_power.
+  FixupMultiply10(estimated_power, is_even, decimal_point,
+                  &numerator, &denominator,
+                  &delta_minus, &delta_plus);
+  // We now have v = (numerator / denominator) * 10^(decimal_point-1), and
+  //  1 <= (numerator + delta_plus) / denominator < 10
+  switch (mode) {
+    case BIGNUM_DTOA_SHORTEST:
+    case BIGNUM_DTOA_SHORTEST_SINGLE:
+      GenerateShortestDigits(&numerator, &denominator,
+                             &delta_minus, &delta_plus,
+                             is_even, buffer, length);
+      break;
+    case BIGNUM_DTOA_FIXED:
+      BignumToFixed(requested_digits, decimal_point,
+                    &numerator, &denominator,
+                    buffer, length);
+      break;
+    case BIGNUM_DTOA_PRECISION:
+      GenerateCountedDigits(requested_digits, decimal_point,
+                            &numerator, &denominator,
+                            buffer, length);
+      break;
+    default:
+      UNREACHABLE();
+  }
+  buffer[*length] = '\0';
+}
+
+
+// The procedure starts generating digits from the left to the right and stops
+// when the generated digits yield the shortest decimal representation of v. A
+// decimal representation of v is a number lying closer to v than to any other
+// double, so it converts to v when read.
+//
+// This is true if d, the decimal representation, is between m- and m+, the
+// upper and lower boundaries. d must be strictly between them if !is_even.
+//           m- := (numerator - delta_minus) / denominator
+//           m+ := (numerator + delta_plus) / denominator
+//
+// Precondition: 0 <= (numerator+delta_plus) / denominator < 10.
+//   If 1 <= (numerator+delta_plus) / denominator < 10 then no leading 0 digit
+//   will be produced. This should be the standard precondition.
+static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator,
+                                   Bignum* delta_minus, Bignum* delta_plus,
+                                   bool is_even,
+                                   Vector<char> buffer, int* length) {
+  // Small optimization: if delta_minus and delta_plus are the same just reuse
+  // one of the two bignums.
+  if (Bignum::Equal(*delta_minus, *delta_plus)) {
+    delta_plus = delta_minus;
+  }
+  *length = 0;
+  while (true) {
+    uint16_t digit;
+    digit = numerator->DivideModuloIntBignum(*denominator);
+    ASSERT(digit <= 9);  // digit is a uint16_t and therefore always positive.
+    // digit = numerator / denominator (integer division).
+    // numerator = numerator % denominator.
+    buffer[(*length)++] = digit + '0';
+
+    // Can we stop already?
+    // If the remainder of the division is less than the distance to the lower
+    // boundary we can stop. In this case we simply round down (discarding the
+    // remainder).
+    // Similarly we test if we can round up (using the upper boundary).
+    bool in_delta_room_minus;
+    bool in_delta_room_plus;
+    if (is_even) {
+      in_delta_room_minus = Bignum::LessEqual(*numerator, *delta_minus);
+    } else {
+      in_delta_room_minus = Bignum::Less(*numerator, *delta_minus);
+    }
+    if (is_even) {
+      in_delta_room_plus =
+          Bignum::PlusCompare(*numerator, *delta_plus, *denominator) >= 0;
+    } else {
+      in_delta_room_plus =
+          Bignum::PlusCompare(*numerator, *delta_plus, *denominator) > 0;
+    }
+    if (!in_delta_room_minus && !in_delta_room_plus) {
+      // Prepare for next iteration.
+      numerator->Times10();
+      delta_minus->Times10();
+      // We optimized delta_plus to be equal to delta_minus (if they share the
+      // same value). So don't multiply delta_plus if they point to the same
+      // object.
+      if (delta_minus != delta_plus) {
+        delta_plus->Times10();
+      }
+    } else if (in_delta_room_minus && in_delta_room_plus) {
+      // Let's see if 2*numerator < denominator.
+      // If yes, then the next digit would be < 5 and we can round down.
+      int compare = Bignum::PlusCompare(*numerator, *numerator, *denominator);
+      if (compare < 0) {
+        // Remaining digits are less than .5. -> Round down (== do nothing).
+      } else if (compare > 0) {
+        // Remaining digits are more than .5 of denominator. -> Round up.
+        // Note that the last digit could not be a '9' as otherwise the whole
+        // loop would have stopped earlier.
+        // We still have an assert here in case the preconditions were not
+        // satisfied.
+        ASSERT(buffer[(*length) - 1] != '9');
+        buffer[(*length) - 1]++;
+      } else {
+        // Halfway case.
+        // TODO(floitsch): need a way to solve half-way cases.
+        //   For now let's round towards even (since this is what Gay seems to
+        //   do).
+
+        if ((buffer[(*length) - 1] - '0') % 2 == 0) {
+          // Round down => Do nothing.
+        } else {
+          ASSERT(buffer[(*length) - 1] != '9');
+          buffer[(*length) - 1]++;
+        }
+      }
+      return;
+    } else if (in_delta_room_minus) {
+      // Round down (== do nothing).
+      return;
+    } else {  // in_delta_room_plus
+      // Round up.
+      // Note again that the last digit could not be '9' since this would have
+      // stopped the loop earlier.
+      // We still have an ASSERT here, in case the preconditions were not
+      // satisfied.
+      ASSERT(buffer[(*length) -1] != '9');
+      buffer[(*length) - 1]++;
+      return;
+    }
+  }
+}
+
+
+// Let v = numerator / denominator < 10.
+// Then we generate 'count' digits of d = x.xxxxx... (without the decimal point)
+// from left to right. Once 'count' digits have been produced we decide wether
+// to round up or down. Remainders of exactly .5 round upwards. Numbers such
+// as 9.999999 propagate a carry all the way, and change the
+// exponent (decimal_point), when rounding upwards.
+static void GenerateCountedDigits(int count, int* decimal_point,
+                                  Bignum* numerator, Bignum* denominator,
+                                  Vector<char>(buffer), int* length) {
+  ASSERT(count >= 0);
+  for (int i = 0; i < count - 1; ++i) {
+    uint16_t digit;
+    digit = numerator->DivideModuloIntBignum(*denominator);
+    ASSERT(digit <= 9);  // digit is a uint16_t and therefore always positive.
+    // digit = numerator / denominator (integer division).
+    // numerator = numerator % denominator.
+    buffer[i] = digit + '0';
+    // Prepare for next iteration.
+    numerator->Times10();
+  }
+  // Generate the last digit.
+  uint16_t digit;
+  digit = numerator->DivideModuloIntBignum(*denominator);
+  if (Bignum::PlusCompare(*numerator, *numerator, *denominator) >= 0) {
+    digit++;
+  }
+  buffer[count - 1] = digit + '0';
+  // Correct bad digits (in case we had a sequence of '9's). Propagate the
+  // carry until we hat a non-'9' or til we reach the first digit.
+  for (int i = count - 1; i > 0; --i) {
+    if (buffer[i] != '0' + 10) break;
+    buffer[i] = '0';
+    buffer[i - 1]++;
+  }
+  if (buffer[0] == '0' + 10) {
+    // Propagate a carry past the top place.
+    buffer[0] = '1';
+    (*decimal_point)++;
+  }
+  *length = count;
+}
+
+
+// Generates 'requested_digits' after the decimal point. It might omit
+// trailing '0's. If the input number is too small then no digits at all are
+// generated (ex.: 2 fixed digits for 0.00001).
+//
+// Input verifies:  1 <= (numerator + delta) / denominator < 10.
+static void BignumToFixed(int requested_digits, int* decimal_point,
+                          Bignum* numerator, Bignum* denominator,
+                          Vector<char>(buffer), int* length) {
+  // Note that we have to look at more than just the requested_digits, since
+  // a number could be rounded up. Example: v=0.5 with requested_digits=0.
+  // Even though the power of v equals 0 we can't just stop here.
+  if (-(*decimal_point) > requested_digits) {
+    // The number is definitively too small.
+    // Ex: 0.001 with requested_digits == 1.
+    // Set decimal-point to -requested_digits. This is what Gay does.
+    // Note that it should not have any effect anyways since the string is
+    // empty.
+    *decimal_point = -requested_digits;
+    *length = 0;
+    return;
+  } else if (-(*decimal_point) == requested_digits) {
+    // We only need to verify if the number rounds down or up.
+    // Ex: 0.04 and 0.06 with requested_digits == 1.
+    ASSERT(*decimal_point == -requested_digits);
+    // Initially the fraction lies in range (1, 10]. Multiply the denominator
+    // by 10 so that we can compare more easily.
+    denominator->Times10();
+    if (Bignum::PlusCompare(*numerator, *numerator, *denominator) >= 0) {
+      // If the fraction is >= 0.5 then we have to include the rounded
+      // digit.
+      buffer[0] = '1';
+      *length = 1;
+      (*decimal_point)++;
+    } else {
+      // Note that we caught most of similar cases earlier.
+      *length = 0;
+    }
+    return;
+  } else {
+    // The requested digits correspond to the digits after the point.
+    // The variable 'needed_digits' includes the digits before the point.
+    int needed_digits = (*decimal_point) + requested_digits;
+    GenerateCountedDigits(needed_digits, decimal_point,
+                          numerator, denominator,
+                          buffer, length);
+  }
+}
+
+
+// Returns an estimation of k such that 10^(k-1) <= v < 10^k where
+// v = f * 2^exponent and 2^52 <= f < 2^53.
+// v is hence a normalized double with the given exponent. The output is an
+// approximation for the exponent of the decimal approimation .digits * 10^k.
+//
+// The result might undershoot by 1 in which case 10^k <= v < 10^k+1.
+// Note: this property holds for v's upper boundary m+ too.
+//    10^k <= m+ < 10^k+1.
+//   (see explanation below).
+//
+// Examples:
+//  EstimatePower(0)   => 16
+//  EstimatePower(-52) => 0
+//
+// Note: e >= 0 => EstimatedPower(e) > 0. No similar claim can be made for e<0.
+static int EstimatePower(int exponent) {
+  // This function estimates log10 of v where v = f*2^e (with e == exponent).
+  // Note that 10^floor(log10(v)) <= v, but v <= 10^ceil(log10(v)).
+  // Note that f is bounded by its container size. Let p = 53 (the double's
+  // significand size). Then 2^(p-1) <= f < 2^p.
+  //
+  // Given that log10(v) == log2(v)/log2(10) and e+(len(f)-1) is quite close
+  // to log2(v) the function is simplified to (e+(len(f)-1)/log2(10)).
+  // The computed number undershoots by less than 0.631 (when we compute log3
+  // and not log10).
+  //
+  // Optimization: since we only need an approximated result this computation
+  // can be performed on 64 bit integers. On x86/x64 architecture the speedup is
+  // not really measurable, though.
+  //
+  // Since we want to avoid overshooting we decrement by 1e10 so that
+  // floating-point imprecisions don't affect us.
+  //
+  // Explanation for v's boundary m+: the computation takes advantage of
+  // the fact that 2^(p-1) <= f < 2^p. Boundaries still satisfy this requirement
+  // (even for denormals where the delta can be much more important).
+
+  const double k1Log10 = 0.30102999566398114;  // 1/lg(10)
+
+  // For doubles len(f) == 53 (don't forget the hidden bit).
+  const int kSignificandSize = Double::kSignificandSize;
+  double estimate = ceil((exponent + kSignificandSize - 1) * k1Log10 - 1e-10);
+  return static_cast<int>(estimate);
+}
+
+
+// See comments for InitialScaledStartValues.
+static void InitialScaledStartValuesPositiveExponent(
+    uint64_t significand, int exponent,
+    int estimated_power, bool need_boundary_deltas,
+    Bignum* numerator, Bignum* denominator,
+    Bignum* delta_minus, Bignum* delta_plus) {
+  // A positive exponent implies a positive power.
+  ASSERT(estimated_power >= 0);
+  // Since the estimated_power is positive we simply multiply the denominator
+  // by 10^estimated_power.
+
+  // numerator = v.
+  numerator->AssignUInt64(significand);
+  numerator->ShiftLeft(exponent);
+  // denominator = 10^estimated_power.
+  denominator->AssignPowerUInt16(10, estimated_power);
+
+  if (need_boundary_deltas) {
+    // Introduce a common denominator so that the deltas to the boundaries are
+    // integers.
+    denominator->ShiftLeft(1);
+    numerator->ShiftLeft(1);
+    // Let v = f * 2^e, then m+ - v = 1/2 * 2^e; With the common
+    // denominator (of 2) delta_plus equals 2^e.
+    delta_plus->AssignUInt16(1);
+    delta_plus->ShiftLeft(exponent);
+    // Same for delta_minus. The adjustments if f == 2^p-1 are done later.
+    delta_minus->AssignUInt16(1);
+    delta_minus->ShiftLeft(exponent);
+  }
+}
+
+
+// See comments for InitialScaledStartValues
+static void InitialScaledStartValuesNegativeExponentPositivePower(
+    uint64_t significand, int exponent,
+    int estimated_power, bool need_boundary_deltas,
+    Bignum* numerator, Bignum* denominator,
+    Bignum* delta_minus, Bignum* delta_plus) {
+  // v = f * 2^e with e < 0, and with estimated_power >= 0.
+  // This means that e is close to 0 (have a look at how estimated_power is
+  // computed).
+
+  // numerator = significand
+  //  since v = significand * 2^exponent this is equivalent to
+  //  numerator = v * / 2^-exponent
+  numerator->AssignUInt64(significand);
+  // denominator = 10^estimated_power * 2^-exponent (with exponent < 0)
+  denominator->AssignPowerUInt16(10, estimated_power);
+  denominator->ShiftLeft(-exponent);
+
+  if (need_boundary_deltas) {
+    // Introduce a common denominator so that the deltas to the boundaries are
+    // integers.
+    denominator->ShiftLeft(1);
+    numerator->ShiftLeft(1);
+    // Let v = f * 2^e, then m+ - v = 1/2 * 2^e; With the common
+    // denominator (of 2) delta_plus equals 2^e.
+    // Given that the denominator already includes v's exponent the distance
+    // to the boundaries is simply 1.
+    delta_plus->AssignUInt16(1);
+    // Same for delta_minus. The adjustments if f == 2^p-1 are done later.
+    delta_minus->AssignUInt16(1);
+  }
+}
+
+
+// See comments for InitialScaledStartValues
+static void InitialScaledStartValuesNegativeExponentNegativePower(
+    uint64_t significand, int exponent,
+    int estimated_power, bool need_boundary_deltas,
+    Bignum* numerator, Bignum* denominator,
+    Bignum* delta_minus, Bignum* delta_plus) {
+  // Instead of multiplying the denominator with 10^estimated_power we
+  // multiply all values (numerator and deltas) by 10^-estimated_power.
+
+  // Use numerator as temporary container for power_ten.
+  Bignum* power_ten = numerator;
+  power_ten->AssignPowerUInt16(10, -estimated_power);
+
+  if (need_boundary_deltas) {
+    // Since power_ten == numerator we must make a copy of 10^estimated_power
+    // before we complete the computation of the numerator.
+    // delta_plus = delta_minus = 10^estimated_power
+    delta_plus->AssignBignum(*power_ten);
+    delta_minus->AssignBignum(*power_ten);
+  }
+
+  // numerator = significand * 2 * 10^-estimated_power
+  //  since v = significand * 2^exponent this is equivalent to
+  // numerator = v * 10^-estimated_power * 2 * 2^-exponent.
+  // Remember: numerator has been abused as power_ten. So no need to assign it
+  //  to itself.
+  ASSERT(numerator == power_ten);
+  numerator->MultiplyByUInt64(significand);
+
+  // denominator = 2 * 2^-exponent with exponent < 0.
+  denominator->AssignUInt16(1);
+  denominator->ShiftLeft(-exponent);
+
+  if (need_boundary_deltas) {
+    // Introduce a common denominator so that the deltas to the boundaries are
+    // integers.
+    numerator->ShiftLeft(1);
+    denominator->ShiftLeft(1);
+    // With this shift the boundaries have their correct value, since
+    // delta_plus = 10^-estimated_power, and
+    // delta_minus = 10^-estimated_power.
+    // These assignments have been done earlier.
+    // The adjustments if f == 2^p-1 (lower boundary is closer) are done later.
+  }
+}
+
+
+// Let v = significand * 2^exponent.
+// Computes v / 10^estimated_power exactly, as a ratio of two bignums, numerator
+// and denominator. The functions GenerateShortestDigits and
+// GenerateCountedDigits will then convert this ratio to its decimal
+// representation d, with the required accuracy.
+// Then d * 10^estimated_power is the representation of v.
+// (Note: the fraction and the estimated_power might get adjusted before
+// generating the decimal representation.)
+//
+// The initial start values consist of:
+//  - a scaled numerator: s.t. numerator/denominator == v / 10^estimated_power.
+//  - a scaled (common) denominator.
+//  optionally (used by GenerateShortestDigits to decide if it has the shortest
+//  decimal converting back to v):
+//  - v - m-: the distance to the lower boundary.
+//  - m+ - v: the distance to the upper boundary.
+//
+// v, m+, m-, and therefore v - m- and m+ - v all share the same denominator.
+//
+// Let ep == estimated_power, then the returned values will satisfy:
+//  v / 10^ep = numerator / denominator.
+//  v's boundarys m- and m+:
+//    m- / 10^ep == v / 10^ep - delta_minus / denominator
+//    m+ / 10^ep == v / 10^ep + delta_plus / denominator
+//  Or in other words:
+//    m- == v - delta_minus * 10^ep / denominator;
+//    m+ == v + delta_plus * 10^ep / denominator;
+//
+// Since 10^(k-1) <= v < 10^k    (with k == estimated_power)
+//  or       10^k <= v < 10^(k+1)
+//  we then have 0.1 <= numerator/denominator < 1
+//           or    1 <= numerator/denominator < 10
+//
+// It is then easy to kickstart the digit-generation routine.
+//
+// The boundary-deltas are only filled if the mode equals BIGNUM_DTOA_SHORTEST
+// or BIGNUM_DTOA_SHORTEST_SINGLE.
+
+static void InitialScaledStartValues(uint64_t significand,
+                                     int exponent,
+                                     bool lower_boundary_is_closer,
+                                     int estimated_power,
+                                     bool need_boundary_deltas,
+                                     Bignum* numerator,
+                                     Bignum* denominator,
+                                     Bignum* delta_minus,
+                                     Bignum* delta_plus) {
+  if (exponent >= 0) {
+    InitialScaledStartValuesPositiveExponent(
+        significand, exponent, estimated_power, need_boundary_deltas,
+        numerator, denominator, delta_minus, delta_plus);
+  } else if (estimated_power >= 0) {
+    InitialScaledStartValuesNegativeExponentPositivePower(
+        significand, exponent, estimated_power, need_boundary_deltas,
+        numerator, denominator, delta_minus, delta_plus);
+  } else {
+    InitialScaledStartValuesNegativeExponentNegativePower(
+        significand, exponent, estimated_power, need_boundary_deltas,
+        numerator, denominator, delta_minus, delta_plus);
+  }
+
+  if (need_boundary_deltas && lower_boundary_is_closer) {
+    // The lower boundary is closer at half the distance of "normal" numbers.
+    // Increase the common denominator and adapt all but the delta_minus.
+    denominator->ShiftLeft(1);  // *2
+    numerator->ShiftLeft(1);    // *2
+    delta_plus->ShiftLeft(1);   // *2
+  }
+}
+
+
+// This routine multiplies numerator/denominator so that its values lies in the
+// range 1-10. That is after a call to this function we have:
+//    1 <= (numerator + delta_plus) /denominator < 10.
+// Let numerator the input before modification and numerator' the argument
+// after modification, then the output-parameter decimal_point is such that
+//  numerator / denominator * 10^estimated_power ==
+//    numerator' / denominator' * 10^(decimal_point - 1)
+// In some cases estimated_power was too low, and this is already the case. We
+// then simply adjust the power so that 10^(k-1) <= v < 10^k (with k ==
+// estimated_power) but do not touch the numerator or denominator.
+// Otherwise the routine multiplies the numerator and the deltas by 10.
+static void FixupMultiply10(int estimated_power, bool is_even,
+                            int* decimal_point,
+                            Bignum* numerator, Bignum* denominator,
+                            Bignum* delta_minus, Bignum* delta_plus) {
+  bool in_range;
+  if (is_even) {
+    // For IEEE doubles half-way cases (in decimal system numbers ending with 5)
+    // are rounded to the closest floating-point number with even significand.
+    in_range = Bignum::PlusCompare(*numerator, *delta_plus, *denominator) >= 0;
+  } else {
+    in_range = Bignum::PlusCompare(*numerator, *delta_plus, *denominator) > 0;
+  }
+  if (in_range) {
+    // Since numerator + delta_plus >= denominator we already have
+    // 1 <= numerator/denominator < 10. Simply update the estimated_power.
+    *decimal_point = estimated_power + 1;
+  } else {
+    *decimal_point = estimated_power;
+    numerator->Times10();
+    if (Bignum::Equal(*delta_minus, *delta_plus)) {
+      delta_minus->Times10();
+      delta_plus->AssignBignum(*delta_minus);
+    } else {
+      delta_minus->Times10();
+      delta_plus->Times10();
+    }
+  }
+}
+
+}  // namespace double_conversion
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/bignum-dtoa.h b/src/third_party/mozjs-45/mfbt/double-conversion/bignum-dtoa.h
new file mode 100644
index 0000000..34b9619
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/bignum-dtoa.h
@@ -0,0 +1,84 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_BIGNUM_DTOA_H_
+#define DOUBLE_CONVERSION_BIGNUM_DTOA_H_
+
+#include "utils.h"
+
+namespace double_conversion {
+
+enum BignumDtoaMode {
+  // Return the shortest correct representation.
+  // For example the output of 0.299999999999999988897 is (the less accurate but
+  // correct) 0.3.
+  BIGNUM_DTOA_SHORTEST,
+  // Same as BIGNUM_DTOA_SHORTEST but for single-precision floats.
+  BIGNUM_DTOA_SHORTEST_SINGLE,
+  // Return a fixed number of digits after the decimal point.
+  // For instance fixed(0.1, 4) becomes 0.1000
+  // If the input number is big, the output will be big.
+  BIGNUM_DTOA_FIXED,
+  // Return a fixed number of digits, no matter what the exponent is.
+  BIGNUM_DTOA_PRECISION
+};
+
+// Converts the given double 'v' to ascii.
+// The result should be interpreted as buffer * 10^(point-length).
+// The buffer will be null-terminated.
+//
+// The input v must be > 0 and different from NaN, and Infinity.
+//
+// The output depends on the given mode:
+//  - SHORTEST: produce the least amount of digits for which the internal
+//   identity requirement is still satisfied. If the digits are printed
+//   (together with the correct exponent) then reading this number will give
+//   'v' again. The buffer will choose the representation that is closest to
+//   'v'. If there are two at the same distance, than the number is round up.
+//   In this mode the 'requested_digits' parameter is ignored.
+//  - FIXED: produces digits necessary to print a given number with
+//   'requested_digits' digits after the decimal point. The produced digits
+//   might be too short in which case the caller has to fill the gaps with '0's.
+//   Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2.
+//   Halfway cases are rounded up. The call toFixed(0.15, 2) thus returns
+//     buffer="2", point=0.
+//   Note: the length of the returned buffer has no meaning wrt the significance
+//   of its digits. That is, just because it contains '0's does not mean that
+//   any other digit would not satisfy the internal identity requirement.
+//  - PRECISION: produces 'requested_digits' where the first digit is not '0'.
+//   Even though the length of produced digits usually equals
+//   'requested_digits', the function is allowed to return fewer digits, in
+//   which case the caller has to fill the missing digits with '0's.
+//   Halfway cases are again rounded up.
+// 'BignumDtoa' expects the given buffer to be big enough to hold all digits
+// and a terminating null-character.
+void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits,
+                Vector<char> buffer, int* length, int* point);
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_BIGNUM_DTOA_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/bignum.cc b/src/third_party/mozjs-45/mfbt/double-conversion/bignum.cc
new file mode 100644
index 0000000..dc8a2a6
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/bignum.cc
@@ -0,0 +1,763 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "bignum.h"
+#include "utils.h"
+
+namespace double_conversion {
+
+Bignum::Bignum()
+    : bigits_(bigits_buffer_, kBigitCapacity), used_digits_(0), exponent_(0) {
+  for (int i = 0; i < kBigitCapacity; ++i) {
+    bigits_[i] = 0;
+  }
+}
+
+
+template<typename S>
+static int BitSize(S value) {
+  return 8 * sizeof(value);
+}
+
+// Guaranteed to lie in one Bigit.
+void Bignum::AssignUInt16(uint16_t value) {
+  ASSERT(kBigitSize >= BitSize(value));
+  Zero();
+  if (value == 0) return;
+
+  EnsureCapacity(1);
+  bigits_[0] = value;
+  used_digits_ = 1;
+}
+
+
+void Bignum::AssignUInt64(uint64_t value) {
+  const int kUInt64Size = 64;
+
+  Zero();
+  if (value == 0) return;
+
+  int needed_bigits = kUInt64Size / kBigitSize + 1;
+  EnsureCapacity(needed_bigits);
+  for (int i = 0; i < needed_bigits; ++i) {
+    bigits_[i] = value & kBigitMask;
+    value = value >> kBigitSize;
+  }
+  used_digits_ = needed_bigits;
+  Clamp();
+}
+
+
+void Bignum::AssignBignum(const Bignum& other) {
+  exponent_ = other.exponent_;
+  for (int i = 0; i < other.used_digits_; ++i) {
+    bigits_[i] = other.bigits_[i];
+  }
+  // Clear the excess digits (if there were any).
+  for (int i = other.used_digits_; i < used_digits_; ++i) {
+    bigits_[i] = 0;
+  }
+  used_digits_ = other.used_digits_;
+}
+
+
+static uint64_t ReadUInt64(Vector<const char> buffer,
+                           int from,
+                           int digits_to_read) {
+  uint64_t result = 0;
+  for (int i = from; i < from + digits_to_read; ++i) {
+    int digit = buffer[i] - '0';
+    ASSERT(0 <= digit && digit <= 9);
+    result = result * 10 + digit;
+  }
+  return result;
+}
+
+
+void Bignum::AssignDecimalString(Vector<const char> value) {
+  // 2^64 = 18446744073709551616 > 10^19
+  const int kMaxUint64DecimalDigits = 19;
+  Zero();
+  int length = value.length();
+  int pos = 0;
+  // Let's just say that each digit needs 4 bits.
+  while (length >= kMaxUint64DecimalDigits) {
+    uint64_t digits = ReadUInt64(value, pos, kMaxUint64DecimalDigits);
+    pos += kMaxUint64DecimalDigits;
+    length -= kMaxUint64DecimalDigits;
+    MultiplyByPowerOfTen(kMaxUint64DecimalDigits);
+    AddUInt64(digits);
+  }
+  uint64_t digits = ReadUInt64(value, pos, length);
+  MultiplyByPowerOfTen(length);
+  AddUInt64(digits);
+  Clamp();
+}
+
+
+static int HexCharValue(char c) {
+  if ('0' <= c && c <= '9') return c - '0';
+  if ('a' <= c && c <= 'f') return 10 + c - 'a';
+  if ('A' <= c && c <= 'F') return 10 + c - 'A';
+  UNREACHABLE();
+  return 0;  // To make compiler happy.
+}
+
+
+void Bignum::AssignHexString(Vector<const char> value) {
+  Zero();
+  int length = value.length();
+
+  int needed_bigits = length * 4 / kBigitSize + 1;
+  EnsureCapacity(needed_bigits);
+  int string_index = length - 1;
+  for (int i = 0; i < needed_bigits - 1; ++i) {
+    // These bigits are guaranteed to be "full".
+    Chunk current_bigit = 0;
+    for (int j = 0; j < kBigitSize / 4; j++) {
+      current_bigit += HexCharValue(value[string_index--]) << (j * 4);
+    }
+    bigits_[i] = current_bigit;
+  }
+  used_digits_ = needed_bigits - 1;
+
+  Chunk most_significant_bigit = 0;  // Could be = 0;
+  for (int j = 0; j <= string_index; ++j) {
+    most_significant_bigit <<= 4;
+    most_significant_bigit += HexCharValue(value[j]);
+  }
+  if (most_significant_bigit != 0) {
+    bigits_[used_digits_] = most_significant_bigit;
+    used_digits_++;
+  }
+  Clamp();
+}
+
+
+void Bignum::AddUInt64(uint64_t operand) {
+  if (operand == 0) return;
+  Bignum other;
+  other.AssignUInt64(operand);
+  AddBignum(other);
+}
+
+
+void Bignum::AddBignum(const Bignum& other) {
+  ASSERT(IsClamped());
+  ASSERT(other.IsClamped());
+
+  // If this has a greater exponent than other append zero-bigits to this.
+  // After this call exponent_ <= other.exponent_.
+  Align(other);
+
+  // There are two possibilities:
+  //   aaaaaaaaaaa 0000  (where the 0s represent a's exponent)
+  //     bbbbb 00000000
+  //   ----------------
+  //   ccccccccccc 0000
+  // or
+  //    aaaaaaaaaa 0000
+  //  bbbbbbbbb 0000000
+  //  -----------------
+  //  cccccccccccc 0000
+  // In both cases we might need a carry bigit.
+
+  EnsureCapacity(1 + Max(BigitLength(), other.BigitLength()) - exponent_);
+  Chunk carry = 0;
+  int bigit_pos = other.exponent_ - exponent_;
+  ASSERT(bigit_pos >= 0);
+  for (int i = 0; i < other.used_digits_; ++i) {
+    Chunk sum = bigits_[bigit_pos] + other.bigits_[i] + carry;
+    bigits_[bigit_pos] = sum & kBigitMask;
+    carry = sum >> kBigitSize;
+    bigit_pos++;
+  }
+
+  while (carry != 0) {
+    Chunk sum = bigits_[bigit_pos] + carry;
+    bigits_[bigit_pos] = sum & kBigitMask;
+    carry = sum >> kBigitSize;
+    bigit_pos++;
+  }
+  used_digits_ = Max(bigit_pos, used_digits_);
+  ASSERT(IsClamped());
+}
+
+
+void Bignum::SubtractBignum(const Bignum& other) {
+  ASSERT(IsClamped());
+  ASSERT(other.IsClamped());
+  // We require this to be bigger than other.
+  ASSERT(LessEqual(other, *this));
+
+  Align(other);
+
+  int offset = other.exponent_ - exponent_;
+  Chunk borrow = 0;
+  int i;
+  for (i = 0; i < other.used_digits_; ++i) {
+    ASSERT((borrow == 0) || (borrow == 1));
+    Chunk difference = bigits_[i + offset] - other.bigits_[i] - borrow;
+    bigits_[i + offset] = difference & kBigitMask;
+    borrow = difference >> (kChunkSize - 1);
+  }
+  while (borrow != 0) {
+    Chunk difference = bigits_[i + offset] - borrow;
+    bigits_[i + offset] = difference & kBigitMask;
+    borrow = difference >> (kChunkSize - 1);
+    ++i;
+  }
+  Clamp();
+}
+
+
+void Bignum::ShiftLeft(int shift_amount) {
+  if (used_digits_ == 0) return;
+  exponent_ += shift_amount / kBigitSize;
+  int local_shift = shift_amount % kBigitSize;
+  EnsureCapacity(used_digits_ + 1);
+  BigitsShiftLeft(local_shift);
+}
+
+
+void Bignum::MultiplyByUInt32(uint32_t factor) {
+  if (factor == 1) return;
+  if (factor == 0) {
+    Zero();
+    return;
+  }
+  if (used_digits_ == 0) return;
+
+  // The product of a bigit with the factor is of size kBigitSize + 32.
+  // Assert that this number + 1 (for the carry) fits into double chunk.
+  ASSERT(kDoubleChunkSize >= kBigitSize + 32 + 1);
+  DoubleChunk carry = 0;
+  for (int i = 0; i < used_digits_; ++i) {
+    DoubleChunk product = static_cast<DoubleChunk>(factor) * bigits_[i] + carry;
+    bigits_[i] = static_cast<Chunk>(product & kBigitMask);
+    carry = (product >> kBigitSize);
+  }
+  while (carry != 0) {
+    EnsureCapacity(used_digits_ + 1);
+    bigits_[used_digits_] = carry & kBigitMask;
+    used_digits_++;
+    carry >>= kBigitSize;
+  }
+}
+
+
+void Bignum::MultiplyByUInt64(uint64_t factor) {
+  if (factor == 1) return;
+  if (factor == 0) {
+    Zero();
+    return;
+  }
+  ASSERT(kBigitSize < 32);
+  uint64_t carry = 0;
+  uint64_t low = factor & 0xFFFFFFFF;
+  uint64_t high = factor >> 32;
+  for (int i = 0; i < used_digits_; ++i) {
+    uint64_t product_low = low * bigits_[i];
+    uint64_t product_high = high * bigits_[i];
+    uint64_t tmp = (carry & kBigitMask) + product_low;
+    bigits_[i] = tmp & kBigitMask;
+    carry = (carry >> kBigitSize) + (tmp >> kBigitSize) +
+        (product_high << (32 - kBigitSize));
+  }
+  while (carry != 0) {
+    EnsureCapacity(used_digits_ + 1);
+    bigits_[used_digits_] = carry & kBigitMask;
+    used_digits_++;
+    carry >>= kBigitSize;
+  }
+}
+
+
+void Bignum::MultiplyByPowerOfTen(int exponent) {
+  const uint64_t kFive27 = UINT64_2PART_C(0x6765c793, fa10079d);
+  const uint16_t kFive1 = 5;
+  const uint16_t kFive2 = kFive1 * 5;
+  const uint16_t kFive3 = kFive2 * 5;
+  const uint16_t kFive4 = kFive3 * 5;
+  const uint16_t kFive5 = kFive4 * 5;
+  const uint16_t kFive6 = kFive5 * 5;
+  const uint32_t kFive7 = kFive6 * 5;
+  const uint32_t kFive8 = kFive7 * 5;
+  const uint32_t kFive9 = kFive8 * 5;
+  const uint32_t kFive10 = kFive9 * 5;
+  const uint32_t kFive11 = kFive10 * 5;
+  const uint32_t kFive12 = kFive11 * 5;
+  const uint32_t kFive13 = kFive12 * 5;
+  const uint32_t kFive1_to_12[] =
+      { kFive1, kFive2, kFive3, kFive4, kFive5, kFive6,
+        kFive7, kFive8, kFive9, kFive10, kFive11, kFive12 };
+
+  ASSERT(exponent >= 0);
+  if (exponent == 0) return;
+  if (used_digits_ == 0) return;
+
+  // We shift by exponent at the end just before returning.
+  int remaining_exponent = exponent;
+  while (remaining_exponent >= 27) {
+    MultiplyByUInt64(kFive27);
+    remaining_exponent -= 27;
+  }
+  while (remaining_exponent >= 13) {
+    MultiplyByUInt32(kFive13);
+    remaining_exponent -= 13;
+  }
+  if (remaining_exponent > 0) {
+    MultiplyByUInt32(kFive1_to_12[remaining_exponent - 1]);
+  }
+  ShiftLeft(exponent);
+}
+
+
+void Bignum::Square() {
+  ASSERT(IsClamped());
+  int product_length = 2 * used_digits_;
+  EnsureCapacity(product_length);
+
+  // Comba multiplication: compute each column separately.
+  // Example: r = a2a1a0 * b2b1b0.
+  //    r =  1    * a0b0 +
+  //        10    * (a1b0 + a0b1) +
+  //        100   * (a2b0 + a1b1 + a0b2) +
+  //        1000  * (a2b1 + a1b2) +
+  //        10000 * a2b2
+  //
+  // In the worst case we have to accumulate nb-digits products of digit*digit.
+  //
+  // Assert that the additional number of bits in a DoubleChunk are enough to
+  // sum up used_digits of Bigit*Bigit.
+  if ((1 << (2 * (kChunkSize - kBigitSize))) <= used_digits_) {
+    UNIMPLEMENTED();
+  }
+  DoubleChunk accumulator = 0;
+  // First shift the digits so we don't overwrite them.
+  int copy_offset = used_digits_;
+  for (int i = 0; i < used_digits_; ++i) {
+    bigits_[copy_offset + i] = bigits_[i];
+  }
+  // We have two loops to avoid some 'if's in the loop.
+  for (int i = 0; i < used_digits_; ++i) {
+    // Process temporary digit i with power i.
+    // The sum of the two indices must be equal to i.
+    int bigit_index1 = i;
+    int bigit_index2 = 0;
+    // Sum all of the sub-products.
+    while (bigit_index1 >= 0) {
+      Chunk chunk1 = bigits_[copy_offset + bigit_index1];
+      Chunk chunk2 = bigits_[copy_offset + bigit_index2];
+      accumulator += static_cast<DoubleChunk>(chunk1) * chunk2;
+      bigit_index1--;
+      bigit_index2++;
+    }
+    bigits_[i] = static_cast<Chunk>(accumulator) & kBigitMask;
+    accumulator >>= kBigitSize;
+  }
+  for (int i = used_digits_; i < product_length; ++i) {
+    int bigit_index1 = used_digits_ - 1;
+    int bigit_index2 = i - bigit_index1;
+    // Invariant: sum of both indices is again equal to i.
+    // Inner loop runs 0 times on last iteration, emptying accumulator.
+    while (bigit_index2 < used_digits_) {
+      Chunk chunk1 = bigits_[copy_offset + bigit_index1];
+      Chunk chunk2 = bigits_[copy_offset + bigit_index2];
+      accumulator += static_cast<DoubleChunk>(chunk1) * chunk2;
+      bigit_index1--;
+      bigit_index2++;
+    }
+    // The overwritten bigits_[i] will never be read in further loop iterations,
+    // because bigit_index1 and bigit_index2 are always greater
+    // than i - used_digits_.
+    bigits_[i] = static_cast<Chunk>(accumulator) & kBigitMask;
+    accumulator >>= kBigitSize;
+  }
+  // Since the result was guaranteed to lie inside the number the
+  // accumulator must be 0 now.
+  ASSERT(accumulator == 0);
+
+  // Don't forget to update the used_digits and the exponent.
+  used_digits_ = product_length;
+  exponent_ *= 2;
+  Clamp();
+}
+
+
+void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) {
+  ASSERT(base != 0);
+  ASSERT(power_exponent >= 0);
+  if (power_exponent == 0) {
+    AssignUInt16(1);
+    return;
+  }
+  Zero();
+  int shifts = 0;
+  // We expect base to be in range 2-32, and most often to be 10.
+  // It does not make much sense to implement different algorithms for counting
+  // the bits.
+  while ((base & 1) == 0) {
+    base >>= 1;
+    shifts++;
+  }
+  int bit_size = 0;
+  int tmp_base = base;
+  while (tmp_base != 0) {
+    tmp_base >>= 1;
+    bit_size++;
+  }
+  int final_size = bit_size * power_exponent;
+  // 1 extra bigit for the shifting, and one for rounded final_size.
+  EnsureCapacity(final_size / kBigitSize + 2);
+
+  // Left to Right exponentiation.
+  int mask = 1;
+  while (power_exponent >= mask) mask <<= 1;
+
+  // The mask is now pointing to the bit above the most significant 1-bit of
+  // power_exponent.
+  // Get rid of first 1-bit;
+  mask >>= 2;
+  uint64_t this_value = base;
+
+  bool delayed_multipliciation = false;
+  const uint64_t max_32bits = 0xFFFFFFFF;
+  while (mask != 0 && this_value <= max_32bits) {
+    this_value = this_value * this_value;
+    // Verify that there is enough space in this_value to perform the
+    // multiplication.  The first bit_size bits must be 0.
+    if ((power_exponent & mask) != 0) {
+      uint64_t base_bits_mask =
+          ~((static_cast<uint64_t>(1) << (64 - bit_size)) - 1);
+      bool high_bits_zero = (this_value & base_bits_mask) == 0;
+      if (high_bits_zero) {
+        this_value *= base;
+      } else {
+        delayed_multipliciation = true;
+      }
+    }
+    mask >>= 1;
+  }
+  AssignUInt64(this_value);
+  if (delayed_multipliciation) {
+    MultiplyByUInt32(base);
+  }
+
+  // Now do the same thing as a bignum.
+  while (mask != 0) {
+    Square();
+    if ((power_exponent & mask) != 0) {
+      MultiplyByUInt32(base);
+    }
+    mask >>= 1;
+  }
+
+  // And finally add the saved shifts.
+  ShiftLeft(shifts * power_exponent);
+}
+
+
+// Precondition: this/other < 16bit.
+uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) {
+  ASSERT(IsClamped());
+  ASSERT(other.IsClamped());
+  ASSERT(other.used_digits_ > 0);
+
+  // Easy case: if we have less digits than the divisor than the result is 0.
+  // Note: this handles the case where this == 0, too.
+  if (BigitLength() < other.BigitLength()) {
+    return 0;
+  }
+
+  Align(other);
+
+  uint16_t result = 0;
+
+  // Start by removing multiples of 'other' until both numbers have the same
+  // number of digits.
+  while (BigitLength() > other.BigitLength()) {
+    // This naive approach is extremely inefficient if `this` divided by other
+    // is big. This function is implemented for doubleToString where
+    // the result should be small (less than 10).
+    ASSERT(other.bigits_[other.used_digits_ - 1] >= ((1 << kBigitSize) / 16));
+    // Remove the multiples of the first digit.
+    // Example this = 23 and other equals 9. -> Remove 2 multiples.
+    result += bigits_[used_digits_ - 1];
+    SubtractTimes(other, bigits_[used_digits_ - 1]);
+  }
+
+  ASSERT(BigitLength() == other.BigitLength());
+
+  // Both bignums are at the same length now.
+  // Since other has more than 0 digits we know that the access to
+  // bigits_[used_digits_ - 1] is safe.
+  Chunk this_bigit = bigits_[used_digits_ - 1];
+  Chunk other_bigit = other.bigits_[other.used_digits_ - 1];
+
+  if (other.used_digits_ == 1) {
+    // Shortcut for easy (and common) case.
+    int quotient = this_bigit / other_bigit;
+    bigits_[used_digits_ - 1] = this_bigit - other_bigit * quotient;
+    result += quotient;
+    Clamp();
+    return result;
+  }
+
+  int division_estimate = this_bigit / (other_bigit + 1);
+  result += division_estimate;
+  SubtractTimes(other, division_estimate);
+
+  if (other_bigit * (division_estimate + 1) > this_bigit) {
+    // No need to even try to subtract. Even if other's remaining digits were 0
+    // another subtraction would be too much.
+    return result;
+  }
+
+  while (LessEqual(other, *this)) {
+    SubtractBignum(other);
+    result++;
+  }
+  return result;
+}
+
+
+template<typename S>
+static int SizeInHexChars(S number) {
+  ASSERT(number > 0);
+  int result = 0;
+  while (number != 0) {
+    number >>= 4;
+    result++;
+  }
+  return result;
+}
+
+
+static char HexCharOfValue(int value) {
+  ASSERT(0 <= value && value <= 16);
+  if (value < 10) return value + '0';
+  return value - 10 + 'A';
+}
+
+
+bool Bignum::ToHexString(char* buffer, int buffer_size) const {
+  ASSERT(IsClamped());
+  // Each bigit must be printable as separate hex-character.
+  ASSERT(kBigitSize % 4 == 0);
+  const int kHexCharsPerBigit = kBigitSize / 4;
+
+  if (used_digits_ == 0) {
+    if (buffer_size < 2) return false;
+    buffer[0] = '0';
+    buffer[1] = '\0';
+    return true;
+  }
+  // We add 1 for the terminating '\0' character.
+  int needed_chars = (BigitLength() - 1) * kHexCharsPerBigit +
+      SizeInHexChars(bigits_[used_digits_ - 1]) + 1;
+  if (needed_chars > buffer_size) return false;
+  int string_index = needed_chars - 1;
+  buffer[string_index--] = '\0';
+  for (int i = 0; i < exponent_; ++i) {
+    for (int j = 0; j < kHexCharsPerBigit; ++j) {
+      buffer[string_index--] = '0';
+    }
+  }
+  for (int i = 0; i < used_digits_ - 1; ++i) {
+    Chunk current_bigit = bigits_[i];
+    for (int j = 0; j < kHexCharsPerBigit; ++j) {
+      buffer[string_index--] = HexCharOfValue(current_bigit & 0xF);
+      current_bigit >>= 4;
+    }
+  }
+  // And finally the last bigit.
+  Chunk most_significant_bigit = bigits_[used_digits_ - 1];
+  while (most_significant_bigit != 0) {
+    buffer[string_index--] = HexCharOfValue(most_significant_bigit & 0xF);
+    most_significant_bigit >>= 4;
+  }
+  return true;
+}
+
+
+Bignum::Chunk Bignum::BigitAt(int index) const {
+  if (index >= BigitLength()) return 0;
+  if (index < exponent_) return 0;
+  return bigits_[index - exponent_];
+}
+
+
+int Bignum::Compare(const Bignum& a, const Bignum& b) {
+  ASSERT(a.IsClamped());
+  ASSERT(b.IsClamped());
+  int bigit_length_a = a.BigitLength();
+  int bigit_length_b = b.BigitLength();
+  if (bigit_length_a < bigit_length_b) return -1;
+  if (bigit_length_a > bigit_length_b) return +1;
+  for (int i = bigit_length_a - 1; i >= Min(a.exponent_, b.exponent_); --i) {
+    Chunk bigit_a = a.BigitAt(i);
+    Chunk bigit_b = b.BigitAt(i);
+    if (bigit_a < bigit_b) return -1;
+    if (bigit_a > bigit_b) return +1;
+    // Otherwise they are equal up to this digit. Try the next digit.
+  }
+  return 0;
+}
+
+
+int Bignum::PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c) {
+  ASSERT(a.IsClamped());
+  ASSERT(b.IsClamped());
+  ASSERT(c.IsClamped());
+  if (a.BigitLength() < b.BigitLength()) {
+    return PlusCompare(b, a, c);
+  }
+  if (a.BigitLength() + 1 < c.BigitLength()) return -1;
+  if (a.BigitLength() > c.BigitLength()) return +1;
+  // The exponent encodes 0-bigits. So if there are more 0-digits in 'a' than
+  // 'b' has digits, then the bigit-length of 'a'+'b' must be equal to the one
+  // of 'a'.
+  if (a.exponent_ >= b.BigitLength() && a.BigitLength() < c.BigitLength()) {
+    return -1;
+  }
+
+  Chunk borrow = 0;
+  // Starting at min_exponent all digits are == 0. So no need to compare them.
+  int min_exponent = Min(Min(a.exponent_, b.exponent_), c.exponent_);
+  for (int i = c.BigitLength() - 1; i >= min_exponent; --i) {
+    Chunk chunk_a = a.BigitAt(i);
+    Chunk chunk_b = b.BigitAt(i);
+    Chunk chunk_c = c.BigitAt(i);
+    Chunk sum = chunk_a + chunk_b;
+    if (sum > chunk_c + borrow) {
+      return +1;
+    } else {
+      borrow = chunk_c + borrow - sum;
+      if (borrow > 1) return -1;
+      borrow <<= kBigitSize;
+    }
+  }
+  if (borrow == 0) return 0;
+  return -1;
+}
+
+
+void Bignum::Clamp() {
+  while (used_digits_ > 0 && bigits_[used_digits_ - 1] == 0) {
+    used_digits_--;
+  }
+  if (used_digits_ == 0) {
+    // Zero.
+    exponent_ = 0;
+  }
+}
+
+
+bool Bignum::IsClamped() const {
+  return used_digits_ == 0 || bigits_[used_digits_ - 1] != 0;
+}
+
+
+void Bignum::Zero() {
+  for (int i = 0; i < used_digits_; ++i) {
+    bigits_[i] = 0;
+  }
+  used_digits_ = 0;
+  exponent_ = 0;
+}
+
+
+void Bignum::Align(const Bignum& other) {
+  if (exponent_ > other.exponent_) {
+    // If "X" represents a "hidden" digit (by the exponent) then we are in the
+    // following case (a == this, b == other):
+    // a:  aaaaaaXXXX   or a:   aaaaaXXX
+    // b:     bbbbbbX      b: bbbbbbbbXX
+    // We replace some of the hidden digits (X) of a with 0 digits.
+    // a:  aaaaaa000X   or a:   aaaaa0XX
+    int zero_digits = exponent_ - other.exponent_;
+    EnsureCapacity(used_digits_ + zero_digits);
+    for (int i = used_digits_ - 1; i >= 0; --i) {
+      bigits_[i + zero_digits] = bigits_[i];
+    }
+    for (int i = 0; i < zero_digits; ++i) {
+      bigits_[i] = 0;
+    }
+    used_digits_ += zero_digits;
+    exponent_ -= zero_digits;
+    ASSERT(used_digits_ >= 0);
+    ASSERT(exponent_ >= 0);
+  }
+}
+
+
+void Bignum::BigitsShiftLeft(int shift_amount) {
+  ASSERT(shift_amount < kBigitSize);
+  ASSERT(shift_amount >= 0);
+  Chunk carry = 0;
+  for (int i = 0; i < used_digits_; ++i) {
+    Chunk new_carry = bigits_[i] >> (kBigitSize - shift_amount);
+    bigits_[i] = ((bigits_[i] << shift_amount) + carry) & kBigitMask;
+    carry = new_carry;
+  }
+  if (carry != 0) {
+    bigits_[used_digits_] = carry;
+    used_digits_++;
+  }
+}
+
+
+void Bignum::SubtractTimes(const Bignum& other, int factor) {
+  ASSERT(exponent_ <= other.exponent_);
+  if (factor < 3) {
+    for (int i = 0; i < factor; ++i) {
+      SubtractBignum(other);
+    }
+    return;
+  }
+  Chunk borrow = 0;
+  int exponent_diff = other.exponent_ - exponent_;
+  for (int i = 0; i < other.used_digits_; ++i) {
+    DoubleChunk product = static_cast<DoubleChunk>(factor) * other.bigits_[i];
+    DoubleChunk remove = borrow + product;
+    Chunk difference = bigits_[i + exponent_diff] - (remove & kBigitMask);
+    bigits_[i + exponent_diff] = difference & kBigitMask;
+    borrow = static_cast<Chunk>((difference >> (kChunkSize - 1)) +
+                                (remove >> kBigitSize));
+  }
+  for (int i = other.used_digits_ + exponent_diff; i < used_digits_; ++i) {
+    if (borrow == 0) return;
+    Chunk difference = bigits_[i] - borrow;
+    bigits_[i] = difference & kBigitMask;
+    borrow = difference >> (kChunkSize - 1);
+  }
+  Clamp();
+}
+
+
+}  // namespace double_conversion
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/bignum.h b/src/third_party/mozjs-45/mfbt/double-conversion/bignum.h
new file mode 100644
index 0000000..5ec3544
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/bignum.h
@@ -0,0 +1,145 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_BIGNUM_H_
+#define DOUBLE_CONVERSION_BIGNUM_H_
+
+#include "utils.h"
+
+namespace double_conversion {
+
+class Bignum {
+ public:
+  // 3584 = 128 * 28. We can represent 2^3584 > 10^1000 accurately.
+  // This bignum can encode much bigger numbers, since it contains an
+  // exponent.
+  static const int kMaxSignificantBits = 3584;
+
+  Bignum();
+  void AssignUInt16(uint16_t value);
+  void AssignUInt64(uint64_t value);
+  void AssignBignum(const Bignum& other);
+
+  void AssignDecimalString(Vector<const char> value);
+  void AssignHexString(Vector<const char> value);
+
+  void AssignPowerUInt16(uint16_t base, int exponent);
+
+  void AddUInt16(uint16_t operand);
+  void AddUInt64(uint64_t operand);
+  void AddBignum(const Bignum& other);
+  // Precondition: this >= other.
+  void SubtractBignum(const Bignum& other);
+
+  void Square();
+  void ShiftLeft(int shift_amount);
+  void MultiplyByUInt32(uint32_t factor);
+  void MultiplyByUInt64(uint64_t factor);
+  void MultiplyByPowerOfTen(int exponent);
+  void Times10() { return MultiplyByUInt32(10); }
+  // Pseudocode:
+  //  int result = this / other;
+  //  this = this % other;
+  // In the worst case this function is in O(this/other).
+  uint16_t DivideModuloIntBignum(const Bignum& other);
+
+  bool ToHexString(char* buffer, int buffer_size) const;
+
+  // Returns
+  //  -1 if a < b,
+  //   0 if a == b, and
+  //  +1 if a > b.
+  static int Compare(const Bignum& a, const Bignum& b);
+  static bool Equal(const Bignum& a, const Bignum& b) {
+    return Compare(a, b) == 0;
+  }
+  static bool LessEqual(const Bignum& a, const Bignum& b) {
+    return Compare(a, b) <= 0;
+  }
+  static bool Less(const Bignum& a, const Bignum& b) {
+    return Compare(a, b) < 0;
+  }
+  // Returns Compare(a + b, c);
+  static int PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c);
+  // Returns a + b == c
+  static bool PlusEqual(const Bignum& a, const Bignum& b, const Bignum& c) {
+    return PlusCompare(a, b, c) == 0;
+  }
+  // Returns a + b <= c
+  static bool PlusLessEqual(const Bignum& a, const Bignum& b, const Bignum& c) {
+    return PlusCompare(a, b, c) <= 0;
+  }
+  // Returns a + b < c
+  static bool PlusLess(const Bignum& a, const Bignum& b, const Bignum& c) {
+    return PlusCompare(a, b, c) < 0;
+  }
+ private:
+  typedef uint32_t Chunk;
+  typedef uint64_t DoubleChunk;
+
+  static const int kChunkSize = sizeof(Chunk) * 8;
+  static const int kDoubleChunkSize = sizeof(DoubleChunk) * 8;
+  // With bigit size of 28 we loose some bits, but a double still fits easily
+  // into two chunks, and more importantly we can use the Comba multiplication.
+  static const int kBigitSize = 28;
+  static const Chunk kBigitMask = (1 << kBigitSize) - 1;
+  // Every instance allocates kBigitLength chunks on the stack. Bignums cannot
+  // grow. There are no checks if the stack-allocated space is sufficient.
+  static const int kBigitCapacity = kMaxSignificantBits / kBigitSize;
+
+  void EnsureCapacity(int size) {
+    if (size > kBigitCapacity) {
+      UNREACHABLE();
+    }
+  }
+  void Align(const Bignum& other);
+  void Clamp();
+  bool IsClamped() const;
+  void Zero();
+  // Requires this to have enough capacity (no tests done).
+  // Updates used_digits_ if necessary.
+  // shift_amount must be < kBigitSize.
+  void BigitsShiftLeft(int shift_amount);
+  // BigitLength includes the "hidden" digits encoded in the exponent.
+  int BigitLength() const { return used_digits_ + exponent_; }
+  Chunk BigitAt(int index) const;
+  void SubtractTimes(const Bignum& other, int factor);
+
+  Chunk bigits_buffer_[kBigitCapacity];
+  // A vector backed by bigits_buffer_. This way accesses to the array are
+  // checked for out-of-bounds errors.
+  Vector<Chunk> bigits_;
+  int used_digits_;
+  // The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize).
+  int exponent_;
+
+  DISALLOW_COPY_AND_ASSIGN(Bignum);
+};
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_BIGNUM_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/cached-powers.cc b/src/third_party/mozjs-45/mfbt/double-conversion/cached-powers.cc
new file mode 100644
index 0000000..c676429
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/cached-powers.cc
@@ -0,0 +1,175 @@
+// Copyright 2006-2008 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <stdarg.h>
+#include <limits.h>
+#include <math.h>
+
+#include "utils.h"
+
+#include "cached-powers.h"
+
+namespace double_conversion {
+
+struct CachedPower {
+  uint64_t significand;
+  int16_t binary_exponent;
+  int16_t decimal_exponent;
+};
+
+static const CachedPower kCachedPowers[] = {
+  {UINT64_2PART_C(0xfa8fd5a0, 081c0288), -1220, -348},
+  {UINT64_2PART_C(0xbaaee17f, a23ebf76), -1193, -340},
+  {UINT64_2PART_C(0x8b16fb20, 3055ac76), -1166, -332},
+  {UINT64_2PART_C(0xcf42894a, 5dce35ea), -1140, -324},
+  {UINT64_2PART_C(0x9a6bb0aa, 55653b2d), -1113, -316},
+  {UINT64_2PART_C(0xe61acf03, 3d1a45df), -1087, -308},
+  {UINT64_2PART_C(0xab70fe17, c79ac6ca), -1060, -300},
+  {UINT64_2PART_C(0xff77b1fc, bebcdc4f), -1034, -292},
+  {UINT64_2PART_C(0xbe5691ef, 416bd60c), -1007, -284},
+  {UINT64_2PART_C(0x8dd01fad, 907ffc3c), -980, -276},
+  {UINT64_2PART_C(0xd3515c28, 31559a83), -954, -268},
+  {UINT64_2PART_C(0x9d71ac8f, ada6c9b5), -927, -260},
+  {UINT64_2PART_C(0xea9c2277, 23ee8bcb), -901, -252},
+  {UINT64_2PART_C(0xaecc4991, 4078536d), -874, -244},
+  {UINT64_2PART_C(0x823c1279, 5db6ce57), -847, -236},
+  {UINT64_2PART_C(0xc2109436, 4dfb5637), -821, -228},
+  {UINT64_2PART_C(0x9096ea6f, 3848984f), -794, -220},
+  {UINT64_2PART_C(0xd77485cb, 25823ac7), -768, -212},
+  {UINT64_2PART_C(0xa086cfcd, 97bf97f4), -741, -204},
+  {UINT64_2PART_C(0xef340a98, 172aace5), -715, -196},
+  {UINT64_2PART_C(0xb23867fb, 2a35b28e), -688, -188},
+  {UINT64_2PART_C(0x84c8d4df, d2c63f3b), -661, -180},
+  {UINT64_2PART_C(0xc5dd4427, 1ad3cdba), -635, -172},
+  {UINT64_2PART_C(0x936b9fce, bb25c996), -608, -164},
+  {UINT64_2PART_C(0xdbac6c24, 7d62a584), -582, -156},
+  {UINT64_2PART_C(0xa3ab6658, 0d5fdaf6), -555, -148},
+  {UINT64_2PART_C(0xf3e2f893, dec3f126), -529, -140},
+  {UINT64_2PART_C(0xb5b5ada8, aaff80b8), -502, -132},
+  {UINT64_2PART_C(0x87625f05, 6c7c4a8b), -475, -124},
+  {UINT64_2PART_C(0xc9bcff60, 34c13053), -449, -116},
+  {UINT64_2PART_C(0x964e858c, 91ba2655), -422, -108},
+  {UINT64_2PART_C(0xdff97724, 70297ebd), -396, -100},
+  {UINT64_2PART_C(0xa6dfbd9f, b8e5b88f), -369, -92},
+  {UINT64_2PART_C(0xf8a95fcf, 88747d94), -343, -84},
+  {UINT64_2PART_C(0xb9447093, 8fa89bcf), -316, -76},
+  {UINT64_2PART_C(0x8a08f0f8, bf0f156b), -289, -68},
+  {UINT64_2PART_C(0xcdb02555, 653131b6), -263, -60},
+  {UINT64_2PART_C(0x993fe2c6, d07b7fac), -236, -52},
+  {UINT64_2PART_C(0xe45c10c4, 2a2b3b06), -210, -44},
+  {UINT64_2PART_C(0xaa242499, 697392d3), -183, -36},
+  {UINT64_2PART_C(0xfd87b5f2, 8300ca0e), -157, -28},
+  {UINT64_2PART_C(0xbce50864, 92111aeb), -130, -20},
+  {UINT64_2PART_C(0x8cbccc09, 6f5088cc), -103, -12},
+  {UINT64_2PART_C(0xd1b71758, e219652c), -77, -4},
+  {UINT64_2PART_C(0x9c400000, 00000000), -50, 4},
+  {UINT64_2PART_C(0xe8d4a510, 00000000), -24, 12},
+  {UINT64_2PART_C(0xad78ebc5, ac620000), 3, 20},
+  {UINT64_2PART_C(0x813f3978, f8940984), 30, 28},
+  {UINT64_2PART_C(0xc097ce7b, c90715b3), 56, 36},
+  {UINT64_2PART_C(0x8f7e32ce, 7bea5c70), 83, 44},
+  {UINT64_2PART_C(0xd5d238a4, abe98068), 109, 52},
+  {UINT64_2PART_C(0x9f4f2726, 179a2245), 136, 60},
+  {UINT64_2PART_C(0xed63a231, d4c4fb27), 162, 68},
+  {UINT64_2PART_C(0xb0de6538, 8cc8ada8), 189, 76},
+  {UINT64_2PART_C(0x83c7088e, 1aab65db), 216, 84},
+  {UINT64_2PART_C(0xc45d1df9, 42711d9a), 242, 92},
+  {UINT64_2PART_C(0x924d692c, a61be758), 269, 100},
+  {UINT64_2PART_C(0xda01ee64, 1a708dea), 295, 108},
+  {UINT64_2PART_C(0xa26da399, 9aef774a), 322, 116},
+  {UINT64_2PART_C(0xf209787b, b47d6b85), 348, 124},
+  {UINT64_2PART_C(0xb454e4a1, 79dd1877), 375, 132},
+  {UINT64_2PART_C(0x865b8692, 5b9bc5c2), 402, 140},
+  {UINT64_2PART_C(0xc83553c5, c8965d3d), 428, 148},
+  {UINT64_2PART_C(0x952ab45c, fa97a0b3), 455, 156},
+  {UINT64_2PART_C(0xde469fbd, 99a05fe3), 481, 164},
+  {UINT64_2PART_C(0xa59bc234, db398c25), 508, 172},
+  {UINT64_2PART_C(0xf6c69a72, a3989f5c), 534, 180},
+  {UINT64_2PART_C(0xb7dcbf53, 54e9bece), 561, 188},
+  {UINT64_2PART_C(0x88fcf317, f22241e2), 588, 196},
+  {UINT64_2PART_C(0xcc20ce9b, d35c78a5), 614, 204},
+  {UINT64_2PART_C(0x98165af3, 7b2153df), 641, 212},
+  {UINT64_2PART_C(0xe2a0b5dc, 971f303a), 667, 220},
+  {UINT64_2PART_C(0xa8d9d153, 5ce3b396), 694, 228},
+  {UINT64_2PART_C(0xfb9b7cd9, a4a7443c), 720, 236},
+  {UINT64_2PART_C(0xbb764c4c, a7a44410), 747, 244},
+  {UINT64_2PART_C(0x8bab8eef, b6409c1a), 774, 252},
+  {UINT64_2PART_C(0xd01fef10, a657842c), 800, 260},
+  {UINT64_2PART_C(0x9b10a4e5, e9913129), 827, 268},
+  {UINT64_2PART_C(0xe7109bfb, a19c0c9d), 853, 276},
+  {UINT64_2PART_C(0xac2820d9, 623bf429), 880, 284},
+  {UINT64_2PART_C(0x80444b5e, 7aa7cf85), 907, 292},
+  {UINT64_2PART_C(0xbf21e440, 03acdd2d), 933, 300},
+  {UINT64_2PART_C(0x8e679c2f, 5e44ff8f), 960, 308},
+  {UINT64_2PART_C(0xd433179d, 9c8cb841), 986, 316},
+  {UINT64_2PART_C(0x9e19db92, b4e31ba9), 1013, 324},
+  {UINT64_2PART_C(0xeb96bf6e, badf77d9), 1039, 332},
+  {UINT64_2PART_C(0xaf87023b, 9bf0ee6b), 1066, 340},
+};
+
+static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
+static const int kCachedPowersOffset = 348;  // -1 * the first decimal_exponent.
+static const double kD_1_LOG2_10 = 0.30102999566398114;  //  1 / lg(10)
+// Difference between the decimal exponents in the table above.
+const int PowersOfTenCache::kDecimalExponentDistance = 8;
+const int PowersOfTenCache::kMinDecimalExponent = -348;
+const int PowersOfTenCache::kMaxDecimalExponent = 340;
+
+void PowersOfTenCache::GetCachedPowerForBinaryExponentRange(
+    int min_exponent,
+    int max_exponent,
+    DiyFp* power,
+    int* decimal_exponent) {
+  int kQ = DiyFp::kSignificandSize;
+  double k = ceil((min_exponent + kQ - 1) * kD_1_LOG2_10);
+  int foo = kCachedPowersOffset;
+  int index =
+      (foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1;
+  ASSERT(0 <= index && index < kCachedPowersLength);
+  CachedPower cached_power = kCachedPowers[index];
+  ASSERT(min_exponent <= cached_power.binary_exponent);
+  ASSERT(cached_power.binary_exponent <= max_exponent);
+  *decimal_exponent = cached_power.decimal_exponent;
+  *power = DiyFp(cached_power.significand, cached_power.binary_exponent);
+}
+
+
+void PowersOfTenCache::GetCachedPowerForDecimalExponent(int requested_exponent,
+                                                        DiyFp* power,
+                                                        int* found_exponent) {
+  ASSERT(kMinDecimalExponent <= requested_exponent);
+  ASSERT(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance);
+  int index =
+      (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance;
+  CachedPower cached_power = kCachedPowers[index];
+  *power = DiyFp(cached_power.significand, cached_power.binary_exponent);
+  *found_exponent = cached_power.decimal_exponent;
+  ASSERT(*found_exponent <= requested_exponent);
+  ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance);
+}
+
+}  // namespace double_conversion
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/cached-powers.h b/src/third_party/mozjs-45/mfbt/double-conversion/cached-powers.h
new file mode 100644
index 0000000..61a5061
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/cached-powers.h
@@ -0,0 +1,64 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_CACHED_POWERS_H_
+#define DOUBLE_CONVERSION_CACHED_POWERS_H_
+
+#include "diy-fp.h"
+
+namespace double_conversion {
+
+class PowersOfTenCache {
+ public:
+
+  // Not all powers of ten are cached. The decimal exponent of two neighboring
+  // cached numbers will differ by kDecimalExponentDistance.
+  static const int kDecimalExponentDistance;
+
+  static const int kMinDecimalExponent;
+  static const int kMaxDecimalExponent;
+
+  // Returns a cached power-of-ten with a binary exponent in the range
+  // [min_exponent; max_exponent] (boundaries included).
+  static void GetCachedPowerForBinaryExponentRange(int min_exponent,
+                                                   int max_exponent,
+                                                   DiyFp* power,
+                                                   int* decimal_exponent);
+
+  // Returns a cached power of ten x ~= 10^k such that
+  //   k <= decimal_exponent < k + kCachedPowersDecimalDistance.
+  // The given decimal_exponent must satisfy
+  //   kMinDecimalExponent <= requested_exponent, and
+  //   requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance.
+  static void GetCachedPowerForDecimalExponent(int requested_exponent,
+                                               DiyFp* power,
+                                               int* found_exponent);
+};
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_CACHED_POWERS_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/diy-fp.cc b/src/third_party/mozjs-45/mfbt/double-conversion/diy-fp.cc
new file mode 100644
index 0000000..ddd1891
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/diy-fp.cc
@@ -0,0 +1,57 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+#include "diy-fp.h"
+#include "utils.h"
+
+namespace double_conversion {
+
+void DiyFp::Multiply(const DiyFp& other) {
+  // Simply "emulates" a 128 bit multiplication.
+  // However: the resulting number only contains 64 bits. The least
+  // significant 64 bits are only used for rounding the most significant 64
+  // bits.
+  const uint64_t kM32 = 0xFFFFFFFFU;
+  uint64_t a = f_ >> 32;
+  uint64_t b = f_ & kM32;
+  uint64_t c = other.f_ >> 32;
+  uint64_t d = other.f_ & kM32;
+  uint64_t ac = a * c;
+  uint64_t bc = b * c;
+  uint64_t ad = a * d;
+  uint64_t bd = b * d;
+  uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32);
+  // By adding 1U << 31 to tmp we round the final result.
+  // Halfway cases will be round up.
+  tmp += 1U << 31;
+  uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
+  e_ += other.e_ + 64;
+  f_ = result_f;
+}
+
+}  // namespace double_conversion
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/diy-fp.h b/src/third_party/mozjs-45/mfbt/double-conversion/diy-fp.h
new file mode 100644
index 0000000..9dcf8fb
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/diy-fp.h
@@ -0,0 +1,118 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_DIY_FP_H_
+#define DOUBLE_CONVERSION_DIY_FP_H_
+
+#include "utils.h"
+
+namespace double_conversion {
+
+// This "Do It Yourself Floating Point" class implements a floating-point number
+// with a uint64 significand and an int exponent. Normalized DiyFp numbers will
+// have the most significant bit of the significand set.
+// Multiplication and Subtraction do not normalize their results.
+// DiyFp are not designed to contain special doubles (NaN and Infinity).
+class DiyFp {
+ public:
+  static const int kSignificandSize = 64;
+
+  DiyFp() : f_(0), e_(0) {}
+  DiyFp(uint64_t f, int e) : f_(f), e_(e) {}
+
+  // this = this - other.
+  // The exponents of both numbers must be the same and the significand of this
+  // must be bigger than the significand of other.
+  // The result will not be normalized.
+  void Subtract(const DiyFp& other) {
+    ASSERT(e_ == other.e_);
+    ASSERT(f_ >= other.f_);
+    f_ -= other.f_;
+  }
+
+  // Returns a - b.
+  // The exponents of both numbers must be the same and this must be bigger
+  // than other. The result will not be normalized.
+  static DiyFp Minus(const DiyFp& a, const DiyFp& b) {
+    DiyFp result = a;
+    result.Subtract(b);
+    return result;
+  }
+
+
+  // this = this * other.
+  void Multiply(const DiyFp& other);
+
+  // returns a * b;
+  static DiyFp Times(const DiyFp& a, const DiyFp& b) {
+    DiyFp result = a;
+    result.Multiply(b);
+    return result;
+  }
+
+  void Normalize() {
+    ASSERT(f_ != 0);
+    uint64_t f = f_;
+    int e = e_;
+
+    // This method is mainly called for normalizing boundaries. In general
+    // boundaries need to be shifted by 10 bits. We thus optimize for this case.
+    const uint64_t k10MSBits = UINT64_2PART_C(0xFFC00000, 00000000);
+    while ((f & k10MSBits) == 0) {
+      f <<= 10;
+      e -= 10;
+    }
+    while ((f & kUint64MSB) == 0) {
+      f <<= 1;
+      e--;
+    }
+    f_ = f;
+    e_ = e;
+  }
+
+  static DiyFp Normalize(const DiyFp& a) {
+    DiyFp result = a;
+    result.Normalize();
+    return result;
+  }
+
+  uint64_t f() const { return f_; }
+  int e() const { return e_; }
+
+  void set_f(uint64_t new_value) { f_ = new_value; }
+  void set_e(int new_value) { e_ = new_value; }
+
+ private:
+  static const uint64_t kUint64MSB = UINT64_2PART_C(0x80000000, 00000000);
+
+  uint64_t f_;
+  int e_;
+};
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_DIY_FP_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/double-conversion.cc b/src/third_party/mozjs-45/mfbt/double-conversion/double-conversion.cc
new file mode 100644
index 0000000..394b6a0
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/double-conversion.cc
@@ -0,0 +1,892 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <limits.h>
+#include <math.h>
+
+#include "double-conversion.h"
+
+#include "bignum-dtoa.h"
+#include "fast-dtoa.h"
+#include "fixed-dtoa.h"
+#include "ieee.h"
+#include "strtod.h"
+#include "utils.h"
+
+namespace double_conversion {
+
+const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() {
+  int flags = UNIQUE_ZERO | EMIT_POSITIVE_EXPONENT_SIGN;
+  static DoubleToStringConverter converter(flags,
+                                           "Infinity",
+                                           "NaN",
+                                           'e',
+                                           -6, 21,
+                                           6, 0);
+  return converter;
+}
+
+
+bool DoubleToStringConverter::HandleSpecialValues(
+    double value,
+    StringBuilder* result_builder) const {
+  Double double_inspect(value);
+  if (double_inspect.IsInfinite()) {
+    if (infinity_symbol_ == NULL) return false;
+    if (value < 0) {
+      result_builder->AddCharacter('-');
+    }
+    result_builder->AddString(infinity_symbol_);
+    return true;
+  }
+  if (double_inspect.IsNan()) {
+    if (nan_symbol_ == NULL) return false;
+    result_builder->AddString(nan_symbol_);
+    return true;
+  }
+  return false;
+}
+
+
+void DoubleToStringConverter::CreateExponentialRepresentation(
+    const char* decimal_digits,
+    int length,
+    int exponent,
+    StringBuilder* result_builder) const {
+  ASSERT(length != 0);
+  result_builder->AddCharacter(decimal_digits[0]);
+  if (length != 1) {
+    result_builder->AddCharacter('.');
+    result_builder->AddSubstring(&decimal_digits[1], length-1);
+  }
+  result_builder->AddCharacter(exponent_character_);
+  if (exponent < 0) {
+    result_builder->AddCharacter('-');
+    exponent = -exponent;
+  } else {
+    if ((flags_ & EMIT_POSITIVE_EXPONENT_SIGN) != 0) {
+      result_builder->AddCharacter('+');
+    }
+  }
+  if (exponent == 0) {
+    result_builder->AddCharacter('0');
+    return;
+  }
+  ASSERT(exponent < 1e4);
+  const int kMaxExponentLength = 5;
+  char buffer[kMaxExponentLength + 1];
+  buffer[kMaxExponentLength] = '\0';
+  int first_char_pos = kMaxExponentLength;
+  while (exponent > 0) {
+    buffer[--first_char_pos] = '0' + (exponent % 10);
+    exponent /= 10;
+  }
+  result_builder->AddSubstring(&buffer[first_char_pos],
+                               kMaxExponentLength - first_char_pos);
+}
+
+
+void DoubleToStringConverter::CreateDecimalRepresentation(
+    const char* decimal_digits,
+    int length,
+    int decimal_point,
+    int digits_after_point,
+    StringBuilder* result_builder) const {
+  // Create a representation that is padded with zeros if needed.
+  if (decimal_point <= 0) {
+      // "0.00000decimal_rep".
+    result_builder->AddCharacter('0');
+    if (digits_after_point > 0) {
+      result_builder->AddCharacter('.');
+      result_builder->AddPadding('0', -decimal_point);
+      ASSERT(length <= digits_after_point - (-decimal_point));
+      result_builder->AddSubstring(decimal_digits, length);
+      int remaining_digits = digits_after_point - (-decimal_point) - length;
+      result_builder->AddPadding('0', remaining_digits);
+    }
+  } else if (decimal_point >= length) {
+    // "decimal_rep0000.00000" or "decimal_rep.0000"
+    result_builder->AddSubstring(decimal_digits, length);
+    result_builder->AddPadding('0', decimal_point - length);
+    if (digits_after_point > 0) {
+      result_builder->AddCharacter('.');
+      result_builder->AddPadding('0', digits_after_point);
+    }
+  } else {
+    // "decima.l_rep000"
+    ASSERT(digits_after_point > 0);
+    result_builder->AddSubstring(decimal_digits, decimal_point);
+    result_builder->AddCharacter('.');
+    ASSERT(length - decimal_point <= digits_after_point);
+    result_builder->AddSubstring(&decimal_digits[decimal_point],
+                                 length - decimal_point);
+    int remaining_digits = digits_after_point - (length - decimal_point);
+    result_builder->AddPadding('0', remaining_digits);
+  }
+  if (digits_after_point == 0) {
+    if ((flags_ & EMIT_TRAILING_DECIMAL_POINT) != 0) {
+      result_builder->AddCharacter('.');
+    }
+    if ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) {
+      result_builder->AddCharacter('0');
+    }
+  }
+}
+
+
+bool DoubleToStringConverter::ToShortestIeeeNumber(
+    double value,
+    StringBuilder* result_builder,
+    DoubleToStringConverter::DtoaMode mode) const {
+  ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE);
+  if (Double(value).IsSpecial()) {
+    return HandleSpecialValues(value, result_builder);
+  }
+
+  int decimal_point;
+  bool sign;
+  const int kDecimalRepCapacity = kBase10MaximalLength + 1;
+  char decimal_rep[kDecimalRepCapacity];
+  int decimal_rep_length;
+
+  DoubleToAscii(value, mode, 0, decimal_rep, kDecimalRepCapacity,
+                &sign, &decimal_rep_length, &decimal_point);
+
+  bool unique_zero = (flags_ & UNIQUE_ZERO) != 0;
+  if (sign && (value != 0.0 || !unique_zero)) {
+    result_builder->AddCharacter('-');
+  }
+
+  int exponent = decimal_point - 1;
+  if ((decimal_in_shortest_low_ <= exponent) &&
+      (exponent < decimal_in_shortest_high_)) {
+    CreateDecimalRepresentation(decimal_rep, decimal_rep_length,
+                                decimal_point,
+                                Max(0, decimal_rep_length - decimal_point),
+                                result_builder);
+  } else {
+    CreateExponentialRepresentation(decimal_rep, decimal_rep_length, exponent,
+                                    result_builder);
+  }
+  return true;
+}
+
+
+bool DoubleToStringConverter::ToFixed(double value,
+                                      int requested_digits,
+                                      StringBuilder* result_builder) const {
+  ASSERT(kMaxFixedDigitsBeforePoint == 60);
+  const double kFirstNonFixed = 1e60;
+
+  if (Double(value).IsSpecial()) {
+    return HandleSpecialValues(value, result_builder);
+  }
+
+  if (requested_digits > kMaxFixedDigitsAfterPoint) return false;
+  if (value >= kFirstNonFixed || value <= -kFirstNonFixed) return false;
+
+  // Find a sufficiently precise decimal representation of n.
+  int decimal_point;
+  bool sign;
+  // Add space for the '\0' byte.
+  const int kDecimalRepCapacity =
+      kMaxFixedDigitsBeforePoint + kMaxFixedDigitsAfterPoint + 1;
+  char decimal_rep[kDecimalRepCapacity];
+  int decimal_rep_length;
+  DoubleToAscii(value, FIXED, requested_digits,
+                decimal_rep, kDecimalRepCapacity,
+                &sign, &decimal_rep_length, &decimal_point);
+
+  bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0);
+  if (sign && (value != 0.0 || !unique_zero)) {
+    result_builder->AddCharacter('-');
+  }
+
+  CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point,
+                              requested_digits, result_builder);
+  return true;
+}
+
+
+bool DoubleToStringConverter::ToExponential(
+    double value,
+    int requested_digits,
+    StringBuilder* result_builder) const {
+  if (Double(value).IsSpecial()) {
+    return HandleSpecialValues(value, result_builder);
+  }
+
+  if (requested_digits < -1) return false;
+  if (requested_digits > kMaxExponentialDigits) return false;
+
+  int decimal_point;
+  bool sign;
+  // Add space for digit before the decimal point and the '\0' character.
+  const int kDecimalRepCapacity = kMaxExponentialDigits + 2;
+  ASSERT(kDecimalRepCapacity > kBase10MaximalLength);
+  char decimal_rep[kDecimalRepCapacity];
+  int decimal_rep_length;
+
+  if (requested_digits == -1) {
+    DoubleToAscii(value, SHORTEST, 0,
+                  decimal_rep, kDecimalRepCapacity,
+                  &sign, &decimal_rep_length, &decimal_point);
+  } else {
+    DoubleToAscii(value, PRECISION, requested_digits + 1,
+                  decimal_rep, kDecimalRepCapacity,
+                  &sign, &decimal_rep_length, &decimal_point);
+    ASSERT(decimal_rep_length <= requested_digits + 1);
+
+    for (int i = decimal_rep_length; i < requested_digits + 1; ++i) {
+      decimal_rep[i] = '0';
+    }
+    decimal_rep_length = requested_digits + 1;
+  }
+
+  bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0);
+  if (sign && (value != 0.0 || !unique_zero)) {
+    result_builder->AddCharacter('-');
+  }
+
+  int exponent = decimal_point - 1;
+  CreateExponentialRepresentation(decimal_rep,
+                                  decimal_rep_length,
+                                  exponent,
+                                  result_builder);
+  return true;
+}
+
+
+bool DoubleToStringConverter::ToPrecision(double value,
+                                          int precision,
+                                          bool* used_exponential_notation,
+                                          StringBuilder* result_builder) const {
+  *used_exponential_notation = false;
+  if (Double(value).IsSpecial()) {
+    return HandleSpecialValues(value, result_builder);
+  }
+
+  if (precision < kMinPrecisionDigits || precision > kMaxPrecisionDigits) {
+    return false;
+  }
+
+  // Find a sufficiently precise decimal representation of n.
+  int decimal_point;
+  bool sign;
+  // Add one for the terminating null character.
+  const int kDecimalRepCapacity = kMaxPrecisionDigits + 1;
+  char decimal_rep[kDecimalRepCapacity];
+  int decimal_rep_length;
+
+  DoubleToAscii(value, PRECISION, precision,
+                decimal_rep, kDecimalRepCapacity,
+                &sign, &decimal_rep_length, &decimal_point);
+  ASSERT(decimal_rep_length <= precision);
+
+  bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0);
+  if (sign && (value != 0.0 || !unique_zero)) {
+    result_builder->AddCharacter('-');
+  }
+
+  // The exponent if we print the number as x.xxeyyy. That is with the
+  // decimal point after the first digit.
+  int exponent = decimal_point - 1;
+
+  int extra_zero = ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) ? 1 : 0;
+  if ((-decimal_point + 1 > max_leading_padding_zeroes_in_precision_mode_) ||
+      (decimal_point - precision + extra_zero >
+       max_trailing_padding_zeroes_in_precision_mode_)) {
+    // Fill buffer to contain 'precision' digits.
+    // Usually the buffer is already at the correct length, but 'DoubleToAscii'
+    // is allowed to return less characters.
+    for (int i = decimal_rep_length; i < precision; ++i) {
+      decimal_rep[i] = '0';
+    }
+
+    *used_exponential_notation = true;
+    CreateExponentialRepresentation(decimal_rep,
+                                    precision,
+                                    exponent,
+                                    result_builder);
+  } else {
+    CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point,
+                                Max(0, precision - decimal_point),
+                                result_builder);
+  }
+  return true;
+}
+
+
+static BignumDtoaMode DtoaToBignumDtoaMode(
+    DoubleToStringConverter::DtoaMode dtoa_mode) {
+  switch (dtoa_mode) {
+    case DoubleToStringConverter::SHORTEST:  return BIGNUM_DTOA_SHORTEST;
+    case DoubleToStringConverter::SHORTEST_SINGLE:
+        return BIGNUM_DTOA_SHORTEST_SINGLE;
+    case DoubleToStringConverter::FIXED:     return BIGNUM_DTOA_FIXED;
+    case DoubleToStringConverter::PRECISION: return BIGNUM_DTOA_PRECISION;
+    default:
+      UNREACHABLE();
+      return BIGNUM_DTOA_SHORTEST;  // To silence compiler.
+  }
+}
+
+
+void DoubleToStringConverter::DoubleToAscii(double v,
+                                            DtoaMode mode,
+                                            int requested_digits,
+                                            char* buffer,
+                                            int buffer_length,
+                                            bool* sign,
+                                            int* length,
+                                            int* point) {
+  Vector<char> vector(buffer, buffer_length);
+  ASSERT(!Double(v).IsSpecial());
+  ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE || requested_digits >= 0);
+
+  if (Double(v).Sign() < 0) {
+    *sign = true;
+    v = -v;
+  } else {
+    *sign = false;
+  }
+
+  if (mode == PRECISION && requested_digits == 0) {
+    vector[0] = '\0';
+    *length = 0;
+    return;
+  }
+
+  if (v == 0) {
+    vector[0] = '0';
+    vector[1] = '\0';
+    *length = 1;
+    *point = 1;
+    return;
+  }
+
+  bool fast_worked;
+  switch (mode) {
+    case SHORTEST:
+      fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST, 0, vector, length, point);
+      break;
+    case SHORTEST_SINGLE:
+      fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST_SINGLE, 0,
+                             vector, length, point);
+      break;
+    case FIXED:
+      fast_worked = FastFixedDtoa(v, requested_digits, vector, length, point);
+      break;
+    case PRECISION:
+      fast_worked = FastDtoa(v, FAST_DTOA_PRECISION, requested_digits,
+                             vector, length, point);
+      break;
+    default:
+      UNREACHABLE();
+      fast_worked = false;
+  }
+  if (fast_worked) return;
+
+  // If the fast dtoa didn't succeed use the slower bignum version.
+  BignumDtoaMode bignum_mode = DtoaToBignumDtoaMode(mode);
+  BignumDtoa(v, bignum_mode, requested_digits, vector, length, point);
+  vector[*length] = '\0';
+}
+
+
+// Consumes the given substring from the iterator.
+// Returns false, if the substring does not match.
+static bool ConsumeSubString(const char** current,
+                             const char* end,
+                             const char* substring) {
+  ASSERT(**current == *substring);
+  for (substring++; *substring != '\0'; substring++) {
+    ++*current;
+    if (*current == end || **current != *substring) return false;
+  }
+  ++*current;
+  return true;
+}
+
+
+// Maximum number of significant digits in decimal representation.
+// The longest possible double in decimal representation is
+// (2^53 - 1) * 2 ^ -1074 that is (2 ^ 53 - 1) * 5 ^ 1074 / 10 ^ 1074
+// (768 digits). If we parse a number whose first digits are equal to a
+// mean of 2 adjacent doubles (that could have up to 769 digits) the result
+// must be rounded to the bigger one unless the tail consists of zeros, so
+// we don't need to preserve all the digits.
+const int kMaxSignificantDigits = 772;
+
+
+// Returns true if a nonspace found and false if the end has reached.
+static inline bool AdvanceToNonspace(const char** current, const char* end) {
+  while (*current != end) {
+    if (**current != ' ') return true;
+    ++*current;
+  }
+  return false;
+}
+
+
+static bool isDigit(int x, int radix) {
+  return (x >= '0' && x <= '9' && x < '0' + radix)
+      || (radix > 10 && x >= 'a' && x < 'a' + radix - 10)
+      || (radix > 10 && x >= 'A' && x < 'A' + radix - 10);
+}
+
+
+static double SignedZero(bool sign) {
+  return sign ? -0.0 : 0.0;
+}
+
+
+// Parsing integers with radix 2, 4, 8, 16, 32. Assumes current != end.
+template <int radix_log_2>
+static double RadixStringToIeee(const char* current,
+                                const char* end,
+                                bool sign,
+                                bool allow_trailing_junk,
+                                double junk_string_value,
+                                bool read_as_double,
+                                const char** trailing_pointer) {
+  ASSERT(current != end);
+
+  const int kDoubleSize = Double::kSignificandSize;
+  const int kSingleSize = Single::kSignificandSize;
+  const int kSignificandSize = read_as_double? kDoubleSize: kSingleSize;
+
+  // Skip leading 0s.
+  while (*current == '0') {
+    ++current;
+    if (current == end) {
+      *trailing_pointer = end;
+      return SignedZero(sign);
+    }
+  }
+
+  int64_t number = 0;
+  int exponent = 0;
+  const int radix = (1 << radix_log_2);
+
+  do {
+    int digit;
+    if (*current >= '0' && *current <= '9' && *current < '0' + radix) {
+      digit = static_cast<char>(*current) - '0';
+    } else if (radix > 10 && *current >= 'a' && *current < 'a' + radix - 10) {
+      digit = static_cast<char>(*current) - 'a' + 10;
+    } else if (radix > 10 && *current >= 'A' && *current < 'A' + radix - 10) {
+      digit = static_cast<char>(*current) - 'A' + 10;
+    } else {
+      if (allow_trailing_junk || !AdvanceToNonspace(&current, end)) {
+        break;
+      } else {
+        return junk_string_value;
+      }
+    }
+
+    number = number * radix + digit;
+    int overflow = static_cast<int>(number >> kSignificandSize);
+    if (overflow != 0) {
+      // Overflow occurred. Need to determine which direction to round the
+      // result.
+      int overflow_bits_count = 1;
+      while (overflow > 1) {
+        overflow_bits_count++;
+        overflow >>= 1;
+      }
+
+      int dropped_bits_mask = ((1 << overflow_bits_count) - 1);
+      int dropped_bits = static_cast<int>(number) & dropped_bits_mask;
+      number >>= overflow_bits_count;
+      exponent = overflow_bits_count;
+
+      bool zero_tail = true;
+      while (true) {
+        ++current;
+        if (current == end || !isDigit(*current, radix)) break;
+        zero_tail = zero_tail && *current == '0';
+        exponent += radix_log_2;
+      }
+
+      if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) {
+        return junk_string_value;
+      }
+
+      int middle_value = (1 << (overflow_bits_count - 1));
+      if (dropped_bits > middle_value) {
+        number++;  // Rounding up.
+      } else if (dropped_bits == middle_value) {
+        // Rounding to even to consistency with decimals: half-way case rounds
+        // up if significant part is odd and down otherwise.
+        if ((number & 1) != 0 || !zero_tail) {
+          number++;  // Rounding up.
+        }
+      }
+
+      // Rounding up may cause overflow.
+      if ((number & ((int64_t)1 << kSignificandSize)) != 0) {
+        exponent++;
+        number >>= 1;
+      }
+      break;
+    }
+    ++current;
+  } while (current != end);
+
+  ASSERT(number < ((int64_t)1 << kSignificandSize));
+  ASSERT(static_cast<int64_t>(static_cast<double>(number)) == number);
+
+  *trailing_pointer = current;
+
+  if (exponent == 0) {
+    if (sign) {
+      if (number == 0) return -0.0;
+      number = -number;
+    }
+    return static_cast<double>(number);
+  }
+
+  ASSERT(number != 0);
+  return Double(DiyFp(number, exponent)).value();
+}
+
+
+double StringToDoubleConverter::StringToIeee(
+    const char* input,
+    int length,
+    int* processed_characters_count,
+    bool read_as_double) const {
+  const char* current = input;
+  const char* end = input + length;
+
+  *processed_characters_count = 0;
+
+  const bool allow_trailing_junk = (flags_ & ALLOW_TRAILING_JUNK) != 0;
+  const bool allow_leading_spaces = (flags_ & ALLOW_LEADING_SPACES) != 0;
+  const bool allow_trailing_spaces = (flags_ & ALLOW_TRAILING_SPACES) != 0;
+  const bool allow_spaces_after_sign = (flags_ & ALLOW_SPACES_AFTER_SIGN) != 0;
+
+  // To make sure that iterator dereferencing is valid the following
+  // convention is used:
+  // 1. Each '++current' statement is followed by check for equality to 'end'.
+  // 2. If AdvanceToNonspace returned false then current == end.
+  // 3. If 'current' becomes equal to 'end' the function returns or goes to
+  // 'parsing_done'.
+  // 4. 'current' is not dereferenced after the 'parsing_done' label.
+  // 5. Code before 'parsing_done' may rely on 'current != end'.
+  if (current == end) return empty_string_value_;
+
+  if (allow_leading_spaces || allow_trailing_spaces) {
+    if (!AdvanceToNonspace(&current, end)) {
+      *processed_characters_count = current - input;
+      return empty_string_value_;
+    }
+    if (!allow_leading_spaces && (input != current)) {
+      // No leading spaces allowed, but AdvanceToNonspace moved forward.
+      return junk_string_value_;
+    }
+  }
+
+  // The longest form of simplified number is: "-<significant digits>.1eXXX\0".
+  const int kBufferSize = kMaxSignificantDigits + 10;
+  char buffer[kBufferSize];  // NOLINT: size is known at compile time.
+  int buffer_pos = 0;
+
+  // Exponent will be adjusted if insignificant digits of the integer part
+  // or insignificant leading zeros of the fractional part are dropped.
+  int exponent = 0;
+  int significant_digits = 0;
+  int insignificant_digits = 0;
+  bool nonzero_digit_dropped = false;
+
+  bool sign = false;
+
+  if (*current == '+' || *current == '-') {
+    sign = (*current == '-');
+    ++current;
+    const char* next_non_space = current;
+    // Skip following spaces (if allowed).
+    if (!AdvanceToNonspace(&next_non_space, end)) return junk_string_value_;
+    if (!allow_spaces_after_sign && (current != next_non_space)) {
+      return junk_string_value_;
+    }
+    current = next_non_space;
+  }
+
+  if (infinity_symbol_ != NULL) {
+    if (*current == infinity_symbol_[0]) {
+      if (!ConsumeSubString(&current, end, infinity_symbol_)) {
+        return junk_string_value_;
+      }
+
+      if (!(allow_trailing_spaces || allow_trailing_junk) && (current != end)) {
+        return junk_string_value_;
+      }
+      if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) {
+        return junk_string_value_;
+      }
+
+      ASSERT(buffer_pos == 0);
+      *processed_characters_count = current - input;
+      return sign ? -Double::Infinity() : Double::Infinity();
+    }
+  }
+
+  if (nan_symbol_ != NULL) {
+    if (*current == nan_symbol_[0]) {
+      if (!ConsumeSubString(&current, end, nan_symbol_)) {
+        return junk_string_value_;
+      }
+
+      if (!(allow_trailing_spaces || allow_trailing_junk) && (current != end)) {
+        return junk_string_value_;
+      }
+      if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) {
+        return junk_string_value_;
+      }
+
+      ASSERT(buffer_pos == 0);
+      *processed_characters_count = current - input;
+      return sign ? -Double::NaN() : Double::NaN();
+    }
+  }
+
+  bool leading_zero = false;
+  if (*current == '0') {
+    ++current;
+    if (current == end) {
+      *processed_characters_count = current - input;
+      return SignedZero(sign);
+    }
+
+    leading_zero = true;
+
+    // It could be hexadecimal value.
+    if ((flags_ & ALLOW_HEX) && (*current == 'x' || *current == 'X')) {
+      ++current;
+      if (current == end || !isDigit(*current, 16)) {
+        return junk_string_value_;  // "0x".
+      }
+
+      const char* tail_pointer = NULL;
+      double result = RadixStringToIeee<4>(current,
+                                           end,
+                                           sign,
+                                           allow_trailing_junk,
+                                           junk_string_value_,
+                                           read_as_double,
+                                           &tail_pointer);
+      if (tail_pointer != NULL) {
+        if (allow_trailing_spaces) AdvanceToNonspace(&tail_pointer, end);
+        *processed_characters_count = tail_pointer - input;
+      }
+      return result;
+    }
+
+    // Ignore leading zeros in the integer part.
+    while (*current == '0') {
+      ++current;
+      if (current == end) {
+        *processed_characters_count = current - input;
+        return SignedZero(sign);
+      }
+    }
+  }
+
+  bool octal = leading_zero && (flags_ & ALLOW_OCTALS) != 0;
+
+  // Copy significant digits of the integer part (if any) to the buffer.
+  while (*current >= '0' && *current <= '9') {
+    if (significant_digits < kMaxSignificantDigits) {
+      ASSERT(buffer_pos < kBufferSize);
+      buffer[buffer_pos++] = static_cast<char>(*current);
+      significant_digits++;
+      // Will later check if it's an octal in the buffer.
+    } else {
+      insignificant_digits++;  // Move the digit into the exponential part.
+      nonzero_digit_dropped = nonzero_digit_dropped || *current != '0';
+    }
+    octal = octal && *current < '8';
+    ++current;
+    if (current == end) goto parsing_done;
+  }
+
+  if (significant_digits == 0) {
+    octal = false;
+  }
+
+  if (*current == '.') {
+    if (octal && !allow_trailing_junk) return junk_string_value_;
+    if (octal) goto parsing_done;
+
+    ++current;
+    if (current == end) {
+      if (significant_digits == 0 && !leading_zero) {
+        return junk_string_value_;
+      } else {
+        goto parsing_done;
+      }
+    }
+
+    if (significant_digits == 0) {
+      // octal = false;
+      // Integer part consists of 0 or is absent. Significant digits start after
+      // leading zeros (if any).
+      while (*current == '0') {
+        ++current;
+        if (current == end) {
+          *processed_characters_count = current - input;
+          return SignedZero(sign);
+        }
+        exponent--;  // Move this 0 into the exponent.
+      }
+    }
+
+    // There is a fractional part.
+    // We don't emit a '.', but adjust the exponent instead.
+    while (*current >= '0' && *current <= '9') {
+      if (significant_digits < kMaxSignificantDigits) {
+        ASSERT(buffer_pos < kBufferSize);
+        buffer[buffer_pos++] = static_cast<char>(*current);
+        significant_digits++;
+        exponent--;
+      } else {
+        // Ignore insignificant digits in the fractional part.
+        nonzero_digit_dropped = nonzero_digit_dropped || *current != '0';
+      }
+      ++current;
+      if (current == end) goto parsing_done;
+    }
+  }
+
+  if (!leading_zero && exponent == 0 && significant_digits == 0) {
+    // If leading_zeros is true then the string contains zeros.
+    // If exponent < 0 then string was [+-]\.0*...
+    // If significant_digits != 0 the string is not equal to 0.
+    // Otherwise there are no digits in the string.
+    return junk_string_value_;
+  }
+
+  // Parse exponential part.
+  if (*current == 'e' || *current == 'E') {
+    if (octal && !allow_trailing_junk) return junk_string_value_;
+    if (octal) goto parsing_done;
+    ++current;
+    if (current == end) {
+      if (allow_trailing_junk) {
+        goto parsing_done;
+      } else {
+        return junk_string_value_;
+      }
+    }
+    char sign = '+';
+    if (*current == '+' || *current == '-') {
+      sign = static_cast<char>(*current);
+      ++current;
+      if (current == end) {
+        if (allow_trailing_junk) {
+          goto parsing_done;
+        } else {
+          return junk_string_value_;
+        }
+      }
+    }
+
+    if (current == end || *current < '0' || *current > '9') {
+      if (allow_trailing_junk) {
+        goto parsing_done;
+      } else {
+        return junk_string_value_;
+      }
+    }
+
+    const int max_exponent = INT_MAX / 2;
+    ASSERT(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2);
+    int num = 0;
+    do {
+      // Check overflow.
+      int digit = *current - '0';
+      if (num >= max_exponent / 10
+          && !(num == max_exponent / 10 && digit <= max_exponent % 10)) {
+        num = max_exponent;
+      } else {
+        num = num * 10 + digit;
+      }
+      ++current;
+    } while (current != end && *current >= '0' && *current <= '9');
+
+    exponent += (sign == '-' ? -num : num);
+  }
+
+  if (!(allow_trailing_spaces || allow_trailing_junk) && (current != end)) {
+    return junk_string_value_;
+  }
+  if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) {
+    return junk_string_value_;
+  }
+  if (allow_trailing_spaces) {
+    AdvanceToNonspace(&current, end);
+  }
+
+  parsing_done:
+  exponent += insignificant_digits;
+
+  if (octal) {
+    double result;
+    const char* tail_pointer = NULL;
+    result = RadixStringToIeee<3>(buffer,
+                                  buffer + buffer_pos,
+                                  sign,
+                                  allow_trailing_junk,
+                                  junk_string_value_,
+                                  read_as_double,
+                                  &tail_pointer);
+    ASSERT(tail_pointer != NULL);
+    *processed_characters_count = current - input;
+    return result;
+  }
+
+  if (nonzero_digit_dropped) {
+    buffer[buffer_pos++] = '1';
+    exponent--;
+  }
+
+  ASSERT(buffer_pos < kBufferSize);
+  buffer[buffer_pos] = '\0';
+
+  double converted;
+  if (read_as_double) {
+    converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent);
+  } else {
+    converted = Strtof(Vector<const char>(buffer, buffer_pos), exponent);
+  }
+  *processed_characters_count = current - input;
+  return sign? -converted: converted;
+}
+
+}  // namespace double_conversion
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/double-conversion.h b/src/third_party/mozjs-45/mfbt/double-conversion/double-conversion.h
new file mode 100644
index 0000000..957575c
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/double-conversion.h
@@ -0,0 +1,538 @@
+// Copyright 2012 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
+#define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
+
+#include "mozilla/Types.h"
+#include "utils.h"
+
+namespace double_conversion {
+
+class DoubleToStringConverter {
+ public:
+  // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint
+  // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the
+  // function returns false.
+  static const int kMaxFixedDigitsBeforePoint = 60;
+  static const int kMaxFixedDigitsAfterPoint = 60;
+
+  // When calling ToExponential with a requested_digits
+  // parameter > kMaxExponentialDigits then the function returns false.
+  static const int kMaxExponentialDigits = 120;
+
+  // When calling ToPrecision with a requested_digits
+  // parameter < kMinPrecisionDigits or requested_digits > kMaxPrecisionDigits
+  // then the function returns false.
+  static const int kMinPrecisionDigits = 1;
+  static const int kMaxPrecisionDigits = 120;
+
+  enum Flags {
+    NO_FLAGS = 0,
+    EMIT_POSITIVE_EXPONENT_SIGN = 1,
+    EMIT_TRAILING_DECIMAL_POINT = 2,
+    EMIT_TRAILING_ZERO_AFTER_POINT = 4,
+    UNIQUE_ZERO = 8
+  };
+
+  // Flags should be a bit-or combination of the possible Flags-enum.
+  //  - NO_FLAGS: no special flags.
+  //  - EMIT_POSITIVE_EXPONENT_SIGN: when the number is converted into exponent
+  //    form, emits a '+' for positive exponents. Example: 1.2e+2.
+  //  - EMIT_TRAILING_DECIMAL_POINT: when the input number is an integer and is
+  //    converted into decimal format then a trailing decimal point is appended.
+  //    Example: 2345.0 is converted to "2345.".
+  //  - EMIT_TRAILING_ZERO_AFTER_POINT: in addition to a trailing decimal point
+  //    emits a trailing '0'-character. This flag requires the
+  //    EXMIT_TRAILING_DECIMAL_POINT flag.
+  //    Example: 2345.0 is converted to "2345.0".
+  //  - UNIQUE_ZERO: "-0.0" is converted to "0.0".
+  //
+  // Infinity symbol and nan_symbol provide the string representation for these
+  // special values. If the string is NULL and the special value is encountered
+  // then the conversion functions return false.
+  //
+  // The exponent_character is used in exponential representations. It is
+  // usually 'e' or 'E'.
+  //
+  // When converting to the shortest representation the converter will
+  // represent input numbers in decimal format if they are in the interval
+  // [10^decimal_in_shortest_low; 10^decimal_in_shortest_high[
+  //    (lower boundary included, greater boundary excluded).
+  // Example: with decimal_in_shortest_low = -6 and
+  //               decimal_in_shortest_high = 21:
+  //   ToShortest(0.000001)  -> "0.000001"
+  //   ToShortest(0.0000001) -> "1e-7"
+  //   ToShortest(111111111111111111111.0)  -> "111111111111111110000"
+  //   ToShortest(100000000000000000000.0)  -> "100000000000000000000"
+  //   ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21"
+  //
+  // When converting to precision mode the converter may add
+  // max_leading_padding_zeroes before returning the number in exponential
+  // format.
+  // Example with max_leading_padding_zeroes_in_precision_mode = 6.
+  //   ToPrecision(0.0000012345, 2) -> "0.0000012"
+  //   ToPrecision(0.00000012345, 2) -> "1.2e-7"
+  // Similarily the converter may add up to
+  // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid
+  // returning an exponential representation. A zero added by the
+  // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit.
+  // Examples for max_trailing_padding_zeroes_in_precision_mode = 1:
+  //   ToPrecision(230.0, 2) -> "230"
+  //   ToPrecision(230.0, 2) -> "230."  with EMIT_TRAILING_DECIMAL_POINT.
+  //   ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT.
+  DoubleToStringConverter(int flags,
+                          const char* infinity_symbol,
+                          const char* nan_symbol,
+                          char exponent_character,
+                          int decimal_in_shortest_low,
+                          int decimal_in_shortest_high,
+                          int max_leading_padding_zeroes_in_precision_mode,
+                          int max_trailing_padding_zeroes_in_precision_mode)
+      : flags_(flags),
+        infinity_symbol_(infinity_symbol),
+        nan_symbol_(nan_symbol),
+        exponent_character_(exponent_character),
+        decimal_in_shortest_low_(decimal_in_shortest_low),
+        decimal_in_shortest_high_(decimal_in_shortest_high),
+        max_leading_padding_zeroes_in_precision_mode_(
+            max_leading_padding_zeroes_in_precision_mode),
+        max_trailing_padding_zeroes_in_precision_mode_(
+            max_trailing_padding_zeroes_in_precision_mode) {
+    // When 'trailing zero after the point' is set, then 'trailing point'
+    // must be set too.
+    ASSERT(((flags & EMIT_TRAILING_DECIMAL_POINT) != 0) ||
+        !((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0));
+  }
+
+  // Returns a converter following the EcmaScript specification.
+  static MFBT_API const DoubleToStringConverter& EcmaScriptConverter();
+
+  // Computes the shortest string of digits that correctly represent the input
+  // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high
+  // (see constructor) it then either returns a decimal representation, or an
+  // exponential representation.
+  // Example with decimal_in_shortest_low = -6,
+  //              decimal_in_shortest_high = 21,
+  //              EMIT_POSITIVE_EXPONENT_SIGN activated, and
+  //              EMIT_TRAILING_DECIMAL_POINT deactived:
+  //   ToShortest(0.000001)  -> "0.000001"
+  //   ToShortest(0.0000001) -> "1e-7"
+  //   ToShortest(111111111111111111111.0)  -> "111111111111111110000"
+  //   ToShortest(100000000000000000000.0)  -> "100000000000000000000"
+  //   ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21"
+  //
+  // Note: the conversion may round the output if the returned string
+  // is accurate enough to uniquely identify the input-number.
+  // For example the most precise representation of the double 9e59 equals
+  // "899999999999999918767229449717619953810131273674690656206848", but
+  // the converter will return the shorter (but still correct) "9e59".
+  //
+  // Returns true if the conversion succeeds. The conversion always succeeds
+  // except when the input value is special and no infinity_symbol or
+  // nan_symbol has been given to the constructor.
+  bool ToShortest(double value, StringBuilder* result_builder) const {
+    return ToShortestIeeeNumber(value, result_builder, SHORTEST);
+  }
+
+  // Same as ToShortest, but for single-precision floats.
+  bool ToShortestSingle(float value, StringBuilder* result_builder) const {
+    return ToShortestIeeeNumber(value, result_builder, SHORTEST_SINGLE);
+  }
+
+
+  // Computes a decimal representation with a fixed number of digits after the
+  // decimal point. The last emitted digit is rounded.
+  //
+  // Examples:
+  //   ToFixed(3.12, 1) -> "3.1"
+  //   ToFixed(3.1415, 3) -> "3.142"
+  //   ToFixed(1234.56789, 4) -> "1234.5679"
+  //   ToFixed(1.23, 5) -> "1.23000"
+  //   ToFixed(0.1, 4) -> "0.1000"
+  //   ToFixed(1e30, 2) -> "1000000000000000019884624838656.00"
+  //   ToFixed(0.1, 30) -> "0.100000000000000005551115123126"
+  //   ToFixed(0.1, 17) -> "0.10000000000000001"
+  //
+  // If requested_digits equals 0, then the tail of the result depends on
+  // the EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT.
+  // Examples, for requested_digits == 0,
+  //   let EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT be
+  //    - false and false: then 123.45 -> 123
+  //                             0.678 -> 1
+  //    - true and false: then 123.45 -> 123.
+  //                            0.678 -> 1.
+  //    - true and true: then 123.45 -> 123.0
+  //                           0.678 -> 1.0
+  //
+  // Returns true if the conversion succeeds. The conversion always succeeds
+  // except for the following cases:
+  //   - the input value is special and no infinity_symbol or nan_symbol has
+  //     been provided to the constructor,
+  //   - 'value' > 10^kMaxFixedDigitsBeforePoint, or
+  //   - 'requested_digits' > kMaxFixedDigitsAfterPoint.
+  // The last two conditions imply that the result will never contain more than
+  // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters
+  // (one additional character for the sign, and one for the decimal point).
+  MFBT_API bool ToFixed(double value,
+               int requested_digits,
+               StringBuilder* result_builder) const;
+
+  // Computes a representation in exponential format with requested_digits
+  // after the decimal point. The last emitted digit is rounded.
+  // If requested_digits equals -1, then the shortest exponential representation
+  // is computed.
+  //
+  // Examples with EMIT_POSITIVE_EXPONENT_SIGN deactivated, and
+  //               exponent_character set to 'e'.
+  //   ToExponential(3.12, 1) -> "3.1e0"
+  //   ToExponential(5.0, 3) -> "5.000e0"
+  //   ToExponential(0.001, 2) -> "1.00e-3"
+  //   ToExponential(3.1415, -1) -> "3.1415e0"
+  //   ToExponential(3.1415, 4) -> "3.1415e0"
+  //   ToExponential(3.1415, 3) -> "3.142e0"
+  //   ToExponential(123456789000000, 3) -> "1.235e14"
+  //   ToExponential(1000000000000000019884624838656.0, -1) -> "1e30"
+  //   ToExponential(1000000000000000019884624838656.0, 32) ->
+  //                     "1.00000000000000001988462483865600e30"
+  //   ToExponential(1234, 0) -> "1e3"
+  //
+  // Returns true if the conversion succeeds. The conversion always succeeds
+  // except for the following cases:
+  //   - the input value is special and no infinity_symbol or nan_symbol has
+  //     been provided to the constructor,
+  //   - 'requested_digits' > kMaxExponentialDigits.
+  // The last condition implies that the result will never contain more than
+  // kMaxExponentialDigits + 8 characters (the sign, the digit before the
+  // decimal point, the decimal point, the exponent character, the
+  // exponent's sign, and at most 3 exponent digits).
+  MFBT_API bool ToExponential(double value,
+                     int requested_digits,
+                     StringBuilder* result_builder) const;
+
+  // Computes 'precision' leading digits of the given 'value' and returns them
+  // either in exponential or decimal format, depending on
+  // max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the
+  // constructor).
+  // The last computed digit is rounded.
+  //
+  // Example with max_leading_padding_zeroes_in_precision_mode = 6.
+  //   ToPrecision(0.0000012345, 2) -> "0.0000012"
+  //   ToPrecision(0.00000012345, 2) -> "1.2e-7"
+  // Similarily the converter may add up to
+  // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid
+  // returning an exponential representation. A zero added by the
+  // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit.
+  // Examples for max_trailing_padding_zeroes_in_precision_mode = 1:
+  //   ToPrecision(230.0, 2) -> "230"
+  //   ToPrecision(230.0, 2) -> "230."  with EMIT_TRAILING_DECIMAL_POINT.
+  //   ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT.
+  // Examples for max_trailing_padding_zeroes_in_precision_mode = 3, and no
+  //    EMIT_TRAILING_ZERO_AFTER_POINT:
+  //   ToPrecision(123450.0, 6) -> "123450"
+  //   ToPrecision(123450.0, 5) -> "123450"
+  //   ToPrecision(123450.0, 4) -> "123500"
+  //   ToPrecision(123450.0, 3) -> "123000"
+  //   ToPrecision(123450.0, 2) -> "1.2e5"
+  //
+  // Returns true if the conversion succeeds. The conversion always succeeds
+  // except for the following cases:
+  //   - the input value is special and no infinity_symbol or nan_symbol has
+  //     been provided to the constructor,
+  //   - precision < kMinPericisionDigits
+  //   - precision > kMaxPrecisionDigits
+  // The last condition implies that the result will never contain more than
+  // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
+  // exponent character, the exponent's sign, and at most 3 exponent digits).
+  MFBT_API bool ToPrecision(double value,
+                   int precision,
+                   bool* used_exponential_notation,
+                   StringBuilder* result_builder) const;
+
+  enum DtoaMode {
+    // Produce the shortest correct representation.
+    // For example the output of 0.299999999999999988897 is (the less accurate
+    // but correct) 0.3.
+    SHORTEST,
+    // Same as SHORTEST, but for single-precision floats.
+    SHORTEST_SINGLE,
+    // Produce a fixed number of digits after the decimal point.
+    // For instance fixed(0.1, 4) becomes 0.1000
+    // If the input number is big, the output will be big.
+    FIXED,
+    // Fixed number of digits (independent of the decimal point).
+    PRECISION
+  };
+
+  // The maximal number of digits that are needed to emit a double in base 10.
+  // A higher precision can be achieved by using more digits, but the shortest
+  // accurate representation of any double will never use more digits than
+  // kBase10MaximalLength.
+  // Note that DoubleToAscii null-terminates its input. So the given buffer
+  // should be at least kBase10MaximalLength + 1 characters long.
+  static const MFBT_DATA int kBase10MaximalLength = 17;
+
+  // Converts the given double 'v' to ascii. 'v' must not be NaN, +Infinity, or
+  // -Infinity. In SHORTEST_SINGLE-mode this restriction also applies to 'v'
+  // after it has been casted to a single-precision float. That is, in this
+  // mode static_cast<float>(v) must not be NaN, +Infinity or -Infinity.
+  //
+  // The result should be interpreted as buffer * 10^(point-length).
+  //
+  // The output depends on the given mode:
+  //  - SHORTEST: produce the least amount of digits for which the internal
+  //   identity requirement is still satisfied. If the digits are printed
+  //   (together with the correct exponent) then reading this number will give
+  //   'v' again. The buffer will choose the representation that is closest to
+  //   'v'. If there are two at the same distance, than the one farther away
+  //   from 0 is chosen (halfway cases - ending with 5 - are rounded up).
+  //   In this mode the 'requested_digits' parameter is ignored.
+  //  - SHORTEST_SINGLE: same as SHORTEST but with single-precision.
+  //  - FIXED: produces digits necessary to print a given number with
+  //   'requested_digits' digits after the decimal point. The produced digits
+  //   might be too short in which case the caller has to fill the remainder
+  //   with '0's.
+  //   Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2.
+  //   Halfway cases are rounded towards +/-Infinity (away from 0). The call
+  //   toFixed(0.15, 2) thus returns buffer="2", point=0.
+  //   The returned buffer may contain digits that would be truncated from the
+  //   shortest representation of the input.
+  //  - PRECISION: produces 'requested_digits' where the first digit is not '0'.
+  //   Even though the length of produced digits usually equals
+  //   'requested_digits', the function is allowed to return fewer digits, in
+  //   which case the caller has to fill the missing digits with '0's.
+  //   Halfway cases are again rounded away from 0.
+  // DoubleToAscii expects the given buffer to be big enough to hold all
+  // digits and a terminating null-character. In SHORTEST-mode it expects a
+  // buffer of at least kBase10MaximalLength + 1. In all other modes the
+  // requested_digits parameter and the padding-zeroes limit the size of the
+  // output. Don't forget the decimal point, the exponent character and the
+  // terminating null-character when computing the maximal output size.
+  // The given length is only used in debug mode to ensure the buffer is big
+  // enough.
+  static MFBT_API void DoubleToAscii(double v,
+                            DtoaMode mode,
+                            int requested_digits,
+                            char* buffer,
+                            int buffer_length,
+                            bool* sign,
+                            int* length,
+                            int* point);
+
+ private:
+  // Implementation for ToShortest and ToShortestSingle.
+  MFBT_API bool ToShortestIeeeNumber(double value,
+                            StringBuilder* result_builder,
+                            DtoaMode mode) const;
+
+  // If the value is a special value (NaN or Infinity) constructs the
+  // corresponding string using the configured infinity/nan-symbol.
+  // If either of them is NULL or the value is not special then the
+  // function returns false.
+  MFBT_API bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
+  // Constructs an exponential representation (i.e. 1.234e56).
+  // The given exponent assumes a decimal point after the first decimal digit.
+  MFBT_API void CreateExponentialRepresentation(const char* decimal_digits,
+                                       int length,
+                                       int exponent,
+                                       StringBuilder* result_builder) const;
+  // Creates a decimal representation (i.e 1234.5678).
+  MFBT_API void CreateDecimalRepresentation(const char* decimal_digits,
+                                   int length,
+                                   int decimal_point,
+                                   int digits_after_point,
+                                   StringBuilder* result_builder) const;
+
+  const int flags_;
+  const char* const infinity_symbol_;
+  const char* const nan_symbol_;
+  const char exponent_character_;
+  const int decimal_in_shortest_low_;
+  const int decimal_in_shortest_high_;
+  const int max_leading_padding_zeroes_in_precision_mode_;
+  const int max_trailing_padding_zeroes_in_precision_mode_;
+
+  DISALLOW_IMPLICIT_CONSTRUCTORS(DoubleToStringConverter);
+};
+
+
+class StringToDoubleConverter {
+ public:
+  // Enumeration for allowing octals and ignoring junk when converting
+  // strings to numbers.
+  enum Flags {
+    NO_FLAGS = 0,
+    ALLOW_HEX = 1,
+    ALLOW_OCTALS = 2,
+    ALLOW_TRAILING_JUNK = 4,
+    ALLOW_LEADING_SPACES = 8,
+    ALLOW_TRAILING_SPACES = 16,
+    ALLOW_SPACES_AFTER_SIGN = 32
+  };
+
+  // Flags should be a bit-or combination of the possible Flags-enum.
+  //  - NO_FLAGS: no special flags.
+  //  - ALLOW_HEX: recognizes the prefix "0x". Hex numbers may only be integers.
+  //      Ex: StringToDouble("0x1234") -> 4660.0
+  //          In StringToDouble("0x1234.56") the characters ".56" are trailing
+  //          junk. The result of the call is hence dependent on
+  //          the ALLOW_TRAILING_JUNK flag and/or the junk value.
+  //      With this flag "0x" is a junk-string. Even with ALLOW_TRAILING_JUNK,
+  //      the string will not be parsed as "0" followed by junk.
+  //
+  //  - ALLOW_OCTALS: recognizes the prefix "0" for octals:
+  //      If a sequence of octal digits starts with '0', then the number is
+  //      read as octal integer. Octal numbers may only be integers.
+  //      Ex: StringToDouble("01234") -> 668.0
+  //          StringToDouble("012349") -> 12349.0  // Not a sequence of octal
+  //                                               // digits.
+  //          In StringToDouble("01234.56") the characters ".56" are trailing
+  //          junk. The result of the call is hence dependent on
+  //          the ALLOW_TRAILING_JUNK flag and/or the junk value.
+  //          In StringToDouble("01234e56") the characters "e56" are trailing
+  //          junk, too.
+  //  - ALLOW_TRAILING_JUNK: ignore trailing characters that are not part of
+  //      a double literal.
+  //  - ALLOW_LEADING_SPACES: skip over leading spaces.
+  //  - ALLOW_TRAILING_SPACES: ignore trailing spaces.
+  //  - ALLOW_SPACES_AFTER_SIGN: ignore spaces after the sign.
+  //       Ex: StringToDouble("-   123.2") -> -123.2.
+  //           StringToDouble("+   123.2") -> 123.2
+  //
+  // empty_string_value is returned when an empty string is given as input.
+  // If ALLOW_LEADING_SPACES or ALLOW_TRAILING_SPACES are set, then a string
+  // containing only spaces is converted to the 'empty_string_value', too.
+  //
+  // junk_string_value is returned when
+  //  a) ALLOW_TRAILING_JUNK is not set, and a junk character (a character not
+  //     part of a double-literal) is found.
+  //  b) ALLOW_TRAILING_JUNK is set, but the string does not start with a
+  //     double literal.
+  //
+  // infinity_symbol and nan_symbol are strings that are used to detect
+  // inputs that represent infinity and NaN. They can be null, in which case
+  // they are ignored.
+  // The conversion routine first reads any possible signs. Then it compares the
+  // following character of the input-string with the first character of
+  // the infinity, and nan-symbol. If either matches, the function assumes, that
+  // a match has been found, and expects the following input characters to match
+  // the remaining characters of the special-value symbol.
+  // This means that the following restrictions apply to special-value symbols:
+  //  - they must not start with signs ('+', or '-'),
+  //  - they must not have the same first character.
+  //  - they must not start with digits.
+  //
+  // Examples:
+  //  flags = ALLOW_HEX | ALLOW_TRAILING_JUNK,
+  //  empty_string_value = 0.0,
+  //  junk_string_value = NaN,
+  //  infinity_symbol = "infinity",
+  //  nan_symbol = "nan":
+  //    StringToDouble("0x1234") -> 4660.0.
+  //    StringToDouble("0x1234K") -> 4660.0.
+  //    StringToDouble("") -> 0.0  // empty_string_value.
+  //    StringToDouble(" ") -> NaN  // junk_string_value.
+  //    StringToDouble(" 1") -> NaN  // junk_string_value.
+  //    StringToDouble("0x") -> NaN  // junk_string_value.
+  //    StringToDouble("-123.45") -> -123.45.
+  //    StringToDouble("--123.45") -> NaN  // junk_string_value.
+  //    StringToDouble("123e45") -> 123e45.
+  //    StringToDouble("123E45") -> 123e45.
+  //    StringToDouble("123e+45") -> 123e45.
+  //    StringToDouble("123E-45") -> 123e-45.
+  //    StringToDouble("123e") -> 123.0  // trailing junk ignored.
+  //    StringToDouble("123e-") -> 123.0  // trailing junk ignored.
+  //    StringToDouble("+NaN") -> NaN  // NaN string literal.
+  //    StringToDouble("-infinity") -> -inf.  // infinity literal.
+  //    StringToDouble("Infinity") -> NaN  // junk_string_value.
+  //
+  //  flags = ALLOW_OCTAL | ALLOW_LEADING_SPACES,
+  //  empty_string_value = 0.0,
+  //  junk_string_value = NaN,
+  //  infinity_symbol = NULL,
+  //  nan_symbol = NULL:
+  //    StringToDouble("0x1234") -> NaN  // junk_string_value.
+  //    StringToDouble("01234") -> 668.0.
+  //    StringToDouble("") -> 0.0  // empty_string_value.
+  //    StringToDouble(" ") -> 0.0  // empty_string_value.
+  //    StringToDouble(" 1") -> 1.0
+  //    StringToDouble("0x") -> NaN  // junk_string_value.
+  //    StringToDouble("0123e45") -> NaN  // junk_string_value.
+  //    StringToDouble("01239E45") -> 1239e45.
+  //    StringToDouble("-infinity") -> NaN  // junk_string_value.
+  //    StringToDouble("NaN") -> NaN  // junk_string_value.
+  StringToDoubleConverter(int flags,
+                          double empty_string_value,
+                          double junk_string_value,
+                          const char* infinity_symbol,
+                          const char* nan_symbol)
+      : flags_(flags),
+        empty_string_value_(empty_string_value),
+        junk_string_value_(junk_string_value),
+        infinity_symbol_(infinity_symbol),
+        nan_symbol_(nan_symbol) {
+  }
+
+  // Performs the conversion.
+  // The output parameter 'processed_characters_count' is set to the number
+  // of characters that have been processed to read the number.
+  // Spaces than are processed with ALLOW_{LEADING|TRAILING}_SPACES are included
+  // in the 'processed_characters_count'. Trailing junk is never included.
+  double StringToDouble(const char* buffer,
+                        int length,
+                        int* processed_characters_count) const {
+    return StringToIeee(buffer, length, processed_characters_count, true);
+  }
+
+  // Same as StringToDouble but reads a float.
+  // Note that this is not equivalent to static_cast<float>(StringToDouble(...))
+  // due to potential double-rounding.
+  float StringToFloat(const char* buffer,
+                      int length,
+                      int* processed_characters_count) const {
+    return static_cast<float>(StringToIeee(buffer, length,
+                                           processed_characters_count, false));
+  }
+
+ private:
+  const int flags_;
+  const double empty_string_value_;
+  const double junk_string_value_;
+  const char* const infinity_symbol_;
+  const char* const nan_symbol_;
+
+  double StringToIeee(const char* buffer,
+                      int length,
+                      int* processed_characters_count,
+                      bool read_as_double) const;
+
+  DISALLOW_IMPLICIT_CONSTRUCTORS(StringToDoubleConverter);
+};
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/fast-dtoa.cc b/src/third_party/mozjs-45/mfbt/double-conversion/fast-dtoa.cc
new file mode 100644
index 0000000..1a0f823
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/fast-dtoa.cc
@@ -0,0 +1,664 @@
+// Copyright 2012 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "fast-dtoa.h"
+
+#include "cached-powers.h"
+#include "diy-fp.h"
+#include "ieee.h"
+
+namespace double_conversion {
+
+// The minimal and maximal target exponent define the range of w's binary
+// exponent, where 'w' is the result of multiplying the input by a cached power
+// of ten.
+//
+// A different range might be chosen on a different platform, to optimize digit
+// generation, but a smaller range requires more powers of ten to be cached.
+static const int kMinimalTargetExponent = -60;
+static const int kMaximalTargetExponent = -32;
+
+
+// Adjusts the last digit of the generated number, and screens out generated
+// solutions that may be inaccurate. A solution may be inaccurate if it is
+// outside the safe interval, or if we cannot prove that it is closer to the
+// input than a neighboring representation of the same length.
+//
+// Input: * buffer containing the digits of too_high / 10^kappa
+//        * the buffer's length
+//        * distance_too_high_w == (too_high - w).f() * unit
+//        * unsafe_interval == (too_high - too_low).f() * unit
+//        * rest = (too_high - buffer * 10^kappa).f() * unit
+//        * ten_kappa = 10^kappa * unit
+//        * unit = the common multiplier
+// Output: returns true if the buffer is guaranteed to contain the closest
+//    representable number to the input.
+//  Modifies the generated digits in the buffer to approach (round towards) w.
+static bool RoundWeed(Vector<char> buffer,
+                      int length,
+                      uint64_t distance_too_high_w,
+                      uint64_t unsafe_interval,
+                      uint64_t rest,
+                      uint64_t ten_kappa,
+                      uint64_t unit) {
+  uint64_t small_distance = distance_too_high_w - unit;
+  uint64_t big_distance = distance_too_high_w + unit;
+  // Let w_low  = too_high - big_distance, and
+  //     w_high = too_high - small_distance.
+  // Note: w_low < w < w_high
+  //
+  // The real w (* unit) must lie somewhere inside the interval
+  // ]w_low; w_high[ (often written as "(w_low; w_high)")
+
+  // Basically the buffer currently contains a number in the unsafe interval
+  // ]too_low; too_high[ with too_low < w < too_high
+  //
+  //  too_high - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+  //                     ^v 1 unit            ^      ^                 ^      ^
+  //  boundary_high ---------------------     .      .                 .      .
+  //                     ^v 1 unit            .      .                 .      .
+  //   - - - - - - - - - - - - - - - - - - -  +  - - + - - - - - -     .      .
+  //                                          .      .         ^       .      .
+  //                                          .  big_distance  .       .      .
+  //                                          .      .         .       .    rest
+  //                              small_distance     .         .       .      .
+  //                                          v      .         .       .      .
+  //  w_high - - - - - - - - - - - - - - - - - -     .         .       .      .
+  //                     ^v 1 unit                   .         .       .      .
+  //  w ----------------------------------------     .         .       .      .
+  //                     ^v 1 unit                   v         .       .      .
+  //  w_low  - - - - - - - - - - - - - - - - - - - - -         .       .      .
+  //                                                           .       .      v
+  //  buffer --------------------------------------------------+-------+--------
+  //                                                           .       .
+  //                                                  safe_interval    .
+  //                                                           v       .
+  //   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -     .
+  //                     ^v 1 unit                                     .
+  //  boundary_low -------------------------                     unsafe_interval
+  //                     ^v 1 unit                                     v
+  //  too_low  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+  //
+  //
+  // Note that the value of buffer could lie anywhere inside the range too_low
+  // to too_high.
+  //
+  // boundary_low, boundary_high and w are approximations of the real boundaries
+  // and v (the input number). They are guaranteed to be precise up to one unit.
+  // In fact the error is guaranteed to be strictly less than one unit.
+  //
+  // Anything that lies outside the unsafe interval is guaranteed not to round
+  // to v when read again.
+  // Anything that lies inside the safe interval is guaranteed to round to v
+  // when read again.
+  // If the number inside the buffer lies inside the unsafe interval but not
+  // inside the safe interval then we simply do not know and bail out (returning
+  // false).
+  //
+  // Similarly we have to take into account the imprecision of 'w' when finding
+  // the closest representation of 'w'. If we have two potential
+  // representations, and one is closer to both w_low and w_high, then we know
+  // it is closer to the actual value v.
+  //
+  // By generating the digits of too_high we got the largest (closest to
+  // too_high) buffer that is still in the unsafe interval. In the case where
+  // w_high < buffer < too_high we try to decrement the buffer.
+  // This way the buffer approaches (rounds towards) w.
+  // There are 3 conditions that stop the decrementation process:
+  //   1) the buffer is already below w_high
+  //   2) decrementing the buffer would make it leave the unsafe interval
+  //   3) decrementing the buffer would yield a number below w_high and farther
+  //      away than the current number. In other words:
+  //              (buffer{-1} < w_high) && w_high - buffer{-1} > buffer - w_high
+  // Instead of using the buffer directly we use its distance to too_high.
+  // Conceptually rest ~= too_high - buffer
+  // We need to do the following tests in this order to avoid over- and
+  // underflows.
+  ASSERT(rest <= unsafe_interval);
+  while (rest < small_distance &&  // Negated condition 1
+         unsafe_interval - rest >= ten_kappa &&  // Negated condition 2
+         (rest + ten_kappa < small_distance ||  // buffer{-1} > w_high
+          small_distance - rest >= rest + ten_kappa - small_distance)) {
+    buffer[length - 1]--;
+    rest += ten_kappa;
+  }
+
+  // We have approached w+ as much as possible. We now test if approaching w-
+  // would require changing the buffer. If yes, then we have two possible
+  // representations close to w, but we cannot decide which one is closer.
+  if (rest < big_distance &&
+      unsafe_interval - rest >= ten_kappa &&
+      (rest + ten_kappa < big_distance ||
+       big_distance - rest > rest + ten_kappa - big_distance)) {
+    return false;
+  }
+
+  // Weeding test.
+  //   The safe interval is [too_low + 2 ulp; too_high - 2 ulp]
+  //   Since too_low = too_high - unsafe_interval this is equivalent to
+  //      [too_high - unsafe_interval + 4 ulp; too_high - 2 ulp]
+  //   Conceptually we have: rest ~= too_high - buffer
+  return (2 * unit <= rest) && (rest <= unsafe_interval - 4 * unit);
+}
+
+
+// Rounds the buffer upwards if the result is closer to v by possibly adding
+// 1 to the buffer. If the precision of the calculation is not sufficient to
+// round correctly, return false.
+// The rounding might shift the whole buffer in which case the kappa is
+// adjusted. For example "99", kappa = 3 might become "10", kappa = 4.
+//
+// If 2*rest > ten_kappa then the buffer needs to be round up.
+// rest can have an error of +/- 1 unit. This function accounts for the
+// imprecision and returns false, if the rounding direction cannot be
+// unambiguously determined.
+//
+// Precondition: rest < ten_kappa.
+static bool RoundWeedCounted(Vector<char> buffer,
+                             int length,
+                             uint64_t rest,
+                             uint64_t ten_kappa,
+                             uint64_t unit,
+                             int* kappa) {
+  ASSERT(rest < ten_kappa);
+  // The following tests are done in a specific order to avoid overflows. They
+  // will work correctly with any uint64 values of rest < ten_kappa and unit.
+  //
+  // If the unit is too big, then we don't know which way to round. For example
+  // a unit of 50 means that the real number lies within rest +/- 50. If
+  // 10^kappa == 40 then there is no way to tell which way to round.
+  if (unit >= ten_kappa) return false;
+  // Even if unit is just half the size of 10^kappa we are already completely
+  // lost. (And after the previous test we know that the expression will not
+  // over/underflow.)
+  if (ten_kappa - unit <= unit) return false;
+  // If 2 * (rest + unit) <= 10^kappa we can safely round down.
+  if ((ten_kappa - rest > rest) && (ten_kappa - 2 * rest >= 2 * unit)) {
+    return true;
+  }
+  // If 2 * (rest - unit) >= 10^kappa, then we can safely round up.
+  if ((rest > unit) && (ten_kappa - (rest - unit) <= (rest - unit))) {
+    // Increment the last digit recursively until we find a non '9' digit.
+    buffer[length - 1]++;
+    for (int i = length - 1; i > 0; --i) {
+      if (buffer[i] != '0' + 10) break;
+      buffer[i] = '0';
+      buffer[i - 1]++;
+    }
+    // If the first digit is now '0'+ 10 we had a buffer with all '9's. With the
+    // exception of the first digit all digits are now '0'. Simply switch the
+    // first digit to '1' and adjust the kappa. Example: "99" becomes "10" and
+    // the power (the kappa) is increased.
+    if (buffer[0] == '0' + 10) {
+      buffer[0] = '1';
+      (*kappa) += 1;
+    }
+    return true;
+  }
+  return false;
+}
+
+// Returns the biggest power of ten that is less than or equal to the given
+// number. We furthermore receive the maximum number of bits 'number' has.
+//
+// Returns power == 10^(exponent_plus_one-1) such that
+//    power <= number < power * 10.
+// If number_bits == 0 then 0^(0-1) is returned.
+// The number of bits must be <= 32.
+// Precondition: number < (1 << (number_bits + 1)).
+
+// Inspired by the method for finding an integer log base 10 from here:
+// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
+static unsigned int const kSmallPowersOfTen[] =
+    {0, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000,
+     1000000000};
+
+static void BiggestPowerTen(uint32_t number,
+                            int number_bits,
+                            uint32_t* power,
+                            int* exponent_plus_one) {
+  ASSERT(number < (1u << (number_bits + 1)));
+  // 1233/4096 is approximately 1/lg(10).
+  int exponent_plus_one_guess = ((number_bits + 1) * 1233 >> 12);
+  // We increment to skip over the first entry in the kPowersOf10 table.
+  // Note: kPowersOf10[i] == 10^(i-1).
+  exponent_plus_one_guess++;
+  // We don't have any guarantees that 2^number_bits <= number.
+  // TODO(floitsch): can we change the 'while' into an 'if'? We definitely see
+  // number < (2^number_bits - 1), but I haven't encountered
+  // number < (2^number_bits - 2) yet.
+  while (number < kSmallPowersOfTen[exponent_plus_one_guess]) {
+    exponent_plus_one_guess--;
+  }
+  *power = kSmallPowersOfTen[exponent_plus_one_guess];
+  *exponent_plus_one = exponent_plus_one_guess;
+}
+
+// Generates the digits of input number w.
+// w is a floating-point number (DiyFp), consisting of a significand and an
+// exponent. Its exponent is bounded by kMinimalTargetExponent and
+// kMaximalTargetExponent.
+//       Hence -60 <= w.e() <= -32.
+//
+// Returns false if it fails, in which case the generated digits in the buffer
+// should not be used.
+// Preconditions:
+//  * low, w and high are correct up to 1 ulp (unit in the last place). That
+//    is, their error must be less than a unit of their last digits.
+//  * low.e() == w.e() == high.e()
+//  * low < w < high, and taking into account their error: low~ <= high~
+//  * kMinimalTargetExponent <= w.e() <= kMaximalTargetExponent
+// Postconditions: returns false if procedure fails.
+//   otherwise:
+//     * buffer is not null-terminated, but len contains the number of digits.
+//     * buffer contains the shortest possible decimal digit-sequence
+//       such that LOW < buffer * 10^kappa < HIGH, where LOW and HIGH are the
+//       correct values of low and high (without their error).
+//     * if more than one decimal representation gives the minimal number of
+//       decimal digits then the one closest to W (where W is the correct value
+//       of w) is chosen.
+// Remark: this procedure takes into account the imprecision of its input
+//   numbers. If the precision is not enough to guarantee all the postconditions
+//   then false is returned. This usually happens rarely (~0.5%).
+//
+// Say, for the sake of example, that
+//   w.e() == -48, and w.f() == 0x1234567890abcdef
+// w's value can be computed by w.f() * 2^w.e()
+// We can obtain w's integral digits by simply shifting w.f() by -w.e().
+//  -> w's integral part is 0x1234
+//  w's fractional part is therefore 0x567890abcdef.
+// Printing w's integral part is easy (simply print 0x1234 in decimal).
+// In order to print its fraction we repeatedly multiply the fraction by 10 and
+// get each digit. Example the first digit after the point would be computed by
+//   (0x567890abcdef * 10) >> 48. -> 3
+// The whole thing becomes slightly more complicated because we want to stop
+// once we have enough digits. That is, once the digits inside the buffer
+// represent 'w' we can stop. Everything inside the interval low - high
+// represents w. However we have to pay attention to low, high and w's
+// imprecision.
+static bool DigitGen(DiyFp low,
+                     DiyFp w,
+                     DiyFp high,
+                     Vector<char> buffer,
+                     int* length,
+                     int* kappa) {
+  ASSERT(low.e() == w.e() && w.e() == high.e());
+  ASSERT(low.f() + 1 <= high.f() - 1);
+  ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent);
+  // low, w and high are imprecise, but by less than one ulp (unit in the last
+  // place).
+  // If we remove (resp. add) 1 ulp from low (resp. high) we are certain that
+  // the new numbers are outside of the interval we want the final
+  // representation to lie in.
+  // Inversely adding (resp. removing) 1 ulp from low (resp. high) would yield
+  // numbers that are certain to lie in the interval. We will use this fact
+  // later on.
+  // We will now start by generating the digits within the uncertain
+  // interval. Later we will weed out representations that lie outside the safe
+  // interval and thus _might_ lie outside the correct interval.
+  uint64_t unit = 1;
+  DiyFp too_low = DiyFp(low.f() - unit, low.e());
+  DiyFp too_high = DiyFp(high.f() + unit, high.e());
+  // too_low and too_high are guaranteed to lie outside the interval we want the
+  // generated number in.
+  DiyFp unsafe_interval = DiyFp::Minus(too_high, too_low);
+  // We now cut the input number into two parts: the integral digits and the
+  // fractionals. We will not write any decimal separator though, but adapt
+  // kappa instead.
+  // Reminder: we are currently computing the digits (stored inside the buffer)
+  // such that:   too_low < buffer * 10^kappa < too_high
+  // We use too_high for the digit_generation and stop as soon as possible.
+  // If we stop early we effectively round down.
+  DiyFp one = DiyFp(static_cast<uint64_t>(1) << -w.e(), w.e());
+  // Division by one is a shift.
+  uint32_t integrals = static_cast<uint32_t>(too_high.f() >> -one.e());
+  // Modulo by one is an and.
+  uint64_t fractionals = too_high.f() & (one.f() - 1);
+  uint32_t divisor;
+  int divisor_exponent_plus_one;
+  BiggestPowerTen(integrals, DiyFp::kSignificandSize - (-one.e()),
+                  &divisor, &divisor_exponent_plus_one);
+  *kappa = divisor_exponent_plus_one;
+  *length = 0;
+  // Loop invariant: buffer = too_high / 10^kappa  (integer division)
+  // The invariant holds for the first iteration: kappa has been initialized
+  // with the divisor exponent + 1. And the divisor is the biggest power of ten
+  // that is smaller than integrals.
+  while (*kappa > 0) {
+    int digit = integrals / divisor;
+    buffer[*length] = '0' + digit;
+    (*length)++;
+    integrals %= divisor;
+    (*kappa)--;
+    // Note that kappa now equals the exponent of the divisor and that the
+    // invariant thus holds again.
+    uint64_t rest =
+        (static_cast<uint64_t>(integrals) << -one.e()) + fractionals;
+    // Invariant: too_high = buffer * 10^kappa + DiyFp(rest, one.e())
+    // Reminder: unsafe_interval.e() == one.e()
+    if (rest < unsafe_interval.f()) {
+      // Rounding down (by not emitting the remaining digits) yields a number
+      // that lies within the unsafe interval.
+      return RoundWeed(buffer, *length, DiyFp::Minus(too_high, w).f(),
+                       unsafe_interval.f(), rest,
+                       static_cast<uint64_t>(divisor) << -one.e(), unit);
+    }
+    divisor /= 10;
+  }
+
+  // The integrals have been generated. We are at the point of the decimal
+  // separator. In the following loop we simply multiply the remaining digits by
+  // 10 and divide by one. We just need to pay attention to multiply associated
+  // data (like the interval or 'unit'), too.
+  // Note that the multiplication by 10 does not overflow, because w.e >= -60
+  // and thus one.e >= -60.
+  ASSERT(one.e() >= -60);
+  ASSERT(fractionals < one.f());
+  ASSERT(UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f());
+  while (true) {
+    fractionals *= 10;
+    unit *= 10;
+    unsafe_interval.set_f(unsafe_interval.f() * 10);
+    // Integer division by one.
+    int digit = static_cast<int>(fractionals >> -one.e());
+    buffer[*length] = '0' + digit;
+    (*length)++;
+    fractionals &= one.f() - 1;  // Modulo by one.
+    (*kappa)--;
+    if (fractionals < unsafe_interval.f()) {
+      return RoundWeed(buffer, *length, DiyFp::Minus(too_high, w).f() * unit,
+                       unsafe_interval.f(), fractionals, one.f(), unit);
+    }
+  }
+}
+
+
+
+// Generates (at most) requested_digits digits of input number w.
+// w is a floating-point number (DiyFp), consisting of a significand and an
+// exponent. Its exponent is bounded by kMinimalTargetExponent and
+// kMaximalTargetExponent.
+//       Hence -60 <= w.e() <= -32.
+//
+// Returns false if it fails, in which case the generated digits in the buffer
+// should not be used.
+// Preconditions:
+//  * w is correct up to 1 ulp (unit in the last place). That
+//    is, its error must be strictly less than a unit of its last digit.
+//  * kMinimalTargetExponent <= w.e() <= kMaximalTargetExponent
+//
+// Postconditions: returns false if procedure fails.
+//   otherwise:
+//     * buffer is not null-terminated, but length contains the number of
+//       digits.
+//     * the representation in buffer is the most precise representation of
+//       requested_digits digits.
+//     * buffer contains at most requested_digits digits of w. If there are less
+//       than requested_digits digits then some trailing '0's have been removed.
+//     * kappa is such that
+//            w = buffer * 10^kappa + eps with |eps| < 10^kappa / 2.
+//
+// Remark: This procedure takes into account the imprecision of its input
+//   numbers. If the precision is not enough to guarantee all the postconditions
+//   then false is returned. This usually happens rarely, but the failure-rate
+//   increases with higher requested_digits.
+static bool DigitGenCounted(DiyFp w,
+                            int requested_digits,
+                            Vector<char> buffer,
+                            int* length,
+                            int* kappa) {
+  ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent);
+  ASSERT(kMinimalTargetExponent >= -60);
+  ASSERT(kMaximalTargetExponent <= -32);
+  // w is assumed to have an error less than 1 unit. Whenever w is scaled we
+  // also scale its error.
+  uint64_t w_error = 1;
+  // We cut the input number into two parts: the integral digits and the
+  // fractional digits. We don't emit any decimal separator, but adapt kappa
+  // instead. Example: instead of writing "1.2" we put "12" into the buffer and
+  // increase kappa by 1.
+  DiyFp one = DiyFp(static_cast<uint64_t>(1) << -w.e(), w.e());
+  // Division by one is a shift.
+  uint32_t integrals = static_cast<uint32_t>(w.f() >> -one.e());
+  // Modulo by one is an and.
+  uint64_t fractionals = w.f() & (one.f() - 1);
+  uint32_t divisor;
+  int divisor_exponent_plus_one;
+  BiggestPowerTen(integrals, DiyFp::kSignificandSize - (-one.e()),
+                  &divisor, &divisor_exponent_plus_one);
+  *kappa = divisor_exponent_plus_one;
+  *length = 0;
+
+  // Loop invariant: buffer = w / 10^kappa  (integer division)
+  // The invariant holds for the first iteration: kappa has been initialized
+  // with the divisor exponent + 1. And the divisor is the biggest power of ten
+  // that is smaller than 'integrals'.
+  while (*kappa > 0) {
+    int digit = integrals / divisor;
+    buffer[*length] = '0' + digit;
+    (*length)++;
+    requested_digits--;
+    integrals %= divisor;
+    (*kappa)--;
+    // Note that kappa now equals the exponent of the divisor and that the
+    // invariant thus holds again.
+    if (requested_digits == 0) break;
+    divisor /= 10;
+  }
+
+  if (requested_digits == 0) {
+    uint64_t rest =
+        (static_cast<uint64_t>(integrals) << -one.e()) + fractionals;
+    return RoundWeedCounted(buffer, *length, rest,
+                            static_cast<uint64_t>(divisor) << -one.e(), w_error,
+                            kappa);
+  }
+
+  // The integrals have been generated. We are at the point of the decimal
+  // separator. In the following loop we simply multiply the remaining digits by
+  // 10 and divide by one. We just need to pay attention to multiply associated
+  // data (the 'unit'), too.
+  // Note that the multiplication by 10 does not overflow, because w.e >= -60
+  // and thus one.e >= -60.
+  ASSERT(one.e() >= -60);
+  ASSERT(fractionals < one.f());
+  ASSERT(UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f());
+  while (requested_digits > 0 && fractionals > w_error) {
+    fractionals *= 10;
+    w_error *= 10;
+    // Integer division by one.
+    int digit = static_cast<int>(fractionals >> -one.e());
+    buffer[*length] = '0' + digit;
+    (*length)++;
+    requested_digits--;
+    fractionals &= one.f() - 1;  // Modulo by one.
+    (*kappa)--;
+  }
+  if (requested_digits != 0) return false;
+  return RoundWeedCounted(buffer, *length, fractionals, one.f(), w_error,
+                          kappa);
+}
+
+
+// Provides a decimal representation of v.
+// Returns true if it succeeds, otherwise the result cannot be trusted.
+// There will be *length digits inside the buffer (not null-terminated).
+// If the function returns true then
+//        v == (double) (buffer * 10^decimal_exponent).
+// The digits in the buffer are the shortest representation possible: no
+// 0.09999999999999999 instead of 0.1. The shorter representation will even be
+// chosen even if the longer one would be closer to v.
+// The last digit will be closest to the actual v. That is, even if several
+// digits might correctly yield 'v' when read again, the closest will be
+// computed.
+static bool Grisu3(double v,
+                   FastDtoaMode mode,
+                   Vector<char> buffer,
+                   int* length,
+                   int* decimal_exponent) {
+  DiyFp w = Double(v).AsNormalizedDiyFp();
+  // boundary_minus and boundary_plus are the boundaries between v and its
+  // closest floating-point neighbors. Any number strictly between
+  // boundary_minus and boundary_plus will round to v when convert to a double.
+  // Grisu3 will never output representations that lie exactly on a boundary.
+  DiyFp boundary_minus, boundary_plus;
+  if (mode == FAST_DTOA_SHORTEST) {
+    Double(v).NormalizedBoundaries(&boundary_minus, &boundary_plus);
+  } else {
+    ASSERT(mode == FAST_DTOA_SHORTEST_SINGLE);
+    float single_v = static_cast<float>(v);
+    Single(single_v).NormalizedBoundaries(&boundary_minus, &boundary_plus);
+  }
+  ASSERT(boundary_plus.e() == w.e());
+  DiyFp ten_mk;  // Cached power of ten: 10^-k
+  int mk;        // -k
+  int ten_mk_minimal_binary_exponent =
+     kMinimalTargetExponent - (w.e() + DiyFp::kSignificandSize);
+  int ten_mk_maximal_binary_exponent =
+     kMaximalTargetExponent - (w.e() + DiyFp::kSignificandSize);
+  PowersOfTenCache::GetCachedPowerForBinaryExponentRange(
+      ten_mk_minimal_binary_exponent,
+      ten_mk_maximal_binary_exponent,
+      &ten_mk, &mk);
+  ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() +
+          DiyFp::kSignificandSize) &&
+         (kMaximalTargetExponent >= w.e() + ten_mk.e() +
+          DiyFp::kSignificandSize));
+  // Note that ten_mk is only an approximation of 10^-k. A DiyFp only contains a
+  // 64 bit significand and ten_mk is thus only precise up to 64 bits.
+
+  // The DiyFp::Times procedure rounds its result, and ten_mk is approximated
+  // too. The variable scaled_w (as well as scaled_boundary_minus/plus) are now
+  // off by a small amount.
+  // In fact: scaled_w - w*10^k < 1ulp (unit in the last place) of scaled_w.
+  // In other words: let f = scaled_w.f() and e = scaled_w.e(), then
+  //           (f-1) * 2^e < w*10^k < (f+1) * 2^e
+  DiyFp scaled_w = DiyFp::Times(w, ten_mk);
+  ASSERT(scaled_w.e() ==
+         boundary_plus.e() + ten_mk.e() + DiyFp::kSignificandSize);
+  // In theory it would be possible to avoid some recomputations by computing
+  // the difference between w and boundary_minus/plus (a power of 2) and to
+  // compute scaled_boundary_minus/plus by subtracting/adding from
+  // scaled_w. However the code becomes much less readable and the speed
+  // enhancements are not terriffic.
+  DiyFp scaled_boundary_minus = DiyFp::Times(boundary_minus, ten_mk);
+  DiyFp scaled_boundary_plus  = DiyFp::Times(boundary_plus,  ten_mk);
+
+  // DigitGen will generate the digits of scaled_w. Therefore we have
+  // v == (double) (scaled_w * 10^-mk).
+  // Set decimal_exponent == -mk and pass it to DigitGen. If scaled_w is not an
+  // integer than it will be updated. For instance if scaled_w == 1.23 then
+  // the buffer will be filled with "123" und the decimal_exponent will be
+  // decreased by 2.
+  int kappa;
+  bool result = DigitGen(scaled_boundary_minus, scaled_w, scaled_boundary_plus,
+                         buffer, length, &kappa);
+  *decimal_exponent = -mk + kappa;
+  return result;
+}
+
+
+// The "counted" version of grisu3 (see above) only generates requested_digits
+// number of digits. This version does not generate the shortest representation,
+// and with enough requested digits 0.1 will at some point print as 0.9999999...
+// Grisu3 is too imprecise for real halfway cases (1.5 will not work) and
+// therefore the rounding strategy for halfway cases is irrelevant.
+static bool Grisu3Counted(double v,
+                          int requested_digits,
+                          Vector<char> buffer,
+                          int* length,
+                          int* decimal_exponent) {
+  DiyFp w = Double(v).AsNormalizedDiyFp();
+  DiyFp ten_mk;  // Cached power of ten: 10^-k
+  int mk;        // -k
+  int ten_mk_minimal_binary_exponent =
+     kMinimalTargetExponent - (w.e() + DiyFp::kSignificandSize);
+  int ten_mk_maximal_binary_exponent =
+     kMaximalTargetExponent - (w.e() + DiyFp::kSignificandSize);
+  PowersOfTenCache::GetCachedPowerForBinaryExponentRange(
+      ten_mk_minimal_binary_exponent,
+      ten_mk_maximal_binary_exponent,
+      &ten_mk, &mk);
+  ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() +
+          DiyFp::kSignificandSize) &&
+         (kMaximalTargetExponent >= w.e() + ten_mk.e() +
+          DiyFp::kSignificandSize));
+  // Note that ten_mk is only an approximation of 10^-k. A DiyFp only contains a
+  // 64 bit significand and ten_mk is thus only precise up to 64 bits.
+
+  // The DiyFp::Times procedure rounds its result, and ten_mk is approximated
+  // too. The variable scaled_w (as well as scaled_boundary_minus/plus) are now
+  // off by a small amount.
+  // In fact: scaled_w - w*10^k < 1ulp (unit in the last place) of scaled_w.
+  // In other words: let f = scaled_w.f() and e = scaled_w.e(), then
+  //           (f-1) * 2^e < w*10^k < (f+1) * 2^e
+  DiyFp scaled_w = DiyFp::Times(w, ten_mk);
+
+  // We now have (double) (scaled_w * 10^-mk).
+  // DigitGen will generate the first requested_digits digits of scaled_w and
+  // return together with a kappa such that scaled_w ~= buffer * 10^kappa. (It
+  // will not always be exactly the same since DigitGenCounted only produces a
+  // limited number of digits.)
+  int kappa;
+  bool result = DigitGenCounted(scaled_w, requested_digits,
+                                buffer, length, &kappa);
+  *decimal_exponent = -mk + kappa;
+  return result;
+}
+
+
+bool FastDtoa(double v,
+              FastDtoaMode mode,
+              int requested_digits,
+              Vector<char> buffer,
+              int* length,
+              int* decimal_point) {
+  ASSERT(v > 0);
+  ASSERT(!Double(v).IsSpecial());
+
+  bool result = false;
+  int decimal_exponent = 0;
+  switch (mode) {
+    case FAST_DTOA_SHORTEST:
+    case FAST_DTOA_SHORTEST_SINGLE:
+      result = Grisu3(v, mode, buffer, length, &decimal_exponent);
+      break;
+    case FAST_DTOA_PRECISION:
+      result = Grisu3Counted(v, requested_digits,
+                             buffer, length, &decimal_exponent);
+      break;
+    default:
+      UNREACHABLE();
+  }
+  if (result) {
+    *decimal_point = *length + decimal_exponent;
+    buffer[*length] = '\0';
+  }
+  return result;
+}
+
+}  // namespace double_conversion
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/fast-dtoa.h b/src/third_party/mozjs-45/mfbt/double-conversion/fast-dtoa.h
new file mode 100644
index 0000000..5f1e8ee
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/fast-dtoa.h
@@ -0,0 +1,88 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_FAST_DTOA_H_
+#define DOUBLE_CONVERSION_FAST_DTOA_H_
+
+#include "utils.h"
+
+namespace double_conversion {
+
+enum FastDtoaMode {
+  // Computes the shortest representation of the given input. The returned
+  // result will be the most accurate number of this length. Longer
+  // representations might be more accurate.
+  FAST_DTOA_SHORTEST,
+  // Same as FAST_DTOA_SHORTEST but for single-precision floats.
+  FAST_DTOA_SHORTEST_SINGLE,
+  // Computes a representation where the precision (number of digits) is
+  // given as input. The precision is independent of the decimal point.
+  FAST_DTOA_PRECISION
+};
+
+// FastDtoa will produce at most kFastDtoaMaximalLength digits. This does not
+// include the terminating '\0' character.
+static const int kFastDtoaMaximalLength = 17;
+// Same for single-precision numbers.
+static const int kFastDtoaMaximalSingleLength = 9;
+
+// Provides a decimal representation of v.
+// The result should be interpreted as buffer * 10^(point - length).
+//
+// Precondition:
+//   * v must be a strictly positive finite double.
+//
+// Returns true if it succeeds, otherwise the result can not be trusted.
+// There will be *length digits inside the buffer followed by a null terminator.
+// If the function returns true and mode equals
+//   - FAST_DTOA_SHORTEST, then
+//     the parameter requested_digits is ignored.
+//     The result satisfies
+//         v == (double) (buffer * 10^(point - length)).
+//     The digits in the buffer are the shortest representation possible. E.g.
+//     if 0.099999999999 and 0.1 represent the same double then "1" is returned
+//     with point = 0.
+//     The last digit will be closest to the actual v. That is, even if several
+//     digits might correctly yield 'v' when read again, the buffer will contain
+//     the one closest to v.
+//   - FAST_DTOA_PRECISION, then
+//     the buffer contains requested_digits digits.
+//     the difference v - (buffer * 10^(point-length)) is closest to zero for
+//     all possible representations of requested_digits digits.
+//     If there are two values that are equally close, then FastDtoa returns
+//     false.
+// For both modes the buffer must be large enough to hold the result.
+bool FastDtoa(double d,
+              FastDtoaMode mode,
+              int requested_digits,
+              Vector<char> buffer,
+              int* length,
+              int* decimal_point);
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_FAST_DTOA_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/fixed-dtoa.cc b/src/third_party/mozjs-45/mfbt/double-conversion/fixed-dtoa.cc
new file mode 100644
index 0000000..d56b144
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/fixed-dtoa.cc
@@ -0,0 +1,402 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <math.h>
+
+#include "fixed-dtoa.h"
+#include "ieee.h"
+
+namespace double_conversion {
+
+// Represents a 128bit type. This class should be replaced by a native type on
+// platforms that support 128bit integers.
+class UInt128 {
+ public:
+  UInt128() : high_bits_(0), low_bits_(0) { }
+  UInt128(uint64_t high, uint64_t low) : high_bits_(high), low_bits_(low) { }
+
+  void Multiply(uint32_t multiplicand) {
+    uint64_t accumulator;
+
+    accumulator = (low_bits_ & kMask32) * multiplicand;
+    uint32_t part = static_cast<uint32_t>(accumulator & kMask32);
+    accumulator >>= 32;
+    accumulator = accumulator + (low_bits_ >> 32) * multiplicand;
+    low_bits_ = (accumulator << 32) + part;
+    accumulator >>= 32;
+    accumulator = accumulator + (high_bits_ & kMask32) * multiplicand;
+    part = static_cast<uint32_t>(accumulator & kMask32);
+    accumulator >>= 32;
+    accumulator = accumulator + (high_bits_ >> 32) * multiplicand;
+    high_bits_ = (accumulator << 32) + part;
+    ASSERT((accumulator >> 32) == 0);
+  }
+
+  void Shift(int shift_amount) {
+    ASSERT(-64 <= shift_amount && shift_amount <= 64);
+    if (shift_amount == 0) {
+      return;
+    } else if (shift_amount == -64) {
+      high_bits_ = low_bits_;
+      low_bits_ = 0;
+    } else if (shift_amount == 64) {
+      low_bits_ = high_bits_;
+      high_bits_ = 0;
+    } else if (shift_amount <= 0) {
+      high_bits_ <<= -shift_amount;
+      high_bits_ += low_bits_ >> (64 + shift_amount);
+      low_bits_ <<= -shift_amount;
+    } else {
+      low_bits_ >>= shift_amount;
+      low_bits_ += high_bits_ << (64 - shift_amount);
+      high_bits_ >>= shift_amount;
+    }
+  }
+
+  // Modifies *this to *this MOD (2^power).
+  // Returns *this DIV (2^power).
+  int DivModPowerOf2(int power) {
+    if (power >= 64) {
+      int result = static_cast<int>(high_bits_ >> (power - 64));
+      high_bits_ -= static_cast<uint64_t>(result) << (power - 64);
+      return result;
+    } else {
+      uint64_t part_low = low_bits_ >> power;
+      uint64_t part_high = high_bits_ << (64 - power);
+      int result = static_cast<int>(part_low + part_high);
+      high_bits_ = 0;
+      low_bits_ -= part_low << power;
+      return result;
+    }
+  }
+
+  bool IsZero() const {
+    return high_bits_ == 0 && low_bits_ == 0;
+  }
+
+  int BitAt(int position) {
+    if (position >= 64) {
+      return static_cast<int>(high_bits_ >> (position - 64)) & 1;
+    } else {
+      return static_cast<int>(low_bits_ >> position) & 1;
+    }
+  }
+
+ private:
+  static const uint64_t kMask32 = 0xFFFFFFFF;
+  // Value == (high_bits_ << 64) + low_bits_
+  uint64_t high_bits_;
+  uint64_t low_bits_;
+};
+
+
+static const int kDoubleSignificandSize = 53;  // Includes the hidden bit.
+
+
+static void FillDigits32FixedLength(uint32_t number, int requested_length,
+                                    Vector<char> buffer, int* length) {
+  for (int i = requested_length - 1; i >= 0; --i) {
+    buffer[(*length) + i] = '0' + number % 10;
+    number /= 10;
+  }
+  *length += requested_length;
+}
+
+
+static void FillDigits32(uint32_t number, Vector<char> buffer, int* length) {
+  int number_length = 0;
+  // We fill the digits in reverse order and exchange them afterwards.
+  while (number != 0) {
+    int digit = number % 10;
+    number /= 10;
+    buffer[(*length) + number_length] = '0' + digit;
+    number_length++;
+  }
+  // Exchange the digits.
+  int i = *length;
+  int j = *length + number_length - 1;
+  while (i < j) {
+    char tmp = buffer[i];
+    buffer[i] = buffer[j];
+    buffer[j] = tmp;
+    i++;
+    j--;
+  }
+  *length += number_length;
+}
+
+
+static void FillDigits64FixedLength(uint64_t number, int requested_length,
+                                    Vector<char> buffer, int* length) {
+  const uint32_t kTen7 = 10000000;
+  // For efficiency cut the number into 3 uint32_t parts, and print those.
+  uint32_t part2 = static_cast<uint32_t>(number % kTen7);
+  number /= kTen7;
+  uint32_t part1 = static_cast<uint32_t>(number % kTen7);
+  uint32_t part0 = static_cast<uint32_t>(number / kTen7);
+
+  FillDigits32FixedLength(part0, 3, buffer, length);
+  FillDigits32FixedLength(part1, 7, buffer, length);
+  FillDigits32FixedLength(part2, 7, buffer, length);
+}
+
+
+static void FillDigits64(uint64_t number, Vector<char> buffer, int* length) {
+  const uint32_t kTen7 = 10000000;
+  // For efficiency cut the number into 3 uint32_t parts, and print those.
+  uint32_t part2 = static_cast<uint32_t>(number % kTen7);
+  number /= kTen7;
+  uint32_t part1 = static_cast<uint32_t>(number % kTen7);
+  uint32_t part0 = static_cast<uint32_t>(number / kTen7);
+
+  if (part0 != 0) {
+    FillDigits32(part0, buffer, length);
+    FillDigits32FixedLength(part1, 7, buffer, length);
+    FillDigits32FixedLength(part2, 7, buffer, length);
+  } else if (part1 != 0) {
+    FillDigits32(part1, buffer, length);
+    FillDigits32FixedLength(part2, 7, buffer, length);
+  } else {
+    FillDigits32(part2, buffer, length);
+  }
+}
+
+
+static void RoundUp(Vector<char> buffer, int* length, int* decimal_point) {
+  // An empty buffer represents 0.
+  if (*length == 0) {
+    buffer[0] = '1';
+    *decimal_point = 1;
+    *length = 1;
+    return;
+  }
+  // Round the last digit until we either have a digit that was not '9' or until
+  // we reached the first digit.
+  buffer[(*length) - 1]++;
+  for (int i = (*length) - 1; i > 0; --i) {
+    if (buffer[i] != '0' + 10) {
+      return;
+    }
+    buffer[i] = '0';
+    buffer[i - 1]++;
+  }
+  // If the first digit is now '0' + 10, we would need to set it to '0' and add
+  // a '1' in front. However we reach the first digit only if all following
+  // digits had been '9' before rounding up. Now all trailing digits are '0' and
+  // we simply switch the first digit to '1' and update the decimal-point
+  // (indicating that the point is now one digit to the right).
+  if (buffer[0] == '0' + 10) {
+    buffer[0] = '1';
+    (*decimal_point)++;
+  }
+}
+
+
+// The given fractionals number represents a fixed-point number with binary
+// point at bit (-exponent).
+// Preconditions:
+//   -128 <= exponent <= 0.
+//   0 <= fractionals * 2^exponent < 1
+//   The buffer holds the result.
+// The function will round its result. During the rounding-process digits not
+// generated by this function might be updated, and the decimal-point variable
+// might be updated. If this function generates the digits 99 and the buffer
+// already contained "199" (thus yielding a buffer of "19999") then a
+// rounding-up will change the contents of the buffer to "20000".
+static void FillFractionals(uint64_t fractionals, int exponent,
+                            int fractional_count, Vector<char> buffer,
+                            int* length, int* decimal_point) {
+  ASSERT(-128 <= exponent && exponent <= 0);
+  // 'fractionals' is a fixed-point number, with binary point at bit
+  // (-exponent). Inside the function the non-converted remainder of fractionals
+  // is a fixed-point number, with binary point at bit 'point'.
+  if (-exponent <= 64) {
+    // One 64 bit number is sufficient.
+    ASSERT(fractionals >> 56 == 0);
+    int point = -exponent;
+    for (int i = 0; i < fractional_count; ++i) {
+      if (fractionals == 0) break;
+      // Instead of multiplying by 10 we multiply by 5 and adjust the point
+      // location. This way the fractionals variable will not overflow.
+      // Invariant at the beginning of the loop: fractionals < 2^point.
+      // Initially we have: point <= 64 and fractionals < 2^56
+      // After each iteration the point is decremented by one.
+      // Note that 5^3 = 125 < 128 = 2^7.
+      // Therefore three iterations of this loop will not overflow fractionals
+      // (even without the subtraction at the end of the loop body). At this
+      // time point will satisfy point <= 61 and therefore fractionals < 2^point
+      // and any further multiplication of fractionals by 5 will not overflow.
+      fractionals *= 5;
+      point--;
+      int digit = static_cast<int>(fractionals >> point);
+      buffer[*length] = '0' + digit;
+      (*length)++;
+      fractionals -= static_cast<uint64_t>(digit) << point;
+    }
+    // If the first bit after the point is set we have to round up.
+    if (((fractionals >> (point - 1)) & 1) == 1) {
+      RoundUp(buffer, length, decimal_point);
+    }
+  } else {  // We need 128 bits.
+    ASSERT(64 < -exponent && -exponent <= 128);
+    UInt128 fractionals128 = UInt128(fractionals, 0);
+    fractionals128.Shift(-exponent - 64);
+    int point = 128;
+    for (int i = 0; i < fractional_count; ++i) {
+      if (fractionals128.IsZero()) break;
+      // As before: instead of multiplying by 10 we multiply by 5 and adjust the
+      // point location.
+      // This multiplication will not overflow for the same reasons as before.
+      fractionals128.Multiply(5);
+      point--;
+      int digit = fractionals128.DivModPowerOf2(point);
+      buffer[*length] = '0' + digit;
+      (*length)++;
+    }
+    if (fractionals128.BitAt(point - 1) == 1) {
+      RoundUp(buffer, length, decimal_point);
+    }
+  }
+}
+
+
+// Removes leading and trailing zeros.
+// If leading zeros are removed then the decimal point position is adjusted.
+static void TrimZeros(Vector<char> buffer, int* length, int* decimal_point) {
+  while (*length > 0 && buffer[(*length) - 1] == '0') {
+    (*length)--;
+  }
+  int first_non_zero = 0;
+  while (first_non_zero < *length && buffer[first_non_zero] == '0') {
+    first_non_zero++;
+  }
+  if (first_non_zero != 0) {
+    for (int i = first_non_zero; i < *length; ++i) {
+      buffer[i - first_non_zero] = buffer[i];
+    }
+    *length -= first_non_zero;
+    *decimal_point -= first_non_zero;
+  }
+}
+
+
+bool FastFixedDtoa(double v,
+                   int fractional_count,
+                   Vector<char> buffer,
+                   int* length,
+                   int* decimal_point) {
+  const uint32_t kMaxUInt32 = 0xFFFFFFFF;
+  uint64_t significand = Double(v).Significand();
+  int exponent = Double(v).Exponent();
+  // v = significand * 2^exponent (with significand a 53bit integer).
+  // If the exponent is larger than 20 (i.e. we may have a 73bit number) then we
+  // don't know how to compute the representation. 2^73 ~= 9.5*10^21.
+  // If necessary this limit could probably be increased, but we don't need
+  // more.
+  if (exponent > 20) return false;
+  if (fractional_count > 20) return false;
+  *length = 0;
+  // At most kDoubleSignificandSize bits of the significand are non-zero.
+  // Given a 64 bit integer we have 11 0s followed by 53 potentially non-zero
+  // bits:  0..11*..0xxx..53*..xx
+  if (exponent + kDoubleSignificandSize > 64) {
+    // The exponent must be > 11.
+    //
+    // We know that v = significand * 2^exponent.
+    // And the exponent > 11.
+    // We simplify the task by dividing v by 10^17.
+    // The quotient delivers the first digits, and the remainder fits into a 64
+    // bit number.
+    // Dividing by 10^17 is equivalent to dividing by 5^17*2^17.
+    const uint64_t kFive17 = UINT64_2PART_C(0xB1, A2BC2EC5);  // 5^17
+    uint64_t divisor = kFive17;
+    int divisor_power = 17;
+    uint64_t dividend = significand;
+    uint32_t quotient;
+    uint64_t remainder;
+    // Let v = f * 2^e with f == significand and e == exponent.
+    // Then need q (quotient) and r (remainder) as follows:
+    //   v            = q * 10^17       + r
+    //   f * 2^e      = q * 10^17       + r
+    //   f * 2^e      = q * 5^17 * 2^17 + r
+    // If e > 17 then
+    //   f * 2^(e-17) = q * 5^17        + r/2^17
+    // else
+    //   f  = q * 5^17 * 2^(17-e) + r/2^e
+    if (exponent > divisor_power) {
+      // We only allow exponents of up to 20 and therefore (17 - e) <= 3
+      dividend <<= exponent - divisor_power;
+      quotient = static_cast<uint32_t>(dividend / divisor);
+      remainder = (dividend % divisor) << divisor_power;
+    } else {
+      divisor <<= divisor_power - exponent;
+      quotient = static_cast<uint32_t>(dividend / divisor);
+      remainder = (dividend % divisor) << exponent;
+    }
+    FillDigits32(quotient, buffer, length);
+    FillDigits64FixedLength(remainder, divisor_power, buffer, length);
+    *decimal_point = *length;
+  } else if (exponent >= 0) {
+    // 0 <= exponent <= 11
+    significand <<= exponent;
+    FillDigits64(significand, buffer, length);
+    *decimal_point = *length;
+  } else if (exponent > -kDoubleSignificandSize) {
+    // We have to cut the number.
+    uint64_t integrals = significand >> -exponent;
+    uint64_t fractionals = significand - (integrals << -exponent);
+    if (integrals > kMaxUInt32) {
+      FillDigits64(integrals, buffer, length);
+    } else {
+      FillDigits32(static_cast<uint32_t>(integrals), buffer, length);
+    }
+    *decimal_point = *length;
+    FillFractionals(fractionals, exponent, fractional_count,
+                    buffer, length, decimal_point);
+  } else if (exponent < -128) {
+    // This configuration (with at most 20 digits) means that all digits must be
+    // 0.
+    ASSERT(fractional_count <= 20);
+    buffer[0] = '\0';
+    *length = 0;
+    *decimal_point = -fractional_count;
+  } else {
+    *decimal_point = 0;
+    FillFractionals(significand, exponent, fractional_count,
+                    buffer, length, decimal_point);
+  }
+  TrimZeros(buffer, length, decimal_point);
+  buffer[*length] = '\0';
+  if ((*length) == 0) {
+    // The string is empty and the decimal_point thus has no importance. Mimick
+    // Gay's dtoa and and set it to -fractional_count.
+    *decimal_point = -fractional_count;
+  }
+  return true;
+}
+
+}  // namespace double_conversion
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/fixed-dtoa.h b/src/third_party/mozjs-45/mfbt/double-conversion/fixed-dtoa.h
new file mode 100644
index 0000000..3bdd08e
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/fixed-dtoa.h
@@ -0,0 +1,56 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_FIXED_DTOA_H_
+#define DOUBLE_CONVERSION_FIXED_DTOA_H_
+
+#include "utils.h"
+
+namespace double_conversion {
+
+// Produces digits necessary to print a given number with
+// 'fractional_count' digits after the decimal point.
+// The buffer must be big enough to hold the result plus one terminating null
+// character.
+//
+// The produced digits might be too short in which case the caller has to fill
+// the gaps with '0's.
+// Example: FastFixedDtoa(0.001, 5, ...) is allowed to return buffer = "1", and
+// decimal_point = -2.
+// Halfway cases are rounded towards +/-Infinity (away from 0). The call
+// FastFixedDtoa(0.15, 2, ...) thus returns buffer = "2", decimal_point = 0.
+// The returned buffer may contain digits that would be truncated from the
+// shortest representation of the input.
+//
+// This method only works for some parameters. If it can't handle the input it
+// returns false. The output is null-terminated when the function succeeds.
+bool FastFixedDtoa(double v, int fractional_count,
+                   Vector<char> buffer, int* length, int* decimal_point);
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_FIXED_DTOA_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/ieee.h b/src/third_party/mozjs-45/mfbt/double-conversion/ieee.h
new file mode 100644
index 0000000..839dc47
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/ieee.h
@@ -0,0 +1,398 @@
+// Copyright 2012 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_DOUBLE_H_
+#define DOUBLE_CONVERSION_DOUBLE_H_
+
+#include "diy-fp.h"
+
+namespace double_conversion {
+
+// We assume that doubles and uint64_t have the same endianness.
+static uint64_t double_to_uint64(double d) { return BitCast<uint64_t>(d); }
+static double uint64_to_double(uint64_t d64) { return BitCast<double>(d64); }
+static uint32_t float_to_uint32(float f) { return BitCast<uint32_t>(f); }
+static float uint32_to_float(uint32_t d32) { return BitCast<float>(d32); }
+
+// Helper functions for doubles.
+class Double {
+ public:
+  static const uint64_t kSignMask = UINT64_2PART_C(0x80000000, 00000000);
+  static const uint64_t kExponentMask = UINT64_2PART_C(0x7FF00000, 00000000);
+  static const uint64_t kSignificandMask = UINT64_2PART_C(0x000FFFFF, FFFFFFFF);
+  static const uint64_t kHiddenBit = UINT64_2PART_C(0x00100000, 00000000);
+  static const int kPhysicalSignificandSize = 52;  // Excludes the hidden bit.
+  static const int kSignificandSize = 53;
+
+  Double() : d64_(0) {}
+  explicit Double(double d) : d64_(double_to_uint64(d)) {}
+  explicit Double(uint64_t d64) : d64_(d64) {}
+  explicit Double(DiyFp diy_fp)
+    : d64_(DiyFpToUint64(diy_fp)) {}
+
+  // The value encoded by this Double must be greater or equal to +0.0.
+  // It must not be special (infinity, or NaN).
+  DiyFp AsDiyFp() const {
+    ASSERT(Sign() > 0);
+    ASSERT(!IsSpecial());
+    return DiyFp(Significand(), Exponent());
+  }
+
+  // The value encoded by this Double must be strictly greater than 0.
+  DiyFp AsNormalizedDiyFp() const {
+    ASSERT(value() > 0.0);
+    uint64_t f = Significand();
+    int e = Exponent();
+
+    // The current double could be a denormal.
+    while ((f & kHiddenBit) == 0) {
+      f <<= 1;
+      e--;
+    }
+    // Do the final shifts in one go.
+    f <<= DiyFp::kSignificandSize - kSignificandSize;
+    e -= DiyFp::kSignificandSize - kSignificandSize;
+    return DiyFp(f, e);
+  }
+
+  // Returns the double's bit as uint64.
+  uint64_t AsUint64() const {
+    return d64_;
+  }
+
+  // Returns the next greater double. Returns +infinity on input +infinity.
+  double NextDouble() const {
+    if (d64_ == kInfinity) return Double(kInfinity).value();
+    if (Sign() < 0 && Significand() == 0) {
+      // -0.0
+      return 0.0;
+    }
+    if (Sign() < 0) {
+      return Double(d64_ - 1).value();
+    } else {
+      return Double(d64_ + 1).value();
+    }
+  }
+
+  double PreviousDouble() const {
+    if (d64_ == (kInfinity | kSignMask)) return -Double::Infinity();
+    if (Sign() < 0) {
+      return Double(d64_ + 1).value();
+    } else {
+      if (Significand() == 0) return -0.0;
+      return Double(d64_ - 1).value();
+    }
+  }
+
+  int Exponent() const {
+    if (IsDenormal()) return kDenormalExponent;
+
+    uint64_t d64 = AsUint64();
+    int biased_e =
+        static_cast<int>((d64 & kExponentMask) >> kPhysicalSignificandSize);
+    return biased_e - kExponentBias;
+  }
+
+  uint64_t Significand() const {
+    uint64_t d64 = AsUint64();
+    uint64_t significand = d64 & kSignificandMask;
+    if (!IsDenormal()) {
+      return significand + kHiddenBit;
+    } else {
+      return significand;
+    }
+  }
+
+  // Returns true if the double is a denormal.
+  bool IsDenormal() const {
+    uint64_t d64 = AsUint64();
+    return (d64 & kExponentMask) == 0;
+  }
+
+  // We consider denormals not to be special.
+  // Hence only Infinity and NaN are special.
+  bool IsSpecial() const {
+    uint64_t d64 = AsUint64();
+    return (d64 & kExponentMask) == kExponentMask;
+  }
+
+  bool IsNan() const {
+    uint64_t d64 = AsUint64();
+    return ((d64 & kExponentMask) == kExponentMask) &&
+        ((d64 & kSignificandMask) != 0);
+  }
+
+  bool IsInfinite() const {
+    uint64_t d64 = AsUint64();
+    return ((d64 & kExponentMask) == kExponentMask) &&
+        ((d64 & kSignificandMask) == 0);
+  }
+
+  int Sign() const {
+    uint64_t d64 = AsUint64();
+    return (d64 & kSignMask) == 0? 1: -1;
+  }
+
+  // Precondition: the value encoded by this Double must be greater or equal
+  // than +0.0.
+  DiyFp UpperBoundary() const {
+    ASSERT(Sign() > 0);
+    return DiyFp(Significand() * 2 + 1, Exponent() - 1);
+  }
+
+  // Computes the two boundaries of this.
+  // The bigger boundary (m_plus) is normalized. The lower boundary has the same
+  // exponent as m_plus.
+  // Precondition: the value encoded by this Double must be greater than 0.
+  void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const {
+    ASSERT(value() > 0.0);
+    DiyFp v = this->AsDiyFp();
+    DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1));
+    DiyFp m_minus;
+    if (LowerBoundaryIsCloser()) {
+      m_minus = DiyFp((v.f() << 2) - 1, v.e() - 2);
+    } else {
+      m_minus = DiyFp((v.f() << 1) - 1, v.e() - 1);
+    }
+    m_minus.set_f(m_minus.f() << (m_minus.e() - m_plus.e()));
+    m_minus.set_e(m_plus.e());
+    *out_m_plus = m_plus;
+    *out_m_minus = m_minus;
+  }
+
+  bool LowerBoundaryIsCloser() const {
+    // The boundary is closer if the significand is of the form f == 2^p-1 then
+    // the lower boundary is closer.
+    // Think of v = 1000e10 and v- = 9999e9.
+    // Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but
+    // at a distance of 1e8.
+    // The only exception is for the smallest normal: the largest denormal is
+    // at the same distance as its successor.
+    // Note: denormals have the same exponent as the smallest normals.
+    bool physical_significand_is_zero = ((AsUint64() & kSignificandMask) == 0);
+    return physical_significand_is_zero && (Exponent() != kDenormalExponent);
+  }
+
+  double value() const { return uint64_to_double(d64_); }
+
+  // Returns the significand size for a given order of magnitude.
+  // If v = f*2^e with 2^p-1 <= f <= 2^p then p+e is v's order of magnitude.
+  // This function returns the number of significant binary digits v will have
+  // once it's encoded into a double. In almost all cases this is equal to
+  // kSignificandSize. The only exceptions are denormals. They start with
+  // leading zeroes and their effective significand-size is hence smaller.
+  static int SignificandSizeForOrderOfMagnitude(int order) {
+    if (order >= (kDenormalExponent + kSignificandSize)) {
+      return kSignificandSize;
+    }
+    if (order <= kDenormalExponent) return 0;
+    return order - kDenormalExponent;
+  }
+
+  static double Infinity() {
+    return Double(kInfinity).value();
+  }
+
+  static double NaN() {
+    return Double(kNaN).value();
+  }
+
+ private:
+  static const int kExponentBias = 0x3FF + kPhysicalSignificandSize;
+  static const int kDenormalExponent = -kExponentBias + 1;
+  static const int kMaxExponent = 0x7FF - kExponentBias;
+  static const uint64_t kInfinity = UINT64_2PART_C(0x7FF00000, 00000000);
+  static const uint64_t kNaN = UINT64_2PART_C(0x7FF80000, 00000000);
+
+  const uint64_t d64_;
+
+  static uint64_t DiyFpToUint64(DiyFp diy_fp) {
+    uint64_t significand = diy_fp.f();
+    int exponent = diy_fp.e();
+    while (significand > kHiddenBit + kSignificandMask) {
+      significand >>= 1;
+      exponent++;
+    }
+    if (exponent >= kMaxExponent) {
+      return kInfinity;
+    }
+    if (exponent < kDenormalExponent) {
+      return 0;
+    }
+    while (exponent > kDenormalExponent && (significand & kHiddenBit) == 0) {
+      significand <<= 1;
+      exponent--;
+    }
+    uint64_t biased_exponent;
+    if (exponent == kDenormalExponent && (significand & kHiddenBit) == 0) {
+      biased_exponent = 0;
+    } else {
+      biased_exponent = static_cast<uint64_t>(exponent + kExponentBias);
+    }
+    return (significand & kSignificandMask) |
+        (biased_exponent << kPhysicalSignificandSize);
+  }
+};
+
+class Single {
+ public:
+  static const uint32_t kSignMask = 0x80000000;
+  static const uint32_t kExponentMask = 0x7F800000;
+  static const uint32_t kSignificandMask = 0x007FFFFF;
+  static const uint32_t kHiddenBit = 0x00800000;
+  static const int kPhysicalSignificandSize = 23;  // Excludes the hidden bit.
+  static const int kSignificandSize = 24;
+
+  Single() : d32_(0) {}
+  explicit Single(float f) : d32_(float_to_uint32(f)) {}
+  explicit Single(uint32_t d32) : d32_(d32) {}
+
+  // The value encoded by this Single must be greater or equal to +0.0.
+  // It must not be special (infinity, or NaN).
+  DiyFp AsDiyFp() const {
+    ASSERT(Sign() > 0);
+    ASSERT(!IsSpecial());
+    return DiyFp(Significand(), Exponent());
+  }
+
+  // Returns the single's bit as uint64.
+  uint32_t AsUint32() const {
+    return d32_;
+  }
+
+  int Exponent() const {
+    if (IsDenormal()) return kDenormalExponent;
+
+    uint32_t d32 = AsUint32();
+    int biased_e =
+        static_cast<int>((d32 & kExponentMask) >> kPhysicalSignificandSize);
+    return biased_e - kExponentBias;
+  }
+
+  uint32_t Significand() const {
+    uint32_t d32 = AsUint32();
+    uint32_t significand = d32 & kSignificandMask;
+    if (!IsDenormal()) {
+      return significand + kHiddenBit;
+    } else {
+      return significand;
+    }
+  }
+
+  // Returns true if the single is a denormal.
+  bool IsDenormal() const {
+    uint32_t d32 = AsUint32();
+    return (d32 & kExponentMask) == 0;
+  }
+
+  // We consider denormals not to be special.
+  // Hence only Infinity and NaN are special.
+  bool IsSpecial() const {
+    uint32_t d32 = AsUint32();
+    return (d32 & kExponentMask) == kExponentMask;
+  }
+
+  bool IsNan() const {
+    uint32_t d32 = AsUint32();
+    return ((d32 & kExponentMask) == kExponentMask) &&
+        ((d32 & kSignificandMask) != 0);
+  }
+
+  bool IsInfinite() const {
+    uint32_t d32 = AsUint32();
+    return ((d32 & kExponentMask) == kExponentMask) &&
+        ((d32 & kSignificandMask) == 0);
+  }
+
+  int Sign() const {
+    uint32_t d32 = AsUint32();
+    return (d32 & kSignMask) == 0? 1: -1;
+  }
+
+  // Computes the two boundaries of this.
+  // The bigger boundary (m_plus) is normalized. The lower boundary has the same
+  // exponent as m_plus.
+  // Precondition: the value encoded by this Single must be greater than 0.
+  void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const {
+    ASSERT(value() > 0.0);
+    DiyFp v = this->AsDiyFp();
+    DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1));
+    DiyFp m_minus;
+    if (LowerBoundaryIsCloser()) {
+      m_minus = DiyFp((v.f() << 2) - 1, v.e() - 2);
+    } else {
+      m_minus = DiyFp((v.f() << 1) - 1, v.e() - 1);
+    }
+    m_minus.set_f(m_minus.f() << (m_minus.e() - m_plus.e()));
+    m_minus.set_e(m_plus.e());
+    *out_m_plus = m_plus;
+    *out_m_minus = m_minus;
+  }
+
+  // Precondition: the value encoded by this Single must be greater or equal
+  // than +0.0.
+  DiyFp UpperBoundary() const {
+    ASSERT(Sign() > 0);
+    return DiyFp(Significand() * 2 + 1, Exponent() - 1);
+  }
+
+  bool LowerBoundaryIsCloser() const {
+    // The boundary is closer if the significand is of the form f == 2^p-1 then
+    // the lower boundary is closer.
+    // Think of v = 1000e10 and v- = 9999e9.
+    // Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but
+    // at a distance of 1e8.
+    // The only exception is for the smallest normal: the largest denormal is
+    // at the same distance as its successor.
+    // Note: denormals have the same exponent as the smallest normals.
+    bool physical_significand_is_zero = ((AsUint32() & kSignificandMask) == 0);
+    return physical_significand_is_zero && (Exponent() != kDenormalExponent);
+  }
+
+  float value() const { return uint32_to_float(d32_); }
+
+  static float Infinity() {
+    return Single(kInfinity).value();
+  }
+
+  static float NaN() {
+    return Single(kNaN).value();
+  }
+
+ private:
+  static const int kExponentBias = 0x7F + kPhysicalSignificandSize;
+  static const int kDenormalExponent = -kExponentBias + 1;
+  static const int kMaxExponent = 0xFF - kExponentBias;
+  static const uint32_t kInfinity = 0x7F800000;
+  static const uint32_t kNaN = 0x7FC00000;
+
+  const uint32_t d32_;
+};
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_DOUBLE_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/strtod.cc b/src/third_party/mozjs-45/mfbt/double-conversion/strtod.cc
new file mode 100644
index 0000000..b097afe
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/strtod.cc
@@ -0,0 +1,555 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <stdarg.h>
+#include <limits.h>
+
+#include "strtod.h"
+#include "bignum.h"
+#include "cached-powers.h"
+#include "ieee.h"
+
+namespace double_conversion {
+
+// 2^53 = 9007199254740992.
+// Any integer with at most 15 decimal digits will hence fit into a double
+// (which has a 53bit significand) without loss of precision.
+static const int kMaxExactDoubleIntegerDecimalDigits = 15;
+// 2^64 = 18446744073709551616 > 10^19
+static const int kMaxUint64DecimalDigits = 19;
+
+// Max double: 1.7976931348623157 x 10^308
+// Min non-zero double: 4.9406564584124654 x 10^-324
+// Any x >= 10^309 is interpreted as +infinity.
+// Any x <= 10^-324 is interpreted as 0.
+// Note that 2.5e-324 (despite being smaller than the min double) will be read
+// as non-zero (equal to the min non-zero double).
+static const int kMaxDecimalPower = 309;
+static const int kMinDecimalPower = -324;
+
+// 2^64 = 18446744073709551616
+static const uint64_t kMaxUint64 = UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF);
+
+
+static const double exact_powers_of_ten[] = {
+  1.0,  // 10^0
+  10.0,
+  100.0,
+  1000.0,
+  10000.0,
+  100000.0,
+  1000000.0,
+  10000000.0,
+  100000000.0,
+  1000000000.0,
+  10000000000.0,  // 10^10
+  100000000000.0,
+  1000000000000.0,
+  10000000000000.0,
+  100000000000000.0,
+  1000000000000000.0,
+  10000000000000000.0,
+  100000000000000000.0,
+  1000000000000000000.0,
+  10000000000000000000.0,
+  100000000000000000000.0,  // 10^20
+  1000000000000000000000.0,
+  // 10^22 = 0x21e19e0c9bab2400000 = 0x878678326eac9 * 2^22
+  10000000000000000000000.0
+};
+static const int kExactPowersOfTenSize = ARRAY_SIZE(exact_powers_of_ten);
+
+// Maximum number of significant digits in the decimal representation.
+// In fact the value is 772 (see conversions.cc), but to give us some margin
+// we round up to 780.
+static const int kMaxSignificantDecimalDigits = 780;
+
+static Vector<const char> TrimLeadingZeros(Vector<const char> buffer) {
+  for (int i = 0; i < buffer.length(); i++) {
+    if (buffer[i] != '0') {
+      return buffer.SubVector(i, buffer.length());
+    }
+  }
+  return Vector<const char>(buffer.start(), 0);
+}
+
+
+static Vector<const char> TrimTrailingZeros(Vector<const char> buffer) {
+  for (int i = buffer.length() - 1; i >= 0; --i) {
+    if (buffer[i] != '0') {
+      return buffer.SubVector(0, i + 1);
+    }
+  }
+  return Vector<const char>(buffer.start(), 0);
+}
+
+
+static void CutToMaxSignificantDigits(Vector<const char> buffer,
+                                       int exponent,
+                                       char* significant_buffer,
+                                       int* significant_exponent) {
+  for (int i = 0; i < kMaxSignificantDecimalDigits - 1; ++i) {
+    significant_buffer[i] = buffer[i];
+  }
+  // The input buffer has been trimmed. Therefore the last digit must be
+  // different from '0'.
+  ASSERT(buffer[buffer.length() - 1] != '0');
+  // Set the last digit to be non-zero. This is sufficient to guarantee
+  // correct rounding.
+  significant_buffer[kMaxSignificantDecimalDigits - 1] = '1';
+  *significant_exponent =
+      exponent + (buffer.length() - kMaxSignificantDecimalDigits);
+}
+
+
+// Trims the buffer and cuts it to at most kMaxSignificantDecimalDigits.
+// If possible the input-buffer is reused, but if the buffer needs to be
+// modified (due to cutting), then the input needs to be copied into the
+// buffer_copy_space.
+static void TrimAndCut(Vector<const char> buffer, int exponent,
+                       char* buffer_copy_space, int space_size,
+                       Vector<const char>* trimmed, int* updated_exponent) {
+  Vector<const char> left_trimmed = TrimLeadingZeros(buffer);
+  Vector<const char> right_trimmed = TrimTrailingZeros(left_trimmed);
+  exponent += left_trimmed.length() - right_trimmed.length();
+  if (right_trimmed.length() > kMaxSignificantDecimalDigits) {
+    ASSERT(space_size >= kMaxSignificantDecimalDigits);
+    CutToMaxSignificantDigits(right_trimmed, exponent,
+                              buffer_copy_space, updated_exponent);
+    *trimmed = Vector<const char>(buffer_copy_space,
+                                 kMaxSignificantDecimalDigits);
+  } else {
+    *trimmed = right_trimmed;
+    *updated_exponent = exponent;
+  }
+}
+
+
+// Reads digits from the buffer and converts them to a uint64.
+// Reads in as many digits as fit into a uint64.
+// When the string starts with "1844674407370955161" no further digit is read.
+// Since 2^64 = 18446744073709551616 it would still be possible read another
+// digit if it was less or equal than 6, but this would complicate the code.
+static uint64_t ReadUint64(Vector<const char> buffer,
+                           int* number_of_read_digits) {
+  uint64_t result = 0;
+  int i = 0;
+  while (i < buffer.length() && result <= (kMaxUint64 / 10 - 1)) {
+    int digit = buffer[i++] - '0';
+    ASSERT(0 <= digit && digit <= 9);
+    result = 10 * result + digit;
+  }
+  *number_of_read_digits = i;
+  return result;
+}
+
+
+// Reads a DiyFp from the buffer.
+// The returned DiyFp is not necessarily normalized.
+// If remaining_decimals is zero then the returned DiyFp is accurate.
+// Otherwise it has been rounded and has error of at most 1/2 ulp.
+static void ReadDiyFp(Vector<const char> buffer,
+                      DiyFp* result,
+                      int* remaining_decimals) {
+  int read_digits;
+  uint64_t significand = ReadUint64(buffer, &read_digits);
+  if (buffer.length() == read_digits) {
+    *result = DiyFp(significand, 0);
+    *remaining_decimals = 0;
+  } else {
+    // Round the significand.
+    if (buffer[read_digits] >= '5') {
+      significand++;
+    }
+    // Compute the binary exponent.
+    int exponent = 0;
+    *result = DiyFp(significand, exponent);
+    *remaining_decimals = buffer.length() - read_digits;
+  }
+}
+
+
+static bool DoubleStrtod(Vector<const char> trimmed,
+                         int exponent,
+                         double* result) {
+#if !defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
+  // On x86 the floating-point stack can be 64 or 80 bits wide. If it is
+  // 80 bits wide (as is the case on Linux) then double-rounding occurs and the
+  // result is not accurate.
+  // We know that Windows32 uses 64 bits and is therefore accurate.
+  // Note that the ARM simulator is compiled for 32bits. It therefore exhibits
+  // the same problem.
+  return false;
+#endif
+  if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) {
+    int read_digits;
+    // The trimmed input fits into a double.
+    // If the 10^exponent (resp. 10^-exponent) fits into a double too then we
+    // can compute the result-double simply by multiplying (resp. dividing) the
+    // two numbers.
+    // This is possible because IEEE guarantees that floating-point operations
+    // return the best possible approximation.
+    if (exponent < 0 && -exponent < kExactPowersOfTenSize) {
+      // 10^-exponent fits into a double.
+      *result = static_cast<double>(ReadUint64(trimmed, &read_digits));
+      ASSERT(read_digits == trimmed.length());
+      *result /= exact_powers_of_ten[-exponent];
+      return true;
+    }
+    if (0 <= exponent && exponent < kExactPowersOfTenSize) {
+      // 10^exponent fits into a double.
+      *result = static_cast<double>(ReadUint64(trimmed, &read_digits));
+      ASSERT(read_digits == trimmed.length());
+      *result *= exact_powers_of_ten[exponent];
+      return true;
+    }
+    int remaining_digits =
+        kMaxExactDoubleIntegerDecimalDigits - trimmed.length();
+    if ((0 <= exponent) &&
+        (exponent - remaining_digits < kExactPowersOfTenSize)) {
+      // The trimmed string was short and we can multiply it with
+      // 10^remaining_digits. As a result the remaining exponent now fits
+      // into a double too.
+      *result = static_cast<double>(ReadUint64(trimmed, &read_digits));
+      ASSERT(read_digits == trimmed.length());
+      *result *= exact_powers_of_ten[remaining_digits];
+      *result *= exact_powers_of_ten[exponent - remaining_digits];
+      return true;
+    }
+  }
+  return false;
+}
+
+
+// Returns 10^exponent as an exact DiyFp.
+// The given exponent must be in the range [1; kDecimalExponentDistance[.
+static DiyFp AdjustmentPowerOfTen(int exponent) {
+  ASSERT(0 < exponent);
+  ASSERT(exponent < PowersOfTenCache::kDecimalExponentDistance);
+  // Simply hardcode the remaining powers for the given decimal exponent
+  // distance.
+  ASSERT(PowersOfTenCache::kDecimalExponentDistance == 8);
+  switch (exponent) {
+    case 1: return DiyFp(UINT64_2PART_C(0xa0000000, 00000000), -60);
+    case 2: return DiyFp(UINT64_2PART_C(0xc8000000, 00000000), -57);
+    case 3: return DiyFp(UINT64_2PART_C(0xfa000000, 00000000), -54);
+    case 4: return DiyFp(UINT64_2PART_C(0x9c400000, 00000000), -50);
+    case 5: return DiyFp(UINT64_2PART_C(0xc3500000, 00000000), -47);
+    case 6: return DiyFp(UINT64_2PART_C(0xf4240000, 00000000), -44);
+    case 7: return DiyFp(UINT64_2PART_C(0x98968000, 00000000), -40);
+    default:
+      UNREACHABLE();
+      return DiyFp(0, 0);
+  }
+}
+
+
+// If the function returns true then the result is the correct double.
+// Otherwise it is either the correct double or the double that is just below
+// the correct double.
+static bool DiyFpStrtod(Vector<const char> buffer,
+                        int exponent,
+                        double* result) {
+  DiyFp input;
+  int remaining_decimals;
+  ReadDiyFp(buffer, &input, &remaining_decimals);
+  // Since we may have dropped some digits the input is not accurate.
+  // If remaining_decimals is different than 0 than the error is at most
+  // .5 ulp (unit in the last place).
+  // We don't want to deal with fractions and therefore keep a common
+  // denominator.
+  const int kDenominatorLog = 3;
+  const int kDenominator = 1 << kDenominatorLog;
+  // Move the remaining decimals into the exponent.
+  exponent += remaining_decimals;
+  int error = (remaining_decimals == 0 ? 0 : kDenominator / 2);
+
+  int old_e = input.e();
+  input.Normalize();
+  error <<= old_e - input.e();
+
+  ASSERT(exponent <= PowersOfTenCache::kMaxDecimalExponent);
+  if (exponent < PowersOfTenCache::kMinDecimalExponent) {
+    *result = 0.0;
+    return true;
+  }
+  DiyFp cached_power;
+  int cached_decimal_exponent;
+  PowersOfTenCache::GetCachedPowerForDecimalExponent(exponent,
+                                                     &cached_power,
+                                                     &cached_decimal_exponent);
+
+  if (cached_decimal_exponent != exponent) {
+    int adjustment_exponent = exponent - cached_decimal_exponent;
+    DiyFp adjustment_power = AdjustmentPowerOfTen(adjustment_exponent);
+    input.Multiply(adjustment_power);
+    if (kMaxUint64DecimalDigits - buffer.length() >= adjustment_exponent) {
+      // The product of input with the adjustment power fits into a 64 bit
+      // integer.
+      ASSERT(DiyFp::kSignificandSize == 64);
+    } else {
+      // The adjustment power is exact. There is hence only an error of 0.5.
+      error += kDenominator / 2;
+    }
+  }
+
+  input.Multiply(cached_power);
+  // The error introduced by a multiplication of a*b equals
+  //   error_a + error_b + error_a*error_b/2^64 + 0.5
+  // Substituting a with 'input' and b with 'cached_power' we have
+  //   error_b = 0.5  (all cached powers have an error of less than 0.5 ulp),
+  //   error_ab = 0 or 1 / kDenominator > error_a*error_b/ 2^64
+  int error_b = kDenominator / 2;
+  int error_ab = (error == 0 ? 0 : 1);  // We round up to 1.
+  int fixed_error = kDenominator / 2;
+  error += error_b + error_ab + fixed_error;
+
+  old_e = input.e();
+  input.Normalize();
+  error <<= old_e - input.e();
+
+  // See if the double's significand changes if we add/subtract the error.
+  int order_of_magnitude = DiyFp::kSignificandSize + input.e();
+  int effective_significand_size =
+      Double::SignificandSizeForOrderOfMagnitude(order_of_magnitude);
+  int precision_digits_count =
+      DiyFp::kSignificandSize - effective_significand_size;
+  if (precision_digits_count + kDenominatorLog >= DiyFp::kSignificandSize) {
+    // This can only happen for very small denormals. In this case the
+    // half-way multiplied by the denominator exceeds the range of an uint64.
+    // Simply shift everything to the right.
+    int shift_amount = (precision_digits_count + kDenominatorLog) -
+        DiyFp::kSignificandSize + 1;
+    input.set_f(input.f() >> shift_amount);
+    input.set_e(input.e() + shift_amount);
+    // We add 1 for the lost precision of error, and kDenominator for
+    // the lost precision of input.f().
+    error = (error >> shift_amount) + 1 + kDenominator;
+    precision_digits_count -= shift_amount;
+  }
+  // We use uint64_ts now. This only works if the DiyFp uses uint64_ts too.
+  ASSERT(DiyFp::kSignificandSize == 64);
+  ASSERT(precision_digits_count < 64);
+  uint64_t one64 = 1;
+  uint64_t precision_bits_mask = (one64 << precision_digits_count) - 1;
+  uint64_t precision_bits = input.f() & precision_bits_mask;
+  uint64_t half_way = one64 << (precision_digits_count - 1);
+  precision_bits *= kDenominator;
+  half_way *= kDenominator;
+  DiyFp rounded_input(input.f() >> precision_digits_count,
+                      input.e() + precision_digits_count);
+  if (precision_bits >= half_way + error) {
+    rounded_input.set_f(rounded_input.f() + 1);
+  }
+  // If the last_bits are too close to the half-way case than we are too
+  // inaccurate and round down. In this case we return false so that we can
+  // fall back to a more precise algorithm.
+
+  *result = Double(rounded_input).value();
+  if (half_way - error < precision_bits && precision_bits < half_way + error) {
+    // Too imprecise. The caller will have to fall back to a slower version.
+    // However the returned number is guaranteed to be either the correct
+    // double, or the next-lower double.
+    return false;
+  } else {
+    return true;
+  }
+}
+
+
+// Returns
+//   - -1 if buffer*10^exponent < diy_fp.
+//   -  0 if buffer*10^exponent == diy_fp.
+//   - +1 if buffer*10^exponent > diy_fp.
+// Preconditions:
+//   buffer.length() + exponent <= kMaxDecimalPower + 1
+//   buffer.length() + exponent > kMinDecimalPower
+//   buffer.length() <= kMaxDecimalSignificantDigits
+static int CompareBufferWithDiyFp(Vector<const char> buffer,
+                                  int exponent,
+                                  DiyFp diy_fp) {
+  ASSERT(buffer.length() + exponent <= kMaxDecimalPower + 1);
+  ASSERT(buffer.length() + exponent > kMinDecimalPower);
+  ASSERT(buffer.length() <= kMaxSignificantDecimalDigits);
+  // Make sure that the Bignum will be able to hold all our numbers.
+  // Our Bignum implementation has a separate field for exponents. Shifts will
+  // consume at most one bigit (< 64 bits).
+  // ln(10) == 3.3219...
+  ASSERT(((kMaxDecimalPower + 1) * 333 / 100) < Bignum::kMaxSignificantBits);
+  Bignum buffer_bignum;
+  Bignum diy_fp_bignum;
+  buffer_bignum.AssignDecimalString(buffer);
+  diy_fp_bignum.AssignUInt64(diy_fp.f());
+  if (exponent >= 0) {
+    buffer_bignum.MultiplyByPowerOfTen(exponent);
+  } else {
+    diy_fp_bignum.MultiplyByPowerOfTen(-exponent);
+  }
+  if (diy_fp.e() > 0) {
+    diy_fp_bignum.ShiftLeft(diy_fp.e());
+  } else {
+    buffer_bignum.ShiftLeft(-diy_fp.e());
+  }
+  return Bignum::Compare(buffer_bignum, diy_fp_bignum);
+}
+
+
+// Returns true if the guess is the correct double.
+// Returns false, when guess is either correct or the next-lower double.
+static bool ComputeGuess(Vector<const char> trimmed, int exponent,
+                         double* guess) {
+  if (trimmed.length() == 0) {
+    *guess = 0.0;
+    return true;
+  }
+  if (exponent + trimmed.length() - 1 >= kMaxDecimalPower) {
+    *guess = Double::Infinity();
+    return true;
+  }
+  if (exponent + trimmed.length() <= kMinDecimalPower) {
+    *guess = 0.0;
+    return true;
+  }
+
+  if (DoubleStrtod(trimmed, exponent, guess) ||
+      DiyFpStrtod(trimmed, exponent, guess)) {
+    return true;
+  }
+  if (*guess == Double::Infinity()) {
+    return true;
+  }
+  return false;
+}
+
+double Strtod(Vector<const char> buffer, int exponent) {
+  char copy_buffer[kMaxSignificantDecimalDigits];
+  Vector<const char> trimmed;
+  int updated_exponent;
+  TrimAndCut(buffer, exponent, copy_buffer, kMaxSignificantDecimalDigits,
+             &trimmed, &updated_exponent);
+  exponent = updated_exponent;
+
+  double guess;
+  bool is_correct = ComputeGuess(trimmed, exponent, &guess);
+  if (is_correct) return guess;
+
+  DiyFp upper_boundary = Double(guess).UpperBoundary();
+  int comparison = CompareBufferWithDiyFp(trimmed, exponent, upper_boundary);
+  if (comparison < 0) {
+    return guess;
+  } else if (comparison > 0) {
+    return Double(guess).NextDouble();
+  } else if ((Double(guess).Significand() & 1) == 0) {
+    // Round towards even.
+    return guess;
+  } else {
+    return Double(guess).NextDouble();
+  }
+}
+
+float Strtof(Vector<const char> buffer, int exponent) {
+  char copy_buffer[kMaxSignificantDecimalDigits];
+  Vector<const char> trimmed;
+  int updated_exponent;
+  TrimAndCut(buffer, exponent, copy_buffer, kMaxSignificantDecimalDigits,
+             &trimmed, &updated_exponent);
+  exponent = updated_exponent;
+
+  double double_guess;
+  bool is_correct = ComputeGuess(trimmed, exponent, &double_guess);
+
+  float float_guess = static_cast<float>(double_guess);
+  if (float_guess == double_guess) {
+    // This shortcut triggers for integer values.
+    return float_guess;
+  }
+
+  // We must catch double-rounding. Say the double has been rounded up, and is
+  // now a boundary of a float, and rounds up again. This is why we have to
+  // look at previous too.
+  // Example (in decimal numbers):
+  //    input: 12349
+  //    high-precision (4 digits): 1235
+  //    low-precision (3 digits):
+  //       when read from input: 123
+  //       when rounded from high precision: 124.
+  // To do this we simply look at the neigbors of the correct result and see
+  // if they would round to the same float. If the guess is not correct we have
+  // to look at four values (since two different doubles could be the correct
+  // double).
+
+  double double_next = Double(double_guess).NextDouble();
+  double double_previous = Double(double_guess).PreviousDouble();
+
+  float f1 = static_cast<float>(double_previous);
+  float f2 = float_guess;
+  float f3 = static_cast<float>(double_next);
+  float f4;
+  if (is_correct) {
+    f4 = f3;
+  } else {
+    double double_next2 = Double(double_next).NextDouble();
+    f4 = static_cast<float>(double_next2);
+  }
+  (void) f2; // Mark variable as used.
+  ASSERT(f1 <= f2 && f2 <= f3 && f3 <= f4);
+
+  // If the guess doesn't lie near a single-precision boundary we can simply
+  // return its float-value.
+  if (f1 == f4) {
+    return float_guess;
+  }
+
+  ASSERT((f1 != f2 && f2 == f3 && f3 == f4) ||
+         (f1 == f2 && f2 != f3 && f3 == f4) ||
+         (f1 == f2 && f2 == f3 && f3 != f4));
+
+  // guess and next are the two possible canditates (in the same way that
+  // double_guess was the lower candidate for a double-precision guess).
+  float guess = f1;
+  float next = f4;
+  DiyFp upper_boundary;
+  if (guess == 0.0f) {
+    float min_float = 1e-45f;
+    upper_boundary = Double(static_cast<double>(min_float) / 2).AsDiyFp();
+  } else {
+    upper_boundary = Single(guess).UpperBoundary();
+  }
+  int comparison = CompareBufferWithDiyFp(trimmed, exponent, upper_boundary);
+  if (comparison < 0) {
+    return guess;
+  } else if (comparison > 0) {
+    return next;
+  } else if ((Single(guess).Significand() & 1) == 0) {
+    // Round towards even.
+    return guess;
+  } else {
+    return next;
+  }
+}
+
+}  // namespace double_conversion
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/strtod.h b/src/third_party/mozjs-45/mfbt/double-conversion/strtod.h
new file mode 100644
index 0000000..ed0293b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/strtod.h
@@ -0,0 +1,45 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_STRTOD_H_
+#define DOUBLE_CONVERSION_STRTOD_H_
+
+#include "utils.h"
+
+namespace double_conversion {
+
+// The buffer must only contain digits in the range [0-9]. It must not
+// contain a dot or a sign. It must not start with '0', and must not be empty.
+double Strtod(Vector<const char> buffer, int exponent);
+
+// The buffer must only contain digits in the range [0-9]. It must not
+// contain a dot or a sign. It must not start with '0', and must not be empty.
+float Strtof(Vector<const char> buffer, int exponent);
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_STRTOD_H_
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/update.sh b/src/third_party/mozjs-45/mfbt/double-conversion/update.sh
new file mode 100755
index 0000000..22233b9
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/update.sh
@@ -0,0 +1,23 @@
+# Usage: ./update.sh <double-conversion-src-directory>
+#
+# Copies the needed files from a directory containing the original
+# double-conversion source that we need.
+
+# This was last updated with git rev 04cae7a8d5ef3d62ceffb03cdc3d38f258457a52.
+
+set -e
+
+cp $1/LICENSE ./
+cp $1/README ./
+
+# Includes
+cp $1/src/*.h ./
+
+# Source
+cp $1/src/*.cc ./
+
+patch -p3 < add-mfbt-api-markers.patch
+patch -p3 < use-StandardInteger.patch
+patch -p3 < use-mozilla-assertions.patch
+patch -p3 < use-static_assert.patch
+patch -p3 < ToPrecision-exponential.patch
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/use-StandardInteger.patch b/src/third_party/mozjs-45/mfbt/double-conversion/use-StandardInteger.patch
new file mode 100644
index 0000000..7fe867f
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/use-StandardInteger.patch
@@ -0,0 +1,29 @@
+diff --git a/mfbt/double-conversion/utils.h b/mfbt/double-conversion/utils.h
+index cd3e330..bdc7d4b 100644
+--- a/mfbt/double-conversion/utils.h
++++ b/mfbt/double-conversion/utils.h
+@@ -74,23 +74,7 @@
+ #endif
+ 
+ 
+-#if defined(_WIN32) && !defined(__MINGW32__)
+-
+-typedef signed char int8_t;
+-typedef unsigned char uint8_t;
+-typedef short int16_t;  // NOLINT
+-typedef unsigned short uint16_t;  // NOLINT
+-typedef int int32_t;
+-typedef unsigned int uint32_t;
+-typedef __int64 int64_t;
+-typedef unsigned __int64 uint64_t;
+-// intptr_t and friends are defined in crtdefs.h through stdio.h.
+-
+-#else
+-
+-#include <stdint.h>
+-
+-#endif
++#include <stdint.h>
+ 
+ // The following macro works on both 32 and 64-bit platforms.
+ // Usage: instead of writing 0x1234567890123456
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/use-mozilla-assertions.patch b/src/third_party/mozjs-45/mfbt/double-conversion/use-mozilla-assertions.patch
new file mode 100644
index 0000000..c98565f
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/use-mozilla-assertions.patch
@@ -0,0 +1,23 @@
+diff --git a/mfbt/double-conversion/utils.h b/mfbt/double-conversion/utils.h
+--- a/mfbt/double-conversion/utils.h
++++ b/mfbt/double-conversion/utils.h
+@@ -31,15 +31,15 @@
+ #include <stdlib.h>
+ #include <string.h>
+ 
+-#include <assert.h>
++#include "mozilla/Assertions.h"
+ #ifndef ASSERT
+-#define ASSERT(condition)      (assert(condition))
++#define ASSERT(condition)      MOZ_ASSERT(condition)
+ #endif
+ #ifndef UNIMPLEMENTED
+-#define UNIMPLEMENTED() (abort())
++#define UNIMPLEMENTED() MOZ_CRASH()
+ #endif
+ #ifndef UNREACHABLE
+-#define UNREACHABLE()   (abort())
++#define UNREACHABLE()   MOZ_CRASH()
+ #endif
+ 
+ // Double operations detection based on target architecture.
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/use-static_assert.patch b/src/third_party/mozjs-45/mfbt/double-conversion/use-static_assert.patch
new file mode 100644
index 0000000..4143782
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/use-static_assert.patch
@@ -0,0 +1,25 @@
+diff --git a/mfbt/double-conversion/utils.h b/mfbt/double-conversion/utils.h
+--- a/mfbt/double-conversion/utils.h
++++ b/mfbt/double-conversion/utils.h
+@@ -275,19 +275,18 @@ class StringBuilder {
+ // There is an additional use for BitCast.
+ // Recent gccs will warn when they see casts that may result in breakage due to
+ // the type-based aliasing rule.  If you have checked that there is no breakage
+ // you can use BitCast to cast one pointer type to another.  This confuses gcc
+ // enough that it can no longer see that you have cast one pointer type to
+ // another thus avoiding the warning.
+ template <class Dest, class Source>
+ inline Dest BitCast(const Source& source) {
+-  // Compile time assertion: sizeof(Dest) == sizeof(Source)
+-  // A compile error here means your Dest and Source have different sizes.
+-  typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
++  static_assert(sizeof(Dest) == sizeof(Source),
++                "BitCast's source and destination types must be the same size");
+ 
+   Dest dest;
+   memmove(&dest, &source, sizeof(dest));
+   return dest;
+ }
+ 
+ template <class Dest, class Source>
+ inline Dest BitCast(Source* source) {
diff --git a/src/third_party/mozjs-45/mfbt/double-conversion/utils.h b/src/third_party/mozjs-45/mfbt/double-conversion/utils.h
new file mode 100644
index 0000000..15dd4bf
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/double-conversion/utils.h
@@ -0,0 +1,298 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DOUBLE_CONVERSION_UTILS_H_
+#define DOUBLE_CONVERSION_UTILS_H_
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "mozilla/Assertions.h"
+#ifndef ASSERT
+#define ASSERT(condition)      MOZ_ASSERT(condition)
+#endif
+#ifndef UNIMPLEMENTED
+#define UNIMPLEMENTED() MOZ_CRASH()
+#endif
+#ifndef UNREACHABLE
+#define UNREACHABLE()   MOZ_CRASH()
+#endif
+
+// Double operations detection based on target architecture.
+// Linux uses a 80bit wide floating point stack on x86. This induces double
+// rounding, which in turn leads to wrong results.
+// An easy way to test if the floating-point operations are correct is to
+// evaluate: 89255.0/1e22. If the floating-point stack is 64 bits wide then
+// the result is equal to 89255e-22.
+// The best way to test this, is to create a division-function and to compare
+// the output of the division with the expected result. (Inlining must be
+// disabled.)
+// On Linux,x86 89255e-22 != Div_double(89255.0/1e22)
+#if defined(_M_X64) || defined(__x86_64__) || \
+    defined(__ARMEL__) || defined(__avr32__) || \
+    defined(__hppa__) || defined(__ia64__) || \
+    defined(__mips__) || \
+    defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || \
+    defined(__sparc__) || defined(__sparc) || defined(__s390__) || \
+    defined(__SH4__) || defined(__alpha__) || \
+    defined(_MIPS_ARCH_MIPS32R2) || \
+    defined(__AARCH64EL__) || defined(__aarch64__)
+#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
+#elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
+#if defined(_WIN32)
+// Windows uses a 64bit wide floating point stack.
+#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
+#else
+#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
+#endif  // _WIN32
+#else
+#error Target architecture was not detected as supported by Double-Conversion.
+#endif
+
+
+#include <stdint.h>
+
+// The following macro works on both 32 and 64-bit platforms.
+// Usage: instead of writing 0x1234567890123456
+//      write UINT64_2PART_C(0x12345678,90123456);
+#define UINT64_2PART_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
+
+
+// The expression ARRAY_SIZE(a) is a compile-time constant of type
+// size_t which represents the number of elements of the given
+// array. You should only use ARRAY_SIZE on statically allocated
+// arrays.
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a)                                   \
+  ((sizeof(a) / sizeof(*(a))) /                         \
+  static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+#endif
+
+// A macro to disallow the evil copy constructor and operator= functions
+// This should be used in the private: declarations for a class
+#ifndef DISALLOW_COPY_AND_ASSIGN
+#define DISALLOW_COPY_AND_ASSIGN(TypeName)      \
+  TypeName(const TypeName&);                    \
+  void operator=(const TypeName&)
+#endif
+
+// A macro to disallow all the implicit constructors, namely the
+// default constructor, copy constructor and operator= functions.
+//
+// This should be used in the private: declarations for a class
+// that wants to prevent anyone from instantiating it. This is
+// especially useful for classes containing only static methods.
+#ifndef DISALLOW_IMPLICIT_CONSTRUCTORS
+#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
+  TypeName();                                    \
+  DISALLOW_COPY_AND_ASSIGN(TypeName)
+#endif
+
+namespace double_conversion {
+
+static const int kCharSize = sizeof(char);
+
+// Returns the maximum of the two parameters.
+template <typename T>
+static T Max(T a, T b) {
+  return a < b ? b : a;
+}
+
+
+// Returns the minimum of the two parameters.
+template <typename T>
+static T Min(T a, T b) {
+  return a < b ? a : b;
+}
+
+
+inline int StrLength(const char* string) {
+  size_t length = strlen(string);
+  ASSERT(length == static_cast<size_t>(static_cast<int>(length)));
+  return static_cast<int>(length);
+}
+
+// This is a simplified version of V8's Vector class.
+template <typename T>
+class Vector {
+ public:
+  Vector() : start_(NULL), length_(0) {}
+  Vector(T* data, int len) : start_(data), length_(len) {
+    ASSERT(len == 0 || (len > 0 && data != NULL));
+  }
+
+  // Returns a vector using the same backing storage as this one,
+  // spanning from and including 'from', to but not including 'to'.
+  Vector<T> SubVector(int from, int to) {
+    ASSERT(to <= length_);
+    ASSERT(from < to);
+    ASSERT(0 <= from);
+    return Vector<T>(start() + from, to - from);
+  }
+
+  // Returns the length of the vector.
+  int length() const { return length_; }
+
+  // Returns whether or not the vector is empty.
+  bool is_empty() const { return length_ == 0; }
+
+  // Returns the pointer to the start of the data in the vector.
+  T* start() const { return start_; }
+
+  // Access individual vector elements - checks bounds in debug mode.
+  T& operator[](int index) const {
+    ASSERT(0 <= index && index < length_);
+    return start_[index];
+  }
+
+  T& first() { return start_[0]; }
+
+  T& last() { return start_[length_ - 1]; }
+
+ private:
+  T* start_;
+  int length_;
+};
+
+
+// Helper class for building result strings in a character buffer. The
+// purpose of the class is to use safe operations that checks the
+// buffer bounds on all operations in debug mode.
+class StringBuilder {
+ public:
+  StringBuilder(char* buffer, int buffer_size)
+      : buffer_(buffer, buffer_size), position_(0) { }
+
+  ~StringBuilder() { if (!is_finalized()) Finalize(); }
+
+  int size() const { return buffer_.length(); }
+
+  // Get the current position in the builder.
+  int position() const {
+    ASSERT(!is_finalized());
+    return position_;
+  }
+
+  // Reset the position.
+  void Reset() { position_ = 0; }
+
+  // Add a single character to the builder. It is not allowed to add
+  // 0-characters; use the Finalize() method to terminate the string
+  // instead.
+  void AddCharacter(char c) {
+    ASSERT(c != '\0');
+    ASSERT(!is_finalized() && position_ < buffer_.length());
+    buffer_[position_++] = c;
+  }
+
+  // Add an entire string to the builder. Uses strlen() internally to
+  // compute the length of the input string.
+  void AddString(const char* s) {
+    AddSubstring(s, StrLength(s));
+  }
+
+  // Add the first 'n' characters of the given string 's' to the
+  // builder. The input string must have enough characters.
+  void AddSubstring(const char* s, int n) {
+    ASSERT(!is_finalized() && position_ + n < buffer_.length());
+    ASSERT(static_cast<size_t>(n) <= strlen(s));
+    memmove(&buffer_[position_], s, n * kCharSize);
+    position_ += n;
+  }
+
+
+  // Add character padding to the builder. If count is non-positive,
+  // nothing is added to the builder.
+  void AddPadding(char c, int count) {
+    for (int i = 0; i < count; i++) {
+      AddCharacter(c);
+    }
+  }
+
+  // Finalize the string by 0-terminating it and returning the buffer.
+  char* Finalize() {
+    ASSERT(!is_finalized() && position_ < buffer_.length());
+    buffer_[position_] = '\0';
+    // Make sure nobody managed to add a 0-character to the
+    // buffer while building the string.
+    ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_));
+    position_ = -1;
+    ASSERT(is_finalized());
+    return buffer_.start();
+  }
+
+ private:
+  Vector<char> buffer_;
+  int position_;
+
+  bool is_finalized() const { return position_ < 0; }
+
+  DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder);
+};
+
+// The type-based aliasing rule allows the compiler to assume that pointers of
+// different types (for some definition of different) never alias each other.
+// Thus the following code does not work:
+//
+// float f = foo();
+// int fbits = *(int*)(&f);
+//
+// The compiler 'knows' that the int pointer can't refer to f since the types
+// don't match, so the compiler may cache f in a register, leaving random data
+// in fbits.  Using C++ style casts makes no difference, however a pointer to
+// char data is assumed to alias any other pointer.  This is the 'memcpy
+// exception'.
+//
+// Bit_cast uses the memcpy exception to move the bits from a variable of one
+// type of a variable of another type.  Of course the end result is likely to
+// be implementation dependent.  Most compilers (gcc-4.2 and MSVC 2005)
+// will completely optimize BitCast away.
+//
+// There is an additional use for BitCast.
+// Recent gccs will warn when they see casts that may result in breakage due to
+// the type-based aliasing rule.  If you have checked that there is no breakage
+// you can use BitCast to cast one pointer type to another.  This confuses gcc
+// enough that it can no longer see that you have cast one pointer type to
+// another thus avoiding the warning.
+template <class Dest, class Source>
+inline Dest BitCast(const Source& source) {
+  static_assert(sizeof(Dest) == sizeof(Source),
+                "BitCast's source and destination types must be the same size");
+
+  Dest dest;
+  memmove(&dest, &source, sizeof(dest));
+  return dest;
+}
+
+template <class Dest, class Source>
+inline Dest BitCast(Source* source) {
+  return BitCast<Dest>(reinterpret_cast<uintptr_t>(source));
+}
+
+}  // namespace double_conversion
+
+#endif  // DOUBLE_CONVERSION_UTILS_H_
diff --git a/src/third_party/mozjs-45/mfbt/lz4.c b/src/third_party/mozjs-45/mfbt/lz4.c
new file mode 100644
index 0000000..c416fe8
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/lz4.c
@@ -0,0 +1,1163 @@
+/*
+   LZ4 - Fast LZ compression algorithm
+   Copyright (C) 2011-2014, Yann Collet.
+   BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+       * Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+       * Redistributions in binary form must reproduce the above
+   copyright notice, this list of conditions and the following disclaimer
+   in the documentation and/or other materials provided with the
+   distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+   You can contact the author at :
+   - LZ4 source repository : http://code.google.com/p/lz4/
+   - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
+*/
+
+/**************************************
+   Tuning parameters
+**************************************/
+/*
+ * HEAPMODE :
+ * Select how default compression functions will allocate memory for their hash table,
+ * in memory stack (0:default, fastest), or in memory heap (1:requires memory allocation (malloc)).
+ */
+#define HEAPMODE 0
+
+
+/**************************************
+   CPU Feature Detection
+**************************************/
+/* 32 or 64 bits ? */
+#if (defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) \
+  || defined(__powerpc64__) || defined(__powerpc64le__) \
+  || defined(__ppc64__) || defined(__ppc64le__) \
+  || defined(__PPC64__) || defined(__PPC64LE__) \
+  || defined(__ia64) || defined(__itanium__) || defined(_M_IA64) \
+  || (defined(__mips64) && defined(_ABI64)))   /* Detects 64 bits mode */
+#  define LZ4_ARCH64 1
+#else
+#  define LZ4_ARCH64 0
+#endif
+
+/*
+ * Little Endian or Big Endian ?
+ * Overwrite the #define below if you know your architecture endianess
+ */
+#include <stdlib.h>   /* Apparently required to detect endianess */
+#if defined (__GLIBC__)
+#  include <endian.h>
+#  if (__BYTE_ORDER == __BIG_ENDIAN)
+#     define LZ4_BIG_ENDIAN 1
+#  endif
+#elif (defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN)) && !(defined(__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN) || defined(_LITTLE_ENDIAN))
+#  define LZ4_BIG_ENDIAN 1
+#elif defined(__sparc) || defined(__sparc__) \
+   || defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) \
+   || defined(__hpux)  || defined(__hppa) \
+   || defined(_MIPSEB) || defined(__s390__)
+#  define LZ4_BIG_ENDIAN 1
+#else
+/* Little Endian assumed. PDP Endian and other very rare endian format are unsupported. */
+#endif
+
+/*
+ * Unaligned memory access is automatically enabled for "common" CPU, such as x86.
+ * For others CPU, such as ARM, the compiler may be more cautious, inserting unnecessary extra code to ensure aligned access property
+ * If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance
+ */
+#if defined(__ARM_FEATURE_UNALIGNED)
+#  define LZ4_FORCE_UNALIGNED_ACCESS 1
+#endif
+
+/* Define this parameter if your target system or compiler does not support hardware bit count */
+#if defined(_MSC_VER) && defined(_WIN32_WCE)   /* Visual Studio for Windows CE does not support Hardware bit count */
+#  define LZ4_FORCE_SW_BITCOUNT
+#endif
+
+/*
+ * BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE :
+ * This option may provide a small boost to performance for some big endian cpu, although probably modest.
+ * You may set this option to 1 if data will remain within closed environment.
+ * This option is useless on Little_Endian CPU (such as x86)
+ */
+
+/* #define BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE 1 */
+
+
+/**************************************
+ Compiler Options
+**************************************/
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)   /* C99 */
+/* "restrict" is a known keyword */
+#else
+#  define restrict /* Disable restrict */
+#endif
+
+#ifdef _MSC_VER    /* Visual Studio */
+#  define FORCE_INLINE static __forceinline
+#  include <intrin.h>                    /* For Visual 2005 */
+#  if LZ4_ARCH64   /* 64-bits */
+#    pragma intrinsic(_BitScanForward64) /* For Visual 2005 */
+#    pragma intrinsic(_BitScanReverse64) /* For Visual 2005 */
+#  else            /* 32-bits */
+#    pragma intrinsic(_BitScanForward)   /* For Visual 2005 */
+#    pragma intrinsic(_BitScanReverse)   /* For Visual 2005 */
+#  endif
+#  pragma warning(disable : 4127)        /* disable: C4127: conditional expression is constant */
+#else
+#  ifdef __GNUC__
+#    define FORCE_INLINE static inline __attribute__((always_inline))
+#  else
+#    define FORCE_INLINE static inline
+#  endif
+#endif
+
+#ifdef _MSC_VER  /* Visual Studio */
+#  define lz4_bswap16(x) _byteswap_ushort(x)
+#else
+#  define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
+#endif
+
+#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+
+#if (GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__)
+#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
+#else
+#  define expect(expr,value)    (expr)
+#endif
+
+#define likely(expr)     expect((expr) != 0, 1)
+#define unlikely(expr)   expect((expr) != 0, 0)
+
+
+/**************************************
+   Memory routines
+**************************************/
+#include <stdlib.h>   /* malloc, calloc, free */
+#define ALLOCATOR(n,s) calloc(n,s)
+#define FREEMEM        free
+#include <string.h>   /* memset, memcpy */
+#define MEM_INIT       memset
+
+
+/**************************************
+   Includes
+**************************************/
+#include "lz4.h"
+
+
+/**************************************
+   Basic Types
+**************************************/
+#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)   /* C99 */
+# include <stdint.h>
+  typedef  uint8_t BYTE;
+  typedef uint16_t U16;
+  typedef uint32_t U32;
+  typedef  int32_t S32;
+  typedef uint64_t U64;
+#else
+  typedef unsigned char       BYTE;
+  typedef unsigned short      U16;
+  typedef unsigned int        U32;
+  typedef   signed int        S32;
+  typedef unsigned long long  U64;
+#endif
+
+#if defined(__GNUC__)  && !defined(LZ4_FORCE_UNALIGNED_ACCESS)
+#  define _PACKED __attribute__ ((packed))
+#else
+#  define _PACKED
+#endif
+
+#if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__)
+#  if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+#    pragma pack(1)
+#  else
+#    pragma pack(push, 1)
+#  endif
+#endif
+
+typedef struct { U16 v; }  _PACKED U16_S;
+typedef struct { U32 v; }  _PACKED U32_S;
+typedef struct { U64 v; }  _PACKED U64_S;
+typedef struct {size_t v;} _PACKED size_t_S;
+
+#if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__)
+#  if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+#    pragma pack(0)
+#  else
+#    pragma pack(pop)
+#  endif
+#endif
+
+#define A16(x)   (((U16_S *)(x))->v)
+#define A32(x)   (((U32_S *)(x))->v)
+#define A64(x)   (((U64_S *)(x))->v)
+#define AARCH(x) (((size_t_S *)(x))->v)
+
+
+/**************************************
+   Constants
+**************************************/
+#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
+#define HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
+#define HASH_SIZE_U32 (1 << LZ4_HASHLOG)
+
+#define MINMATCH 4
+
+#define COPYLENGTH 8
+#define LASTLITERALS 5
+#define MFLIMIT (COPYLENGTH+MINMATCH)
+static const int LZ4_minLength = (MFLIMIT+1);
+
+#define KB *(1U<<10)
+#define MB *(1U<<20)
+#define GB *(1U<<30)
+
+#define LZ4_64KLIMIT ((64 KB) + (MFLIMIT-1))
+#define SKIPSTRENGTH 6   /* Increasing this value will make the compression run slower on incompressible data */
+
+#define MAXD_LOG 16
+#define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
+
+#define ML_BITS  4
+#define ML_MASK  ((1U<<ML_BITS)-1)
+#define RUN_BITS (8-ML_BITS)
+#define RUN_MASK ((1U<<RUN_BITS)-1)
+
+
+/**************************************
+   Structures and local types
+**************************************/
+typedef struct {
+    U32  hashTable[HASH_SIZE_U32];
+    U32  currentOffset;
+    U32  initCheck;
+    const BYTE* dictionary;
+    const BYTE* bufferStart;
+    U32  dictSize;
+} LZ4_stream_t_internal;
+
+typedef enum { notLimited = 0, limitedOutput = 1 } limitedOutput_directive;
+typedef enum { byPtr, byU32, byU16 } tableType_t;
+
+typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive;
+typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
+
+typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive;
+typedef enum { full = 0, partial = 1 } earlyEnd_directive;
+
+
+/**************************************
+   Architecture-specific macros
+**************************************/
+#define STEPSIZE                  sizeof(size_t)
+#define LZ4_COPYSTEP(d,s)         { AARCH(d) = AARCH(s); d+=STEPSIZE; s+=STEPSIZE; }
+#define LZ4_COPY8(d,s)            { LZ4_COPYSTEP(d,s); if (STEPSIZE<8) LZ4_COPYSTEP(d,s); }
+
+#if (defined(LZ4_BIG_ENDIAN) && !defined(BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE))
+#  define LZ4_READ_LITTLEENDIAN_16(d,s,p) { U16 v = A16(p); v = lz4_bswap16(v); d = (s) - v; }
+#  define LZ4_WRITE_LITTLEENDIAN_16(p,i)  { U16 v = (U16)(i); v = lz4_bswap16(v); A16(p) = v; p+=2; }
+#else      /* Little Endian */
+#  define LZ4_READ_LITTLEENDIAN_16(d,s,p) { d = (s) - A16(p); }
+#  define LZ4_WRITE_LITTLEENDIAN_16(p,v)  { A16(p) = v; p+=2; }
+#endif
+
+
+/**************************************
+   Macros
+**************************************/
+#define LZ4_STATIC_ASSERT(c)    { enum { LZ4_static_assert = 1/(!!(c)) }; }   /* use only *after* variable declarations */
+#if LZ4_ARCH64 || !defined(__GNUC__)
+#  define LZ4_WILDCOPY(d,s,e)   { do { LZ4_COPY8(d,s) } while (d<e); }        /* at the end, d>=e; */
+#else
+#  define LZ4_WILDCOPY(d,s,e)   { if (likely(e-d <= 8)) LZ4_COPY8(d,s) else do { LZ4_COPY8(d,s) } while (d<e); }
+#endif
+
+
+/****************************
+   Private local functions
+****************************/
+#if LZ4_ARCH64
+
+int LZ4_NbCommonBytes (register U64 val)
+{
+# if defined(LZ4_BIG_ENDIAN)
+#   if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+    unsigned long r = 0;
+    _BitScanReverse64( &r, val );
+    return (int)(r>>3);
+#   elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
+    return (__builtin_clzll(val) >> 3);
+#   else
+    int r;
+    if (!(val>>32)) { r=4; } else { r=0; val>>=32; }
+    if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
+    r += (!val);
+    return r;
+#   endif
+# else
+#   if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+    unsigned long r = 0;
+    _BitScanForward64( &r, val );
+    return (int)(r>>3);
+#   elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
+    return (__builtin_ctzll(val) >> 3);
+#   else
+    static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
+    return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
+#   endif
+# endif
+}
+
+#else
+
+int LZ4_NbCommonBytes (register U32 val)
+{
+# if defined(LZ4_BIG_ENDIAN)
+#   if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+    unsigned long r = 0;
+    _BitScanReverse( &r, val );
+    return (int)(r>>3);
+#   elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
+    return (__builtin_clz(val) >> 3);
+#   else
+    int r;
+    if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
+    r += (!val);
+    return r;
+#   endif
+# else
+#   if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+    unsigned long r;
+    _BitScanForward( &r, val );
+    return (int)(r>>3);
+#   elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
+    return (__builtin_ctz(val) >> 3);
+#   else
+    static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
+    return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
+#   endif
+# endif
+}
+
+#endif
+
+
+/********************************
+   Compression functions
+********************************/
+int LZ4_compressBound(int isize)  { return LZ4_COMPRESSBOUND(isize); }
+
+static int LZ4_hashSequence(U32 sequence, tableType_t tableType)
+{
+    if (tableType == byU16)
+        return (((sequence) * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1)));
+    else
+        return (((sequence) * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
+}
+
+static int LZ4_hashPosition(const BYTE* p, tableType_t tableType) { return LZ4_hashSequence(A32(p), tableType); }
+
+static void LZ4_putPositionOnHash(const BYTE* p, U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase)
+{
+    switch (tableType)
+    {
+    case byPtr: { const BYTE** hashTable = (const BYTE**) tableBase; hashTable[h] = p; break; }
+    case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); break; }
+    case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); break; }
+    }
+}
+
+static void LZ4_putPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase)
+{
+    U32 h = LZ4_hashPosition(p, tableType);
+    LZ4_putPositionOnHash(p, h, tableBase, tableType, srcBase);
+}
+
+static const BYTE* LZ4_getPositionOnHash(U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase)
+{
+    if (tableType == byPtr) { const BYTE** hashTable = (const BYTE**) tableBase; return hashTable[h]; }
+    if (tableType == byU32) { U32* hashTable = (U32*) tableBase; return hashTable[h] + srcBase; }
+    { U16* hashTable = (U16*) tableBase; return hashTable[h] + srcBase; }   /* default, to ensure a return */
+}
+
+static const BYTE* LZ4_getPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase)
+{
+    U32 h = LZ4_hashPosition(p, tableType);
+    return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase);
+}
+
+static unsigned LZ4_count(const BYTE* pIn, const BYTE* pRef, const BYTE* pInLimit)
+{
+    const BYTE* const pStart = pIn;
+
+    while (likely(pIn<pInLimit-(STEPSIZE-1)))
+    {
+        size_t diff = AARCH(pRef) ^ AARCH(pIn);
+        if (!diff) { pIn+=STEPSIZE; pRef+=STEPSIZE; continue; }
+        pIn += LZ4_NbCommonBytes(diff);
+        return (unsigned)(pIn - pStart);
+    }
+    if (sizeof(void*)==8) if ((pIn<(pInLimit-3)) && (A32(pRef) == A32(pIn))) { pIn+=4; pRef+=4; }
+    if ((pIn<(pInLimit-1)) && (A16(pRef) == A16(pIn))) { pIn+=2; pRef+=2; }
+    if ((pIn<pInLimit) && (*pRef == *pIn)) pIn++;
+
+    return (unsigned)(pIn - pStart);
+}
+
+
+static int LZ4_compress_generic(
+                 void* ctx,
+                 const char* source,
+                 char* dest,
+                 int inputSize,
+                 int maxOutputSize,
+
+                 limitedOutput_directive outputLimited,
+                 tableType_t tableType,
+                 dict_directive dict,
+                 dictIssue_directive dictIssue)
+{
+    LZ4_stream_t_internal* const dictPtr = (LZ4_stream_t_internal*)ctx;
+
+    const BYTE* ip = (const BYTE*) source;
+    const BYTE* base;
+    const BYTE* lowLimit;
+    const BYTE* const lowRefLimit = ip - dictPtr->dictSize;
+    const BYTE* const dictionary = dictPtr->dictionary;
+    const BYTE* const dictEnd = dictionary + dictPtr->dictSize;
+    const size_t dictDelta = dictEnd - (const BYTE*)source;
+    const BYTE* anchor = (const BYTE*) source;
+    const BYTE* const iend = ip + inputSize;
+    const BYTE* const mflimit = iend - MFLIMIT;
+    const BYTE* const matchlimit = iend - LASTLITERALS;
+
+    BYTE* op = (BYTE*) dest;
+    BYTE* const olimit = op + maxOutputSize;
+
+    const int skipStrength = SKIPSTRENGTH;
+    U32 forwardH;
+    size_t refDelta=0;
+
+    /* Init conditions */
+    if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0;          /* Unsupported input size, too large (or negative) */
+    switch(dict)
+    {
+    case noDict:
+    default:
+        base = (const BYTE*)source;
+        lowLimit = (const BYTE*)source;
+        break;
+    case withPrefix64k:
+        base = (const BYTE*)source - dictPtr->currentOffset;
+        lowLimit = (const BYTE*)source - dictPtr->dictSize;
+        break;
+    case usingExtDict:
+        base = (const BYTE*)source - dictPtr->currentOffset;
+        lowLimit = (const BYTE*)source;
+        break;
+    }
+    if ((tableType == byU16) && (inputSize>=(int)LZ4_64KLIMIT)) return 0;   /* Size too large (not within 64K limit) */
+    if (inputSize<LZ4_minLength) goto _last_literals;                       /* Input too small, no compression (all literals) */
+
+    /* First Byte */
+    LZ4_putPosition(ip, ctx, tableType, base);
+    ip++; forwardH = LZ4_hashPosition(ip, tableType);
+
+    /* Main Loop */
+    for ( ; ; )
+    {
+        const BYTE* ref;
+        BYTE* token;
+        {
+            const BYTE* forwardIp = ip;
+            unsigned step=1;
+            unsigned searchMatchNb = (1U << skipStrength);
+
+            /* Find a match */
+            do {
+                U32 h = forwardH;
+                ip = forwardIp;
+                forwardIp += step;
+                step = searchMatchNb++ >> skipStrength;
+                //if (step>8) step=8;   // required for valid forwardIp ; slows down uncompressible data a bit
+
+                if (unlikely(forwardIp > mflimit)) goto _last_literals;
+
+                ref = LZ4_getPositionOnHash(h, ctx, tableType, base);
+                if (dict==usingExtDict)
+                {
+                    if (ref<(const BYTE*)source)
+                    {
+                        refDelta = dictDelta;
+                        lowLimit = dictionary;
+                    }
+                    else
+                    {
+                        refDelta = 0;
+                        lowLimit = (const BYTE*)source;
+                    }
+                }
+                forwardH = LZ4_hashPosition(forwardIp, tableType);
+                LZ4_putPositionOnHash(ip, h, ctx, tableType, base);
+
+            } while ( ((dictIssue==dictSmall) ? (ref < lowRefLimit) : 0)
+                || ((tableType==byU16) ? 0 : (ref + MAX_DISTANCE < ip))
+                || (A32(ref+refDelta) != A32(ip)) );
+        }
+
+        /* Catch up */
+        while ((ip>anchor) && (ref+refDelta > lowLimit) && (unlikely(ip[-1]==ref[refDelta-1]))) { ip--; ref--; }
+
+        {
+            /* Encode Literal length */
+            unsigned litLength = (unsigned)(ip - anchor);
+            token = op++;
+            if ((outputLimited) && (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit)))
+                return 0;   /* Check output limit */
+            if (litLength>=RUN_MASK)
+            {
+                int len = (int)litLength-RUN_MASK;
+                *token=(RUN_MASK<<ML_BITS);
+                for(; len >= 255 ; len-=255) *op++ = 255;
+                *op++ = (BYTE)len;
+            }
+            else *token = (BYTE)(litLength<<ML_BITS);
+
+            /* Copy Literals */
+            { BYTE* end = op+litLength; LZ4_WILDCOPY(op,anchor,end); op=end; }
+        }
+
+_next_match:
+        /* Encode Offset */
+        LZ4_WRITE_LITTLEENDIAN_16(op, (U16)(ip-ref));
+
+        /* Encode MatchLength */
+        {
+            unsigned matchLength;
+
+            if ((dict==usingExtDict) && (lowLimit==dictionary))
+            {
+                const BYTE* limit;
+                ref += refDelta;
+                limit = ip + (dictEnd-ref);
+                if (limit > matchlimit) limit = matchlimit;
+                matchLength = LZ4_count(ip+MINMATCH, ref+MINMATCH, limit);
+                ip += MINMATCH + matchLength;
+                if (ip==limit)
+                {
+                    unsigned more = LZ4_count(ip, (const BYTE*)source, matchlimit);
+                    matchLength += more;
+                    ip += more;
+                }
+            }
+            else
+            {
+                matchLength = LZ4_count(ip+MINMATCH, ref+MINMATCH, matchlimit);
+                ip += MINMATCH + matchLength;
+            }
+
+            if (matchLength>=ML_MASK)
+            {
+                if ((outputLimited) && (unlikely(op + (1 + LASTLITERALS) + (matchLength>>8) > olimit)))
+                    return 0;    /* Check output limit */
+                *token += ML_MASK;
+                matchLength -= ML_MASK;
+                for (; matchLength >= 510 ; matchLength-=510) { *op++ = 255; *op++ = 255; }
+                if (matchLength >= 255) { matchLength-=255; *op++ = 255; }
+                *op++ = (BYTE)matchLength;
+            }
+            else *token += (BYTE)(matchLength);
+        }
+
+        anchor = ip;
+
+        /* Test end of chunk */
+        if (ip > mflimit) break;
+
+        /* Fill table */
+        LZ4_putPosition(ip-2, ctx, tableType, base);
+
+        /* Test next position */
+        ref = LZ4_getPosition(ip, ctx, tableType, base);
+        if (dict==usingExtDict)
+        {
+            if (ref<(const BYTE*)source)
+            {
+                refDelta = dictDelta;
+                lowLimit = dictionary;
+            }
+            else
+            {
+                refDelta = 0;
+                lowLimit = (const BYTE*)source;
+            }
+        }
+        LZ4_putPosition(ip, ctx, tableType, base);
+        if ( ((dictIssue==dictSmall) ? (ref>=lowRefLimit) : 1)
+            && (ref+MAX_DISTANCE>=ip)
+            && (A32(ref+refDelta)==A32(ip)) )
+        { token=op++; *token=0; goto _next_match; }
+
+        /* Prepare next loop */
+        forwardH = LZ4_hashPosition(++ip, tableType);
+    }
+
+_last_literals:
+    /* Encode Last Literals */
+    {
+        int lastRun = (int)(iend - anchor);
+        if ((outputLimited) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize))
+            return 0;   /* Check output limit */
+        if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun >= 255 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
+        else *op++ = (BYTE)(lastRun<<ML_BITS);
+        memcpy(op, anchor, iend - anchor);
+        op += iend-anchor;
+    }
+
+    /* End */
+    return (int) (((char*)op)-dest);
+}
+
+
+int LZ4_compress(const char* source, char* dest, int inputSize)
+{
+#if (HEAPMODE)
+    void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U32, 4);   /* Aligned on 4-bytes boundaries */
+#else
+    U32 ctx[LZ4_STREAMSIZE_U32] = {0};      /* Ensure data is aligned on 4-bytes boundaries */
+#endif
+    int result;
+
+    if (inputSize < (int)LZ4_64KLIMIT)
+        result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, byU16, noDict, noDictIssue);
+    else
+        result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, (sizeof(void*)==8) ? byU32 : byPtr, noDict, noDictIssue);
+
+#if (HEAPMODE)
+    FREEMEM(ctx);
+#endif
+    return result;
+}
+
+int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize)
+{
+#if (HEAPMODE)
+    void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U32, 4);   /* Aligned on 4-bytes boundaries */
+#else
+    U32 ctx[LZ4_STREAMSIZE_U32] = {0};      /* Ensure data is aligned on 4-bytes boundaries */
+#endif
+    int result;
+
+    if (inputSize < (int)LZ4_64KLIMIT)
+        result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue);
+    else
+        result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, (sizeof(void*)==8) ? byU32 : byPtr, noDict, noDictIssue);
+
+#if (HEAPMODE)
+    FREEMEM(ctx);
+#endif
+    return result;
+}
+
+
+/*****************************************
+   Experimental : Streaming functions
+*****************************************/
+
+void* LZ4_createStream()
+{
+    void* lz4s = ALLOCATOR(4, LZ4_STREAMSIZE_U32);
+    MEM_INIT(lz4s, 0, LZ4_STREAMSIZE);
+    return lz4s;
+}
+
+int LZ4_free (void* LZ4_stream)
+{
+    FREEMEM(LZ4_stream);
+    return (0);
+}
+
+
+int LZ4_loadDict (void* LZ4_dict, const char* dictionary, int dictSize)
+{
+    LZ4_stream_t_internal* dict = (LZ4_stream_t_internal*) LZ4_dict;
+    const BYTE* p = (const BYTE*)dictionary;
+    const BYTE* const dictEnd = p + dictSize;
+    const BYTE* base;
+
+    LZ4_STATIC_ASSERT(LZ4_STREAMSIZE >= sizeof(LZ4_stream_t_internal));      /* A compilation error here means LZ4_STREAMSIZE is not large enough */
+    if (dict->initCheck) MEM_INIT(dict, 0, sizeof(LZ4_stream_t_internal));   /* Uninitialized structure detected */
+
+    if (dictSize < MINMATCH)
+    {
+        dict->dictionary = NULL;
+        dict->dictSize = 0;
+        return 1;
+    }
+
+    if (p <= dictEnd - 64 KB) p = dictEnd - 64 KB;
+    base = p - dict->currentOffset;
+    dict->dictionary = p;
+    dict->dictSize = (U32)(dictEnd - p);
+    dict->currentOffset += dict->dictSize;
+
+    while (p <= dictEnd-MINMATCH)
+    {
+        LZ4_putPosition(p, dict, byU32, base);
+        p+=3;
+    }
+
+    return 1;
+}
+
+
+void LZ4_renormDictT(LZ4_stream_t_internal* LZ4_dict, const BYTE* src)
+{
+    if ((LZ4_dict->currentOffset > 0x80000000) ||
+        ((size_t)LZ4_dict->currentOffset > (size_t)src))   /* address space overflow */
+    {
+        /* rescale hash table */
+        U32 delta = LZ4_dict->currentOffset - 64 KB;
+        const BYTE* dictEnd = LZ4_dict->dictionary + LZ4_dict->dictSize;
+        int i;
+        for (i=0; i<HASH_SIZE_U32; i++)
+        {
+            if (LZ4_dict->hashTable[i] < delta) LZ4_dict->hashTable[i]=0;
+            else LZ4_dict->hashTable[i] -= delta;
+        }
+        LZ4_dict->currentOffset = 64 KB;
+        if (LZ4_dict->dictSize > 64 KB) LZ4_dict->dictSize = 64 KB;
+        LZ4_dict->dictionary = dictEnd - LZ4_dict->dictSize;
+    }
+}
+
+
+FORCE_INLINE int LZ4_compress_continue_generic (void* LZ4_stream, const char* source, char* dest, int inputSize,
+                                                int maxOutputSize, limitedOutput_directive limit)
+{
+    LZ4_stream_t_internal* streamPtr = (LZ4_stream_t_internal*)LZ4_stream;
+    const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize;
+
+    const BYTE* smallest = (const BYTE*) source;
+    if (streamPtr->initCheck) return 0;   /* Uninitialized structure detected */
+    if ((streamPtr->dictSize>0) && (smallest>dictEnd)) smallest = dictEnd;
+    LZ4_renormDictT(streamPtr, smallest);
+
+    /* Check overlapping input/dictionary space */
+    {
+        const BYTE* sourceEnd = (const BYTE*) source + inputSize;
+        if ((sourceEnd > streamPtr->dictionary) && (sourceEnd < dictEnd))
+        {
+            streamPtr->dictSize = (U32)(dictEnd - sourceEnd);
+            if (streamPtr->dictSize > 64 KB) streamPtr->dictSize = 64 KB;
+            if (streamPtr->dictSize < 4) streamPtr->dictSize = 0;
+            streamPtr->dictionary = dictEnd - streamPtr->dictSize;
+        }
+    }
+
+    /* prefix mode : source data follows dictionary */
+    if (dictEnd == (const BYTE*)source)
+    {
+        int result;
+        if ((streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset))
+            result = LZ4_compress_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limit, byU32, withPrefix64k, dictSmall);
+        else
+            result = LZ4_compress_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limit, byU32, withPrefix64k, noDictIssue);
+        streamPtr->dictSize += (U32)inputSize;
+        streamPtr->currentOffset += (U32)inputSize;
+        return result;
+    }
+
+    /* external dictionary mode */
+    {
+        int result;
+        if ((streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset))
+            result = LZ4_compress_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limit, byU32, usingExtDict, dictSmall);
+        else
+            result = LZ4_compress_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limit, byU32, usingExtDict, noDictIssue);
+        streamPtr->dictionary = (const BYTE*)source;
+        streamPtr->dictSize = (U32)inputSize;
+        streamPtr->currentOffset += (U32)inputSize;
+        return result;
+    }
+}
+
+
+int LZ4_compress_continue (void* LZ4_stream, const char* source, char* dest, int inputSize)
+{
+    return LZ4_compress_continue_generic(LZ4_stream, source, dest, inputSize, 0, notLimited);
+}
+
+int LZ4_compress_limitedOutput_continue (void* LZ4_stream, const char* source, char* dest, int inputSize, int maxOutputSize)
+{
+    return LZ4_compress_continue_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limitedOutput);
+}
+
+
+// Hidden debug function, to force separate dictionary mode
+int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char* dest, int inputSize)
+{
+    LZ4_stream_t_internal* streamPtr = (LZ4_stream_t_internal*)LZ4_dict;
+    int result;
+    const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize;
+
+    const BYTE* smallest = dictEnd;
+    if (smallest > (const BYTE*) source) smallest = (const BYTE*) source;
+    LZ4_renormDictT((LZ4_stream_t_internal*)LZ4_dict, smallest);
+
+    result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, 0, notLimited, byU32, usingExtDict, noDictIssue);
+
+    streamPtr->dictionary = (const BYTE*)source;
+    streamPtr->dictSize = (U32)inputSize;
+    streamPtr->currentOffset += (U32)inputSize;
+
+    return result;
+}
+
+
+int LZ4_saveDict (void* LZ4_dict, char* safeBuffer, int dictSize)
+{
+    LZ4_stream_t_internal* dict = (LZ4_stream_t_internal*) LZ4_dict;
+    const BYTE* previousDictEnd = dict->dictionary + dict->dictSize;
+
+    if ((U32)dictSize > 64 KB) dictSize = 64 KB;   /* useless to define a dictionary > 64 KB */
+    if ((U32)dictSize > dict->dictSize) dictSize = dict->dictSize;
+
+    memcpy(safeBuffer, previousDictEnd - dictSize, dictSize);
+
+    dict->dictionary = (const BYTE*)safeBuffer;
+    dict->dictSize = (U32)dictSize;
+
+    return 1;
+}
+
+
+
+/****************************
+   Decompression functions
+****************************/
+/*
+ * This generic decompression function cover all use cases.
+ * It shall be instanciated several times, using different sets of directives
+ * Note that it is essential this generic function is really inlined,
+ * in order to remove useless branches during compilation optimisation.
+ */
+FORCE_INLINE int LZ4_decompress_generic(
+                 const char* source,
+                 char* dest,
+                 int inputSize,
+                 int outputSize,         /* If endOnInput==endOnInputSize, this value is the max size of Output Buffer. */
+
+                 int endOnInput,         /* endOnOutputSize, endOnInputSize */
+                 int partialDecoding,    /* full, partial */
+                 int targetOutputSize,   /* only used if partialDecoding==partial */
+                 int dict,               /* noDict, withPrefix64k, usingExtDict */
+                 const char* dictStart,  /* only if dict==usingExtDict */
+                 int dictSize            /* note : = 0 if noDict */
+                 )
+{
+    /* Local Variables */
+    const BYTE* restrict ip = (const BYTE*) source;
+    const BYTE* ref;
+    const BYTE* const iend = ip + inputSize;
+
+    BYTE* op = (BYTE*) dest;
+    BYTE* const oend = op + outputSize;
+    BYTE* cpy;
+    BYTE* oexit = op + targetOutputSize;
+    const BYTE* const lowLimit = (const BYTE*)dest - dictSize;
+
+    const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize;
+//#define OLD
+#ifdef OLD
+    const size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0};   /* static reduces speed for LZ4_decompress_safe() on GCC64 */
+#else
+    const size_t dec32table[] = {4-0, 4-3, 4-2, 4-3, 4-0, 4-0, 4-0, 4-0};   /* static reduces speed for LZ4_decompress_safe() on GCC64 */
+#endif
+    static const size_t dec64table[] = {0, 0, 0, (size_t)-1, 0, 1, 2, 3};
+
+    const int checkOffset = (endOnInput) && (dictSize < (int)(64 KB));
+
+
+    /* Special cases */
+    if ((partialDecoding) && (oexit> oend-MFLIMIT)) oexit = oend-MFLIMIT;                        /* targetOutputSize too high => decode everything */
+    if ((endOnInput) && (unlikely(outputSize==0))) return ((inputSize==1) && (*ip==0)) ? 0 : -1;   /* Empty output buffer */
+    if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0?1:-1);
+
+
+    /* Main Loop */
+    while (1)
+    {
+        unsigned token;
+        size_t length;
+
+        /* get runlength */
+        token = *ip++;
+        if ((length=(token>>ML_BITS)) == RUN_MASK)
+        {
+            unsigned s;
+            do
+            {
+                s = *ip++;
+                length += s;
+            }
+            while (likely((endOnInput)?ip<iend-RUN_MASK:1) && (s==255));
+            //if ((sizeof(void*)==4) && unlikely(length>LZ4_MAX_INPUT_SIZE)) goto _output_error;   /* overflow detection */
+            if ((sizeof(void*)==4) && unlikely((size_t)(op+length)<(size_t)(op))) goto _output_error;   /* quickfix issue 134 */
+            if ((endOnInput) && (sizeof(void*)==4) && unlikely((size_t)(ip+length)<(size_t)(ip))) goto _output_error;   /* quickfix issue 134 */
+        }
+
+        /* copy literals */
+        cpy = op+length;
+        if (((endOnInput) && ((cpy>(partialDecoding?oexit:oend-MFLIMIT)) || (ip+length>iend-(2+1+LASTLITERALS))) )
+            || ((!endOnInput) && (cpy>oend-COPYLENGTH)))
+        {
+            if (partialDecoding)
+            {
+                if (cpy > oend) goto _output_error;                           /* Error : write attempt beyond end of output buffer */
+                if ((endOnInput) && (ip+length > iend)) goto _output_error;   /* Error : read attempt beyond end of input buffer */
+            }
+            else
+            {
+                if ((!endOnInput) && (cpy != oend)) goto _output_error;       /* Error : block decoding must stop exactly there */
+                if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error;   /* Error : input must be consumed */
+            }
+            memcpy(op, ip, length);
+            ip += length;
+            op += length;
+            break;                                       /* Necessarily EOF, due to parsing restrictions */
+        }
+        LZ4_WILDCOPY(op, ip, cpy); ip -= (op-cpy); op = cpy;
+
+        /* get offset */
+        LZ4_READ_LITTLEENDIAN_16(ref,cpy,ip); ip+=2;
+        if ((checkOffset) && (unlikely(ref < lowLimit))) goto _output_error;   /* Error : offset outside destination buffer */
+
+        /* get matchlength */
+        if ((length=(token&ML_MASK)) == ML_MASK)
+        {
+            unsigned s;
+            do
+            {
+                if ((endOnInput) && (ip > iend-LASTLITERALS)) goto _output_error;
+                s = *ip++;
+                length += s;
+            } while (s==255);
+            //if ((sizeof(void*)==4) && unlikely(length>LZ4_MAX_INPUT_SIZE)) goto _output_error;   /* overflow detection */
+            if ((sizeof(void*)==4) && unlikely((size_t)(op+length)<(size_t)op)) goto _output_error;   /* quickfix issue 134 */
+        }
+
+        /* check external dictionary */
+        if ((dict==usingExtDict) && (ref < (BYTE* const)dest))
+        {
+            if (unlikely(op+length+MINMATCH > oend-LASTLITERALS)) goto _output_error;
+
+            if (length+MINMATCH <= (size_t)(dest-(char*)ref))
+            {
+                ref = dictEnd - (dest-(char*)ref);
+                memcpy(op, ref, length+MINMATCH);
+                op += length+MINMATCH;
+            }
+            else
+            {
+                size_t copySize = (size_t)(dest-(char*)ref);
+                memcpy(op, dictEnd - copySize, copySize);
+                op += copySize;
+                copySize = length+MINMATCH - copySize;
+                if (copySize > (size_t)((char*)op-dest))   /* overlap */
+                {
+                    BYTE* const cpy = op + copySize;
+                    const BYTE* ref = (BYTE*)dest;
+                    while (op < cpy) *op++ = *ref++;
+                }
+                else
+                {
+                    memcpy(op, dest, copySize);
+                    op += copySize;
+                }
+            }
+            continue;
+        }
+
+        /* copy repeated sequence */
+        if (unlikely((op-ref)<(int)STEPSIZE))
+        {
+            const size_t dec64 = dec64table[(sizeof(void*)==4) ? 0 : op-ref];
+            op[0] = ref[0];
+            op[1] = ref[1];
+            op[2] = ref[2];
+            op[3] = ref[3];
+#ifdef OLD
+            op += 4, ref += 4; ref -= dec32table[op-ref];
+            A32(op) = A32(ref);
+            op += STEPSIZE-4; ref -= dec64;
+#else
+            ref += dec32table[op-ref];
+            A32(op+4) = A32(ref);
+            op += STEPSIZE; ref -= dec64;
+#endif
+        } else { LZ4_COPYSTEP(op,ref); }
+        cpy = op + length - (STEPSIZE-4);
+
+        if (unlikely(cpy>oend-COPYLENGTH-(STEPSIZE-4)))
+        {
+            if (cpy > oend-LASTLITERALS) goto _output_error;    /* Error : last 5 bytes must be literals */
+            if (op<oend-COPYLENGTH) LZ4_WILDCOPY(op, ref, (oend-COPYLENGTH));
+            while(op<cpy) *op++=*ref++;
+            op=cpy;
+            continue;
+        }
+        LZ4_WILDCOPY(op, ref, cpy);
+        op=cpy;   /* correction */
+    }
+
+    /* end of decoding */
+    if (endOnInput)
+       return (int) (((char*)op)-dest);     /* Nb of output bytes decoded */
+    else
+       return (int) (((char*)ip)-source);   /* Nb of input bytes read */
+
+    /* Overflow error detected */
+_output_error:
+    return (int) (-(((char*)ip)-source))-1;
+}
+
+
+int LZ4_decompress_safe(const char* source, char* dest, int compressedSize, int maxOutputSize)
+{
+    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, noDict, NULL, 0);
+}
+
+int LZ4_decompress_safe_partial(const char* source, char* dest, int compressedSize, int targetOutputSize, int maxOutputSize)
+{
+    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, partial, targetOutputSize, noDict, NULL, 0);
+}
+
+int LZ4_decompress_fast(const char* source, char* dest, int originalSize)
+{
+    return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, NULL, 0);
+}
+
+/* streaming decompression functions */
+
+//#define LZ4_STREAMDECODESIZE_U32 4
+//#define LZ4_STREAMDECODESIZE     (LZ4_STREAMDECODESIZE_U32 * sizeof(unsigned int))
+//typedef struct { unsigned int table[LZ4_STREAMDECODESIZE_U32]; } LZ4_streamDecode_t;
+typedef struct
+{
+    const char* dictionary;
+    int dictSize;
+} LZ4_streamDecode_t_internal;
+
+/*
+ * If you prefer dynamic allocation methods,
+ * LZ4_createStreamDecode()
+ * provides a pointer (void*) towards an initialized LZ4_streamDecode_t structure.
+ */
+void* LZ4_createStreamDecode()
+{
+    void* lz4s = ALLOCATOR(sizeof(U32), LZ4_STREAMDECODESIZE_U32);
+    MEM_INIT(lz4s, 0, LZ4_STREAMDECODESIZE);
+    return lz4s;
+}
+
+/*
+ * LZ4_setDictDecode
+ * Use this function to instruct where to find the dictionary
+ * This function is not necessary if previous data is still available where it was decoded.
+ * Loading a size of 0 is allowed (same effect as no dictionary).
+ * Return : 1 if OK, 0 if error
+ */
+int LZ4_setDictDecode (void* LZ4_streamDecode, const char* dictionary, int dictSize)
+{
+    LZ4_streamDecode_t_internal* lz4sd = (LZ4_streamDecode_t_internal*) LZ4_streamDecode;
+    lz4sd->dictionary = dictionary;
+    lz4sd->dictSize = dictSize;
+    return 1;
+}
+
+/*
+*_continue() :
+    These decoding functions allow decompression of multiple blocks in "streaming" mode.
+    Previously decoded blocks must still be available at the memory position where they were decoded.
+    If it's not possible, save the relevant part of decoded data into a safe buffer,
+    and indicate where it stands using LZ4_setDictDecode()
+*/
+int LZ4_decompress_safe_continue (void* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize)
+{
+    LZ4_streamDecode_t_internal* lz4sd = (LZ4_streamDecode_t_internal*) LZ4_streamDecode;
+    int result;
+
+    result = LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, lz4sd->dictionary, lz4sd->dictSize);
+    if (result <= 0) return result;
+    if (lz4sd->dictionary + lz4sd->dictSize == dest)
+    {
+        lz4sd->dictSize += result;
+    }
+    else
+    {
+        lz4sd->dictionary = dest;
+        lz4sd->dictSize = result;
+    }
+
+    return result;
+}
+
+int LZ4_decompress_fast_continue (void* LZ4_streamDecode, const char* source, char* dest, int originalSize)
+{
+    LZ4_streamDecode_t_internal* lz4sd = (LZ4_streamDecode_t_internal*) LZ4_streamDecode;
+    int result;
+
+    result = LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, usingExtDict, lz4sd->dictionary, lz4sd->dictSize);
+    if (result <= 0) return result;
+    if (lz4sd->dictionary + lz4sd->dictSize == dest)
+    {
+        lz4sd->dictSize += result;
+    }
+    else
+    {
+        lz4sd->dictionary = dest;
+        lz4sd->dictSize = result;
+    }
+
+    return result;
+}
+
+
+/*
+Advanced decoding functions :
+*_usingDict() :
+    These decoding functions work the same as "_continue" ones,
+    the dictionary must be explicitly provided within parameters
+*/
+
+int LZ4_decompress_safe_usingDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize)
+{
+    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, dictStart, dictSize);
+}
+
+int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSize, const char* dictStart, int dictSize)
+{
+    return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, usingExtDict, dictStart, dictSize);
+}
diff --git a/src/third_party/mozjs-45/mfbt/lz4.h b/src/third_party/mozjs-45/mfbt/lz4.h
new file mode 100644
index 0000000..bf67801
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/lz4.h
@@ -0,0 +1,276 @@
+/*
+   LZ4 - Fast LZ compression algorithm
+   Header File
+   Copyright (C) 2011-2014, Yann Collet.
+   BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+       * Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+       * Redistributions in binary form must reproduce the above
+   copyright notice, this list of conditions and the following disclaimer
+   in the documentation and/or other materials provided with the
+   distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+   You can contact the author at :
+   - LZ4 source repository : http://code.google.com/p/lz4/
+   - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
+*/
+#pragma once
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/**************************************
+   Version
+**************************************/
+#define LZ4_VERSION_MAJOR    1    /* for major interface/format changes  */
+#define LZ4_VERSION_MINOR    2    /* for minor interface/format changes  */
+#define LZ4_VERSION_RELEASE  0    /* for tweaks, bug-fixes, or development */
+
+
+/**************************************
+   Tuning parameter
+**************************************/
+/*
+ * LZ4_MEMORY_USAGE :
+ * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.)
+ * Increasing memory usage improves compression ratio
+ * Reduced memory usage can improve speed, due to cache effect
+ * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
+ */
+#define LZ4_MEMORY_USAGE 14
+
+
+/**************************************
+   Simple Functions
+**************************************/
+
+int LZ4_compress        (const char* source, char* dest, int inputSize);
+int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxOutputSize);
+
+/*
+LZ4_compress() :
+    Compresses 'inputSize' bytes from 'source' into 'dest'.
+    Destination buffer must be already allocated,
+    and must be sized to handle worst cases situations (input data not compressible)
+    Worst case size evaluation is provided by function LZ4_compressBound()
+    inputSize : Max supported value is LZ4_MAX_INPUT_VALUE
+    return : the number of bytes written in buffer dest
+             or 0 if the compression fails
+
+LZ4_decompress_safe() :
+    compressedSize : is obviously the source size
+    maxOutputSize : is the size of the destination buffer, which must be already allocated.
+    return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
+             If the destination buffer is not large enough, decoding will stop and output an error code (<0).
+             If the source stream is detected malformed, the function will stop decoding and return a negative result.
+             This function is protected against buffer overflow exploits :
+             it never writes outside of output buffer, and never reads outside of input buffer.
+             Therefore, it is protected against malicious data packets.
+*/
+
+
+/*
+Note :
+    Should you prefer to explicitly allocate compression-table memory using your own allocation method,
+    use the streaming functions provided below, simply reset the memory area between each call to LZ4_compress_continue()
+*/
+
+
+/**************************************
+   Advanced Functions
+**************************************/
+#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
+#define LZ4_COMPRESSBOUND(isize)  ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
+
+/*
+LZ4_compressBound() :
+    Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible)
+    primarily useful for memory allocation of output buffer.
+    macro is also provided when result needs to be evaluated at compilation (such as stack memory allocation).
+
+    isize  : is the input size. Max supported value is LZ4_MAX_INPUT_SIZE
+    return : maximum output size in a "worst case" scenario
+             or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE)
+*/
+int LZ4_compressBound(int isize);
+
+
+/*
+LZ4_compress_limitedOutput() :
+    Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
+    If it cannot achieve it, compression will stop, and result of the function will be zero.
+    This function never writes outside of provided output buffer.
+
+    inputSize  : Max supported value is LZ4_MAX_INPUT_VALUE
+    maxOutputSize : is the size of the destination buffer (which must be already allocated)
+    return : the number of bytes written in buffer 'dest'
+             or 0 if the compression fails
+*/
+int LZ4_compress_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
+
+
+/*
+LZ4_decompress_fast() :
+    originalSize : is the original and therefore uncompressed size
+    return : the number of bytes read from the source buffer (in other words, the compressed size)
+             If the source stream is malformed, the function will stop decoding and return a negative result.
+             Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes.
+    note : This function is a bit faster than LZ4_decompress_safe()
+           It provides fast decompression and fully respect memory boundaries for properly formed compressed data.
+           It does not provide full protection against intentionnally modified data stream.
+           Use this function in a trusted environment (data to decode comes from a trusted source).
+*/
+int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
+
+
+/*
+LZ4_decompress_safe_partial() :
+    This function decompress a compressed block of size 'compressedSize' at position 'source'
+    into output buffer 'dest' of size 'maxOutputSize'.
+    The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached,
+    reducing decompression time.
+    return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
+       Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller.
+             Always control how many bytes were decoded.
+             If the source stream is detected malformed, the function will stop decoding and return a negative result.
+             This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
+*/
+int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxOutputSize);
+
+
+/***********************************************
+   Experimental Streaming Compression Functions
+***********************************************/
+
+#define LZ4_STREAMSIZE_U32 ((1 << (LZ4_MEMORY_USAGE-2)) + 8)
+#define LZ4_STREAMSIZE     (LZ4_STREAMSIZE_U32 * sizeof(unsigned int))
+/*
+ * LZ4_stream_t
+ * information structure to track an LZ4 stream.
+ * important : set this structure content to zero before first use !
+ */
+typedef struct { unsigned int table[LZ4_STREAMSIZE_U32]; } LZ4_stream_t;
+
+/*
+ * If you prefer dynamic allocation methods,
+ * LZ4_createStream
+ * provides a pointer (void*) towards an initialized LZ4_stream_t structure.
+ * LZ4_free just frees it.
+ */
+void* LZ4_createStream();
+int   LZ4_free (void* LZ4_stream);
+
+
+/*
+ * LZ4_loadDict
+ * Use this function to load a static dictionary into LZ4_stream.
+ * Any previous data will be forgotten, only 'dictionary' will remain in memory.
+ * Loading a size of 0 is allowed (same effect as init).
+ * Return : 1 if OK, 0 if error
+ */
+int LZ4_loadDict (void* LZ4_stream, const char* dictionary, int dictSize);
+
+/*
+ * LZ4_compress_continue
+ * Compress data block 'source', using blocks compressed before as dictionary to improve compression ratio
+ * Previous data blocks are assumed to still be present at their previous location.
+ */
+int LZ4_compress_continue (void* LZ4_stream, const char* source, char* dest, int inputSize);
+
+/*
+ * LZ4_compress_limitedOutput_continue
+ * Same as before, but also specify a maximum target compressed size (maxOutputSize)
+ * If objective cannot be met, compression exits, and returns a zero.
+ */
+int LZ4_compress_limitedOutput_continue (void* LZ4_stream, const char* source, char* dest, int inputSize, int maxOutputSize);
+
+/*
+ * LZ4_saveDict
+ * If previously compressed data block is not guaranteed to remain at its previous memory location
+ * save it into a safe place (char* safeBuffer)
+ * Note : you don't need to call LZ4_loadDict() afterwards,
+ *        dictionary is immediately usable, you can therefore call again LZ4_compress_continue()
+ * Return : 1 if OK, 0 if error
+ * Note : any dictSize > 64 KB will be interpreted as 64KB.
+ */
+int LZ4_saveDict (void* LZ4_stream, char* safeBuffer, int dictSize);
+
+
+/************************************************
+  Experimental Streaming Decompression Functions
+************************************************/
+
+#define LZ4_STREAMDECODESIZE_U32 4
+#define LZ4_STREAMDECODESIZE     (LZ4_STREAMDECODESIZE_U32 * sizeof(unsigned int))
+/*
+ * LZ4_streamDecode_t
+ * information structure to track an LZ4 stream.
+ * important : set this structure content to zero before first use !
+ */
+typedef struct { unsigned int table[LZ4_STREAMDECODESIZE_U32]; } LZ4_streamDecode_t;
+
+/*
+ * If you prefer dynamic allocation methods,
+ * LZ4_createStreamDecode()
+ * provides a pointer (void*) towards an initialized LZ4_streamDecode_t structure.
+ * LZ4_free just frees it.
+ */
+void* LZ4_createStreamDecode();
+int   LZ4_free (void* LZ4_stream);   /* yes, it's the same one as for compression */
+
+/*
+*_continue() :
+    These decoding functions allow decompression of multiple blocks in "streaming" mode.
+    Previously decoded blocks must still be available at the memory position where they were decoded.
+    If it's not possible, save the relevant part of decoded data into a safe buffer,
+    and indicate where it stands using LZ4_setDictDecode()
+*/
+int LZ4_decompress_safe_continue (void* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize);
+int LZ4_decompress_fast_continue (void* LZ4_streamDecode, const char* source, char* dest, int originalSize);
+
+/*
+ * LZ4_setDictDecode
+ * Use this function to instruct where to find the dictionary.
+ * This function can be used to specify a static dictionary,
+ * or to instruct where to find some previously decoded data saved into a different memory space.
+ * Setting a size of 0 is allowed (same effect as no dictionary).
+ * Return : 1 if OK, 0 if error
+ */
+int LZ4_setDictDecode (void* LZ4_streamDecode, const char* dictionary, int dictSize);
+
+
+/*
+Advanced decoding functions :
+*_usingDict() :
+    These decoding functions work the same as
+    a combination of LZ4_setDictDecode() followed by LZ4_decompress_x_continue()
+    all together into a single function call.
+    It doesn't use nor update an LZ4_streamDecode_t structure.
+*/
+int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize);
+int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);
+
+
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/src/third_party/mozjs-45/mfbt/moz.build b/src/third_party/mozjs-45/mfbt/moz.build
new file mode 100644
index 0000000..a071040
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/moz.build
@@ -0,0 +1,130 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+TEST_DIRS += ['tests']
+
+# On win we build two mfbt libs - mfbt linked to crt dlls here and in
+# staticruntime we build a statically linked mfbt lib.
+if CONFIG['OS_ARCH'] == 'WINNT':
+    DIRS += ['staticruntime']
+
+Library('mfbt')
+
+EXPORTS.mozilla = [
+    'Alignment.h',
+    'AllocPolicy.h',
+    'AlreadyAddRefed.h',
+    'Array.h',
+    'ArrayUtils.h',
+    'Assertions.h',
+    'Atomics.h',
+    'Attributes.h',
+    'BinarySearch.h',
+    'BloomFilter.h',
+    'Casting.h',
+    'ChaosMode.h',
+    'Char16.h',
+    'CheckedInt.h',
+    'Compiler.h',
+    'Compression.h',
+    'DebugOnly.h',
+    'decimal/Decimal.h',
+    'double-conversion/double-conversion.h',
+    'double-conversion/utils.h',
+    'Endian.h',
+    'EnumeratedArray.h',
+    'EnumeratedRange.h',
+    'EnumSet.h',
+    'FastBernoulliTrial.h',
+    'FloatingPoint.h',
+    'Function.h',
+    'GuardObjects.h',
+    'HashFunctions.h',
+    'IndexSequence.h',
+    'IntegerPrintfMacros.h',
+    'IntegerRange.h',
+    'IntegerTypeTraits.h',
+    'JSONWriter.h',
+    'Likely.h',
+    'LinkedList.h',
+    'MacroArgs.h',
+    'MacroForEach.h',
+    'MathAlgorithms.h',
+    'Maybe.h',
+    'MaybeOneOf.h',
+    'MemoryChecking.h',
+    'MemoryReporting.h',
+    'Move.h',
+    'NullPtr.h',
+    'NumericLimits.h',
+    'Opaque.h',
+    'Pair.h',
+    'PodOperations.h',
+    'Poison.h',
+    'Range.h',
+    'RangedArray.h',
+    'RangedPtr.h',
+    'ReentrancyGuard.h',
+    'RefCounted.h',
+    'RefCountType.h',
+    'RefPtr.h',
+    'ReverseIterator.h',
+    'RollingMean.h',
+    'Scoped.h',
+    'ScopeExit.h',
+    'SegmentedVector.h',
+    'SHA1.h',
+    'SizePrintfMacros.h',
+    'Snprintf.h',
+    'SplayTree.h',
+    'TaggedAnonymousMemory.h',
+    'TemplateLib.h',
+    'ThreadLocal.h',
+    'ToString.h',
+    'Tuple.h',
+    'TypedEnumBits.h',
+    'Types.h',
+    'TypeTraits.h',
+    'UniquePtr.h',
+    'UniquePtrExtensions.h',
+    'unused.h',
+    'Variant.h',
+    'Vector.h',
+    'WeakPtr.h',
+    'XorShift128PlusRNG.h',
+]
+
+if CONFIG['OS_ARCH'] == 'WINNT':
+    EXPORTS.mozilla += [
+        'WindowsVersion.h',
+    ]
+elif CONFIG['OS_ARCH'] == 'Linux':
+    EXPORTS.mozilla += [
+        'LinuxSignal.h',
+    ]
+
+include('objs.mozbuild')
+
+UNIFIED_SOURCES += mfbt_src_cppsrcs
+
+DEFINES['IMPL_MFBT'] = True
+
+SOURCES += mfbt_nonunified_src_cppsrcs
+
+DISABLE_STL_WRAPPING = True
+
+# Suppress warnings in third-party LZ4 code.
+# TODO: Remove these suppressions after bug 993267 is fixed.
+
+if CONFIG['GNU_CXX']:
+    SOURCES['/mfbt/Compression.cpp'].flags += ['-Wno-unused-function']
+
+if CONFIG['_MSC_VER']:
+    # Error 4804 is "'>' : unsafe use of type 'bool' in operation"
+    SOURCES['/mfbt/Compression.cpp'].flags += ['-wd4804']
+
+if CONFIG['MOZ_NEEDS_LIBATOMIC']:
+    OS_LIBS += ['atomic']
diff --git a/src/third_party/mozjs-45/mfbt/objs.mozbuild b/src/third_party/mozjs-45/mfbt/objs.mozbuild
new file mode 100644
index 0000000..444851a
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/objs.mozbuild
@@ -0,0 +1,39 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+mfbt_src_lcppsrcs = [
+    'ChaosMode.cpp',
+    'double-conversion/bignum-dtoa.cc',
+    'double-conversion/bignum.cc',
+    'double-conversion/cached-powers.cc',
+    'double-conversion/diy-fp.cc',
+    'double-conversion/double-conversion.cc',
+    'double-conversion/fast-dtoa.cc',
+    'double-conversion/fixed-dtoa.cc',
+    'double-conversion/strtod.cc',
+    'FloatingPoint.cpp',
+    'HashFunctions.cpp',
+    'JSONWriter.cpp',
+    'Poison.cpp',
+    'SHA1.cpp',
+    'TaggedAnonymousMemory.cpp',
+    'unused.cpp',
+]
+
+mfbt_src_cppsrcs = [
+    '/mfbt/%s' % s for s in mfbt_src_lcppsrcs
+]
+
+# Compression.cpp cannot be built in unified mode because it pulls in Windows system headers.
+# Decimal.cpp doesn't build in unified mode with gcc.
+mfbt_nonunified_src_lcppsrcs = [
+    'Compression.cpp',
+    'decimal/Decimal.cpp',
+]
+
+mfbt_nonunified_src_cppsrcs = [
+    '/mfbt/%s' % s for s in mfbt_nonunified_src_lcppsrcs
+]
diff --git a/src/third_party/mozjs-45/mfbt/staticruntime/moz.build b/src/third_party/mozjs-45/mfbt/staticruntime/moz.build
new file mode 100644
index 0000000..f325e13
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/staticruntime/moz.build
@@ -0,0 +1,29 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+Library('mfbt_staticruntime')
+
+include('../objs.mozbuild')
+
+UNIFIED_SOURCES += mfbt_src_cppsrcs
+
+DEFINES['IMPL_MFBT'] = True
+
+SOURCES += mfbt_nonunified_src_cppsrcs
+
+USE_STATIC_LIBS = True
+
+DISABLE_STL_WRAPPING = True
+
+# Suppress warnings in third-party LZ4 code.
+# TODO: Remove these suppressions after bug 993267 is fixed.
+
+if CONFIG['GNU_CXX']:
+    SOURCES['/mfbt/Compression.cpp'].flags += ['-Wno-unused-function']
+
+if CONFIG['_MSC_VER']:
+    # Error 4804 is "'>' : unsafe use of type 'bool' in operation"
+    SOURCES['/mfbt/Compression.cpp'].flags += ['-wd4804']
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestArrayUtils.cpp b/src/third_party/mozjs-45/mfbt/tests/TestArrayUtils.cpp
new file mode 100644
index 0000000..6566a3c
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestArrayUtils.cpp
@@ -0,0 +1,313 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/ArrayUtils.h"
+#include "mozilla/Assertions.h"
+
+using mozilla::IsInRange;
+
+static void
+TestIsInRangeNonClass()
+{
+  void* nul = nullptr;
+  int* intBegin = nullptr;
+  int* intEnd = intBegin + 1;
+  int* intEnd2 = intBegin + 2;
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, intBegin, intEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, intEnd, intEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(intBegin, intBegin, intEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(intEnd, intBegin, intEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(intBegin, intBegin, intEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(intEnd, intBegin, intEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(intEnd2, intBegin, intEnd2));
+
+  uintptr_t uintBegin = uintptr_t(intBegin);
+  uintptr_t uintEnd = uintptr_t(intEnd);
+  uintptr_t uintEnd2 = uintptr_t(intEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, uintBegin, uintEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, uintEnd, uintEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(intBegin, uintBegin, uintEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(intEnd, uintBegin, uintEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(intBegin, uintBegin, uintEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(intEnd, uintBegin, uintEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(intEnd2, uintBegin, uintEnd2));
+}
+
+static void
+TestIsInRangeVoid()
+{
+  int* intBegin = nullptr;
+  int* intEnd = intBegin + 1;
+  int* intEnd2 = intBegin + 2;
+
+  void* voidBegin = intBegin;
+  void* voidEnd = intEnd;
+  void* voidEnd2 = intEnd2;
+
+  MOZ_RELEASE_ASSERT(IsInRange(voidBegin, intBegin, intEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(voidEnd, intBegin, intEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(voidBegin, voidBegin, voidEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(voidEnd, voidBegin, voidEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(voidBegin, intBegin, intEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(voidEnd, intBegin, intEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(voidEnd2, intBegin, intEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(voidBegin, voidBegin, voidEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(voidEnd, voidBegin, voidEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(voidEnd2, voidBegin, voidEnd2));
+
+  uintptr_t uintBegin = uintptr_t(intBegin);
+  uintptr_t uintEnd = uintptr_t(intEnd);
+  uintptr_t uintEnd2 = uintptr_t(intEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(voidBegin, uintBegin, uintEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(voidEnd, uintBegin, uintEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(voidBegin, uintBegin, uintEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(voidEnd, uintBegin, uintEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(voidEnd2, uintBegin, uintEnd2));
+}
+
+struct Base { int mX; };
+
+static void
+TestIsInRangeClass()
+{
+  void* nul = nullptr;
+  Base* baseBegin = nullptr;
+  Base* baseEnd = baseBegin + 1;
+  Base* baseEnd2 = baseBegin + 2;
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, baseBegin, baseEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, baseEnd, baseEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, baseBegin, baseEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd, baseBegin, baseEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, baseBegin, baseEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(baseEnd, baseBegin, baseEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd2, baseBegin, baseEnd2));
+
+  uintptr_t ubaseBegin = uintptr_t(baseBegin);
+  uintptr_t ubaseEnd = uintptr_t(baseEnd);
+  uintptr_t ubaseEnd2 = uintptr_t(baseEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, ubaseBegin, ubaseEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, ubaseEnd, ubaseEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, ubaseBegin, ubaseEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd, ubaseBegin, ubaseEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, ubaseBegin, ubaseEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(baseEnd, ubaseBegin, ubaseEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd2, ubaseBegin, ubaseEnd2));
+}
+
+struct EmptyBase {};
+
+static void
+TestIsInRangeEmptyClass()
+{
+  void* nul = nullptr;
+  EmptyBase* baseBegin = nullptr;
+  EmptyBase* baseEnd = baseBegin + 1;
+  EmptyBase* baseEnd2 = baseBegin + 2;
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, baseBegin, baseEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, baseEnd, baseEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, baseBegin, baseEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd, baseBegin, baseEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, baseBegin, baseEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(baseEnd, baseBegin, baseEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd2, baseBegin, baseEnd2));
+
+  uintptr_t ubaseBegin = uintptr_t(baseBegin);
+  uintptr_t ubaseEnd = uintptr_t(baseEnd);
+  uintptr_t ubaseEnd2 = uintptr_t(baseEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, ubaseBegin, ubaseEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, ubaseEnd, ubaseEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, ubaseBegin, ubaseEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd, ubaseBegin, ubaseEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, ubaseBegin, ubaseEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(baseEnd, ubaseBegin, ubaseEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd2, ubaseBegin, ubaseEnd2));
+}
+
+struct Derived : Base {};
+
+static void
+TestIsInRangeClassDerived()
+{
+  void* nul = nullptr;
+  Derived* derivedBegin = nullptr;
+  Derived* derivedEnd = derivedBegin + 1;
+  Derived* derivedEnd2 = derivedBegin + 2;
+
+  Base* baseBegin = static_cast<Base*>(derivedBegin);
+  Base* baseEnd = static_cast<Base*>(derivedEnd);
+  Base* baseEnd2 = static_cast<Base*>(derivedEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, derivedBegin, derivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, derivedEnd, derivedEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, derivedBegin, derivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd, derivedBegin, derivedEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, derivedBegin, derivedEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(baseEnd, derivedBegin, derivedEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd2, derivedBegin, derivedEnd2));
+
+  uintptr_t uderivedBegin = uintptr_t(derivedBegin);
+  uintptr_t uderivedEnd = uintptr_t(derivedEnd);
+  uintptr_t uderivedEnd2 = uintptr_t(derivedEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(derivedBegin, uderivedBegin, uderivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(derivedEnd, uderivedBegin, uderivedEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(derivedBegin, uderivedBegin, uderivedEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(derivedEnd, uderivedBegin, uderivedEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(derivedEnd2, uderivedBegin, uderivedEnd2));
+}
+
+struct DerivedEmpty : EmptyBase {};
+
+static void
+TestIsInRangeClassDerivedEmpty()
+{
+  void* nul = nullptr;
+  DerivedEmpty* derivedEmptyBegin = nullptr;
+  DerivedEmpty* derivedEmptyEnd = derivedEmptyBegin + 1;
+  DerivedEmpty* derivedEmptyEnd2 = derivedEmptyBegin + 2;
+
+  EmptyBase* baseBegin = static_cast<EmptyBase*>(derivedEmptyBegin);
+  EmptyBase* baseEnd = static_cast<EmptyBase*>(derivedEmptyEnd);
+  EmptyBase* baseEnd2 = static_cast<EmptyBase*>(derivedEmptyEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, derivedEmptyBegin, derivedEmptyEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, derivedEmptyEnd, derivedEmptyEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, derivedEmptyBegin, derivedEmptyEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd, derivedEmptyBegin, derivedEmptyEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, derivedEmptyBegin, derivedEmptyEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(baseEnd, derivedEmptyBegin, derivedEmptyEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd2, derivedEmptyBegin, derivedEmptyEnd2));
+
+  uintptr_t uderivedEmptyBegin = uintptr_t(derivedEmptyBegin);
+  uintptr_t uderivedEmptyEnd = uintptr_t(derivedEmptyEnd);
+  uintptr_t uderivedEmptyEnd2 = uintptr_t(derivedEmptyEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(derivedEmptyBegin, uderivedEmptyBegin,
+                               uderivedEmptyEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(derivedEmptyEnd, uderivedEmptyBegin,
+                                uderivedEmptyEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(derivedEmptyBegin, uderivedEmptyBegin,
+                               uderivedEmptyEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(derivedEmptyEnd, uderivedEmptyBegin,
+                               uderivedEmptyEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(derivedEmptyEnd2, uderivedEmptyBegin,
+                                uderivedEmptyEnd2));
+}
+
+struct ExtraDerived : Base { int y; };
+
+static void
+TestIsInRangeClassExtraDerived()
+{
+  void* nul = nullptr;
+  ExtraDerived* derivedBegin = nullptr;
+  ExtraDerived* derivedEnd = derivedBegin + 1;
+  ExtraDerived* derivedEnd2 = derivedBegin + 2;
+
+  Base* baseBegin = static_cast<Base*>(derivedBegin);
+  Base* baseEnd = static_cast<Base*>(derivedEnd);
+  Base* baseEnd2 = static_cast<Base*>(derivedEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, derivedBegin, derivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, derivedEnd, derivedEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, derivedBegin, derivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd, derivedBegin, derivedEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, derivedBegin, derivedEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(baseEnd, derivedBegin, derivedEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd2, derivedBegin, derivedEnd2));
+
+  uintptr_t uderivedBegin = uintptr_t(derivedBegin);
+  uintptr_t uderivedEnd = uintptr_t(derivedEnd);
+  uintptr_t uderivedEnd2 = uintptr_t(derivedEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(derivedBegin, uderivedBegin, uderivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(derivedEnd, uderivedBegin, uderivedEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(derivedBegin, uderivedBegin, uderivedEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(derivedEnd, uderivedBegin, uderivedEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(derivedEnd2, uderivedBegin, uderivedEnd2));
+}
+
+struct ExtraDerivedEmpty : EmptyBase { int y; };
+
+static void
+TestIsInRangeClassExtraDerivedEmpty()
+{
+  void* nul = nullptr;
+  ExtraDerivedEmpty* derivedBegin = nullptr;
+  ExtraDerivedEmpty* derivedEnd = derivedBegin + 1;
+  ExtraDerivedEmpty* derivedEnd2 = derivedBegin + 2;
+
+  EmptyBase* baseBegin = static_cast<EmptyBase*>(derivedBegin);
+  EmptyBase* baseEnd = static_cast<EmptyBase*>(derivedEnd);
+  EmptyBase* baseEnd2 = static_cast<EmptyBase*>(derivedEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(nul, derivedBegin, derivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(nul, derivedEnd, derivedEnd2));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, derivedBegin, derivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd, derivedBegin, derivedEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(baseBegin, derivedBegin, derivedEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(baseEnd, derivedBegin, derivedEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(baseEnd2, derivedBegin, derivedEnd2));
+
+  uintptr_t uderivedBegin = uintptr_t(derivedBegin);
+  uintptr_t uderivedEnd = uintptr_t(derivedEnd);
+  uintptr_t uderivedEnd2 = uintptr_t(derivedEnd2);
+
+  MOZ_RELEASE_ASSERT(IsInRange(derivedBegin, uderivedBegin, uderivedEnd));
+  MOZ_RELEASE_ASSERT(!IsInRange(derivedEnd, uderivedBegin, uderivedEnd));
+
+  MOZ_RELEASE_ASSERT(IsInRange(derivedBegin, uderivedBegin, uderivedEnd2));
+  MOZ_RELEASE_ASSERT(IsInRange(derivedEnd, uderivedBegin, uderivedEnd2));
+  MOZ_RELEASE_ASSERT(!IsInRange(derivedEnd2, uderivedBegin, uderivedEnd2));
+}
+
+int
+main()
+{
+  TestIsInRangeNonClass();
+  TestIsInRangeVoid();
+  TestIsInRangeClass();
+  TestIsInRangeEmptyClass();
+  TestIsInRangeClassDerived();
+  TestIsInRangeClassDerivedEmpty();
+  TestIsInRangeClassExtraDerived();
+  TestIsInRangeClassExtraDerivedEmpty();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestAtomics.cpp b/src/third_party/mozjs-45/mfbt/tests/TestAtomics.cpp
new file mode 100644
index 0000000..e23b3d5
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestAtomics.cpp
@@ -0,0 +1,295 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Atomics.h"
+
+#include <stdint.h>
+
+using mozilla::Atomic;
+using mozilla::MemoryOrdering;
+using mozilla::Relaxed;
+using mozilla::ReleaseAcquire;
+using mozilla::SequentiallyConsistent;
+
+#define A(a,b)  MOZ_RELEASE_ASSERT(a,b)
+
+template <typename T, MemoryOrdering Order>
+static void
+TestTypeWithOrdering()
+{
+  Atomic<T, Order> atomic(5);
+  A(atomic == 5, "Atomic variable did not initialize");
+
+  // Test atomic increment
+  A(++atomic == T(6), "Atomic increment did not work");
+  A(atomic++ == T(6), "Atomic post-increment did not work");
+  A(atomic == T(7), "Atomic post-increment did not work");
+
+  // Test atomic decrement
+  A(--atomic == 6, "Atomic decrement did not work");
+  A(atomic-- == 6, "Atomic post-decrement did not work");
+  A(atomic == 5, "Atomic post-decrement did not work");
+
+  // Test other arithmetic.
+  T result;
+  result = (atomic += T(5));
+  A(atomic == T(10), "Atomic += did not work");
+  A(result == T(10), "Atomic += returned the wrong value");
+  result = (atomic -= T(3));
+  A(atomic == T(7), "Atomic -= did not work");
+  A(result == T(7), "Atomic -= returned the wrong value");
+
+  // Test assignment
+  result = (atomic = T(5));
+  A(atomic == T(5), "Atomic assignment failed");
+  A(result == T(5), "Atomic assignment returned the wrong value");
+
+  // Test logical operations.
+  result = (atomic ^= T(2));
+  A(atomic == T(7), "Atomic ^= did not work");
+  A(result == T(7), "Atomic ^= returned the wrong value");
+  result = (atomic ^= T(4));
+  A(atomic == T(3), "Atomic ^= did not work");
+  A(result == T(3), "Atomic ^= returned the wrong value");
+  result = (atomic |= T(8));
+  A(atomic == T(11), "Atomic |= did not work");
+  A(result == T(11), "Atomic |= returned the wrong value");
+  result = (atomic |= T(8));
+  A(atomic == T(11), "Atomic |= did not work");
+  A(result == T(11), "Atomic |= returned the wrong value");
+  result = (atomic &= T(12));
+  A(atomic == T(8), "Atomic &= did not work");
+  A(result == T(8), "Atomic &= returned the wrong value");
+
+  // Test exchange.
+  atomic = T(30);
+  result = atomic.exchange(42);
+  A(atomic == T(42), "Atomic exchange did not work");
+  A(result == T(30), "Atomic exchange returned the wrong value");
+
+  // Test CAS.
+  atomic = T(1);
+  bool boolResult = atomic.compareExchange(0, 2);
+  A(!boolResult, "CAS should have returned false.");
+  A(atomic == T(1), "CAS shouldn't have done anything.");
+
+  boolResult = atomic.compareExchange(1, 42);
+  A(boolResult, "CAS should have succeeded.");
+  A(atomic == T(42), "CAS should have changed atomic's value.");
+}
+
+template<typename T, MemoryOrdering Order>
+static void
+TestPointerWithOrdering()
+{
+  T array1[10];
+  Atomic<T*, Order> atomic(array1);
+  A(atomic == array1, "Atomic variable did not initialize");
+
+  // Test atomic increment
+  A(++atomic == array1 + 1, "Atomic increment did not work");
+  A(atomic++ == array1 + 1, "Atomic post-increment did not work");
+  A(atomic == array1 + 2, "Atomic post-increment did not work");
+
+  // Test atomic decrement
+  A(--atomic == array1 + 1, "Atomic decrement did not work");
+  A(atomic-- == array1 + 1, "Atomic post-decrement did not work");
+  A(atomic == array1, "Atomic post-decrement did not work");
+
+  // Test other arithmetic operations
+  T* result;
+  result = (atomic += 2);
+  A(atomic == array1 + 2, "Atomic += did not work");
+  A(result == array1 + 2, "Atomic += returned the wrong value");
+  result = (atomic -= 1);
+  A(atomic == array1 + 1, "Atomic -= did not work");
+  A(result == array1 + 1, "Atomic -= returned the wrong value");
+
+  // Test stores
+  result = (atomic = array1);
+  A(atomic == array1, "Atomic assignment did not work");
+  A(result == array1, "Atomic assignment returned the wrong value");
+
+  // Test exchange
+  atomic = array1 + 2;
+  result = atomic.exchange(array1);
+  A(atomic == array1, "Atomic exchange did not work");
+  A(result == array1 + 2, "Atomic exchange returned the wrong value");
+
+  atomic = array1;
+  bool boolResult = atomic.compareExchange(array1 + 1, array1 + 2);
+  A(!boolResult, "CAS should have returned false.");
+  A(atomic == array1, "CAS shouldn't have done anything.");
+
+  boolResult = atomic.compareExchange(array1, array1 + 3);
+  A(boolResult, "CAS should have succeeded.");
+  A(atomic == array1 + 3, "CAS should have changed atomic's value.");
+}
+
+enum EnumType
+{
+  EnumType_0 = 0,
+  EnumType_1 = 1,
+  EnumType_2 = 2,
+  EnumType_3 = 3
+};
+
+template<MemoryOrdering Order>
+static void
+TestEnumWithOrdering()
+{
+  Atomic<EnumType, Order> atomic(EnumType_2);
+  A(atomic == EnumType_2, "Atomic variable did not initialize");
+
+  // Test assignment
+  EnumType result;
+  result = (atomic = EnumType_3);
+  A(atomic == EnumType_3, "Atomic assignment failed");
+  A(result == EnumType_3, "Atomic assignment returned the wrong value");
+
+  // Test exchange.
+  atomic = EnumType_1;
+  result = atomic.exchange(EnumType_2);
+  A(atomic == EnumType_2, "Atomic exchange did not work");
+  A(result == EnumType_1, "Atomic exchange returned the wrong value");
+
+  // Test CAS.
+  atomic = EnumType_1;
+  bool boolResult = atomic.compareExchange(EnumType_0, EnumType_2);
+  A(!boolResult, "CAS should have returned false.");
+  A(atomic == EnumType_1, "CAS shouldn't have done anything.");
+
+  boolResult = atomic.compareExchange(EnumType_1, EnumType_3);
+  A(boolResult, "CAS should have succeeded.");
+  A(atomic == EnumType_3, "CAS should have changed atomic's value.");
+}
+
+enum class EnumClass : uint32_t
+{
+  Value0 = 0,
+  Value1 = 1,
+  Value2 = 2,
+  Value3 = 3
+};
+
+template<MemoryOrdering Order>
+static void
+TestEnumClassWithOrdering()
+{
+  Atomic<EnumClass, Order> atomic(EnumClass::Value2);
+  A(atomic == EnumClass::Value2, "Atomic variable did not initialize");
+
+  // Test assignment
+  EnumClass result;
+  result = (atomic = EnumClass::Value3);
+  A(atomic == EnumClass::Value3, "Atomic assignment failed");
+  A(result == EnumClass::Value3, "Atomic assignment returned the wrong value");
+
+  // Test exchange.
+  atomic = EnumClass::Value1;
+  result = atomic.exchange(EnumClass::Value2);
+  A(atomic == EnumClass::Value2, "Atomic exchange did not work");
+  A(result == EnumClass::Value1, "Atomic exchange returned the wrong value");
+
+  // Test CAS.
+  atomic = EnumClass::Value1;
+  bool boolResult = atomic.compareExchange(EnumClass::Value0, EnumClass::Value2);
+  A(!boolResult, "CAS should have returned false.");
+  A(atomic == EnumClass::Value1, "CAS shouldn't have done anything.");
+
+  boolResult = atomic.compareExchange(EnumClass::Value1, EnumClass::Value3);
+  A(boolResult, "CAS should have succeeded.");
+  A(atomic == EnumClass::Value3, "CAS should have changed atomic's value.");
+}
+
+template <MemoryOrdering Order>
+static void
+TestBoolWithOrdering()
+{
+  Atomic<bool, Order> atomic(false);
+  A(atomic == false, "Atomic variable did not initialize");
+
+  // Test assignment
+  bool result;
+  result = (atomic = true);
+  A(atomic == true, "Atomic assignment failed");
+  A(result == true, "Atomic assignment returned the wrong value");
+
+  // Test exchange.
+  atomic = false;
+  result = atomic.exchange(true);
+  A(atomic == true, "Atomic exchange did not work");
+  A(result == false, "Atomic exchange returned the wrong value");
+
+  // Test CAS.
+  atomic = false;
+  bool boolResult = atomic.compareExchange(true, false);
+  A(!boolResult, "CAS should have returned false.");
+  A(atomic == false, "CAS shouldn't have done anything.");
+
+  boolResult = atomic.compareExchange(false, true);
+  A(boolResult, "CAS should have succeeded.");
+  A(atomic == true, "CAS should have changed atomic's value.");
+}
+
+template <typename T>
+static void
+TestType()
+{
+  TestTypeWithOrdering<T, SequentiallyConsistent>();
+  TestTypeWithOrdering<T, ReleaseAcquire>();
+  TestTypeWithOrdering<T, Relaxed>();
+}
+
+template<typename T>
+static void
+TestPointer()
+{
+  TestPointerWithOrdering<T, SequentiallyConsistent>();
+  TestPointerWithOrdering<T, ReleaseAcquire>();
+  TestPointerWithOrdering<T, Relaxed>();
+}
+
+static void
+TestEnum()
+{
+  TestEnumWithOrdering<SequentiallyConsistent>();
+  TestEnumWithOrdering<ReleaseAcquire>();
+  TestEnumWithOrdering<Relaxed>();
+
+  TestEnumClassWithOrdering<SequentiallyConsistent>();
+  TestEnumClassWithOrdering<ReleaseAcquire>();
+  TestEnumClassWithOrdering<Relaxed>();
+}
+
+static void
+TestBool()
+{
+  TestBoolWithOrdering<SequentiallyConsistent>();
+  TestBoolWithOrdering<ReleaseAcquire>();
+  TestBoolWithOrdering<Relaxed>();
+}
+
+#undef A
+
+int
+main()
+{
+  TestType<uint32_t>();
+  TestType<int32_t>();
+  TestType<uint64_t>();
+  TestType<int64_t>();
+  TestType<intptr_t>();
+  TestType<uintptr_t>();
+  TestPointer<int>();
+  TestPointer<float>();
+  TestPointer<uint16_t*>();
+  TestPointer<uint32_t*>();
+  TestEnum();
+  TestBool();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestBinarySearch.cpp b/src/third_party/mozjs-45/mfbt/tests/TestBinarySearch.cpp
new file mode 100644
index 0000000..334eb21
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestBinarySearch.cpp
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/BinarySearch.h"
+#include "mozilla/Vector.h"
+
+using mozilla::ArrayLength;
+using mozilla::BinarySearch;
+using mozilla::BinarySearchIf;
+using mozilla::Vector;
+
+#define A(a) MOZ_RELEASE_ASSERT(a)
+
+struct Person
+{
+  int mAge;
+  int mId;
+  Person(int aAge, int aId) : mAge(aAge), mId(aId) {}
+};
+
+struct GetAge
+{
+  Vector<Person>& mV;
+  explicit GetAge(Vector<Person>& aV) : mV(aV) {}
+  int operator[](size_t index) const { return mV[index].mAge; }
+};
+
+struct RangeFinder {
+  const int mLower, mUpper;
+  RangeFinder(int lower, int upper) : mLower(lower), mUpper(upper) {}
+  int operator()(int val) const {
+    if (val >= mUpper) return -1;
+    if (val < mLower) return 1;
+    return 0;
+  }
+};
+
+static void
+TestBinarySearch()
+{
+  size_t m;
+
+  Vector<int> v1;
+  v1.append(2);
+  v1.append(4);
+  v1.append(6);
+  v1.append(8);
+
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 0, v1.length(), 1, &m) && m == 0);
+  MOZ_RELEASE_ASSERT( BinarySearch(v1, 0, v1.length(), 2, &m) && m == 0);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 0, v1.length(), 3, &m) && m == 1);
+  MOZ_RELEASE_ASSERT( BinarySearch(v1, 0, v1.length(), 4, &m) && m == 1);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 0, v1.length(), 5, &m) && m == 2);
+  MOZ_RELEASE_ASSERT( BinarySearch(v1, 0, v1.length(), 6, &m) && m == 2);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 0, v1.length(), 7, &m) && m == 3);
+  MOZ_RELEASE_ASSERT( BinarySearch(v1, 0, v1.length(), 8, &m) && m == 3);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 0, v1.length(), 9, &m) && m == 4);
+
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 1, 3, 1, &m) && m == 1);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 1, 3, 2, &m) && m == 1);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 1, 3, 3, &m) && m == 1);
+  MOZ_RELEASE_ASSERT( BinarySearch(v1, 1, 3, 4, &m) && m == 1);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 1, 3, 5, &m) && m == 2);
+  MOZ_RELEASE_ASSERT( BinarySearch(v1, 1, 3, 6, &m) && m == 2);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 1, 3, 7, &m) && m == 3);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 1, 3, 8, &m) && m == 3);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 1, 3, 9, &m) && m == 3);
+
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 0, 0, 0, &m) && m == 0);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v1, 0, 0, 9, &m) && m == 0);
+
+  Vector<int> v2;
+  MOZ_RELEASE_ASSERT(!BinarySearch(v2, 0, 0, 0, &m) && m == 0);
+  MOZ_RELEASE_ASSERT(!BinarySearch(v2, 0, 0, 9, &m) && m == 0);
+
+  Vector<Person> v3;
+  v3.append(Person(2, 42));
+  v3.append(Person(4, 13));
+  v3.append(Person(6, 360));
+
+  A(!BinarySearch(GetAge(v3), 0, v3.length(), 1, &m) && m == 0);
+  A( BinarySearch(GetAge(v3), 0, v3.length(), 2, &m) && m == 0);
+  A(!BinarySearch(GetAge(v3), 0, v3.length(), 3, &m) && m == 1);
+  A( BinarySearch(GetAge(v3), 0, v3.length(), 4, &m) && m == 1);
+  A(!BinarySearch(GetAge(v3), 0, v3.length(), 5, &m) && m == 2);
+  A( BinarySearch(GetAge(v3), 0, v3.length(), 6, &m) && m == 2);
+  A(!BinarySearch(GetAge(v3), 0, v3.length(), 7, &m) && m == 3);
+}
+
+static void
+TestBinarySearchIf()
+{
+  const int v1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+  const size_t len = ArrayLength(v1);
+  size_t m;
+
+  A( BinarySearchIf(v1, 0, len, RangeFinder( 2,  3), &m) && m == 2);
+  A(!BinarySearchIf(v1, 0, len, RangeFinder(-5, -2), &m) && m == 0);
+  A( BinarySearchIf(v1, 0, len, RangeFinder( 3,  5), &m) && m >= 3 && m < 5);
+  A(!BinarySearchIf(v1, 0, len, RangeFinder(10, 12), &m) && m == 10);
+}
+
+int
+main()
+{
+  TestBinarySearch();
+  TestBinarySearchIf();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestBloomFilter.cpp b/src/third_party/mozjs-45/mfbt/tests/TestBloomFilter.cpp
new file mode 100644
index 0000000..42e8b82
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestBloomFilter.cpp
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/BloomFilter.h"
+
+#include <stddef.h>
+#include <stdio.h>
+
+using mozilla::BloomFilter;
+
+class FilterChecker
+{
+public:
+  explicit FilterChecker(uint32_t aHash) : mHash(aHash) { }
+
+  uint32_t hash() const { return mHash; }
+
+private:
+  uint32_t mHash;
+};
+
+int
+main()
+{
+  BloomFilter<12, FilterChecker>* filter = new BloomFilter<12, FilterChecker>();
+  MOZ_RELEASE_ASSERT(filter);
+
+  FilterChecker one(1);
+  FilterChecker two(0x20000);
+  FilterChecker many(0x10000);
+  FilterChecker multiple(0x20001);
+
+  filter->add(&one);
+  MOZ_RELEASE_ASSERT(filter->mightContain(&one),
+             "Filter should contain 'one'");
+
+  MOZ_RELEASE_ASSERT(!filter->mightContain(&multiple),
+             "Filter claims to contain 'multiple' when it should not");
+
+  MOZ_RELEASE_ASSERT(filter->mightContain(&many),
+             "Filter should contain 'many' (false positive)");
+
+  filter->add(&two);
+  MOZ_RELEASE_ASSERT(filter->mightContain(&multiple),
+             "Filter should contain 'multiple' (false positive)");
+
+  // Test basic removals
+  filter->remove(&two);
+  MOZ_RELEASE_ASSERT(!filter->mightContain(&multiple),
+             "Filter claims to contain 'multiple' when it should not after two "
+             "was removed");
+
+  // Test multiple addition/removal
+  const size_t FILTER_SIZE = 255;
+  for (size_t i = 0; i < FILTER_SIZE - 1; ++i) {
+    filter->add(&two);
+  }
+  MOZ_RELEASE_ASSERT(filter->mightContain(&multiple),
+             "Filter should contain 'multiple' after 'two' added lots of times "
+             "(false positive)");
+
+  for (size_t i = 0; i < FILTER_SIZE - 1; ++i) {
+    filter->remove(&two);
+  }
+  MOZ_RELEASE_ASSERT(!filter->mightContain(&multiple),
+             "Filter claims to contain 'multiple' when it should not after two "
+             "was removed lots of times");
+
+  // Test overflowing the filter buckets
+  for (size_t i = 0; i < FILTER_SIZE + 1; ++i) {
+    filter->add(&two);
+  }
+  MOZ_RELEASE_ASSERT(filter->mightContain(&multiple),
+             "Filter should contain 'multiple' after 'two' added lots more "
+             "times (false positive)");
+
+  for (size_t i = 0; i < FILTER_SIZE + 1; ++i) {
+    filter->remove(&two);
+  }
+  MOZ_RELEASE_ASSERT(filter->mightContain(&multiple),
+             "Filter claims to not contain 'multiple' even though we should "
+             "have run out of space in the buckets (false positive)");
+  MOZ_RELEASE_ASSERT(filter->mightContain(&two),
+             "Filter claims to not contain 'two' even though we should have "
+             "run out of space in the buckets (false positive)");
+
+  filter->remove(&one);
+
+  MOZ_RELEASE_ASSERT(!filter->mightContain(&one),
+             "Filter should not contain 'one', because we didn't overflow its "
+             "bucket");
+
+  filter->clear();
+
+  MOZ_RELEASE_ASSERT(!filter->mightContain(&multiple),
+             "clear() failed to work");
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestCasting.cpp b/src/third_party/mozjs-45/mfbt/tests/TestCasting.cpp
new file mode 100644
index 0000000..c8bd124
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestCasting.cpp
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Casting.h"
+
+#include <stdint.h>
+
+using mozilla::BitwiseCast;
+using mozilla::detail::IsInBounds;
+
+template<typename Uint, typename Ulong, bool = (sizeof(Uint) == sizeof(Ulong))>
+struct UintUlongBitwiseCast;
+
+template<typename Uint, typename Ulong>
+struct UintUlongBitwiseCast<Uint, Ulong, true>
+{
+  static void test()
+  {
+    MOZ_RELEASE_ASSERT(BitwiseCast<Ulong>(Uint(8675309)) == Ulong(8675309));
+  }
+};
+
+template<typename Uint, typename Ulong>
+struct UintUlongBitwiseCast<Uint, Ulong, false>
+{
+  static void test() { }
+};
+
+static void
+TestBitwiseCast()
+{
+  MOZ_RELEASE_ASSERT(BitwiseCast<int>(int(8675309)) == int(8675309));
+  UintUlongBitwiseCast<unsigned int, unsigned long>::test();
+}
+
+static void
+TestSameSize()
+{
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, int16_t>(int16_t(0))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, int16_t>(int16_t(INT16_MIN))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, int16_t>(int16_t(INT16_MAX))));
+  MOZ_RELEASE_ASSERT((IsInBounds<uint16_t, uint16_t>(uint16_t(UINT16_MAX))));
+  MOZ_RELEASE_ASSERT((IsInBounds<uint16_t, int16_t>(uint16_t(0))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<uint16_t, int16_t>(uint16_t(-1))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, uint16_t>(int16_t(-1))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, uint16_t>(int16_t(INT16_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, uint16_t>(int16_t(INT16_MIN))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int32_t, uint32_t>(int32_t(INT32_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int32_t, uint32_t>(int32_t(INT32_MIN))));
+}
+
+static void
+TestToBiggerSize()
+{
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, int32_t>(int16_t(0))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, int32_t>(int16_t(INT16_MIN))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, int32_t>(int16_t(INT16_MAX))));
+  MOZ_RELEASE_ASSERT((IsInBounds<uint16_t, uint32_t>(uint16_t(UINT16_MAX))));
+  MOZ_RELEASE_ASSERT((IsInBounds<uint16_t, int32_t>(uint16_t(0))));
+  MOZ_RELEASE_ASSERT((IsInBounds<uint16_t, int32_t>(uint16_t(-1))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, uint32_t>(int16_t(-1))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, uint32_t>(int16_t(INT16_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, uint32_t>(int16_t(INT16_MIN))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int32_t, uint64_t>(int32_t(INT32_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int32_t, uint64_t>(int32_t(INT32_MIN))));
+}
+
+static void
+TestToSmallerSize()
+{
+  MOZ_RELEASE_ASSERT((IsInBounds<int16_t, int8_t>(int16_t(0))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, int8_t>(int16_t(INT16_MIN))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, int8_t>(int16_t(INT16_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<uint16_t, uint8_t>(uint16_t(UINT16_MAX))));
+  MOZ_RELEASE_ASSERT((IsInBounds<uint16_t, int8_t>(uint16_t(0))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<uint16_t, int8_t>(uint16_t(-1))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, uint8_t>(int16_t(-1))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, uint8_t>(int16_t(INT16_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int16_t, uint8_t>(int16_t(INT16_MIN))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int32_t, uint16_t>(int32_t(INT32_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int32_t, uint16_t>(int32_t(INT32_MIN))));
+
+  // Boundary cases
+  MOZ_RELEASE_ASSERT((!IsInBounds<int64_t, int32_t>(int64_t(INT32_MIN) - 1)));
+  MOZ_RELEASE_ASSERT((IsInBounds<int64_t, int32_t>(int64_t(INT32_MIN))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int64_t, int32_t>(int64_t(INT32_MIN) + 1)));
+  MOZ_RELEASE_ASSERT((IsInBounds<int64_t, int32_t>(int64_t(INT32_MAX) - 1)));
+  MOZ_RELEASE_ASSERT((IsInBounds<int64_t, int32_t>(int64_t(INT32_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int64_t, int32_t>(int64_t(INT32_MAX) + 1)));
+
+  MOZ_RELEASE_ASSERT((!IsInBounds<int64_t, uint32_t>(int64_t(-1))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int64_t, uint32_t>(int64_t(0))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int64_t, uint32_t>(int64_t(1))));
+  MOZ_RELEASE_ASSERT((IsInBounds<int64_t, uint32_t>(int64_t(UINT32_MAX) - 1)));
+  MOZ_RELEASE_ASSERT((IsInBounds<int64_t, uint32_t>(int64_t(UINT32_MAX))));
+  MOZ_RELEASE_ASSERT((!IsInBounds<int64_t, uint32_t>(int64_t(UINT32_MAX) + 1)));
+}
+
+int
+main()
+{
+  TestBitwiseCast();
+
+  TestSameSize();
+  TestToBiggerSize();
+  TestToSmallerSize();
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestCeilingFloor.cpp b/src/third_party/mozjs-45/mfbt/tests/TestCeilingFloor.cpp
new file mode 100644
index 0000000..f1c50de
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestCeilingFloor.cpp
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/MathAlgorithms.h"
+
+using mozilla::CeilingLog2;
+using mozilla::FloorLog2;
+using mozilla::RoundUpPow2;
+
+static void
+TestCeiling()
+{
+  for (uint32_t i = 0; i <= 1; i++) {
+    MOZ_RELEASE_ASSERT(CeilingLog2(i) == 0);
+  }
+  for (uint32_t i = 2; i <= 2; i++) {
+    MOZ_RELEASE_ASSERT(CeilingLog2(i) == 1);
+  }
+  for (uint32_t i = 3; i <= 4; i++) {
+    MOZ_RELEASE_ASSERT(CeilingLog2(i) == 2);
+  }
+  for (uint32_t i = 5; i <= 8; i++) {
+    MOZ_RELEASE_ASSERT(CeilingLog2(i) == 3);
+  }
+  for (uint32_t i = 9; i <= 16; i++) {
+    MOZ_RELEASE_ASSERT(CeilingLog2(i) == 4);
+  }
+}
+
+static void
+TestFloor()
+{
+  for (uint32_t i = 0; i <= 1; i++) {
+    MOZ_RELEASE_ASSERT(FloorLog2(i) == 0);
+  }
+  for (uint32_t i = 2; i <= 3; i++) {
+    MOZ_RELEASE_ASSERT(FloorLog2(i) == 1);
+  }
+  for (uint32_t i = 4; i <= 7; i++) {
+    MOZ_RELEASE_ASSERT(FloorLog2(i) == 2);
+  }
+  for (uint32_t i = 8; i <= 15; i++) {
+    MOZ_RELEASE_ASSERT(FloorLog2(i) == 3);
+  }
+  for (uint32_t i = 16; i <= 31; i++) {
+    MOZ_RELEASE_ASSERT(FloorLog2(i) == 4);
+  }
+}
+
+static void
+TestRoundUpPow2()
+{
+  MOZ_RELEASE_ASSERT(RoundUpPow2(0) == 1);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(1) == 1);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(2) == 2);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(3) == 4);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(4) == 4);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(5) == 8);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(6) == 8);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(7) == 8);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(8) == 8);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(9) == 16);
+
+  MOZ_RELEASE_ASSERT(RoundUpPow2(15) == 16);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(16) == 16);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(17) == 32);
+
+  MOZ_RELEASE_ASSERT(RoundUpPow2(31) == 32);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(32) == 32);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(33) == 64);
+
+  size_t MaxPow2 = size_t(1) << (sizeof(size_t) * CHAR_BIT - 1);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(MaxPow2 - 1) == MaxPow2);
+  MOZ_RELEASE_ASSERT(RoundUpPow2(MaxPow2) == MaxPow2);
+  // not valid to round up when past the max power of two
+}
+
+int
+main()
+{
+  TestCeiling();
+  TestFloor();
+
+  TestRoundUpPow2();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestCheckedInt.cpp b/src/third_party/mozjs-45/mfbt/tests/TestCheckedInt.cpp
new file mode 100644
index 0000000..7ded8e3
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestCheckedInt.cpp
@@ -0,0 +1,626 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/CheckedInt.h"
+
+#include <iostream>
+#include <climits>
+
+using namespace mozilla;
+
+int gIntegerTypesTested = 0;
+int gTestsPassed = 0;
+int gTestsFailed = 0;
+
+void verifyImplFunction(bool aX, bool aExpected,
+                        const char* aFile, int aLine,
+                        int aSize, bool aIsTSigned)
+{
+  if (aX == aExpected) {
+    gTestsPassed++;
+  } else {
+    gTestsFailed++;
+    std::cerr << "Test failed at " << aFile << ":" << aLine;
+    std::cerr << " with T a ";
+    if (aIsTSigned) {
+      std::cerr << "signed";
+    } else {
+      std::cerr << "unsigned";
+    }
+    std::cerr << " " << CHAR_BIT * aSize << "-bit integer type" << std::endl;
+  }
+}
+
+#define VERIFY_IMPL(x, expected) \
+    verifyImplFunction((x), \
+    (expected), \
+    __FILE__, \
+    __LINE__, \
+    sizeof(T), \
+    IsSigned<T>::value)
+
+#define VERIFY(x)            VERIFY_IMPL(x, true)
+#define VERIFY_IS_FALSE(x)   VERIFY_IMPL(x, false)
+#define VERIFY_IS_VALID(x)   VERIFY_IMPL((x).isValid(), true)
+#define VERIFY_IS_INVALID(x) VERIFY_IMPL((x).isValid(), false)
+#define VERIFY_IS_VALID_IF(x,condition) VERIFY_IMPL((x).isValid(), (condition))
+
+template<typename T, size_t Size = sizeof(T)>
+struct testTwiceBiggerType
+{
+  static void run()
+  {
+    VERIFY(detail::IsSupported<typename detail::TwiceBiggerType<T>::Type>::value);
+    VERIFY(sizeof(typename detail::TwiceBiggerType<T>::Type) == 2 * sizeof(T));
+    VERIFY(bool(IsSigned<typename detail::TwiceBiggerType<T>::Type>::value) ==
+           bool(IsSigned<T>::value));
+  }
+};
+
+template<typename T>
+struct testTwiceBiggerType<T, 8>
+{
+  static void run()
+  {
+    VERIFY_IS_FALSE(detail::IsSupported<
+                      typename detail::TwiceBiggerType<T>::Type
+                    >::value);
+  }
+};
+
+
+template<typename T>
+void test()
+{
+  static bool alreadyRun = false;
+  // Integer types from different families may just be typedefs for types from
+  // other families. E.g. int32_t might be just a typedef for int. No point
+  // re-running the same tests then.
+  if (alreadyRun) {
+    return;
+  }
+  alreadyRun = true;
+
+  VERIFY(detail::IsSupported<T>::value);
+  const bool isTSigned = IsSigned<T>::value;
+  VERIFY(bool(isTSigned) == !bool(T(-1) > T(0)));
+
+  testTwiceBiggerType<T>::run();
+
+  typedef typename MakeUnsigned<T>::Type unsignedT;
+
+  VERIFY(sizeof(unsignedT) == sizeof(T));
+  VERIFY(IsSigned<unsignedT>::value == false);
+
+  const CheckedInt<T> max(MaxValue<T>::value);
+  const CheckedInt<T> min(MinValue<T>::value);
+
+  // Check MinValue and MaxValue, since they are custom implementations and a
+  // mistake there could potentially NOT be caught by any other tests... while
+  // making everything wrong!
+
+  unsignedT bit = 1;
+  unsignedT unsignedMinValue(min.value());
+  unsignedT unsignedMaxValue(max.value());
+  for (size_t i = 0; i < sizeof(T) * CHAR_BIT - 1; i++) {
+    VERIFY((unsignedMinValue & bit) == 0);
+    bit <<= 1;
+  }
+  VERIFY((unsignedMinValue & bit) == (isTSigned ? bit : unsignedT(0)));
+  VERIFY(unsignedMaxValue == unsignedT(~unsignedMinValue));
+
+  const CheckedInt<T> zero(0);
+  const CheckedInt<T> one(1);
+  const CheckedInt<T> two(2);
+  const CheckedInt<T> three(3);
+  const CheckedInt<T> four(4);
+
+  /* Addition / subtraction checks */
+
+  VERIFY_IS_VALID(zero + zero);
+  VERIFY(zero + zero == zero);
+  VERIFY_IS_FALSE(zero + zero == one); // Check == doesn't always return true
+  VERIFY_IS_VALID(zero + one);
+  VERIFY(zero + one == one);
+  VERIFY_IS_VALID(one + one);
+  VERIFY(one + one == two);
+
+  const CheckedInt<T> maxMinusOne = max - one;
+  const CheckedInt<T> maxMinusTwo = max - two;
+  VERIFY_IS_VALID(maxMinusOne);
+  VERIFY_IS_VALID(maxMinusTwo);
+  VERIFY_IS_VALID(maxMinusOne + one);
+  VERIFY_IS_VALID(maxMinusTwo + one);
+  VERIFY_IS_VALID(maxMinusTwo + two);
+  VERIFY(maxMinusOne + one == max);
+  VERIFY(maxMinusTwo + one == maxMinusOne);
+  VERIFY(maxMinusTwo + two == max);
+
+  VERIFY_IS_VALID(max + zero);
+  VERIFY_IS_VALID(max - zero);
+  VERIFY_IS_INVALID(max + one);
+  VERIFY_IS_INVALID(max + two);
+  VERIFY_IS_INVALID(max + maxMinusOne);
+  VERIFY_IS_INVALID(max + max);
+
+  const CheckedInt<T> minPlusOne = min + one;
+  const CheckedInt<T> minPlusTwo = min + two;
+  VERIFY_IS_VALID(minPlusOne);
+  VERIFY_IS_VALID(minPlusTwo);
+  VERIFY_IS_VALID(minPlusOne - one);
+  VERIFY_IS_VALID(minPlusTwo - one);
+  VERIFY_IS_VALID(minPlusTwo - two);
+  VERIFY(minPlusOne - one == min);
+  VERIFY(minPlusTwo - one == minPlusOne);
+  VERIFY(minPlusTwo - two == min);
+
+  const CheckedInt<T> minMinusOne = min - one;
+  VERIFY_IS_VALID(min + zero);
+  VERIFY_IS_VALID(min - zero);
+  VERIFY_IS_INVALID(min - one);
+  VERIFY_IS_INVALID(min - two);
+  VERIFY_IS_INVALID(min - minMinusOne);
+  VERIFY_IS_VALID(min - min);
+
+  const CheckedInt<T> maxOverTwo = max / two;
+  VERIFY_IS_VALID(maxOverTwo + maxOverTwo);
+  VERIFY_IS_VALID(maxOverTwo + one);
+  VERIFY((maxOverTwo + one) - one == maxOverTwo);
+  VERIFY_IS_VALID(maxOverTwo - maxOverTwo);
+  VERIFY(maxOverTwo - maxOverTwo == zero);
+
+  const CheckedInt<T> minOverTwo = min / two;
+  VERIFY_IS_VALID(minOverTwo + minOverTwo);
+  VERIFY_IS_VALID(minOverTwo + one);
+  VERIFY((minOverTwo + one) - one == minOverTwo);
+  VERIFY_IS_VALID(minOverTwo - minOverTwo);
+  VERIFY(minOverTwo - minOverTwo == zero);
+
+  VERIFY_IS_INVALID(min - one);
+  VERIFY_IS_INVALID(min - two);
+
+  if (isTSigned) {
+    VERIFY_IS_INVALID(min + min);
+    VERIFY_IS_INVALID(minOverTwo + minOverTwo + minOverTwo);
+    VERIFY_IS_INVALID(zero - min + min);
+    VERIFY_IS_INVALID(one - min + min);
+  }
+
+  /* Modulo checks */
+  VERIFY_IS_INVALID(zero % zero);
+  VERIFY_IS_INVALID(one % zero);
+  VERIFY_IS_VALID(zero % one);
+  VERIFY_IS_VALID(zero % max);
+  VERIFY_IS_VALID(one % max);
+  VERIFY_IS_VALID(max % one);
+  VERIFY_IS_VALID(max % max);
+  if (isTSigned) {
+    const CheckedInt<T> minusOne = zero - one;
+    VERIFY_IS_INVALID(minusOne % minusOne);
+    VERIFY_IS_INVALID(zero % minusOne);
+    VERIFY_IS_INVALID(one % minusOne);
+    VERIFY_IS_INVALID(minusOne % one);
+
+    VERIFY_IS_INVALID(min % min);
+    VERIFY_IS_INVALID(zero % min);
+    VERIFY_IS_INVALID(min % one);
+  }
+
+  /* Unary operator- checks */
+
+  const CheckedInt<T> negOne = -one;
+  const CheckedInt<T> negTwo = -two;
+
+  if (isTSigned) {
+    VERIFY_IS_VALID(-max);
+    VERIFY_IS_INVALID(-min);
+    VERIFY(-max - min == one);
+    VERIFY_IS_VALID(-max - one);
+    VERIFY_IS_VALID(negOne);
+    VERIFY_IS_VALID(-max + negOne);
+    VERIFY_IS_VALID(negOne + one);
+    VERIFY(negOne + one == zero);
+    VERIFY_IS_VALID(negTwo);
+    VERIFY_IS_VALID(negOne + negOne);
+    VERIFY(negOne + negOne == negTwo);
+  } else {
+    VERIFY_IS_INVALID(-max);
+    VERIFY_IS_VALID(-min);
+    VERIFY(min == zero);
+    VERIFY_IS_INVALID(negOne);
+  }
+
+  /* multiplication checks */
+
+  VERIFY_IS_VALID(zero * zero);
+  VERIFY(zero * zero == zero);
+  VERIFY_IS_VALID(zero * one);
+  VERIFY(zero * one == zero);
+  VERIFY_IS_VALID(one * zero);
+  VERIFY(one * zero == zero);
+  VERIFY_IS_VALID(one * one);
+  VERIFY(one * one == one);
+  VERIFY_IS_VALID(one * three);
+  VERIFY(one * three == three);
+  VERIFY_IS_VALID(two * two);
+  VERIFY(two * two == four);
+
+  VERIFY_IS_INVALID(max * max);
+  VERIFY_IS_INVALID(maxOverTwo * max);
+  VERIFY_IS_INVALID(maxOverTwo * maxOverTwo);
+
+  const CheckedInt<T> maxApproxSqrt(T(T(1) << (CHAR_BIT*sizeof(T)/2)));
+
+  VERIFY_IS_VALID(maxApproxSqrt);
+  VERIFY_IS_VALID(maxApproxSqrt * two);
+  VERIFY_IS_INVALID(maxApproxSqrt * maxApproxSqrt);
+  VERIFY_IS_INVALID(maxApproxSqrt * maxApproxSqrt * maxApproxSqrt);
+
+  if (isTSigned) {
+    VERIFY_IS_INVALID(min * min);
+    VERIFY_IS_INVALID(minOverTwo * min);
+    VERIFY_IS_INVALID(minOverTwo * minOverTwo);
+
+    const CheckedInt<T> minApproxSqrt = -maxApproxSqrt;
+
+    VERIFY_IS_VALID(minApproxSqrt);
+    VERIFY_IS_VALID(minApproxSqrt * two);
+    VERIFY_IS_INVALID(minApproxSqrt * maxApproxSqrt);
+    VERIFY_IS_INVALID(minApproxSqrt * minApproxSqrt);
+  }
+
+  // make sure to check all 4 paths in signed multiplication validity check.
+  // test positive * positive
+  VERIFY_IS_VALID(max * one);
+  VERIFY(max * one == max);
+  VERIFY_IS_INVALID(max * two);
+  VERIFY_IS_VALID(maxOverTwo * two);
+  VERIFY((maxOverTwo + maxOverTwo) == (maxOverTwo * two));
+
+  if (isTSigned) {
+    // test positive * negative
+    VERIFY_IS_VALID(max * negOne);
+    VERIFY_IS_VALID(-max);
+    VERIFY(max * negOne == -max);
+    VERIFY_IS_VALID(one * min);
+    VERIFY_IS_INVALID(max * negTwo);
+    VERIFY_IS_VALID(maxOverTwo * negTwo);
+    VERIFY_IS_VALID(two * minOverTwo);
+    VERIFY_IS_VALID((maxOverTwo + one) * negTwo);
+    VERIFY_IS_INVALID((maxOverTwo + two) * negTwo);
+    VERIFY_IS_INVALID(two * (minOverTwo - one));
+
+    // test negative * positive
+    VERIFY_IS_VALID(min * one);
+    VERIFY_IS_VALID(minPlusOne * one);
+    VERIFY_IS_INVALID(min * two);
+    VERIFY_IS_VALID(minOverTwo * two);
+    VERIFY(minOverTwo * two == min);
+    VERIFY_IS_INVALID((minOverTwo - one) * negTwo);
+    VERIFY_IS_INVALID(negTwo * max);
+    VERIFY_IS_VALID(minOverTwo * two);
+    VERIFY(minOverTwo * two == min);
+    VERIFY_IS_VALID(negTwo * maxOverTwo);
+    VERIFY_IS_INVALID((minOverTwo - one) * two);
+    VERIFY_IS_VALID(negTwo * (maxOverTwo + one));
+    VERIFY_IS_INVALID(negTwo * (maxOverTwo + two));
+
+    // test negative * negative
+    VERIFY_IS_INVALID(min * negOne);
+    VERIFY_IS_VALID(minPlusOne * negOne);
+    VERIFY(minPlusOne * negOne == max);
+    VERIFY_IS_INVALID(min * negTwo);
+    VERIFY_IS_INVALID(minOverTwo * negTwo);
+    VERIFY_IS_INVALID(negOne * min);
+    VERIFY_IS_VALID(negOne * minPlusOne);
+    VERIFY(negOne * minPlusOne == max);
+    VERIFY_IS_INVALID(negTwo * min);
+    VERIFY_IS_INVALID(negTwo * minOverTwo);
+  }
+
+  /* Division checks */
+
+  VERIFY_IS_VALID(one / one);
+  VERIFY(one / one == one);
+  VERIFY_IS_VALID(three / three);
+  VERIFY(three / three == one);
+  VERIFY_IS_VALID(four / two);
+  VERIFY(four / two == two);
+  VERIFY((four*three)/four == three);
+
+  // Check that div by zero is invalid
+  VERIFY_IS_INVALID(zero / zero);
+  VERIFY_IS_INVALID(one / zero);
+  VERIFY_IS_INVALID(two / zero);
+  VERIFY_IS_INVALID(negOne / zero);
+  VERIFY_IS_INVALID(max / zero);
+  VERIFY_IS_INVALID(min / zero);
+
+  if (isTSigned) {
+    // Check that min / -1 is invalid
+    VERIFY_IS_INVALID(min / negOne);
+
+    // Check that the test for div by -1 isn't banning other numerators than min
+    VERIFY_IS_VALID(one / negOne);
+    VERIFY_IS_VALID(zero / negOne);
+    VERIFY_IS_VALID(negOne / negOne);
+    VERIFY_IS_VALID(max / negOne);
+  }
+
+  /* Check that invalidity is correctly preserved by arithmetic ops */
+
+  const CheckedInt<T> someInvalid = max + max;
+  VERIFY_IS_INVALID(someInvalid + zero);
+  VERIFY_IS_INVALID(someInvalid - zero);
+  VERIFY_IS_INVALID(zero + someInvalid);
+  VERIFY_IS_INVALID(zero - someInvalid);
+  VERIFY_IS_INVALID(-someInvalid);
+  VERIFY_IS_INVALID(someInvalid * zero);
+  VERIFY_IS_INVALID(someInvalid * one);
+  VERIFY_IS_INVALID(zero * someInvalid);
+  VERIFY_IS_INVALID(one * someInvalid);
+  VERIFY_IS_INVALID(someInvalid / zero);
+  VERIFY_IS_INVALID(someInvalid / one);
+  VERIFY_IS_INVALID(zero / someInvalid);
+  VERIFY_IS_INVALID(one / someInvalid);
+  VERIFY_IS_INVALID(someInvalid % zero);
+  VERIFY_IS_INVALID(someInvalid % one);
+  VERIFY_IS_INVALID(zero % someInvalid);
+  VERIFY_IS_INVALID(one % someInvalid);
+  VERIFY_IS_INVALID(someInvalid + someInvalid);
+  VERIFY_IS_INVALID(someInvalid - someInvalid);
+  VERIFY_IS_INVALID(someInvalid * someInvalid);
+  VERIFY_IS_INVALID(someInvalid / someInvalid);
+  VERIFY_IS_INVALID(someInvalid % someInvalid);
+
+  // Check that mixing checked integers with plain integers in expressions is
+  // allowed
+
+  VERIFY(one + T(2) == three);
+  VERIFY(2 + one == three);
+  {
+    CheckedInt<T> x = one;
+    x += 2;
+    VERIFY(x == three);
+  }
+  VERIFY(two - 1 == one);
+  VERIFY(2 - one == one);
+  {
+    CheckedInt<T> x = two;
+    x -= 1;
+    VERIFY(x == one);
+  }
+  VERIFY(one * 2 == two);
+  VERIFY(2 * one == two);
+  {
+    CheckedInt<T> x = one;
+    x *= 2;
+    VERIFY(x == two);
+  }
+  VERIFY(four / 2 == two);
+  VERIFY(4 / two == two);
+  {
+    CheckedInt<T> x = four;
+    x /= 2;
+    VERIFY(x == two);
+  }
+  VERIFY(three % 2 == one);
+  VERIFY(3 % two == one);
+  {
+    CheckedInt<T> x = three;
+    x %= 2;
+    VERIFY(x == one);
+  }
+
+  VERIFY(one == 1);
+  VERIFY(1 == one);
+  VERIFY_IS_FALSE(two == 1);
+  VERIFY_IS_FALSE(1 == two);
+  VERIFY_IS_FALSE(someInvalid == 1);
+  VERIFY_IS_FALSE(1 == someInvalid);
+
+  // Check that compound operators work when both sides of the expression
+  // are checked integers
+  {
+    CheckedInt<T> x = one;
+    x += two;
+    VERIFY(x == three);
+  }
+  {
+    CheckedInt<T> x = two;
+    x -= one;
+    VERIFY(x == one);
+  }
+  {
+    CheckedInt<T> x = one;
+    x *= two;
+    VERIFY(x == two);
+  }
+  {
+    CheckedInt<T> x = four;
+    x /= two;
+    VERIFY(x == two);
+  }
+  {
+    CheckedInt<T> x = three;
+    x %= two;
+    VERIFY(x == one);
+  }
+
+  // Check that compound operators work when both sides of the expression
+  // are checked integers and the right-hand side is invalid
+  {
+    CheckedInt<T> x = one;
+    x += someInvalid;
+    VERIFY_IS_INVALID(x);
+  }
+  {
+    CheckedInt<T> x = two;
+    x -= someInvalid;
+    VERIFY_IS_INVALID(x);
+  }
+  {
+    CheckedInt<T> x = one;
+    x *= someInvalid;
+    VERIFY_IS_INVALID(x);
+  }
+  {
+    CheckedInt<T> x = four;
+    x /= someInvalid;
+    VERIFY_IS_INVALID(x);
+  }
+  {
+    CheckedInt<T> x = three;
+    x %= someInvalid;
+    VERIFY_IS_INVALID(x);
+  }
+
+  // Check simple casting between different signedness and sizes.
+  {
+    CheckedInt<uint8_t> foo = CheckedInt<uint16_t>(2).toChecked<uint8_t>();
+    VERIFY_IS_VALID(foo);
+    VERIFY(foo == 2);
+  }
+  {
+    CheckedInt<uint8_t> foo = CheckedInt<uint16_t>(255).toChecked<uint8_t>();
+    VERIFY_IS_VALID(foo);
+    VERIFY(foo == 255);
+  }
+  {
+    CheckedInt<uint8_t> foo = CheckedInt<uint16_t>(256).toChecked<uint8_t>();
+    VERIFY_IS_INVALID(foo);
+  }
+  {
+    CheckedInt<uint8_t> foo = CheckedInt<int8_t>(-2).toChecked<uint8_t>();
+    VERIFY_IS_INVALID(foo);
+  }
+
+  // Check that construction of CheckedInt from an integer value of a
+  // mismatched type is checked Also check casting between all types.
+
+  #define VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE2(U,V,PostVExpr) \
+  { \
+    bool isUSigned = IsSigned<U>::value; \
+    VERIFY_IS_VALID(CheckedInt<T>(V(  0)PostVExpr)); \
+    VERIFY_IS_VALID(CheckedInt<T>(V(  1)PostVExpr)); \
+    VERIFY_IS_VALID(CheckedInt<T>(V(100)PostVExpr)); \
+    if (isUSigned) { \
+      VERIFY_IS_VALID_IF(CheckedInt<T>(V(-1)PostVExpr), isTSigned); \
+    } \
+    if (sizeof(U) > sizeof(T)) { \
+      VERIFY_IS_INVALID(CheckedInt<T>(V(MaxValue<T>::value)PostVExpr + one.value())); \
+    } \
+    VERIFY_IS_VALID_IF(CheckedInt<T>(MaxValue<U>::value), \
+      (sizeof(T) > sizeof(U) || ((sizeof(T) == sizeof(U)) && (isUSigned || !isTSigned)))); \
+    VERIFY_IS_VALID_IF(CheckedInt<T>(MinValue<U>::value), \
+      isUSigned == false ? 1 \
+                         : bool(isTSigned) == false ? 0 \
+                                                    : sizeof(T) >= sizeof(U)); \
+  }
+  #define VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(U) \
+    VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE2(U,U,+zero) \
+    VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE2(U,CheckedInt<U>,.toChecked<T>())
+
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(int8_t)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(uint8_t)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(int16_t)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(uint16_t)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(int32_t)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(uint32_t)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(int64_t)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(uint64_t)
+
+  typedef signed char signedChar;
+  typedef unsigned char unsignedChar;
+  typedef unsigned short unsignedShort;
+  typedef unsigned int  unsignedInt;
+  typedef unsigned long unsignedLong;
+  typedef long long longLong;
+  typedef unsigned long long unsignedLongLong;
+
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(char)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(signedChar)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(unsignedChar)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(short)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(unsignedShort)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(int)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(unsignedInt)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(long)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(unsignedLong)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(longLong)
+  VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(unsignedLongLong)
+
+  /* Test increment/decrement operators */
+
+  CheckedInt<T> x, y;
+  x = one;
+  y = x++;
+  VERIFY(x == two);
+  VERIFY(y == one);
+  x = one;
+  y = ++x;
+  VERIFY(x == two);
+  VERIFY(y == two);
+  x = one;
+  y = x--;
+  VERIFY(x == zero);
+  VERIFY(y == one);
+  x = one;
+  y = --x;
+  VERIFY(x == zero);
+  VERIFY(y == zero);
+  x = max;
+  VERIFY_IS_VALID(x++);
+  x = max;
+  VERIFY_IS_INVALID(++x);
+  x = min;
+  VERIFY_IS_VALID(x--);
+  x = min;
+  VERIFY_IS_INVALID(--x);
+
+  gIntegerTypesTested++;
+}
+
+int
+main()
+{
+  test<int8_t>();
+  test<uint8_t>();
+  test<int16_t>();
+  test<uint16_t>();
+  test<int32_t>();
+  test<uint32_t>();
+  test<int64_t>();
+  test<uint64_t>();
+
+  test<char>();
+  test<signed char>();
+  test<unsigned char>();
+  test<short>();
+  test<unsigned short>();
+  test<int>();
+  test<unsigned int>();
+  test<long>();
+  test<unsigned long>();
+  test<long long>();
+  test<unsigned long long>();
+
+  const int MIN_TYPES_TESTED = 9;
+  if (gIntegerTypesTested < MIN_TYPES_TESTED) {
+    std::cerr << "Only " << gIntegerTypesTested << " have been tested. "
+              << "This should not be less than " << MIN_TYPES_TESTED << "."
+              << std::endl;
+    gTestsFailed++;
+  }
+
+  std::cerr << gTestsFailed << " tests failed, "
+            << gTestsPassed << " tests passed out of "
+            << gTestsFailed + gTestsPassed
+            << " tests, covering " << gIntegerTypesTested
+            << " distinct integer types." << std::endl;
+
+  return gTestsFailed > 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestCountPopulation.cpp b/src/third_party/mozjs-45/mfbt/tests/TestCountPopulation.cpp
new file mode 100644
index 0000000..272a0dc
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestCountPopulation.cpp
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/MathAlgorithms.h"
+
+using mozilla::CountPopulation32;
+
+static void
+TestCountPopulation32()
+{
+  MOZ_RELEASE_ASSERT(CountPopulation32(0xFFFFFFFF) == 32);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0xF0FF1000) == 13);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x7F8F0001) == 13);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x3FFF0100) == 15);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x1FF50010) == 12);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x00800000) == 1);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x00400000) == 1);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x00008000) == 1);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x00004000) == 1);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x00000080) == 1);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x00000040) == 1);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x00000001) == 1);
+  MOZ_RELEASE_ASSERT(CountPopulation32(0x00000000) == 0);
+}
+
+int
+main()
+{
+  TestCountPopulation32();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestCountZeroes.cpp b/src/third_party/mozjs-45/mfbt/tests/TestCountZeroes.cpp
new file mode 100644
index 0000000..799ee84
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestCountZeroes.cpp
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/MathAlgorithms.h"
+
+using mozilla::CountLeadingZeroes32;
+using mozilla::CountLeadingZeroes64;
+using mozilla::CountTrailingZeroes32;
+using mozilla::CountTrailingZeroes64;
+
+static void
+TestLeadingZeroes32()
+{
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0xF0FF1000) == 0);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x7F8F0001) == 1);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x3FFF0100) == 2);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x1FF50010) == 3);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x00800000) == 8);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x00400000) == 9);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x00008000) == 16);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x00004000) == 17);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x00000080) == 24);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x00000040) == 25);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes32(0x00000001) == 31);
+}
+
+static void
+TestLeadingZeroes64()
+{
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0xF000F0F010000000) == 0);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x70F080F000000001) == 1);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x30F0F0F000100000) == 2);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x10F0F05000000100) == 3);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0080000000000001) == 8);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0040000010001000) == 9);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x000080F010000000) == 16);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x000040F010000000) == 17);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000008000100100) == 24);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000004100010010) == 25);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000080100100) == 32);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000041001010) == 33);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000000800100) == 40);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000000411010) == 41);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000000008001) == 48);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000000004010) == 49);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000000000081) == 56);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000000000040) == 57);
+  MOZ_RELEASE_ASSERT(CountLeadingZeroes64(0x0000000000000001) == 63);
+}
+
+static void
+TestTrailingZeroes32()
+{
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x0100FFFF) == 0);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x7000FFFE) == 1);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x0080FFFC) == 2);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x0080FFF8) == 3);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x010FFF00) == 8);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x7000FE00) == 9);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x10CF0000) == 16);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x0BDE0000) == 17);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x0F000000) == 24);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0xDE000000) == 25);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes32(0x80000000) == 31);
+}
+
+static void
+TestTrailingZeroes64()
+{
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x000100000F0F0F0F) == 0);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x070000000F0F0F0E) == 1);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x000008000F0F0F0C) == 2);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x000008000F0F0F08) == 3);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0xC001000F0F0F0F00) == 8);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x0200000F0F0F0E00) == 9);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0xB0C10F0FEFDF0000) == 16);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x0AAA00F0FF0E0000) == 17);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0xD010F0FEDF000000) == 24);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x7AAF0CF0BE000000) == 25);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x20F0A5D100000000) == 32);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x489BF0B200000000) == 33);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0xE0F0D10000000000) == 40);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x97F0B20000000000) == 41);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x2C07000000000000) == 48);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x1FBA000000000000) == 49);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x0100000000000000) == 56);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x0200000000000000) == 57);
+  MOZ_RELEASE_ASSERT(CountTrailingZeroes64(0x8000000000000000) == 63);
+}
+
+int
+main()
+{
+  TestLeadingZeroes32();
+  TestLeadingZeroes64();
+  TestTrailingZeroes32();
+  TestTrailingZeroes64();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestEndian.cpp b/src/third_party/mozjs-45/mfbt/tests/TestEndian.cpp
new file mode 100644
index 0000000..b5fcd19
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestEndian.cpp
@@ -0,0 +1,472 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Endian.h"
+
+#include <stddef.h>
+
+using mozilla::BigEndian;
+using mozilla::LittleEndian;
+using mozilla::NativeEndian;
+
+template<typename T>
+void
+TestSingleSwap(T aValue, T aSwappedValue)
+{
+#if MOZ_LITTLE_ENDIAN
+  MOZ_RELEASE_ASSERT(NativeEndian::swapToBigEndian(aValue) == aSwappedValue);
+  MOZ_RELEASE_ASSERT(NativeEndian::swapFromBigEndian(aValue) == aSwappedValue);
+  MOZ_RELEASE_ASSERT(NativeEndian::swapToNetworkOrder(aValue) == aSwappedValue);
+  MOZ_RELEASE_ASSERT(NativeEndian::swapFromNetworkOrder(aValue) ==
+                     aSwappedValue);
+#else
+  MOZ_RELEASE_ASSERT(NativeEndian::swapToLittleEndian(aValue) == aSwappedValue);
+  MOZ_RELEASE_ASSERT(NativeEndian::swapFromLittleEndian(aValue) ==
+                     aSwappedValue);
+#endif
+}
+
+template<typename T>
+void
+TestSingleNoSwap(T aValue, T aUnswappedValue)
+{
+#if MOZ_LITTLE_ENDIAN
+  MOZ_RELEASE_ASSERT(NativeEndian::swapToLittleEndian(aValue) ==
+                     aUnswappedValue);
+  MOZ_RELEASE_ASSERT(NativeEndian::swapFromLittleEndian(aValue) ==
+                     aUnswappedValue);
+#else
+  MOZ_RELEASE_ASSERT(NativeEndian::swapToBigEndian(aValue) == aUnswappedValue);
+  MOZ_RELEASE_ASSERT(NativeEndian::swapFromBigEndian(aValue) == aUnswappedValue);
+  MOZ_RELEASE_ASSERT(NativeEndian::swapToNetworkOrder(aValue) ==
+                     aUnswappedValue);
+  MOZ_RELEASE_ASSERT(NativeEndian::swapFromNetworkOrder(aValue) ==
+                     aUnswappedValue);
+#endif
+}
+
+// Endian.h functions are declared as protected in an base class and
+// then re-exported as public in public derived classes.  The
+// standardese around explicit instantiation of templates is not clear
+// in such cases.  Provide these wrappers to make things more explicit.
+// For your own enlightenment, you may wish to peruse:
+// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56152 and subsequently
+// http://j.mp/XosS6S .
+#define WRAP_COPYTO(NAME)                                       \
+  template<typename T>                                          \
+  void                                                          \
+  NAME(void* aDst, const T* aSrc, size_t aCount)                \
+  {                                                             \
+    NativeEndian::NAME<T>(aDst, aSrc, aCount);                  \
+  }
+
+WRAP_COPYTO(copyAndSwapToLittleEndian)
+WRAP_COPYTO(copyAndSwapToBigEndian)
+WRAP_COPYTO(copyAndSwapToNetworkOrder)
+
+#define WRAP_COPYFROM(NAME)                                     \
+  template<typename T>                                          \
+  void                                                          \
+  NAME(T* aDst, const void* aSrc, size_t aCount)                \
+  {                                                             \
+    NativeEndian::NAME<T>(aDst, aSrc, aCount);                  \
+  }
+
+WRAP_COPYFROM(copyAndSwapFromLittleEndian)
+WRAP_COPYFROM(copyAndSwapFromBigEndian)
+WRAP_COPYFROM(copyAndSwapFromNetworkOrder)
+
+#define WRAP_IN_PLACE(NAME)                                     \
+  template<typename T>                                          \
+  void                                                          \
+  NAME(T* aP, size_t aCount)                                    \
+  {                                                             \
+    NativeEndian::NAME<T>(aP, aCount);                          \
+  }
+WRAP_IN_PLACE(swapToLittleEndianInPlace)
+WRAP_IN_PLACE(swapFromLittleEndianInPlace)
+WRAP_IN_PLACE(swapToBigEndianInPlace)
+WRAP_IN_PLACE(swapFromBigEndianInPlace)
+WRAP_IN_PLACE(swapToNetworkOrderInPlace)
+WRAP_IN_PLACE(swapFromNetworkOrderInPlace)
+
+enum SwapExpectation
+{
+  Swap,
+  NoSwap
+};
+
+template<typename T, size_t Count>
+void
+TestBulkSwapToSub(enum SwapExpectation aExpectSwap,
+                  const T (&aValues)[Count],
+                  void (*aSwapperFunc)(void*, const T*, size_t),
+                  T (*aReaderFunc)(const void*))
+{
+  const size_t arraySize = 2 * Count;
+  const size_t bufferSize = arraySize * sizeof(T);
+  static uint8_t buffer[bufferSize];
+  const uint8_t fillValue = 0xa5;
+  static uint8_t checkBuffer[bufferSize];
+
+  MOZ_RELEASE_ASSERT(bufferSize > 2 * sizeof(T));
+
+  memset(checkBuffer, fillValue, bufferSize);
+
+  for (size_t startPosition = 0; startPosition < sizeof(T); ++startPosition) {
+    for (size_t nValues = 0; nValues < Count; ++nValues) {
+      memset(buffer, fillValue, bufferSize);
+      aSwapperFunc(buffer + startPosition, aValues, nValues);
+
+      MOZ_RELEASE_ASSERT(memcmp(buffer, checkBuffer, startPosition) == 0);
+      size_t valuesEndPosition = startPosition + sizeof(T) * nValues;
+      MOZ_RELEASE_ASSERT(memcmp(buffer + valuesEndPosition,
+                         checkBuffer + valuesEndPosition,
+                         bufferSize - valuesEndPosition) == 0);
+      if (aExpectSwap == NoSwap) {
+        MOZ_RELEASE_ASSERT(memcmp(buffer + startPosition, aValues,
+                           nValues * sizeof(T)) == 0);
+      }
+      for (size_t i = 0; i < nValues; ++i) {
+        MOZ_RELEASE_ASSERT(
+          aReaderFunc(buffer + startPosition + sizeof(T) * i) == aValues[i]);
+      }
+    }
+  }
+}
+
+template<typename T, size_t Count>
+void
+TestBulkSwapFromSub(enum SwapExpectation aExpectSwap,
+                    const T (&aValues)[Count],
+                    void (*aSwapperFunc)(T*, const void*, size_t),
+                    T (*aReaderFunc)(const void*))
+{
+  const size_t arraySize = 2 * Count;
+  const size_t bufferSize = arraySize * sizeof(T);
+  static T buffer[arraySize];
+  const uint8_t fillValue = 0xa5;
+  static T checkBuffer[arraySize];
+
+  memset(checkBuffer, fillValue, bufferSize);
+
+  for (size_t startPosition = 0; startPosition < Count; ++startPosition) {
+    for (size_t nValues = 0; nValues < (Count - startPosition); ++nValues) {
+      memset(buffer, fillValue, bufferSize);
+      aSwapperFunc(buffer + startPosition, aValues, nValues);
+
+      MOZ_RELEASE_ASSERT(
+        memcmp(buffer, checkBuffer, startPosition * sizeof(T)) == 0);
+      size_t valuesEndPosition = startPosition + nValues;
+      MOZ_RELEASE_ASSERT(memcmp(buffer + valuesEndPosition,
+                        checkBuffer + valuesEndPosition,
+                        (arraySize - valuesEndPosition) * sizeof(T)) == 0);
+      if (aExpectSwap == NoSwap) {
+        MOZ_RELEASE_ASSERT(memcmp(buffer + startPosition, aValues,
+                          nValues * sizeof(T)) == 0);
+      }
+      for (size_t i = 0; i < nValues; ++i) {
+        MOZ_RELEASE_ASSERT(aReaderFunc(buffer + startPosition + i) == aValues[i]);
+      }
+    }
+  }
+}
+
+
+template<typename T, size_t Count>
+void
+TestBulkInPlaceSub(enum SwapExpectation aExpectSwap,
+                   const T (&aValues)[Count],
+                   void (*aSwapperFunc)(T*, size_t),
+                   T (*aReaderFunc)(const void*))
+{
+  const size_t bufferCount = 4 * Count;
+  const size_t bufferSize = bufferCount * sizeof(T);
+  static T buffer[bufferCount];
+  const T fillValue = 0xa5;
+  static T checkBuffer[bufferCount];
+
+  MOZ_RELEASE_ASSERT(bufferSize > 2 * sizeof(T));
+
+  memset(checkBuffer, fillValue, bufferSize);
+
+  for (size_t startPosition = 0; startPosition < Count; ++startPosition) {
+    for (size_t nValues = 0; nValues < Count; ++nValues) {
+      memset(buffer, fillValue, bufferSize);
+      memcpy(buffer + startPosition, aValues, nValues * sizeof(T));
+      aSwapperFunc(buffer + startPosition, nValues);
+
+      MOZ_RELEASE_ASSERT(
+        memcmp(buffer, checkBuffer, startPosition * sizeof(T)) == 0);
+      size_t valuesEndPosition = startPosition + nValues;
+      MOZ_RELEASE_ASSERT(memcmp(buffer + valuesEndPosition,
+                         checkBuffer + valuesEndPosition,
+                         bufferSize - valuesEndPosition * sizeof(T)) == 0);
+      if (aExpectSwap == NoSwap) {
+        MOZ_RELEASE_ASSERT(memcmp(buffer + startPosition, aValues,
+                           nValues * sizeof(T)) == 0);
+      }
+      for (size_t i = 0; i < nValues; ++i) {
+        MOZ_RELEASE_ASSERT(aReaderFunc(buffer + startPosition + i) == aValues[i]);
+      }
+    }
+  }
+}
+
+template<typename T>
+struct Reader
+{
+};
+
+#define SPECIALIZE_READER(TYPE, READ_FUNC)                                    \
+  template<>                                                                  \
+  struct Reader<TYPE>                                                         \
+  {                                                                           \
+    static TYPE readLE(const void* aP) { return LittleEndian::READ_FUNC(aP); }\
+    static TYPE readBE(const void* aP) { return BigEndian::READ_FUNC(aP); }   \
+  };
+
+SPECIALIZE_READER(uint16_t, readUint16)
+SPECIALIZE_READER(uint32_t, readUint32)
+SPECIALIZE_READER(uint64_t, readUint64)
+SPECIALIZE_READER(int16_t, readInt16)
+SPECIALIZE_READER(int32_t, readInt32)
+SPECIALIZE_READER(int64_t, readInt64)
+
+template<typename T, size_t Count>
+void
+TestBulkSwap(const T (&aBytes)[Count])
+{
+#if MOZ_LITTLE_ENDIAN
+  TestBulkSwapToSub(Swap, aBytes, copyAndSwapToBigEndian<T>,
+                    Reader<T>::readBE);
+  TestBulkSwapFromSub(Swap, aBytes, copyAndSwapFromBigEndian<T>,
+                      Reader<T>::readBE);
+  TestBulkSwapToSub(Swap, aBytes, copyAndSwapToNetworkOrder<T>,
+                    Reader<T>::readBE);
+  TestBulkSwapFromSub(Swap, aBytes, copyAndSwapFromNetworkOrder<T>,
+                      Reader<T>::readBE);
+#else
+  TestBulkSwapToSub(Swap, aBytes, copyAndSwapToLittleEndian<T>,
+                    Reader<T>::readLE);
+  TestBulkSwapFromSub(Swap, aBytes, copyAndSwapFromLittleEndian<T>,
+                      Reader<T>::readLE);
+#endif
+}
+
+template<typename T, size_t Count>
+void
+TestBulkNoSwap(const T (&aBytes)[Count])
+{
+#if MOZ_LITTLE_ENDIAN
+  TestBulkSwapToSub(NoSwap, aBytes, copyAndSwapToLittleEndian<T>,
+                    Reader<T>::readLE);
+  TestBulkSwapFromSub(NoSwap, aBytes, copyAndSwapFromLittleEndian<T>,
+                      Reader<T>::readLE);
+#else
+  TestBulkSwapToSub(NoSwap, aBytes, copyAndSwapToBigEndian<T>,
+                    Reader<T>::readBE);
+  TestBulkSwapFromSub(NoSwap, aBytes, copyAndSwapFromBigEndian<T>,
+                      Reader<T>::readBE);
+  TestBulkSwapToSub(NoSwap, aBytes, copyAndSwapToNetworkOrder<T>,
+                    Reader<T>::readBE);
+  TestBulkSwapFromSub(NoSwap, aBytes, copyAndSwapFromNetworkOrder<T>,
+                      Reader<T>::readBE);
+#endif
+}
+
+template<typename T, size_t Count>
+void
+TestBulkInPlaceSwap(const T (&aBytes)[Count])
+{
+#if MOZ_LITTLE_ENDIAN
+  TestBulkInPlaceSub(Swap, aBytes, swapToBigEndianInPlace<T>,
+                     Reader<T>::readBE);
+  TestBulkInPlaceSub(Swap, aBytes, swapFromBigEndianInPlace<T>,
+                     Reader<T>::readBE);
+  TestBulkInPlaceSub(Swap, aBytes, swapToNetworkOrderInPlace<T>,
+                     Reader<T>::readBE);
+  TestBulkInPlaceSub(Swap, aBytes, swapFromNetworkOrderInPlace<T>,
+                     Reader<T>::readBE);
+#else
+  TestBulkInPlaceSub(Swap, aBytes, swapToLittleEndianInPlace<T>,
+                     Reader<T>::readLE);
+  TestBulkInPlaceSub(Swap, aBytes, swapFromLittleEndianInPlace<T>,
+                     Reader<T>::readLE);
+#endif
+}
+
+template<typename T, size_t Count>
+void
+TestBulkInPlaceNoSwap(const T (&aBytes)[Count])
+{
+#if MOZ_LITTLE_ENDIAN
+  TestBulkInPlaceSub(NoSwap, aBytes, swapToLittleEndianInPlace<T>,
+                     Reader<T>::readLE);
+  TestBulkInPlaceSub(NoSwap, aBytes, swapFromLittleEndianInPlace<T>,
+                     Reader<T>::readLE);
+#else
+  TestBulkInPlaceSub(NoSwap, aBytes, swapToBigEndianInPlace<T>,
+                     Reader<T>::readBE);
+  TestBulkInPlaceSub(NoSwap, aBytes, swapFromBigEndianInPlace<T>,
+                     Reader<T>::readBE);
+  TestBulkInPlaceSub(NoSwap, aBytes, swapToNetworkOrderInPlace<T>,
+                     Reader<T>::readBE);
+  TestBulkInPlaceSub(NoSwap, aBytes, swapFromNetworkOrderInPlace<T>,
+                     Reader<T>::readBE);
+#endif
+}
+
+int
+main()
+{
+  static const uint8_t unsigned_bytes[16] = {
+    0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8,
+    0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8
+  };
+  static const int8_t signed_bytes[16] = {
+    -0x0f, -0x0e, -0x0d, -0x0c, -0x0b, -0x0a, -0x09, -0x08,
+    -0x0f, -0x0e, -0x0d, -0x0c, -0x0b, -0x0a, -0x09, -0x08
+  };
+  static const uint16_t uint16_values[8] = {
+    0x102, 0x304, 0x506, 0x708, 0x102, 0x304, 0x506, 0x708
+  };
+  static const int16_t int16_values[8] = {
+    int16_t(0xf1f2), int16_t(0xf3f4), int16_t(0xf5f6), int16_t(0xf7f8),
+    int16_t(0xf1f2), int16_t(0xf3f4), int16_t(0xf5f6), int16_t(0xf7f8)
+  };
+  static const uint32_t uint32_values[4] = {
+    0x1020304, 0x5060708, 0x1020304, 0x5060708
+  };
+  static const int32_t int32_values[4] = {
+    int32_t(0xf1f2f3f4), int32_t(0xf5f6f7f8),
+    int32_t(0xf1f2f3f4), int32_t(0xf5f6f7f8)
+  };
+  static const uint64_t uint64_values[2] = {
+    0x102030405060708, 0x102030405060708
+  };
+  static const int64_t int64_values[2] = {
+    int64_t(0xf1f2f3f4f5f6f7f8), int64_t(0xf1f2f3f4f5f6f7f8)
+  };
+  uint8_t buffer[8];
+
+  MOZ_RELEASE_ASSERT(LittleEndian::readUint16(&unsigned_bytes[0]) == 0x201);
+  MOZ_RELEASE_ASSERT(BigEndian::readUint16(&unsigned_bytes[0]) == 0x102);
+
+  MOZ_RELEASE_ASSERT(
+    LittleEndian::readUint32(&unsigned_bytes[0]) == 0x4030201U);
+  MOZ_RELEASE_ASSERT(
+    BigEndian::readUint32(&unsigned_bytes[0]) == 0x1020304U);
+
+  MOZ_RELEASE_ASSERT(
+    LittleEndian::readUint64(&unsigned_bytes[0]) == 0x807060504030201ULL);
+  MOZ_RELEASE_ASSERT(
+    BigEndian::readUint64(&unsigned_bytes[0]) == 0x102030405060708ULL);
+
+  LittleEndian::writeUint16(&buffer[0], 0x201);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&unsigned_bytes[0], &buffer[0], sizeof(uint16_t)) == 0);
+  BigEndian::writeUint16(&buffer[0], 0x102);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&unsigned_bytes[0], &buffer[0], sizeof(uint16_t)) == 0);
+
+  LittleEndian::writeUint32(&buffer[0], 0x4030201U);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&unsigned_bytes[0], &buffer[0], sizeof(uint32_t)) == 0);
+  BigEndian::writeUint32(&buffer[0], 0x1020304U);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&unsigned_bytes[0], &buffer[0], sizeof(uint32_t)) == 0);
+
+  LittleEndian::writeUint64(&buffer[0], 0x807060504030201ULL);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&unsigned_bytes[0], &buffer[0], sizeof(uint64_t)) == 0);
+  BigEndian::writeUint64(&buffer[0], 0x102030405060708ULL);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&unsigned_bytes[0], &buffer[0], sizeof(uint64_t)) == 0);
+
+  MOZ_RELEASE_ASSERT(
+    LittleEndian::readInt16(&signed_bytes[0]) == int16_t(0xf2f1));
+  MOZ_RELEASE_ASSERT(
+    BigEndian::readInt16(&signed_bytes[0]) == int16_t(0xf1f2));
+
+  MOZ_RELEASE_ASSERT(
+    LittleEndian::readInt32(&signed_bytes[0]) == int32_t(0xf4f3f2f1));
+  MOZ_RELEASE_ASSERT(
+    BigEndian::readInt32(&signed_bytes[0]) == int32_t(0xf1f2f3f4));
+
+  MOZ_RELEASE_ASSERT(
+    LittleEndian::readInt64(&signed_bytes[0]) == int64_t(0xf8f7f6f5f4f3f2f1LL));
+  MOZ_RELEASE_ASSERT(
+    BigEndian::readInt64(&signed_bytes[0]) == int64_t(0xf1f2f3f4f5f6f7f8LL));
+
+  LittleEndian::writeInt16(&buffer[0], int16_t(0xf2f1));
+  MOZ_RELEASE_ASSERT(
+    memcmp(&signed_bytes[0], &buffer[0], sizeof(int16_t)) == 0);
+  BigEndian::writeInt16(&buffer[0], int16_t(0xf1f2));
+  MOZ_RELEASE_ASSERT(
+    memcmp(&signed_bytes[0], &buffer[0], sizeof(int16_t)) == 0);
+
+  LittleEndian::writeInt32(&buffer[0], 0xf4f3f2f1);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&signed_bytes[0], &buffer[0], sizeof(int32_t)) == 0);
+  BigEndian::writeInt32(&buffer[0], 0xf1f2f3f4);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&signed_bytes[0], &buffer[0], sizeof(int32_t)) == 0);
+
+  LittleEndian::writeInt64(&buffer[0], 0xf8f7f6f5f4f3f2f1LL);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&signed_bytes[0], &buffer[0], sizeof(int64_t)) == 0);
+  BigEndian::writeInt64(&buffer[0], 0xf1f2f3f4f5f6f7f8LL);
+  MOZ_RELEASE_ASSERT(
+    memcmp(&signed_bytes[0], &buffer[0], sizeof(int64_t)) == 0);
+
+  TestSingleSwap(uint16_t(0xf2f1), uint16_t(0xf1f2));
+  TestSingleSwap(uint32_t(0xf4f3f2f1), uint32_t(0xf1f2f3f4));
+  TestSingleSwap(uint64_t(0xf8f7f6f5f4f3f2f1), uint64_t(0xf1f2f3f4f5f6f7f8));
+
+  TestSingleSwap(int16_t(0xf2f1), int16_t(0xf1f2));
+  TestSingleSwap(int32_t(0xf4f3f2f1), int32_t(0xf1f2f3f4));
+  TestSingleSwap(int64_t(0xf8f7f6f5f4f3f2f1), int64_t(0xf1f2f3f4f5f6f7f8));
+
+  TestSingleNoSwap(uint16_t(0xf2f1), uint16_t(0xf2f1));
+  TestSingleNoSwap(uint32_t(0xf4f3f2f1), uint32_t(0xf4f3f2f1));
+  TestSingleNoSwap(uint64_t(0xf8f7f6f5f4f3f2f1), uint64_t(0xf8f7f6f5f4f3f2f1));
+
+  TestSingleNoSwap(int16_t(0xf2f1), int16_t(0xf2f1));
+  TestSingleNoSwap(int32_t(0xf4f3f2f1), int32_t(0xf4f3f2f1));
+  TestSingleNoSwap(int64_t(0xf8f7f6f5f4f3f2f1), int64_t(0xf8f7f6f5f4f3f2f1));
+
+  TestBulkSwap(uint16_values);
+  TestBulkSwap(int16_values);
+  TestBulkSwap(uint32_values);
+  TestBulkSwap(int32_values);
+  TestBulkSwap(uint64_values);
+  TestBulkSwap(int64_values);
+
+  TestBulkNoSwap(uint16_values);
+  TestBulkNoSwap(int16_values);
+  TestBulkNoSwap(uint32_values);
+  TestBulkNoSwap(int32_values);
+  TestBulkNoSwap(uint64_values);
+  TestBulkNoSwap(int64_values);
+
+  TestBulkInPlaceSwap(uint16_values);
+  TestBulkInPlaceSwap(int16_values);
+  TestBulkInPlaceSwap(uint32_values);
+  TestBulkInPlaceSwap(int32_values);
+  TestBulkInPlaceSwap(uint64_values);
+  TestBulkInPlaceSwap(int64_values);
+
+  TestBulkInPlaceNoSwap(uint16_values);
+  TestBulkInPlaceNoSwap(int16_values);
+  TestBulkInPlaceNoSwap(uint32_values);
+  TestBulkInPlaceNoSwap(int32_values);
+  TestBulkInPlaceNoSwap(uint64_values);
+  TestBulkInPlaceNoSwap(int64_values);
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestEnumSet.cpp b/src/third_party/mozjs-45/mfbt/tests/TestEnumSet.cpp
new file mode 100644
index 0000000..6d5b040
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestEnumSet.cpp
@@ -0,0 +1,249 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/EnumSet.h"
+
+using namespace mozilla;
+
+enum SeaBird
+{
+  PENGUIN,
+  ALBATROSS,
+  FULMAR,
+  PRION,
+  SHEARWATER,
+  GADFLY_PETREL,
+  TRUE_PETREL,
+  DIVING_PETREL,
+  STORM_PETREL,
+  PELICAN,
+  GANNET,
+  BOOBY,
+  CORMORANT,
+  FRIGATEBIRD,
+  TROPICBIRD,
+  SKUA,
+  GULL,
+  TERN,
+  SKIMMER,
+  AUK
+};
+
+class EnumSetSuite
+{
+public:
+  EnumSetSuite()
+    : mAlcidae()
+    , mDiomedeidae(ALBATROSS)
+    , mPetrelProcellariidae(GADFLY_PETREL, TRUE_PETREL)
+    , mNonPetrelProcellariidae(FULMAR, PRION, SHEARWATER)
+    , mPetrels(GADFLY_PETREL, TRUE_PETREL, DIVING_PETREL, STORM_PETREL)
+  { }
+
+  void runTests()
+  {
+    testSize();
+    testContains();
+    testAddTo();
+    testAdd();
+    testAddAll();
+    testUnion();
+    testRemoveFrom();
+    testRemove();
+    testRemoveAllFrom();
+    testRemoveAll();
+    testIntersect();
+    testInsersection();
+    testEquality();
+    testDuplicates();
+  }
+
+private:
+  void testSize()
+  {
+    MOZ_RELEASE_ASSERT(mAlcidae.size() == 0);
+    MOZ_RELEASE_ASSERT(mDiomedeidae.size() == 1);
+    MOZ_RELEASE_ASSERT(mPetrelProcellariidae.size() == 2);
+    MOZ_RELEASE_ASSERT(mNonPetrelProcellariidae.size() == 3);
+    MOZ_RELEASE_ASSERT(mPetrels.size() == 4);
+  }
+
+  void testContains()
+  {
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(PENGUIN));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(ALBATROSS));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(FULMAR));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(PRION));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(SHEARWATER));
+    MOZ_RELEASE_ASSERT(mPetrels.contains(GADFLY_PETREL));
+    MOZ_RELEASE_ASSERT(mPetrels.contains(TRUE_PETREL));
+    MOZ_RELEASE_ASSERT(mPetrels.contains(DIVING_PETREL));
+    MOZ_RELEASE_ASSERT(mPetrels.contains(STORM_PETREL));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(PELICAN));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(GANNET));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(BOOBY));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(CORMORANT));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(FRIGATEBIRD));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(TROPICBIRD));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(SKUA));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(GULL));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(TERN));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(SKIMMER));
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(AUK));
+  }
+
+  void testCopy()
+  {
+    EnumSet<SeaBird> likes = mPetrels;
+    likes -= TRUE_PETREL;
+    MOZ_RELEASE_ASSERT(mPetrels.size() == 4);
+    MOZ_RELEASE_ASSERT(mPetrels.contains(TRUE_PETREL));
+
+    MOZ_RELEASE_ASSERT(likes.size() == 3);
+    MOZ_RELEASE_ASSERT(likes.contains(GADFLY_PETREL));
+    MOZ_RELEASE_ASSERT(likes.contains(DIVING_PETREL));
+    MOZ_RELEASE_ASSERT(likes.contains(STORM_PETREL));
+  }
+
+  void testAddTo()
+  {
+    EnumSet<SeaBird> seen = mPetrels;
+    seen += CORMORANT;
+    seen += TRUE_PETREL;
+    MOZ_RELEASE_ASSERT(mPetrels.size() == 4);
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(CORMORANT));
+    MOZ_RELEASE_ASSERT(seen.size() == 5);
+    MOZ_RELEASE_ASSERT(seen.contains(GADFLY_PETREL));
+    MOZ_RELEASE_ASSERT(seen.contains(TRUE_PETREL));
+    MOZ_RELEASE_ASSERT(seen.contains(DIVING_PETREL));
+    MOZ_RELEASE_ASSERT(seen.contains(STORM_PETREL));
+    MOZ_RELEASE_ASSERT(seen.contains(CORMORANT));
+  }
+
+  void testAdd()
+  {
+    EnumSet<SeaBird> seen = mPetrels + CORMORANT + STORM_PETREL;
+    MOZ_RELEASE_ASSERT(mPetrels.size() == 4);
+    MOZ_RELEASE_ASSERT(!mPetrels.contains(CORMORANT));
+    MOZ_RELEASE_ASSERT(seen.size() == 5);
+    MOZ_RELEASE_ASSERT(seen.contains(GADFLY_PETREL));
+    MOZ_RELEASE_ASSERT(seen.contains(TRUE_PETREL));
+    MOZ_RELEASE_ASSERT(seen.contains(DIVING_PETREL));
+    MOZ_RELEASE_ASSERT(seen.contains(STORM_PETREL));
+    MOZ_RELEASE_ASSERT(seen.contains(CORMORANT));
+  }
+
+  void testAddAll()
+  {
+    EnumSet<SeaBird> procellariidae;
+    procellariidae += mPetrelProcellariidae;
+    procellariidae += mNonPetrelProcellariidae;
+    MOZ_RELEASE_ASSERT(procellariidae.size() == 5);
+
+    // Both procellariidae and mPetrels include GADFLY_PERTEL and TRUE_PETREL
+    EnumSet<SeaBird> procellariiformes;
+    procellariiformes += mDiomedeidae;
+    procellariiformes += procellariidae;
+    procellariiformes += mPetrels;
+    MOZ_RELEASE_ASSERT(procellariiformes.size() == 8);
+  }
+
+  void testUnion()
+  {
+    EnumSet<SeaBird> procellariidae = mPetrelProcellariidae +
+                                      mNonPetrelProcellariidae;
+    MOZ_RELEASE_ASSERT(procellariidae.size() == 5);
+
+    // Both procellariidae and mPetrels include GADFLY_PETREL and TRUE_PETREL
+    EnumSet<SeaBird> procellariiformes = mDiomedeidae + procellariidae +
+                                         mPetrels;
+    MOZ_RELEASE_ASSERT(procellariiformes.size() == 8);
+  }
+
+  void testRemoveFrom()
+  {
+    EnumSet<SeaBird> likes = mPetrels;
+    likes -= TRUE_PETREL;
+    likes -= DIVING_PETREL;
+    MOZ_RELEASE_ASSERT(likes.size() == 2);
+    MOZ_RELEASE_ASSERT(likes.contains(GADFLY_PETREL));
+    MOZ_RELEASE_ASSERT(likes.contains(STORM_PETREL));
+  }
+
+  void testRemove()
+  {
+    EnumSet<SeaBird> likes = mPetrels - TRUE_PETREL - DIVING_PETREL;
+    MOZ_RELEASE_ASSERT(likes.size() == 2);
+    MOZ_RELEASE_ASSERT(likes.contains(GADFLY_PETREL));
+    MOZ_RELEASE_ASSERT(likes.contains(STORM_PETREL));
+  }
+
+  void testRemoveAllFrom()
+  {
+    EnumSet<SeaBird> likes = mPetrels;
+    likes -= mPetrelProcellariidae;
+    MOZ_RELEASE_ASSERT(likes.size() == 2);
+    MOZ_RELEASE_ASSERT(likes.contains(DIVING_PETREL));
+    MOZ_RELEASE_ASSERT(likes.contains(STORM_PETREL));
+  }
+
+  void testRemoveAll()
+  {
+    EnumSet<SeaBird> likes = mPetrels - mPetrelProcellariidae;
+    MOZ_RELEASE_ASSERT(likes.size() == 2);
+    MOZ_RELEASE_ASSERT(likes.contains(DIVING_PETREL));
+    MOZ_RELEASE_ASSERT(likes.contains(STORM_PETREL));
+  }
+
+  void testIntersect()
+  {
+    EnumSet<SeaBird> likes = mPetrels;
+    likes &= mPetrelProcellariidae;
+    MOZ_RELEASE_ASSERT(likes.size() == 2);
+    MOZ_RELEASE_ASSERT(likes.contains(GADFLY_PETREL));
+    MOZ_RELEASE_ASSERT(likes.contains(TRUE_PETREL));
+  }
+
+  void testInsersection()
+  {
+    EnumSet<SeaBird> likes = mPetrels & mPetrelProcellariidae;
+    MOZ_RELEASE_ASSERT(likes.size() == 2);
+    MOZ_RELEASE_ASSERT(likes.contains(GADFLY_PETREL));
+    MOZ_RELEASE_ASSERT(likes.contains(TRUE_PETREL));
+  }
+
+  void testEquality()
+  {
+    EnumSet<SeaBird> likes = mPetrels & mPetrelProcellariidae;
+    MOZ_RELEASE_ASSERT(likes == EnumSet<SeaBird>(GADFLY_PETREL,
+                                         TRUE_PETREL));
+  }
+
+  void testDuplicates()
+  {
+    EnumSet<SeaBird> likes = mPetrels;
+    likes += GADFLY_PETREL;
+    likes += TRUE_PETREL;
+    likes += DIVING_PETREL;
+    likes += STORM_PETREL;
+    MOZ_RELEASE_ASSERT(likes.size() == 4);
+    MOZ_RELEASE_ASSERT(likes == mPetrels);
+  }
+
+  EnumSet<SeaBird> mAlcidae;
+  EnumSet<SeaBird> mDiomedeidae;
+  EnumSet<SeaBird> mPetrelProcellariidae;
+  EnumSet<SeaBird> mNonPetrelProcellariidae;
+  EnumSet<SeaBird> mPetrels;
+};
+
+int
+main()
+{
+  EnumSetSuite suite;
+  suite.runTests();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestFastBernoulliTrial.cpp b/src/third_party/mozjs-45/mfbt/tests/TestFastBernoulliTrial.cpp
new file mode 100644
index 0000000..62d4b51
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestFastBernoulliTrial.cpp
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/FastBernoulliTrial.h"
+
+#include <math.h>
+
+// Note that because we always provide FastBernoulliTrial with a fixed
+// pseudorandom seed in these tests, the results here are completely
+// deterministic.
+//
+// A non-optimized version of this test runs in .009s on my laptop. Using larger
+// sample sizes lets us meet tighter bounds on the counts.
+
+static void
+TestProportions()
+{
+  mozilla::FastBernoulliTrial bernoulli(1.0,
+                                        698079309544035222ULL,
+                                        6012389156611637584ULL);
+
+  for (size_t i = 0; i < 100; i++)
+    MOZ_RELEASE_ASSERT(bernoulli.trial());
+
+  {
+    bernoulli.setProbability(0.5);
+    size_t count = 0;
+    for (size_t i = 0; i < 1000; i++)
+      count += bernoulli.trial();
+    MOZ_RELEASE_ASSERT(count == 496);
+  }
+
+  {
+    bernoulli.setProbability(0.001);
+    size_t count = 0;
+    for (size_t i = 0; i < 1000; i++)
+      count += bernoulli.trial();
+    MOZ_RELEASE_ASSERT(count == 2);
+  }
+
+  {
+    bernoulli.setProbability(0.85);
+    size_t count = 0;
+    for (size_t i = 0; i < 1000; i++)
+      count += bernoulli.trial();
+    MOZ_RELEASE_ASSERT(count == 852);
+  }
+
+  bernoulli.setProbability(0.0);
+  for (size_t i = 0; i < 100; i++)
+    MOZ_RELEASE_ASSERT(!bernoulli.trial());
+}
+
+static void
+TestHarmonics()
+{
+  mozilla::FastBernoulliTrial bernoulli(0.1,
+                                        698079309544035222ULL,
+                                        6012389156611637584ULL);
+
+  const size_t n = 100000;
+  bool trials[n];
+  for (size_t i = 0; i < n; i++)
+    trials[i] = bernoulli.trial();
+
+  // For each harmonic and phase, check that the proportion sampled is
+  // within acceptable bounds.
+  for (size_t harmonic = 1; harmonic < 20; harmonic++) {
+    size_t expected = n / harmonic / 10;
+    size_t low_expected = expected * 85 / 100;
+    size_t high_expected = expected * 115 / 100;
+
+    for (size_t phase = 0; phase < harmonic; phase++) {
+      size_t count = 0;
+      for (size_t i = phase; i < n; i += harmonic)
+        count += trials[i];
+
+      MOZ_RELEASE_ASSERT(low_expected <= count && count <= high_expected);
+    }
+  }
+}
+
+static void
+TestTrialN()
+{
+  mozilla::FastBernoulliTrial bernoulli(0.01,
+                                        0x67ff17e25d855942ULL,
+                                        0x74f298193fe1c5b1ULL);
+
+  {
+    size_t count = 0;
+    for (size_t i = 0; i < 10000; i++)
+      count += bernoulli.trial(1);
+
+    // Expected value: 0.01 * 10000 == 100
+    MOZ_RELEASE_ASSERT(count == 97);
+  }
+
+  {
+    size_t count = 0;
+    for (size_t i = 0; i < 10000; i++)
+      count += bernoulli.trial(3);
+
+    // Expected value: (1 - (1 - 0.01) ** 3) == 0.0297,
+    // 0.0297 * 10000 == 297
+    MOZ_RELEASE_ASSERT(count == 304);
+  }
+
+  {
+    size_t count = 0;
+    for (size_t i = 0; i < 10000; i++)
+      count += bernoulli.trial(10);
+
+    // Expected value: (1 - (1 - 0.01) ** 10) == 0.0956,
+    // 0.0956 * 10000 == 956
+    MOZ_RELEASE_ASSERT(count == 936);
+  }
+
+  {
+    size_t count = 0;
+    for (size_t i = 0; i < 10000; i++)
+      count += bernoulli.trial(100);
+
+    // Expected value: (1 - (1 - 0.01) ** 100) == 0.6339
+    // 0.6339 * 10000 == 6339
+    MOZ_RELEASE_ASSERT(count == 6372);
+  }
+
+  {
+    size_t count = 0;
+    for (size_t i = 0; i < 10000; i++)
+      count += bernoulli.trial(1000);
+
+    // Expected value: (1 - (1 - 0.01) ** 1000) == 0.9999
+    // 0.9999 * 10000 == 9999
+    MOZ_RELEASE_ASSERT(count == 9998);
+  }
+}
+
+static void
+TestChangeProbability()
+{
+  mozilla::FastBernoulliTrial bernoulli(1.0,
+                                        0x67ff17e25d855942ULL,
+                                        0x74f298193fe1c5b1ULL);
+
+  // Establish a very high skip count.
+  bernoulli.setProbability(0.0);
+
+  // This should re-establish a zero skip count.
+  bernoulli.setProbability(1.0);
+
+  // So this should return true.
+  MOZ_RELEASE_ASSERT(bernoulli.trial());
+}
+
+static void
+TestCuspProbabilities()
+{
+  /*
+   * FastBernoulliTrial takes care to avoid screwing up on edge cases. The
+   * checks here all look pretty dumb, but they exercise paths in the code that
+   * could exhibit undefined behavior if coded naïvely.
+   */
+
+  /*
+   * This should not be perceptibly different from 1; for 64-bit doubles, this
+   * is a one in ten trillion chance of the trial not succeeding. Overflows
+   * converting doubles to size_t skip counts may change this, though.
+   */
+  mozilla::FastBernoulliTrial bernoulli(nextafter(1, 0),
+                                        0x67ff17e25d855942ULL,
+                                        0x74f298193fe1c5b1ULL);
+
+  for (size_t i = 0; i < 1000; i++)
+    MOZ_RELEASE_ASSERT(bernoulli.trial());
+
+  /*
+   * This should not be perceptibly different from 0; for 64-bit doubles,
+   * the FastBernoulliTrial will actually treat this as exactly zero.
+   */
+  bernoulli.setProbability(nextafter(0, 1));
+  for (size_t i = 0; i < 1000; i++)
+    MOZ_RELEASE_ASSERT(!bernoulli.trial());
+
+  /*
+   * This should be a vanishingly low probability which FastBernoulliTrial does
+   * *not* treat as exactly zero.
+   */
+  bernoulli.setProbability(1 - nextafter(1, 0));
+  for (size_t i = 0; i < 1000; i++)
+    MOZ_RELEASE_ASSERT(!bernoulli.trial());
+}
+
+int
+main()
+{
+  TestProportions();
+  TestHarmonics();
+  TestTrialN();
+  TestChangeProbability();
+  TestCuspProbabilities();
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestFloatingPoint.cpp b/src/third_party/mozjs-45/mfbt/tests/TestFloatingPoint.cpp
new file mode 100644
index 0000000..7f5bf90
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestFloatingPoint.cpp
@@ -0,0 +1,579 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/FloatingPoint.h"
+
+#include <math.h>
+
+using mozilla::ExponentComponent;
+using mozilla::FloatingPoint;
+using mozilla::FuzzyEqualsAdditive;
+using mozilla::FuzzyEqualsMultiplicative;
+using mozilla::IsFinite;
+using mozilla::IsInfinite;
+using mozilla::IsNaN;
+using mozilla::IsNegative;
+using mozilla::IsNegativeZero;
+using mozilla::NegativeInfinity;
+using mozilla::NumberEqualsInt32;
+using mozilla::NumberIsInt32;
+using mozilla::NumbersAreIdentical;
+using mozilla::PositiveInfinity;
+using mozilla::SpecificNaN;
+using mozilla::UnspecifiedNaN;
+
+#define A(a) MOZ_RELEASE_ASSERT(a)
+
+template<typename T>
+static void
+ShouldBeIdentical(T aD1, T aD2)
+{
+  A(NumbersAreIdentical(aD1, aD2));
+  A(NumbersAreIdentical(aD2, aD1));
+}
+
+template<typename T>
+static void
+ShouldNotBeIdentical(T aD1, T aD2)
+{
+  A(!NumbersAreIdentical(aD1, aD2));
+  A(!NumbersAreIdentical(aD2, aD1));
+}
+
+static void
+TestDoublesAreIdentical()
+{
+  ShouldBeIdentical(+0.0, +0.0);
+  ShouldBeIdentical(-0.0, -0.0);
+  ShouldNotBeIdentical(+0.0, -0.0);
+
+  ShouldBeIdentical(1.0, 1.0);
+  ShouldNotBeIdentical(-1.0, 1.0);
+  ShouldBeIdentical(4294967295.0, 4294967295.0);
+  ShouldNotBeIdentical(-4294967295.0, 4294967295.0);
+  ShouldBeIdentical(4294967296.0, 4294967296.0);
+  ShouldBeIdentical(4294967297.0, 4294967297.0);
+  ShouldBeIdentical(1e300, 1e300);
+
+  ShouldBeIdentical(PositiveInfinity<double>(), PositiveInfinity<double>());
+  ShouldBeIdentical(NegativeInfinity<double>(), NegativeInfinity<double>());
+  ShouldNotBeIdentical(PositiveInfinity<double>(), NegativeInfinity<double>());
+
+  ShouldNotBeIdentical(-0.0, NegativeInfinity<double>());
+  ShouldNotBeIdentical(+0.0, NegativeInfinity<double>());
+  ShouldNotBeIdentical(1e300, NegativeInfinity<double>());
+  ShouldNotBeIdentical(3.141592654, NegativeInfinity<double>());
+
+  ShouldBeIdentical(UnspecifiedNaN<double>(), UnspecifiedNaN<double>());
+  ShouldBeIdentical(-UnspecifiedNaN<double>(), UnspecifiedNaN<double>());
+  ShouldBeIdentical(UnspecifiedNaN<double>(), -UnspecifiedNaN<double>());
+
+  ShouldBeIdentical(SpecificNaN<double>(0, 17), SpecificNaN<double>(0, 42));
+  ShouldBeIdentical(SpecificNaN<double>(1, 17), SpecificNaN<double>(1, 42));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17), SpecificNaN<double>(1, 42));
+  ShouldBeIdentical(SpecificNaN<double>(1, 17), SpecificNaN<double>(0, 42));
+
+  const uint64_t Mask = 0xfffffffffffffULL;
+  for (unsigned i = 0; i < 52; i++) {
+    for (unsigned j = 0; j < 52; j++) {
+      for (unsigned sign = 0; i < 2; i++) {
+        ShouldBeIdentical(SpecificNaN<double>(0, 1ULL << i),
+                          SpecificNaN<double>(sign, 1ULL << j));
+        ShouldBeIdentical(SpecificNaN<double>(1, 1ULL << i),
+                          SpecificNaN<double>(sign, 1ULL << j));
+
+        ShouldBeIdentical(SpecificNaN<double>(0, Mask & ~(1ULL << i)),
+                          SpecificNaN<double>(sign, Mask & ~(1ULL << j)));
+        ShouldBeIdentical(SpecificNaN<double>(1, Mask & ~(1ULL << i)),
+                          SpecificNaN<double>(sign, Mask & ~(1ULL << j)));
+      }
+    }
+  }
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x8000000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x4000000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x2000000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x1000000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x0800000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x0400000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x0200000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x0100000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x0080000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x0040000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x0020000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(0, 17),
+                    SpecificNaN<double>(0, 0x0010000000000ULL));
+  ShouldBeIdentical(SpecificNaN<double>(1, 17),
+                    SpecificNaN<double>(0, 0xff0ffffffffffULL));
+  ShouldBeIdentical(SpecificNaN<double>(1, 17),
+                    SpecificNaN<double>(0, 0xfffffffffff0fULL));
+
+  ShouldNotBeIdentical(UnspecifiedNaN<double>(), +0.0);
+  ShouldNotBeIdentical(UnspecifiedNaN<double>(), -0.0);
+  ShouldNotBeIdentical(UnspecifiedNaN<double>(), 1.0);
+  ShouldNotBeIdentical(UnspecifiedNaN<double>(), -1.0);
+  ShouldNotBeIdentical(UnspecifiedNaN<double>(), PositiveInfinity<double>());
+  ShouldNotBeIdentical(UnspecifiedNaN<double>(), NegativeInfinity<double>());
+}
+
+static void
+TestFloatsAreIdentical()
+{
+  ShouldBeIdentical(+0.0f, +0.0f);
+  ShouldBeIdentical(-0.0f, -0.0f);
+  ShouldNotBeIdentical(+0.0f, -0.0f);
+
+  ShouldBeIdentical(1.0f, 1.0f);
+  ShouldNotBeIdentical(-1.0f, 1.0f);
+  ShouldBeIdentical(8388607.0f, 8388607.0f);
+  ShouldNotBeIdentical(-8388607.0f, 8388607.0f);
+  ShouldBeIdentical(8388608.0f, 8388608.0f);
+  ShouldBeIdentical(8388609.0f, 8388609.0f);
+  ShouldBeIdentical(1e36f, 1e36f);
+
+  ShouldBeIdentical(PositiveInfinity<float>(), PositiveInfinity<float>());
+  ShouldBeIdentical(NegativeInfinity<float>(), NegativeInfinity<float>());
+  ShouldNotBeIdentical(PositiveInfinity<float>(), NegativeInfinity<float>());
+
+  ShouldNotBeIdentical(-0.0f, NegativeInfinity<float>());
+  ShouldNotBeIdentical(+0.0f, NegativeInfinity<float>());
+  ShouldNotBeIdentical(1e36f, NegativeInfinity<float>());
+  ShouldNotBeIdentical(3.141592654f, NegativeInfinity<float>());
+
+  ShouldBeIdentical(UnspecifiedNaN<float>(), UnspecifiedNaN<float>());
+  ShouldBeIdentical(-UnspecifiedNaN<float>(), UnspecifiedNaN<float>());
+  ShouldBeIdentical(UnspecifiedNaN<float>(), -UnspecifiedNaN<float>());
+
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 42));
+  ShouldBeIdentical(SpecificNaN<float>(1, 17), SpecificNaN<float>(1, 42));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(1, 42));
+  ShouldBeIdentical(SpecificNaN<float>(1, 17), SpecificNaN<float>(0, 42));
+
+  const uint32_t Mask = 0x7fffffUL;
+  for (unsigned i = 0; i < 23; i++) {
+    for (unsigned j = 0; j < 23; j++) {
+      for (unsigned sign = 0; i < 2; i++) {
+        ShouldBeIdentical(SpecificNaN<float>(0, 1UL << i),
+                          SpecificNaN<float>(sign, 1UL << j));
+        ShouldBeIdentical(SpecificNaN<float>(1, 1UL << i),
+                          SpecificNaN<float>(sign, 1UL << j));
+
+        ShouldBeIdentical(SpecificNaN<float>(0, Mask & ~(1UL << i)),
+                          SpecificNaN<float>(sign, Mask & ~(1UL << j)));
+        ShouldBeIdentical(SpecificNaN<float>(1, Mask & ~(1UL << i)),
+                          SpecificNaN<float>(sign, Mask & ~(1UL << j)));
+      }
+    }
+  }
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x700000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x400000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x200000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x100000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x080000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x040000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x020000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x010000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x008000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x004000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x002000));
+  ShouldBeIdentical(SpecificNaN<float>(0, 17), SpecificNaN<float>(0, 0x001000));
+  ShouldBeIdentical(SpecificNaN<float>(1, 17), SpecificNaN<float>(0, 0x7f0fff));
+  ShouldBeIdentical(SpecificNaN<float>(1, 17), SpecificNaN<float>(0, 0x7fff0f));
+
+  ShouldNotBeIdentical(UnspecifiedNaN<float>(), +0.0f);
+  ShouldNotBeIdentical(UnspecifiedNaN<float>(), -0.0f);
+  ShouldNotBeIdentical(UnspecifiedNaN<float>(), 1.0f);
+  ShouldNotBeIdentical(UnspecifiedNaN<float>(), -1.0f);
+  ShouldNotBeIdentical(UnspecifiedNaN<float>(), PositiveInfinity<float>());
+  ShouldNotBeIdentical(UnspecifiedNaN<float>(), NegativeInfinity<float>());
+}
+
+static void
+TestAreIdentical()
+{
+  TestDoublesAreIdentical();
+  TestFloatsAreIdentical();
+}
+
+static void
+TestDoubleExponentComponent()
+{
+  A(ExponentComponent(0.0) ==
+    -int_fast16_t(FloatingPoint<double>::kExponentBias));
+  A(ExponentComponent(-0.0) ==
+    -int_fast16_t(FloatingPoint<double>::kExponentBias));
+  A(ExponentComponent(0.125) == -3);
+  A(ExponentComponent(0.5) == -1);
+  A(ExponentComponent(1.0) == 0);
+  A(ExponentComponent(1.5) == 0);
+  A(ExponentComponent(2.0) == 1);
+  A(ExponentComponent(7.0) == 2);
+  A(ExponentComponent(PositiveInfinity<double>()) ==
+    FloatingPoint<double>::kExponentBias + 1);
+  A(ExponentComponent(NegativeInfinity<double>()) ==
+    FloatingPoint<double>::kExponentBias + 1);
+  A(ExponentComponent(UnspecifiedNaN<double>()) ==
+    FloatingPoint<double>::kExponentBias + 1);
+}
+
+static void
+TestFloatExponentComponent()
+{
+  A(ExponentComponent(0.0f) ==
+    -int_fast16_t(FloatingPoint<float>::kExponentBias));
+  A(ExponentComponent(-0.0f) ==
+    -int_fast16_t(FloatingPoint<float>::kExponentBias));
+  A(ExponentComponent(0.125f) == -3);
+  A(ExponentComponent(0.5f) == -1);
+  A(ExponentComponent(1.0f) == 0);
+  A(ExponentComponent(1.5f) == 0);
+  A(ExponentComponent(2.0f) == 1);
+  A(ExponentComponent(7.0f) == 2);
+  A(ExponentComponent(PositiveInfinity<float>()) ==
+    FloatingPoint<float>::kExponentBias + 1);
+  A(ExponentComponent(NegativeInfinity<float>()) ==
+    FloatingPoint<float>::kExponentBias + 1);
+  A(ExponentComponent(UnspecifiedNaN<float>()) ==
+    FloatingPoint<float>::kExponentBias + 1);
+}
+
+static void
+TestExponentComponent()
+{
+  TestDoubleExponentComponent();
+  TestFloatExponentComponent();
+}
+
+static void
+TestDoublesPredicates()
+{
+  A(IsNaN(UnspecifiedNaN<double>()));
+  A(IsNaN(SpecificNaN<double>(1, 17)));;
+  A(IsNaN(SpecificNaN<double>(0, 0xfffffffffff0fULL)));
+  A(!IsNaN(0.0));
+  A(!IsNaN(-0.0));
+  A(!IsNaN(1.0));
+  A(!IsNaN(PositiveInfinity<double>()));
+  A(!IsNaN(NegativeInfinity<double>()));
+
+  A(IsInfinite(PositiveInfinity<double>()));
+  A(IsInfinite(NegativeInfinity<double>()));
+  A(!IsInfinite(UnspecifiedNaN<double>()));
+  A(!IsInfinite(0.0));
+  A(!IsInfinite(-0.0));
+  A(!IsInfinite(1.0));
+
+  A(!IsFinite(PositiveInfinity<double>()));
+  A(!IsFinite(NegativeInfinity<double>()));
+  A(!IsFinite(UnspecifiedNaN<double>()));
+  A(IsFinite(0.0));
+  A(IsFinite(-0.0));
+  A(IsFinite(1.0));
+
+  A(!IsNegative(PositiveInfinity<double>()));
+  A(IsNegative(NegativeInfinity<double>()));
+  A(IsNegative(-0.0));
+  A(!IsNegative(0.0));
+  A(IsNegative(-1.0));
+  A(!IsNegative(1.0));
+
+  A(!IsNegativeZero(PositiveInfinity<double>()));
+  A(!IsNegativeZero(NegativeInfinity<double>()));
+  A(!IsNegativeZero(SpecificNaN<double>(1, 17)));;
+  A(!IsNegativeZero(SpecificNaN<double>(1, 0xfffffffffff0fULL)));
+  A(!IsNegativeZero(SpecificNaN<double>(0, 17)));;
+  A(!IsNegativeZero(SpecificNaN<double>(0, 0xfffffffffff0fULL)));
+  A(!IsNegativeZero(UnspecifiedNaN<double>()));
+  A(IsNegativeZero(-0.0));
+  A(!IsNegativeZero(0.0));
+  A(!IsNegativeZero(-1.0));
+  A(!IsNegativeZero(1.0));
+
+  int32_t i;
+  A(NumberIsInt32(0.0, &i));
+  A(i == 0);
+  A(!NumberIsInt32(-0.0, &i));
+  A(NumberEqualsInt32(0.0, &i));
+  A(i == 0);
+  A(NumberEqualsInt32(-0.0, &i));
+  A(i == 0);
+  A(NumberIsInt32(double(INT32_MIN), &i));
+  A(i == INT32_MIN);
+  A(NumberIsInt32(double(INT32_MAX), &i));
+  A(i == INT32_MAX);
+  A(NumberEqualsInt32(double(INT32_MIN), &i));
+  A(i == INT32_MIN);
+  A(NumberEqualsInt32(double(INT32_MAX), &i));
+  A(i == INT32_MAX);
+  A(!NumberIsInt32(0.5, &i));
+  A(!NumberIsInt32(double(INT32_MAX) + 0.1, &i));
+  A(!NumberIsInt32(double(INT32_MIN) - 0.1, &i));
+  A(!NumberIsInt32(NegativeInfinity<double>(), &i));
+  A(!NumberIsInt32(PositiveInfinity<double>(), &i));
+  A(!NumberIsInt32(UnspecifiedNaN<double>(), &i));
+  A(!NumberEqualsInt32(0.5, &i));
+  A(!NumberEqualsInt32(double(INT32_MAX) + 0.1, &i));
+  A(!NumberEqualsInt32(double(INT32_MIN) - 0.1, &i));
+  A(!NumberEqualsInt32(NegativeInfinity<double>(), &i));
+  A(!NumberEqualsInt32(PositiveInfinity<double>(), &i));
+  A(!NumberEqualsInt32(UnspecifiedNaN<double>(), &i));
+}
+
+static void
+TestFloatsPredicates()
+{
+  A(IsNaN(UnspecifiedNaN<float>()));
+  A(IsNaN(SpecificNaN<float>(1, 17)));;
+  A(IsNaN(SpecificNaN<float>(0, 0x7fff0fUL)));
+  A(!IsNaN(0.0f));
+  A(!IsNaN(-0.0f));
+  A(!IsNaN(1.0f));
+  A(!IsNaN(PositiveInfinity<float>()));
+  A(!IsNaN(NegativeInfinity<float>()));
+
+  A(IsInfinite(PositiveInfinity<float>()));
+  A(IsInfinite(NegativeInfinity<float>()));
+  A(!IsInfinite(UnspecifiedNaN<float>()));
+  A(!IsInfinite(0.0f));
+  A(!IsInfinite(-0.0f));
+  A(!IsInfinite(1.0f));
+
+  A(!IsFinite(PositiveInfinity<float>()));
+  A(!IsFinite(NegativeInfinity<float>()));
+  A(!IsFinite(UnspecifiedNaN<float>()));
+  A(IsFinite(0.0f));
+  A(IsFinite(-0.0f));
+  A(IsFinite(1.0f));
+
+  A(!IsNegative(PositiveInfinity<float>()));
+  A(IsNegative(NegativeInfinity<float>()));
+  A(IsNegative(-0.0f));
+  A(!IsNegative(0.0f));
+  A(IsNegative(-1.0f));
+  A(!IsNegative(1.0f));
+
+  A(!IsNegativeZero(PositiveInfinity<float>()));
+  A(!IsNegativeZero(NegativeInfinity<float>()));
+  A(!IsNegativeZero(SpecificNaN<float>(1, 17)));;
+  A(!IsNegativeZero(SpecificNaN<float>(1, 0x7fff0fUL)));
+  A(!IsNegativeZero(SpecificNaN<float>(0, 17)));;
+  A(!IsNegativeZero(SpecificNaN<float>(0, 0x7fff0fUL)));
+  A(!IsNegativeZero(UnspecifiedNaN<float>()));
+  A(IsNegativeZero(-0.0f));
+  A(!IsNegativeZero(0.0f));
+  A(!IsNegativeZero(-1.0f));
+  A(!IsNegativeZero(1.0f));
+
+  int32_t i;
+  const int32_t BIG = 2097151;
+  A(NumberIsInt32(0.0f, &i));
+  A(i == 0);
+  A(!NumberIsInt32(-0.0f, &i));
+  A(NumberEqualsInt32(0.0f, &i));
+  A(i == 0);
+  A(NumberEqualsInt32(-0.0f, &i));
+  A(i == 0);
+  A(NumberIsInt32(float(INT32_MIN), &i));
+  A(i == INT32_MIN);
+  A(NumberIsInt32(float(BIG), &i));
+  A(i == BIG);
+  A(NumberEqualsInt32(float(INT32_MIN), &i));
+  A(i == INT32_MIN);
+  A(NumberEqualsInt32(float(BIG), &i));
+  A(i == BIG);
+  A(!NumberIsInt32(0.5f, &i));
+  A(!NumberIsInt32(float(BIG) + 0.1f, &i));
+  A(!NumberIsInt32(NegativeInfinity<float>(), &i));
+  A(!NumberIsInt32(PositiveInfinity<float>(), &i));
+  A(!NumberIsInt32(UnspecifiedNaN<float>(), &i));
+  A(!NumberEqualsInt32(0.5f, &i));
+  A(!NumberEqualsInt32(float(BIG) + 0.1f, &i));
+  A(!NumberEqualsInt32(NegativeInfinity<float>(), &i));
+  A(!NumberEqualsInt32(PositiveInfinity<float>(), &i));
+  A(!NumberEqualsInt32(UnspecifiedNaN<float>(), &i));
+}
+
+static void
+TestPredicates()
+{
+  TestFloatsPredicates();
+  TestDoublesPredicates();
+}
+
+static void
+TestFloatsAreApproximatelyEqual()
+{
+  float epsilon = mozilla::detail::FuzzyEqualsEpsilon<float>::value();
+  float lessThanEpsilon = epsilon / 2.0f;
+  float moreThanEpsilon = epsilon * 2.0f;
+
+  // Additive tests using the default epsilon
+  // ... around 1.0
+  A(FuzzyEqualsAdditive(1.0f, 1.0f + lessThanEpsilon));
+  A(FuzzyEqualsAdditive(1.0f, 1.0f - lessThanEpsilon));
+  A(FuzzyEqualsAdditive(1.0f, 1.0f + epsilon));
+  A(FuzzyEqualsAdditive(1.0f, 1.0f - epsilon));
+  A(!FuzzyEqualsAdditive(1.0f, 1.0f + moreThanEpsilon));
+  A(!FuzzyEqualsAdditive(1.0f, 1.0f - moreThanEpsilon));
+  // ... around 1.0e2 (this is near the upper bound of the range where
+  // adding moreThanEpsilon will still be representable and return false)
+  A(FuzzyEqualsAdditive(1.0e2f, 1.0e2f + lessThanEpsilon));
+  A(FuzzyEqualsAdditive(1.0e2f, 1.0e2f + epsilon));
+  A(!FuzzyEqualsAdditive(1.0e2f, 1.0e2f + moreThanEpsilon));
+  // ... around 1.0e-10
+  A(FuzzyEqualsAdditive(1.0e-10f, 1.0e-10f + lessThanEpsilon));
+  A(FuzzyEqualsAdditive(1.0e-10f, 1.0e-10f + epsilon));
+  A(!FuzzyEqualsAdditive(1.0e-10f, 1.0e-10f + moreThanEpsilon));
+  // ... straddling 0
+  A(FuzzyEqualsAdditive(1.0e-6f, -1.0e-6f));
+  A(!FuzzyEqualsAdditive(1.0e-5f, -1.0e-5f));
+  // Using a small epsilon
+  A(FuzzyEqualsAdditive(1.0e-5f, 1.0e-5f + 1.0e-10f, 1.0e-9f));
+  A(!FuzzyEqualsAdditive(1.0e-5f, 1.0e-5f + 1.0e-10f, 1.0e-11f));
+  // Using a big epsilon
+  A(FuzzyEqualsAdditive(1.0e20f, 1.0e20f + 1.0e15f, 1.0e16f));
+  A(!FuzzyEqualsAdditive(1.0e20f, 1.0e20f + 1.0e15f, 1.0e14f));
+
+  // Multiplicative tests using the default epsilon
+  // ... around 1.0
+  A(FuzzyEqualsMultiplicative(1.0f, 1.0f + lessThanEpsilon));
+  A(FuzzyEqualsMultiplicative(1.0f, 1.0f - lessThanEpsilon));
+  A(FuzzyEqualsMultiplicative(1.0f, 1.0f + epsilon));
+  A(!FuzzyEqualsMultiplicative(1.0f, 1.0f - epsilon));
+  A(!FuzzyEqualsMultiplicative(1.0f, 1.0f + moreThanEpsilon));
+  A(!FuzzyEqualsMultiplicative(1.0f, 1.0f - moreThanEpsilon));
+  // ... around 1.0e10
+  A(FuzzyEqualsMultiplicative(1.0e10f, 1.0e10f + (lessThanEpsilon * 1.0e10f)));
+  A(!FuzzyEqualsMultiplicative(1.0e10f, 1.0e10f + (moreThanEpsilon * 1.0e10f)));
+  // ... around 1.0e-10
+  A(FuzzyEqualsMultiplicative(1.0e-10f,
+                              1.0e-10f + (lessThanEpsilon * 1.0e-10f)));
+  A(!FuzzyEqualsMultiplicative(1.0e-10f,
+                               1.0e-10f + (moreThanEpsilon * 1.0e-10f)));
+  // ... straddling 0
+  A(!FuzzyEqualsMultiplicative(1.0e-6f, -1.0e-6f));
+  A(FuzzyEqualsMultiplicative(1.0e-6f, -1.0e-6f, 1.0e2f));
+  // Using a small epsilon
+  A(FuzzyEqualsMultiplicative(1.0e-5f, 1.0e-5f + 1.0e-10f, 1.0e-4f));
+  A(!FuzzyEqualsMultiplicative(1.0e-5f, 1.0e-5f + 1.0e-10f, 1.0e-5f));
+  // Using a big epsilon
+  A(FuzzyEqualsMultiplicative(1.0f, 2.0f, 1.0f));
+  A(!FuzzyEqualsMultiplicative(1.0f, 2.0f, 0.1f));
+
+  // "real world case"
+  float oneThird = 10.0f / 3.0f;
+  A(FuzzyEqualsAdditive(10.0f, 3.0f * oneThird));
+  A(FuzzyEqualsMultiplicative(10.0f, 3.0f * oneThird));
+  // NaN check
+  A(!FuzzyEqualsAdditive(SpecificNaN<float>(1, 1), SpecificNaN<float>(1, 1)));
+  A(!FuzzyEqualsAdditive(SpecificNaN<float>(1, 2), SpecificNaN<float>(0, 8)));
+  A(!FuzzyEqualsMultiplicative(SpecificNaN<float>(1, 1),
+                               SpecificNaN<float>(1, 1)));
+  A(!FuzzyEqualsMultiplicative(SpecificNaN<float>(1, 2),
+                               SpecificNaN<float>(0, 200)));
+}
+
+static void
+TestDoublesAreApproximatelyEqual()
+{
+  double epsilon = mozilla::detail::FuzzyEqualsEpsilon<double>::value();
+  double lessThanEpsilon = epsilon / 2.0;
+  double moreThanEpsilon = epsilon * 2.0;
+
+  // Additive tests using the default epsilon
+  // ... around 1.0
+  A(FuzzyEqualsAdditive(1.0, 1.0 + lessThanEpsilon));
+  A(FuzzyEqualsAdditive(1.0, 1.0 - lessThanEpsilon));
+  A(FuzzyEqualsAdditive(1.0, 1.0 + epsilon));
+  A(FuzzyEqualsAdditive(1.0, 1.0 - epsilon));
+  A(!FuzzyEqualsAdditive(1.0, 1.0 + moreThanEpsilon));
+  A(!FuzzyEqualsAdditive(1.0, 1.0 - moreThanEpsilon));
+  // ... around 1.0e4 (this is near the upper bound of the range where
+  // adding moreThanEpsilon will still be representable and return false)
+  A(FuzzyEqualsAdditive(1.0e4, 1.0e4 + lessThanEpsilon));
+  A(FuzzyEqualsAdditive(1.0e4, 1.0e4 + epsilon));
+  A(!FuzzyEqualsAdditive(1.0e4, 1.0e4 + moreThanEpsilon));
+  // ... around 1.0e-25
+  A(FuzzyEqualsAdditive(1.0e-25, 1.0e-25 + lessThanEpsilon));
+  A(FuzzyEqualsAdditive(1.0e-25, 1.0e-25 + epsilon));
+  A(!FuzzyEqualsAdditive(1.0e-25, 1.0e-25 + moreThanEpsilon));
+  // ... straddling 0
+  A(FuzzyEqualsAdditive(1.0e-13, -1.0e-13));
+  A(!FuzzyEqualsAdditive(1.0e-12, -1.0e-12));
+  // Using a small epsilon
+  A(FuzzyEqualsAdditive(1.0e-15, 1.0e-15 + 1.0e-30, 1.0e-29));
+  A(!FuzzyEqualsAdditive(1.0e-15, 1.0e-15 + 1.0e-30, 1.0e-31));
+  // Using a big epsilon
+  A(FuzzyEqualsAdditive(1.0e40, 1.0e40 + 1.0e25, 1.0e26));
+  A(!FuzzyEqualsAdditive(1.0e40, 1.0e40 + 1.0e25, 1.0e24));
+
+  // Multiplicative tests using the default epsilon
+  // ... around 1.0
+  A(FuzzyEqualsMultiplicative(1.0, 1.0 + lessThanEpsilon));
+  A(FuzzyEqualsMultiplicative(1.0, 1.0 - lessThanEpsilon));
+  A(FuzzyEqualsMultiplicative(1.0, 1.0 + epsilon));
+  A(!FuzzyEqualsMultiplicative(1.0, 1.0 - epsilon));
+  A(!FuzzyEqualsMultiplicative(1.0, 1.0 + moreThanEpsilon));
+  A(!FuzzyEqualsMultiplicative(1.0, 1.0 - moreThanEpsilon));
+  // ... around 1.0e30
+  A(FuzzyEqualsMultiplicative(1.0e30, 1.0e30 + (lessThanEpsilon * 1.0e30)));
+  A(!FuzzyEqualsMultiplicative(1.0e30, 1.0e30 + (moreThanEpsilon * 1.0e30)));
+  // ... around 1.0e-30
+  A(FuzzyEqualsMultiplicative(1.0e-30, 1.0e-30 + (lessThanEpsilon * 1.0e-30)));
+  A(!FuzzyEqualsMultiplicative(1.0e-30, 1.0e-30 + (moreThanEpsilon * 1.0e-30)));
+  // ... straddling 0
+  A(!FuzzyEqualsMultiplicative(1.0e-6, -1.0e-6));
+  A(FuzzyEqualsMultiplicative(1.0e-6, -1.0e-6, 1.0e2));
+  // Using a small epsilon
+  A(FuzzyEqualsMultiplicative(1.0e-15, 1.0e-15 + 1.0e-30, 1.0e-15));
+  A(!FuzzyEqualsMultiplicative(1.0e-15, 1.0e-15 + 1.0e-30, 1.0e-16));
+  // Using a big epsilon
+  A(FuzzyEqualsMultiplicative(1.0e40, 2.0e40, 1.0));
+  A(!FuzzyEqualsMultiplicative(1.0e40, 2.0e40, 0.1));
+
+  // "real world case"
+  double oneThird = 10.0 / 3.0;
+  A(FuzzyEqualsAdditive(10.0, 3.0 * oneThird));
+  A(FuzzyEqualsMultiplicative(10.0, 3.0 * oneThird));
+  // NaN check
+  A(!FuzzyEqualsAdditive(SpecificNaN<double>(1, 1),
+                         SpecificNaN<double>(1, 1)));
+  A(!FuzzyEqualsAdditive(SpecificNaN<double>(1, 2),
+                         SpecificNaN<double>(0, 8)));
+  A(!FuzzyEqualsMultiplicative(SpecificNaN<double>(1, 1),
+                               SpecificNaN<double>(1, 1)));
+  A(!FuzzyEqualsMultiplicative(SpecificNaN<double>(1, 2),
+                               SpecificNaN<double>(0, 200)));
+}
+
+static void
+TestAreApproximatelyEqual()
+{
+  TestFloatsAreApproximatelyEqual();
+  TestDoublesAreApproximatelyEqual();
+}
+
+#undef A
+
+int
+main()
+{
+  TestAreIdentical();
+  TestExponentComponent();
+  TestPredicates();
+  TestAreApproximatelyEqual();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestFunction.cpp b/src/third_party/mozjs-45/mfbt/tests/TestFunction.cpp
new file mode 100644
index 0000000..6074fab
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestFunction.cpp
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+   /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Function.h"
+
+using mozilla::Function;
+
+#define CHECK(c) \
+  do { \
+    bool cond = !!(c); \
+    MOZ_RELEASE_ASSERT(cond, "Failed assertion: " #c); \
+  } while (false)
+
+struct ConvertibleToInt
+{
+  operator int() const { return 42; }
+};
+
+int increment(int arg) { return arg + 1; }
+
+struct S {
+  S() {}
+  static int increment(int arg) { return arg + 1; }
+  int decrement(int arg) { return arg - 1;}
+  int sum(int arg1, int arg2) const { return arg1 + arg2;}
+};
+
+struct Incrementor {
+  int operator()(int arg) { return arg + 1; }
+};
+
+static void
+TestNonmemberFunction()
+{
+  Function<int(int)> f = &increment;
+  CHECK(f(42) == 43);
+}
+
+static void
+TestStaticMemberFunction()
+{
+  Function<int(int)> f = &S::increment;
+  CHECK(f(42) == 43);
+}
+
+static void
+TestFunctionObject()
+{
+  Function<int(int)> f = Incrementor();
+  CHECK(f(42) == 43);
+}
+
+static void
+TestLambda()
+{
+  // Test non-capturing lambda
+  Function<int(int)> f = [](int arg){ return arg + 1; };
+  CHECK(f(42) == 43);
+
+  // Test capturing lambda
+  int one = 1;
+  Function<int(int)> g = [one](int arg){ return arg + one; };
+  CHECK(g(42) == 43);
+}
+
+static void
+TestDefaultConstructionAndAssignmentLater()
+{
+  Function<int(int)> f;  // allowed
+  // Would get an assertion if we tried calling f now.
+  f = &increment;
+  CHECK(f(42) == 43);
+}
+
+static void
+TestReassignment()
+{
+  Function<int(int)> f = &increment;
+  CHECK(f(42) == 43);
+  f = [](int arg){ return arg + 2; };
+  CHECK(f(42) == 44);
+}
+
+static void
+TestMemberFunction()
+{
+  Function<int(S&, int)> f = &S::decrement;
+  S s;
+  CHECK((f(s, 1) == 0));
+}
+
+static void
+TestConstMemberFunction()
+{
+  Function<int(const S*, int, int)> f = &S::sum;
+  const S s;
+  CHECK((f(&s, 1, 1) == 2));
+}
+int
+main()
+{
+  TestNonmemberFunction();
+  TestStaticMemberFunction();
+  TestFunctionObject();
+  TestLambda();
+  TestDefaultConstructionAndAssignmentLater();
+  TestReassignment();
+  TestMemberFunction();
+  TestConstMemberFunction();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestIntegerPrintfMacros.cpp b/src/third_party/mozjs-45/mfbt/tests/TestIntegerPrintfMacros.cpp
new file mode 100644
index 0000000..d37c066
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestIntegerPrintfMacros.cpp
@@ -0,0 +1,1269 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/IntegerPrintfMacros.h" // this must pick up <stdint.h>
+#include "mozilla/Snprintf.h"
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Output array and poisoning method shared by all tests. */
+static char gOutput[32];
+
+static void
+PoisonOutput()
+{
+  memset(gOutput, 0xDA, sizeof(gOutput));
+}
+
+/*
+ * The fprintf macros for signed integers are:
+ *
+ *   PRIdN   PRIdLEASTN   PRIdFASTN   PRIdMAX   PRIdPTR
+ *   PRIiN   PRIiLEASTN   PRIiFASTN   PRIiMAX   PRIiPTR
+ *
+ * In these names N is the width of the type as described in C99 7.18.1.
+ */
+
+static void
+TestPrintSigned8()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRId8, int8_t(-17));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-17"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIi8, int8_t(42));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
+}
+
+static void
+TestPrintSigned16()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRId16, int16_t(-289));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-289"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIi16, int16_t(728));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "728"));
+}
+
+static void
+TestPrintSigned32()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRId32, int32_t(-342178));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-342178"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIi32, int32_t(5719283));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "5719283"));
+}
+
+static void
+TestPrintSigned64()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRId64, int64_t(-INT64_C(432157943248732)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-432157943248732"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIi64, int64_t(INT64_C(325719232983)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
+}
+
+static void
+TestPrintSignedN()
+{
+  TestPrintSigned8();
+  TestPrintSigned16();
+  TestPrintSigned32();
+  TestPrintSigned64();
+}
+
+static void
+TestPrintSignedLeast8()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdLEAST8, int_least8_t(-17));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-17"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiLEAST8, int_least8_t(42));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
+}
+
+static void
+TestPrintSignedLeast16()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdLEAST16, int_least16_t(-289));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-289"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiLEAST16, int_least16_t(728));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "728"));
+}
+
+static void
+TestPrintSignedLeast32()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdLEAST32, int_least32_t(-342178));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-342178"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiLEAST32, int_least32_t(5719283));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "5719283"));
+}
+
+static void
+TestPrintSignedLeast64()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdLEAST64, int_least64_t(-INT64_C(432157943248732)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-432157943248732"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiLEAST64, int_least64_t(INT64_C(325719232983)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
+}
+
+static void
+TestPrintSignedLeastN()
+{
+  TestPrintSignedLeast8();
+  TestPrintSignedLeast16();
+  TestPrintSignedLeast32();
+  TestPrintSignedLeast64();
+}
+
+static void
+TestPrintSignedFast8()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdFAST8, int_fast8_t(-17));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-17"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiFAST8, int_fast8_t(42));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
+}
+
+static void
+TestPrintSignedFast16()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdFAST16, int_fast16_t(-289));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-289"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiFAST16, int_fast16_t(728));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "728"));
+}
+
+static void
+TestPrintSignedFast32()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdFAST32, int_fast32_t(-342178));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-342178"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiFAST32, int_fast32_t(5719283));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "5719283"));
+}
+
+static void
+TestPrintSignedFast64()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdFAST64, int_fast64_t(-INT64_C(432157943248732)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-432157943248732"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiFAST64, int_fast64_t(INT64_C(325719232983)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
+}
+
+static void
+TestPrintSignedFastN()
+{
+  TestPrintSignedFast8();
+  TestPrintSignedFast16();
+  TestPrintSignedFast32();
+  TestPrintSignedFast64();
+}
+
+static void
+TestPrintSignedMax()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdMAX, intmax_t(-INTMAX_C(432157943248732)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-432157943248732"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiMAX, intmax_t(INTMAX_C(325719232983)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
+}
+
+static void
+TestPrintSignedPtr()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIdPTR, intptr_t(reinterpret_cast<void*>(12345678)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "12345678"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIiPTR, intptr_t(reinterpret_cast<void*>(87654321)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "87654321"));
+}
+
+static void
+TestPrintSigned()
+{
+  TestPrintSignedN();
+  TestPrintSignedLeastN();
+  TestPrintSignedFastN();
+  TestPrintSignedMax();
+  TestPrintSignedPtr();
+}
+
+/*
+ * The fprintf macros for unsigned integers are:
+ *
+ *   PRIoN   PRIoLEASTN   PRIoFASTN   PRIoMAX   PRIoPTR
+ *   PRIuN   PRIuLEASTN   PRIuFASTN   PRIuMAX   PRIuPTR
+ *   PRIxN   PRIxLEASTN   PRIxFASTN   PRIxMAX   PRIxPTR
+ *   PRIXN   PRIXLEASTN   PRIXFASTN   PRIXMAX   PRIXPTR
+ *
+ * In these names N is the width of the type as described in C99 7.18.1.
+ */
+
+static void
+TestPrintUnsigned8()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIo8, uint8_t(042));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIu8, uint8_t(17));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIx8, uint8_t(0x2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIX8, uint8_t(0xCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CD"));
+}
+
+static void
+TestPrintUnsigned16()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIo16, uint16_t(04242));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIu16, uint16_t(1717));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "1717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIx16, uint16_t(0x2a2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIX16, uint16_t(0xCDCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCD"));
+}
+
+static void
+TestPrintUnsigned32()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIo32, uint32_t(0424242));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIu32, uint32_t(171717));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "171717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIx32, uint32_t(0x2a2a2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIX32, uint32_t(0xCDCDCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCD"));
+}
+
+static void
+TestPrintUnsigned64()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIo64, uint64_t(UINT64_C(0424242424242)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242424242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIu64, uint64_t(UINT64_C(17171717171717171717)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17171717171717171717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIx64, uint64_t(UINT64_C(0x2a2a2a2a2a2a2a)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a2a2a2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIX64, uint64_t(UINT64_C(0xCDCDCDCDCDCD)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCDCDCDCD"));
+}
+
+static void
+TestPrintUnsignedN()
+{
+  TestPrintUnsigned8();
+  TestPrintUnsigned16();
+  TestPrintUnsigned32();
+  TestPrintUnsigned64();
+}
+
+static void
+TestPrintUnsignedLeast8()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoLEAST8, uint_least8_t(042));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuLEAST8, uint_least8_t(17));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxLEAST8, uint_least8_t(0x2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXLEAST8, uint_least8_t(0xCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CD"));
+}
+
+static void
+TestPrintUnsignedLeast16()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoLEAST16, uint_least16_t(04242));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuLEAST16, uint_least16_t(1717));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "1717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxLEAST16, uint_least16_t(0x2a2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXLEAST16, uint_least16_t(0xCDCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCD"));
+}
+
+static void
+TestPrintUnsignedLeast32()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoLEAST32, uint_least32_t(0424242));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuLEAST32, uint_least32_t(171717));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "171717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxLEAST32, uint_least32_t(0x2a2a2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXLEAST32, uint_least32_t(0xCDCDCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCD"));
+}
+
+static void
+TestPrintUnsignedLeast64()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoLEAST64, uint_least64_t(UINT64_C(0424242424242)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242424242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuLEAST64,
+          uint_least64_t(UINT64_C(17171717171717171717)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17171717171717171717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxLEAST64, uint_least64_t(UINT64_C(0x2a2a2a2a2a2a2a)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a2a2a2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXLEAST64, uint_least64_t(UINT64_C(0xCDCDCDCDCDCD)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCDCDCDCD"));
+}
+
+static void
+TestPrintUnsignedLeastN()
+{
+  TestPrintUnsignedLeast8();
+  TestPrintUnsignedLeast16();
+  TestPrintUnsignedLeast32();
+  TestPrintUnsignedLeast64();
+}
+
+static void
+TestPrintUnsignedFast8()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoFAST8, uint_fast8_t(042));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuFAST8, uint_fast8_t(17));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxFAST8, uint_fast8_t(0x2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXFAST8, uint_fast8_t(0xCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CD"));
+}
+
+static void
+TestPrintUnsignedFast16()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoFAST16, uint_fast16_t(04242));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuFAST16, uint_fast16_t(1717));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "1717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxFAST16, uint_fast16_t(0x2a2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXFAST16, uint_fast16_t(0xCDCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCD"));
+}
+
+static void
+TestPrintUnsignedFast32()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoFAST32, uint_fast32_t(0424242));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuFAST32, uint_fast32_t(171717));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "171717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxFAST32, uint_fast32_t(0x2a2a2a));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXFAST32, uint_fast32_t(0xCDCDCD));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCD"));
+}
+
+static void
+TestPrintUnsignedFast64()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoFAST64, uint_fast64_t(UINT64_C(0424242424242)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242424242"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuFAST64,
+          uint_fast64_t(UINT64_C(17171717171717171717)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17171717171717171717"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxFAST64, uint_fast64_t(UINT64_C(0x2a2a2a2a2a2a2a)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a2a2a2a2a"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXFAST64, uint_fast64_t(UINT64_C(0xCDCDCDCDCDCD)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCDCDCDCD"));
+}
+
+static void
+TestPrintUnsignedFastN()
+{
+  TestPrintUnsignedFast8();
+  TestPrintUnsignedFast16();
+  TestPrintUnsignedFast32();
+  TestPrintUnsignedFast64();
+}
+
+static void
+TestPrintUnsignedMax()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoMAX, uintmax_t(UINTMAX_C(432157943248732)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "14220563454333534"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuMAX, uintmax_t(UINTMAX_C(325719232983)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxMAX, uintmax_t(UINTMAX_C(327281321873)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4c337ca791"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXMAX, uintmax_t(UINTMAX_C(912389523743523)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "33DD03D75A323"));
+}
+
+static void
+TestPrintUnsignedPtr()
+{
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIoPTR, uintptr_t(reinterpret_cast<void*>(12345678)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "57060516"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIuPTR, uintptr_t(reinterpret_cast<void*>(87654321)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "87654321"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIxPTR, uintptr_t(reinterpret_cast<void*>(0x4c3a791)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4c3a791"));
+
+  PoisonOutput();
+  snprintf_literal(gOutput, "%" PRIXPTR, uintptr_t(reinterpret_cast<void*>(0xF328DB)));
+  MOZ_RELEASE_ASSERT(!strcmp(gOutput, "F328DB"));
+}
+
+static void
+TestPrintUnsigned()
+{
+  TestPrintUnsignedN();
+  TestPrintUnsignedLeastN();
+  TestPrintUnsignedFastN();
+  TestPrintUnsignedMax();
+  TestPrintUnsignedPtr();
+}
+
+static void
+TestPrint()
+{
+  TestPrintSigned();
+  TestPrintUnsigned();
+}
+
+/*
+ * The fscanf macros for signed integers are:
+ *
+ *   SCNdN   SCNdLEASTN   SCNdFASTN   SCNdMAX   SCNdPTR
+ *   SCNiN   SCNiLEASTN   SCNiFASTN   SCNiMAX   SCNiPTR
+ *
+ * In these names N is the width of the type as described in C99 7.18.1.
+ */
+
+/*
+ * MSVC's scanf is insufficiently powerful to implement all the SCN* macros.
+ * Rather than support some subset of them, we instead support none of them.
+ * See the comment at the top of IntegerPrintfMacros.h.  But in case we ever do
+ * support them, the following tests should adequately test implementation
+ * correctness.  (Indeed, these tests *revealed* MSVC's limitations.)
+ *
+ * That said, even if MSVC ever picks up complete support, we still probably
+ * don't want to support these, because of the undefined-behavior issue noted
+ * further down in the comment atop IntegerPrintfMacros.h.
+ */
+#define SHOULD_TEST_SCANF_MACROS 0
+
+#if SHOULD_TEST_SCANF_MACROS
+
+/*
+ * glibc header definitions for SCN{d,i,o,u,x}{,LEAST,FAST}8 use the "hh" length
+ * modifier, which is new in C99 (and C++11, by reference).  We compile this
+ * file as C++11, so if "hh" is used in these macros, it's standard.  But some
+ * versions of gcc wrongly think it isn't and warn about a "non-standard"
+ * modifier.  And since these tests mostly exist to verify format-macro/type
+ * consistency (particularly through compiler warnings about incorrect formats),
+ * these warnings are unacceptable.  So for now, compile tests for those macros
+ * only if we aren't compiling with gcc.
+ */
+#define SHOULD_TEST_8BIT_FORMAT_MACROS (!(MOZ_IS_GCC))
+
+template<typename T>
+union Input
+{
+  T mI;
+  unsigned char mPun[16];
+};
+
+template<typename T>
+static void
+PoisonInput(Input<T>& aInput)
+{
+  memset(aInput.mPun, 0xDA, sizeof(aInput.mPun));
+}
+
+template<typename T>
+static bool
+ExtraBitsUntouched(const Input<T>& aInput)
+{
+  for (size_t i = sizeof(aInput.mI); i < sizeof(aInput); i++) {
+    if (aInput.mPun[i] != 0xDA) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+static void
+TestScanSigned8()
+{
+#if SHOULD_TEST_8BIT_FORMAT_MACROS
+  Input<int8_t> u;
+
+  PoisonInput(u);
+  sscanf("-17", "%" SCNd8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -17);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("042", "%" SCNi8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 042);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+#endif
+}
+
+static void
+TestScanSigned16()
+{
+  Input<int16_t> u;
+
+  PoisonInput(u);
+  sscanf("-1742", "%" SCNd16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -1742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("04217", "%" SCNi16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 04217);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSigned32()
+{
+  Input<int32_t> u;
+
+  PoisonInput(u);
+  sscanf("-174257", "%" SCNd32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -174257);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("0423571", "%" SCNi32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0423571);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSigned64()
+{
+  Input<int64_t> u;
+
+  PoisonInput(u);
+  sscanf("-17425238927232", "%" SCNd64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -INT64_C(17425238927232));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("042333576571", "%" SCNi64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == INT64_C(042333576571));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSignedN()
+{
+  TestScanSigned8();
+  TestScanSigned16();
+  TestScanSigned32();
+  TestScanSigned64();
+}
+
+static void
+TestScanSignedLeast8()
+{
+#if SHOULD_TEST_8BIT_FORMAT_MACROS
+  Input<int_least8_t> u;
+
+  PoisonInput(u);
+  sscanf("-17", "%" SCNdLEAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -17);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("042", "%" SCNiLEAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 042);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+#endif
+}
+
+static void
+TestScanSignedLeast16()
+{
+  Input<int_least16_t> u;
+
+  PoisonInput(u);
+  sscanf("-1742", "%" SCNdLEAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -1742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("04217", "%" SCNiLEAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 04217);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSignedLeast32()
+{
+  Input<int_least32_t> u;
+
+  PoisonInput(u);
+  sscanf("-174257", "%" SCNdLEAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -174257);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("0423571", "%" SCNiLEAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0423571);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSignedLeast64()
+{
+  Input<int_least64_t> u;
+
+  PoisonInput(u);
+  sscanf("-17425238927232", "%" SCNdLEAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -INT64_C(17425238927232));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("042333576571", "%" SCNiLEAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == INT64_C(042333576571));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSignedLeastN()
+{
+  TestScanSignedLeast8();
+  TestScanSignedLeast16();
+  TestScanSignedLeast32();
+  TestScanSignedLeast64();
+}
+
+static void
+TestScanSignedFast8()
+{
+#if SHOULD_TEST_8BIT_FORMAT_MACROS
+  Input<int_fast8_t> u;
+
+  PoisonInput(u);
+  sscanf("-17", "%" SCNdFAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -17);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("042", "%" SCNiFAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 042);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+#endif
+}
+
+static void
+TestScanSignedFast16()
+{
+  Input<int_fast16_t> u;
+
+  PoisonInput(u);
+  sscanf("-1742", "%" SCNdFAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -1742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("04217", "%" SCNiFAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 04217);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSignedFast32()
+{
+  Input<int_fast32_t> u;
+
+  PoisonInput(u);
+  sscanf("-174257", "%" SCNdFAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -174257);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("0423571", "%" SCNiFAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0423571);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSignedFast64()
+{
+  Input<int_fast64_t> u;
+
+  PoisonInput(u);
+  sscanf("-17425238927232", "%" SCNdFAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -INT64_C(17425238927232));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("042333576571", "%" SCNiFAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == INT64_C(042333576571));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSignedFastN()
+{
+  TestScanSignedFast8();
+  TestScanSignedFast16();
+  TestScanSignedFast32();
+  TestScanSignedFast64();
+}
+
+static void
+TestScanSignedMax()
+{
+  Input<intmax_t> u;
+
+  PoisonInput(u);
+  sscanf("-432157943248732", "%" SCNdMAX, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == -INTMAX_C(432157943248732));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("04233357236571", "%" SCNiMAX, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == INTMAX_C(04233357236571));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSignedPtr()
+{
+  Input<intptr_t> u;
+
+  PoisonInput(u);
+  sscanf("12345678", "%" SCNdPTR, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == intptr_t(reinterpret_cast<void*>(12345678)));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("04233357236", "%" SCNiPTR, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == intptr_t(reinterpret_cast<void*>(04233357236)));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanSigned()
+{
+  TestScanSignedN();
+  TestScanSignedLeastN();
+  TestScanSignedFastN();
+  TestScanSignedMax();
+  TestScanSignedPtr();
+}
+
+/*
+ * The fscanf macros for unsigned integers are:
+ *
+ *   SCNoN   SCNoLEASTN   SCNoFASTN   SCNoMAX   SCNoPTR
+ *   SCNuN   SCNuLEASTN   SCNuFASTN   SCNuMAX   SCNuPTR
+ *   SCNxN   SCNxLEASTN   SCNxFASTN   SCNxMAX   SCNxPTR
+ *
+ * In these names N is the width of the type as described in C99 7.18.1.
+ */
+
+static void
+TestScanUnsigned8()
+{
+#if SHOULD_TEST_8BIT_FORMAT_MACROS
+  Input<uint8_t> u;
+
+  PoisonInput(u);
+  sscanf("17", "%" SCNo8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 017);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("42", "%" SCNu8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 42);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2A", "%" SCNx8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2A);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+#endif
+}
+
+static void
+TestScanUnsigned16()
+{
+  Input<uint16_t> u;
+
+  PoisonInput(u);
+  sscanf("1742", "%" SCNo16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 01742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("4217", "%" SCNu16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 4217);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2ABC", "%" SCNx16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2ABC);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsigned32()
+{
+  Input<uint32_t> u;
+
+  PoisonInput(u);
+  sscanf("17421742", "%" SCNo32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 017421742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("4217867", "%" SCNu32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 4217867);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2ABCBEEF", "%" SCNx32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2ABCBEEF);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsigned64()
+{
+  Input<uint64_t> u;
+
+  PoisonInput(u);
+  sscanf("17421742173", "%" SCNo64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(017421742173));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("421786713579", "%" SCNu64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(421786713579));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("DEADBEEF7457E", "%" SCNx64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(0xDEADBEEF7457E));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsignedN()
+{
+  TestScanUnsigned8();
+  TestScanUnsigned16();
+  TestScanUnsigned32();
+  TestScanUnsigned64();
+}
+
+static void
+TestScanUnsignedLeast8()
+{
+#if SHOULD_TEST_8BIT_FORMAT_MACROS
+  Input<uint_least8_t> u;
+
+  PoisonInput(u);
+  sscanf("17", "%" SCNoLEAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 017);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("42", "%" SCNuLEAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 42);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2A", "%" SCNxLEAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2A);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+#endif
+}
+
+static void
+TestScanUnsignedLeast16()
+{
+  Input<uint_least16_t> u;
+
+  PoisonInput(u);
+  sscanf("1742", "%" SCNoLEAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 01742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("4217", "%" SCNuLEAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 4217);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2ABC", "%" SCNxLEAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2ABC);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsignedLeast32()
+{
+  Input<uint_least32_t> u;
+
+  PoisonInput(u);
+  sscanf("17421742", "%" SCNoLEAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 017421742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("4217867", "%" SCNuLEAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 4217867);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2ABCBEEF", "%" SCNxLEAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2ABCBEEF);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsignedLeast64()
+{
+  Input<uint_least64_t> u;
+
+  PoisonInput(u);
+  sscanf("17421742173", "%" SCNoLEAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(017421742173));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("421786713579", "%" SCNuLEAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(421786713579));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("DEADBEEF7457E", "%" SCNxLEAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(0xDEADBEEF7457E));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsignedLeastN()
+{
+  TestScanUnsignedLeast8();
+  TestScanUnsignedLeast16();
+  TestScanUnsignedLeast32();
+  TestScanUnsignedLeast64();
+}
+
+static void
+TestScanUnsignedFast8()
+{
+#if SHOULD_TEST_8BIT_FORMAT_MACROS
+  Input<uint_fast8_t> u;
+
+  PoisonInput(u);
+  sscanf("17", "%" SCNoFAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 017);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("42", "%" SCNuFAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 42);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2A", "%" SCNxFAST8, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2A);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+#endif
+}
+
+static void
+TestScanUnsignedFast16()
+{
+  Input<uint_fast16_t> u;
+
+  PoisonInput(u);
+  sscanf("1742", "%" SCNoFAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 01742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("4217", "%" SCNuFAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 4217);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2ABC", "%" SCNxFAST16, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2ABC);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsignedFast32()
+{
+  Input<uint_fast32_t> u;
+
+  PoisonInput(u);
+  sscanf("17421742", "%" SCNoFAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 017421742);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("4217867", "%" SCNuFAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 4217867);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("2ABCBEEF", "%" SCNxFAST32, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == 0x2ABCBEEF);
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsignedFast64()
+{
+  Input<uint_fast64_t> u;
+
+  PoisonInput(u);
+  sscanf("17421742173", "%" SCNoFAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(017421742173));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("421786713579", "%" SCNuFAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(421786713579));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("DEADBEEF7457E", "%" SCNxFAST64, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINT64_C(0xDEADBEEF7457E));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsignedFastN()
+{
+  TestScanUnsignedFast8();
+  TestScanUnsignedFast16();
+  TestScanUnsignedFast32();
+  TestScanUnsignedFast64();
+}
+
+static void
+TestScanUnsignedMax()
+{
+  Input<uintmax_t> u;
+
+  PoisonInput(u);
+  sscanf("14220563454333534", "%" SCNoMAX, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINTMAX_C(432157943248732));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("432157943248732", "%" SCNuMAX, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINTMAX_C(432157943248732));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("4c337ca791", "%" SCNxMAX, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == UINTMAX_C(327281321873));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsignedPtr()
+{
+  Input<uintptr_t> u;
+
+  PoisonInput(u);
+  sscanf("57060516", "%" SCNoPTR, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == uintptr_t(reinterpret_cast<void*>(12345678)));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("87654321", "%" SCNuPTR, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == uintptr_t(reinterpret_cast<void*>(87654321)));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+
+  PoisonInput(u);
+  sscanf("4c3a791", "%" SCNxPTR, &u.i);
+  MOZ_RELEASE_ASSERT(u.i == uintptr_t(reinterpret_cast<void*>(0x4c3a791)));
+  MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
+}
+
+static void
+TestScanUnsigned()
+{
+  TestScanUnsignedN();
+  TestScanUnsignedLeastN();
+  TestScanUnsignedFastN();
+  TestScanUnsignedMax();
+  TestScanUnsignedPtr();
+}
+
+static void
+TestScan()
+{
+  TestScanSigned();
+  TestScanUnsigned();
+}
+
+#endif /* SHOULD_TEST_SCANF_MACROS */
+
+int
+main()
+{
+  TestPrint();
+#if SHOULD_TEST_SCANF_MACROS
+  TestScan();
+#endif
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestIntegerRange.cpp b/src/third_party/mozjs-45/mfbt/tests/TestIntegerRange.cpp
new file mode 100644
index 0000000..c2691a2
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestIntegerRange.cpp
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/IntegerRange.h"
+
+#include <stddef.h>
+
+using mozilla::IsSame;
+using mozilla::MakeRange;
+using mozilla::Reversed;
+
+const size_t kMaxNumber = 50;
+const size_t kArraySize = 256;
+
+template<typename IntType>
+static IntType
+GenerateNumber()
+{
+  return static_cast<IntType>(rand() % kMaxNumber + 1);
+}
+
+template<typename IntType>
+static void
+TestSingleParamRange(const IntType aN)
+{
+  IntType array[kArraySize];
+  IntType* ptr = array;
+  for (auto i : MakeRange(aN)) {
+    static_assert(IsSame<decltype(i), IntType>::value,
+                  "type of the loop var and the param should be the same");
+    *ptr++ = i;
+  }
+
+  MOZ_RELEASE_ASSERT(ptr - array == static_cast<ptrdiff_t>(aN),
+                     "Should iterates N items");
+  for (size_t i = 0; i < static_cast<size_t>(aN); i++) {
+    MOZ_RELEASE_ASSERT(array[i] == static_cast<IntType>(i),
+                       "Values should equal to the index");
+  }
+}
+
+template<typename IntType>
+static void
+TestSingleParamReverseRange(const IntType aN)
+{
+  IntType array[kArraySize];
+  IntType* ptr = array;
+  for (auto i : Reversed(MakeRange(aN))) {
+    static_assert(IsSame<decltype(i), IntType>::value,
+                  "type of the loop var and the param should be the same");
+    *ptr++ = i;
+  }
+
+  MOZ_RELEASE_ASSERT(ptr - array == static_cast<ptrdiff_t>(aN),
+                     "Should iterates N items");
+  for (size_t i = 0; i < static_cast<size_t>(aN); i++) {
+    MOZ_RELEASE_ASSERT(array[i] == static_cast<IntType>(aN - i - 1),
+                       "Values should be the reverse of their index");
+  }
+}
+
+template<typename IntType>
+static void
+TestSingleParamIntegerRange()
+{
+  const auto kN = GenerateNumber<IntType>();
+  TestSingleParamRange<IntType>(0);
+  TestSingleParamReverseRange<IntType>(0);
+  TestSingleParamRange<IntType>(kN);
+  TestSingleParamReverseRange<IntType>(kN);
+}
+
+template<typename IntType1, typename IntType2>
+static void
+TestDoubleParamRange(const IntType1 aBegin, const IntType2 aEnd)
+{
+  IntType2 array[kArraySize];
+  IntType2* ptr = array;
+  for (auto i : MakeRange(aBegin, aEnd)) {
+    static_assert(IsSame<decltype(i), IntType2>::value, "type of the loop var "
+                  "should be same as that of the second param");
+    *ptr++ = i;
+  }
+
+  MOZ_RELEASE_ASSERT(ptr - array == static_cast<ptrdiff_t>(aEnd - aBegin),
+                     "Should iterates (aEnd - aBegin) times");
+  for (size_t i = 0; i < static_cast<size_t>(aEnd - aBegin); i++) {
+    MOZ_RELEASE_ASSERT(array[i] == static_cast<IntType2>(aBegin + i),
+                       "Should iterate integers in [aBegin, aEnd) in order");
+  }
+}
+
+template<typename IntType1, typename IntType2>
+static void
+TestDoubleParamReverseRange(const IntType1 aBegin, const IntType2 aEnd)
+{
+  IntType2 array[kArraySize];
+  IntType2* ptr = array;
+  for (auto i : Reversed(MakeRange(aBegin, aEnd))) {
+    static_assert(IsSame<decltype(i), IntType2>::value, "type of the loop var "
+                  "should be same as that of the second param");
+    *ptr++ = i;
+  }
+
+  MOZ_RELEASE_ASSERT(ptr - array == static_cast<ptrdiff_t>(aEnd - aBegin),
+                     "Should iterates (aEnd - aBegin) times");
+  for (size_t i = 0; i < static_cast<size_t>(aEnd - aBegin); i++) {
+    MOZ_RELEASE_ASSERT(array[i] == static_cast<IntType2>(aEnd - i - 1),
+                       "Should iterate integers in [aBegin, aEnd) in reverse order");
+  }
+}
+
+template<typename IntType1, typename IntType2>
+static void
+TestDoubleParamIntegerRange()
+{
+  const auto kStart = GenerateNumber<IntType1>();
+  const auto kEnd = static_cast<IntType2>(kStart + GenerateNumber<IntType2>());
+  TestDoubleParamRange(kStart, static_cast<IntType2>(kStart));
+  TestDoubleParamReverseRange(kStart, static_cast<IntType2>(kStart));
+  TestDoubleParamRange(kStart, kEnd);
+  TestDoubleParamReverseRange(kStart, kEnd);
+}
+
+int
+main()
+{
+  TestSingleParamIntegerRange<int8_t>();
+  TestSingleParamIntegerRange<int16_t>();
+  TestSingleParamIntegerRange<int32_t>();
+  TestSingleParamIntegerRange<int64_t>();
+
+  TestSingleParamIntegerRange<uint8_t>();
+  TestSingleParamIntegerRange<uint16_t>();
+  TestSingleParamIntegerRange<uint32_t>();
+  TestSingleParamIntegerRange<uint64_t>();
+
+  TestDoubleParamIntegerRange<int8_t, int8_t>();
+  TestDoubleParamIntegerRange<int16_t, int16_t>();
+  TestDoubleParamIntegerRange<int32_t, int32_t>();
+  TestDoubleParamIntegerRange<int64_t, int64_t>();
+
+  TestDoubleParamIntegerRange<uint8_t, uint8_t>();
+  TestDoubleParamIntegerRange<uint16_t, uint16_t>();
+  TestDoubleParamIntegerRange<uint32_t, uint32_t>();
+  TestDoubleParamIntegerRange<uint64_t, uint64_t>();
+
+  TestDoubleParamIntegerRange<int8_t, int16_t>();
+  TestDoubleParamIntegerRange<int16_t, int32_t>();
+  TestDoubleParamIntegerRange<int32_t, int64_t>();
+  TestDoubleParamIntegerRange<int64_t, int8_t>();
+
+  TestDoubleParamIntegerRange<uint8_t, uint64_t>();
+  TestDoubleParamIntegerRange<uint16_t, uint8_t>();
+  TestDoubleParamIntegerRange<uint32_t, uint16_t>();
+  TestDoubleParamIntegerRange<uint64_t, uint32_t>();
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestJSONWriter.cpp b/src/third_party/mozjs-45/mfbt/tests/TestJSONWriter.cpp
new file mode 100644
index 0000000..6c081d1
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestJSONWriter.cpp
@@ -0,0 +1,539 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/JSONWriter.h"
+#include "mozilla/UniquePtr.h"
+#include <stdio.h>
+#include <string.h>
+
+using mozilla::JSONWriteFunc;
+using mozilla::JSONWriter;
+using mozilla::MakeUnique;
+
+// This writes all the output into a big buffer.
+struct StringWriteFunc : public JSONWriteFunc
+{
+  const static size_t kLen = 100000;
+  char mBuf[kLen];
+  char* mPtr;
+
+  StringWriteFunc() : mPtr(mBuf) {}
+
+  void Write(const char* aStr)
+  {
+    char* last = mPtr + strlen(aStr);    // where the nul will be added
+
+    // If you change this test and this assertion fails, just make kLen bigger.
+    MOZ_RELEASE_ASSERT(last < mBuf + kLen);
+    sprintf(mPtr, "%s", aStr);
+    mPtr = last;
+  }
+};
+
+void Check(JSONWriteFunc* aFunc, const char* aExpected)
+{
+  const char* actual = static_cast<StringWriteFunc*>(aFunc)->mBuf;
+  if (strcmp(aExpected, actual) != 0) {
+    fprintf(stderr,
+            "---- EXPECTED ----\n<<<%s>>>\n"
+            "---- ACTUAL ----\n<<<%s>>>\n",
+            aExpected, actual);
+    MOZ_RELEASE_ASSERT(false, "expected and actual output don't match");
+  }
+}
+
+// Note: to convert actual output into |expected| strings that C++ can handle,
+// apply the following substitutions, in order, to each line.
+// - s/\\/\\\\/g    # escapes backslashes
+// - s/"/\\"/g      # escapes quotes
+// - s/$/\\n\\/     # adds a newline and string continuation char to each line
+
+void TestBasicProperties()
+{
+  const char* expected = "\
+{\n\
+ \"null\": null,\n\
+ \"bool1\": true,\n\
+ \"bool2\": false,\n\
+ \"int1\": 123,\n\
+ \"int2\": -123,\n\
+ \"int3\": -123456789000,\n\
+ \"double1\": 1.2345,\n\
+ \"double2\": -3,\n\
+ \"double3\": 1e-7,\n\
+ \"double4\": 1.1111111111111111e+21,\n\
+ \"string1\": \"\",\n\
+ \"string2\": \"1234\",\n\
+ \"string3\": \"hello\",\n\
+ \"string4\": \"\\\" \\\\ \\u0007 \\b \\t \\n \\u000b \\f \\r\",\n\
+ \"len 0 array, multi-line\": [\n\
+ ],\n\
+ \"len 0 array, single-line\": [],\n\
+ \"len 1 array\": [\n\
+  1\n\
+ ],\n\
+ \"len 5 array, multi-line\": [\n\
+  1,\n\
+  2,\n\
+  3,\n\
+  4,\n\
+  5\n\
+ ],\n\
+ \"len 3 array, single-line\": [1, [{}, 2, []], 3],\n\
+ \"len 0 object, multi-line\": {\n\
+ },\n\
+ \"len 0 object, single-line\": {},\n\
+ \"len 1 object\": {\n\
+  \"one\": 1\n\
+ },\n\
+ \"len 5 object\": {\n\
+  \"one\": 1,\n\
+  \"two\": 2,\n\
+  \"three\": 3,\n\
+  \"four\": 4,\n\
+  \"five\": 5\n\
+ },\n\
+ \"len 3 object, single-line\": {\"a\": 1, \"b\": [{}, 2, []], \"c\": 3}\n\
+}\n\
+";
+
+  JSONWriter w(MakeUnique<StringWriteFunc>());
+
+  w.Start();
+  {
+    w.NullProperty("null");
+
+    w.BoolProperty("bool1", true);
+    w.BoolProperty("bool2", false);
+
+    w.IntProperty("int1", 123);
+    w.IntProperty("int2", -0x7b);
+    w.IntProperty("int3", -123456789000ll);
+
+    w.DoubleProperty("double1", 1.2345);
+    w.DoubleProperty("double2", -3);
+    w.DoubleProperty("double3", 1e-7);
+    w.DoubleProperty("double4", 1.1111111111111111e+21);
+
+    w.StringProperty("string1", "");
+    w.StringProperty("string2", "1234");
+    w.StringProperty("string3", "hello");
+    w.StringProperty("string4", "\" \\ \a \b \t \n \v \f \r");
+
+    w.StartArrayProperty("len 0 array, multi-line", w.MultiLineStyle);
+    w.EndArray();
+
+    w.StartArrayProperty("len 0 array, single-line", w.SingleLineStyle);
+    w.EndArray();
+
+    w.StartArrayProperty("len 1 array");
+    {
+      w.IntElement(1);
+    }
+    w.EndArray();
+
+    w.StartArrayProperty("len 5 array, multi-line", w.MultiLineStyle);
+    {
+      w.IntElement(1);
+      w.IntElement(2);
+      w.IntElement(3);
+      w.IntElement(4);
+      w.IntElement(5);
+    }
+    w.EndArray();
+
+    w.StartArrayProperty("len 3 array, single-line", w.SingleLineStyle);
+    {
+      w.IntElement(1);
+      w.StartArrayElement();
+      {
+        w.StartObjectElement(w.SingleLineStyle);
+        w.EndObject();
+
+        w.IntElement(2);
+
+        w.StartArrayElement(w.MultiLineStyle);  // style overridden from above
+        w.EndArray();
+      }
+      w.EndArray();
+      w.IntElement(3);
+    }
+    w.EndArray();
+
+    w.StartObjectProperty("len 0 object, multi-line");
+    w.EndObject();
+
+    w.StartObjectProperty("len 0 object, single-line", w.SingleLineStyle);
+    w.EndObject();
+
+    w.StartObjectProperty("len 1 object");
+    {
+      w.IntProperty("one", 1);
+    }
+    w.EndObject();
+
+    w.StartObjectProperty("len 5 object");
+    {
+      w.IntProperty("one", 1);
+      w.IntProperty("two", 2);
+      w.IntProperty("three", 3);
+      w.IntProperty("four", 4);
+      w.IntProperty("five", 5);
+    }
+    w.EndObject();
+
+    w.StartObjectProperty("len 3 object, single-line", w.SingleLineStyle);
+    {
+      w.IntProperty("a", 1);
+      w.StartArrayProperty("b");
+      {
+        w.StartObjectElement();
+        w.EndObject();
+
+        w.IntElement(2);
+
+        w.StartArrayElement(w.SingleLineStyle);
+        w.EndArray();
+      }
+      w.EndArray();
+      w.IntProperty("c", 3);
+    }
+    w.EndObject();
+  }
+  w.End();
+
+  Check(w.WriteFunc(), expected);
+}
+
+void TestBasicElements()
+{
+  const char* expected = "\
+{\n\
+ \"array\": [\n\
+  null,\n\
+  true,\n\
+  false,\n\
+  123,\n\
+  -123,\n\
+  -123456789000,\n\
+  1.2345,\n\
+  -3,\n\
+  1e-7,\n\
+  1.1111111111111111e+21,\n\
+  \"\",\n\
+  \"1234\",\n\
+  \"hello\",\n\
+  \"\\\" \\\\ \\u0007 \\b \\t \\n \\u000b \\f \\r\",\n\
+  [\n\
+  ],\n\
+  [],\n\
+  [\n\
+   1\n\
+  ],\n\
+  [\n\
+   1,\n\
+   2,\n\
+   3,\n\
+   4,\n\
+   5\n\
+  ],\n\
+  [1, [{}, 2, []], 3],\n\
+  {\n\
+  },\n\
+  {},\n\
+  {\n\
+   \"one\": 1\n\
+  },\n\
+  {\n\
+   \"one\": 1,\n\
+   \"two\": 2,\n\
+   \"three\": 3,\n\
+   \"four\": 4,\n\
+   \"five\": 5\n\
+  },\n\
+  {\"a\": 1, \"b\": [{}, 2, []], \"c\": 3}\n\
+ ]\n\
+}\n\
+";
+
+  JSONWriter w(MakeUnique<StringWriteFunc>());
+
+  w.Start();
+  w.StartArrayProperty("array");
+  {
+    w.NullElement();
+
+    w.BoolElement(true);
+    w.BoolElement(false);
+
+    w.IntElement(123);
+    w.IntElement(-0x7b);
+    w.IntElement(-123456789000ll);
+
+    w.DoubleElement(1.2345);
+    w.DoubleElement(-3);
+    w.DoubleElement(1e-7);
+    w.DoubleElement(1.1111111111111111e+21);
+
+    w.StringElement("");
+    w.StringElement("1234");
+    w.StringElement("hello");
+    w.StringElement("\" \\ \a \b \t \n \v \f \r");
+
+    w.StartArrayElement();
+    w.EndArray();
+
+    w.StartArrayElement(w.SingleLineStyle);
+    w.EndArray();
+
+    w.StartArrayElement();
+    {
+      w.IntElement(1);
+    }
+    w.EndArray();
+
+    w.StartArrayElement();
+    {
+      w.IntElement(1);
+      w.IntElement(2);
+      w.IntElement(3);
+      w.IntElement(4);
+      w.IntElement(5);
+    }
+    w.EndArray();
+
+    w.StartArrayElement(w.SingleLineStyle);
+    {
+      w.IntElement(1);
+      w.StartArrayElement();
+      {
+        w.StartObjectElement(w.SingleLineStyle);
+        w.EndObject();
+
+        w.IntElement(2);
+
+        w.StartArrayElement(w.MultiLineStyle);  // style overridden from above
+        w.EndArray();
+      }
+      w.EndArray();
+      w.IntElement(3);
+    }
+    w.EndArray();
+
+    w.StartObjectElement();
+    w.EndObject();
+
+    w.StartObjectElement(w.SingleLineStyle);
+    w.EndObject();
+
+    w.StartObjectElement();
+    {
+      w.IntProperty("one", 1);
+    }
+    w.EndObject();
+
+    w.StartObjectElement();
+    {
+      w.IntProperty("one", 1);
+      w.IntProperty("two", 2);
+      w.IntProperty("three", 3);
+      w.IntProperty("four", 4);
+      w.IntProperty("five", 5);
+    }
+    w.EndObject();
+
+    w.StartObjectElement(w.SingleLineStyle);
+    {
+      w.IntProperty("a", 1);
+      w.StartArrayProperty("b");
+      {
+        w.StartObjectElement();
+        w.EndObject();
+
+        w.IntElement(2);
+
+        w.StartArrayElement(w.SingleLineStyle);
+        w.EndArray();
+      }
+      w.EndArray();
+      w.IntProperty("c", 3);
+    }
+    w.EndObject();
+  }
+  w.EndArray();
+  w.End();
+
+  Check(w.WriteFunc(), expected);
+}
+
+void TestOneLineObject()
+{
+  const char* expected = "\
+{\"i\": 1, \"array\": [null, [{}], {\"o\": {}}, \"s\"], \"d\": 3.33}\n\
+";
+
+  JSONWriter w(MakeUnique<StringWriteFunc>());
+
+  w.Start(w.SingleLineStyle);
+
+  w.IntProperty("i", 1);
+
+  w.StartArrayProperty("array");
+  {
+    w.NullElement();
+
+    w.StartArrayElement(w.MultiLineStyle);  // style overridden from above
+    {
+      w.StartObjectElement();
+      w.EndObject();
+    }
+    w.EndArray();
+
+    w.StartObjectElement();
+    {
+      w.StartObjectProperty("o");
+      w.EndObject();
+    }
+    w.EndObject();
+
+    w.StringElement("s");
+  }
+  w.EndArray();
+
+  w.DoubleProperty("d", 3.33);
+
+  w.End();
+
+  Check(w.WriteFunc(), expected);
+}
+
+void TestStringEscaping()
+{
+  // This test uses hexadecimal character escapes because UTF8 literals cause
+  // problems for some compilers (see bug 1069726).
+  const char* expected = "\
+{\n\
+ \"ascii\": \"\x7F~}|{zyxwvutsrqponmlkjihgfedcba`_^]\\\\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#\\\"! \\u001f\\u001e\\u001d\\u001c\\u001b\\u001a\\u0019\\u0018\\u0017\\u0016\\u0015\\u0014\\u0013\\u0012\\u0011\\u0010\\u000f\\u000e\\r\\f\\u000b\\n\\t\\b\\u0007\\u0006\\u0005\\u0004\\u0003\\u0002\\u0001\",\n\
+ \"\xD9\x85\xD8\xB1\xD8\xAD\xD8\xA8\xD8\xA7 \xD9\x87\xD9\x86\xD8\xA7\xD9\x83\": true,\n\
+ \"\xD5\xA2\xD5\xA1\xD6\x80\xD5\xA5\xD6\x82 \xD5\xB9\xD5\xAF\xD5\xA1\": -123,\n\
+ \"\xE4\xBD\xA0\xE5\xA5\xBD\": 1.234,\n\
+ \"\xCE\xB3\xCE\xB5\xCE\xB9\xCE\xB1 \xCE\xB5\xCE\xBA\xCE\xB5\xCE\xAF\": \"\xD8\xB3\xD9\x84\xD8\xA7\xD9\x85\",\n\
+ \"hall\xC3\xB3 \xC3\xBE" "arna\": 4660,\n\
+ \"\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF\": {\n\
+  \"\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82\": [\n\
+  ]\n\
+ }\n\
+}\n\
+";
+
+  JSONWriter w(MakeUnique<StringWriteFunc>());
+
+  // Test the string escaping behaviour.
+  w.Start();
+  {
+    // Test all 127 ascii values. Do it in reverse order so that the 0
+    // at the end serves as the null char.
+    char buf[128];
+    for (int i = 0; i < 128; i++) {
+      buf[i] = 127 - i;
+    }
+    w.StringProperty("ascii", buf);
+
+    // Test lots of unicode stuff. Note that this file is encoded as UTF-8.
+    w.BoolProperty("\xD9\x85\xD8\xB1\xD8\xAD\xD8\xA8\xD8\xA7 \xD9\x87\xD9\x86\xD8\xA7\xD9\x83", true);
+    w.IntProperty("\xD5\xA2\xD5\xA1\xD6\x80\xD5\xA5\xD6\x82 \xD5\xB9\xD5\xAF\xD5\xA1", -123);
+    w.DoubleProperty("\xE4\xBD\xA0\xE5\xA5\xBD", 1.234);
+    w.StringProperty("\xCE\xB3\xCE\xB5\xCE\xB9\xCE\xB1 \xCE\xB5\xCE\xBA\xCE\xB5\xCE\xAF", "\xD8\xB3\xD9\x84\xD8\xA7\xD9\x85");
+    w.IntProperty("hall\xC3\xB3 \xC3\xBE" "arna", 0x1234);
+    w.StartObjectProperty("\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF");
+    {
+      w.StartArrayProperty("\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82");
+      w.EndArray();
+    }
+    w.EndObject();
+  }
+  w.End();
+
+  Check(w.WriteFunc(), expected);
+}
+
+void TestDeepNesting()
+{
+  const char* expected = "\
+{\n\
+ \"a\": [\n\
+  {\n\
+   \"a\": [\n\
+    {\n\
+     \"a\": [\n\
+      {\n\
+       \"a\": [\n\
+        {\n\
+         \"a\": [\n\
+          {\n\
+           \"a\": [\n\
+            {\n\
+             \"a\": [\n\
+              {\n\
+               \"a\": [\n\
+                {\n\
+                 \"a\": [\n\
+                  {\n\
+                   \"a\": [\n\
+                    {\n\
+                    }\n\
+                   ]\n\
+                  }\n\
+                 ]\n\
+                }\n\
+               ]\n\
+              }\n\
+             ]\n\
+            }\n\
+           ]\n\
+          }\n\
+         ]\n\
+        }\n\
+       ]\n\
+      }\n\
+     ]\n\
+    }\n\
+   ]\n\
+  }\n\
+ ]\n\
+}\n\
+";
+
+  JSONWriter w(MakeUnique<StringWriteFunc>());
+
+  w.Start();
+  {
+    static const int n = 10;
+    for (int i = 0; i < n; i++) {
+      w.StartArrayProperty("a");
+      w.StartObjectElement();
+    }
+    for (int i = 0; i < n; i++) {
+      w.EndObject();
+      w.EndArray();
+    }
+  }
+  w.End();
+
+  Check(w.WriteFunc(), expected);
+}
+
+int main(void)
+{
+  TestBasicProperties();
+  TestBasicElements();
+  TestOneLineObject();
+  TestStringEscaping();
+  TestDeepNesting();
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestLinkedList.cpp b/src/third_party/mozjs-45/mfbt/tests/TestLinkedList.cpp
new file mode 100644
index 0000000..55db355
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestLinkedList.cpp
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/LinkedList.h"
+
+using mozilla::LinkedList;
+using mozilla::LinkedListElement;
+
+struct SomeClass : public LinkedListElement<SomeClass> {
+  unsigned int mValue;
+  explicit SomeClass(int aValue) : mValue(aValue) {}
+  void incr() { ++mValue; }
+};
+
+template <size_t N>
+static void
+CheckListValues(LinkedList<SomeClass>& list, unsigned int (&values)[N])
+{
+  size_t count = 0;
+  for (SomeClass* x : list) {
+    MOZ_RELEASE_ASSERT(x->mValue == values[count]);
+    ++count;
+  }
+  MOZ_RELEASE_ASSERT(count == N);
+}
+
+static void
+TestList()
+{
+  LinkedList<SomeClass> list;
+
+  SomeClass one(1), two(2), three(3);
+  
+  MOZ_RELEASE_ASSERT(list.isEmpty());
+  MOZ_RELEASE_ASSERT(!list.getFirst());
+  MOZ_RELEASE_ASSERT(!list.getLast());
+  MOZ_RELEASE_ASSERT(!list.popFirst());
+  MOZ_RELEASE_ASSERT(!list.popLast());
+
+  for (SomeClass* x : list) {
+    MOZ_RELEASE_ASSERT(x);
+    MOZ_RELEASE_ASSERT(false);
+  }
+
+  list.insertFront(&one);
+  { unsigned int check[] { 1 }; CheckListValues(list, check); }
+
+  MOZ_RELEASE_ASSERT(one.isInList());
+  MOZ_RELEASE_ASSERT(!two.isInList());
+  MOZ_RELEASE_ASSERT(!three.isInList());
+  
+  MOZ_RELEASE_ASSERT(!list.isEmpty());
+  MOZ_RELEASE_ASSERT(list.getFirst()->mValue == 1);
+  MOZ_RELEASE_ASSERT(list.getLast()->mValue == 1);
+
+  list.insertFront(&two);
+  { unsigned int check[] { 2, 1 }; CheckListValues(list, check); }
+
+  MOZ_RELEASE_ASSERT(list.getFirst()->mValue == 2);
+  MOZ_RELEASE_ASSERT(list.getLast()->mValue == 1);
+
+  list.insertBack(&three);
+  { unsigned int check[] { 2, 1, 3 }; CheckListValues(list, check); }
+
+  MOZ_RELEASE_ASSERT(list.getFirst()->mValue == 2);
+  MOZ_RELEASE_ASSERT(list.getLast()->mValue == 3);
+
+  one.removeFrom(list);
+  { unsigned int check[] { 2, 3 }; CheckListValues(list, check); }
+
+  three.setPrevious(&one);
+  { unsigned int check[] { 2, 1, 3 }; CheckListValues(list, check); }
+
+  three.removeFrom(list);
+  { unsigned int check[] { 2, 1 }; CheckListValues(list, check); }
+
+  two.setPrevious(&three);
+  { unsigned int check[] { 3, 2, 1 }; CheckListValues(list, check); }
+
+  three.removeFrom(list);
+  { unsigned int check[] { 2, 1 }; CheckListValues(list, check); }
+
+  two.setNext(&three);
+  { unsigned int check[] { 2, 3, 1 }; CheckListValues(list, check); }
+
+  one.remove();
+  { unsigned int check[] { 2, 3 }; CheckListValues(list, check); }
+
+  two.remove();
+  { unsigned int check[] { 3 }; CheckListValues(list, check); }
+
+  three.setPrevious(&two);
+  { unsigned int check[] { 2, 3 }; CheckListValues(list, check); }
+
+  three.remove();
+  { unsigned int check[] { 2 }; CheckListValues(list, check); }
+
+  two.remove();
+
+  list.insertBack(&three);
+  { unsigned int check[] { 3 }; CheckListValues(list, check); }
+
+  list.insertFront(&two);
+  { unsigned int check[] { 2, 3 }; CheckListValues(list, check); }
+
+  for (SomeClass* x : list) {
+    x->incr();
+  }
+
+  MOZ_RELEASE_ASSERT(list.getFirst() == &two);
+  MOZ_RELEASE_ASSERT(list.getLast() == &three);
+  MOZ_RELEASE_ASSERT(list.getFirst()->mValue == 3);
+  MOZ_RELEASE_ASSERT(list.getLast()->mValue == 4);
+}
+
+struct PrivateClass : private LinkedListElement<PrivateClass> {
+  friend class mozilla::LinkedList<PrivateClass>;
+  friend class mozilla::LinkedListElement<PrivateClass>;
+};
+
+static void
+TestPrivate()
+{
+  LinkedList<PrivateClass> list;
+  PrivateClass one, two;
+  list.insertBack(&one);
+  list.insertBack(&two);
+
+  size_t count = 0;
+  for (PrivateClass* p : list) {
+    MOZ_RELEASE_ASSERT(p, "cannot have null elements in list");
+    count++;
+  }
+  MOZ_RELEASE_ASSERT(count == 2);
+}
+
+int
+main()
+{
+  TestList();
+  TestPrivate();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestMacroArgs.cpp b/src/third_party/mozjs-45/mfbt/tests/TestMacroArgs.cpp
new file mode 100644
index 0000000..0d97604
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestMacroArgs.cpp
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/MacroArgs.h"
+
+MOZ_STATIC_ASSERT_VALID_ARG_COUNT(1);
+MOZ_STATIC_ASSERT_VALID_ARG_COUNT(1, 2);
+
+static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(100, a, b, c) == 1003, "");
+
+static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, a, b, c) == 3, "");
+static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, a) == 1, "");
+static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, !a) == 1, "");
+static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, (a, b)) == 1, "");
+
+static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, MOZ_ARGS_AFTER_1(a, b, c)) == 2,
+              "MOZ_ARGS_AFTER_1(a, b, c) should expand to 'b, c'");
+static_assert(MOZ_ARGS_AFTER_2(a, b, 3) == 3,
+              "MOZ_ARGS_AFTER_2(a, b, 3) should expand to '3'");
+
+static_assert(MOZ_ARG_1(10, 20, 30) == 10, "");
+static_assert(MOZ_ARG_2(10, 20, 30) == 20, "");
+
+int
+main()
+{
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestMacroForEach.cpp b/src/third_party/mozjs-45/mfbt/tests/TestMacroForEach.cpp
new file mode 100644
index 0000000..04a78d4
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestMacroForEach.cpp
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/MacroForEach.h"
+
+#define HELPER_IDENTITY_PLUS(x) x +
+static_assert(MOZ_FOR_EACH(HELPER_IDENTITY_PLUS, (), (10)) 0 == 10, "");
+static_assert(MOZ_FOR_EACH(HELPER_IDENTITY_PLUS, (), (1, 1, 1)) 0 == 3, "");
+
+#define HELPER_DEFINE_VAR(x) const int test1_##x = x;
+MOZ_FOR_EACH(HELPER_DEFINE_VAR, (), (10, 20))
+static_assert(test1_10 == 10 && test1_20 == 20, "");
+
+#define HELPER_DEFINE_VAR2(k, x) const int test2_##x = k + x;
+MOZ_FOR_EACH(HELPER_DEFINE_VAR2, (5,), (10, 20))
+static_assert(test2_10 == 15 && test2_20 == 25, "");
+
+#define HELPER_IDENTITY_COMMA(k1, k2, x) k1, k2, x,
+
+int
+main()
+{
+  const int a[] = {
+    MOZ_FOR_EACH(HELPER_IDENTITY_COMMA, (1, 2,), (10, 20, 30))
+  };
+  MOZ_RELEASE_ASSERT(a[0] == 1 && a[1] == 2 && a[2] == 10 &&
+                     a[3] == 1 && a[4] == 2 && a[5] == 20 &&
+                     a[6] == 1 && a[7] == 2 && a[8] == 30,
+                     "MOZ_FOR_EACH args enumerated in incorrect order");
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestMathAlgorithms.cpp b/src/third_party/mozjs-45/mfbt/tests/TestMathAlgorithms.cpp
new file mode 100644
index 0000000..b3bf1ce
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestMathAlgorithms.cpp
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/MathAlgorithms.h"
+
+using mozilla::Clamp;
+using mozilla::IsPowerOfTwo;
+
+static void
+TestClamp()
+{
+  MOZ_RELEASE_ASSERT(Clamp(0, 0, 0) == 0);
+  MOZ_RELEASE_ASSERT(Clamp(1, 0, 0) == 0);
+  MOZ_RELEASE_ASSERT(Clamp(-1, 0, 0) == 0);
+
+  MOZ_RELEASE_ASSERT(Clamp(0, 1, 1) == 1);
+  MOZ_RELEASE_ASSERT(Clamp(0, 1, 2) == 1);
+
+  MOZ_RELEASE_ASSERT(Clamp(0, -1, -1) == -1);
+  MOZ_RELEASE_ASSERT(Clamp(0, -2, -1) == -1);
+
+  MOZ_RELEASE_ASSERT(Clamp(0, 1, 3) == 1);
+  MOZ_RELEASE_ASSERT(Clamp(1, 1, 3) == 1);
+  MOZ_RELEASE_ASSERT(Clamp(2, 1, 3) == 2);
+  MOZ_RELEASE_ASSERT(Clamp(3, 1, 3) == 3);
+  MOZ_RELEASE_ASSERT(Clamp(4, 1, 3) == 3);
+  MOZ_RELEASE_ASSERT(Clamp(5, 1, 3) == 3);
+
+  MOZ_RELEASE_ASSERT(Clamp<uint8_t>(UINT8_MAX, 0, UINT8_MAX) == UINT8_MAX);
+  MOZ_RELEASE_ASSERT(Clamp<uint8_t>(0, 0, UINT8_MAX) == 0);
+
+  MOZ_RELEASE_ASSERT(Clamp<int8_t>(INT8_MIN, INT8_MIN, INT8_MAX) == INT8_MIN);
+  MOZ_RELEASE_ASSERT(Clamp<int8_t>(INT8_MIN, 0, INT8_MAX) == 0);
+  MOZ_RELEASE_ASSERT(Clamp<int8_t>(INT8_MAX, INT8_MIN, INT8_MAX) == INT8_MAX);
+  MOZ_RELEASE_ASSERT(Clamp<int8_t>(INT8_MAX, INT8_MIN, 0) == 0);
+}
+
+static void
+TestIsPowerOfTwo()
+{
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(0u));
+  MOZ_RELEASE_ASSERT( IsPowerOfTwo(1u));
+  MOZ_RELEASE_ASSERT( IsPowerOfTwo(2u));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(3u));
+  MOZ_RELEASE_ASSERT( IsPowerOfTwo(4u));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(5u));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(6u));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(7u));
+  MOZ_RELEASE_ASSERT( IsPowerOfTwo(8u));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(9u));
+
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint8_t(UINT8_MAX/2)));     // 127, 0x7f
+  MOZ_RELEASE_ASSERT( IsPowerOfTwo(uint8_t(UINT8_MAX/2 + 1))); // 128, 0x80
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint8_t(UINT8_MAX/2 + 2))); // 129, 0x81
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint8_t(UINT8_MAX - 1)));   // 254, 0xfe
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint8_t(UINT8_MAX)));       // 255, 0xff
+
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint16_t(UINT16_MAX/2)));     // 0x7fff
+  MOZ_RELEASE_ASSERT( IsPowerOfTwo(uint16_t(UINT16_MAX/2 + 1))); // 0x8000
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint16_t(UINT16_MAX/2 + 2))); // 0x8001
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint16_t(UINT16_MAX - 1)));   // 0xfffe
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint16_t(UINT16_MAX)));       // 0xffff
+
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint32_t(UINT32_MAX/2)));
+  MOZ_RELEASE_ASSERT( IsPowerOfTwo(uint32_t(UINT32_MAX/2 + 1)));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint32_t(UINT32_MAX/2 + 2)));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint32_t(UINT32_MAX - 1)));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint32_t(UINT32_MAX)));
+
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint64_t(UINT64_MAX/2)));
+  MOZ_RELEASE_ASSERT( IsPowerOfTwo(uint64_t(UINT64_MAX/2 + 1)));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint64_t(UINT64_MAX/2 + 2)));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint64_t(UINT64_MAX - 1)));
+  MOZ_RELEASE_ASSERT(!IsPowerOfTwo(uint64_t(UINT64_MAX)));
+}
+
+int
+main()
+{
+  TestIsPowerOfTwo();
+  TestClamp();
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestMaybe.cpp b/src/third_party/mozjs-45/mfbt/tests/TestMaybe.cpp
new file mode 100644
index 0000000..f1b098e
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestMaybe.cpp
@@ -0,0 +1,828 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <utility>
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Compiler.h"
+#include "mozilla/Maybe.h"
+#include "mozilla/Move.h"
+#include "mozilla/Types.h"
+#include "mozilla/TypeTraits.h"
+#include "mozilla/UniquePtr.h"
+
+using mozilla::IsSame;
+using mozilla::Maybe;
+using mozilla::Move;
+using mozilla::Nothing;
+using mozilla::Some;
+using mozilla::Swap;
+using mozilla::ToMaybe;
+using mozilla::UniquePtr;
+
+#if MOZ_IS_MSVC
+   template<typename T> struct Identity { typedef T type; };
+#  define DECLTYPE(EXPR) Identity<decltype(EXPR)>::type
+#elif MOZ_IS_GCC
+// Work around a bug in GCC < 4.7 that prevents expressions of
+// the form |decltype(foo)::type| from working. See here:
+// http://stackoverflow.com/questions/14330768/c11-compiler-error-when-using-decltypevar-followed-by-internal-type-of-var
+#  if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
+#    define DECLTYPE(EXPR) decltype(EXPR)
+#  else
+     template<typename T> struct Identity { typedef T type; };
+#    define DECLTYPE(EXPR) Identity<decltype(EXPR)>::type
+#  endif
+#else
+#  define DECLTYPE(EXPR) decltype(EXPR)
+#endif
+
+#define RUN_TEST(t) \
+  do { \
+    bool cond = (t()); \
+    if (!cond) \
+      return 1; \
+    cond = AllDestructorsWereCalled(); \
+    MOZ_ASSERT(cond, "Failed to destroy all objects during test: " #t); \
+    if (!cond) \
+      return 1; \
+  } while (false)
+
+enum Status
+{
+  eWasDefaultConstructed,
+  eWasConstructed,
+  eWasCopyConstructed,
+  eWasMoveConstructed,
+  eWasCopyAssigned,
+  eWasMoveAssigned,
+  eWasMovedFrom
+};
+
+static size_t sUndestroyedObjects = 0;
+
+static bool AllDestructorsWereCalled()
+{
+  return sUndestroyedObjects == 0;
+}
+
+struct BasicValue
+{
+  BasicValue()
+    : mStatus(eWasDefaultConstructed)
+    , mTag(0)
+  {
+    ++sUndestroyedObjects;
+  }
+
+  explicit BasicValue(int aTag)
+    : mStatus(eWasConstructed)
+    , mTag(aTag)
+  {
+    ++sUndestroyedObjects;
+  }
+
+  BasicValue(const BasicValue& aOther)
+    : mStatus(eWasCopyConstructed)
+    , mTag(aOther.mTag)
+  {
+    ++sUndestroyedObjects;
+  }
+
+  BasicValue(BasicValue&& aOther)
+    : mStatus(eWasMoveConstructed)
+    , mTag(aOther.mTag)
+  {
+    ++sUndestroyedObjects;
+    aOther.mStatus = eWasMovedFrom;
+    aOther.mTag = 0;
+  }
+
+  ~BasicValue() { --sUndestroyedObjects; }
+
+  BasicValue& operator=(const BasicValue& aOther)
+  {
+    mStatus = eWasCopyAssigned;
+    mTag = aOther.mTag;
+    return *this;
+  }
+
+  BasicValue& operator=(BasicValue&& aOther)
+  {
+    mStatus = eWasMoveAssigned;
+    mTag = aOther.mTag;
+    aOther.mStatus = eWasMovedFrom;
+    aOther.mTag = 0;
+    return *this;
+  }
+
+  bool operator==(const BasicValue& aOther) const
+  {
+    return mTag == aOther.mTag;
+  }
+
+  bool operator<(const BasicValue& aOther) const
+  {
+    return mTag < aOther.mTag;
+  }
+
+  Status GetStatus() const { return mStatus; }
+  void SetTag(int aValue) { mTag = aValue; }
+  int GetTag() const { return mTag; }
+
+private:
+  Status mStatus;
+  int mTag;
+};
+
+struct UncopyableValue
+{
+  UncopyableValue()
+    : mStatus(eWasDefaultConstructed)
+  {
+    ++sUndestroyedObjects;
+  }
+
+  UncopyableValue(UncopyableValue&& aOther)
+    : mStatus(eWasMoveConstructed)
+  {
+    ++sUndestroyedObjects;
+    aOther.mStatus = eWasMovedFrom;
+  }
+
+  ~UncopyableValue() { --sUndestroyedObjects; }
+
+  UncopyableValue& operator=(UncopyableValue&& aOther)
+  {
+    mStatus = eWasMoveAssigned;
+    aOther.mStatus = eWasMovedFrom;
+    return *this;
+  }
+
+  Status GetStatus() { return mStatus; }
+
+private:
+  UncopyableValue(const UncopyableValue& aOther) = delete;
+  UncopyableValue& operator=(const UncopyableValue& aOther) = delete;
+
+  Status mStatus;
+};
+
+struct UnmovableValue
+{
+  UnmovableValue()
+    : mStatus(eWasDefaultConstructed)
+  {
+    ++sUndestroyedObjects;
+  }
+
+  UnmovableValue(const UnmovableValue& aOther)
+    : mStatus(eWasCopyConstructed)
+  {
+    ++sUndestroyedObjects;
+  }
+
+  ~UnmovableValue() { --sUndestroyedObjects; }
+
+  UnmovableValue& operator=(const UnmovableValue& aOther)
+  {
+    mStatus = eWasCopyAssigned;
+    return *this;
+  }
+
+  Status GetStatus() { return mStatus; }
+
+private:
+  UnmovableValue(UnmovableValue&& aOther) = delete;
+  UnmovableValue& operator=(UnmovableValue&& aOther) = delete;
+
+  Status mStatus;
+};
+
+struct UncopyableUnmovableValue
+{
+  UncopyableUnmovableValue()
+    : mStatus(eWasDefaultConstructed)
+  {
+    ++sUndestroyedObjects;
+  }
+
+  explicit UncopyableUnmovableValue(int)
+    : mStatus(eWasConstructed)
+  {
+    ++sUndestroyedObjects;
+  }
+
+  ~UncopyableUnmovableValue() { --sUndestroyedObjects; }
+
+  Status GetStatus() { return mStatus; }
+
+private:
+  UncopyableUnmovableValue(const UncopyableUnmovableValue& aOther) = delete;
+  UncopyableUnmovableValue& operator=(const UncopyableUnmovableValue& aOther) = delete;
+  UncopyableUnmovableValue(UncopyableUnmovableValue&& aOther) = delete;
+  UncopyableUnmovableValue& operator=(UncopyableUnmovableValue&& aOther) = delete;
+
+  Status mStatus;
+};
+
+static bool
+TestBasicFeatures()
+{
+  // Check that a Maybe<T> is initialized to Nothing.
+  Maybe<BasicValue> mayValue;
+  static_assert(IsSame<BasicValue, DECLTYPE(mayValue)::ValueType>::value,
+                "Should have BasicValue ValueType");
+  MOZ_RELEASE_ASSERT(!mayValue);
+  MOZ_RELEASE_ASSERT(!mayValue.isSome());
+  MOZ_RELEASE_ASSERT(mayValue.isNothing());
+
+  // Check that emplace() default constructs and the accessors work.
+  mayValue.emplace();
+  MOZ_RELEASE_ASSERT(mayValue);
+  MOZ_RELEASE_ASSERT(mayValue.isSome());
+  MOZ_RELEASE_ASSERT(!mayValue.isNothing());
+  MOZ_RELEASE_ASSERT(*mayValue == BasicValue());
+  MOZ_RELEASE_ASSERT(mayValue.value() == BasicValue());
+  static_assert(IsSame<BasicValue, DECLTYPE(mayValue.value())>::value,
+                "value() should return a BasicValue");
+  MOZ_RELEASE_ASSERT(mayValue.ref() == BasicValue());
+  static_assert(IsSame<BasicValue&, DECLTYPE(mayValue.ref())>::value,
+                "ref() should return a BasicValue&");
+  MOZ_RELEASE_ASSERT(mayValue.ptr() != nullptr);
+  static_assert(IsSame<BasicValue*, DECLTYPE(mayValue.ptr())>::value,
+                "ptr() should return a BasicValue*");
+  MOZ_RELEASE_ASSERT(mayValue->GetStatus() == eWasDefaultConstructed);
+
+  // Check that reset() works.
+  mayValue.reset();
+  MOZ_RELEASE_ASSERT(!mayValue);
+  MOZ_RELEASE_ASSERT(!mayValue.isSome());
+  MOZ_RELEASE_ASSERT(mayValue.isNothing());
+
+  // Check that emplace(T1) calls the correct constructor.
+  mayValue.emplace(1);
+  MOZ_RELEASE_ASSERT(mayValue);
+  MOZ_RELEASE_ASSERT(mayValue->GetStatus() == eWasConstructed);
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 1);
+  mayValue.reset();
+  MOZ_RELEASE_ASSERT(!mayValue);
+
+  // Check that Some() and Nothing() work.
+  mayValue = Some(BasicValue(2));
+  MOZ_RELEASE_ASSERT(mayValue);
+  MOZ_RELEASE_ASSERT(mayValue->GetStatus() == eWasMoveConstructed);
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 2);
+  mayValue = Nothing();
+  MOZ_RELEASE_ASSERT(!mayValue);
+
+  // Check that the accessors work through a const ref.
+  mayValue.emplace();
+  const Maybe<BasicValue>& mayValueCRef = mayValue;
+  MOZ_RELEASE_ASSERT(mayValueCRef);
+  MOZ_RELEASE_ASSERT(mayValueCRef.isSome());
+  MOZ_RELEASE_ASSERT(!mayValueCRef.isNothing());
+  MOZ_RELEASE_ASSERT(*mayValueCRef == BasicValue());
+  MOZ_RELEASE_ASSERT(mayValueCRef.value() == BasicValue());
+  static_assert(IsSame<BasicValue, DECLTYPE(mayValueCRef.value())>::value,
+                "value() should return a BasicValue");
+  MOZ_RELEASE_ASSERT(mayValueCRef.ref() == BasicValue());
+  static_assert(IsSame<const BasicValue&,
+                       DECLTYPE(mayValueCRef.ref())>::value,
+                "ref() should return a const BasicValue&");
+  MOZ_RELEASE_ASSERT(mayValueCRef.ptr() != nullptr);
+  static_assert(IsSame<const BasicValue*,
+                       DECLTYPE(mayValueCRef.ptr())>::value,
+                "ptr() should return a const BasicValue*");
+  MOZ_RELEASE_ASSERT(mayValueCRef->GetStatus() == eWasDefaultConstructed);
+  mayValue.reset();
+
+  return true;
+}
+
+static bool
+TestCopyAndMove()
+{
+  // Check that we get moves when possible for types that can support both moves
+  // and copies.
+  Maybe<BasicValue> mayBasicValue = Some(BasicValue(1));
+  MOZ_RELEASE_ASSERT(mayBasicValue->GetStatus() == eWasMoveConstructed);
+  MOZ_RELEASE_ASSERT(mayBasicValue->GetTag() == 1);
+  mayBasicValue = Some(BasicValue(2));
+  MOZ_RELEASE_ASSERT(mayBasicValue->GetStatus() == eWasMoveAssigned);
+  MOZ_RELEASE_ASSERT(mayBasicValue->GetTag() == 2);
+  mayBasicValue.reset();
+  mayBasicValue.emplace(BasicValue(3));
+  MOZ_RELEASE_ASSERT(mayBasicValue->GetStatus() == eWasMoveConstructed);
+  MOZ_RELEASE_ASSERT(mayBasicValue->GetTag() == 3);
+
+  // Check that we get copies when moves aren't possible.
+  Maybe<BasicValue> mayBasicValue2 = Some(*mayBasicValue);
+  MOZ_RELEASE_ASSERT(mayBasicValue2->GetStatus() == eWasCopyConstructed);
+  MOZ_RELEASE_ASSERT(mayBasicValue2->GetTag() == 3);
+  mayBasicValue->SetTag(4);
+  mayBasicValue2 = mayBasicValue;
+  // This test should work again when we fix bug 1052940.
+  //MOZ_RELEASE_ASSERT(mayBasicValue2->GetStatus() == eWasCopyAssigned);
+  MOZ_RELEASE_ASSERT(mayBasicValue2->GetTag() == 4);
+  mayBasicValue->SetTag(5);
+  mayBasicValue2.reset();
+  mayBasicValue2.emplace(*mayBasicValue);
+  MOZ_RELEASE_ASSERT(mayBasicValue2->GetStatus() == eWasCopyConstructed);
+  MOZ_RELEASE_ASSERT(mayBasicValue2->GetTag() == 5);
+
+  // Check that Move() works. (Another sanity check for move support.)
+  Maybe<BasicValue> mayBasicValue3 = Some(Move(*mayBasicValue));
+  MOZ_RELEASE_ASSERT(mayBasicValue3->GetStatus() == eWasMoveConstructed);
+  MOZ_RELEASE_ASSERT(mayBasicValue3->GetTag() == 5);
+  MOZ_RELEASE_ASSERT(mayBasicValue->GetStatus() == eWasMovedFrom);
+  mayBasicValue2->SetTag(6);
+  mayBasicValue3 = Some(Move(*mayBasicValue2));
+  MOZ_RELEASE_ASSERT(mayBasicValue3->GetStatus() == eWasMoveAssigned);
+  MOZ_RELEASE_ASSERT(mayBasicValue3->GetTag() == 6);
+  MOZ_RELEASE_ASSERT(mayBasicValue2->GetStatus() == eWasMovedFrom);
+  Maybe<BasicValue> mayBasicValue4;
+  mayBasicValue4.emplace(Move(*mayBasicValue3));
+  MOZ_RELEASE_ASSERT(mayBasicValue4->GetStatus() == eWasMoveConstructed);
+  MOZ_RELEASE_ASSERT(mayBasicValue4->GetTag() == 6);
+  MOZ_RELEASE_ASSERT(mayBasicValue3->GetStatus() == eWasMovedFrom);
+
+  // Check that we always get copies for types that don't support moves.
+  // XXX(seth): These tests fail but probably shouldn't. For now we'll just
+  // consider using Maybe with types that allow copies but have deleted or
+  // private move constructors, or which do not support copy assignment, to
+  // be supported only to the extent that we need for existing code to work.
+  // These tests should work again when we fix bug 1052940.
+  /*
+  Maybe<UnmovableValue> mayUnmovableValue = Some(UnmovableValue());
+  MOZ_RELEASE_ASSERT(mayUnmovableValue->GetStatus() == eWasCopyConstructed);
+  mayUnmovableValue = Some(UnmovableValue());
+  MOZ_RELEASE_ASSERT(mayUnmovableValue->GetStatus() == eWasCopyAssigned);
+  mayUnmovableValue.reset();
+  mayUnmovableValue.emplace(UnmovableValue());
+  MOZ_RELEASE_ASSERT(mayUnmovableValue->GetStatus() == eWasCopyConstructed);
+  */
+
+  // Check that types that only support moves, but not copies, work.
+  Maybe<UncopyableValue> mayUncopyableValue = Some(UncopyableValue());
+  MOZ_RELEASE_ASSERT(mayUncopyableValue->GetStatus() == eWasMoveConstructed);
+  mayUncopyableValue = Some(UncopyableValue());
+  MOZ_RELEASE_ASSERT(mayUncopyableValue->GetStatus() == eWasMoveAssigned);
+  mayUncopyableValue.reset();
+  mayUncopyableValue.emplace(UncopyableValue());
+  MOZ_RELEASE_ASSERT(mayUncopyableValue->GetStatus() == eWasMoveConstructed);
+
+  // Check that types that support neither moves or copies work.
+  Maybe<UncopyableUnmovableValue> mayUncopyableUnmovableValue;
+  mayUncopyableUnmovableValue.emplace();
+  MOZ_RELEASE_ASSERT(mayUncopyableUnmovableValue->GetStatus() == eWasDefaultConstructed);
+  mayUncopyableUnmovableValue.reset();
+  mayUncopyableUnmovableValue.emplace(0);
+  MOZ_RELEASE_ASSERT(mayUncopyableUnmovableValue->GetStatus() == eWasConstructed);
+
+  return true;
+}
+
+static BasicValue* sStaticBasicValue = nullptr;
+
+static BasicValue
+MakeBasicValue()
+{
+  return BasicValue(9);
+}
+
+static BasicValue&
+MakeBasicValueRef()
+{
+  return *sStaticBasicValue;
+}
+
+static BasicValue*
+MakeBasicValuePtr()
+{
+  return sStaticBasicValue;
+}
+
+static bool
+TestFunctionalAccessors()
+{
+  BasicValue value(9);
+  sStaticBasicValue = new BasicValue(9);
+
+  // Check that the 'some' case of functional accessors works.
+  Maybe<BasicValue> someValue = Some(BasicValue(3));
+  MOZ_RELEASE_ASSERT(someValue.valueOr(value) == BasicValue(3));
+  static_assert(IsSame<BasicValue,
+                       DECLTYPE(someValue.valueOr(value))>::value,
+                "valueOr should return a BasicValue");
+  MOZ_RELEASE_ASSERT(someValue.valueOrFrom(&MakeBasicValue) == BasicValue(3));
+  static_assert(IsSame<BasicValue,
+                       DECLTYPE(someValue.valueOrFrom(&MakeBasicValue))>::value,
+                "valueOrFrom should return a BasicValue");
+  MOZ_RELEASE_ASSERT(someValue.ptrOr(&value) != &value);
+  static_assert(IsSame<BasicValue*,
+                       DECLTYPE(someValue.ptrOr(&value))>::value,
+                "ptrOr should return a BasicValue*");
+  MOZ_RELEASE_ASSERT(*someValue.ptrOrFrom(&MakeBasicValuePtr) == BasicValue(3));
+  static_assert(IsSame<BasicValue*,
+                       DECLTYPE(someValue.ptrOrFrom(&MakeBasicValuePtr))>::value,
+                "ptrOrFrom should return a BasicValue*");
+  MOZ_RELEASE_ASSERT(someValue.refOr(value) == BasicValue(3));
+  static_assert(IsSame<BasicValue&,
+                       DECLTYPE(someValue.refOr(value))>::value,
+                "refOr should return a BasicValue&");
+  MOZ_RELEASE_ASSERT(someValue.refOrFrom(&MakeBasicValueRef) == BasicValue(3));
+  static_assert(IsSame<BasicValue&,
+                       DECLTYPE(someValue.refOrFrom(&MakeBasicValueRef))>::value,
+                "refOrFrom should return a BasicValue&");
+
+  // Check that the 'some' case works through a const reference.
+  const Maybe<BasicValue>& someValueCRef = someValue;
+  MOZ_RELEASE_ASSERT(someValueCRef.valueOr(value) == BasicValue(3));
+  static_assert(IsSame<BasicValue,
+                       DECLTYPE(someValueCRef.valueOr(value))>::value,
+                "valueOr should return a BasicValue");
+  MOZ_RELEASE_ASSERT(someValueCRef.valueOrFrom(&MakeBasicValue) == BasicValue(3));
+  static_assert(IsSame<BasicValue,
+                       DECLTYPE(someValueCRef.valueOrFrom(&MakeBasicValue))>::value,
+                "valueOrFrom should return a BasicValue");
+  MOZ_RELEASE_ASSERT(someValueCRef.ptrOr(&value) != &value);
+  static_assert(IsSame<const BasicValue*,
+                       DECLTYPE(someValueCRef.ptrOr(&value))>::value,
+                "ptrOr should return a const BasicValue*");
+  MOZ_RELEASE_ASSERT(*someValueCRef.ptrOrFrom(&MakeBasicValuePtr) == BasicValue(3));
+  static_assert(IsSame<const BasicValue*,
+                       DECLTYPE(someValueCRef.ptrOrFrom(&MakeBasicValuePtr))>::value,
+                "ptrOrFrom should return a const BasicValue*");
+  MOZ_RELEASE_ASSERT(someValueCRef.refOr(value) == BasicValue(3));
+  static_assert(IsSame<const BasicValue&,
+                       DECLTYPE(someValueCRef.refOr(value))>::value,
+                "refOr should return a const BasicValue&");
+  MOZ_RELEASE_ASSERT(someValueCRef.refOrFrom(&MakeBasicValueRef) == BasicValue(3));
+  static_assert(IsSame<const BasicValue&,
+                       DECLTYPE(someValueCRef.refOrFrom(&MakeBasicValueRef))>::value,
+                "refOrFrom should return a const BasicValue&");
+
+  // Check that the 'none' case of functional accessors works.
+  Maybe<BasicValue> noneValue;
+  MOZ_RELEASE_ASSERT(noneValue.valueOr(value) == BasicValue(9));
+  static_assert(IsSame<BasicValue,
+                       DECLTYPE(noneValue.valueOr(value))>::value,
+                "valueOr should return a BasicValue");
+  MOZ_RELEASE_ASSERT(noneValue.valueOrFrom(&MakeBasicValue) == BasicValue(9));
+  static_assert(IsSame<BasicValue,
+                       DECLTYPE(noneValue.valueOrFrom(&MakeBasicValue))>::value,
+                "valueOrFrom should return a BasicValue");
+  MOZ_RELEASE_ASSERT(noneValue.ptrOr(&value) == &value);
+  static_assert(IsSame<BasicValue*,
+                       DECLTYPE(noneValue.ptrOr(&value))>::value,
+                "ptrOr should return a BasicValue*");
+  MOZ_RELEASE_ASSERT(*noneValue.ptrOrFrom(&MakeBasicValuePtr) == BasicValue(9));
+  static_assert(IsSame<BasicValue*,
+                       DECLTYPE(noneValue.ptrOrFrom(&MakeBasicValuePtr))>::value,
+                "ptrOrFrom should return a BasicValue*");
+  MOZ_RELEASE_ASSERT(noneValue.refOr(value) == BasicValue(9));
+  static_assert(IsSame<BasicValue&,
+                       DECLTYPE(noneValue.refOr(value))>::value,
+                "refOr should return a BasicValue&");
+  MOZ_RELEASE_ASSERT(noneValue.refOrFrom(&MakeBasicValueRef) == BasicValue(9));
+  static_assert(IsSame<BasicValue&,
+                       DECLTYPE(noneValue.refOrFrom(&MakeBasicValueRef))>::value,
+                "refOrFrom should return a BasicValue&");
+
+  // Check that the 'none' case works through a const reference.
+  const Maybe<BasicValue>& noneValueCRef = noneValue;
+  MOZ_RELEASE_ASSERT(noneValueCRef.valueOr(value) == BasicValue(9));
+  static_assert(IsSame<BasicValue,
+                       DECLTYPE(noneValueCRef.valueOr(value))>::value,
+                "valueOr should return a BasicValue");
+  MOZ_RELEASE_ASSERT(noneValueCRef.valueOrFrom(&MakeBasicValue) == BasicValue(9));
+  static_assert(IsSame<BasicValue,
+                       DECLTYPE(noneValueCRef.valueOrFrom(&MakeBasicValue))>::value,
+                "valueOrFrom should return a BasicValue");
+  MOZ_RELEASE_ASSERT(noneValueCRef.ptrOr(&value) == &value);
+  static_assert(IsSame<const BasicValue*,
+                       DECLTYPE(noneValueCRef.ptrOr(&value))>::value,
+                "ptrOr should return a const BasicValue*");
+  MOZ_RELEASE_ASSERT(*noneValueCRef.ptrOrFrom(&MakeBasicValuePtr) == BasicValue(9));
+  static_assert(IsSame<const BasicValue*,
+                       DECLTYPE(noneValueCRef.ptrOrFrom(&MakeBasicValuePtr))>::value,
+                "ptrOrFrom should return a const BasicValue*");
+  MOZ_RELEASE_ASSERT(noneValueCRef.refOr(value) == BasicValue(9));
+  static_assert(IsSame<const BasicValue&,
+                       DECLTYPE(noneValueCRef.refOr(value))>::value,
+                "refOr should return a const BasicValue&");
+  MOZ_RELEASE_ASSERT(noneValueCRef.refOrFrom(&MakeBasicValueRef) == BasicValue(9));
+  static_assert(IsSame<const BasicValue&,
+                       DECLTYPE(noneValueCRef.refOrFrom(&MakeBasicValueRef))>::value,
+                "refOrFrom should return a const BasicValue&");
+
+  // Clean up so the undestroyed objects count stays accurate.
+  delete sStaticBasicValue;
+  sStaticBasicValue = nullptr;
+
+  return true;
+}
+
+static bool gFunctionWasApplied = false;
+
+static void
+IncrementTag(BasicValue& aValue)
+{
+  gFunctionWasApplied = true;
+  aValue.SetTag(aValue.GetTag() + 1);
+}
+
+static void
+IncrementTagBy(BasicValue& aValue, int aAmount)
+{
+  gFunctionWasApplied = true;
+  aValue.SetTag(aValue.GetTag() + aAmount);
+}
+
+static void
+AccessValue(const BasicValue&)
+{
+  gFunctionWasApplied = true;
+}
+
+static void
+AccessValueWithArg(const BasicValue&, int)
+{
+  gFunctionWasApplied = true;
+}
+
+struct IncrementTagFunctor
+{
+  IncrementTagFunctor() : mBy(1), mArgMoved(false) { }
+
+  void operator()(BasicValue& aValue)
+  {
+    aValue.SetTag(aValue.GetTag() + mBy.GetTag());
+  }
+
+  void operator()(BasicValue& aValue, const BasicValue& aArg)
+  {
+    mArgMoved = false;
+    aValue.SetTag(aValue.GetTag() + aArg.GetTag());
+  }
+
+  void operator()(BasicValue& aValue, BasicValue&& aArg)
+  {
+    mArgMoved = true;
+    aValue.SetTag(aValue.GetTag() + aArg.GetTag());
+  }
+
+  BasicValue mBy;
+  bool mArgMoved;
+};
+
+static bool
+TestApply()
+{
+  // Check that apply handles the 'Nothing' case.
+  gFunctionWasApplied = false;
+  Maybe<BasicValue> mayValue;
+  mayValue.apply(&IncrementTag);
+  mayValue.apply(&AccessValue);
+  mayValue.apply(&IncrementTagBy, 1);
+  mayValue.apply(&AccessValueWithArg, 1);
+  MOZ_RELEASE_ASSERT(!gFunctionWasApplied);
+
+  // Check that apply handles the 'Some' case.
+  mayValue = Some(BasicValue(1));
+  mayValue.apply(&IncrementTag);
+  MOZ_RELEASE_ASSERT(gFunctionWasApplied);
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 2);
+  gFunctionWasApplied = false;
+  mayValue.apply(&AccessValue);
+  MOZ_RELEASE_ASSERT(gFunctionWasApplied);
+  gFunctionWasApplied = false;
+  mayValue.apply(&IncrementTagBy, 2);
+  MOZ_RELEASE_ASSERT(gFunctionWasApplied);
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 4);
+  gFunctionWasApplied = false;
+  mayValue.apply(&AccessValueWithArg, 1);
+  MOZ_RELEASE_ASSERT(gFunctionWasApplied);
+
+  // Check that apply works with a const reference.
+  const Maybe<BasicValue>& mayValueCRef = mayValue;
+  gFunctionWasApplied = false;
+  mayValueCRef.apply(&AccessValue);
+  MOZ_RELEASE_ASSERT(gFunctionWasApplied);
+  gFunctionWasApplied = false;
+  mayValueCRef.apply(&AccessValueWithArg, 1);
+  MOZ_RELEASE_ASSERT(gFunctionWasApplied);
+
+  // Check that apply works with functors.
+  IncrementTagFunctor tagIncrementer;
+  MOZ_RELEASE_ASSERT(tagIncrementer.mBy.GetStatus() == eWasConstructed);
+  mayValue = Some(BasicValue(1));
+  mayValue.apply(tagIncrementer);
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 2);
+  MOZ_RELEASE_ASSERT(tagIncrementer.mBy.GetStatus() == eWasConstructed);
+  mayValue.apply(tagIncrementer, BasicValue(2));
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 4);
+  MOZ_RELEASE_ASSERT(tagIncrementer.mBy.GetStatus() == eWasConstructed);
+  MOZ_RELEASE_ASSERT(tagIncrementer.mArgMoved == true);
+  BasicValue incrementBy(3);
+  mayValue.apply(tagIncrementer, incrementBy);
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 7);
+  MOZ_RELEASE_ASSERT(tagIncrementer.mBy.GetStatus() == eWasConstructed);
+  MOZ_RELEASE_ASSERT(tagIncrementer.mArgMoved == false);
+
+  return true;
+}
+
+static int
+TimesTwo(const BasicValue& aValue)
+{
+  return aValue.GetTag() * 2;
+}
+
+static int
+TimesTwoAndResetOriginal(BasicValue& aValue)
+{
+  int tag = aValue.GetTag();
+  aValue.SetTag(1);
+  return tag * 2;
+}
+
+static int
+TimesNum(const BasicValue& aValue, int aNum)
+{
+  return aValue.GetTag() * aNum;
+}
+
+static int
+TimesNumAndResetOriginal(BasicValue& aValue, int aNum)
+{
+  int tag = aValue.GetTag();
+  aValue.SetTag(1);
+  return tag * aNum;
+}
+
+struct MultiplyTagFunctor
+{
+  MultiplyTagFunctor() : mBy(2), mArgMoved(false) { }
+
+  int operator()(BasicValue& aValue)
+  {
+    return aValue.GetTag() * mBy.GetTag();
+  }
+
+  int operator()(BasicValue& aValue, const BasicValue& aArg)
+  {
+    mArgMoved = false;
+    return aValue.GetTag() * aArg.GetTag();
+  }
+
+  int operator()(BasicValue& aValue, BasicValue&& aArg)
+  {
+    mArgMoved = true;
+    return aValue.GetTag() * aArg.GetTag();
+  }
+
+  BasicValue mBy;
+  bool mArgMoved;
+};
+
+static bool
+TestMap()
+{
+  // Check that map handles the 'Nothing' case.
+  Maybe<BasicValue> mayValue;
+  MOZ_RELEASE_ASSERT(mayValue.map(&TimesTwo) == Nothing());
+  static_assert(IsSame<Maybe<int>,
+                       DECLTYPE(mayValue.map(&TimesTwo))>::value,
+                "map(TimesTwo) should return a Maybe<int>");
+  MOZ_RELEASE_ASSERT(mayValue.map(&TimesTwoAndResetOriginal) == Nothing());
+  MOZ_RELEASE_ASSERT(mayValue.map(&TimesNum, 3) == Nothing());
+  static_assert(IsSame<Maybe<int>,
+                       DECLTYPE(mayValue.map(&TimesNum, 3))>::value,
+                "map(TimesNum, 3) should return a Maybe<int>");
+  MOZ_RELEASE_ASSERT(mayValue.map(&TimesNumAndResetOriginal, 3) == Nothing());
+
+  // Check that map handles the 'Some' case.
+  mayValue = Some(BasicValue(2));
+  MOZ_RELEASE_ASSERT(mayValue.map(&TimesTwo) == Some(4));
+  MOZ_RELEASE_ASSERT(mayValue.map(&TimesTwoAndResetOriginal) == Some(4));
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 1);
+  mayValue = Some(BasicValue(2));
+  MOZ_RELEASE_ASSERT(mayValue.map(&TimesNum, 3) == Some(6));
+  MOZ_RELEASE_ASSERT(mayValue.map(&TimesNumAndResetOriginal, 3) == Some(6));
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 1);
+
+  // Check that map works with a const reference.
+  mayValue->SetTag(2);
+  const Maybe<BasicValue>& mayValueCRef = mayValue;
+  MOZ_RELEASE_ASSERT(mayValueCRef.map(&TimesTwo) == Some(4));
+  static_assert(IsSame<Maybe<int>,
+                       DECLTYPE(mayValueCRef.map(&TimesTwo))>::value,
+                "map(TimesTwo) should return a Maybe<int>");
+  MOZ_RELEASE_ASSERT(mayValueCRef.map(&TimesNum, 3) == Some(6));
+  static_assert(IsSame<Maybe<int>,
+                       DECLTYPE(mayValueCRef.map(&TimesNum, 3))>::value,
+                "map(TimesNum, 3) should return a Maybe<int>");
+
+  // Check that map works with functors.
+  // XXX(seth): Support for functors will be added in bug 1054115; it had to be
+  // ripped out temporarily because of incompatibilities with GCC 4.4.
+  /*
+  MultiplyTagFunctor tagMultiplier;
+  MOZ_RELEASE_ASSERT(tagMultiplier.mBy.GetStatus() == eWasConstructed);
+  MOZ_RELEASE_ASSERT(mayValue.map(tagMultiplier) == Some(4));
+  MOZ_RELEASE_ASSERT(tagMultiplier.mBy.GetStatus() == eWasConstructed);
+  MOZ_RELEASE_ASSERT(mayValue.map(tagMultiplier, BasicValue(3)) == Some(6));
+  MOZ_RELEASE_ASSERT(tagMultiplier.mBy.GetStatus() == eWasConstructed);
+  MOZ_RELEASE_ASSERT(tagMultiplier.mArgMoved == true);
+  BasicValue multiplyBy(3);
+  MOZ_RELEASE_ASSERT(mayValue.map(tagMultiplier, multiplyBy) == Some(6));
+  MOZ_RELEASE_ASSERT(tagMultiplier.mBy.GetStatus() == eWasConstructed);
+  MOZ_RELEASE_ASSERT(tagMultiplier.mArgMoved == false);
+  */
+
+  return true;
+}
+
+static bool
+TestToMaybe()
+{
+  BasicValue value(1);
+  BasicValue* nullPointer = nullptr;
+
+  // Check that a non-null pointer translates into a Some value.
+  Maybe<BasicValue> mayValue = ToMaybe(&value);
+  static_assert(IsSame<Maybe<BasicValue>, DECLTYPE(ToMaybe(&value))>::value,
+                "ToMaybe should return a Maybe<BasicValue>");
+  MOZ_RELEASE_ASSERT(mayValue.isSome());
+  MOZ_RELEASE_ASSERT(mayValue->GetTag() == 1);
+  MOZ_RELEASE_ASSERT(mayValue->GetStatus() == eWasCopyConstructed);
+  MOZ_RELEASE_ASSERT(value.GetStatus() != eWasMovedFrom);
+
+  // Check that a null pointer translates into a Nothing value.
+  mayValue = ToMaybe(nullPointer);
+  static_assert(IsSame<Maybe<BasicValue>, DECLTYPE(ToMaybe(nullPointer))>::value,
+                "ToMaybe should return a Maybe<BasicValue>");
+  MOZ_RELEASE_ASSERT(mayValue.isNothing());
+
+  return true;
+}
+
+static bool
+TestComparisonOperators()
+{
+  Maybe<BasicValue> nothingValue = Nothing();
+  Maybe<BasicValue> anotherNothingValue = Nothing();
+  Maybe<BasicValue> oneValue = Some(BasicValue(1));
+  Maybe<BasicValue> anotherOneValue = Some(BasicValue(1));
+  Maybe<BasicValue> twoValue = Some(BasicValue(2));
+
+  // Check equality.
+  MOZ_RELEASE_ASSERT(nothingValue == anotherNothingValue);
+  MOZ_RELEASE_ASSERT(oneValue == anotherOneValue);
+
+  // Check inequality.
+  MOZ_RELEASE_ASSERT(nothingValue != oneValue);
+  MOZ_RELEASE_ASSERT(oneValue != nothingValue);
+  MOZ_RELEASE_ASSERT(oneValue != twoValue);
+
+  // Check '<'.
+  MOZ_RELEASE_ASSERT(nothingValue < oneValue);
+  MOZ_RELEASE_ASSERT(oneValue < twoValue);
+
+  // Check '<='.
+  MOZ_RELEASE_ASSERT(nothingValue <= anotherNothingValue);
+  MOZ_RELEASE_ASSERT(nothingValue <= oneValue);
+  MOZ_RELEASE_ASSERT(oneValue <= oneValue);
+  MOZ_RELEASE_ASSERT(oneValue <= twoValue);
+
+  // Check '>'.
+  MOZ_RELEASE_ASSERT(oneValue > nothingValue);
+  MOZ_RELEASE_ASSERT(twoValue > oneValue);
+
+  // Check '>='.
+  MOZ_RELEASE_ASSERT(nothingValue >= anotherNothingValue);
+  MOZ_RELEASE_ASSERT(oneValue >= nothingValue);
+  MOZ_RELEASE_ASSERT(oneValue >= oneValue);
+  MOZ_RELEASE_ASSERT(twoValue >= oneValue);
+
+  return true;
+}
+
+int
+main()
+{
+  RUN_TEST(TestBasicFeatures);
+  RUN_TEST(TestCopyAndMove);
+  RUN_TEST(TestFunctionalAccessors);
+  RUN_TEST(TestApply);
+  RUN_TEST(TestMap);
+  RUN_TEST(TestToMaybe);
+  RUN_TEST(TestComparisonOperators);
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestPair.cpp b/src/third_party/mozjs-45/mfbt/tests/TestPair.cpp
new file mode 100644
index 0000000..f1fa9c5
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestPair.cpp
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Pair.h"
+#include "mozilla/TypeTraits.h"
+
+using mozilla::IsSame;
+using mozilla::MakePair;
+using mozilla::Pair;
+
+// Sizes aren't part of the guaranteed Pair interface, but we want to verify our
+// attempts at compactness through EBO are moderately functional, *somewhere*.
+#define INSTANTIATE(T1, T2, name, size) \
+  Pair<T1, T2> name##_1(T1(0), T2(0)); \
+  static_assert(sizeof(name##_1.first()) > 0, \
+                "first method should work on Pair<" #T1 ", " #T2 ">"); \
+  static_assert(sizeof(name##_1.second()) > 0, \
+                "second method should work on Pair<" #T1 ", " #T2 ">"); \
+  static_assert(sizeof(name##_1) == (size), \
+                "Pair<" #T1 ", " #T2 "> has an unexpected size"); \
+  Pair<T2, T1> name##_2(T2(0), T1(0)); \
+  static_assert(sizeof(name##_2.first()) > 0, \
+                "first method should work on Pair<" #T2 ", " #T1 ">"); \
+  static_assert(sizeof(name##_2.second()) > 0, \
+                "second method should work on Pair<" #T2 ", " #T1 ">"); \
+  static_assert(sizeof(name##_2) == (size), \
+                "Pair<" #T2 ", " #T1 "> has an unexpected size");
+
+INSTANTIATE(int, int, prim1, 2 * sizeof(int));
+INSTANTIATE(int, long, prim2, 2 * sizeof(long));
+
+struct EmptyClass { explicit EmptyClass(int) {} };
+struct NonEmpty { char mC; explicit NonEmpty(int) {} };
+
+INSTANTIATE(int, EmptyClass, both1, sizeof(int));
+INSTANTIATE(int, NonEmpty, both2, 2 * sizeof(int));
+INSTANTIATE(EmptyClass, NonEmpty, both3, 1);
+
+struct A { char dummy; explicit A(int) {} };
+struct B : A { explicit B(int aI) : A(aI) {} };
+
+INSTANTIATE(A, A, class1, 2);
+INSTANTIATE(A, B, class2, 2);
+INSTANTIATE(A, EmptyClass, class3, 1);
+
+struct OtherEmpty : EmptyClass { explicit OtherEmpty(int aI) : EmptyClass(aI) {} };
+
+// C++11 requires distinct objects of the same type, within the same "most
+// derived object", to have different addresses.  Pair allocates its elements as
+// two bases, a base and a member, or two members.  If the two elements have
+// non-zero size or are unrelated, no big deal.  But if they're both empty and
+// related, something -- possibly both -- must be inflated.  Exactly which are
+// inflated depends which PairHelper specialization is used.  We could
+// potentially assert something about size for this case, but whatever we could
+// assert would be very finicky.  Plus it's two empty classes -- hardly likely.
+// So don't bother trying to assert anything about this case.
+//INSTANTIATE(EmptyClass, OtherEmpty, class4, ...something finicky...);
+
+int
+main()
+{
+  A a(0);
+  B b(0);
+  const A constA(0);
+  const B constB(0);
+
+  // Check that MakePair generates Pair objects of the correct types.
+  static_assert(IsSame<decltype(MakePair(A(0), B(0))), Pair<A, B>>::value,
+                "MakePair should strip rvalue references");
+  static_assert(IsSame<decltype(MakePair(a, b)), Pair<A, B>>::value,
+                "MakePair should strip lvalue references");
+  static_assert(IsSame<decltype(MakePair(constA, constB)), Pair<A, B>>::value,
+                "MakePair should strip CV-qualifiers");
+
+  // Check that copy assignment and move assignment work.
+  a = constA;
+  a = A(0);
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestPoisonArea.cpp b/src/third_party/mozjs-45/mfbt/tests/TestPoisonArea.cpp
new file mode 100644
index 0000000..43a2f51
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestPoisonArea.cpp
@@ -0,0 +1,549 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/* Code in this file needs to be kept in sync with code in nsPresArena.cpp.
+ *
+ * We want to use a fixed address for frame poisoning so that it is readily
+ * identifiable in crash dumps.  Whether such an address is available
+ * without any special setup depends on the system configuration.
+ *
+ * All current 64-bit CPUs (with the possible exception of PowerPC64)
+ * reserve the vast majority of the virtual address space for future
+ * hardware extensions; valid addresses must be below some break point
+ * between 2**48 and 2**54, depending on exactly which chip you have.  Some
+ * chips (notably amd64) also allow the use of the *highest* 2**48 -- 2**54
+ * addresses.  Thus, if user space pointers are 64 bits wide, we can just
+ * use an address outside this range, and no more is required.  To
+ * accommodate the chips that allow very high addresses to be valid, the
+ * value chosen is close to 2**63 (that is, in the middle of the space).
+ *
+ * In most cases, a purely 32-bit operating system must reserve some
+ * fraction of the address space for its own use.  Contemporary 32-bit OSes
+ * tend to take the high gigabyte or so (0xC000_0000 on up).  If we can
+ * prove that high addresses are reserved to the kernel, we can use an
+ * address in that region.  Unfortunately, not all 32-bit OSes do this;
+ * OSX 10.4 might not, and it is unclear what mobile OSes are like
+ * (some 32-bit CPUs make it very easy for the kernel to exist in its own
+ * private address space).
+ *
+ * Furthermore, when a 32-bit user space process is running on a 64-bit
+ * kernel, the operating system has no need to reserve any of the space that
+ * the process can see, and generally does not do so.  This is the scenario
+ * of greatest concern, since it covers all contemporary OSX iterations
+ * (10.5+) as well as Windows Vista and 7 on newer amd64 hardware.  Linux on
+ * amd64 is generally run as a pure 64-bit environment, but its 32-bit
+ * compatibility mode also has this property.
+ *
+ * Thus, when user space pointers are 32 bits wide, we need to validate
+ * our chosen address, and possibly *make* it a good poison address by
+ * allocating a page around it and marking it inaccessible.  The algorithm
+ * for this is:
+ *
+ *  1. Attempt to make the page surrounding the poison address a reserved,
+ *     inaccessible memory region using OS primitives.  On Windows, this is
+ *     done with VirtualAlloc(MEM_RESERVE); on Unix, mmap(PROT_NONE).
+ *
+ *  2. If mmap/VirtualAlloc failed, there are two possible reasons: either
+ *     the region is reserved to the kernel and no further action is
+ *     required, or there is already usable memory in this area and we have
+ *     to pick a different address.  The tricky part is knowing which case
+ *     we have, without attempting to access the region.  On Windows, we
+ *     rely on GetSystemInfo()'s reported upper and lower bounds of the
+ *     application memory area.  On Unix, there is nothing devoted to the
+ *     purpose, but seeing if madvise() fails is close enough (it *might*
+ *     disrupt someone else's use of the memory region, but not by as much
+ *     as anything else available).
+ *
+ * Be aware of these gotchas:
+ *
+ * 1. We cannot use mmap() with MAP_FIXED.  MAP_FIXED is defined to
+ *    _replace_ any existing mapping in the region, if necessary to satisfy
+ *    the request.  Obviously, as we are blindly attempting to acquire a
+ *    page at a constant address, we must not do this, lest we overwrite
+ *    someone else's allocation.
+ *
+ * 2. For the same reason, we cannot blindly use mprotect() if mmap() fails.
+ *
+ * 3. madvise() may fail when applied to a 'magic' memory region provided as
+ *    a kernel/user interface.  Fortunately, the only such case I know about
+ *    is the "vsyscall" area (not to be confused with the "vdso" area) for
+ *    *64*-bit processes on Linux - and we don't even run this code for
+ *    64-bit processes.
+ *
+ * 4. VirtualQuery() does not produce any useful information if
+ *    applied to kernel memory - in fact, it doesn't write its output
+ *    at all.  Thus, it is not used here.
+ */
+
+#include "mozilla/IntegerPrintfMacros.h"
+
+// MAP_ANON(YMOUS) is not in any standard.  Add defines as necessary.
+#define _GNU_SOURCE 1
+#define _DARWIN_C_SOURCE 1
+
+#include <stddef.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <sys/types.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include <sys/mman.h>
+#ifndef MAP_ANON
+#ifdef MAP_ANONYMOUS
+#define MAP_ANON MAP_ANONYMOUS
+#else
+#error "Don't know how to get anonymous memory"
+#endif
+#endif
+#endif
+
+#define SIZxPTR ((int)(sizeof(uintptr_t)*2))
+
+/* This program assumes that a whole number of return instructions fit into
+ * 32 bits, and that 32-bit alignment is sufficient for a branch destination.
+ * For architectures where this is not true, fiddling with RETURN_INSTR_TYPE
+ * can be enough.
+ */
+
+#if defined __i386__ || defined __x86_64__ ||   \
+  defined __i386 || defined __x86_64 ||         \
+  defined _M_IX86 || defined _M_AMD64
+#define RETURN_INSTR 0xC3C3C3C3  /* ret; ret; ret; ret */
+
+#elif defined __arm__ || defined _M_ARM
+#define RETURN_INSTR 0xE12FFF1E /* bx lr */
+
+// PPC has its own style of CPU-id #defines.  There is no Windows for
+// PPC as far as I know, so no _M_ variant.
+#elif defined _ARCH_PPC || defined _ARCH_PWR || defined _ARCH_PWR2
+#define RETURN_INSTR 0x4E800020 /* blr */
+
+#elif defined __sparc || defined __sparcv9
+#define RETURN_INSTR 0x81c3e008 /* retl */
+
+#elif defined __alpha
+#define RETURN_INSTR 0x6bfa8001 /* ret */
+
+#elif defined __hppa
+#define RETURN_INSTR 0xe840c002 /* bv,n r0(rp) */
+
+#elif defined __mips
+#define RETURN_INSTR 0x03e00008 /* jr ra */
+
+#ifdef __MIPSEL
+/* On mipsel, jr ra needs to be followed by a nop.
+   0x03e00008 as a 64 bits integer just does that */
+#define RETURN_INSTR_TYPE uint64_t
+#endif
+
+#elif defined __s390__
+#define RETURN_INSTR 0x07fe0000 /* br %r14 */
+
+#elif defined __aarch64__
+#define RETURN_INSTR 0xd65f03c0 /* ret */
+
+#elif defined __ia64
+struct ia64_instr { uint32_t mI[4]; };
+static const ia64_instr _return_instr =
+  {{ 0x00000011, 0x00000001, 0x80000200, 0x00840008 }}; /* br.ret.sptk.many b0 */
+
+#define RETURN_INSTR _return_instr
+#define RETURN_INSTR_TYPE ia64_instr
+
+#else
+#error "Need return instruction for this architecture"
+#endif
+
+#ifndef RETURN_INSTR_TYPE
+#define RETURN_INSTR_TYPE uint32_t
+#endif
+
+// Miscellaneous Windows/Unix portability gumph
+
+#ifdef _WIN32
+// Uses of this function deliberately leak the string.
+static LPSTR
+StrW32Error(DWORD aErrcode)
+{
+  LPSTR errmsg;
+  FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                 FORMAT_MESSAGE_FROM_SYSTEM |
+                 FORMAT_MESSAGE_IGNORE_INSERTS,
+                 nullptr, aErrcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                 (LPSTR)&errmsg, 0, nullptr);
+
+  // FormatMessage puts an unwanted newline at the end of the string
+  size_t n = strlen(errmsg)-1;
+  while (errmsg[n] == '\r' || errmsg[n] == '\n') {
+    n--;
+  }
+  errmsg[n+1] = '\0';
+  return errmsg;
+}
+#define LastErrMsg() (StrW32Error(GetLastError()))
+
+// Because we use VirtualAlloc in MEM_RESERVE mode, the "page size" we want
+// is the allocation granularity.
+static SYSTEM_INFO sInfo_;
+
+static inline uint32_t
+PageSize()
+{
+  return sInfo_.dwAllocationGranularity;
+}
+
+static void*
+ReserveRegion(uintptr_t aRequest, bool aAccessible)
+{
+  return VirtualAlloc((void*)aRequest, PageSize(),
+                      aAccessible ? MEM_RESERVE|MEM_COMMIT : MEM_RESERVE,
+                      aAccessible ? PAGE_EXECUTE_READWRITE : PAGE_NOACCESS);
+}
+
+static void
+ReleaseRegion(void* aPage)
+{
+  VirtualFree(aPage, PageSize(), MEM_RELEASE);
+}
+
+static bool
+ProbeRegion(uintptr_t aPage)
+{
+  return aPage >= (uintptr_t)sInfo_.lpMaximumApplicationAddress &&
+         aPage + PageSize() >= (uintptr_t)sInfo_.lpMaximumApplicationAddress;
+}
+
+static bool
+MakeRegionExecutable(void*)
+{
+  return false;
+}
+
+#undef MAP_FAILED
+#define MAP_FAILED 0
+
+#else // Unix
+
+#define LastErrMsg() (strerror(errno))
+
+static unsigned long gUnixPageSize;
+
+static inline unsigned long
+PageSize()
+{
+  return gUnixPageSize;
+}
+
+static void*
+ReserveRegion(uintptr_t aRequest, bool aAccessible)
+{
+  return mmap(reinterpret_cast<void*>(aRequest), PageSize(),
+              aAccessible ? PROT_READ|PROT_WRITE : PROT_NONE,
+              MAP_PRIVATE|MAP_ANON, -1, 0);
+}
+
+static void
+ReleaseRegion(void* aPage)
+{
+  munmap(aPage, PageSize());
+}
+
+static bool
+ProbeRegion(uintptr_t aPage)
+{
+  return !!madvise(reinterpret_cast<void*>(aPage), PageSize(), MADV_NORMAL);
+}
+
+static int
+MakeRegionExecutable(void* aPage)
+{
+  return mprotect((caddr_t)aPage, PageSize(), PROT_READ|PROT_WRITE|PROT_EXEC);
+}
+
+#endif
+
+static uintptr_t
+ReservePoisonArea()
+{
+  if (sizeof(uintptr_t) == 8) {
+    // Use the hardware-inaccessible region.
+    // We have to avoid 64-bit constants and shifts by 32 bits, since this
+    // code is compiled in 32-bit mode, although it is never executed there.
+    uintptr_t result = (((uintptr_t(0x7FFFFFFFu) << 31) << 1 |
+                         uintptr_t(0xF0DEAFFFu)) &
+                        ~uintptr_t(PageSize()-1));
+    printf("INFO | poison area assumed at 0x%.*" PRIxPTR "\n", SIZxPTR, result);
+    return result;
+  }
+
+  // First see if we can allocate the preferred poison address from the OS.
+  uintptr_t candidate = (0xF0DEAFFF & ~(PageSize() - 1));
+  void* result = ReserveRegion(candidate, false);
+  if (result == reinterpret_cast<void*>(candidate)) {
+    // success - inaccessible page allocated
+    printf("INFO | poison area allocated at 0x%.*" PRIxPTR
+           " (preferred addr)\n", SIZxPTR, reinterpret_cast<uintptr_t>(result));
+    return candidate;
+  }
+
+  // That didn't work, so see if the preferred address is within a range
+  // of permanently inacessible memory.
+  if (ProbeRegion(candidate)) {
+    // success - selected page cannot be usable memory
+    if (result != MAP_FAILED) {
+      ReleaseRegion(result);
+    }
+    printf("INFO | poison area assumed at 0x%.*" PRIxPTR
+           " (preferred addr)\n", SIZxPTR, candidate);
+    return candidate;
+  }
+
+  // The preferred address is already in use.  Did the OS give us a
+  // consolation prize?
+  if (result != MAP_FAILED) {
+    uintptr_t ures = reinterpret_cast<uintptr_t>(result);
+    printf("INFO | poison area allocated at 0x%.*" PRIxPTR
+           " (consolation prize)\n", SIZxPTR, ures);
+    return ures;
+  }
+
+  // It didn't, so try to allocate again, without any constraint on
+  // the address.
+  result = ReserveRegion(0, false);
+  if (result != MAP_FAILED) {
+    uintptr_t ures = reinterpret_cast<uintptr_t>(result);
+    printf("INFO | poison area allocated at 0x%.*" PRIxPTR
+           " (fallback)\n", SIZxPTR, ures);
+    return ures;
+  }
+
+  printf("ERROR | no usable poison area found\n");
+  return 0;
+}
+
+/* The "positive control" area confirms that we can allocate a page with the
+ * proper characteristics.
+ */
+static uintptr_t
+ReservePositiveControl()
+{
+
+  void* result = ReserveRegion(0, false);
+  if (result == MAP_FAILED) {
+    printf("ERROR | allocating positive control | %s\n", LastErrMsg());
+    return 0;
+  }
+  printf("INFO | positive control allocated at 0x%.*" PRIxPTR "\n",
+         SIZxPTR, (uintptr_t)result);
+  return (uintptr_t)result;
+}
+
+/* The "negative control" area confirms that our probe logic does detect a
+ * page that is readable, writable, or executable.
+ */
+static uintptr_t
+ReserveNegativeControl()
+{
+  void* result = ReserveRegion(0, true);
+  if (result == MAP_FAILED) {
+    printf("ERROR | allocating negative control | %s\n", LastErrMsg());
+    return 0;
+  }
+
+  // Fill the page with return instructions.
+  RETURN_INSTR_TYPE* p = reinterpret_cast<RETURN_INSTR_TYPE*>(result);
+  RETURN_INSTR_TYPE* limit =
+    reinterpret_cast<RETURN_INSTR_TYPE*>(
+      reinterpret_cast<char*>(result) + PageSize());
+  while (p < limit) {
+    *p++ = RETURN_INSTR;
+  }
+
+  // Now mark it executable as well as readable and writable.
+  // (mmap(PROT_EXEC) may fail when applied to anonymous memory.)
+
+  if (MakeRegionExecutable(result)) {
+    printf("ERROR | making negative control executable | %s\n", LastErrMsg());
+    return 0;
+  }
+
+  printf("INFO | negative control allocated at 0x%.*" PRIxPTR "\n",
+         SIZxPTR, (uintptr_t)result);
+  return (uintptr_t)result;
+}
+
+static void
+JumpTo(uintptr_t aOpaddr)
+{
+#ifdef __ia64
+  struct func_call
+  {
+    uintptr_t mFunc;
+    uintptr_t mGp;
+  } call = { aOpaddr, };
+  ((void (*)())&call)();
+#else
+  ((void (*)())aOpaddr)();
+#endif
+}
+
+#ifdef _WIN32
+static BOOL
+IsBadExecPtr(uintptr_t aPtr)
+{
+  BOOL ret = false;
+
+#if defined(_MSC_VER) && !defined(__clang__)
+  __try {
+    JumpTo(aPtr);
+  } __except (EXCEPTION_EXECUTE_HANDLER) {
+    ret = true;
+  }
+#else
+  printf("INFO | exec test not supported on MinGW or clang-cl builds\n");
+  // We do our best
+  ret = IsBadReadPtr((const void*)aPtr, 1);
+#endif
+  return ret;
+}
+#endif
+
+/* Test each page.  */
+static bool
+TestPage(const char* aPageLabel, uintptr_t aPageAddr, int aShouldSucceed)
+{
+  const char* oplabel;
+  uintptr_t opaddr;
+
+  bool failed = false;
+  for (unsigned int test = 0; test < 3; test++) {
+    switch (test) {
+      // The execute test must be done before the write test, because the
+      // write test will clobber memory at the target address.
+    case 0: oplabel = "reading"; opaddr = aPageAddr + PageSize()/2 - 1; break;
+    case 1: oplabel = "executing"; opaddr = aPageAddr + PageSize()/2; break;
+    case 2: oplabel = "writing"; opaddr = aPageAddr + PageSize()/2 - 1; break;
+    default: abort();
+    }
+
+#ifdef _WIN32
+    BOOL badptr;
+
+    switch (test) {
+    case 0: badptr = IsBadReadPtr((const void*)opaddr, 1); break;
+    case 1: badptr = IsBadExecPtr(opaddr); break;
+    case 2: badptr = IsBadWritePtr((void*)opaddr, 1); break;
+    default: abort();
+    }
+
+    if (badptr) {
+      if (aShouldSucceed) {
+        printf("TEST-UNEXPECTED-FAIL | %s %s\n", oplabel, aPageLabel);
+        failed = true;
+      } else {
+        printf("TEST-PASS | %s %s\n", oplabel, aPageLabel);
+      }
+    } else {
+      // if control reaches this point the probe succeeded
+      if (aShouldSucceed) {
+        printf("TEST-PASS | %s %s\n", oplabel, aPageLabel);
+      } else {
+        printf("TEST-UNEXPECTED-FAIL | %s %s\n", oplabel, aPageLabel);
+        failed = true;
+      }
+    }
+#else
+    pid_t pid = fork();
+    if (pid == -1) {
+      printf("ERROR | %s %s | fork=%s\n", oplabel, aPageLabel,
+             LastErrMsg());
+      exit(2);
+    } else if (pid == 0) {
+      volatile unsigned char scratch;
+      switch (test) {
+      case 0: scratch = *(volatile unsigned char*)opaddr; break;
+      case 1: JumpTo(opaddr); break;
+      case 2: *(volatile unsigned char*)opaddr = 0; break;
+      default: abort();
+      }
+      (void)scratch;
+      _exit(0);
+    } else {
+      int status;
+      if (waitpid(pid, &status, 0) != pid) {
+        printf("ERROR | %s %s | wait=%s\n", oplabel, aPageLabel,
+               LastErrMsg());
+        exit(2);
+      }
+
+      if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+        if (aShouldSucceed) {
+          printf("TEST-PASS | %s %s\n", oplabel, aPageLabel);
+        } else {
+          printf("TEST-UNEXPECTED-FAIL | %s %s | unexpected successful exit\n",
+                 oplabel, aPageLabel);
+          failed = true;
+        }
+      } else if (WIFEXITED(status)) {
+        printf("ERROR | %s %s | unexpected exit code %d\n",
+               oplabel, aPageLabel, WEXITSTATUS(status));
+        exit(2);
+      } else if (WIFSIGNALED(status)) {
+        if (aShouldSucceed) {
+          printf("TEST-UNEXPECTED-FAIL | %s %s | unexpected signal %d\n",
+                 oplabel, aPageLabel, WTERMSIG(status));
+          failed = true;
+        } else {
+          printf("TEST-PASS | %s %s | signal %d (as expected)\n",
+                 oplabel, aPageLabel, WTERMSIG(status));
+        }
+      } else {
+        printf("ERROR | %s %s | unexpected exit status %d\n",
+               oplabel, aPageLabel, status);
+        exit(2);
+      }
+    }
+#endif
+  }
+  return failed;
+}
+
+int
+main()
+{
+#ifdef _WIN32
+  GetSystemInfo(&sInfo_);
+#else
+  gUnixPageSize = sysconf(_SC_PAGESIZE);
+#endif
+
+  uintptr_t ncontrol = ReserveNegativeControl();
+  uintptr_t pcontrol = ReservePositiveControl();
+  uintptr_t poison = ReservePoisonArea();
+
+  if (!ncontrol || !pcontrol || !poison) {
+    return 2;
+  }
+
+  bool failed = false;
+  failed |= TestPage("negative control", ncontrol, 1);
+  failed |= TestPage("positive control", pcontrol, 0);
+  failed |= TestPage("poison area", poison, 0);
+
+  return failed ? 1 : 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestRefPtr.cpp b/src/third_party/mozjs-45/mfbt/tests/TestRefPtr.cpp
new file mode 100644
index 0000000..4d9e712
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestRefPtr.cpp
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/RefPtr.h"
+#include "mozilla/RefCounted.h"
+
+using mozilla::RefCounted;
+
+class Foo : public RefCounted<Foo>
+{
+public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(Foo)
+
+  Foo() : mDead(false) {}
+
+  static int sNumDestroyed;
+
+  ~Foo()
+  {
+    MOZ_ASSERT(!mDead);
+    mDead = true;
+    sNumDestroyed++;
+  }
+
+private:
+  bool mDead;
+};
+int Foo::sNumDestroyed;
+
+struct Bar : public Foo {};
+
+already_AddRefed<Foo>
+NewFoo()
+{
+  RefPtr<Foo> f(new Foo());
+  return f.forget();
+}
+
+already_AddRefed<Foo>
+NewBar()
+{
+  RefPtr<Bar> bar = new Bar();
+  return bar.forget();
+}
+
+void
+GetNewFoo(Foo** aFoo)
+{
+  *aFoo = new Bar();
+  // Kids, don't try this at home
+  (*aFoo)->AddRef();
+}
+
+void
+GetNewFoo(RefPtr<Foo>* aFoo)
+{
+  *aFoo = new Bar();
+}
+
+already_AddRefed<Foo>
+GetNullFoo()
+{
+  return 0;
+}
+
+int
+main()
+{
+  MOZ_RELEASE_ASSERT(0 == Foo::sNumDestroyed);
+  {
+    RefPtr<Foo> f = new Foo();
+    MOZ_RELEASE_ASSERT(f->refCount() == 1);
+  }
+  MOZ_RELEASE_ASSERT(1 == Foo::sNumDestroyed);
+
+  {
+    RefPtr<Foo> f1 = NewFoo();
+    RefPtr<Foo> f2(NewFoo());
+    MOZ_RELEASE_ASSERT(1 == Foo::sNumDestroyed);
+  }
+  MOZ_RELEASE_ASSERT(3 == Foo::sNumDestroyed);
+
+  {
+    RefPtr<Foo> b = NewBar();
+    MOZ_RELEASE_ASSERT(3 == Foo::sNumDestroyed);
+  }
+  MOZ_RELEASE_ASSERT(4 == Foo::sNumDestroyed);
+
+  {
+    RefPtr<Foo> f1;
+    {
+      f1 = new Foo();
+      RefPtr<Foo> f2(f1);
+      RefPtr<Foo> f3 = f2;
+      MOZ_RELEASE_ASSERT(4 == Foo::sNumDestroyed);
+    }
+    MOZ_RELEASE_ASSERT(4 == Foo::sNumDestroyed);
+  }
+  MOZ_RELEASE_ASSERT(5 == Foo::sNumDestroyed);
+
+  {
+    {
+      RefPtr<Foo> f = new Foo();
+      RefPtr<Foo> g = f.forget();
+    }
+    MOZ_RELEASE_ASSERT(6 == Foo::sNumDestroyed);
+  }
+
+  {
+    RefPtr<Foo> f = new Foo();
+    GetNewFoo(getter_AddRefs(f));
+    MOZ_RELEASE_ASSERT(7 == Foo::sNumDestroyed);
+  }
+  MOZ_RELEASE_ASSERT(8 == Foo::sNumDestroyed);
+
+  {
+    RefPtr<Foo> f = new Foo();
+    GetNewFoo(&f);
+    MOZ_RELEASE_ASSERT(9 == Foo::sNumDestroyed);
+  }
+  MOZ_RELEASE_ASSERT(10 == Foo::sNumDestroyed);
+
+  {
+    RefPtr<Foo> f1 = new Bar();
+  }
+  MOZ_RELEASE_ASSERT(11 == Foo::sNumDestroyed);
+
+  {
+    RefPtr<Foo> f = GetNullFoo();
+    MOZ_RELEASE_ASSERT(11 == Foo::sNumDestroyed);
+  }
+  MOZ_RELEASE_ASSERT(11 == Foo::sNumDestroyed);
+
+  return 0;
+}
+
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestRollingMean.cpp b/src/third_party/mozjs-45/mfbt/tests/TestRollingMean.cpp
new file mode 100644
index 0000000..bec7778
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestRollingMean.cpp
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/RollingMean.h"
+
+using mozilla::RollingMean;
+
+class MyClass
+{
+public:
+  uint32_t mValue;
+
+  explicit MyClass(uint32_t aValue = 0) : mValue(aValue) { }
+
+  bool operator==(const MyClass& aOther) const
+  {
+    return mValue == aOther.mValue;
+  }
+
+  MyClass operator+(const MyClass& aOther) const
+  {
+    return MyClass(mValue + aOther.mValue);
+  }
+
+  MyClass operator-(const MyClass& aOther) const
+  {
+    return MyClass(mValue - aOther.mValue);
+  }
+
+  MyClass operator/(uint32_t aDiv) const
+  {
+    return MyClass(mValue / aDiv);
+  }
+};
+
+class RollingMeanSuite
+{
+public:
+  RollingMeanSuite() { }
+
+  void runTests() {
+    testZero();
+    testClear();
+    testRolling();
+    testClass();
+    testMove();
+  }
+
+private:
+  void testZero()
+  {
+    RollingMean<uint32_t, uint64_t> mean(3);
+    MOZ_RELEASE_ASSERT(mean.empty());
+  }
+
+  void testClear()
+  {
+    RollingMean<uint32_t, uint64_t> mean(3);
+
+    mean.insert(4);
+    MOZ_RELEASE_ASSERT(mean.mean() == 4);
+
+    mean.clear();
+    MOZ_RELEASE_ASSERT(mean.empty());
+
+    mean.insert(3);
+    MOZ_RELEASE_ASSERT(mean.mean() == 3);
+  }
+
+  void testRolling()
+  {
+    RollingMean<uint32_t, uint64_t> mean(3);
+
+    mean.insert(10);
+    MOZ_RELEASE_ASSERT(mean.mean() == 10);
+
+    mean.insert(20);
+    MOZ_RELEASE_ASSERT(mean.mean() == 15);
+
+    mean.insert(35);
+    MOZ_RELEASE_ASSERT(mean.mean() == 21);
+
+    mean.insert(5);
+    MOZ_RELEASE_ASSERT(mean.mean() == 20);
+
+    mean.insert(10);
+    MOZ_RELEASE_ASSERT(mean.mean() == 16);
+  }
+
+  void testClass()
+  {
+    RollingMean<MyClass, MyClass> mean(3);
+
+    mean.insert(MyClass(4));
+    MOZ_RELEASE_ASSERT(mean.mean() == MyClass(4));
+
+    mean.clear();
+    MOZ_RELEASE_ASSERT(mean.empty());
+  }
+
+  void testMove()
+  {
+    RollingMean<uint32_t, uint64_t> mean(3);
+    mean = RollingMean<uint32_t, uint64_t>(4);
+    MOZ_RELEASE_ASSERT(mean.maxValues() == 4);
+
+    mean.insert(10);
+    MOZ_RELEASE_ASSERT(mean.mean() == 10);
+
+    mean = RollingMean<uint32_t, uint64_t>(3);
+    mean.insert(30);
+    mean.insert(40);
+    mean.insert(50);
+    mean.insert(60);
+    MOZ_RELEASE_ASSERT(mean.mean() == 50);
+  }
+};
+
+int
+main()
+{
+  RollingMeanSuite suite;
+  suite.runTests();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestSHA1.cpp b/src/third_party/mozjs-45/mfbt/tests/TestSHA1.cpp
new file mode 100644
index 0000000..fd64df1
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestSHA1.cpp
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/SHA1.h"
+
+using mozilla::SHA1Sum;
+
+static unsigned int gTestV[1024] = {
+  0x048edc1a, 0x4345588c, 0x0ef03cbf, 0x1d6438f5, 0x094e0a1e, 0x68535f60,
+  0x14e8c927, 0x60190043, 0x5d640ab7, 0x73dc7c62, 0x364223f9, 0x47320292,
+  0x3924cae0, 0x5f6b26d3, 0x5efa04ef, 0x7aab361e, 0x2773b1aa, 0x1631b07d,
+  0x385b5dd1, 0x26c809b0, 0x28ad3a9f, 0x0315292a, 0x1a544e67, 0x1e79dcb9,
+  0x787683e8, 0x3a591c75, 0x1dd338c7, 0x01c539e5, 0x1c15b23e, 0x0697c25c,
+  0x4df5fd45, 0x672aa324, 0x39f74e6e, 0x269cdd5f, 0x087b6fce, 0x293509db,
+  0x0aef54a9, 0x210c4cc5, 0x29d6dc4a, 0x16320825, 0x3ab7b181, 0x56d6fd25,
+  0x6837fda2, 0x3e7994c2, 0x37f77529, 0x48c85472, 0x424fd84d, 0x00aba7fa,
+  0x6d8475de, 0x354634a7, 0x0c73bb49, 0x0a335de6, 0x0a9ea542, 0x5ffb31f1,
+  0x00a6a3f2, 0x76b14a03, 0x1e436a37, 0x173b766a, 0x33cf3ca0, 0x34eb0f1a,
+  0x4ca073ee, 0x27591fe6, 0x5eaf3356, 0x10c24493, 0x1bad88b6, 0x676f2309,
+  0x7f5e2d91, 0x74bd4c83, 0x66549b43, 0x52ffdf24, 0x2dfa0a83, 0x7c3e1cbf,
+  0x1edf87fc, 0x1f6fa930, 0x7c29bc74, 0x374bcd2f, 0x5b43de94, 0x0d09a3a6,
+  0x7437ecb0, 0x635117f8, 0x2aa78f65, 0x2c788958, 0x098cb9f3, 0x13ed5b3f,
+  0x41b7c7ba, 0x696b2d88, 0x42e20d63, 0x69585b1d, 0x4a9b027c, 0x0c761cba,
+  0x563bdbc4, 0x3bde2f5b, 0x0bab9730, 0x7740104c, 0x11641702, 0x26f03c32,
+  0x011a87c6, 0x2c5e4e6c, 0x46c34200, 0x6a167e84, 0x34205728, 0x0e8a6152,
+  0x0014604b, 0x6793bacd, 0x442bca9c, 0x6f2018ce, 0x4313e07e, 0x77f2c69c,
+  0x62621441, 0x47bf6358, 0x59c45e04, 0x16ba3426, 0x6ac0c19d, 0x20218c6b,
+  0x510b4ddc, 0x585f6c9d, 0x1ed02b0c, 0x366bf0a9, 0x131c7f59, 0x0ebcd320,
+  0x00ca858a, 0x5efbcb77, 0x2a7a1859, 0x64bb5afd, 0x76258886, 0x6505c895,
+  0x602cfa32, 0x17040942, 0x783df744, 0x3838e0ae, 0x6a021e39, 0x4c8c9c5a,
+  0x4a5e96b6, 0x10f4477d, 0x247fda4f, 0x4c390400, 0x0cbe048c, 0x7b547d26,
+  0x1e2e6897, 0x4ba7e01b, 0x5cfea1bb, 0x39a2d199, 0x45aee64a, 0x12615500,
+  0x0151615f, 0x1a9f5d33, 0x4542ed44, 0x101357eb, 0x35a16b1f, 0x3420b3e1,
+  0x6442bac7, 0x1c0f2a8c, 0x68d642f1, 0x45744fc4, 0x048e60cb, 0x5f217f44,
+  0x6cc7d151, 0x27f41984, 0x2d01eb09, 0x2bb15aea, 0x6dda49f8, 0x590dd6bc,
+  0x280cc20b, 0x7e2592b5, 0x043642f0, 0x292b5d29, 0x2e0a9b69, 0x41162471,
+  0x1e55db6b, 0x648b96fe, 0x05f8f9d1, 0x4a9d4cbb, 0x38517039, 0x2b0f8917,
+  0x4d1e67bb, 0x713e0974, 0x64fdf214, 0x11223963, 0x2bd09d24, 0x19924092,
+  0x4b4a70f0, 0x1ece6b03, 0x1780c9c1, 0x09b4c3ac, 0x58ac7e73, 0x5c9a4747,
+  0x321f943b, 0x41167667, 0x3a19cf8c, 0x53f4144d, 0x03a498de, 0x6fb4b742,
+  0x54d793cb, 0x7ee164e2, 0x501af74c, 0x43201e7f, 0x0ad581be, 0x497f046a,
+  0x3b1d2a9f, 0x53b88eb0, 0x2c3a26c5, 0x5ae970ba, 0x7d7ee4ff, 0x471366c5,
+  0x46119703, 0x3bfc2e58, 0x456d6c4f, 0x4b6bb181, 0x45d7c872, 0x0d023221,
+  0x021176d1, 0x4195ad44, 0x4621ec90, 0x3ae68279, 0x57952f71, 0x1796080c,
+  0x228077bb, 0x5e2b7fee, 0x3d71dd88, 0x4a651849, 0x7f1c8081, 0x04c333fc,
+  0x1f99bff6, 0x11b7754c, 0x740be324, 0x069bf2e2, 0x0802f3e0, 0x371cf30e,
+  0x1d44dda5, 0x6033b9e5, 0x5639a9b0, 0x6526bfff, 0x14d7d9b7, 0x4182b6a7,
+  0x01a5fa76, 0x7aa5e581, 0x762465e6, 0x386b3a2e, 0x495a3ab0, 0x04421b2e,
+  0x46e04591, 0x472af458, 0x6a007dd3, 0x2e8be484, 0x18660abe, 0x7969af82,
+  0x5a242a83, 0x581b5f72, 0x5f0eff6d, 0x38aea98c, 0x2acb5853, 0x6d650b35,
+  0x10b750d7, 0x18fdcd14, 0x09b4816c, 0x3ceef016, 0x6957153c, 0x27cf39fb,
+  0x60e3495d, 0x381e1da6, 0x4b5be02d, 0x14b6f309, 0x6380c589, 0x1a31f436,
+  0x4b5e50c1, 0x493ac048, 0x314baad1, 0x71e24ab7, 0x718af49c, 0x022f4658,
+  0x1a419d5b, 0x1854610d, 0x2ec4e99a, 0x7096ce50, 0x5467ba00, 0x404aab4c,
+  0x1a5ab015, 0x217580f7, 0x2d50071e, 0x71a9f437, 0x27f758b5, 0x11cd8b3f,
+  0x63b089c9, 0x53c860c1, 0x2fa6b7d7, 0x61e54771, 0x5c0ba6b9, 0x3138f796,
+  0x5c7359cd, 0x4c2c5654, 0x549d581c, 0x3129ebf7, 0x4958a248, 0x1a460541,
+  0x68e64964, 0x597c0609, 0x57afcbab, 0x2f1c6479, 0x57a0ad5c, 0x5936938f,
+  0x536a5cbe, 0x29aacf0b, 0x43eca70d, 0x6e7a3e4e, 0x563c1e3b, 0x32f23909,
+  0x12faa42d, 0x28b0bbde, 0x797e2842, 0x1b827bdf, 0x0df96a6e, 0x542ef7f4,
+  0x6226d368, 0x01cb4258, 0x77bcba08, 0x7e6dc041, 0x0571eda3, 0x0fdf5065,
+  0x5c9b9f7a, 0x2b496dd6, 0x02d3b40b, 0x3a5752db, 0x4843a293, 0x6fdc9c3f,
+  0x42963996, 0x39c9e4eb, 0x01db58ad, 0x7e79381c, 0x5bb207bb, 0x2df5de51,
+  0x1549ec82, 0x64f01e70, 0x536eb0d0, 0x10fa6e03, 0x5b7f9a20, 0x2d8b625d,
+  0x397410c7, 0x7778284e, 0x1ab75170, 0x254f304e, 0x395ba877, 0x0c2e2815,
+  0x5c723dec, 0x63b91327, 0x7c5954b5, 0x67dd69a3, 0x21d220c7, 0x5a287fcd,
+  0x0d0b9c59, 0x22444c9f, 0x6305cb43, 0x12f717cc, 0x77c11945, 0x0e79bda8,
+  0x6e014391, 0x441d0179, 0x5e17dd2f, 0x53e57a5c, 0x692f4b9a, 0x76c1e94b,
+  0x5a872d81, 0x044f7e7e, 0x0970844f, 0x25e34e73, 0x57865d3c, 0x640771d2,
+  0x12d410ed, 0x1424e079, 0x3e1c7fd7, 0x0e89295a, 0x48dcf262, 0x55a29550,
+  0x0fd4d360, 0x7494d449, 0x41e6f260, 0x2230d4e7, 0x5ad1cd49, 0x7f8dd428,
+  0x7722b48a, 0x7a14848d, 0x2a83335a, 0x548c0d9b, 0x24f5d43b, 0x33a417cb,
+  0x3061e078, 0x1a1bc935, 0x5aedb5df, 0x6755f3e4, 0x795e4cdb, 0x64dfcd1c,
+  0x6d5164fc, 0x34a3df0e, 0x2cc92142, 0x2569127d, 0x130f3d86, 0x43617cc2,
+  0x25eaf1fa, 0x044ae792, 0x4b47ee17, 0x6879ea87, 0x7eb455fa, 0x54481e19,
+  0x13bba2f0, 0x6da3fe79, 0x19c306ff, 0x42591e38, 0x2b0e205d, 0x60bd48bc,
+  0x550aa0ce, 0x2296a6ef, 0x551eb052, 0x76df1b8e, 0x242a2d22, 0x0ada0b06,
+  0x58b661ec, 0x490bec94, 0x20bd7c59, 0x760de8c3, 0x7a048ee8, 0x44ba6dcd,
+  0x3816abd9, 0x47e8527e, 0x2194a188, 0x6967a480, 0x7f7e2083, 0x0ec455f3,
+  0x78198eab, 0x3d710773, 0x05969198, 0x76ffcffe, 0x54be4797, 0x11105781,
+  0x3a851719, 0x516284b8, 0x4295de1c, 0x3905be43, 0x6d4e7d6a, 0x0877796d,
+  0x0b9e986a, 0x5e2b853f, 0x7e6c79cd, 0x4a44a54c, 0x1e28b9a2, 0x5b1e408e,
+  0x6a1c8eac, 0x62a87929, 0x4f075dac, 0x5c030e8c, 0x3df73ce9, 0x321c3c69,
+  0x2325cc45, 0x4eaf0759, 0x486a31fb, 0x12d04b94, 0x714e15d5, 0x420d1910,
+  0x092dc45b, 0x0119beac, 0x68b2bfdb, 0x74863a17, 0x3c7ab8e5, 0x035bc2df,
+  0x4e7a7965, 0x017f58d6, 0x6414074e, 0x3a1e64ae, 0x2d6725d8, 0x0f22f82a,
+  0x0a0affa0, 0x4159f31e, 0x4002cb9d, 0x234e393f, 0x6028169f, 0x3b804078,
+  0x0c16e2e1, 0x0e198020, 0x24b13c40, 0x1ceb2143, 0x38dd4246, 0x6f483590,
+  0x69b20a6e, 0x105580b1, 0x5d60f184, 0x065d18eb, 0x09a28739, 0x70345728,
+  0x595a5934, 0x14a78a43, 0x449f05c7, 0x6556fcfc, 0x260bc0b2, 0x3afb600e,
+  0x1f47bb91, 0x145c14b6, 0x541832fe, 0x54f10f23, 0x3013650e, 0x6c0d32ba,
+  0x4f202c8d, 0x66bcc661, 0x6131dc7f, 0x04828b25, 0x1737565d, 0x520e967f,
+  0x16cf0438, 0x6f2bc19e, 0x553c3dda, 0x356906b0, 0x333916d5, 0x2887c195,
+  0x11e7440b, 0x6354f182, 0x06b2f977, 0x6d2c9a5c, 0x2d02bfb7, 0x74fafcf6,
+  0x2b955161, 0x74035c38, 0x6e9bc991, 0x09a3a5b9, 0x460f416a, 0x11afabfc,
+  0x66e32d10, 0x4a56ac6e, 0x6448afa8, 0x680b0044, 0x05d0e296, 0x49569eac,
+  0x0adb563b, 0x4a9da168, 0x4f857004, 0x0f234600, 0x6db386ec, 0x280b94bf,
+  0x7cd258a5, 0x6165fd88, 0x3bf2aac9, 0x2cb47c44, 0x2381c2a4, 0x4fe42552,
+  0x21d4c81e, 0x24baa9af, 0x365231cb, 0x11b7fc81, 0x419748fb, 0x38ff637e,
+  0x065f3365, 0x21f1aba8, 0x2df41ace, 0x5cec1d95, 0x22c078a8, 0x7bb894fc,
+  0x2d66fc53, 0x7ed82ccc, 0x4485c9d7, 0x1af210fc, 0x5d2faa09, 0x3b33412e,
+  0x79d12ea8, 0x7bb8103b, 0x5cea1a7b, 0x2779db45, 0x1250ed5b, 0x0c4d8964,
+  0x6c18e9f5, 0x501ddc60, 0x3de43ae4, 0x6c0e8577, 0x0adfb426, 0x7ec718f5,
+  0x1991f387, 0x101ccb9c, 0x632360b4, 0x7d52ce4d, 0x0b58c91c, 0x1fa59d53,
+  0x0b0b48b0, 0x297315d0, 0x7f3132ff, 0x323b85d1, 0x2f852141, 0x23e84bdc,
+  0x3732cb25, 0x1274eb57, 0x21a882c3, 0x095288a9, 0x2120e253, 0x617799ce,
+  0x5e4926b3, 0x52575363, 0x696722e0, 0x509c9117, 0x3b60f14f, 0x423310fa,
+  0x4e694e80, 0x000a647e, 0x453e283a, 0x3f1d21ef, 0x527c91f0, 0x7ac2e88a,
+  0x1ba3b840, 0x1c3f253a, 0x04c40280, 0x437dc361, 0x7247859c, 0x61e5b34c,
+  0x20746a53, 0x58cfc2df, 0x79edf48e, 0x5b48e723, 0x7b08baac, 0x1d1035ea,
+  0x023fc918, 0x2de0427c, 0x71540904, 0x4030e8f5, 0x2b0961f6, 0x4ec98ef0,
+  0x781076ee, 0x0dac959b, 0x16f66214, 0x273411e5, 0x02334297, 0x3b568cd1,
+  0x7cf4e8c0, 0x0f4c2c91, 0x2d8dd28e, 0x4a7b3fb0, 0x237969ae, 0x363d6cb6,
+  0x75fee60a, 0x5825f4df, 0x29f79f9d, 0x22de4f33, 0x2309590e, 0x1977c2bd,
+  0x67f7bebe, 0x452b8330, 0x5dc70832, 0x5cddbea4, 0x59091e0b, 0x4d287830,
+  0x2bbc2ce6, 0x420ee023, 0x02d6e086, 0x228a7a14, 0x48207207, 0x1d5ccc5a,
+  0x37d32cdc, 0x50dc6508, 0x0b795304, 0x5b9fd543, 0x2a3f2925, 0x72e71606,
+  0x0dc8ba42, 0x3279a910, 0x6bd2c2e2, 0x775065d8, 0x547c59a6, 0x4b5374cf,
+  0x0c45cd18, 0x532096d6, 0x351c9bd1, 0x107fdce0, 0x3ae69075, 0x5dddd5de,
+  0x3bb0ba8b, 0x0b1a0019, 0x6c226525, 0x109e9002, 0x312191be, 0x16fa3de8,
+  0x4a5197aa, 0x0931b2d2, 0x79ee6e1b, 0x657a142b, 0x6ab74d38, 0x77440cff,
+  0x11e37956, 0x5c335799, 0x269d3be3, 0x18923cfd, 0x4dd71b00, 0x77c58014,
+  0x07145324, 0x1678546a, 0x5dfd4f6a, 0x207f4e13, 0x6b0a98c0, 0x015bc2cf,
+  0x1636d8fe, 0x7bc5f038, 0x183a0661, 0x573ec5f3, 0x54cf2255, 0x2fcc905c,
+  0x71bb70b9, 0x2b122a89, 0x59f86e5b, 0x5528273d, 0x464cf857, 0x27efdeec,
+  0x1d0bcfcc, 0x64d7837f, 0x1e7a659a, 0x02aa611c, 0x53969ad5, 0x0e83f59f,
+  0x50a6d11b, 0x79513c59, 0x0e5c3c98, 0x2ed7bbcf, 0x117de9d9, 0x375ec696,
+  0x19c830aa, 0x66950511, 0x2b6dbbaa, 0x5ca18c9b, 0x0a487514, 0x6f44a887,
+  0x6921bc6e, 0x3ef8130b, 0x26f6cde3, 0x686d7605, 0x6583553a, 0x29bcf7cc,
+  0x55d42201, 0x1c93497c, 0x64c53231, 0x32088f6e, 0x381c5770, 0x617574d8,
+  0x09757952, 0x1a616eb0, 0x1140e8aa, 0x0ff66ffb, 0x32039001, 0x5a455e7c,
+  0x0027b906, 0x21cf154c, 0x67d3527f, 0x56fd7602, 0x150f8b25, 0x2ae8e4c8,
+  0x0bf10aec, 0x3d26a40f, 0x5c4c8ffc, 0x3c291322, 0x737fd02c, 0x4b506209,
+  0x484ddaa4, 0x00b44669, 0x5974bdd1, 0x7d39d617, 0x12995404, 0x48f00bbe,
+  0x44f7c59a, 0x23cb9292, 0x6476f20b, 0x034fbd59, 0x2893161c, 0x1dbae8c0,
+  0x50348c2e, 0x797f0957, 0x685ddeaf, 0x36fb8a2e, 0x0fceb6f4, 0x10347ab4,
+  0x72720bfc, 0x292a4304, 0x0cbf8a27, 0x3cea6db7, 0x4b0c6b15, 0x57e8e716,
+  0x4e9c54cc, 0x4fc7f7ca, 0x49a6d3e2, 0x10fc2df3, 0x73db387e, 0x72cb89c3,
+  0x71dba437, 0x4b14048c, 0x6e1af265, 0x1084b213, 0x3842107d, 0x6ecdc171,
+  0x647919b2, 0x41a80841, 0x7b387c76, 0x46bc094b, 0x331b312a, 0x2f140cc4,
+  0x355d0a11, 0x19390200, 0x69b05263, 0x582963fa, 0x44897e31, 0x66a473f0,
+  0x0374f08d, 0x35879e45, 0x5e1dd7ef, 0x34d6a311, 0x6e4e18eb, 0x7b44734b,
+  0x0e421333, 0x3da026d8, 0x5becbf4b, 0x56db4a1f, 0x1f2089bc, 0x28c733f2,
+  0x04b0975d, 0x6156f224, 0x12d1f40f, 0x7f4d30f4, 0x2c0b9861, 0x769a083b,
+  0x739544fb, 0x1dbd1067, 0x0e8cd717, 0x4c246fb2, 0x115eff39, 0x19e22f2a,
+  0x4563ba61, 0x5d33a617, 0x54af83cf, 0x030bde73, 0x54b4736d, 0x0f01dfec,
+  0x08869c01, 0x4e9e4d7b, 0x4739855a, 0x62d964a3, 0x26948fde, 0x30adf212,
+  0x1f57b400, 0x3766c914, 0x1e7f9d1c, 0x33258b59, 0x522ab2c2, 0x3dc99798,
+  0x15f53fe2, 0x05636669, 0x354b59c3, 0x1c37ebd4, 0x0bb7ebf9, 0x0e4e87f9,
+  0x680d3124, 0x2770d549, 0x0c5e112e, 0x74aaa7ed, 0x06c0b550, 0x342b5922,
+  0x4532ab5b, 0x4257dbee, 0x087f32a9, 0x45ada3e3, 0x7a854272, 0x061625f2,
+  0x47c85a91, 0x25ad375d, 0x2809bd9d, 0x168b9348, 0x4381b0a3, 0x6f2dc6ca,
+  0x122e54f6, 0x6c3228a6, 0x653c1652, 0x60b60584, 0x1d304b77, 0x4cc74c58,
+  0x087e3dd5, 0x79bd540e, 0x79ab7a70, 0x26fcd1c9, 0x342abaaf, 0x644716b0,
+  0x01f076cb, 0x73628937, 0x20b01ff8, 0x5832b80b, 0x2f77fc92, 0x4468d962,
+  0x2bac2679, 0x7f850778, 0x47d2997c, 0x02690cb7, 0x7de54951, 0x54d80b14,
+  0x5e0c6854, 0x313cc749, 0x622b86ba, 0x38dbf6d3, 0x045d3e52, 0x574f87fd,
+  0x09f1b078, 0x31784f71, 0x4f01dd2f, 0x1874c9f9, 0x5837c7af, 0x2372f768,
+  0x531bd1e8, 0x61816c0b, 0x4592995f, 0x156463c0, 0x250c5afe, 0x40c83178,
+  0x4396f6b7, 0x29bdbec0, 0x43ea8ca5, 0x5c474696, 0x2c869192, 0x2ff2f51a,
+  0x7c963fe5, 0x294319c1, 0x019fbe26, 0x72fa8e68, 0x245ca463, 0x4ca88208,
+  0x72ac845a, 0x25307181, 0x2cdf88f7, 0x0adbfebd, 0x2eea465b, 0x52e4eee0,
+  0x084daacd, 0x717ce67e, 0x594087c2, 0x2b8ee5c7, 0x4558f811, 0x76b65ba4,
+  0x5de05e09, 0x3db76e27, 0x3c75110d, 0x04ca67e7, 0x51cd6d09, 0x7b4e9c3e,
+  0x7cdda4d2, 0x674fb021, 0x7d372d2d, 0x13f7978b, 0x5fb106b1, 0x034377d1,
+  0x2e5336f3, 0x099bb17d, 0x04e6755e, 0x34f73c1e, 0x004e0a0d, 0x7f2c32e2,
+  0x1fc8f910, 0x67d0859d, 0x76462b25, 0x59fa9a17, 0x028e53ef, 0x3d6d5fdd,
+  0x79a4671e, 0x5cbec506, 0x2c23ee6d, 0x628a2c1e, 0x4dae87bd, 0x07a189ea,
+  0x3a414a96, 0x5915f622, 0x6bea011e, 0x412674cf, 0x07ecc314, 0x6a7dbce8,
+  0x7e176f10, 0x68e60d47, 0x079ea970, 0x79f3b55c, 0x65a46098, 0x56155533,
+  0x7e5d0272, 0x795bfad5, 0x094da770, 0x05ba427c, 0x152e430e, 0x187d8470,
+  0x08e607bc, 0x45ce5ef9, 0x654231ae, 0x38d8cb48, 0x605632f8, 0x25cf8ee9,
+  0x11497170, 0x171a3b00, 0x0f103d49, 0x24826483, 0x2848e187, 0x7498919b,
+  0x1bb788cb, 0x791ad5c7, 0x5129330e, 0x016c4436, 0x430f05bf, 0x1f06b5cd,
+  0x62df1378, 0x0423b9b4, 0x0341acaf, 0x3189543c, 0x7b96b2ea, 0x6c4865c3,
+  0x4cc7adc3, 0x78a2bff6, 0x642db7c7, 0x70d02300, 0x7cd43ac0, 0x4f5fe414,
+  0x333b52c2, 0x500d3c74, 0x65782c01, 0x3f72a2c5, 0x278f59d8, 0x493bf7f8,
+  0x16bf51a0, 0x6cc70ced, 0x6ed15979, 0x1a77abae, 0x08cadbb7, 0x2f2e0bc0,
+  0x236f5e8d, 0x1a4b4495, 0x360bd008, 0x32227d40
+};
+
+int
+main()
+{
+  SHA1Sum sum;
+  SHA1Sum::Hash hash;
+  sum.update(reinterpret_cast<const uint8_t*>(gTestV), sizeof(gTestV));
+  sum.finish(hash);
+
+  static const uint8_t expected[20] = {
+    0xc8, 0xf2, 0x09, 0x59, 0x4e, 0x64, 0x40, 0xaa, 0x7b, 0xf7, 0xb8, 0xe0,
+    0xfa, 0x44, 0xb2, 0x31, 0x95, 0xad, 0x94, 0x81
+  };
+
+  static_assert(sizeof(expected) == sizeof(SHA1Sum::Hash),
+                "expected-data size should be the same as the actual hash "
+                "size");
+
+  for (size_t i = 0; i < SHA1Sum::kHashSize; i++) {
+    MOZ_RELEASE_ASSERT(hash[i] == expected[i]);
+  }
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestScopeExit.cpp b/src/third_party/mozjs-45/mfbt/tests/TestScopeExit.cpp
new file mode 100644
index 0000000..fadd3a1
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestScopeExit.cpp
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/ScopeExit.h"
+
+using mozilla::MakeScopeExit;
+
+#define CHECK(c) \
+  do { \
+    bool cond = !!(c); \
+    MOZ_RELEASE_ASSERT(cond, "Failed assertion: " #c); \
+    if (!cond) { \
+      return false; \
+    } \
+  } while (false)
+
+static bool
+Test()
+{
+  int a = 1;
+  int b = 1;
+
+  {
+    a++;
+    auto guardA = MakeScopeExit([&] {
+      a--;
+    });
+
+    b++;
+    auto guardB = MakeScopeExit([&] {
+      b--;
+    });
+
+    guardB.release();
+  }
+
+  CHECK(a == 1);
+  CHECK(b == 2);
+
+  return true;
+}
+
+int
+main()
+{
+  if (!Test()) {
+    return 1;
+  }
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestSegmentedVector.cpp b/src/third_party/mozjs-45/mfbt/tests/TestSegmentedVector.cpp
new file mode 100644
index 0000000..d81a0d0
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestSegmentedVector.cpp
@@ -0,0 +1,179 @@
+/* -*- Mode: C++; tab-width: 9; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// This is included first to ensure it doesn't implicitly depend on anything
+// else.
+#include "mozilla/SegmentedVector.h"
+
+#include "mozilla/Alignment.h"
+#include "mozilla/Assertions.h"
+
+using mozilla::SegmentedVector;
+
+// It would be nice if we could use the InfallibleAllocPolicy from mozalloc,
+// but MFBT cannot use mozalloc.
+class InfallibleAllocPolicy
+{
+public:
+  template <typename T>
+  T* pod_malloc(size_t aNumElems)
+  {
+    if (aNumElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value) {
+      MOZ_CRASH("TestSegmentedVector.cpp: overflow");
+    }
+    T* rv = static_cast<T*>(malloc(aNumElems * sizeof(T)));
+    if (!rv) {
+      MOZ_CRASH("TestSegmentedVector.cpp: out of memory");
+    }
+    return rv;
+  }
+
+  void free_(void* aPtr) { free(aPtr); }
+};
+
+// We want to test Append(), which is fallible and marked with
+// MOZ_WARN_UNUSED_RESULT. But we're using an infallible alloc policy, and so
+// don't really need to check the result. Casting to |void| works with clang
+// but not GCC, so we instead use this dummy variable which works with both
+// compilers.
+static int gDummy;
+
+// This tests basic segmented vector construction and iteration.
+void TestBasics()
+{
+  // A SegmentedVector with a POD element type.
+  typedef SegmentedVector<int, 1024, InfallibleAllocPolicy> MyVector;
+  MyVector v;
+  int i, n;
+
+  MOZ_RELEASE_ASSERT(v.IsEmpty());
+
+  // Add 100 elements, then check various things.
+  i = 0;
+  for ( ; i < 100; i++) {
+    gDummy = v.Append(mozilla::Move(i));
+  }
+  MOZ_RELEASE_ASSERT(!v.IsEmpty());
+  MOZ_RELEASE_ASSERT(v.Length() == 100);
+
+  n = 0;
+  for (auto iter = v.Iter(); !iter.Done(); iter.Next()) {
+    MOZ_RELEASE_ASSERT(iter.Get() == n);
+    n++;
+  }
+  MOZ_RELEASE_ASSERT(n == 100);
+
+  // Add another 900 elements, then re-check.
+  for ( ; i < 1000; i++) {
+    v.InfallibleAppend(mozilla::Move(i));
+  }
+  MOZ_RELEASE_ASSERT(!v.IsEmpty());
+  MOZ_RELEASE_ASSERT(v.Length() == 1000);
+
+  n = 0;
+  for (auto iter = v.Iter(); !iter.Done(); iter.Next()) {
+    MOZ_RELEASE_ASSERT(iter.Get() == n);
+    n++;
+  }
+  MOZ_RELEASE_ASSERT(n == 1000);
+
+  // Pop off all of the elements.
+  MOZ_RELEASE_ASSERT(v.Length() == 1000);
+  for (int len = (int)v.Length(); len > 0; len--) {
+    MOZ_RELEASE_ASSERT(v.GetLast() == len - 1);
+    v.PopLast();
+  }
+  MOZ_RELEASE_ASSERT(v.IsEmpty());
+  MOZ_RELEASE_ASSERT(v.Length() == 0);
+
+  // Fill the vector up again to prepare for the clear.
+  for (i = 0; i < 1000; i++) {
+    v.InfallibleAppend(mozilla::Move(i));
+  }
+  MOZ_RELEASE_ASSERT(!v.IsEmpty());
+  MOZ_RELEASE_ASSERT(v.Length() == 1000);
+
+  v.Clear();
+  MOZ_RELEASE_ASSERT(v.IsEmpty());
+  MOZ_RELEASE_ASSERT(v.Length() == 0);
+}
+
+static size_t gNumDefaultCtors;
+static size_t gNumExplicitCtors;
+static size_t gNumCopyCtors;
+static size_t gNumMoveCtors;
+static size_t gNumDtors;
+
+struct NonPOD
+{
+  NonPOD()                { gNumDefaultCtors++; }
+  explicit NonPOD(int x)  { gNumExplicitCtors++; }
+  NonPOD(NonPOD&)         { gNumCopyCtors++; }
+  NonPOD(NonPOD&&)        { gNumMoveCtors++; }
+  ~NonPOD()               { gNumDtors++; }
+};
+
+// This tests how segmented vectors with non-POD elements construct and
+// destruct those elements.
+void TestConstructorsAndDestructors()
+{
+  {
+    // A SegmentedVector with a non-POD element type.
+    NonPOD x(1);                          // explicit constructor called
+    SegmentedVector<NonPOD, 64, InfallibleAllocPolicy> v;
+                                          // default constructor called 0 times
+    MOZ_RELEASE_ASSERT(v.IsEmpty());
+    gDummy = v.Append(x);                 // copy constructor called
+    NonPOD y(1);                          // explicit constructor called
+    gDummy = v.Append(mozilla::Move(y));  // move constructor called
+    NonPOD z(1);                          // explicit constructor called
+    v.InfallibleAppend(mozilla::Move(z)); // move constructor called
+    v.PopLast();                          // destructor called 1 time
+    MOZ_RELEASE_ASSERT(gNumDtors == 1);
+    v.Clear();                            // destructor called 2 times
+
+    MOZ_RELEASE_ASSERT(gNumDefaultCtors  == 0);
+    MOZ_RELEASE_ASSERT(gNumExplicitCtors == 3);
+    MOZ_RELEASE_ASSERT(gNumCopyCtors     == 1);
+    MOZ_RELEASE_ASSERT(gNumMoveCtors     == 2);
+    MOZ_RELEASE_ASSERT(gNumDtors         == 3);
+  }                                       // destructor called for x, y, z
+  MOZ_RELEASE_ASSERT(gNumDtors == 6);
+}
+
+struct A { int mX; int mY; };
+struct B { int mX; char mY; double mZ; };
+struct C { A mA; B mB; };
+struct D { char mBuf[101]; };
+struct E { };
+
+// This tests that we get the right segment capacities for specified segment
+// sizes, and that the elements are aligned appropriately.
+void TestSegmentCapacitiesAndAlignments()
+{
+  // When SegmentedVector's constructor is passed a size, it asserts that the
+  // vector's segment capacity results in a segment size equal to (or very
+  // close to) the passed size.
+  //
+  // Also, SegmentedVector has a static assertion that elements are
+  // appropriately aligned.
+  SegmentedVector<double, 512> v1(512);
+  SegmentedVector<A, 1024> v2(1024);
+  SegmentedVector<B, 999> v3(999);
+  SegmentedVector<C, 10> v4(10);
+  SegmentedVector<D, 1234> v5(1234);
+  SegmentedVector<E> v6(4096);  // 4096 is the default segment size
+  SegmentedVector<mozilla::AlignedElem<16>, 100> v7(100);
+}
+
+int main(void)
+{
+  TestBasics();
+  TestConstructorsAndDestructors();
+  TestSegmentCapacitiesAndAlignments();
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestSplayTree.cpp b/src/third_party/mozjs-45/mfbt/tests/TestSplayTree.cpp
new file mode 100644
index 0000000..8fad2bc
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestSplayTree.cpp
@@ -0,0 +1,212 @@
+/* -*- Mode: C++; tab-width: 9; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/ArrayUtils.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/SplayTree.h"
+#include "mozilla/unused.h"
+
+using mozilla::SplayTree;
+using mozilla::SplayTreeNode;
+
+// The following array contains the values 0..999 in random order, as computed
+// with the following Python program:
+//
+//   from random import shuffle
+//   x = range(1000)
+//   shuffle(x)
+//   print(x);
+//
+static int gValues[] = {
+  778, 999, 248, 795, 607, 177, 725, 33, 215, 565, 436, 821, 941, 802, 322, 54,
+  151, 416, 531, 65, 818, 99, 340, 401, 274, 767, 278, 617, 425, 629, 833, 878,
+  440, 984, 724, 519, 100, 369, 490, 131, 422, 169, 932, 476, 823, 521, 390,
+  781, 747, 218, 376, 461, 717, 532, 471, 298, 720, 608, 334, 788, 161, 500,
+  280, 963, 430, 484, 779, 572, 96, 333, 650, 158, 199, 137, 991, 399, 882,
+  689, 358, 548, 196, 718, 211, 388, 133, 188, 321, 892, 25, 694, 735, 886,
+  872, 785, 195, 275, 696, 975, 393, 619, 894, 18, 281, 191, 792, 846, 861,
+  351, 542, 806, 570, 702, 931, 585, 444, 284, 217, 132, 251, 253, 302, 808,
+  224, 37, 63, 863, 409, 49, 780, 790, 31, 638, 890, 186, 114, 152, 949, 491,
+  207, 392, 170, 460, 794, 482, 877, 407, 263, 909, 249, 710, 614, 51, 431,
+  915, 62, 332, 74, 495, 901, 23, 365, 752, 89, 660, 745, 741, 547, 669, 449,
+  465, 605, 107, 774, 205, 852, 266, 247, 690, 835, 765, 410, 140, 122, 400,
+  510, 664, 105, 935, 230, 134, 106, 959, 375, 884, 361, 527, 715, 840, 272,
+  232, 102, 415, 903, 117, 313, 153, 463, 464, 876, 406, 967, 713, 381, 836,
+  555, 190, 859, 172, 483, 61, 633, 294, 993, 72, 337, 11, 896, 523, 101, 916,
+  244, 566, 706, 533, 439, 201, 222, 695, 739, 553, 571, 289, 918, 209, 189,
+  357, 814, 670, 866, 910, 579, 246, 636, 750, 891, 494, 758, 341, 626, 426,
+  772, 254, 682, 588, 104, 347, 184, 977, 126, 498, 165, 955, 241, 516, 235,
+  497, 121, 123, 791, 844, 259, 995, 283, 602, 417, 221, 308, 855, 429, 86,
+  345, 928, 44, 679, 796, 363, 402, 445, 492, 450, 964, 749, 925, 847, 637,
+  982, 648, 635, 481, 564, 867, 940, 291, 159, 290, 929, 59, 712, 986, 611,
+  954, 820, 103, 622, 316, 142, 204, 225, 678, 314, 84, 578, 315, 141, 990,
+  880, 504, 969, 412, 746, 47, 517, 124, 848, 466, 438, 674, 979, 782, 651,
+  181, 26, 435, 832, 386, 951, 229, 642, 655, 91, 162, 921, 647, 113, 686, 56,
+  805, 763, 245, 581, 287, 998, 525, 641, 135, 634, 237, 728, 112, 828, 228,
+  899, 1, 723, 16, 613, 144, 659, 97, 185, 312, 292, 733, 624, 276, 387, 926,
+  339, 768, 960, 610, 807, 656, 851, 219, 582, 709, 927, 514, 680, 870, 597,
+  536, 77, 164, 512, 149, 900, 85, 335, 997, 8, 705, 777, 653, 815, 311, 701,
+  507, 202, 530, 827, 541, 958, 82, 874, 55, 487, 383, 885, 684, 180, 829, 760,
+  109, 194, 540, 816, 906, 657, 469, 446, 857, 907, 38, 600, 618, 797, 950,
+  822, 277, 842, 116, 513, 255, 424, 643, 163, 372, 129, 67, 118, 754, 529,
+  917, 687, 473, 174, 538, 939, 663, 775, 474, 242, 883, 20, 837, 293, 584,
+  943, 32, 176, 904, 14, 448, 893, 888, 744, 171, 714, 454, 691, 261, 934, 606,
+  789, 825, 671, 397, 338, 317, 612, 737, 130, 41, 923, 574, 136, 980, 850, 12,
+  729, 197, 403, 57, 783, 360, 146, 75, 432, 447, 192, 799, 740, 267, 214, 250,
+  367, 853, 968, 120, 736, 391, 881, 784, 665, 68, 398, 350, 839, 268, 697,
+  567, 428, 738, 48, 182, 70, 220, 865, 418, 374, 148, 945, 353, 539, 589, 307,
+  427, 506, 265, 558, 128, 46, 336, 299, 349, 309, 377, 304, 420, 30, 34, 875,
+  948, 212, 394, 442, 719, 273, 269, 157, 502, 675, 751, 838, 897, 862, 831,
+  676, 590, 811, 966, 854, 477, 15, 598, 573, 108, 98, 81, 408, 421, 296, 73,
+  644, 456, 362, 666, 550, 331, 368, 193, 470, 203, 769, 342, 36, 604, 60, 970,
+  748, 813, 522, 515, 90, 672, 243, 793, 947, 595, 632, 912, 475, 258, 80, 873,
+  623, 524, 546, 262, 727, 216, 505, 330, 373, 58, 297, 609, 908, 150, 206,
+  703, 755, 260, 511, 213, 198, 766, 898, 992, 488, 405, 974, 770, 936, 743,
+  554, 0, 499, 976, 94, 160, 919, 434, 324, 156, 757, 830, 677, 183, 630, 871,
+  640, 938, 518, 344, 366, 742, 552, 306, 535, 200, 652, 496, 233, 419, 787,
+  318, 981, 371, 166, 143, 384, 88, 508, 698, 812, 559, 658, 549, 208, 599,
+  621, 961, 668, 563, 93, 154, 587, 560, 389, 3, 210, 326, 4, 924, 300, 2, 804,
+  914, 801, 753, 654, 27, 236, 19, 708, 451, 985, 596, 478, 922, 240, 127, 994,
+  983, 385, 472, 40, 528, 288, 111, 543, 568, 155, 625, 759, 937, 956, 545,
+  953, 962, 382, 479, 809, 557, 501, 354, 414, 343, 378, 843, 379, 178, 556,
+  800, 803, 592, 627, 942, 576, 920, 704, 707, 726, 223, 119, 404, 24, 879,
+  722, 868, 5, 238, 817, 520, 631, 946, 462, 457, 295, 480, 957, 441, 145, 286,
+  303, 688, 17, 628, 493, 364, 226, 110, 615, 69, 320, 534, 593, 721, 411, 285,
+  869, 952, 849, 139, 356, 346, 28, 887, 810, 92, 798, 544, 458, 996, 692, 396,
+  667, 328, 173, 22, 773, 50, 645, 987, 42, 685, 734, 700, 683, 601, 580, 639,
+  913, 323, 858, 179, 761, 6, 841, 905, 234, 730, 29, 21, 575, 586, 902, 443,
+  826, 646, 257, 125, 649, 53, 453, 252, 13, 87, 971, 227, 485, 168, 380, 711,
+  79, 732, 325, 52, 468, 76, 551, 39, 395, 327, 973, 459, 45, 583, 989, 147,
+  455, 776, 944, 569, 889, 256, 35, 175, 834, 756, 933, 860, 526, 845, 864,
+  764, 771, 282, 9, 693, 352, 731, 7, 577, 264, 319, 138, 467, 819, 930, 231,
+  115, 988, 978, 762, 486, 301, 616, 10, 78, 603, 452, 965, 279, 972, 413, 895,
+  591, 662, 594, 348, 423, 489, 43, 699, 433, 509, 355, 270, 66, 83, 95, 561,
+  661, 562, 329, 620, 370, 64, 187, 503, 716, 856, 310, 786, 167, 71, 239, 359,
+  537, 437, 305, 673, 824, 911, 681, 271
+};
+
+struct SplayInt : SplayTreeNode<SplayInt>
+{
+  explicit SplayInt(int aValue) : mValue(aValue) {}
+
+  static int compare(const SplayInt& aOne, const SplayInt& aTwo)
+  {
+    if (aOne.mValue < aTwo.mValue) {
+      return -1;
+    }
+    if (aOne.mValue > aTwo.mValue) {
+      return 1;
+    }
+    return 0;
+  }
+
+  int mValue;
+};
+
+struct SplayNoCopy : SplayTreeNode<SplayNoCopy>
+{
+  SplayNoCopy(const SplayNoCopy&) = delete;
+  SplayNoCopy(SplayNoCopy&&) = delete;
+
+  static int compare(const SplayNoCopy&, const SplayNoCopy&) { return 0; }
+};
+
+static SplayTree<SplayNoCopy, SplayNoCopy> testNoCopy;
+
+int
+main()
+{
+  mozilla::Unused << testNoCopy;
+
+  SplayTree<SplayInt, SplayInt> tree;
+
+  MOZ_RELEASE_ASSERT(tree.empty());
+
+  MOZ_RELEASE_ASSERT(!tree.find(SplayInt(0)));
+
+  static const int N = mozilla::ArrayLength(gValues);
+
+  // Insert the values, and check each one is findable just after insertion.
+  for (int i = 0; i < N; i++) {
+    tree.insert(new SplayInt(gValues[i]));
+    SplayInt* inserted = tree.find(SplayInt(gValues[i]));
+    MOZ_RELEASE_ASSERT(inserted);
+    MOZ_RELEASE_ASSERT(tree.findOrInsert(SplayInt(gValues[i])) == inserted);
+    tree.checkCoherency();
+  }
+
+  // Check they're all findable after all insertions.
+  for (int i = 0; i < N; i++) {
+    MOZ_RELEASE_ASSERT(tree.find(SplayInt(gValues[i])));
+    MOZ_RELEASE_ASSERT(tree.findOrInsert(SplayInt(gValues[i])));
+    tree.checkCoherency();
+  }
+
+  // Check that non-inserted values cannot be found.
+  MOZ_RELEASE_ASSERT(!tree.find(SplayInt(-1)));
+  MOZ_RELEASE_ASSERT(!tree.find(SplayInt(N)));
+  MOZ_RELEASE_ASSERT(!tree.find(SplayInt(0x7fffffff)));
+
+  // Remove the values, and check each one is not findable just after removal.
+  for (int i = 0; i < N; i++) {
+    SplayInt* removed = tree.remove(SplayInt(gValues[i]));
+    MOZ_RELEASE_ASSERT(removed->mValue == gValues[i]);
+    MOZ_RELEASE_ASSERT(!tree.find(*removed));
+    delete removed;
+    tree.checkCoherency();
+  }
+
+  MOZ_RELEASE_ASSERT(tree.empty());
+
+  // Insert the values, and check each one is findable just after insertion.
+  for (int i = 0; i < N; i++) {
+    SplayInt* inserted = tree.findOrInsert(SplayInt(gValues[i]));
+    MOZ_RELEASE_ASSERT(tree.find(SplayInt(gValues[i])) == inserted);
+    MOZ_RELEASE_ASSERT(tree.findOrInsert(SplayInt(gValues[i])) == inserted);
+    tree.checkCoherency();
+  }
+
+  // Check they're all findable after all insertions.
+  for (int i = 0; i < N; i++) {
+    MOZ_RELEASE_ASSERT(tree.find(SplayInt(gValues[i])));
+    MOZ_RELEASE_ASSERT(tree.findOrInsert(SplayInt(gValues[i])));
+    tree.checkCoherency();
+  }
+
+  // Check that non-inserted values cannot be found.
+  MOZ_RELEASE_ASSERT(!tree.find(SplayInt(-1)));
+  MOZ_RELEASE_ASSERT(!tree.find(SplayInt(N)));
+  MOZ_RELEASE_ASSERT(!tree.find(SplayInt(0x7fffffff)));
+
+  // Remove the values, and check each one is not findable just after removal.
+  for (int i = 0; i < N; i++) {
+    SplayInt* removed = tree.remove(SplayInt(gValues[i]));
+    MOZ_RELEASE_ASSERT(removed->mValue == gValues[i]);
+    MOZ_RELEASE_ASSERT(!tree.find(*removed));
+    delete removed;
+    tree.checkCoherency();
+  }
+
+  MOZ_RELEASE_ASSERT(tree.empty());
+
+  // Reinsert the values, in reverse order to last time.
+  for (int i = 0; i < N; i++) {
+    tree.insert(new SplayInt(gValues[N - i - 1]));
+    tree.checkCoherency();
+  }
+
+  // Remove the minimum value repeatedly.
+  for (int i = 0; i < N; i++) {
+    SplayInt* removed = tree.removeMin();
+    MOZ_RELEASE_ASSERT(removed->mValue == i);
+    delete removed;
+    tree.checkCoherency();
+  }
+
+  MOZ_RELEASE_ASSERT(tree.empty());
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestTemplateLib.cpp b/src/third_party/mozjs-45/mfbt/tests/TestTemplateLib.cpp
new file mode 100644
index 0000000..7ad0831
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestTemplateLib.cpp
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/TemplateLib.h"
+
+using mozilla::tl::And;
+
+static_assert(And<>::value == true,
+              "And<>::value should be true");
+static_assert(And<true>::value == true,
+              "And<true>::value should be true");
+static_assert(And<false>::value == false,
+              "And<false>::value should be false");
+static_assert(And<false, true>::value == false,
+              "And<false, true>::value should be false");
+static_assert(And<false, false>::value == false,
+              "And<false, false>::value should be false");
+static_assert(And<true, false>::value == false,
+              "And<true, false>::value should be false");
+static_assert(And<true, true>::value == true,
+              "And<true, true>::value should be true");
+static_assert(And<true, true, true>::value == true,
+              "And<true, true, true>::value should be true");
+static_assert(And<true, false, true>::value == false,
+              "And<true, false, true>::value should be false");
+
+int
+main()
+{
+  // Nothing to do here.
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestTuple.cpp b/src/third_party/mozjs-45/mfbt/tests/TestTuple.cpp
new file mode 100644
index 0000000..b5ad664
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestTuple.cpp
@@ -0,0 +1,302 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+   /* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Move.h"
+#include "mozilla/Pair.h"
+#include "mozilla/Tuple.h"
+#include "mozilla/TypeTraits.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/unused.h"
+
+#include <stddef.h>
+#include <utility>
+
+using mozilla::Get;
+using mozilla::IsSame;
+using mozilla::MakeTuple;
+using mozilla::MakeUnique;
+using mozilla::Move;
+using mozilla::Pair;
+using mozilla::Tie;
+using mozilla::Tuple;
+using mozilla::UniquePtr;
+using mozilla::Unused;
+using std::pair;
+
+#if (_MSC_VER == 1800)
+// Optimizations in VS2013 on Windows 10 cause an internal compiler error
+// with this file.
+#pragma optimize("", off)
+#endif
+
+#define CHECK(c) \
+  do { \
+    bool cond = !!(c); \
+    MOZ_RELEASE_ASSERT(cond, "Failed assertion: " #c); \
+  } while (false)
+
+// The second argument is the expected type. It's variadic to allow the
+// type to contain commas.
+#define CHECK_TYPE(expression, ...)  \
+  static_assert(IsSame<decltype(expression), __VA_ARGS__>::value, \
+      "Type mismatch!")
+
+struct ConvertibleToInt
+{
+  operator int() const { return 42; }
+};
+
+static void
+TestConstruction()
+{
+  // Default construction
+  Tuple<> a;
+  Unused << a;
+  Tuple<int> b;
+  Unused << b;
+
+  // Construction from elements
+  int x = 1, y = 1;
+  Tuple<int, int> c{x, y};
+  Tuple<int&, const int&> d{x, y};
+  x = 42;
+  y = 42;
+  CHECK(Get<0>(c) == 1);
+  CHECK(Get<1>(c) == 1);
+  CHECK(Get<0>(d) == 42);
+  CHECK(Get<1>(d) == 42);
+
+  // Construction from objects convertible to the element types
+  Tuple<int, int> e{1.0, ConvertibleToInt{}};
+
+  // Copy construction
+  Tuple<int> x1;
+  Tuple<int> x2{x1};
+
+  Tuple<int, int> f(c);
+  CHECK(Get<0>(f) == 1);
+  CHECK(Get<0>(f) == 1);
+
+  // Move construction
+  Tuple<UniquePtr<int>> g{MakeUnique<int>(42)};
+  Tuple<UniquePtr<int>> h{Move(g)};
+  CHECK(Get<0>(g) == nullptr);
+  CHECK(*Get<0>(h) == 42);
+}
+
+static void
+TestConstructionFromMozPair()
+{
+  // Construction from elements
+  int x = 1, y = 1;
+  Pair<int, int> a{x, y};
+  Pair<int&, const int&> b{x, y};
+  Tuple<int, int> c(a);
+  Tuple<int&, const int&> d(b);
+  x = 42;
+  y = 42;
+  CHECK(Get<0>(c) == 1);
+  CHECK(Get<1>(c) == 1);
+  CHECK(Get<0>(d) == 42);
+  CHECK(Get<1>(d) == 42);
+}
+
+static void
+TestConstructionFromStdPair()
+{
+  // Construction from elements
+  int x = 1, y = 1;
+  pair<int, int> a{x, y};
+  pair<int&, const int&> b{x, y};
+  Tuple<int, int> c(a);
+  Tuple<int&, const int&> d(b);
+  x = 42;
+  y = 42;
+  CHECK(Get<0>(c) == 1);
+  CHECK(Get<1>(c) == 1);
+  CHECK(Get<0>(d) == 42);
+  CHECK(Get<1>(d) == 42);
+}
+
+static void
+TestAssignment()
+{
+  // Copy assignment
+  Tuple<int> a{0};
+  Tuple<int> b{42};
+  a = b;
+  CHECK(Get<0>(a) == 42);
+
+  // Assignment to reference member
+  int i = 0;
+  int j = 42;
+  Tuple<int&> c{i};
+  Tuple<int&> d{j};
+  c = d;
+  CHECK(i == 42);
+
+  // Move assignment
+  Tuple<UniquePtr<int>> e{MakeUnique<int>(0)};
+  Tuple<UniquePtr<int>> f{MakeUnique<int>(42)};
+  e = Move(f);
+  CHECK(*Get<0>(e) == 42);
+  CHECK(Get<0>(f) == nullptr);
+}
+
+static void
+TestAssignmentFromMozPair()
+{
+  // Copy assignment
+  Tuple<int, int> a{0, 0};
+  Pair<int, int> b{42, 42};
+  a = b;
+  CHECK(Get<0>(a) == 42);
+  CHECK(Get<1>(a) == 42);
+
+  // Assignment to reference member
+  int i = 0;
+  int j = 0;
+  int k = 42;
+  Tuple<int&, int&> c{i, j};
+  Pair<int&, int&> d{k, k};
+  c = d;
+  CHECK(i == 42);
+  CHECK(j == 42);
+
+  // Move assignment
+  Tuple<UniquePtr<int>, UniquePtr<int>> e{MakeUnique<int>(0),
+                                          MakeUnique<int>(0)};
+  Pair<UniquePtr<int>, UniquePtr<int>> f{MakeUnique<int>(42),
+                                         MakeUnique<int>(42)};
+  e = Move(f);
+  CHECK(*Get<0>(e) == 42);
+  CHECK(*Get<1>(e) == 42);
+  CHECK(f.first() == nullptr);
+  CHECK(f.second() == nullptr);
+}
+
+static void
+TestAssignmentFromStdPair()
+{
+  // Copy assignment
+  Tuple<int, int> a{0, 0};
+  pair<int, int> b{42, 42};
+  a = b;
+  CHECK(Get<0>(a) == 42);
+  CHECK(Get<1>(a) == 42);
+
+  // Assignment to reference member
+  int i = 0;
+  int j = 0;
+  int k = 42;
+  Tuple<int&, int&> c{i, j};
+  pair<int&, int&> d{k, k};
+  c = d;
+  CHECK(i == 42);
+  CHECK(j == 42);
+
+  // Move assignment.
+  Tuple<UniquePtr<int>, UniquePtr<int>> e{MakeUnique<int>(0), MakeUnique<int>(0)};
+  // XXX: On some platforms std::pair doesn't support move constructor.
+  pair<UniquePtr<int>, UniquePtr<int>> f;
+  f.first = MakeUnique<int>(42);
+  f.second = MakeUnique<int>(42);
+
+  e = Move(f);
+  CHECK(*Get<0>(e) == 42);
+  CHECK(*Get<1>(e) == 42);
+  CHECK(f.first == nullptr);
+  CHECK(f.second == nullptr);
+}
+
+static void
+TestGet()
+{
+  int x = 1;
+  int y = 2;
+  int z = 3;
+  Tuple<int, int&, const int&> tuple(x, y, z);
+
+  // Using Get<>() to read elements
+  CHECK(Get<0>(tuple) == 1);
+  CHECK(Get<1>(tuple) == 2);
+  CHECK(Get<2>(tuple) == 3);
+
+  // Using Get<>() to write to elements
+  Get<0>(tuple) = 41;
+  CHECK(Get<0>(tuple) == 41);
+
+  // Writing through reference elements
+  Get<1>(tuple) = 42;
+  CHECK(Get<1>(tuple) == 42);
+  CHECK(y == 42);
+}
+
+static void
+TestMakeTuple()
+{
+  auto tuple = MakeTuple(42, 0.5f, 'c');
+  CHECK_TYPE(tuple, Tuple<int, float, char>);
+  CHECK(Get<0>(tuple) == 42);
+  CHECK(Get<1>(tuple) == 0.5f);
+  CHECK(Get<2>(tuple) == 'c');
+
+  // Make sure we don't infer the type to be Tuple<int&>.
+  int x = 1;
+  auto tuple2 = MakeTuple(x);
+  CHECK_TYPE(tuple2, Tuple<int>);
+  x = 2;
+  CHECK(Get<0>(tuple2) == 1);
+}
+
+static bool
+TestTie()
+{
+  int i;
+  float f;
+  char c;
+  Tuple<int, float, char> rhs1(42, 0.5f, 'c');
+  Tie(i, f, c) = rhs1;
+  CHECK(i == Get<0>(rhs1));
+  CHECK(f == Get<1>(rhs1));
+  CHECK(c == Get<2>(rhs1));
+  // Test conversions
+  Tuple<ConvertibleToInt, double, unsigned char> rhs2(ConvertibleToInt(),
+      0.7f, 'd');
+  Tie(i, f, c) = rhs2;
+  CHECK(i == Get<0>(rhs2));
+  CHECK(f == Get<1>(rhs2));
+  CHECK(c == Get<2>(rhs2));
+
+  // Test Pair
+  Pair<int, float> rhs3(-1, 1.2f);
+  Tie(i, f) = rhs3;
+  CHECK(i == rhs3.first());
+  CHECK(f == rhs3.second());
+
+  pair<int, float> rhs4(42, 1.5f);
+  Tie(i, f) = rhs4;
+  CHECK(i == rhs4.first);
+  CHECK(f == rhs4.second);
+
+  return true;
+}
+
+int
+main()
+{
+  TestConstruction();
+  TestConstructionFromMozPair();
+  TestConstructionFromStdPair();
+  TestAssignment();
+  TestAssignmentFromMozPair();
+  TestAssignmentFromStdPair();
+  TestGet();
+  TestMakeTuple();
+  TestTie();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestTypeTraits.cpp b/src/third_party/mozjs-45/mfbt/tests/TestTypeTraits.cpp
new file mode 100644
index 0000000..3dfedac
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestTypeTraits.cpp
@@ -0,0 +1,561 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/TypeTraits.h"
+
+using mozilla::AddLvalueReference;
+using mozilla::AddPointer;
+using mozilla::AddRvalueReference;
+using mozilla::Decay;
+using mozilla::DeclVal;
+using mozilla::IsFunction;
+using mozilla::IsArray;
+using mozilla::IsBaseOf;
+using mozilla::IsClass;
+using mozilla::IsConvertible;
+using mozilla::IsEmpty;
+using mozilla::IsLvalueReference;
+using mozilla::IsPointer;
+using mozilla::IsReference;
+using mozilla::IsRvalueReference;
+using mozilla::IsSame;
+using mozilla::IsSigned;
+using mozilla::IsUnsigned;
+using mozilla::MakeSigned;
+using mozilla::MakeUnsigned;
+using mozilla::RemoveExtent;
+using mozilla::RemovePointer;
+
+static_assert(!IsFunction<int>::value,
+              "int is not a function type");
+static_assert(IsFunction<void(int)>::value,
+              "void(int) is a function type");
+static_assert(!IsFunction<void(*)(int)>::value,
+              "void(*)(int) is not a function type");
+
+static_assert(!IsArray<bool>::value,
+              "bool not an array");
+static_assert(IsArray<bool[]>::value,
+              "bool[] is an array");
+static_assert(IsArray<bool[5]>::value,
+              "bool[5] is an array");
+
+static_assert(!IsPointer<bool>::value,
+              "bool not a pointer");
+static_assert(IsPointer<bool*>::value,
+              "bool* is a pointer");
+static_assert(IsPointer<bool* const>::value,
+              "bool* const is a pointer");
+static_assert(IsPointer<bool* volatile>::value,
+              "bool* volatile is a pointer");
+static_assert(IsPointer<bool* const volatile>::value,
+              "bool* const volatile is a pointer");
+static_assert(IsPointer<bool**>::value,
+              "bool** is a pointer");
+static_assert(IsPointer<void (*)(void)>::value,
+              "void (*)(void) is a pointer");
+struct IsPointerTest { bool m; void f(); };
+static_assert(!IsPointer<IsPointerTest>::value,
+              "IsPointerTest not a pointer");
+static_assert(IsPointer<IsPointerTest*>::value,
+              "IsPointerTest* is a pointer");
+static_assert(!IsPointer<bool(IsPointerTest::*)>::value,
+              "bool(IsPointerTest::*) not a pointer");
+static_assert(!IsPointer<void(IsPointerTest::*)(void)>::value,
+              "void(IsPointerTest::*)(void) not a pointer");
+
+static_assert(!IsLvalueReference<bool>::value,
+              "bool not an lvalue reference");
+static_assert(!IsLvalueReference<bool*>::value,
+              "bool* not an lvalue reference");
+static_assert(IsLvalueReference<bool&>::value,
+              "bool& is an lvalue reference");
+static_assert(!IsLvalueReference<bool&&>::value,
+              "bool&& not an lvalue reference");
+
+static_assert(!IsLvalueReference<void>::value,
+              "void not an lvalue reference");
+static_assert(!IsLvalueReference<void*>::value,
+              "void* not an lvalue reference");
+
+static_assert(!IsLvalueReference<int>::value,
+              "int not an lvalue reference");
+static_assert(!IsLvalueReference<int*>::value,
+              "int* not an lvalue reference");
+static_assert(IsLvalueReference<int&>::value,
+              "int& is an lvalue reference");
+static_assert(!IsLvalueReference<int&&>::value,
+              "int&& not an lvalue reference");
+
+static_assert(!IsRvalueReference<bool>::value,
+              "bool not an rvalue reference");
+static_assert(!IsRvalueReference<bool*>::value,
+              "bool* not an rvalue reference");
+static_assert(!IsRvalueReference<bool&>::value,
+              "bool& not an rvalue reference");
+static_assert(IsRvalueReference<bool&&>::value,
+              "bool&& is an rvalue reference");
+
+static_assert(!IsRvalueReference<void>::value,
+              "void not an rvalue reference");
+static_assert(!IsRvalueReference<void*>::value,
+              "void* not an rvalue reference");
+
+static_assert(!IsRvalueReference<int>::value,
+              "int not an rvalue reference");
+static_assert(!IsRvalueReference<int*>::value,
+              "int* not an rvalue reference");
+static_assert(!IsRvalueReference<int&>::value,
+              "int& not an rvalue reference");
+static_assert(IsRvalueReference<int&&>::value,
+              "int&& is an rvalue reference");
+
+static_assert(!IsReference<bool>::value,
+              "bool not a reference");
+static_assert(!IsReference<bool*>::value,
+              "bool* not a reference");
+static_assert(IsReference<bool&>::value,
+              "bool& is a reference");
+static_assert(IsReference<bool&&>::value,
+              "bool&& is a reference");
+
+static_assert(!IsReference<void>::value,
+              "void not a reference");
+static_assert(!IsReference<void*>::value,
+              "void* not a reference");
+
+static_assert(!IsReference<int>::value,
+              "int not a reference");
+static_assert(!IsReference<int*>::value,
+              "int* not a reference");
+static_assert(IsReference<int&>::value,
+              "int& is a reference");
+static_assert(IsReference<int&&>::value,
+              "int&& is a reference");
+
+struct S1 {};
+union U1 { int mX; };
+
+static_assert(!IsClass<int>::value,
+              "int isn't a class");
+static_assert(IsClass<const S1>::value,
+              "S is a class");
+static_assert(!IsClass<U1>::value,
+              "U isn't a class");
+
+static_assert(!mozilla::IsEmpty<int>::value,
+              "not a class => not empty");
+static_assert(!mozilla::IsEmpty<bool[5]>::value,
+              "not a class => not empty");
+
+static_assert(!mozilla::IsEmpty<U1>::value,
+              "not a class => not empty");
+
+struct E1 {};
+struct E2 { int : 0; };
+struct E3 : E1 {};
+struct E4 : E2 {};
+
+static_assert(IsEmpty<const volatile S1>::value,
+              "S should be empty");
+
+static_assert(mozilla::IsEmpty<E1>::value &&
+              mozilla::IsEmpty<E2>::value &&
+              mozilla::IsEmpty<E3>::value &&
+              mozilla::IsEmpty<E4>::value,
+              "all empty");
+
+union U2 { E1 e1; };
+static_assert(!mozilla::IsEmpty<U2>::value,
+              "not a class => not empty");
+
+struct NE1 { int mX; };
+struct NE2 : virtual E1 {};
+struct NE3 : E2 { virtual ~NE3() {} };
+struct NE4 { virtual void f() {} };
+
+static_assert(!mozilla::IsEmpty<NE1>::value &&
+              !mozilla::IsEmpty<NE2>::value &&
+              !mozilla::IsEmpty<NE3>::value &&
+              !mozilla::IsEmpty<NE4>::value,
+              "all empty");
+
+static_assert(!IsSigned<bool>::value,
+              "bool shouldn't be signed");
+static_assert(IsUnsigned<bool>::value,
+              "bool should be unsigned");
+
+static_assert(!IsSigned<const bool>::value,
+              "const bool shouldn't be signed");
+static_assert(IsUnsigned<const bool>::value,
+              "const bool should be unsigned");
+
+static_assert(!IsSigned<volatile bool>::value,
+              "volatile bool shouldn't be signed");
+static_assert(IsUnsigned<volatile bool>::value,
+              "volatile bool should be unsigned");
+
+static_assert(!IsSigned<unsigned char>::value,
+              "unsigned char shouldn't be signed");
+static_assert(IsUnsigned<unsigned char>::value,
+              "unsigned char should be unsigned");
+static_assert(IsSigned<signed char>::value,
+              "signed char should be signed");
+static_assert(!IsUnsigned<signed char>::value,
+              "signed char shouldn't be unsigned");
+
+static_assert(!IsSigned<unsigned short>::value,
+              "unsigned short shouldn't be signed");
+static_assert(IsUnsigned<unsigned short>::value,
+              "unsigned short should be unsigned");
+static_assert(IsSigned<short>::value,
+              "short should be signed");
+static_assert(!IsUnsigned<short>::value,
+              "short shouldn't be unsigned");
+
+static_assert(!IsSigned<unsigned int>::value,
+              "unsigned int shouldn't be signed");
+static_assert(IsUnsigned<unsigned int>::value,
+              "unsigned int should be unsigned");
+static_assert(IsSigned<int>::value,
+              "int should be signed");
+static_assert(!IsUnsigned<int>::value,
+              "int shouldn't be unsigned");
+
+static_assert(!IsSigned<unsigned long>::value,
+              "unsigned long shouldn't be signed");
+static_assert(IsUnsigned<unsigned long>::value,
+              "unsigned long should be unsigned");
+static_assert(IsSigned<long>::value,
+              "long should be signed");
+static_assert(!IsUnsigned<long>::value,
+              "long shouldn't be unsigned");
+
+static_assert(IsSigned<float>::value,
+              "float should be signed");
+static_assert(!IsUnsigned<float>::value,
+              "float shouldn't be unsigned");
+
+static_assert(IsSigned<const float>::value,
+              "const float should be signed");
+static_assert(!IsUnsigned<const float>::value,
+              "const float shouldn't be unsigned");
+
+static_assert(IsSigned<double>::value,
+              "double should be signed");
+static_assert(!IsUnsigned<double>::value,
+              "double shouldn't be unsigned");
+
+static_assert(IsSigned<volatile double>::value,
+              "volatile double should be signed");
+static_assert(!IsUnsigned<volatile double>::value,
+              "volatile double shouldn't be unsigned");
+
+static_assert(IsSigned<long double>::value,
+              "long double should be signed");
+static_assert(!IsUnsigned<long double>::value,
+              "long double shouldn't be unsigned");
+
+static_assert(IsSigned<const volatile long double>::value,
+              "const volatile long double should be signed");
+static_assert(!IsUnsigned<const volatile long double>::value,
+              "const volatile long double shouldn't be unsigned");
+
+class NotIntConstructible
+{
+  NotIntConstructible(int) = delete;
+};
+
+static_assert(!IsSigned<NotIntConstructible>::value,
+              "non-arithmetic types are not signed");
+static_assert(!IsUnsigned<NotIntConstructible>::value,
+              "non-arithmetic types are not unsigned");
+
+namespace CPlusPlus11IsBaseOf {
+
+// Adapted from C++11 § 20.9.6.
+struct B {};
+struct B1 : B {};
+struct B2 : B {};
+struct D : private B1, private B2 {};
+
+static void
+StandardIsBaseOfTests()
+{
+  static_assert((IsBaseOf<B, D>::value) == true,
+                "IsBaseOf fails on diamond");
+  static_assert((IsBaseOf<const B, D>::value) == true,
+                "IsBaseOf fails on diamond plus constness change");
+  static_assert((IsBaseOf<B, const D>::value) == true,
+                "IsBaseOf fails on diamond plus constness change");
+  static_assert((IsBaseOf<B, const B>::value) == true,
+                "IsBaseOf fails on constness change");
+  static_assert((IsBaseOf<D, B>::value) == false,
+                "IsBaseOf got the direction of inheritance wrong");
+  static_assert((IsBaseOf<B&, D&>::value) == false,
+                "IsBaseOf should return false on references");
+  static_assert((IsBaseOf<B[3], D[3]>::value) == false,
+                "IsBaseOf should return false on arrays");
+  // We fail at the following test.  To fix it, we need to specialize IsBaseOf
+  // for all built-in types.
+  // static_assert((IsBaseOf<int, int>::value) == false);
+}
+
+} /* namespace CPlusPlus11IsBaseOf */
+
+class A { };
+class B : public A { };
+class C : private A { };
+class D { };
+class E : public A { };
+class F : public B, public E { };
+
+static void
+TestIsBaseOf()
+{
+  static_assert((IsBaseOf<A, B>::value),
+                "A is a base of B");
+  static_assert((!IsBaseOf<B, A>::value),
+                "B is not a base of A");
+  static_assert((IsBaseOf<A, C>::value),
+                "A is a base of C");
+  static_assert((!IsBaseOf<C, A>::value),
+                "C is not a base of A");
+  static_assert((IsBaseOf<A, F>::value),
+                "A is a base of F");
+  static_assert((!IsBaseOf<F, A>::value),
+                "F is not a base of A");
+  static_assert((!IsBaseOf<A, D>::value),
+                "A is not a base of D");
+  static_assert((!IsBaseOf<D, A>::value),
+                "D is not a base of A");
+  static_assert((IsBaseOf<B, B>::value),
+                "B is the same as B (and therefore, a base of B)");
+}
+
+class ExplicitCopyConstructor {
+  explicit ExplicitCopyConstructor(const ExplicitCopyConstructor&) = default;
+};
+
+static void
+TestIsConvertible()
+{
+  // Pointer type convertibility
+  static_assert((IsConvertible<A*, A*>::value),
+                "A* should convert to A*");
+  static_assert((IsConvertible<B*, A*>::value),
+                "B* should convert to A*");
+  static_assert((!IsConvertible<A*, B*>::value),
+                "A* shouldn't convert to B*");
+  static_assert((!IsConvertible<A*, C*>::value),
+                "A* shouldn't convert to C*");
+  static_assert((!IsConvertible<A*, D*>::value),
+                "A* shouldn't convert to unrelated D*");
+  static_assert((!IsConvertible<D*, A*>::value),
+                "D* shouldn't convert to unrelated A*");
+
+  // Instance type convertibility
+  static_assert((IsConvertible<A, A>::value),
+                "A is A");
+  static_assert((IsConvertible<B, A>::value),
+                "B converts to A");
+  static_assert((!IsConvertible<D, A>::value),
+                "D and A are unrelated");
+  static_assert((!IsConvertible<A, D>::value),
+                "A and D are unrelated");
+
+  static_assert(IsConvertible<void, void>::value, "void is void");
+  static_assert(!IsConvertible<A, void>::value, "A shouldn't convert to void");
+  static_assert(!IsConvertible<void, B>::value, "void shouldn't convert to B");
+
+  static_assert(!IsConvertible<const ExplicitCopyConstructor&,
+                               ExplicitCopyConstructor>::value,
+                "IsConvertible should test for implicit convertibility");
+
+  // These cases seem to require C++11 support to properly implement them, so
+  // for now just disable them.
+  //static_assert((!IsConvertible<C*, A*>::value),
+  //           "C* shouldn't convert to A* (private inheritance)");
+  //static_assert((!IsConvertible<C, A>::value),
+  //           "C doesn't convert to A (private inheritance)");
+}
+
+static_assert(IsSame<AddLvalueReference<int>::Type, int&>::value,
+              "not adding & to int correctly");
+static_assert(IsSame<AddLvalueReference<volatile int&>::Type, volatile int&>::value,
+              "not adding & to volatile int& correctly");
+static_assert(IsSame<AddLvalueReference<void*>::Type, void*&>::value,
+              "not adding & to void* correctly");
+static_assert(IsSame<AddLvalueReference<void>::Type, void>::value,
+              "void shouldn't be transformed by AddLvalueReference");
+static_assert(IsSame<AddLvalueReference<struct S1&&>::Type, struct S1&>::value,
+              "not reference-collapsing struct S1&& & to struct S1& correctly");
+
+static_assert(IsSame<AddRvalueReference<int>::Type, int&&>::value,
+              "not adding && to int correctly");
+static_assert(IsSame<AddRvalueReference<volatile int&>::Type, volatile int&>::value,
+              "not adding && to volatile int& correctly");
+static_assert(IsSame<AddRvalueReference<const int&&>::Type, const int&&>::value,
+              "not adding && to volatile int& correctly");
+static_assert(IsSame<AddRvalueReference<void*>::Type, void*&&>::value,
+              "not adding && to void* correctly");
+static_assert(IsSame<AddRvalueReference<void>::Type, void>::value,
+              "void shouldn't be transformed by AddRvalueReference");
+static_assert(IsSame<AddRvalueReference<struct S1&>::Type, struct S1&>::value,
+              "not reference-collapsing struct S1& && to struct S1& correctly");
+
+struct TestWithDefaultConstructor
+{
+  int foo() const { return 0; }
+};
+struct TestWithNoDefaultConstructor
+{
+  explicit TestWithNoDefaultConstructor(int) {}
+  int foo() const { return 1; }
+};
+
+static_assert(IsSame<decltype(TestWithDefaultConstructor().foo()), int>::value,
+              "decltype should work using a struct with a default constructor");
+static_assert(IsSame<decltype(DeclVal<TestWithDefaultConstructor>().foo()), int>::value,
+              "decltype should work using a DeclVal'd struct with a default constructor");
+static_assert(IsSame<decltype(DeclVal<TestWithNoDefaultConstructor>().foo()), int>::value,
+              "decltype should work using a DeclVal'd struct without a default constructor");
+
+static_assert(IsSame<MakeSigned<const unsigned char>::Type, const signed char>::value,
+              "const unsigned char won't signify correctly");
+static_assert(IsSame<MakeSigned<volatile unsigned short>::Type, volatile signed short>::value,
+              "volatile unsigned short won't signify correctly");
+static_assert(IsSame<MakeSigned<const volatile unsigned int>::Type, const volatile signed int>::value,
+              "const volatile unsigned int won't signify correctly");
+static_assert(IsSame<MakeSigned<unsigned long>::Type, signed long>::value,
+              "unsigned long won't signify correctly");
+static_assert(IsSame<MakeSigned<const signed char>::Type, const signed char>::value,
+              "const signed char won't signify correctly");
+
+static_assert(IsSame<MakeSigned<volatile signed short>::Type, volatile signed short>::value,
+              "volatile signed short won't signify correctly");
+static_assert(IsSame<MakeSigned<const volatile signed int>::Type, const volatile signed int>::value,
+              "const volatile signed int won't signify correctly");
+static_assert(IsSame<MakeSigned<signed long>::Type, signed long>::value,
+              "signed long won't signify correctly");
+
+static_assert(IsSame<MakeSigned<char>::Type, signed char>::value,
+              "char won't signify correctly");
+static_assert(IsSame<MakeSigned<volatile char>::Type, volatile signed char>::value,
+              "volatile char won't signify correctly");
+static_assert(IsSame<MakeSigned<const char>::Type, const signed char>::value,
+              "const char won't signify correctly");
+
+static_assert(IsSame<MakeUnsigned<const signed char>::Type, const unsigned char>::value,
+              "const signed char won't unsignify correctly");
+static_assert(IsSame<MakeUnsigned<volatile signed short>::Type, volatile unsigned short>::value,
+              "volatile signed short won't unsignify correctly");
+static_assert(IsSame<MakeUnsigned<const volatile signed int>::Type, const volatile unsigned int>::value,
+              "const volatile signed int won't unsignify correctly");
+static_assert(IsSame<MakeUnsigned<signed long>::Type, unsigned long>::value,
+              "signed long won't unsignify correctly");
+
+static_assert(IsSame<MakeUnsigned<const unsigned char>::Type, const unsigned char>::value,
+              "const unsigned char won't unsignify correctly");
+
+static_assert(IsSame<MakeUnsigned<volatile unsigned short>::Type, volatile unsigned short>::value,
+              "volatile unsigned short won't unsignify correctly");
+static_assert(IsSame<MakeUnsigned<const volatile unsigned int>::Type, const volatile unsigned int>::value,
+              "const volatile unsigned int won't unsignify correctly");
+static_assert(IsSame<MakeUnsigned<unsigned long>::Type, unsigned long>::value,
+              "signed long won't unsignify correctly");
+
+static_assert(IsSame<MakeUnsigned<char>::Type, unsigned char>::value,
+              "char won't unsignify correctly");
+static_assert(IsSame<MakeUnsigned<volatile char>::Type, volatile unsigned char>::value,
+              "volatile char won't unsignify correctly");
+static_assert(IsSame<MakeUnsigned<const char>::Type, const unsigned char>::value,
+              "const char won't unsignify correctly");
+
+static_assert(IsSame<RemoveExtent<int>::Type, int>::value,
+              "removing extent from non-array must return the non-array");
+static_assert(IsSame<RemoveExtent<const int[]>::Type, const int>::value,
+              "removing extent from unknown-bound array must return element type");
+static_assert(IsSame<RemoveExtent<volatile int[5]>::Type, volatile int>::value,
+              "removing extent from known-bound array must return element type");
+static_assert(IsSame<RemoveExtent<long[][17]>::Type, long[17]>::value,
+              "removing extent from multidimensional array must return element type");
+
+struct TestRemovePointer { bool m; void f(); };
+static_assert(IsSame<RemovePointer<int>::Type, int>::value,
+              "removing pointer from int must return int");
+static_assert(IsSame<RemovePointer<int*>::Type, int>::value,
+              "removing pointer from int* must return int");
+static_assert(IsSame<RemovePointer<int* const>::Type, int>::value,
+              "removing pointer from int* const must return int");
+static_assert(IsSame<RemovePointer<int* volatile>::Type, int>::value,
+              "removing pointer from int* volatile must return int");
+static_assert(IsSame<RemovePointer<const long*>::Type, const long>::value,
+              "removing pointer from const long* must return const long");
+static_assert(IsSame<RemovePointer<void* const>::Type, void>::value,
+              "removing pointer from void* const must return void");
+static_assert(IsSame<RemovePointer<void (TestRemovePointer::*)()>::Type,
+                                   void (TestRemovePointer::*)()>::value,
+              "removing pointer from void (S::*)() must return void (S::*)()");
+static_assert(IsSame<RemovePointer<void (*)()>::Type, void()>::value,
+              "removing pointer from void (*)() must return void()");
+static_assert(IsSame<RemovePointer<bool TestRemovePointer::*>::Type,
+                                   bool TestRemovePointer::*>::value,
+              "removing pointer from bool S::* must return bool S::*");
+
+static_assert(IsSame<AddPointer<int>::Type, int*>::value,
+              "adding pointer to int must return int*");
+static_assert(IsSame<AddPointer<int*>::Type, int**>::value,
+              "adding pointer to int* must return int**");
+static_assert(IsSame<AddPointer<int&>::Type, int*>::value,
+              "adding pointer to int& must return int*");
+static_assert(IsSame<AddPointer<int* const>::Type, int* const*>::value,
+              "adding pointer to int* const must return int* const*");
+static_assert(IsSame<AddPointer<int* volatile>::Type, int* volatile*>::value,
+              "adding pointer to int* volatile must return int* volatile*");
+
+static_assert(IsSame<Decay<int>::Type, int>::value,
+              "decaying int must return int");
+static_assert(IsSame<Decay<int*>::Type, int*>::value,
+              "decaying int* must return int*");
+static_assert(IsSame<Decay<int* const>::Type, int*>::value,
+              "decaying int* const must return int*");
+static_assert(IsSame<Decay<int* volatile>::Type, int*>::value,
+              "decaying int* volatile must return int*");
+static_assert(IsSame<Decay<int&>::Type, int>::value,
+              "decaying int& must return int");
+static_assert(IsSame<Decay<const int&>::Type, int>::value,
+              "decaying const int& must return int");
+static_assert(IsSame<Decay<int&&>::Type, int>::value,
+              "decaying int&& must return int");
+static_assert(IsSame<Decay<int[1]>::Type, int*>::value,
+              "decaying int[1] must return int*");
+static_assert(IsSame<Decay<void(int)>::Type, void(*)(int)>::value,
+              "decaying void(int) must return void(*)(int)");
+
+/*
+ * Android's broken [u]intptr_t inttype macros are broken because its PRI*PTR
+ * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t)
+ * is 4 on 32-bit Android. We redefine Android's PRI*PTR macros in
+ * IntegerPrintfMacros.h and assert here that our new definitions match the
+ * actual type sizes seen at compile time.
+ */
+#if defined(ANDROID) && !defined(__LP64__)
+static_assert(mozilla::IsSame<int, intptr_t>::value,
+              "emulated PRI[di]PTR definitions will be wrong");
+static_assert(mozilla::IsSame<unsigned int, uintptr_t>::value,
+              "emulated PRI[ouxX]PTR definitions will be wrong");
+#endif
+
+int
+main()
+{
+  CPlusPlus11IsBaseOf::StandardIsBaseOfTests();
+  TestIsBaseOf();
+  TestIsConvertible();
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestTypedEnum.cpp b/src/third_party/mozjs-45/mfbt/tests/TestTypedEnum.cpp
new file mode 100644
index 0000000..6464eff
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestTypedEnum.cpp
@@ -0,0 +1,564 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/TypedEnumBits.h"
+
+#include <stdint.h>
+
+// A rough feature check for is_literal_type. Not very carefully checked.
+// Feel free to amend as needed.
+// We leave ANDROID out because it's using stlport which doesn't have std::is_literal_type.
+#if __cplusplus >= 201103L && !defined(ANDROID)
+#  if defined(__clang__)
+     /*
+      * Per Clang documentation, "Note that marketing version numbers should not
+      * be used to check for language features, as different vendors use different
+      * numbering schemes. Instead, use the feature checking macros."
+      */
+#    ifndef __has_extension
+#      define __has_extension __has_feature /* compatibility, for older versions of clang */
+#    endif
+#    if __has_extension(is_literal) && __has_include(<type_traits>)
+#      define MOZ_HAVE_IS_LITERAL
+#    endif
+#  elif defined(__GNUC__) || defined(_MSC_VER)
+#    define MOZ_HAVE_IS_LITERAL
+#  endif
+#endif
+
+#if defined(MOZ_HAVE_IS_LITERAL) && defined(MOZ_HAVE_CXX11_CONSTEXPR)
+#include <type_traits>
+template<typename T>
+void
+RequireLiteralType()
+{
+  static_assert(std::is_literal_type<T>::value, "Expected a literal type");
+}
+#else // not MOZ_HAVE_IS_LITERAL
+template<typename T>
+void
+RequireLiteralType()
+{
+}
+#endif
+
+template<typename T>
+void
+RequireLiteralType(const T&)
+{
+  RequireLiteralType<T>();
+}
+
+enum class AutoEnum {
+  A,
+  B = -3,
+  C
+};
+
+enum class CharEnum : char {
+  A,
+  B = 3,
+  C
+};
+
+enum class AutoEnumBitField {
+  A = 0x10,
+  B = 0x20,
+  C
+};
+
+enum class CharEnumBitField : char {
+  A = 0x10,
+  B,
+  C = 0x40
+};
+
+struct Nested
+{
+  enum class AutoEnum {
+    A,
+    B,
+    C = -1
+  };
+
+  enum class CharEnum : char {
+    A = 4,
+    B,
+    C = 1
+  };
+
+  enum class AutoEnumBitField {
+    A,
+    B = 0x20,
+    C
+  };
+
+  enum class CharEnumBitField : char {
+    A = 1,
+    B = 1,
+    C = 1
+  };
+};
+
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AutoEnumBitField)
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CharEnumBitField)
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Nested::AutoEnumBitField)
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Nested::CharEnumBitField)
+
+#define MAKE_STANDARD_BITFIELD_FOR_TYPE(IntType)                   \
+  enum class BitFieldFor_##IntType : IntType {                     \
+    A = 1,                                                         \
+    B = 2,                                                         \
+    C = 4,                                                         \
+  };                                                               \
+  MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(BitFieldFor_##IntType)
+
+MAKE_STANDARD_BITFIELD_FOR_TYPE(int8_t)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(uint8_t)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(int16_t)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(uint16_t)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(int32_t)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(uint32_t)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(int64_t)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(uint64_t)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(char)
+typedef signed char signed_char;
+MAKE_STANDARD_BITFIELD_FOR_TYPE(signed_char)
+typedef unsigned char unsigned_char;
+MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_char)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(short)
+typedef unsigned short unsigned_short;
+MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_short)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(int)
+typedef unsigned int unsigned_int;
+MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_int)
+MAKE_STANDARD_BITFIELD_FOR_TYPE(long)
+typedef unsigned long unsigned_long;
+MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_long)
+typedef long long long_long;
+MAKE_STANDARD_BITFIELD_FOR_TYPE(long_long)
+typedef unsigned long long unsigned_long_long;
+MAKE_STANDARD_BITFIELD_FOR_TYPE(unsigned_long_long)
+
+#undef MAKE_STANDARD_BITFIELD_FOR_TYPE
+
+template<typename T>
+void
+TestNonConvertibilityForOneType()
+{
+  using mozilla::IsConvertible;
+
+#if defined(MOZ_HAVE_EXPLICIT_CONVERSION)
+  static_assert(!IsConvertible<T, bool>::value, "should not be convertible");
+  static_assert(!IsConvertible<T, int>::value, "should not be convertible");
+  static_assert(!IsConvertible<T, uint64_t>::value, "should not be convertible");
+#endif
+
+  static_assert(!IsConvertible<bool, T>::value, "should not be convertible");
+  static_assert(!IsConvertible<int, T>::value, "should not be convertible");
+  static_assert(!IsConvertible<uint64_t, T>::value, "should not be convertible");
+}
+
+template<typename TypedEnum>
+void
+TestTypedEnumBasics()
+{
+  const TypedEnum a = TypedEnum::A;
+  int unused = int(a);
+  (void) unused;
+  RequireLiteralType(TypedEnum::A);
+  RequireLiteralType(a);
+  TestNonConvertibilityForOneType<TypedEnum>();
+}
+
+// Op wraps a bitwise binary operator, passed as a char template parameter,
+// and applies it to its arguments (aT1, aT2). For example,
+//
+//   Op<'|'>(aT1, aT2)
+//
+// is the same as
+//
+//   aT1 | aT2.
+//
+template<char o, typename T1, typename T2>
+auto Op(const T1& aT1, const T2& aT2)
+  -> decltype(aT1 | aT2) // See the static_assert's below --- the return type
+                         // depends solely on the operands type, not on the
+                         // choice of operation.
+{
+  using mozilla::IsSame;
+  static_assert(IsSame<decltype(aT1 | aT2), decltype(aT1 & aT2)>::value,
+                "binary ops should have the same result type");
+  static_assert(IsSame<decltype(aT1 | aT2), decltype(aT1 ^ aT2)>::value,
+                "binary ops should have the same result type");
+
+  static_assert(o == '|' ||
+                o == '&' ||
+                o == '^', "unexpected operator character");
+
+  return o == '|' ? aT1 | aT2
+       : o == '&' ? aT1 & aT2
+                  : aT1 ^ aT2;
+}
+
+// OpAssign wraps a bitwise binary operator, passed as a char template
+// parameter, and applies the corresponding compound-assignment operator to its
+// arguments (aT1, aT2). For example,
+//
+//   OpAssign<'|'>(aT1, aT2)
+//
+// is the same as
+//
+//   aT1 |= aT2.
+//
+template<char o, typename T1, typename T2>
+T1& OpAssign(T1& aT1, const T2& aT2)
+{
+  static_assert(o == '|' ||
+                o == '&' ||
+                o == '^', "unexpected operator character");
+
+  switch (o) {
+    case '|': return aT1 |= aT2;
+    case '&': return aT1 &= aT2;
+    case '^': return aT1 ^= aT2;
+    default: MOZ_CRASH();
+  }
+}
+
+// Tests a single binary bitwise operator, using a single set of three operands.
+// The operations tested are:
+//
+//   result = aT1 Op aT2;
+//   result Op= aT3;
+//
+// Where Op is the operator specified by the char template parameter 'o' and
+// can be any of '|', '&', '^'.
+//
+// Note that the operands aT1, aT2, aT3 are intentionally passed with free
+// types (separate template parameters for each) because their type may
+// actually be different from TypedEnum:
+//
+//   1) Their type could be CastableTypedEnumResult<TypedEnum> if they are
+//      the result of a bitwise operation themselves;
+//   2) In the non-c++11 legacy path, the type of enum values is also
+//      different from TypedEnum.
+//
+template<typename TypedEnum, char o, typename T1, typename T2, typename T3>
+void TestBinOp(const T1& aT1, const T2& aT2, const T3& aT3)
+{
+  typedef typename mozilla::detail::UnsignedIntegerTypeForEnum<TypedEnum>::Type
+          UnsignedIntegerType;
+
+  // Part 1:
+  // Test the bitwise binary operator i.e.
+  //   result = aT1 Op aT2;
+  auto result = Op<o>(aT1, aT2);
+
+  typedef decltype(result) ResultType;
+
+  RequireLiteralType<ResultType>();
+  TestNonConvertibilityForOneType<ResultType>();
+
+  UnsignedIntegerType unsignedIntegerResult =
+    Op<o>(UnsignedIntegerType(aT1), UnsignedIntegerType(aT2));
+
+  MOZ_RELEASE_ASSERT(unsignedIntegerResult == UnsignedIntegerType(result));
+  MOZ_RELEASE_ASSERT(TypedEnum(unsignedIntegerResult) == TypedEnum(result));
+  MOZ_RELEASE_ASSERT((!unsignedIntegerResult) == (!result));
+  MOZ_RELEASE_ASSERT((!!unsignedIntegerResult) == (!!result));
+  MOZ_RELEASE_ASSERT(bool(unsignedIntegerResult) == bool(result));
+
+  // Part 2:
+  // Test the compound-assignment operator, i.e.
+  //   result Op= aT3;
+  TypedEnum newResult = result;
+  OpAssign<o>(newResult, aT3);
+  UnsignedIntegerType unsignedIntegerNewResult = unsignedIntegerResult;
+  OpAssign<o>(unsignedIntegerNewResult, UnsignedIntegerType(aT3));
+  MOZ_RELEASE_ASSERT(TypedEnum(unsignedIntegerNewResult) == newResult);
+
+  // Part 3:
+  // Test additional boolean operators that we unfortunately had to add to
+  // CastableTypedEnumResult at some point to please some compiler,
+  // even though bool convertibility should have been enough.
+  MOZ_RELEASE_ASSERT(result == TypedEnum(result));
+  MOZ_RELEASE_ASSERT(!(result != TypedEnum(result)));
+  MOZ_RELEASE_ASSERT((result && true) == bool(result));
+  MOZ_RELEASE_ASSERT((result && false) == false);
+  MOZ_RELEASE_ASSERT((true && result) == bool(result));
+  MOZ_RELEASE_ASSERT((false && result && false) == false);
+  MOZ_RELEASE_ASSERT((result || false) == bool(result));
+  MOZ_RELEASE_ASSERT((result || true) == true);
+  MOZ_RELEASE_ASSERT((false || result) == bool(result));
+  MOZ_RELEASE_ASSERT((true || result) == true);
+}
+
+// Similar to TestBinOp but testing the unary ~ operator.
+template<typename TypedEnum, typename T>
+void TestTilde(const T& aT)
+{
+  typedef typename mozilla::detail::UnsignedIntegerTypeForEnum<TypedEnum>::Type
+          UnsignedIntegerType;
+
+  auto result = ~aT;
+
+  typedef decltype(result) ResultType;
+
+  RequireLiteralType<ResultType>();
+  TestNonConvertibilityForOneType<ResultType>();
+
+  UnsignedIntegerType unsignedIntegerResult = ~(UnsignedIntegerType(aT));
+
+  MOZ_RELEASE_ASSERT(unsignedIntegerResult == UnsignedIntegerType(result));
+  MOZ_RELEASE_ASSERT(TypedEnum(unsignedIntegerResult) == TypedEnum(result));
+  MOZ_RELEASE_ASSERT((!unsignedIntegerResult) == (!result));
+  MOZ_RELEASE_ASSERT((!!unsignedIntegerResult) == (!!result));
+  MOZ_RELEASE_ASSERT(bool(unsignedIntegerResult) == bool(result));
+}
+
+// Helper dispatching a given triple of operands to all operator-specific
+// testing functions.
+template<typename TypedEnum, typename T1, typename T2, typename T3>
+void TestAllOpsForGivenOperands(const T1& aT1, const T2& aT2, const T3& aT3)
+{
+  TestBinOp<TypedEnum, '|'>(aT1, aT2, aT3);
+  TestBinOp<TypedEnum, '&'>(aT1, aT2, aT3);
+  TestBinOp<TypedEnum, '^'>(aT1, aT2, aT3);
+  TestTilde<TypedEnum>(aT1);
+}
+
+// Helper building various triples of operands using a given operator,
+// and testing all operators with them.
+template<typename TypedEnum, char o>
+void TestAllOpsForOperandsBuiltUsingGivenOp()
+{
+  // The type of enum values like TypedEnum::A may be different from
+  // TypedEnum. That is the case in the legacy non-C++11 path. We want to
+  // ensure good test coverage even when these two types are distinct.
+  // To that effect, we have both 'auto' typed variables, preserving the
+  // original type of enum values, and 'plain' typed variables, that
+  // are plain TypedEnum's.
+
+  const TypedEnum a_plain = TypedEnum::A;
+  const TypedEnum b_plain = TypedEnum::B;
+  const TypedEnum c_plain = TypedEnum::C;
+
+  auto a_auto = TypedEnum::A;
+  auto b_auto = TypedEnum::B;
+  auto c_auto = TypedEnum::C;
+
+  auto ab_plain = Op<o>(a_plain, b_plain);
+  auto bc_plain = Op<o>(b_plain, c_plain);
+  auto ab_auto = Op<o>(a_auto, b_auto);
+  auto bc_auto = Op<o>(b_auto, c_auto);
+
+  // On each row below, we pass a triple of operands. Keep in mind that this
+  // is going to be received as (aT1, aT2, aT3) and the actual tests performed
+  // will be of the form
+  //
+  //   result = aT1 Op aT2;
+  //   result Op= aT3;
+  //
+  // For this reason, we carefully ensure that the values of (aT1, aT2)
+  // systematically cover all types of such pairs; to limit complexity,
+  // we are not so careful with aT3, and we just try to pass aT3's
+  // that may lead to nontrivial bitwise operations.
+  TestAllOpsForGivenOperands<TypedEnum>(a_plain,  b_plain,  c_plain);
+  TestAllOpsForGivenOperands<TypedEnum>(a_plain,  bc_plain, b_auto);
+  TestAllOpsForGivenOperands<TypedEnum>(ab_plain, c_plain,  a_plain);
+  TestAllOpsForGivenOperands<TypedEnum>(ab_plain, bc_plain, a_auto);
+
+  TestAllOpsForGivenOperands<TypedEnum>(a_plain,  b_auto,   c_plain);
+  TestAllOpsForGivenOperands<TypedEnum>(a_plain,  bc_auto,  b_auto);
+  TestAllOpsForGivenOperands<TypedEnum>(ab_plain, c_auto,   a_plain);
+  TestAllOpsForGivenOperands<TypedEnum>(ab_plain, bc_auto,  a_auto);
+
+  TestAllOpsForGivenOperands<TypedEnum>(a_auto,   b_plain,  c_plain);
+  TestAllOpsForGivenOperands<TypedEnum>(a_auto,   bc_plain, b_auto);
+  TestAllOpsForGivenOperands<TypedEnum>(ab_auto,  c_plain,  a_plain);
+  TestAllOpsForGivenOperands<TypedEnum>(ab_auto,  bc_plain, a_auto);
+
+  TestAllOpsForGivenOperands<TypedEnum>(a_auto,   b_auto,   c_plain);
+  TestAllOpsForGivenOperands<TypedEnum>(a_auto,   bc_auto,  b_auto);
+  TestAllOpsForGivenOperands<TypedEnum>(ab_auto,  c_auto,   a_plain);
+  TestAllOpsForGivenOperands<TypedEnum>(ab_auto,  bc_auto,  a_auto);
+}
+
+// Tests all bitwise operations on a given TypedEnum bitfield.
+template<typename TypedEnum>
+void
+TestTypedEnumBitField()
+{
+  TestTypedEnumBasics<TypedEnum>();
+
+  TestAllOpsForOperandsBuiltUsingGivenOp<TypedEnum, '|'>();
+  TestAllOpsForOperandsBuiltUsingGivenOp<TypedEnum, '&'>();
+  TestAllOpsForOperandsBuiltUsingGivenOp<TypedEnum, '^'>();
+}
+
+// Checks that enum bitwise expressions have the same non-convertibility
+// properties as c++11 enum classes do, i.e. not implicitly convertible to
+// anything (though *explicitly* convertible).
+void TestNoConversionsBetweenUnrelatedTypes()
+{
+  using mozilla::IsConvertible;
+
+  // Two typed enum classes having the same underlying integer type, to ensure
+  // that we would catch bugs accidentally allowing conversions in that case.
+  typedef CharEnumBitField T1;
+  typedef Nested::CharEnumBitField T2;
+
+  static_assert(!IsConvertible<T1, T2>::value,
+                "should not be convertible");
+  static_assert(!IsConvertible<T1, decltype(T2::A)>::value,
+                "should not be convertible");
+  static_assert(!IsConvertible<T1, decltype(T2::A | T2::B)>::value,
+                "should not be convertible");
+
+  static_assert(!IsConvertible<decltype(T1::A), T2>::value,
+                "should not be convertible");
+  static_assert(!IsConvertible<decltype(T1::A), decltype(T2::A)>::value,
+                "should not be convertible");
+  static_assert(!IsConvertible<decltype(T1::A), decltype(T2::A | T2::B)>::value,
+                "should not be convertible");
+
+  // The following are #ifdef MOZ_HAVE_EXPLICIT_CONVERSION because without
+  // support for explicit conversion operators, we can't easily have these bad
+  // conversions completely removed. They still do fail to compile in practice,
+  // but not in a way that we can static_assert on.
+#ifdef MOZ_HAVE_EXPLICIT_CONVERSION
+  static_assert(!IsConvertible<decltype(T1::A | T1::B), T2>::value,
+                "should not be convertible");
+  static_assert(!IsConvertible<decltype(T1::A | T1::B), decltype(T2::A)>::value,
+                "should not be convertible");
+  static_assert(!IsConvertible<decltype(T1::A | T1::B), decltype(T2::A | T2::B)>::value,
+                "should not be convertible");
+#endif
+}
+
+enum class Int8EnumWithHighBits : int8_t {
+  A = 0x20,
+  B = 0x40
+};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int8EnumWithHighBits)
+
+enum class Uint8EnumWithHighBits : uint8_t {
+  A = 0x40,
+  B = 0x80
+};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Uint8EnumWithHighBits)
+
+enum class Int16EnumWithHighBits : int16_t {
+  A = 0x2000,
+  B = 0x4000
+};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int16EnumWithHighBits)
+
+enum class Uint16EnumWithHighBits : uint16_t {
+  A = 0x4000,
+  B = 0x8000
+};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Uint16EnumWithHighBits)
+
+enum class Int32EnumWithHighBits : int32_t {
+  A = 0x20000000,
+  B = 0x40000000
+};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int32EnumWithHighBits)
+
+enum class Uint32EnumWithHighBits : uint32_t {
+  A = 0x40000000u,
+  B = 0x80000000u
+};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Uint32EnumWithHighBits)
+
+enum class Int64EnumWithHighBits : int64_t {
+  A = 0x2000000000000000ll,
+  B = 0x4000000000000000ll
+};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Int64EnumWithHighBits)
+
+enum class Uint64EnumWithHighBits : uint64_t {
+  A = 0x4000000000000000ull,
+  B = 0x8000000000000000ull
+};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Uint64EnumWithHighBits)
+
+// Checks that we don't accidentally truncate high bits by coercing to the wrong
+// integer type internally when implementing bitwise ops.
+template<typename EnumType, typename IntType>
+void TestIsNotTruncated()
+{
+  EnumType a = EnumType::A;
+  EnumType b = EnumType::B;
+  MOZ_RELEASE_ASSERT(IntType(a));
+  MOZ_RELEASE_ASSERT(IntType(b));
+  MOZ_RELEASE_ASSERT(a | EnumType::B);
+  MOZ_RELEASE_ASSERT(a | b);
+  MOZ_RELEASE_ASSERT(EnumType::A | EnumType::B);
+  EnumType c = EnumType::A | EnumType::B;
+  MOZ_RELEASE_ASSERT(IntType(c));
+  MOZ_RELEASE_ASSERT(c & c);
+  MOZ_RELEASE_ASSERT(c | c);
+  MOZ_RELEASE_ASSERT(c == (EnumType::A | EnumType::B));
+  MOZ_RELEASE_ASSERT(a != (EnumType::A | EnumType::B));
+  MOZ_RELEASE_ASSERT(b != (EnumType::A | EnumType::B));
+  MOZ_RELEASE_ASSERT(c & EnumType::A);
+  MOZ_RELEASE_ASSERT(c & EnumType::B);
+  EnumType d = EnumType::A;
+  d |= EnumType::B;
+  MOZ_RELEASE_ASSERT(d == c);
+}
+
+int
+main()
+{
+  TestTypedEnumBasics<AutoEnum>();
+  TestTypedEnumBasics<CharEnum>();
+  TestTypedEnumBasics<Nested::AutoEnum>();
+  TestTypedEnumBasics<Nested::CharEnum>();
+
+  TestTypedEnumBitField<AutoEnumBitField>();
+  TestTypedEnumBitField<CharEnumBitField>();
+  TestTypedEnumBitField<Nested::AutoEnumBitField>();
+  TestTypedEnumBitField<Nested::CharEnumBitField>();
+
+  TestTypedEnumBitField<BitFieldFor_uint8_t>();
+  TestTypedEnumBitField<BitFieldFor_int8_t>();
+  TestTypedEnumBitField<BitFieldFor_uint16_t>();
+  TestTypedEnumBitField<BitFieldFor_int16_t>();
+  TestTypedEnumBitField<BitFieldFor_uint32_t>();
+  TestTypedEnumBitField<BitFieldFor_int32_t>();
+  TestTypedEnumBitField<BitFieldFor_uint64_t>();
+  TestTypedEnumBitField<BitFieldFor_int64_t>();
+  TestTypedEnumBitField<BitFieldFor_char>();
+  TestTypedEnumBitField<BitFieldFor_signed_char>();
+  TestTypedEnumBitField<BitFieldFor_unsigned_char>();
+  TestTypedEnumBitField<BitFieldFor_short>();
+  TestTypedEnumBitField<BitFieldFor_unsigned_short>();
+  TestTypedEnumBitField<BitFieldFor_int>();
+  TestTypedEnumBitField<BitFieldFor_unsigned_int>();
+  TestTypedEnumBitField<BitFieldFor_long>();
+  TestTypedEnumBitField<BitFieldFor_unsigned_long>();
+  TestTypedEnumBitField<BitFieldFor_long_long>();
+  TestTypedEnumBitField<BitFieldFor_unsigned_long_long>();
+
+  TestNoConversionsBetweenUnrelatedTypes();
+
+  TestIsNotTruncated<Int8EnumWithHighBits, int8_t>();
+  TestIsNotTruncated<Int16EnumWithHighBits, int16_t>();
+  TestIsNotTruncated<Int32EnumWithHighBits, int32_t>();
+  TestIsNotTruncated<Int64EnumWithHighBits, int64_t>();
+  TestIsNotTruncated<Uint8EnumWithHighBits, uint8_t>();
+  TestIsNotTruncated<Uint16EnumWithHighBits, uint16_t>();
+  TestIsNotTruncated<Uint32EnumWithHighBits, uint32_t>();
+  TestIsNotTruncated<Uint64EnumWithHighBits, uint64_t>();
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestUniquePtr.cpp b/src/third_party/mozjs-45/mfbt/tests/TestUniquePtr.cpp
new file mode 100644
index 0000000..3455d64
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestUniquePtr.cpp
@@ -0,0 +1,575 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
+#include "mozilla/Compiler.h"
+#include "mozilla/Move.h"
+#include "mozilla/TypeTraits.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/Vector.h"
+
+#include <stddef.h>
+
+using mozilla::DefaultDelete;
+using mozilla::IsSame;
+using mozilla::MakeUnique;
+using mozilla::Swap;
+using mozilla::UniquePtr;
+using mozilla::Vector;
+
+#define CHECK(c) \
+  do { \
+    bool cond = !!(c); \
+    MOZ_ASSERT(cond, "Failed assertion: " #c); \
+    if (!cond) { \
+      return false; \
+    } \
+  } while (false)
+
+typedef UniquePtr<int> NewInt;
+static_assert(sizeof(NewInt) == sizeof(int*), "stored most efficiently");
+
+static size_t gADestructorCalls = 0;
+
+struct A
+{
+public:
+  A() : mX(0) {}
+  virtual ~A() { gADestructorCalls++; }
+
+  int mX;
+};
+
+static size_t gBDestructorCalls = 0;
+
+struct B : public A
+{
+public:
+  B() : mY(1) {}
+  ~B() { gBDestructorCalls++; }
+
+  int mY;
+};
+
+typedef UniquePtr<A> UniqueA;
+typedef UniquePtr<B, UniqueA::DeleterType> UniqueB; // permit interconversion
+
+static_assert(sizeof(UniqueA) == sizeof(A*), "stored most efficiently");
+static_assert(sizeof(UniqueB) == sizeof(B*), "stored most efficiently");
+
+struct DeleterSubclass : UniqueA::DeleterType {};
+
+typedef UniquePtr<B, DeleterSubclass> UniqueC;
+static_assert(sizeof(UniqueC) == sizeof(B*), "stored most efficiently");
+
+static UniqueA
+ReturnUniqueA()
+{
+  return UniqueA(new B);
+}
+
+static UniqueA
+ReturnLocalA()
+{
+  UniqueA a(new A);
+  return Move(a);
+}
+
+static bool
+TestDefaultFreeGuts()
+{
+  static_assert(IsSame<NewInt::DeleterType, DefaultDelete<int> >::value,
+                "weird deleter?");
+
+  NewInt n1(new int);
+  CHECK(n1);
+  CHECK(n1.get() != nullptr);
+
+  n1 = nullptr;
+  CHECK(!n1);
+  CHECK(n1.get() == nullptr);
+
+  int* p1 = new int;
+  n1.reset(p1);
+  CHECK(n1);
+  NewInt n2(Move(n1));
+  CHECK(!n1);
+  CHECK(n1.get() == nullptr);
+  CHECK(n2.get() == p1);
+
+  Swap(n1, n2);
+  CHECK(n1.get() == p1);
+  CHECK(n2.get() == nullptr);
+
+  n1.swap(n2);
+  CHECK(n1.get() == nullptr);
+  CHECK(n2.get() == p1);
+  delete n2.release();
+
+  CHECK(n1.get() == nullptr);
+  CHECK(n2 == nullptr);
+  CHECK(nullptr == n2);
+
+  int* p2 = new int;
+  int* p3 = new int;
+  n1.reset(p2);
+  n2.reset(p3);
+  CHECK(n1.get() == p2);
+  CHECK(n2.get() == p3);
+
+  n1.swap(n2);
+  CHECK(n2 != nullptr);
+  CHECK(nullptr != n2);
+  CHECK(n2.get() == p2);
+  CHECK(n1.get() == p3);
+
+  UniqueA a1;
+  CHECK(a1 == nullptr);
+  a1.reset(new A);
+  CHECK(gADestructorCalls == 0);
+  CHECK(a1->mX == 0);
+
+  B* bp1 = new B;
+  bp1->mX = 5;
+  CHECK(gBDestructorCalls == 0);
+  a1.reset(bp1);
+  CHECK(gADestructorCalls == 1);
+  CHECK(a1->mX == 5);
+  a1.reset(nullptr);
+  CHECK(gADestructorCalls == 2);
+  CHECK(gBDestructorCalls == 1);
+
+  B* bp2 = new B;
+  UniqueB b1(bp2);
+  UniqueA a2(nullptr);
+  a2 = Move(b1);
+  CHECK(gADestructorCalls == 2);
+  CHECK(gBDestructorCalls == 1);
+
+  UniqueA a3(Move(a2));
+  a3 = nullptr;
+  CHECK(gADestructorCalls == 3);
+  CHECK(gBDestructorCalls == 2);
+
+  B* bp3 = new B;
+  bp3->mX = 42;
+  UniqueB b2(bp3);
+  UniqueA a4(Move(b2));
+  CHECK(b2.get() == nullptr);
+  CHECK((*a4).mX == 42);
+  CHECK(gADestructorCalls == 3);
+  CHECK(gBDestructorCalls == 2);
+
+  UniqueA a5(new A);
+  UniqueB b3(new B);
+  a5 = Move(b3);
+  CHECK(gADestructorCalls == 4);
+  CHECK(gBDestructorCalls == 2);
+
+  ReturnUniqueA();
+  CHECK(gADestructorCalls == 5);
+  CHECK(gBDestructorCalls == 3);
+
+  ReturnLocalA();
+  CHECK(gADestructorCalls == 6);
+  CHECK(gBDestructorCalls == 3);
+
+  UniqueA a6(ReturnLocalA());
+  a6 = nullptr;
+  CHECK(gADestructorCalls == 7);
+  CHECK(gBDestructorCalls == 3);
+
+  UniqueC c1(new B);
+  UniqueA a7(new B);
+  a7 = Move(c1);
+  CHECK(gADestructorCalls == 8);
+  CHECK(gBDestructorCalls == 4);
+
+  c1.reset(new B);
+
+  UniqueA a8(Move(c1));
+  CHECK(gADestructorCalls == 8);
+  CHECK(gBDestructorCalls == 4);
+
+  // These smart pointers still own B resources.
+  CHECK(a4);
+  CHECK(a5);
+  CHECK(a7);
+  CHECK(a8);
+  return true;
+}
+
+static bool
+TestDefaultFree()
+{
+  CHECK(TestDefaultFreeGuts());
+  CHECK(gADestructorCalls == 12);
+  CHECK(gBDestructorCalls == 8);
+  return true;
+}
+
+static size_t FreeClassCounter = 0;
+
+struct FreeClass
+{
+public:
+  FreeClass() {}
+
+  void operator()(int* aPtr)
+  {
+    FreeClassCounter++;
+    delete aPtr;
+  }
+};
+
+typedef UniquePtr<int, FreeClass> NewIntCustom;
+static_assert(sizeof(NewIntCustom) == sizeof(int*),
+              "stored most efficiently");
+
+static bool
+TestFreeClass()
+{
+  CHECK(FreeClassCounter == 0);
+  {
+    NewIntCustom n1(new int);
+    CHECK(FreeClassCounter == 0);
+  }
+  CHECK(FreeClassCounter == 1);
+
+  NewIntCustom n2;
+  {
+    NewIntCustom n3(new int);
+    CHECK(FreeClassCounter == 1);
+    n2 = Move(n3);
+  }
+  CHECK(FreeClassCounter == 1);
+  n2 = nullptr;
+  CHECK(FreeClassCounter == 2);
+
+  n2.reset(nullptr);
+  CHECK(FreeClassCounter == 2);
+  n2.reset(new int);
+  n2.reset();
+  CHECK(FreeClassCounter == 3);
+
+  NewIntCustom n4(new int, FreeClass());
+  CHECK(FreeClassCounter == 3);
+  n4.reset(new int);
+  CHECK(FreeClassCounter == 4);
+  n4.reset();
+  CHECK(FreeClassCounter == 5);
+
+  FreeClass f;
+  NewIntCustom n5(new int, f);
+  CHECK(FreeClassCounter == 5);
+  int* p = n5.release();
+  CHECK(FreeClassCounter == 5);
+  delete p;
+
+  return true;
+}
+
+typedef UniquePtr<int, DefaultDelete<int>&> IntDeleterRef;
+typedef UniquePtr<A, DefaultDelete<A>&> ADeleterRef;
+typedef UniquePtr<B, DefaultDelete<A>&> BDeleterRef;
+
+static_assert(sizeof(IntDeleterRef) > sizeof(int*),
+              "has to be heavier than an int* to store the reference");
+static_assert(sizeof(ADeleterRef) > sizeof(A*),
+              "has to be heavier than an A* to store the reference");
+static_assert(sizeof(BDeleterRef) > sizeof(int*),
+              "has to be heavier than a B* to store the reference");
+
+static bool
+TestReferenceDeleterGuts()
+{
+  DefaultDelete<int> delInt;
+  IntDeleterRef id1(new int, delInt);
+
+  IntDeleterRef id2(Move(id1));
+  CHECK(id1 == nullptr);
+  CHECK(nullptr != id2);
+  CHECK(&id1.getDeleter() == &id2.getDeleter());
+
+  IntDeleterRef id3(Move(id2));
+
+  DefaultDelete<A> delA;
+  ADeleterRef a1(new A, delA);
+  a1.reset(nullptr);
+  a1.reset(new B);
+  a1 = nullptr;
+
+  BDeleterRef b1(new B, delA);
+  a1 = Move(b1);
+
+  BDeleterRef b2(new B, delA);
+
+  ADeleterRef a2(Move(b2));
+
+  return true;
+}
+
+static bool
+TestReferenceDeleter()
+{
+  gADestructorCalls = 0;
+  gBDestructorCalls = 0;
+
+  CHECK(TestReferenceDeleterGuts());
+
+  CHECK(gADestructorCalls == 4);
+  CHECK(gBDestructorCalls == 3);
+
+  gADestructorCalls = 0;
+  gBDestructorCalls = 0;
+  return true;
+}
+
+typedef void (&FreeSignature)(void*);
+
+static size_t DeleteIntFunctionCallCount = 0;
+
+static void
+DeleteIntFunction(void* aPtr)
+{
+  DeleteIntFunctionCallCount++;
+  delete static_cast<int*>(aPtr);
+}
+
+static void
+SetMallocedInt(UniquePtr<int, FreeSignature>& aPtr, int aI)
+{
+  int* newPtr = static_cast<int*>(malloc(sizeof(int)));
+  *newPtr = aI;
+  aPtr.reset(newPtr);
+}
+
+static UniquePtr<int, FreeSignature>
+MallocedInt(int aI)
+{
+  UniquePtr<int, FreeSignature>
+    ptr(static_cast<int*>(malloc(sizeof(int))), free);
+  *ptr = aI;
+  return Move(ptr);
+}
+static bool
+TestFunctionReferenceDeleter()
+{
+  // Look for allocator mismatches and leaks to verify these bits
+  UniquePtr<int, FreeSignature> i1(MallocedInt(17));
+  CHECK(*i1 == 17);
+
+  SetMallocedInt(i1, 42);
+  CHECK(*i1 == 42);
+
+  // These bits use a custom deleter so we can instrument deletion.
+  {
+    UniquePtr<int, FreeSignature> i2 =
+      UniquePtr<int, FreeSignature>(new int(42), DeleteIntFunction);
+    CHECK(DeleteIntFunctionCallCount == 0);
+
+    i2.reset(new int(76));
+    CHECK(DeleteIntFunctionCallCount == 1);
+  }
+
+  CHECK(DeleteIntFunctionCallCount == 2);
+
+  return true;
+}
+
+template<typename T>
+struct AppendNullptrTwice
+{
+  AppendNullptrTwice() {}
+
+  bool operator()(Vector<T>& vec)
+  {
+    CHECK(vec.append(nullptr));
+    CHECK(vec.append(nullptr));
+    return true;
+  }
+};
+
+static size_t AAfter;
+static size_t BAfter;
+
+static bool
+TestVectorGuts()
+{
+  Vector<UniqueA> vec;
+  CHECK(vec.append(new B));
+  CHECK(vec.append(new A));
+  CHECK(AppendNullptrTwice<UniqueA>()(vec));
+  CHECK(vec.append(new B));
+
+  size_t initialLength = vec.length();
+
+  UniqueA* begin = vec.begin();
+  bool appendA = true;
+  do {
+    CHECK(appendA ? vec.append(new A) : vec.append(new B));
+    appendA = !appendA;
+  } while (begin == vec.begin());
+
+  size_t numAppended = vec.length() - initialLength;
+
+  BAfter = numAppended / 2;
+  AAfter = numAppended - numAppended / 2;
+
+  CHECK(gADestructorCalls == 0);
+  CHECK(gBDestructorCalls == 0);
+  return true;
+}
+
+static bool
+TestVector()
+{
+  gADestructorCalls = 0;
+  gBDestructorCalls = 0;
+
+  CHECK(TestVectorGuts());
+
+  CHECK(gADestructorCalls == 3 + AAfter + BAfter);
+  CHECK(gBDestructorCalls == 2 + BAfter);
+  return true;
+}
+
+typedef UniquePtr<int[]> IntArray;
+static_assert(sizeof(IntArray) == sizeof(int*),
+              "stored most efficiently");
+
+static bool
+TestArray()
+{
+  static_assert(IsSame<IntArray::DeleterType, DefaultDelete<int[]> >::value,
+                "weird deleter?");
+
+  IntArray n1(new int[5]);
+  CHECK(n1);
+  CHECK(n1.get() != nullptr);
+
+  n1 = nullptr;
+  CHECK(!n1);
+  CHECK(n1.get() == nullptr);
+
+  int* p1 = new int[42];
+  n1.reset(p1);
+  CHECK(n1);
+  IntArray n2(Move(n1));
+  CHECK(!n1);
+  CHECK(n1.get() == nullptr);
+  CHECK(n2.get() == p1);
+
+  Swap(n1, n2);
+  CHECK(n1.get() == p1);
+  CHECK(n2.get() == nullptr);
+
+  n1.swap(n2);
+  CHECK(n1.get() == nullptr);
+  CHECK(n2.get() == p1);
+  delete[] n2.release();
+
+  CHECK(n1.get() == nullptr);
+  CHECK(n2.get() == nullptr);
+
+  int* p2 = new int[7];
+  int* p3 = new int[42];
+  n1.reset(p2);
+  n2.reset(p3);
+  CHECK(n1.get() == p2);
+  CHECK(n2.get() == p3);
+
+  n1.swap(n2);
+  CHECK(n2.get() == p2);
+  CHECK(n1.get() == p3);
+
+  n1 = Move(n2);
+  CHECK(n1.get() == p2);
+  n1 = Move(n2);
+  CHECK(n1.get() == nullptr);
+
+  UniquePtr<A[]> a1(new A[17]);
+  static_assert(sizeof(a1) == sizeof(A*),
+                "stored most efficiently");
+
+  UniquePtr<A[]> a2(new A[5], DefaultDelete<A[]>());
+  a2.reset(nullptr);
+  a2.reset(new A[17]);
+  a2 = nullptr;
+
+  UniquePtr<A[]> a3(nullptr);
+  a3.reset(new A[7]);
+
+  return true;
+}
+
+struct Q
+{
+  Q() {}
+  Q(const Q&) {}
+
+  Q(Q&, char) {}
+
+  template<typename T>
+  Q(Q, T&&, int) {}
+
+  Q(int, long, double, void*) {}
+};
+
+static int randomInt() { return 4; }
+
+static bool
+TestMakeUnique()
+{
+  UniquePtr<int> a1(MakeUnique<int>());
+  UniquePtr<long> a2(MakeUnique<long>(4));
+
+  // no args, easy
+  UniquePtr<Q> q0(MakeUnique<Q>());
+
+  // temporary bound to const lval ref
+  UniquePtr<Q> q1(MakeUnique<Q>(Q()));
+
+  // passing through a non-const lval ref
+  UniquePtr<Q> q2(MakeUnique<Q>(*q1, 'c'));
+
+  // pass by copying, forward a temporary, pass by value
+  UniquePtr<Q> q3(MakeUnique<Q>(Q(), UniquePtr<int>(), randomInt()));
+
+  // various type mismatching to test "fuzzy" forwarding
+  UniquePtr<Q> q4(MakeUnique<Q>('s', 66LL, 3.141592654, &q3));
+
+  UniquePtr<char[]> c1(MakeUnique<char[]>(5));
+
+  return true;
+}
+
+int
+main()
+{
+  if (!TestDefaultFree()) {
+    return 1;
+  }
+  if (!TestFreeClass()) {
+    return 1;
+  }
+  if (!TestReferenceDeleter()) {
+    return 1;
+  }
+  if (!TestFunctionReferenceDeleter()) {
+    return 1;
+  }
+  if (!TestVector()) {
+    return 1;
+  }
+  if (!TestArray()) {
+    return 1;
+  }
+  if (!TestMakeUnique()) {
+    return 1;
+  }
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestVariant.cpp b/src/third_party/mozjs-45/mfbt/tests/TestVariant.cpp
new file mode 100644
index 0000000..531e175
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestVariant.cpp
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/UniquePtr.h"
+#include "mozilla/Variant.h"
+
+using mozilla::MakeUnique;
+using mozilla::UniquePtr;
+using mozilla::Variant;
+
+struct Destroyer {
+  static int destroyedCount;
+  ~Destroyer() {
+    destroyedCount++;
+  }
+};
+
+int Destroyer::destroyedCount = 0;
+
+static void
+testSimple()
+{
+  printf("testSimple\n");
+  Variant<uint32_t, uint64_t> v(uint64_t(1));
+  MOZ_RELEASE_ASSERT(v.is<uint64_t>());
+  MOZ_RELEASE_ASSERT(!v.is<uint32_t>());
+  MOZ_RELEASE_ASSERT(v.as<uint64_t>() == 1);
+}
+
+static void
+testCopy()
+{
+  printf("testCopy\n");
+  Variant<uint32_t, uint64_t> v1(uint64_t(1));
+  Variant<uint32_t, uint64_t> v2(v1);
+  MOZ_RELEASE_ASSERT(v2.is<uint64_t>());
+  MOZ_RELEASE_ASSERT(!v2.is<uint32_t>());
+  MOZ_RELEASE_ASSERT(v2.as<uint64_t>() == 1);
+
+  Variant<uint32_t, uint64_t> v3(uint32_t(10));
+  v3 = v2;
+  MOZ_RELEASE_ASSERT(v3.is<uint64_t>());
+  MOZ_RELEASE_ASSERT(v3.as<uint64_t>() == 1);
+}
+
+static void
+testMove()
+{
+  printf("testMove\n");
+  Variant<UniquePtr<int>, char> v1(MakeUnique<int>(5));
+  Variant<UniquePtr<int>, char> v2(Move(v1));
+
+  MOZ_RELEASE_ASSERT(v2.is<UniquePtr<int>>());
+  MOZ_RELEASE_ASSERT(*v2.as<UniquePtr<int>>() == 5);
+
+  MOZ_RELEASE_ASSERT(v1.is<UniquePtr<int>>());
+  MOZ_RELEASE_ASSERT(v1.as<UniquePtr<int>>() == nullptr);
+
+  Destroyer::destroyedCount = 0;
+  {
+    Variant<char, UniquePtr<Destroyer>> v3(MakeUnique<Destroyer>());
+    Variant<char, UniquePtr<Destroyer>> v4(Move(v3));
+
+    Variant<char, UniquePtr<Destroyer>> v5('a');
+    v5 = Move(v4);
+
+    auto ptr = v5.extract<UniquePtr<Destroyer>>();
+    MOZ_RELEASE_ASSERT(Destroyer::destroyedCount == 0);
+  }
+  MOZ_RELEASE_ASSERT(Destroyer::destroyedCount == 1);
+}
+
+static void
+testDestructor()
+{
+  printf("testDestructor\n");
+  Destroyer::destroyedCount = 0;
+
+  {
+    Destroyer d;
+
+    {
+      Variant<char, UniquePtr<char[]>, Destroyer> v(d);
+      MOZ_RELEASE_ASSERT(Destroyer::destroyedCount == 0); // None detroyed yet.
+    }
+
+    MOZ_RELEASE_ASSERT(Destroyer::destroyedCount == 1); // v's copy of d is destroyed.
+  }
+
+  MOZ_RELEASE_ASSERT(Destroyer::destroyedCount == 2); // d is destroyed.
+}
+
+static void
+testEquality()
+{
+  printf("testEquality\n");
+  using V = Variant<char, int>;
+
+  V v0('a');
+  V v1('b');
+  V v2('b');
+  V v3(42);
+  V v4(27);
+  V v5(27);
+  V v6(int('b'));
+
+  MOZ_RELEASE_ASSERT(v0 != v1);
+  MOZ_RELEASE_ASSERT(v1 == v2);
+  MOZ_RELEASE_ASSERT(v2 != v3);
+  MOZ_RELEASE_ASSERT(v3 != v4);
+  MOZ_RELEASE_ASSERT(v4 == v5);
+  MOZ_RELEASE_ASSERT(v1 != v6);
+
+  MOZ_RELEASE_ASSERT(v0 == v0);
+  MOZ_RELEASE_ASSERT(v1 == v1);
+  MOZ_RELEASE_ASSERT(v2 == v2);
+  MOZ_RELEASE_ASSERT(v3 == v3);
+  MOZ_RELEASE_ASSERT(v4 == v4);
+  MOZ_RELEASE_ASSERT(v5 == v5);
+  MOZ_RELEASE_ASSERT(v6 == v6);
+}
+
+struct Describer
+{
+  static const char* little;
+  static const char* medium;
+  static const char* big;
+
+  using ReturnType = const char*;
+
+  const char* match(const uint8_t&) { return little; }
+  const char* match(const uint32_t&) { return medium; }
+  const char* match(const uint64_t&) { return big; }
+};
+
+const char* Describer::little = "little";
+const char* Describer::medium = "medium";
+const char* Describer::big = "big";
+
+static void
+testMatching()
+{
+  printf("testMatching\n");
+  using V = Variant<uint8_t, uint32_t, uint64_t>;
+
+  Describer desc;
+
+  V v1(uint8_t(1));
+  V v2(uint32_t(2));
+  V v3(uint64_t(3));
+
+  MOZ_RELEASE_ASSERT(v1.match(desc) == Describer::little);
+  MOZ_RELEASE_ASSERT(v2.match(desc) == Describer::medium);
+  MOZ_RELEASE_ASSERT(v3.match(desc) == Describer::big);
+
+  const V& constRef1 = v1;
+  const V& constRef2 = v2;
+  const V& constRef3 = v3;
+
+  MOZ_RELEASE_ASSERT(constRef1.match(desc) == Describer::little);
+  MOZ_RELEASE_ASSERT(constRef2.match(desc) == Describer::medium);
+  MOZ_RELEASE_ASSERT(constRef3.match(desc) == Describer::big);
+}
+
+int
+main()
+{
+  testSimple();
+  testCopy();
+  testMove();
+  testDestructor();
+  testEquality();
+  testMatching();
+
+  printf("TestVariant OK!\n");
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestVector.cpp b/src/third_party/mozjs-45/mfbt/tests/TestVector.cpp
new file mode 100644
index 0000000..a05e85d
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestVector.cpp
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Move.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/Vector.h"
+
+using mozilla::detail::VectorTesting;
+using mozilla::MakeUnique;
+using mozilla::Move;
+using mozilla::UniquePtr;
+using mozilla::Vector;
+
+struct mozilla::detail::VectorTesting
+{
+  static void testReserved();
+  static void testConstRange();
+  static void testEmplaceBack();
+};
+
+void
+mozilla::detail::VectorTesting::testReserved()
+{
+#ifdef DEBUG
+  Vector<bool> bv;
+  MOZ_RELEASE_ASSERT(bv.reserved() == 0);
+
+  MOZ_RELEASE_ASSERT(bv.append(true));
+  MOZ_RELEASE_ASSERT(bv.reserved() == 1);
+
+  Vector<bool> otherbv;
+  MOZ_RELEASE_ASSERT(otherbv.append(false));
+  MOZ_RELEASE_ASSERT(otherbv.append(true));
+  MOZ_RELEASE_ASSERT(bv.appendAll(otherbv));
+  MOZ_RELEASE_ASSERT(bv.reserved() == 3);
+
+  MOZ_RELEASE_ASSERT(bv.reserve(5));
+  MOZ_RELEASE_ASSERT(bv.reserved() == 5);
+
+  MOZ_RELEASE_ASSERT(bv.reserve(1));
+  MOZ_RELEASE_ASSERT(bv.reserved() == 5);
+
+  Vector<bool> bv2(Move(bv));
+  MOZ_RELEASE_ASSERT(bv.reserved() == 0);
+  MOZ_RELEASE_ASSERT(bv2.reserved() == 5);
+
+  bv2.clearAndFree();
+  MOZ_RELEASE_ASSERT(bv2.reserved() == 0);
+
+  Vector<int, 42> iv;
+  MOZ_RELEASE_ASSERT(iv.reserved() == 0);
+
+  MOZ_RELEASE_ASSERT(iv.append(17));
+  MOZ_RELEASE_ASSERT(iv.reserved() == 1);
+
+  Vector<int, 42> otheriv;
+  MOZ_RELEASE_ASSERT(otheriv.append(42));
+  MOZ_RELEASE_ASSERT(otheriv.append(37));
+  MOZ_RELEASE_ASSERT(iv.appendAll(otheriv));
+  MOZ_RELEASE_ASSERT(iv.reserved() == 3);
+
+  MOZ_RELEASE_ASSERT(iv.reserve(5));
+  MOZ_RELEASE_ASSERT(iv.reserved() == 5);
+
+  MOZ_RELEASE_ASSERT(iv.reserve(1));
+  MOZ_RELEASE_ASSERT(iv.reserved() == 5);
+
+  MOZ_RELEASE_ASSERT(iv.reserve(55));
+  MOZ_RELEASE_ASSERT(iv.reserved() == 55);
+
+  Vector<int, 42> iv2(Move(iv));
+  MOZ_RELEASE_ASSERT(iv.reserved() == 0);
+  MOZ_RELEASE_ASSERT(iv2.reserved() == 55);
+
+  iv2.clearAndFree();
+  MOZ_RELEASE_ASSERT(iv2.reserved() == 0);
+#endif
+}
+
+void
+mozilla::detail::VectorTesting::testConstRange()
+{
+#ifdef DEBUG
+  Vector<int> vec;
+
+  for (int i = 0; i < 10; i++) {
+    MOZ_RELEASE_ASSERT(vec.append(i));
+  }
+
+  const auto &vecRef = vec;
+
+  Vector<int>::ConstRange range = vecRef.all();
+  for (int i = 0; i < 10; i++) {
+    MOZ_RELEASE_ASSERT(!range.empty());
+    MOZ_RELEASE_ASSERT(range.front() == i);
+    range.popFront();
+  }
+#endif
+}
+
+namespace {
+
+struct S
+{
+  size_t            j;
+  UniquePtr<size_t> k;
+
+  static size_t constructCount;
+  static size_t moveCount;
+
+  S(size_t j, size_t k)
+    : j(j)
+    , k(MakeUnique<size_t>(k))
+  {
+    constructCount++;
+  }
+
+  S(S&& rhs)
+    : j(rhs.j)
+    , k(Move(rhs.k))
+  {
+    rhs.~S();
+    moveCount++;
+  }
+
+  S(const S&) = delete;
+  S& operator=(const S&) = delete;
+};
+
+size_t S::constructCount = 0;
+size_t S::moveCount = 0;
+
+}
+
+void
+mozilla::detail::VectorTesting::testEmplaceBack()
+{
+  Vector<S> vec;
+  MOZ_RELEASE_ASSERT(vec.reserve(20));
+
+  for (size_t i = 0; i < 10; i++) {
+    S s(i, i*i);
+    MOZ_RELEASE_ASSERT(vec.append(Move(s)));
+  }
+
+  MOZ_RELEASE_ASSERT(vec.length() == 10);
+  MOZ_RELEASE_ASSERT(S::constructCount == 10);
+  MOZ_RELEASE_ASSERT(S::moveCount == 10);
+
+  for (size_t i = 10; i < 20; i++) {
+    MOZ_RELEASE_ASSERT(vec.emplaceBack(i, i*i));
+  }
+
+  MOZ_RELEASE_ASSERT(vec.length() == 20);
+  MOZ_RELEASE_ASSERT(S::constructCount == 20);
+  MOZ_RELEASE_ASSERT(S::moveCount == 10);
+
+  for (size_t i = 0; i < 20; i++) {
+    MOZ_RELEASE_ASSERT(vec[i].j == i);
+    MOZ_RELEASE_ASSERT(*vec[i].k == i*i);
+  }
+}
+
+int
+main()
+{
+  VectorTesting::testReserved();
+  VectorTesting::testConstRange();
+  VectorTesting::testEmplaceBack();
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestWeakPtr.cpp b/src/third_party/mozjs-45/mfbt/tests/TestWeakPtr.cpp
new file mode 100644
index 0000000..15060f0
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestWeakPtr.cpp
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/WeakPtr.h"
+
+using mozilla::SupportsWeakPtr;
+using mozilla::WeakPtr;
+
+// To have a class C support weak pointers, inherit from SupportsWeakPtr<C>.
+class C : public SupportsWeakPtr<C>
+{
+public:
+  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(C)
+
+  int mNum;
+
+  C()
+    : mNum(0)
+  {}
+
+  ~C()
+  {
+    // Setting mNum in the destructor allows us to test against use-after-free below
+    mNum = 0xDEAD;
+  }
+
+  void act() {}
+
+  bool isConst() {
+    return false;
+  }
+
+  bool isConst() const {
+    return true;
+  }
+};
+
+bool isConst(C*)
+{
+  return false;
+}
+
+bool isConst(const C*)
+{
+  return true;
+}
+
+int
+main()
+{
+  C* c1 = new C;
+  MOZ_RELEASE_ASSERT(c1->mNum == 0);
+
+  // Get weak pointers to c1. The first time,
+  // a reference-counted WeakReference object is created that
+  // can live beyond the lifetime of 'c1'. The WeakReference
+  // object will be notified of 'c1's destruction.
+  WeakPtr<C> w1 = c1;
+  // Test a weak pointer for validity before using it.
+  MOZ_RELEASE_ASSERT(w1);
+  MOZ_RELEASE_ASSERT(w1 == c1);
+  w1->mNum = 1;
+  w1->act();
+
+  // Test taking another WeakPtr<C> to c1
+  WeakPtr<C> w2 = c1;
+  MOZ_RELEASE_ASSERT(w2);
+  MOZ_RELEASE_ASSERT(w2 == c1);
+  MOZ_RELEASE_ASSERT(w2 == w1);
+  MOZ_RELEASE_ASSERT(w2->mNum == 1);
+
+  // Test a WeakPtr<const C>
+  WeakPtr<const C> w3const = c1;
+  MOZ_RELEASE_ASSERT(w3const);
+  MOZ_RELEASE_ASSERT(w3const == c1);
+  MOZ_RELEASE_ASSERT(w3const == w1);
+  MOZ_RELEASE_ASSERT(w3const == w2);
+  MOZ_RELEASE_ASSERT(w3const->mNum == 1);
+
+  // Test const-correctness of operator-> and operator T*
+  MOZ_RELEASE_ASSERT(!w1->isConst());
+  MOZ_RELEASE_ASSERT(w3const->isConst());
+  MOZ_RELEASE_ASSERT(!isConst(w1));
+  MOZ_RELEASE_ASSERT(isConst(w3const));
+
+  // Test that when a WeakPtr is destroyed, it does not destroy the object that it points to,
+  // and it does not affect other WeakPtrs pointing to the same object (e.g. it does not
+  // destroy the WeakReference object).
+  {
+    WeakPtr<C> w4local = c1;
+    MOZ_RELEASE_ASSERT(w4local == c1);
+  }
+  // Now w4local has gone out of scope. If that had destroyed c1, then the following would fail
+  // for sure (see C::~C()).
+  MOZ_RELEASE_ASSERT(c1->mNum == 1);
+  // Check that w4local going out of scope hasn't affected other WeakPtr's pointing to c1
+  MOZ_RELEASE_ASSERT(w1 == c1);
+  MOZ_RELEASE_ASSERT(w2 == c1);
+
+  // Now construct another C object and test changing what object a WeakPtr points to
+  C* c2 = new C;
+  c2->mNum = 2;
+  MOZ_RELEASE_ASSERT(w2->mNum == 1); // w2 was pointing to c1
+  w2 = c2;
+  MOZ_RELEASE_ASSERT(w2);
+  MOZ_RELEASE_ASSERT(w2 == c2);
+  MOZ_RELEASE_ASSERT(w2 != c1);
+  MOZ_RELEASE_ASSERT(w2 != w1);
+  MOZ_RELEASE_ASSERT(w2->mNum == 2);
+
+  // Destroying the underlying object clears weak pointers to it.
+  // It should not affect pointers that are not currently pointing to it.
+  delete c1;
+  MOZ_RELEASE_ASSERT(!w1, "Deleting an object should clear WeakPtr's to it.");
+  MOZ_RELEASE_ASSERT(!w3const, "Deleting an object should clear WeakPtr's to it.");
+  MOZ_RELEASE_ASSERT(w2, "Deleting an object should not clear WeakPtr that are not pointing to it.");
+
+  delete c2;
+  MOZ_RELEASE_ASSERT(!w2, "Deleting an object should clear WeakPtr's to it.");
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/TestXorShift128PlusRNG.cpp b/src/third_party/mozjs-45/mfbt/tests/TestXorShift128PlusRNG.cpp
new file mode 100644
index 0000000..dbe83d0
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/TestXorShift128PlusRNG.cpp
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <math.h>
+
+#include "mozilla/Assertions.h"
+#include "mozilla/PodOperations.h"
+#include "mozilla/XorShift128PlusRNG.h"
+
+using mozilla::non_crypto::XorShift128PlusRNG;
+
+static void
+TestDumbSequence()
+{
+  XorShift128PlusRNG rng(1, 4);
+
+  // Calculated by hand following the algorithm given in the paper. The upper
+  // bits are mostly zero because we started with a poor seed; once it has run
+  // for a while, we'll get an even mix of ones and zeros in all 64 bits.
+  MOZ_RELEASE_ASSERT(rng.next() == 0x800049);
+  MOZ_RELEASE_ASSERT(rng.next() == 0x3000186);
+  MOZ_RELEASE_ASSERT(rng.next() == 0x400003001145);
+
+  // Using ldexp here lets us write out the mantissa in hex, so we can compare
+  // them with the results generated by hand.
+  MOZ_RELEASE_ASSERT(rng.nextDouble()
+                     == ldexp(static_cast<double>(0x1400003105049), -53));
+  MOZ_RELEASE_ASSERT(rng.nextDouble()
+                     == ldexp(static_cast<double>(0x2000802e49146), -53));
+  MOZ_RELEASE_ASSERT(rng.nextDouble()
+                     == ldexp(static_cast<double>(0x248300468544d), -53));
+}
+
+static size_t
+Population(uint64_t n)
+{
+  size_t pop = 0;
+
+  while (n > 0) {
+    n &= n-1; // Clear the rightmost 1-bit in n.
+    pop++;
+  }
+
+  return pop;
+}
+
+static void
+TestPopulation()
+{
+  XorShift128PlusRNG rng(698079309544035222ULL, 6012389156611637584ULL);
+
+  // Give it some time to warm up; it should tend towards more
+  // even distributions of zeros and ones.
+  for (size_t i = 0; i < 40; i++)
+    rng.next();
+
+  for (size_t i = 0; i < 40; i++) {
+    size_t pop = Population(rng.next());
+    MOZ_RELEASE_ASSERT(24 <= pop && pop <= 40);
+  }
+}
+
+static void
+TestSetState()
+{
+  static const uint64_t seed[2] = { 1795644156779822404ULL, 14162896116325912595ULL };
+  XorShift128PlusRNG rng(seed[0], seed[1]);
+
+  const size_t n = 10;
+  uint64_t log[n];
+
+  for (size_t i = 0; i < n; i++)
+    log[i] = rng.next();
+
+  rng.setState(seed[0], seed[1]);
+
+  for (size_t i = 0; i < n; i++)
+    MOZ_RELEASE_ASSERT(log[i] == rng.next());
+}
+
+static void
+TestDoubleDistribution()
+{
+  XorShift128PlusRNG rng(0xa207aaede6859736, 0xaca6ca5060804791);
+
+  const size_t n = 100;
+  size_t bins[n];
+  mozilla::PodArrayZero(bins);
+
+  // This entire file runs in 0.006s on my laptop. Generating
+  // more numbers lets us put tighter bounds on the bins.
+  for (size_t i = 0; i < 100000; i++) {
+    double d = rng.nextDouble();
+    MOZ_RELEASE_ASSERT(0.0 <= d && d < 1.0);
+    bins[(int) (d * n)]++;
+  }
+
+  for (size_t i = 0; i < n; i++) {
+    MOZ_RELEASE_ASSERT(900 <= bins[i] && bins[i] <= 1100);
+  }
+}
+
+int
+main()
+{
+  TestDumbSequence();
+  TestPopulation();
+  TestSetState();
+  TestDoubleDistribution();
+
+  return 0;
+}
diff --git a/src/third_party/mozjs-45/mfbt/tests/moz.build b/src/third_party/mozjs-45/mfbt/tests/moz.build
new file mode 100644
index 0000000..850254b
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/tests/moz.build
@@ -0,0 +1,66 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+CppUnitTests([
+    'TestArrayUtils',
+    'TestAtomics',
+    'TestBinarySearch',
+    'TestBloomFilter',
+    'TestCasting',
+    'TestCeilingFloor',
+    'TestCheckedInt',
+    'TestCountPopulation',
+    'TestCountZeroes',
+    'TestEndian',
+    'TestEnumSet',
+    'TestFastBernoulliTrial',
+    'TestFloatingPoint',
+    'TestFunction',
+    'TestIntegerPrintfMacros',
+    'TestIntegerRange',
+    'TestJSONWriter',
+    'TestLinkedList',
+    'TestMacroArgs',
+    'TestMacroForEach',
+    'TestMathAlgorithms',
+    'TestMaybe',
+    'TestPair',
+    'TestRefPtr',
+    'TestRollingMean',
+    'TestScopeExit',
+    'TestSegmentedVector',
+    'TestSHA1',
+    'TestSplayTree',
+    'TestTemplateLib',
+    'TestTuple',
+    'TestTypedEnum',
+    'TestTypeTraits',
+    'TestUniquePtr',
+    'TestVariant',
+    'TestVector',
+    'TestWeakPtr',
+    'TestXorShift128PlusRNG',
+])
+
+if not CONFIG['MOZ_ASAN']:
+    CppUnitTests([
+        'TestPoisonArea',
+    ])
+
+# Since we link directly with MFBT object files, define IMPL_MFBT
+DEFINES['IMPL_MFBT'] = True
+
+DISABLE_STL_WRAPPING = True
+
+if CONFIG['_MSC_VER']:
+  CXXFLAGS += [
+    '-wd4275', # non dll-interface class used as base for dll-interface class
+    '-wd4530', # C++ exception handler used, but unwind semantics are not enabled
+  ]
+
+USE_LIBS += [
+    'mfbt',
+]
diff --git a/src/third_party/mozjs-45/mfbt/unused.cpp b/src/third_party/mozjs-45/mfbt/unused.cpp
new file mode 100644
index 0000000..4acfa7a
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/unused.cpp
@@ -0,0 +1,13 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/unused.h"
+
+namespace mozilla {
+
+const unused_t Unused = unused_t();
+
+} // namespace mozilla
diff --git a/src/third_party/mozjs-45/mfbt/unused.h b/src/third_party/mozjs-45/mfbt/unused.h
new file mode 100644
index 0000000..e693e32
--- /dev/null
+++ b/src/third_party/mozjs-45/mfbt/unused.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_unused_h
+#define mozilla_unused_h
+
+#include "mozilla/Types.h"
+
+#ifdef __cplusplus
+
+namespace mozilla {
+
+//
+// Suppress GCC warnings about unused return values with
+//   Unused << SomeFuncDeclaredWarnUnusedReturnValue();
+//
+struct unused_t
+{
+  template<typename T>
+  inline void
+  operator<<(const T& /*unused*/) const {}
+};
+
+extern MFBT_DATA const unused_t Unused;
+
+} // namespace mozilla
+
+#endif // __cplusplus
+
+// An alternative to mozilla::Unused for use in (a) C code and (b) code where
+// linking with unused.o is difficult.
+#define MOZ_UNUSED(expr) \
+  do { if (expr) { (void)0; } } while (0)
+
+#endif // mozilla_unused_h