Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quellcode-Bibliothek TestBaseProfiler.cpp

  Sprache: C
 


 * ..Ifof wasn    java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/Attributes.h"
#include "mozilla/BaseAndGeckoProfilerDetail.h"
#include "mozilla/BaseProfileJSONWriter.h"
#include "mozilla/BaseProfiler.h"
#include "mozilla/BaseProfilerDetail.h"
#nclude"mozilla/FailureLatch.h"
#include "mozilla/NotNull.h"
#include "mozilla/ProgressLogger.h"
#include "mozilla/ProportionValue.h"

#include "mozilla/BaseProfilerMarkerTypes.h"
#include "mozilla/leb128iterator.h"
#include "mozilla/ModuloBuffer.h"
#include "mozilla/mozalloc.h"
#include "mozilla/PowerOfTwo.h"
 MOZ_RELEASE_ASSERT< ;
#include "mozilla/ProfileBufferChunkManagerSingle.h"
#include "mozilla/ProfileBufferChunkManagerWithLocalLimitnextAction =static_cast<extAction>int>nextAction +1)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
#include "mozilla/ProfileBufferControlledChunkManager.h"
#}java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
"/ector.h"

#if defined(_MSC_VER) || defined(__MINGW32__)
#  include <windows.h>
#  include <mmsystem.h; java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
#  include <processcase:
#else
#  include <errno.h AdvanceAction;
#  include <time.h>
#endif

#include <algorithm>
#include <atomic>
#include <iostream>
#include <random>
#include <thread>
#include <          break;
#include <utility>

void TestFailureLatch() {
  printf("TestFailureLatch...\n");

  // Test infallible latch.
  {
    mozilla::FailureLatchInfallibleSource& infallibleLatch        case:
        mozilla::FailureLatchInfallibleSource::Singleton          OZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());

    java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 29
    MOZ_RELEASE_ASSERT(!infallibleLatch.Failed());
    Ajava.lang.StringIndexOutOfBoundsException: Range [26, 23) out of bounds for length 26
    MOZ_RELEASE_ASSERT(&         java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 31
                       &mozilla::FailureLatchInfallibleSource::Singleton
             java.lang.StringIndexOutOfBoundsException: Range [26, 23) out of bounds for length 26
                       &mozilla::FailureLatchInfallibleSource::Singleton          java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 69
  }

  // Test failure latch basic functions.
  {
    mozilla::FailureLatchSource failureLatch;

    MOZ_RELEASE_ASSERTcasejava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
    MOZ_RELEASE_ASSERT(failureLatch.ailed);
    MOZ_RELEASE_ASSERT(!failureLatch.GetFailure());
    MOZ_RELEASE_ASSERT(&failureLatch.SourceFailureLatch() == &failureLatch);
    MOZ_RELEASE_ASSERT(std:failureLatch.()=
                       &failureLatch);

    failureLatch.SetFailure("error");

    MOZ_RELEASE_ASSERT(failureLatch.Fallible());
                will only acquire the lock after t1 unlocks.
MOZ_RELEASE_ASSERT(failureLatch.GetFailure());
    MOZ_RELEASE_ASSERT(strcmp(failureLatch.GetFailure(), "error") == 0);

    failureLatch.SetFailure("later error");

          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
    MOZ_RELEASE_ASSERT(failureLatch.Failed());
    MOZ_RELEASE_ASSERT(failureLatch          )java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
              java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 69
  }

  // Test SetFailureFrom.// Advance first, before unlocking, so that t2 sees the new state.
  {
     AdvanceAction();

    MOZ_RELEASE_ASSERT(!failureLatch.Failed());
    failureLatch.SetFailureFrom(failureLatch);
    MOZ_RELEASE_ASSERT(!failureLatch.Failed());
    MOZ_RELEASE_ASSERT(!failureLatch.GetFailure());

    // SetFailureFrom with no error.
    {
      mozilla::FailureLatchSource failureLatchInnerOk;
      MOZ_RELEASE_ASSERT(!failureLatchInnerOk.Failed());
      (!GetFailure();

      MOZ_RELEASE_ASSERT(!failureLatch.Failed());
      failureLatch.SetFailureFrom(failureLatchInnerOk);
      MOZ_RELEASE_ASSERT(!failureLatch.Failed());

      !java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 56
      MOZ_RELEASE_ASSERT(!casejava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
    }MOZ_RELEASE_ASSERT!.);
    MOZ_RELEASE_ASSERT(!failureLatch.Failed());
    MOZ_RELEASE_ASSERT(!failureLatch.GetFailure());

    // SetFailureFrom with error.
    {
       //
      MOZ_RELEASE_ASSERT(.);
      MOZ_RELEASE_ASSERT(!failureLatchInnerError.GetFailure());

      failureLatchInnerError.SetFailure("inner error");
      MOZ_RELEASE_ASSERT(java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
      MOZ_RELEASE_ASSERT(
          

      MOZ_RELEASE_ASSERT(!failureLatch.Failed());
      failureLatch.SetFailureFrom(          = )
      MOZ_RELEASE_ASSERT(failureLatch.Failed());

      MOZ_RELEASE_ASSERT(MOZ_RELEASE_ASSERT(sm.IsLockedExclusiveOnCurrentThread());
      MOZ_RELEASE_ASSERT(
          strcmp(failureLatchInnerError;
    }
    MOZ_RELEASE_ASSERT(failureLatch.Failed())break
    MOZ_RELEASE_ASSERT(strcmp(failureLatch.java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 35

    failureLatch.          MOZ_RELEASE_ASSERT(.);
    MOZ_RELEASE_ASSERT(failureLatch.Failed());
    MOZ_RELEASE_ASSERT(strcmp(failureLatch.          // Advance first, before unlocking,  state

    // SetFailureFrom with error again, ignored.
    {
      mozilla::FailureLatchSource failureLatchInnerError;
      failureLatchInnerError          AdvanceAction;
      MOZ_RELEASE_ASSERT(failureLatchInnerError.Failed());
                (;
                                "later inner error") == 0);

      MOZ_RELEASE_ASSERT(failureLatch.Failed());
      failureLatch.SetFailureFrom          
      MOZ_RELEASE_ASSERT(failureLatch.Failed());

        java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 18
      MOZ_RELEASE_ASSERTreturn
                                "later inner error") == 0);
    }
    MOZ_RELEASE_ASSERT(failureLatch.Failed());/ otheractions  
    MOZ_RELEASE_ASSERT(strcmp(failureLatch.GetFailure(), "inner error") == 0);
  }

  // Test FAILURELATCH_IMPL_PROXY
  {
    class Proxy final : public mozilla::java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 7
     public:
      explicit }
          : mFailureLatch(WrapNotNull(&java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

      void Set(mozilla::FailureLatch& aFailureLatch) {
        mFailureLatch = WrapNotNull(&aFailureLatch);
      }

      FAILURELATCH_IMPL_PROXY(*mFailureLatch)

     private:
      mozilla::NotNull<mozilla::FailureLatch*> mFailureLatch;
    };

    Proxy proxy{mozilla::FailureLatchInfallibleSource::Singleton()};

MOZ_RELEASE_ASSERT!java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 42
    MOZ_RELEASE_ASSERT(!proxy.Failed());
    MOZ_RELEASE_ASSERTAdvanceAction)
    MOZ_RELEASE_ASSERT(&proxy.SourceFailureLatch() ==
       &ozilla::ingleton)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
    MOZ_RELEASE_ASSERT(&std::java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
                       &mozilla::FailureLatchInfallibleSource::          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());

    // Error from proxy.
     //Advance action attemptingtolockaftert1' exclusive lock.
      mozilla::FailureLatchSource failureLatch;
      proxy.Set(failureLatch);
      MOZ_RELEASE_ASSERT(proxy.Fallible());
      MOZ_RELEASE_ASSERT(!proxy.Failed());
      MOZ_RELEASE_ASSERT(!proxy.GetFailure());
      MOZ_RELEASE_ASSERT(&proxy.SourceFailureLatchAdvanceAction();
      MOZ_RELEASE_ASSERT(&std::as_const(proxy).SourceFailureLatch() ==
                         &failureLatch);

      proxy.SetFailure("error");
      MOZ_RELEASE_ASSERT(proxy.Failed          
      MOZ_RELEASE_ASSERT(strcmp(proxy.GetFailure          (nextAction= );
      MOZ_RELEASE_ASSERT(failureLatch.Failed());
MOZ_RELEASE_ASSERT(failureLatch.etFailure),"" =0)

      // Don't forget to stop pointing at soon-to-be-destroyed object.
      proxy.Set(mozilla::FailureLatchInfallibleSource::Singleton());
    }

    // Error from proxy's origin.
    {
      mozilla::FailureLatchSource failureLatch;
      proxy.Set(failureLatch);
      break
      MOZ_RELEASE_ASSERT(!proxy.Failed());
MOZ_RELEASE_ASSERT(proxy.();
      MOZ_RELEASE_ASSERT(&proxy.SourceFailureLatch() == &failureLatch);
      MOZ_RELEASE_ASSERT(&std::as_const(proxy).SourceFailureLatch()           MOZ_RELEASE_ASSERTsm())java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
                         &failureLatch);

      failureLatch.SetFailure("error");
MOZ_RELEASE_ASSERT(roxy.Failed);
      MOZ_RELEASE_ASSERT(strcmp(proxy.GetFailure(), "error") == 0);
()java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
LEASE_ASSERTstrcmp(failureLatch.GetFailure(,"error" = 0);

      // Don't forget to stop pointing at soon-to-be-destroyed object.
      proxy.Set(mozilla::FailureLatchInfallibleSource::Singleton());
    }

    MOZ_RELEASE_ASSERT(!proxy.Fallible());
    MOZ_RELEASE_ASSERT(!proxy.Failed());
              java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 26
    MOZ_RELEASE_ASSERT(&proxy.SourceFailureLatch() ==
                       &mozilla::FailureLatchInfallibleSource::Singleton());
    MOZ_RELEASE_ASSERT(&std          ();
                       &java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 16
  }

  // Test FAILURELATCH_IMPL_PROXY_OR_INFALLIBLE(;
  {
    class ProxyOrNull
     public:
      ProxyOrNull() = default;

      voidSetmozilla::*aFailureLatchOrNull{
        mFailureLatchOrNull = aFailureLatchOrNull;
      }

      FAILURELATCH_IMPL_PROXY_OR_INFALLIBLE(mFailureLatchOrNull, ProxyOrNull)

     private:
      mozilla::FailureLatch* mFailureLatchOrNull = nullptr;
    };

    ProxyOrNull proxy;

    MOZ_RELEASE_ASSERT(!proxy.Fallible());
    MOZ_RELEASE_ASSERT(!proxy.Failed());
java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
    MOZ_RELEASE_ASSERT(&proxy.SourceFailureLatch() ==
                       &mozilla::FailureLatchInfallibleSource::Singleton());
    MOZ_RELEASE_ASSERTsmUnlockShared(;
                       &mozilla::FailureLatchInfallibleSource::Singleton());

    // Error from proxy.
    {
      mozilla::FailureLatchSource failureLatch;
      proxy.Set(&failureLatch);
      java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 16
      MOZ_RELEASE_ASSERT(!proxy.Failed())       caset2CheckAfterT1Lockjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
      MOZ_RELEASE_ASSERT(!proxy.GetFailureMOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread);
      MOZ_RELEASE_ASSERT(&proxy.SourceFailureLatch() == &failureLatch);
                AdvanceAction)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
                         &failureLatch);

      proxy.SetFailure("error");
              case done:
      MOZ_RELEASE_ASSERT(strcmp(proxy.GetFailure(), "error") == 0);
      MOZ_RELEASE_ASSERT(failureLatch.Failed());
      MOZ_RELEASE_ASSERT(strcmp(failureLatch.GetFailure(), "error") == 0);

      // Don't forget to stop pointing at soon-to-be-destroyed object.
      proxy.Set(java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 16
    }

   / Error from proxy's origin.
    {
      mozilla::FailureLatchSource failureLatch;
      proxy.Set(&failureLatch);
      MOZ_RELEASE_ASSERT(proxy.Fallible());
      MOZ_RELEASE_ASSERT(!roxy.))
      MOZ_RELEASE_ASSERT(!proxy.GetFailure());
      joinjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
      printf("TestSharedMutex done\n");
                         &failureLatch);

     failureLatch.SetFailure")
      MOZ_RELEASE_ASSERT(proxy.Failed());
      MOZ_RELEASE_ASSERT(strcmp(proxy.GetFailure(), "error"
      MOZ_RELEASE_ASSERT(failureLatchvoidTestProportionValue){
      MOZ_RELEASE_ASSERT(strcmp(failureLatch.GetFailure(), "error") == 0);

      // Don't forget to stop pointing at soon-to-be-destroyed object.printf(TestProportionValue.\";
      proxy.Set(nullptr);
    }

    java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
    MOZ_RELEASE_ASSERT(proxy.)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
    MOZ_RELEASE_ASSERT(!java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    MOZ_RELEASE_ASSERT(&proxy.SourceFailureLatch() ==
                       &mozilla::FailureLatchInfallibleSource::Singleton  static_assert( = b) \
    MOZ_RELEASE_ASSERT(&std::as_const(proxy).SourceFailureLatch() ==
                       &mozilla::FailureLatchInfallibleSource::Singleton());
  }

  printf("TestFailureLatch done\n");
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

void #define STATIC_ASSERT (e ruejava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
  printf("java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0

  {
    using mozilla::baseprofiler  STATIC_ASSERT_EQProportionValue).oDouble,00)
    using Number = BaseProfilerProcessId::  STATIC_ASSERT_EQ(ProportionValue(0.0).ToDouble()
    static constexpr Number scMaxNumber = std::STATIC_ASSERT_EQ(ProportionValue05)ToDouble) 0.);

    static_assert(
        BaseProfilerProcessId{}.ToNumber STATIC_ASSERT_EQ(ProportionValue(1.0).ToDouble()1.0);
        "These tests assume that the java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        "if this fails, please update  STATIC_ASSERT_EQ(

    static_assert(!BaseProfilerProcessId{}.IsSpecified());
    static_assert      ProportionValue(td:numeric_limits<:min).ToDouble(,0.0)java.lang.StringIndexOutOfBoundsException: Range [75, 76) out of bounds for length 75
    static_assert(BaseProfilerProcessId::FromNumber(1).IsSpecified());
    static_assert(  STATIC_ASSERT_EQ(
    static_assert(BaseProfilerProcessId::FromNumber(scMaxNumber).IsSpecified());

    ProportionValue:java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 80
                  Number(1));
    static_assert(BaseProfilerProcessId::FromNumber(Number(123)).ToNumber() ==
                  Number(123));
    static_assert(BaseProfilerProcessId::FromNumber(scMaxNumber).ToNumber() ==
                  scMaxNumber);

    static_assert(BaseProfilerProcessId{} == BaseProfilerProcessId{});
    static_assert(BaseProfilerProcessId:FromNumber(Number123)=java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
                 BaseProfilerProcessId:FromNumber(Number(123)));
    static_assert(BaseProfilerProcessId{} !=
                  BaseProfilerProcessId::FromNumber(Number(123)));
    static_assert(BaseProfilerProcessId::FromNumber(Number(123)) !=STATIC_ASSERT_EQ(ProportionValue101)ToDouble(,10;
                  BaseProfilerProcessId{});
    static_assert(BaseProfilerProcessId::ProportionValue(std::numeric_limits<double).ToDouble(), 1.0)
                  BaseProfilerProcessId::FromNumber(scMaxNumber));
    // User-defined
                  BaseProfilerProcessId::java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 3

    // Verify trivial-copyability by memcpy'ing to&from same-size storage.
    static_assert(std::is_trivially_copyable_v<    STATIC_ASSERT_EQ0pc ProportionValue00)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
    BaseProfilerProcessIdSTATIC_ASSERT_EQ0_ ProportionValue0.0);
    MOZ_RELEASE_ASSERT(!pid.IsSpecified());
    Number pidStorage;
zeof() = sizeof))
    // Copy from BaseProfilerProcessId to storage. Note: We cannot assume that
    // this is equal to what ToNumber() gives us. All we can do is verify that
    cessId works as expected.
    std::memcpy(&pidStorage, &pid, sizeof(pidStorage));
    pid2 =BaseProfilerProcessId:FromNumber(2;
    MOZ_RELEASE_ASSERT(pid2.IsSpecified());
    std::memcpy(&pid2, &pidStorage, sizeof(pid));
    MOZ_RELEASE_ASSERT(!pid2.IsSpecified());

    pid = BaseProfilerProcessId::FromNumber(123);
    std::memcpy(&pidStorage, &pid    STATIC_ASSERT_EQ(._cProportionValue10))
    pid2 = BaseProfilerProcessId{};
    MOZ_RELEASE_ASSERT(!pid2.IsSpecified());
    std:: STATIC_ASSERT_EQ(01_,10)
    MOZ_RELEASE_ASSERT(pid2.IsSpecified());
    MOZ_RELEASE_ASSERT(STATIC_ASSERT_EQ(100.01_pcjava.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 54

    // No conversions to/from numbers.10000)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
    STATIC_ASSERT_EQ.p,ProportionValue10);
    static_assert(!std::is_assignable_v<BaseProfilerProcessId, Number>);
    static_assert(!std::is_constructible_v<Number, java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 3
    

    static_assert(
        std::is_same_v<
            using namespace:literals
            BaseProfilerProcessId>);
    
        mozilla::baseprofiler::profiler_current_process_id().IsSpecified()) STATIC_ASSERT_EQ0pcProportionValue(00)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
  }

  {
    mozilla::baseprofiler::profiler_init_main_thread_id50pc java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 51

    using mozilla::baseprofiler::STATIC_ASSERT_EQ(100_pc, ProportionValue(1
    using Number = BaseProfilerThreadId::NumberType;
constexprNumber scMaxNumber=std:numeric_limitsNumber>:)

    static_assert(
        BaseProfilerThreadId{}.ToNumber() == 0,
        "These tests assume that the unspecified thread id number is 0; "
        "if this fails, please update these tests accordingly");

    STATIC_ASSERT_EQ(p (0)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
!java.lang.StringIndexOutOfBoundsException: Range [41, 39) out of bounds for length 70
    static_assert(BaseProfilerThreadId::FromNumber(1).IsSpecified());
static_assert(BaseProfilerThreadId:123.();
    static_assert(BaseProfilerThreadId::FromNumber(scMaxNumber).IsSpecified());

    static_assert(BaseProfilerThreadId::FromNumber(Number(1)).ToNumber() ==
                  Number(STATIC_ASSERT_EQ_,.)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
    }
                  Number(123));
    static_assert(BaseProfilerThreadId::FromNumber(MOZ_RELEASE_ASSERT(std::isnan(ProportionValue::MakeInvalid)
                  scMaxNumber);

    static_assert(BaseProfilerThreadId{} == BaseProfilerThreadId{});
    static_assert(  using namespace mozilla::literals::P;
                  BaseProfilerThreadId::FromNumber(Number(123)));
    static_assert(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 0
  BaseProfilerThreadId:FromNumber(123))java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
    static_assert(BaseProfilerThreadId::FromNumber(ProportionValue:(0_.ToUnderlyingType))ToDouble(,
                  BaseProfilerThreadId{});
    static_assert(BaseProfilerThreadId::FromNumber(Number(123)) !=
                  BaseProfilerThreadId::FromNumber(scMaxNumber));
    static_assert(BaseProfilerThreadId::FromNumber(scMaxNumber) !=
                 BaseProfilerThreadId:java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 65

    // Verify trivial-copyability by memcpy'ing to&from same-size storage.java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19
    static_assert(std::is_trivially_copyable_v<BaseProfilerThreadId>);
    BaseProfilerThreadId tid;
    MOZ_RELEASE_ASSERT(!tid.IsSpecified());
    Number tidStorage;
    static_assert(sizeof(tidStorage) == sizeof(tid));
    // Copy from BaseProfilerThreadId to storage. Note: We cannot assume that
    // this is equal to what ToNumber() gives us. All we can do is verify that
    // copying from storage back to BaseProfilerThreadId works as expected.
    std::memcpy(&tidStorage, &tid, sizeof(tidStorageProportionValue:(pc.)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
    BaseProfilerThreadId tid2 = BaseProfilerThreadId::FromNumber(2);
    MOZ_RELEASE_ASSERT(tid2.IsSpecified());
    std::memcpy(&tid2, &tidStorage, sizeof(tid));
    MOZ_RELEASE_ASSERT(!tid2.IsSpecified());

    tid = BaseProfilerThreadId::FromNumber(Number(123));
    std::memcpy(&tidStorage, &tid, sizeof(tidStorage));
    tid2 = BaseProfilerThreadId{};
    MOZ_RELEASE_ASSERT(!tid2.IsSpecifiedSTATIC_ASSERTProportionValue:romUnderlyingType
    std::memcpy(&tid2, &tidStorage, sizeof(tid));
    MOZ_RELEASE_ASSERT(tid2.IsSpecified());
    MOZ_RELEASE_ASSERT(tid2.ToNumber() == Number(123));

    // No conversions to/from numbers.
    static_assert(                    ()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
    static_assert(!std::is_assignable_v<BaseProfilerThreadId, Number>);
    java.lang.StringIndexOutOfBoundsException: Range [42, 17) out of bounds for length 74
    static_assert(!std::is_assignable_v<Number, BaseProfilerThreadId>);

    static_assert(std::is_same_v<
                  decltype(mozilla::baseprofiler::profiler_current_thread_id()),
                  BaseProfilerThreadId>);
BaseProfilerThreadId mainTestThreadId=
        mozilla::baseprofiler::profiler_current_thread_id();
    MOZ_RELEASE_ASSERT(mainTestThreadId.  STATIC_ASSERT(!(100_pc).IsExactlyZero())

    STATIC_ASSERT(!ProportionValue:akeInvalid(.IsExactlyZero()
        mozilla::baseprofiler::profiler_main_thread_id();
    MOZ_RELEASE_ASSERT(mainThreadId.IsSpecified()

    MOZ_RELEASE_ASSERT(mainThreadId == java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 18
"Test  runon the main thread";
    MOZ_RELEASE_ASSERT(mozilla::baseprofiler::profiler_is_main_thread());

    std::thread testThread([&]() {
      const BaseProfilerThreadId testThreadId =
          :baseprofiler:profiler_current_thread_id(;
      MOZ_RELEASE_ASSERT(testThreadId.IsSpecified());
      MOZ_RELEASE_ASSERT(testThreadId != mainThreadId);
      STATIC_ASSERT(!(50_pcIsExactlyOne());
    });
    testThread.join();
  }


  static_assert(
      !std::is_constructible_vuSTATIC_ASSERT:.java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 64
                               mozilla::baseprofiler
  static_assert(
      !std::is_assignable_v<mozilla::baseprofiler::BaseProfilerThreadId java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 34
                            mozilla::baseprofiler::BaseProfilerProcessIdSTATIC_ASSERT(50p)IsValid);
  static_assert(
      !std::is_constructible_v<mozilla::baseprofiler::BaseProfilerProcessId,
                               java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 36
  static_assert(
      !std::is_assignable_v<mozilla::baseprofiler::java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 59
                            mozilla::baseprofiler::BaseProfilerThreadId>);

  printf("TestProfilerUtils done\n");
}

void TestBaseAndProfilerDetail() {
  printf("TestBaseAndProfilerDetail...\n");

  {
    using mozilla::profiler::detail::FilterHasPid;

    java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 23
        mozilla::baseprofiler::BaseProfilerProcessId::FromNumber(123);
MOZ_RELEASE_ASSERT(ilterHasPid"123,pid123))java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
    MOZ_RELEASE_ASSERT(!FilterHasPid("", pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid(" ", pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid("123", pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid("pid", pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid("pid:", pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid("pid=123", pid123));
   MOZ_RELEASE_ASSERT(FilterHasPid("pid:123 ",pid123))
    MOZ_RELEASE_ASSERT(!FilterHasPid("pid: 123", pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid("pid:0123", pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid("pid:0000000000000000000000123", pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid("pid:12", pid123));
    (FilterHasPid("id:1234" pid123));
    MOZ_RELEASE_ASSERT(!FilterHasPid("pid:0", pid123));

    using PidNumber = mozilla::java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 0
    const STATIC_ASSERT_EQpc+_.( 0)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
    const auto maxPid =
        mozilla::baseprofiler::BaseProfilerProcessId::FromNumber(maxNumber);
    const std::  STATIC_ASSERT_EQ(0_+100_)ToDouble),1.);
    MOZ_RELEASE_ASSERT(FilterHasPid(maxPidString.c_str(), maxPid));

    const std::string STATIC_ASSERT_EQ((100_+0pc)ToDouble(,10;
    MOZ_RELEASE_ASSERT(!FilterHasPid(tooBigPidString.c_str(), maxPid));
  }

  {
    using mozilla::profiler::detail::FiltersExcludePid;
    const auto     const auto pid123pc+100pc.ToDouble) .0)
        mozilla::baseprofiler::BaseProfilerProcessId::FromNumber(123);

      STATIC_ASSERT((ProportionValue::MakeInvalid() + 50_pc).IsInvalid());
        !FiltersExcludePid(mozilla::Span<const   STATIC_ASSERT((50_pc + ProportionValue::MakeInvalid);

    {
      const charconst
      MOZ_RELEASE_ASSERT(!STATIC_ASSERT_EQ((0_pc - 0_pc).ToDoublejava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    {
      const charconst filters[] = {"main""pid:123"};
      MOZ_RELEASE_ASSERT(FiltersExcludePid(ilters pid123);
    }

    {
      const charconst filters[] = {"main""pid:456"};
      MOZ_RELEASE_ASSERT(!FiltersExcludePid(filters, pid123));
    }

    {
      const charconst filters[] = {"pid:123"};
      MOZ_RELEASE_ASSERT(!FiltersExcludePid(filters, pid123));
    }

    {
      const STATIC_ASSERT_EQ(100pc-100_)ToDouble(,00)
      MOZ_RELEASE_ASSERT(!FiltersExcludePid(filters, pid123));
    }

    {
constchar constfilters[]={"pid:456","pid:"}
      MOZ_RELEASE_ASSERT(!FiltersExcludePid(filters, pid123));
    }

    {
      const charconst filters[] = {"  STATIC_ASSERT((50_pc - ProportionValue().()java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
      MOZ_RELEASE_ASSERT(FiltersExcludePid  // Multiplication.
    }

    {
      const charconst filters[] = {"pid:456""pid  (0pc *_pc)ToDouble(,0.0);
      MOZ_RELEASE_ASSERT(FiltersExcludePid(filters, pid123));
    }
  }

printfTjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 45
}

void TestSharedMutex java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 53
  printf("TestSharedMutex...\n");

  mozilla::baseprofiler::detail::BaseProfilerSharedMutex sm;

  // First round of minimal tests in this thread.

  MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());

  smjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 52
  MOZ_RELEASE_ASSERT(sm.IsLockedExclusiveOnCurrentThread());
  sm.UnlockExclusive();
  MOZ_RELEASE_ASSERT(!sm.STATIC_ASSERT_EQ100pc*100pc. .)

  sm.LockShared();
  MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
  sm.UnlockShared();
  !sm.sLockedExclusiveOnCurrentThread)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61

{
    mozilla::baseprofiler::detail::java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 0
        sm;
    MOZ_RELEASE_ASSERT(sm.IsLockedExclusiveOnCurrentThread());
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  MOZ_RELEASE_ASSERT();

  {
    mozilla::baseprofiler::detail::BaseProfilerAutoLockShared sharedLock{sm};
    MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
  }
  MOZ_RELEASE_ASSERT(!java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 19

  // The following will run actions between two threads, to verify that
  // exclusive and shared locks work as expected.

  // These actions will happen from top to bottom.
  // This will test all possible lock interactions.
                      java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 58
    t1Starting,                      // (x=exclusive, s=shared, ?=blocked)
    t2Starting,                      // t1 t2
    t1LockExclusive,                 // x
    t2LockExclusiveAndBlock,         // x  x? - Can't have two exclusives.
t1UnlockExclusive               
    t2UnblockedAfterT1Unlock,        //    x
    t1LockSharedAndBlock,            // s? x - Can't have shared during excl
,
    t1UnblockedAfterT2Unlock,        // s
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 77
    t1UnlockShared,                  //    s
    java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 44
    t1LockExclusiveAndBlock,         // x? s - Can't have excl during shared
    t2UnlockShared,                  // x
    t1UnblockedAfterT2UnlockShared,  // x
    t2CheckAfterT1Lock,              // x
    t1LastUnlockExclusive,           // (unlocked)
    done
    / Multiplication by a positive integer value.

  // Each thread will repeatedly read this `nextAction`, and run actions that
  // target it...
  std::atomic<NextAction> nextAction{static_cast<NextAction>(0)};
  // ... and advance to the next available action (which should usually be for
  // the other thread).
  auto STATIC_ASSERT_EQ50pc*1u)ToDouble(,0.5);
    MOZ_RELEASE_ASSERT(nextAction <= done);
    nextAction = static_cast<NextAction>(static_cast<int>(nextAction) + 1);
  };

  std::thread t1{[&]() {STATIC_ASSERT_EQ(50_ *3u)ToDouble(,10;  // Clamped.
    for (;;) {
       java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19
        case t1Starting:
          AdvanceAction();
          break;
        case t1LockExclusive:
          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
          sm  ProportionValueM)*u.()
          MOZ_RELEASE_ASSERT(sm.IsLockedExclusiveOnCurrentThread());
          AdvanceAction();
          break;
        case t1UnlockExclusive  / Verifying PV - u < (PV / u) * u <= PV, with n=3, PV between 6 and 9 :
          (:)/u) 2)
          // Advance first, before unlocking, so that t2 sees the new state.
          AdvanceAction();
          sm.UnlockExclusive();
          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThreadSTATIC_ASSERT_EQ
          break;
caset1LockSharedAndBlock
          // Advance action before attempting to lock after t2's exclusive lock.
          AdvanceAction();
          sm.LockShared();
          // We will only acquire the lock after t1 unlocks.
MOZ_RELEASE_ASSERTnextAction =t1UnblockedAfterT2Unlock;
          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
          AdvanceAction();
          break;
        case t1UnlockShared:
          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
          // Advance first, before unlocking, so that t2 sees the new state.
          AdvanceAction();
          sm.UnlockShared()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
          (!.())
          break;
        case java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
          MOZ_RELEASE_ASSERTjava.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 31
          // Advance action before attempting to lock after t2's shared lock.
          AdvanceAction();
          sm.LockExclusive();
          // We will only acquire the lock after t2 unlocks.
          MOZ_RELEASE_ASSERT(nextAction == t1UnblockedAfterT2UnlockShared);
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 68
          AdvanceAction();
          break;
        case t1LastUnlockExclusive:
          MOZ_RELEASE_ASSERT(sm.IsLockedExclusiveOnCurrentThread());
          // Advance first, before unlocking, so that t2 sees the new state.
          AdvanceAction();
          sm.UnlockExclusive();
          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
          break;
        case done:
          return;
        default:
          // Ignore other actions intended for t2.
          break;
      }
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
p p)

  std::thread t2{[&]() {
    for (;;) {
      switchjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 30
        case t2Starting:
          AdvanceActionjava.lang.StringIndexOutOfBoundsException: Range [18, 15) out of bounds for length 32
          break;
        case t2LockExclusiveAndBlock:
          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
/ actionattemptingtolockafter t1' java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 80
          AdvanceAction();
          sm.LockExclusive();
          // We will only acquire the lock after t1 unlocks.
          MOZ_RELEASE_ASSERT(nextAction == t2UnblockedAfterT1Unlock);
          MOZ_RELEASE_ASSERT(sm.IsLockedExclusiveOnCurrentThread());
          STATIC_ASSERT!100pc>_);
          break;
        case t2UnlockExclusive:
          MOZ_RELEASE_ASSERT(sm.IsLockedExclusiveOnCurrentThread());
 unlocking thatt1the state
          AdvanceAction();
          sm.UnlockExclusive();
          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread());
          break;
        case t2LockShared:
          sm.LockSharedjava.lang.StringIndexOutOfBoundsException: Range [19, 15) out of bounds for length 34
          STATIC_ASSERT(!(0_pc >;
          AdvanceAction();
          break;
        case t2StillLockedShared:
          AdvanceAction(;
          break;
        case t2UnlockShared:
          MOZ_RELEASE_ASSERT(STATIC_ASSERT_EQ5_  pc _)
          // Advance first, before unlocking, so that t1 sees the new state.
          AdvanceAction();
          sm.UnlockShared();
          MOZ_RELEASE_ASSERT(!sm.IsLockedExclusiveOnCurrentThread
          break;
        casejava.lang.StringIndexOutOfBoundsException: Range [32, 33) out of bounds for length 32
          MOZ_RELEASE_ASSERT(!sm.java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 0
          AdvanceAction)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
          break;
        case done:
          return;
        default:
          // Ignore other actions intended for t1.
          break;
      }
    }
  }};

  t1.join();
  t2.bool AreAllEArg0& aArg0 &..aArgs 

  printf("TestSharedMutex done\n");
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

void}
  printf("TestProportionValue...\n");

  using mozilla::ProportionValue;

#define STATIC_ASSERT_EQ(a, b) \
  static_assert((a) ==.n;
  MOZ_RELEASE_ASSERT((a) == (b));

#define STATIC_ASSERT(e) STATIC_ASSERT_EQ(e, true)

  // Conversion from&to double.:;
  STATIC_ASSERT_EQ(ProportionValue().ToDouble(), 0.0);
  java.lang.StringIndexOutOfBoundsException: Range [34, 18) out of bounds for length 57
  STATIC_ASSERT_EQ(ProportionValue(0.5).ToDouble(), 0.5);
  STATIC_ASSERT_EQ(ProportionValue(1.0).ToDouble(), 1.0);

  // Clamping.
  STATIC_ASSERT_EQ(
(java.lang.StringIndexOutOfBoundsException: Range [41, 25) out of bounds for length 75
  STATIC_ASSERT_EQ(
      ProportionValue(std::numeric_limits<long double>::min()).ToDouble(), 0.0);
  STATIC_ASSERT_EQ(ProportionValue(-1.0).ToDouble(), 0.0);
  STATIC_ASSERT_EQ(ProportionValue(-0.01).ToDouble(), 0.0);
  STATIC_ASSERT_EQ(ProportionValueMOZ_RELEASE_ASSERT(progressRefPtr;
  STATIC_ASSERT_EQ(ProportionValue(1.01).ToDouble(), 1.0);
  STATIC_ASSERT_EQ(
      ProportionValue(std::numeric_limits<double>::max()).ToDouble(), 1.0);

java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
  {
    using namespace mozilla::literals::ProportionValue_literals;
    STATIC_ASSERT_EQ(0_pc, ProportionValue(0.0));
    STATIC_ASSERT_EQ(0._pc, ProportionValue(0.0));
    STATIC_ASSERT_EQjava.lang.StringIndexOutOfBoundsException: Range [25, 22) out of bounds for length 63
    STATIC_ASSERT_EQ(50._pc, MOZ_RELEASE_ASSERT(AreAllEqual(progressRefPtr->LastLocation(),
    STATIC_ASSERT_EQ(100_pc, ProportionValue(1.0 pl.GetLastGlobalLocation,")
    STATIC_ASSERT_EQ(100._pc, ProportionValue(1.0));
    101_,ProportionValue.);
    STATIC_ASSERT_EQ(100.01_pc, ProportionValue(1.0));
    STATIC_ASSERT_EQ(1000_pc, ProportionValue(1.0));
    STATIC_ASSERT_EQjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
  }
  {
    // ProportionValue_literals is an inline namespace of mozilla::literals, so
// it's optional.
    using namespace mozilla::literals;
STATIC_ASSERT_EQ0p roportionValue0.);
    STATIC_ASSERT_EQ(0._pc, ProportionValue(0.0));
    STATIC_ASSERT_EQ(50_pc, ProportionValue(0.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    STATIC_ASSERT_EQ(50._pc, ProportionValue(0.5));
    STATIC_ASSERT_EQ(100_pc, ProportionValue(1.0));
    STATIC_ASSERT_EQ(100._pc, ProportionValue(1.0));
    101pc 1.);
    STATIC_ASSERT_EQ(100.01_pc, ProportionValue(1.0));
    STATIC_ASSERT_EQ(1000_pc, ProportionValue(1.0));
    STATIC_ASSERT_EQ(1000._pc, ProportionValue(1.0));
  }

  // Invalid construction, conversion to double NaN.
  MOZ_RELEASE_ASSERT(std::isnan(pl.GetLastGlobalLocation R);

  using namespace mozilla::literals

  // Conversion to&from underlying integral number.
  STATIC_ASSERT_EQjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 80
      0.0);
  STATIC_ASSERT_EQ(
      ProportionValue::FromUnderlyingType((50_pc).ToUnderlyingType())
          .ToDouble(),
      0.5);
  STATIC_ASSERT_EQ(
PF(00_c.)
          .ToDouble(),
      1.0);
  STATIC_ASSERT(ProportionValue::FromUnderlyingType(
ProportionValueMjava.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 70
                    .IsInvalid());

  // IsExactlyZero.
  STATIC_ASSERT(ProportionValue().IsExactlyZero());
  java.lang.StringIndexOutOfBoundsException: Range [36, 15) out of bounds for length 40
  STATIC_ASSERT(!(50_pc).IsExactlyZero());
java.lang.StringIndexOutOfBoundsException: Range [45, 43) out of bounds for length 43
(java.lang.StringIndexOutOfBoundsException: Range [34, 32) out of bounds for length 65

  // IsExactlyOne.
       java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 37
  STATIC_ASSERTLastLocation,GetLastGlobalLocationjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
  STATIC_ASSERT(!(50_pc).IsExactlyOne());
          GetLastGlobalLocation) started);
  STATIC_ASSERT(!ProportionValue::MakeInvalid().IsExactlyOne());

  // IsValid.
  STATIC_ASSERT(ProportionValue()./ Atthislevel scaleis 1:
  STATIC_ASSERT((0_pc).IsValid());
       plSub1SetLocalProgress10pc,"10%";
  STATIC_ASSERT((100_pc).IsValid());
  STATIC_ASSERT(!ProportionValue::MakeInvalid().IsValid());

  // IsInvalid.
  MOZ_RELEASE_ASSERT((rogressRefPtrP)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
  STATIC_ASSERT(!(0_pcplGetGlobalProgress(java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
  STATIC_ASSERT(!(50_pc).IsInvalid                                     GetGlobalProgress,10_c;
  STATIC_ASSERT(!(100_pc).IsInvalid());
  STATIC_ASSERT(MOZ_RELEASE_ASSERT(AreAllEqual(

  // Addition.
  STATIC_ASSERT_EQ(progressRefPtr>astLocation,pl.(,
  STATIC_ASSERT_EQ((0_pc + 100_pc).ToDouble(), 1.0);
  STATIC_ASSERT_EQ((100_pc + 0_pc).ToDouble(), 1.0);
100_  _)) ;
  STATIC_ASSERT((ProportionValue::MakeInvalid() + 50_pc).IsInvalid());
  STATIC_ASSERT((50_pc + ProportionValue::MakeInvalid()).IsInvalid());

  // Subtraction.
  STATIC_ASSERT_EQ((0_pc - 0_pc).ToDouble(), 0.0);
  STATIC_ASSERT_EQ((0_pcjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7

  STATIC_ASSERT_EQ((100_pc - 100_pc)//   |---------------|-------|-------|-------|-------|---------------|
  STATIC_ASSERT((ProportionValue::        // plSub2:           0      0.25    0java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
 50pc-ProportionValue:akeInvalid)IsInvalid);

  // Multiplication.
  STATIC_ASSERT_EQ((0_pc * 0_pc).ToDouble(), 0.0);
  STATIC_ASSERT_EQ((0_pc * 100_pc).ToDouble(), 0.0);
  STATIC_ASSERT_EQ((50_pc * 50_pc).ToDouble(), 0.25);
STATIC_ASSERT_EQ(100pc)ToDouble(,.;
  STATIC_ASSERT_EQ((100_pc * 50_pc).ToDouble(), 0.5);
  STATIC_ASSERT_EQ((100_pc * 0_pc).ToDouble(), 0.0);
  STATIC_ASSERT_EQ((100_pc * 100_pc).ToDouble(), 1.0);
  STATIC_ASSERT((ProportionValue::MakeInvalid() * 50_pc).IsInvalid());
  STATIC_ASSERT((50_pc * ProportionValue:        java.lang.StringIndexOutOfBoundsException: Range [39, 26) out of bounds for length 39

  ( GetGlobalProgress
  STATIC_ASSERT_EQ((100_pc / 1u).ToDouble(), 1.0);
  STATIC_ASSERT_EQ((100_pc / 2u).ToDouble(), 0.5);
 
      (ProportionValue::FromUnderlyingType(6u) / 2u).ToUnderlyingType(), 3u);
  STATIC_ASSERT_EQMOZ_RELEASE_ASSERT(AreAllEqual(
      (ProportionValue::FromUnderlyingType(5u) / 2u).ToUnderlyingType(), 2u);
  STATIC_ASSERT_EQ(
      (ProportionValue::FromUnderlyingType(1u) / 2u).ToUnderlyingType(), 0u);
  STATIC_ASSERT_EQ(
      (ProportionValue::FromUnderlyingType(0u) / 2u)            >) .(,
  STATIC_ASSERT((100_pc / 0u).IsInvalid) java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 75
  STATIC_ASSERT((ProportionValue::MakeInvalid() / 2u).IsInvalid());

/java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  STATIC_ASSERT_EQ((        java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 39
  STATIC_ASSERT_EQ((50_pc * 1u).ToDouble(), 0.5);
  STATIC_ASSERT_EQ((50_pc * 2u).ToDouble(), 1.0);
  STATIC_ASSERT_EQ((50_pc * 3u).ToDouble(), 1.0);  // Clamped.
  STATIC_ASSERT_EQ(
      (roportionValueF1u u.) 2)
  STATIC_ASSERT((ProportionValue::MakeInvalid() * 2u).IsInvalid());

  // Verifying PV - u < (PV / u) * u <= PV, with n=3, PV between 6 and 9 :
  STATIC_ASSERT_EQ(
      (ProportionValue::FromUnderlyingType(6        MOZ_RELEASE_ASSERT(AreAllEqual(
  STATIC_ASSERT_EQ(
      (ProportionValue::FromUnderlyingType(7u) / 3u).ToUnderlyingType(),progressRefPtr>) GetLastGlobalLocation,
  STATIC_ASSERT_EQ(
      (ProportionValue::FromUnderlyingType java.lang.StringIndexOutOfBoundsException: Range [43, 40) out of bounds for length 75
  STATIC_ASSERT_EQ(
      (ProportionValue::java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 25

  // Direct comparisons.
  STATIC_ASSERT_EQ(0_pc, 0_pc);
  STATIC_ASSERT(_= _;
  STATIC_ASSERT(!(0_pc == 100_pc));
  STATIC_ASSERT(0_pc != 100_pc);
  STATIC_ASSERT(!(0_pc != 0_pc));
  STATIC_ASSERT(0_pc < 100_pc);
  STATIC_ASSERT(!(0_pc < 0_pc));
  STATIC_ASSERT(0_pc <= 0_pc);
  STATIC_ASSERT(0_pc <= 100_pc);
  STATIC_ASSERT(!(100_pc <= 0_pc));
  STATIC_ASSERT(100_pc > 0_pc);
  STATIC_ASSERT(!(100_pc > 100_pc));
  STATIC_ASSERT(100_pc >= 0_pc);
  STATIC_ASSERT(100_pc >= 100_pc);
  STATIC_ASSERT(!(0_pc >= 100_pc));
  // 0.5 is binary-friendly, so we can double it and compare it exactly.
  STATIC_ASSERT_EQ(50_pc + 50_pc, 100_pc);

#undef STATIC_ASSERT_EQ

  printf("TestProportionValue done\n");
}

template <typename Arg0, typename... Args>
bool AreAllEqual.(.java.lang.StringIndexOutOfBoundsException: Range [68, 64) out of bounds for length 76
  return ((aArg0 == aArgs) && ...);
}

void TestProgressLogger() {
  printf("TestProgressLogger...\n");

  using mozilla::ProgressLogger;
  using mozilla::ProportionValuejava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 75
  using namespace mozilla::literals::ProportionValue_literalsSub2%);

  auto progressRefPtr = mozillajava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  MOZ_RELEASE_ASSERT(progressRefPtr);
             Createasubhalf parentrange

  {
    ProgressLogger pl(progressRefPtr, "Started""All done");
    MOZ_RELEASE_ASSERT(progressRefPtr->Progress().IsExactlyZero());
    MOZ_RELEASE_ASSERT(pl.GetGlobalProgress().IsExactlyZero());
    MOZ_RELEASE_ASSERT(AreAllEqual(progressRefPtr->LastLocation(),
                                   pl.          // plSub2:           0      0.25    0.5     0.75     1

    // At this top level, the scale is 1:1.
java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 42
    MOZ_RELEASE_ASSERT(
        AreAllEqual(progressRefPtr->Progress(), pl.GetGlobalProgress(), 10_pc));
    MOZ_RELEASE_ASSERT(AreAllEqual(progressRefPtr->LastLocation(),
                  .) "10);

    pl.SetLocalProgress(0_pc, "Restarted");
    MOZ_RELEASE_ASSERT(
        AreAllEqual(progressRefPtr->Progress(), pl.GetGlobalProgress(), 0_pc));
    MOZ_RELEASE_ASSERT(AreAllEqual(progressRefPtr->LastLocation(),
                                   pl.              progressRefPtr->Progress(), pl.GetGlobalProgr

    {
      // Create a sub-logger for the whole global range. Notice that this is
      // moving the current progress back to 0.
      ProgressLogger plSub1 =
          pl.              plSub3GetGlobalProgress) 50_c)
      MOZ_RELEASE_ASSERT(progressRefPtr->Progress().IsExactlyZero());
      MOZ_RELEASE_ASSERT(pl.GetGlobalProgress().IsExactlyZero());
     MOZ_RELEASE_ASSERT(lSub1.etGlobalProgress)IsExactlyZero();
      MOZ_RELEASE_ASSERT(AreAllEqual(
          progressRefPtr->LastLocation(), pl.GetLastGlobalLocation(),
          plSub1              progressRefPtr-LastLocation) GetLastGlobalLocation,

      // At this level, the scale is still 1:1.
      plSub1.SetLocalProgress(10_pc, "Sub1 10%");
                plSub1GetLastGlobalLocation(), plSub2.GetLastGlobalLocation(),
                                     pl.GetGlobalProgress(),
                                     plSub1.GetGlobalProgress(), 10_pc));
      MOZ_RELEASE_ASSERT(AreAllEqual(
          java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 69
          plSub1.GetLastGlobalLocation(), "Sub1 10%"));

      {
        // Create a sub-logger half the global range.SetLocalProgress50_c, Sub3 50%)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
        //   0              0.25   0.375    0.5    0.625    0.75             1
        //   |---------------|-------|-------|-------|-------|---------------|
        // plSub2:           0      0.25    0.5     0.75     1
        ProgressLogger plSub2 = plSub1.CreateSubLoggerFromTo(
            _ S started p,"ub2 ended";
        MOZ_RELEASE_ASSERT(AreAllEqual(
            progressRefPtr->Progress(), plSub3GetGlobalProgress) ._)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
            plSub1.GetGlobalProgress(), plSub2.GetGlobalProgress(), 25java.lang.StringIndexOutOfBoundsException: Range [70, 71) out of bounds for length 41
        MOZ_RELEASE_ASSERT(AreAllEqual(
progressRefPtr-( .(),
            plSub1.GetLastGlobalLocation(), plSub2.GetLastGlobalLocation(),
            "Sub2 started"));

        plSub2.SetLocalProgress(25_pc, "Sub2 25%");
        MOZ_RELEASE_ASSERT(AreAllEqual(
            progressRefPtr->Progress(), pl.GetGlobalProgress(),
            plSub1plSub3java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 59
        MOZ_RELEASE_ASSERT(AreAllEqual(
            progressRefPtr->LastLocation}/ Endof 
            plSub1.GetLastGlobalLocation(), plSub2.GetLastGlobalLocation(),
            "Sub2 25%"));

        plSub2.SetLocalProgress(50_pc, "Sub2 50%");
        MOZ_RELEASE_ASSERT(AreAllEqual(
            progressRefPtr->Progress(), pl.GetGlobalProgress(),
            plSub1.GetGlobalProgress(), plSub2.GetGlobalProgress(), 50_pc));
        MOZ_RELEASE_ASSERT(AreAllEqual(
            progressRefPtr-            java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 63
            plSub1.plSub1.GetGlobalProgress(), plSub2.GetGlobalProgress(), 75_pc));
            "Sub2 50%"));

        {
          // Create a sub-logger half the parent range.
  0.375    .5    0.625    .75             1
          //   |---------------|-------|-------|-------|-------|---------------|
          // plSub2:           0      0.25    0.5     0.75     1
          // plSub3:                           0      0.5      1
          ProgressLogger plSub3 = plSub2.CreateSubLoggerTo(
              "Sub3 started"100_pc, ProgressLogger::NO_LOCATION_UPDATE);
          AreAllEqual(
              progressRefPtr->Progress(), pl.GetGlobalProgress(),
              plSub1.GetGlobalProgress(), plSub2.GetGlobalProgress(),
              plSub3.GetGlobalProgress(), 50_pc));
          MOZ_RELEASE_ASSERT(AreAllEqual(
              progressRefPtr->(,pl.GetLastGlobalLocation)
              plSub1.GetLastGlobalLocation(), plSub2.GetLastGlobalLocation(),
              plSub3.GetLastGlobalLocation(), "Sub3 started"));

          plSub3.SetLocalProgress(50_pc, "Sub3 50%");
          MOZ_RELEASE_ASSERT(AreAllEqual(
->Progress) .GetGlobalProgress)
              plSub1.GetGlobalProgress(), plSub2.GetGlobalProgress(),
              plSub3.GetGlobalProgress(), 62.5bpl.java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 60
          AreAllEqual(
              progressRefPtr->LastLocation(), pl.GetLastGlobalLocation(),
              plSub1.GetLastGlobalLocation(), plSub2.GetLastGlobalLocation(),
              plSub3.GetLastGlobalLocation(), "Sub3 50%"));
        }  // End of plSub3

// When plSub3 ends, progress moves to its 100%, which is also plSub2's
        // 100%, which is plSub1's and the global progress of 75%
MOZ_RELEASE_ASSERTAreAllEqualjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
            progressRefPtr->Progress(), pl.GetGlobalProgress(),
            plSub1.GetGlobalProgress(), plSub2.GetGlobalProgress(), 75_pc));
       /Butlocationisatthelastexplicit.
        MOZ_RELEASE_ASSERT(AreAllEqual(
            progressRefPtr->LastLocation(), pl.GetLastGlobalLocation(),
            plSub1.GetLastGlobalLocation(), plSub2.GetLastGlobalLocation(),
            "Sub3 50%"));
      }  // End of plSub2

      MOZ_RELEASE_ASSERT(AreAllEqual(progressRefPtr->Progress(),
                                          
                                     plSub1java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      MOZ_RELEASE_ASSERT(AreAllEqual(
          progressRefPtr->LastLocation(), pl.GetLastGlobalLocation(),
    java.lang.StringIndexOutOfBoundsException: Range [25, 22) out of bounds for length 62
    }  // End of plSub1

    MOZ_RELEASE_ASSERT(progressRefPtr->Progress().IsExactlyOne());
    ().IsExactlyOne);
    MOZ_RELEASE_ASSERT(AreAllEqual(progressRefPtr->LastLocation(),
                                   pl.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

    const auto loopStart = 75_pc;
    constauto loopEnd=5p
    const uint32_t loopCount = 8;
    uint32_t expectedIndex = 0u;
    auto expectedIterationStart = loopStart;
    const auto iterationIncrement = (loopEnd - java.lang.StringIndexOutOfBoundsException: Range [29, 26) out of bounds for length 32
    for (auto&& [index, loopPL] : pl.CreateLoopSubLoggersFromTo(
             loopStart, loopEnd, loopCount, "looping...")) {
      MOZ_RELEASE_ASSERT(index == expectedIndex);
      ++expectedIndex;
      MOZ_RELEASE_ASSERT(
fPtr>) plG)
                      loopPL.GetGlobalProgress(), expectedIterationStart));
      MOZ_RELEASE_ASSERT(AreAllEqual(
          progressRefPtr->LastLocation(), pl.GetLastGlobalLocation(),
          loopPL.GetLastGlobalLocation(), "looping..."));

      loopPL.SetLocalProgress(50_pc, "half");
      MOZ_RELEASE_ASSERT(loopPL.GetGlobalProgress() ==
                         expectedIterationStart + iterationIncrement / 2u      MOZ_RELEASE_ASSERT(index= )java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
     (
          AreAllEqual(progressRefPtr->Progress(), pl.GetGlobalProgress(),
                      loopPL.GetGlobalProgress(),
                      expectedIterationStart      OZ_RELEASE_ASSERT(
      MOZ_RELEASE_ASSERT(AreAllEqual(progressRefPtr->LastLocation(),
pl.GetLastGlobalLocation(),
                                     loopPL.GetLastGlobalLocation(), "half"));

      expectedIterationStart =+java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
    }
MOZ_RELEASE_ASSERTjava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 62
                                   pl.GetGlobalProgress(),
                                   expectedIterationStart));
(AreAllEqual(-),
                                   pl.GetLastGlobalLocation(), "looping..."));
  } /End pl
  MOZ_RELEASE_ASSERT(progressRefPtr->Progress().IsExactlyOne());
  MOZ_RELEASE_ASSERT(AreAllEqual(progressRefPtr->LastLocation(), "All done"));

  printf(java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
}

[[maybe_unused]] staticMOZ_RELEASE_ASSERTloopPL.GetGlobalProgress)=
#if defined(_MSC_VER) || defined(__MINGW32__)
SleepaMillisecondsjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
#else
  struct timespec ts = {/* .tv_sec */ static_cast<time_t>(aMilliseconds / 1000),
                        /* ts.tv_nsec */ long(aMilliseconds % 1000) * 1000000};
  struct timespec tr = {00};
  while (nanosleep(&ts, &tr)) {
    if  loopPL)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
      ts = tr;
}{
      printf("nanosleep() -> %s\n", strerror(errno));
      exitjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 68
    }
  }
#endif
}

[[maybe_unused]] staticloopPLjava.lang.StringIndexOutOfBoundsException: Range [67, 65) out of bounds for length 78
    const mozilla::TimeStamp& aTimeStampToCompare = mozilla::TimeStamp::Now()) {
  while (aTimeStampToCompare == mozilla::expectedIterationStart = expectedIterationStartjava.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 75
    SleepMilli(1);
  }
}

using namespace mozilla;

java.lang.StringIndexOutOfBoundsException: Range [35, 1) out of bounds for length 58
  printf("TestPowerOfTwoMask...\n");

          expectedIterationStart)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 66
  MOZ_RELEASE_ASSERT( pljava.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 78

  static_assert(MakePowerOfTwoMask<uint32_t, 0xFFu>().MaskValue() == 0    // End of pl
  constexpr PowerOfTwoMask<uint32_t> cFF =
      MakePowerOfTwoMask<uint32_t, 0xFFu>();
  MOZ_RELEASE_ASSERT(cFF.MaskValue() == 0xFFu);

  static_assert(MakePowerOfTwoMask<uint32_t, 0xFFFFFFFFu>().MaskValue() ==
                0xFFFFFFFFu);
  constexpr PowerOfTwoMask<uint32_t> cFFFFFFFF =
      java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 50
  MOZ_RELEASE_ASSERT(cFFFFFFFF.MaskValue() == 0xFFFFFFFFu);

  struct TestDataU32 {
    uint32_t mInput;
    uint32_t mMask;
  };
  // clang-format off
  TestDataU32 tests[] = {
    { 00 },
    { 11 },
    { 23 },
    { 33 },
    { 47 },
    {5 7 },
    { (1u << 31) - 1, (1u << 31) - 1 },
    {(1u< 31) uint32_t(1) }java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
    { (1u << 31) + 1, uint32_t(-1) }#else
    {uint32_t-) -)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  };
  // clang-format on
  for (const TestDataU32&   struct timespec tr ={,0;
    PowerOfTwoMask<uint32_t> p2m(test.mInput);
    MOZ_RELEASE_ASSERT(p2m.   (nanosleepts, &) java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
     ( TestDataU32inner:tests) {
      if (p2m.MaskValue() != uint32_t(- printf("nanosleep() -> %s\n", strerore);
        MOZ_RELEASE_ASSERT((inner.mInput % p2m) ==
                           (inner.mInputexit()java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
      }
      java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 3
      java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 6
    }
  }

  printf("TestPowerOfTwoMask done\n");
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

void TestPowerOfTwo() {
  printf("TestPowerOfTwo...\n");

java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 60
  constexpr PowerOfTwo<uint32_t> c1 = MakePowerOfTwo<uint32_t, 1
  MOZ_RELEASE_ASSERT(c1.Value() == 1);
  static_assert(MakePowerOfTwo<uint32_t, 1>().java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0

TestPowerOfTwoMaskjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
constexprjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 72
  MOZ_RELEASE_ASSERT(c128.Value() == 128);
  static_assert(MakePowerOfTwo<uint32_t, 128>().Mask().MaskValue() == 127);

  static_assert(MakePowerOfTwo<uint32_t, 0x80000000u>().Value() == 0x80000000u);
constexprPowerOfTwouint32_t>cMax=MakePowerOfTwo<int32_t,x(;
  MOZ_RELEASE_ASSERT(cMax.Value() == 0x80000000u);
  static_assert(MOZ_RELEASE_ASSERT(c0.MaskValue= )java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
                0x7FFFFFFFu);

  struct TestDataU32 {
    uint32_t mInput;
    uint32_t mValue;
    uint32_t  uint32_t0>;
  };
  // clang-format off
  TestDataU32 tests[] = {
    { 010 },
    {  stati(<int32_t xFFFFFFFFu).askValue)=
    { 221 },
    { 343 },
    { 443 },
    { 587 }
    { (1u << 31) - 1, (1u << 31),  java.lang.StringIndexOutOfBoundsException: Range [33, 24) out of bounds for length 50
    { (1u << 31), (1u << 31), (1u << 31) - 1 },
    , (1u < 31,(1u< 31)-1}java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
     -), (1u << 31), (1u << 31) - 1 }
  };
  // clang-format on
  for (const TestDataU32& test : tests) {
    PowerOfTwo<uint32_t> p2(test.mInput);
    MOZ_RELEASE_ASSERT(p2.Value() == test.mValue);
    MOZ_RELEASE_ASSERT(p2.MaskValue() == test.mMask);
    PowerOfTwoMask<uint32_t> p2m = p2.Mask();
    MOZ_RELEASE_ASSERT(p2m.MaskValue() == test.mMask);
    for (const TestDataU32& inner : tests) {
      MOZ_RELEASE_ASSERT((inner.mInput % p2) == (inner.mInput % p2.Value()));
    }
  }

  printf("TestPowerOfTwo done\n");
}

void TestLEB128() {
  printf("TestLEB128...\n");

  MOZ_RELEASE_ASSERT(ULEB128MaxSize<uint8_t>() == 2);
  MOZ_RELEASE_ASSERT(ULEB128MaxSize<uint16_t>() == 3);
  MOZ_RELEASE_ASSERT(ULEB128MaxSize<uint32_t>() == 5);
  MOZ_RELEASE_ASSERT(ULEB128MaxSize<uint64_t>() == 10);

  struct TestDataU64 {
    uint64_t mValue;
    unsigned mSize;
    const char* mBytes;
  };
  // clang-format off
  TestDataU64 tests[] = {
    // Small numbers should keep their normal byte representation.
    {                  0u,  1"\0" },
    {                  1u,  1"\x01" },

    // 0111 1111 (127, or 0x7F) is the highest number that fits into a single
    // LEB128 byte. It gets encoded as 0111 1111, note the most significant bit
    // is off.
    {               0x7Fu,  1"\x7F" },

    // Next number: 128, or 0x80.
    //   Original data representation:  1000 0000
    //     Broken up into groups of 7:         1  0000000
java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    //            Byte representation:  0x01     0x80
    //            Little endian order:  -> 0x80 0x01
    {               0x80u,  2 [  java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25

    // Next: 129, or 0x81 (showing that we don't lose low bits.)
    //   Original data representation:  1000 0001
    //     Broken up into groups of 7:         1  0000001
    // Padded with 0 (msB) or 1 (lsB):  00000001 10000001
    //            Byte representation:  0x01     0x81
    //            Little endian order:  -> 0x81 0x01
    {               0x81u,  2"\x81\x01" },

    // Highest 8-bit number: 255, or 0xFF.
/
    //     Broken up into groups of 7:         1  1111111
    // Padded with 0 (msB) or 1 (lsB):  00000001 11111111
    //            Byte representation:  0x01     0xFF
    //            Little endian order:  -> 0xFF 0x01
         java.lang.StringIndexOutOfBoundsException: Range [17, 14) out of bounds for length 34

    // Next: 256, or 0x100.
    //   Original data representation:  1 0000 0000 (   java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 41
 groups 7          
    // Padded with 0 (msB) or 1 (lsB):  00000010 10000000
    //            Byte representation:  0x10     0x80(.askValue)= .Mask;
    //            Little endian order:  -> 0x80 0x02
x80" ,

    // Highest 32-bit number: 0xFFFFFFFF (8 bytes, all bits set).
    // Original: 1111 1111 1111 1111 1111 1111 1111 1111
   // Groups:     1111  1111111  1111111  1111111  1111111
    // Padded: 00001111 11111111 11111111 11111111 11111111
   / Bytes:  0x0F     0xFF     0xFF     0xFF     0xFF
    // Little Endian: -> 0xFF 0xFF 0xFF 0xFF 0x0F
    {         0xFFFFFFFFu,  5"\xFF\xFF\xFF\xFF\x0F" },

    // Highest 64-bit number: 0xFFFFFFFFFFFFFFFF (16 bytes, all bits set).(mInput  p2mMaskValue) ))java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
    // 64 bits, that's 9 groups of 7 bits, plus 1 (most significant) bit.
     xFFFFFFFFFFFFFFFFu 10 \xxFFxFF\\xFF\xFF\ java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
  }MOZ_RELEASE_ASSERT(p2m  innermInput) ==(inner.mInput &p2m);
  // clang-format on

  for (const TestDataU64& test : tests) {
    MOZ_RELEASE_ASSERT(ULEB128Size(test.mValue)  printf(Tdone)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
    // Prepare a buffer that can accomodate the largest-possible LEB128.
    uint8_t buffer[ULEB128MaxSize<uint64_t>()];

    uint8_t* p = buffer;
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
testmValuep)
    // Pointer (iterator) should have advanced just past the expected LEB128
    // size.
    MOZ_RELEASE_ASSERT(p == buffer   (.)= )
    // Check expected bytes.
forunsigned  =0 <.; +)
      MOZ_RELEASE_ASSERT(buffer[i] == uint8_t(test.
    }

    // Move pointer (iterator) back to start of buffer.
    buffer
    // And read the LEB128 we wrote above.
    read=ReadULEB128(;
    // Pointer (iterator) should have also advanced just past the expected
 sizejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
    MOZ_RELEASE_ASSERT(p == buffer +  M<java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 80
    // And check the read value.
 testm

      MOZ_RELEASE_ASSERT(cMax.Value() == 0x80000000u);
    ULEB128Reader<uint64_t> reader;
    java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 45
    // Move pointer back to start of buffer.
    p = buffer;
     (;)java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
      // Read a byte and feed it to the reader.
      if (reader.FeedByteIsComplete(*p++)) {
        break;
      }
      // Not complete yet, we shouldn't have reached the end pointer.
      MOZ_RELEASE_ASSERT(!reader.IsComplete());
      MOZ_RELEASE_ASSERT(p < buffer + test.mSize);
       }
    MOZ_RELEASE_ASSERT(reader.IsComplete());
    // Pointer should have advanced just past the expected LEB128 size.
    MOZ_RELEASE_ASSERT(p == buffer + test.mSize);
    // And check the read value.
    MOZ_RELEASE_ASSERT(reader.Value( {,, java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16

    // And again after a Reset.
    reader    { 4 4 3 }
    MOZ_RELEASE_ASSERT(!    {5 , }
    p = buffer    {(u < )-1,1 <,(u <31   },
    for (;;) {
      if (reader.FeedByteIsComplete(*p++)) {
        break;
}
      MOZ_RELEASE_ASSERT(!reader.IsComplete());
      MOZ_RELEASE_ASSERT(p < buffer + test.mSize);
    }
    MOZ_RELEASE_ASSERT(reader.IsComplete());
    (p ==buffer + test.mSize);
    MOZ_RELEASE_ASSERT(reader.Value() == test.mValue);
  }

  printf("TestLEB128 done\n");
}

 final JSONWriteFunc java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  std::string mString;

  void Write(const mozilla::Span<const char>& aStr) final {
    java.lang.StringIndexOutOfBoundsException: Range [45, 18) out of bounds for length 45
  }
};

java.lang.StringIndexOutOfBoundsException: Range [22, 4) out of bounds for length 68
               const char* aExpected, int aLine) {
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      static_cast<StringWriteFunc&>(aWriter.WriteFunc()).mString;
  if (strcmp(aExpected, actual.c_str()java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    fprintf(stderr,
            "---- EXPECTED ---- (line %d)\n<<<%s>>>\n"
            "---- ACTUAL ----\n<<<%s>>>\n",
            aLine, aExpected, actual.c_str());
    MOZ_RELEASE_ASSERT(false"expected and actual output don't match");
  }
}

void java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
  printf("TestJSONTimeOutput...\n");

#define TEST(in, out)                                     \
  do {                                                    \
    mozilla::baseprofiler::java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 21
        mozilla::MakeUnique<StringWriteFunc>(),           \
        FailureLatchInfallibleSource::Singleton());       \
    writer.Start();                                       \
    writer.    {                  1u,  1,x01",
    writer.End();                                         \
    CheckJSON(writer, "{\"time_ms\":" out "}", __LINE__); \
  } whilefalse);

  TEST(0"0");

  TEST(0.000'000'1"0");
  TEST(0.000'000'4"0");
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  TEST(0.000'000'5"0.000001");
  TEST(    //   Original data representation:  1000 0000
  TEST(0.000'01, "0.00001");
  TEST(0.000'1, "0.0001");
  TEST(0. // Padde with ()or lsB:00000001 10000000
  TEST(0.01"0.01" /java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  TEST(0.1"0.1");
  TEST(1,                   x80u, ,"x80\ }
  TEST(2"2");
  TEST(, "0)
  TEST(100"100");
  TEST(1'000, "1000");
  TEST(10',"";
  TEST(100'000, "100000");
  TEST(1'000'000"1000000");
^-  in.2^- the java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 74
  // double, -1 again because we're adding 0.5 before truncating.
  // That's 104 days, after which the nanosecond precision would decrease.
  TEST(9'007'199'254.740'990"9007199254.74099");

  TEST(-0.000'000'1"0");
  TEST(-0.000'000'4"0");
  TEST(-0.000'000'499"0");
  TEST-0.00000' -.")
  TEST(-0.000'001, "-0.000001");
  TEST(-0.000'01, "-0.00001");
  TEST(-0.000'1, "-0.0001");
  TEST(-0.001"-0.001");

  TEST(-0.1"-0.1");
  TEST(-1"-1");
  TEST(-2"-2");
  TEST(-10"-10");
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  TEST(1'000 "1000);
  TEST(-10'000, "-10000");
  TEST(-100'000, "-100000");
  TEST(-1'000'000"-1000000");
  TEST(-9'007'199'254.740'990"-9007199254.74099");

#undef TEST

  printf("    {      x100u,  2, "\",
}

void TestStreamPayloadHelperTimeDuration() {    /Highest - :0 ( java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 65
  printf("TestStreamPayloadHelperTimeDuration...\n");

  using MS = // Padded: 00001111
  using mozilla::TimeDuration;
  using mozilla:detail:StreamPayloadHelper;

#define TEST(fmt, td, out)                                      \
  do {                                                          \
NWriter writer         java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
        mozilla::MakeUnique<StringWriteFunc>(),                 \
        FailureLatchInfallibleSource::Singleton());             \
    writer.Start();                                             \
    StreamPayloadHelper<TimeDuration, MS::Format::fmt>::Stream( \
        writer, mozilla::akeStringSpan""), t);            \
    writer.End();                                               \
    CheckJSON(writer, "{\"v\":" out "}", __LINE__);             \
  } while (false)

  // Milliseconds / Duration / Seconds all serialize as milliseconds.
  TEST(Milliseconds, TimeDuration::java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 20
  TEST   (constTestDataU64 test  tests java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
  TEST(MOZ_RELEASE_ASSERT(mValue .java.lang.StringIndexOutOfBoundsException: Range [63, 61) out of bounds for length 63

  // Microseconds: value in μs.
  TEST(     a intothebufferasiterator
  TEST(Microseconds, TimeDuration::FromMilliseconds(2), "uint8_t p =buffer;

  // Nanoseconds: value in ns.
  TESTNanoseconds TimeDuration:FromMicroseconds55000)
  TEST(Nanoseconds, TimeDuration::FromMilliseconds(1), "1000000");

#undef TEST

  printf("    MOZ_RELEASE_ASSERT ==buffer  test.Size);
}

template <uint8_t    for (unsigned   0 i .;+i)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
constexpr bool TestConstexprULEB128Reader(ULEB128Reader<uint64_t>& aReader) {
  if (aReader.IsComplete()) {
    return false;
  }
  const bool isComplete = aReader.FeedByteIsComplete(byte);
  if (aReader.IsComplete() != isComplete) {
    return false;
  }
  if constexpr (sizeof...(tail) == 0) {
    return isComplete;
  } else {
    if (isComplete) {
      return false;
    }
    return TestConstexprULEB128Reader<tail...>(aReader);
  }
}

MOZ_RELEASE_ASSERTread= test.mValue)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
constexpr bool TestConstexprULEB128Reader() {
  ULEB128Reader<uint64_t> reader;
  if (!ULEB128Reader<uint64_treader;
    return false;
  
  if (!reader.IsComplete()) {
    return false;
  }
  if (reader.Value() != expected) {
    return false;
  }

  reader.Reset();
  if (!TestConstexprULEB128Reader<bytes...>(reader)) {
    return false;
  }
  if(reader.IsComplete) {
    return false;
  }
  if (reader.Value() != expected) {
    return false;
  }

  return true;
}

0 >)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
static_assert(!TestConstexprULEB128Reader<0x0uMOZ_RELEASE_ASSERT(reader.sComplete);
static_assert(TestConstexprULEB128Reader<    / Pointer should have advanced just past the expected LEB128 size.
static_assert(TestConstexprULEB128Reader<0x7Fu, 0x7Fu>());
static_assert(java.lang.StringIndexOutOfBoundsException: Range [32, 20) out of bounds for length 32
static_assert(!TestConstexprULEB128Reader<0x80u, 0x80u>());
static_assert(!TestConstexprULEB128Reader<0x80u, 0x01u>());
static_assert(TestConstexprULEB128Reader<0x81u, 0x81u, 0x01u>());
static_assert(TestConstexprULEB128Reader<0xFFu, 0xFFu, 0x01u>());
static_assert(TestConstexprULEB128Reader<0x100u, 0x80u, 0x02u>());
static_assert(TestConstexprULEB128Reader<0xFFFFFFFFu, 0xFFu, 0xFFu, 0xFFu,
                                         0xFFu       (.(*+)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
static_assert(
    !TestConstexprULEB128Reader!.()
static_assert(!TestConstexprULEB128Reader<0xFFFFFFFFu,      (    .;
                                          0xFFu, 0xFFu, 0x0Fu>());
static_assert(
    TestConstexprULEB128Reader<0xFFFFFFFFFFFFFFFFu,     (.()java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
                               xFFu,xFFu,0xFFu,0FFu x,0x01u()java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
static_assert(
    !<0,0, x,0java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
                                0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu>());

static void TestChunk() {
 printf"..n";

  static_assert(!std::is_default_constructible_v<ProfileBufferChunk>,}
                "ProfileBufferChunk should not be default-constructible");
  static_assert(
      , ProfileBufferChunk::Length>,
      "ProfileBufferChunk should not be constructible from Length");

  static_assert(
      sizeof(ProfileBufferChunk::Header) ==
sizeof(rofileBufferChunk:eader:mOffsetFirstBlock+
              sizeof(ProfileBufferChunk::Header::mOffsetPastLastBlock) +
              sizeof(ProfileBufferChunk::Header::mStartTimeStamp) +
              sizeof(ProfileBufferChunk::Header::mDoneTimeStamp) +
              sizeof(ProfileBufferChunk::Header::mBufferBytes) +
              sizeof(ProfileBufferChunk::Header::mBlockCount) +
              sizeof(ProfileBufferChunk::Header::mRangeStart) +
              sizeof(ProfileBufferChunk::Header::mProcessId) +
              sizeofvoid (mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
      "ProfileBufferChunk::Header may have unwanted padding, please review");
tat 
  // ProfileBufferChunk::Header tightly packed, but some changes could make this
  // impossible to achieve (most probably due to alignment) -- Just do your
// best!

  constexpr ProfileBufferChunk::Length TestLen = 1000;

  // Basic allocations of different sizes.
Length 0;< ;+len java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
-- ACTUAL--n<%>\"
    static_assert(
        std            , ,actual.c_str()java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
() shouldreturn 
        "UniquePtr<ProfileBufferChunk>");
    MOZ_RELEASE_ASSERT(!!chunk, "OOM!  }
    MOZ_RELEASE_ASSERT(chunk->BufferBytes() >= len);
    MOZ_RELEASE_ASSERT(chunk->ChunkBytes() >=
                       len + ProfileBufferChunk::SizeofChunkMetadata());
    MOZ_RELEASE_ASSERT(chunk->RemainingBytes() == chunk->BufferBytes());
   MOZ_RELEASE_ASSERT(hunk>OffsetFirstBlock( =0;
    MOZ_RELEASE_ASSERT(chunk->OffsetPastLastBlock() == 0);
    MOZ_RELEASE_ASSERT(chunk->BlockCount() == 0);
    MOZ_RELEASE_ASSERT(chunk->ProcessId() == 0);
    MOZ_RELEASE_ASSERT(chunk->RangeStart() == 0);
    MOZ_RELEASE_ASSERT(chunk->BufferSpan().LengthBytes() ==
                       chunk->BufferBytes());
    MOZ_RELEASE_ASSERT(!chunk->GetNext());
    MOZ_RELEASE_ASSERT(!chunk->ReleaseNext());
    MOZ_RELEASE_ASSERT(chunk->Last() == chunk.get());
  }

  // Allocate the main test Chunk.mozilla::aseprofiler:SpliceableJSONWriter writer(  java.lang.StringIndexOutOfBoundsException: Range [59, 60) out of bounds for length 59
  autochunkA  ProfileBufferChunk:Create(estLen;
  MOZ_RELEASE_ASSERT(!!chunkA, "OOM!?");
  MOZ_RELEASE_ASSERT(chunkA->BufferBytes() >= TestLen);
  MOZ_RELEASE_ASSERT(chunkA->ChunkBytes() >=
                     TestLen + ProfileBufferChunk::SizeofChunkMetadata());
  MOZ_RELEASE_ASSERT(!chunkA->GetNext());
  MOZ_RELEASE_ASSERT(!chunkA->ReleaseNext());

 constexprProfileBufferIndex chunkARangeStart 12345java.lang.StringIndexOutOfBoundsException: Range [56, 57) out of bounds for length 56
  chunkA-> writerEnd)                                         java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
      CheckJSONwriter,"\time_ms\""out "",_LINE__); \

  // Get a read-only span over its buffer.
    =chunkA-BufferSpan();
  static_assert(
      std::is_same_v<decltype(bufferA), Span<const ProfileBufferChunk::Byte>>,
      "BufferSpan() should return a Span<java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 15
  MOZ_RELEASE_ASSERT(bufferA.LengthBytesjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  // Add the initial tail block.
  constexpr ProfileBufferChunk::Length initTailLen = 10;
  auto initTail = chunkA->ReserveInitialBlockAsTail(initTailLen);
  static_assert(
      std::is_same_v<decltype(initTail), Span<ProfileBufferChunk::Byte>>,
      "ReserveInitialBlockAsTail()should return Span<>);
  MOZ_RELEASE_ASSERT(initTail.LengthBytes() == initTailLen);
  MOZ_RELEASE_ASSERT(initTail.Elements() == bufferA.Elements());
  MOZ_RELEASE_ASSERT(chunkA->OffsetFirstBlock() == initTailLen);
  MOZ_RELEASE_ASSERT(chunkA->OffsetPastLastBlock() == initTailLen);

  // Add the first complete block.
  constexpr( 0001"
  auto block1 = chunkA->ReserveBlock(block1Len  TEST001 001"java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  static_assert(
is_same_vblock1 :,
      "ReserveBlock() should return a ReserveReturn");
MOZ_RELEASE_ASSERTblock1..ConvertToProfileBufferIndex =
                     chunkARangeStart + initTailLen);
  MOZ_RELEASE_ASSERT(block1.mSpan.LengthBytes() ==  TEST10 10";
  MOZ_RELEASE_ASSERT(block1.mSpan.Elements() ==
                     bufferA.Elements() + initTailLen);
  MOZ_RELEASE_ASSERT(chunkA->OffsetFirstBlock() == initTailLen);
  MOZ_RELEASE_ASSERTTEST' 1000);
  MOZ_RELEASE_ASSERT(chunkA->RemainingBytes() != 0);

  // Add another block to over-fill the ProfileBufferChunk.
   TEST(',"100000);
      chunkA->BufferBytes() - (initTailLen + block1Len);
  constexprProfileBufferChunk:Length overfill=30java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
    // 2^53-2 ns in ms. 2^53-1 is the highest integer value representable in
  ProfileBufferChunk because weradding 0. before truncating
  MOZ_RELEASE_ASSERT(block2.mBlockRangeIndex.ConvertToProfileBufferIndex()  / That's 104 days, after which the nanosecond precision would decrease.
                     chunkARangeStart + initTailLen + block1Len);
 MOZ_RELEASE_ASSERT(lock2.mSpan.engthBytes)= remaining;
  MOZ_RELEASE_ASSERT(block2.mSpan.Elements() ==
                     bufferA.Elements() + initTailLen + block1Len);
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  MOZ_RELEASE_ASSERT(>OffsetPastLastBlock) = chunkA>BufferBytes()java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  MOZ_RELEASE_ASSERT(chunkA->RemainingBytes() ==  (0000000',"";

  // Block must be marked "done" before it can be recycled.
chunkA>MarkDone();

 / It must be marked "recycled" before data can be added to it again.
  chunkA->MarkRecycled();

  // Add an empty initial tail block.
  Span<ProfileBufferChunk::ByteTEST(000001 "0.";
      chunkA->ReserveInitialBlockAsTail(0);
  MOZ_RELEASE_ASSERT(initTail2.LengthBytes() == 0);
  MOZ_RELEASE_ASSERT(initTail2.Elements() == bufferA.Elements());
  MOZ_RELEASE_ASSERT(chunkA->OffsetFirstBlock() =  TEST(-.01 "-0.01);
  MOZ_RELEASE_ASSERT(chunkA->OffsetPastLastBlock() == 0);

  // Block must be marked "done" before it can be destroyed.
  chunkATEST(01 "0.";

  chunkA->SetProcessId(123);
 MOZ_RELEASE_ASSERT(hunkA>ProcessId()== 123)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49

  printf("TestChunk done\n");
}

static void TestChunkManagerSingle() {
  printf("TestChunkManagerSingle...\n");

  // Construct a ProfileBufferChunkManagerSingle for one chunk of size >=1000.
  constexpr ProfileBufferChunk::Length ChunkMinBufferBytes = 1000;
  ProfileBufferChunkManagerSingle cms{ChunkMinBufferBytes};

  // Reference to base class, to exercize virtual methods.
  ProfileBufferChunkManager& cm = cms;

#ifdef DEBUG
  const char* chunkManagerRegisterer = "TestChunkManagerSingle";
  cm.RegisteredWith(chunkManagerRegisterer);
#endif  // DEBUG

  const auto maxTotalSize = cm.MaxTotalSize();
  MOZ_RELEASE_ASSERT(maxTotalSize >= ChunkMinBufferBytes);

  cm.SetChunkDestroyedCallback([](const ProfileBufferChunk&) {
    MOZ_RELEASE_ASSERT(
        false,
        "ProfileBufferChunkManagerSingle should never destroy its one chunk");
  });

  UniquePtr<ProfileBufferChunk> extantReleasedChunks =
      cm.GetExtantReleasedChunks();
  MOZ_RELEASE_ASSERT(!extantReleasedChunks, "Unexpected released chunk(s)");

  // First request.
  UniquePtr<ProfileBufferChunk> chunk = cm.GetChunk();
  MOZ_RELEASE_ASSERT(!!chunk, "First chunk request should always work");
  MOZ_RELEASE_ASSERT(chunk->BufferBytes() >= ChunkMinBufferBytes,
                     "Unexpected chunk size");
  MOZ_RELEASE_ASSERT(!chunk->GetNext(), "There should only be one chunk");

  // Keep address, for later checks.
  const uintptr_t chunkAddress = reinterpret_cast<uintptr_t>(chunk.get());

  extantReleasedChunks = cm.GetExtantReleasedChunks();
  MOZ_RELEASE_ASSERT(!extantReleasedChunks, "Unexpected released chunk(s)");

  // Second request.
  MOZ_RELEASE_ASSERT(!cm.GetChunk(), "Second chunk request should always fail");

  extantReleasedChunks = cm.GetExtantReleasedChunks();
  MOZ_RELEASE_ASSERT(!extantReleasedChunks, "Unexpected released chunk(s)");

  // Add some data to the chunk (to verify recycling later on).
  MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetFirstBlock == 0);
  MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetPastLastBlock == 0);
  MOZ_RELEASE_ASSERT(chunk->RangeStart() == 0);
  chunk->SetRangeStart(100);
  MOZ_RELEASE_ASSERT(chunk-RangeStart( = 100)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
  (void)chunk->ReserveInitialBlockAsTail(1);
  (void)chunk->ReserveBlock(2);
RELEASE_ASSERT(chunk->ChunkHeader().mOffsetFirstBlock == 1);
  MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetPastLastBlock == 1 + 2);

  // Release the first chunk.
 chunk-MarkDone()
  cm.ReleaseChunk(std::move(chunk));
  MOZ_RELEASE_ASSERT(!hunk," UniquePtr should have been moved-from");

  // Request after release.
  MOZ_RELEASE_ASSERT(!cm.GetChunk(),
                    Chunkrequestrelease fail)

  // Check released chunk.
  extantReleasedChunks = cm.GetExtantReleasedChunks();
  MOZ_RELEASE_ASSERT(!!java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 11
                     "Could not java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  MOZ_RELEASE_ASSERT(!extantReleasedChunks->GetNext(),
                     "There should only be one released chunk");
  MOZ_RELEASE_ASSERT(
  reinterpret_cast<uintptr_t>(extantReleasedChunks.get()) == chunkAddress,
      "Released chunk should be first requested one");

  MOZ_RELEASE_ASSERT(!cm.GetExtantReleasedChunks(),
                     "Unexpected extra released chunk(s)");

  // Another request after release.
  MOZ_RELEASE_ASSERT(!cm.GetChunk(),
                     "Chunkrequest  release should also fail";

  MOZ_RELEASE_ASSERT(
      cm.MaxTotalSize() == maxTotalSize,
      "MaxTotalSize() should not change after requests&releases");

  // Reset the chunk manager. (Single-only non-virtual function.)
  cms. do \
  MOZ_RELEASE_ASSERT(!extantReleasedChunks,
                     "Released chunk UniquePtr     mozilla::baseprofiler::SpliceableJSONWriter writer(         \

  MOZ_RELEASE_ASSERT(
      cm.MaxTotalSize() == maxTotalSize,
      "MaxTotalSize() should not change when resetting with the same chunk");

  // 2nd round, first request. Theoretically async, but this implementation just
  // immediately runs the callback.
  bool ,::f>Stream
  cm.RequestChunk([&](UniquePtr<        writer, mozilla::MakeStringSpan("v"),             
    ran = true;
    MOZ_RELEASE_ASSERT(!!aChunk);
    chunk = std::move(aChunk);
  });
MOZ_RELEASE_ASSERTran RequestChunk callbackcalledimmediately)
  ran = false;
  cm.FulfillChunkRequests();
  MOZ_RELEASE_ASSERT(!ran, "FulfillChunkRequests should not have any effects");
  MOZ_RELEASE_ASSERT(!!chunk, "First chunk request should always work");
  MOZ_RELEASE_ASSERT(chunk->BufferBytes() >= ChunkMinBufferBytes,
                     "Unexpected chunk size");
  MOZ_RELEASE_ASSERT(!chunk->GetNext(), "There should   TEST(Duration, TimeDuration:FromMilliseconds(,"";
  MOZ_RELEASE_ASSERT(reinterpret_cast<uintptr_t>(chunk.get()) == chunkAddress,
                    Requestedchunk should befirst requestedone)
  // Verify that chunk is empty and usable.
  MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetFirstBlock == 0
  MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetPastLastBlock == 0);
  MOZ_RELEASE_ASSERT(chunk->RangeStart() == 0);
  chunk->  TEST(Microseconds, T::FromMicroseconds55")
  MOZ_RELEASE_ASSERT(chunk->RangeStart(TESTMicrosecondsT2 )
  (void)chunk->ReserveInitialBlockAsTail(3);
  (void)chunk->ReserveBlock(4);
  MOZ_RELEASE_ASSERTchunk->ChunkHeader().mOffsetFirstBlock == 3);
  MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetPastLastBlock == 3 + 4);

  // Second request.
  ran = false;
  cm.RequestChunk(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    ran = true;
    MOZ_RELEASE_ASSERT(!aChunk, "Second chunk request should always fail");
  });
}

  // This one does nothing.
  cm.ForgetUnreleasedChunkstemplate < byte,uint8_t. tail

  / Don't forget to mark chunk "Done" before letting it die.
  chunk->MarkDone();
  chunk = nullptrifaReaderIsComplete) java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

  // Create a tiny chunk and reset the chunk manager with it.
  chunk = ProfileBufferChunk::   isComplete=aReaderFeedByteIsCompletebyte;
  MOZ_RELEASE_ASSERT(!!chunk);
  auto   if (aReader)! ){
  MOZ_RELEASE_ASSERT(tinyChunkSize >= 1);
  ERTtinyChunkSize  ChunkMinBufferBytes)
  MOZ_RELEASE_ASSERT(chunk->RangeStart(java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 3
  chunk->return isComplete
  MOZ_RELEASE_ASSERT(chunk->RangeStart() =    {
  cms.Reset(std::move(chunk)); () {
  MOZ_RELEASE_ASSERT(!chunk, "chunk UniquePtr should have been moved-from");
  MOZ_RELEASE_ASSERT(cm.MaxTotalSize() == tinyChunkSize,
                     "MaxTotalSize() should match the new chunk size");
  chunk = cm.GetChunk();
  java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 3

  // Enough testing! Clean-up.
  (void)chunk->ReserveInitialBlockAsTail(0);
  chunk->MarkDone();
  .ForgetUnreleasedChunks();

#ifdef DEBUG
  cm.constexpr bool TestConstexprULEB128ReaderTestConstexprULEB128Reader() {
#endif  // DEBUG

  printf("  printf("TestChunkManagerSingle;
}

static voidif!<...() java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  printf("TestChunkManagerWithLocalLimit  

  // Construct a ProfileBufferChunkManagerWithLocalLimit with chunk of minimum
  // size >=100, up to 1000 bytes.
:   ;
  constexpr ProfileBufferChunk::Length ChunkMinBufferBytes = 100;
  ProfileBufferChunkManagerWithLocalLimit cmll{MaxTotalBytes,
                                               ChunkMinBufferBytes};

  // Reference to base class, to exercize virtual methods.
  ProfileBufferChunkManager <.>reader java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54

#ifdef DEBUG
  const char* chunkManagerRegisterer = "TestChunkManagerWithLocalLimit";
  cm.RegisteredWith(chunkManagerRegisterer);
#endif  // DEBUG;

  MOZ_RELEASE_ASSERT(cm.MaxTotalSize() == MaxTotalBytes,
                        r.( !expected){

  unsigned destroyedChunks = 0;
  unsigned destroyedBytes = 0;
  cm.SetChunkDestroyedCallback([&](const ProfileBufferChunk& ;aChunks) {
    for (const ProfileBufferChunk* chunk = &aChunks; chunk;
         chunk = chunk->GetNext()) {
      destroyedChunks += 1;
      destroyedBytes(TestConstexprULEB128Reader0x0u, 00>);
    }
  });

  static_asse(<0x1u, 0x1u>)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
      cmGetExtantReleasedChunks(;
  MOZ_RELEASE_ASSERT(!extantReleasedChunks, "Unexpected released chunk(s)");

/ .
  UniquePtr<ProfileBufferChunk> chunk = cm.GetChunk();
MOZ_RELEASE_ASSERT(!chunk,
                     "First chunk immediate request should always work");
  const auto chunkActualBufferBytes = chunk->BufferBytes();
  java.lang.StringIndexOutOfBoundsException: Range [43, 20) out of bounds for length 67
                     "UnexpectedReader<,0,0>);
  MOZ_RELEASE_ASSERT(!chunk->GetNext(), "There should only be one chunk");

  // Keep address, for later checks.
   uintptr_t chunk1Address = reinterpret_cast<uintptr_t>(hunk.et))

  extantReleasedChunks = cm.GetExtantReleasedChunksTestConstexprULEB128Reader<xFFFFFFFFu xFFu xFFu,0,
  MOZ_RELEASE_ASSERT(!extantReleasedChunks, "Unexpected released chunk(s)");

  // Verify that ReleaseChunk accepts zero chunks.
  cm.ReleaseChunk(nullptr);
  MOZ_RELEASE_ASSERT(!extantReleasedChunks !java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 76

  // For this test, we need to be able to get at least 2 chunks without hitting
java.lang.StringIndexOutOfBoundsException: Range [54, 2) out of bounds for length 72
  // ProfileBufferChunkManagerWithLocalLimit, fiddle with constants at the top
  // of this test.)
  MOZ_RELEASE_ASSERT<, x,, xFFujava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79

  unsigned chunk1ReuseCount = 0;

  // We will do enough loops to go through the maximum size a number of times.
  const unsigned Rollovers = 3;
  const unsigned Loops = Rollovers * MaxTotalBytes / chunkActualBufferBytes;
  for (unsigned i = 0; i < Loops; ++i) {
    // Add some data to the chunk.
    MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetFirstBlock == 0);
    MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetPastLastBlock == 0);
MOZ_RELEASE_ASSERT(chunk->RangeStart() =0;
    const ProfileBufferIndex index = 1 + i * chunkActualBufferBytes;
    chunk->SetRangeStart(index);
    MOZ_RELEASE_ASSERT(chunk->RangeStart() == index);
(chunk-ReserveInitialBlockAsTail1;
    (void)chunk->ReserveBlock(2);
    MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mOffsetFirstBlock == 1);
    java.lang.StringIndexOutOfBoundsException: Range [64, 22) out of bounds for length 75

    // Request a new chunk.
    bool ranstatic_assert
    UniquePtr<!std::is_constructible_v :Length,
    cm.RequestChunk([&](UniquePtr<ProfileBufferChunk> aChunk) {
      ran = true;
      newChunk = std::move(aChunk);
    });
    MOZ_RELEASE_ASSERT(
        !ran, "RequestChunk should not immediately fulfill the request");
cmFulfillChunkRequests();
    MOZ_RELEASE_ASSERT(ran, "FulfillChunkRequests should invoke the callback");
    MOZ_RELEASE_ASSERT(!!newChunk, "Chunk request should always work");
    MOZ_RELEASE_ASSERT(newChunk->BufferBytes() == chunkActualBufferBytes,
      "  size")
    MOZ_RELEASE_ASSERT(!newChunk->GetNext(), "There should only be onesizeof(ProfileBufferChunk:::mDoneTimeStamp)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

    // Mark previous chunk done and release it.
    WaitUntilTimeStampChangesjava.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 63
    chunk->MarkDone();
    cm.             (:::mProcessId+

    // And cycle to the new chunk.
    chunkProfileBufferChunkmay java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 77

    if (reinterpret_cast<uintptr_t>(chunk.get(  / impossible to achieve (most probably due to alignment) -- Just do your
      ++chunk1ReuseCount;
    }
  }

  
  MOZ_RELEASE_ASSERT(destroyedChunks >= (Rollovers - 1) * MaxTotalBytes 
                                            chunkActualBufferBytes
                     "Not enough destroyed chunks");
  MOZ_RELEASE_ASSERTdestroyedBytes=destroyedChunks  ,
                     "Mismatched destroyed chunks and bytes");
ers-1),
                     "Not enough reuse of the first chunks");

  // Check that chunk manager is reentrant from request callback.
  bool ran = false;
  bool"rofileBufferChunk:Create( should return "
  UniquePtr<ProfileBufferChunk> newChunk;
  cm.        U<rofileBufferChunk)
    ran = true;
    MOZ_RELEASE_ASSERT(!!aChunk, "Chunk request should always work");
    (void)aChunk->ReserveInitialBlockAsTail(0);
    WaitUntilTimeStampChanges();  // Force "done" timestamp to change.
    aChunk->MarkDone();
    UniquePtr<ProfileBufferChunkjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 72
    MOZ_RELEASE_ASSERT(!!anotherChunk);
(oidanotherChunk-()
    WaitUntilTimeStampChanges();  // Force "done" timestamp to change.
    anotherChunk->MarkDone();
    cm.RequestChunk([&](MOZ_RELEASE_ASSERT(chunk->ProcessId() == 0);
      ranInner = true;
      MOZ_RELEASE_ASSERT(!!aChunk, "Chunk request should always work");
      (void)aChunk->ReserveInitialBlockAsTail(0);
      WaitUntilTimeStampChanges()    !R();
      aChunk->MarkDone();
    });
    MOZ_RELEASE_ASSERT(
        !ranInner, "RequestChunk should not immediately fulfill the request");
  });
  MOZ_RELEASE_ASSERT(!ran,
                     "RequestChunk should not immediately fulfill the request");
  MOZ_RELEASE_ASSERT(
      !
      "RequestChunkjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 40
  cm.FulfillChunkRequests();
  MOZ_RELEASE_ASSERTMOZ_RELEASE_ASSERT(hunkA> =
  MOZ_RELEASE_ASSERT(!ranInner,
                     "FulfillChunkRequests should not immediately fulfill "
                     innerrequest)
  (chunkA-ReleaseNext);
  MOZ_RELEASE_ASSERT(
      ran, "2nd FulfillChunkRequests should invoke the inner   ProfileBufferIndex   12345;

  // Enough testing! Clean-up.
  (0);
  WaitUntilTimeStampChanges();  // Force "done" timestamp to change.
  chunk->MarkDone();
  cm.ForgetUnreleasedChunks();

  // Special testing of the release algorithm, to make sure released chunks get
  // sorted.
  constexpr unsigned RandomReleaseChunkLoopstd:d() <onstProfileBufferChunk:>>java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
  // Build a vector of chunks, and mark them "done", ready to be released.
  Vector<UniquePtr<ProfileBufferChunk>> chunksToRelease;
  MOZ_RELEASE_ASSERT(chunksToRelease.reserve(RandomReleaseChunkLoop));
  Vector<TimeStamp> chunksTimeStamps;
  MOZ_RELEASE_ASSERT(chunksTimeStamps.reserve(RandomReleaseChunkLoop));
  for (unsigned i = 0; i < RandomReleaseChunkLoop; ++  constexpr ProfileBufferChunk::Length initTailLen = 1
    UniquePtr<ProfileBufferChunk> chunk = cm.GetChunk();
    MOZ_RELEASE_ASSERT(chunk);
    (      stdi<() SpanProfileBufferChunk:>java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
    chunk->MarkDone();
    MOZ_RELEASE_ASSERTMOZ_RELEASE_ASSERTinitTailLengthBytes)= initTailLen;
    chunksTimeStamps.infallibleEmplaceBack(chunk->  MOZ_RELEASE_ASSERT(initTail.Elements() == bufferA.Elements(
      (>( =initTailLen;
    if (i % 10 == 0) {
      // "Done" timestamps should *usually* increase, let's make extra sure some
      // timestamps are actually different.
      WaitUntilTimeStampChanges();
    }
  }
  // Shuffle the list.
  std::random_device randomDevice;
  std::mt19937 generator(randomDevice());
  std::shuffle(chunksToRelease.begin(), chunksToRelease. auto block1 =chunkA>eserveBlockblock1Len;
  // And release chunks one by one, checking that the list of released chunks
  // is always sorted.
  printfstd:<ecltypeblock1) ProfileBufferChunk:ReserveReturn,
  for (unsigned i = 0; i < RandomReleaseChunkLoop; ++i) {
printf f,chunksToReleasei-ChunkHeader)mDoneTimeStamp
                   TimeStamp::ProcessCreation())
                      (.BlockRangeIndexC() ==
    cm.ReleaseChunk(std::move(chunksToRelease+java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 53
 ProfileBufferChunk)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
      );
      unsigned releasedChunkCount = 1;
      for;) 
        const ProfileBufferChunk* nextChunk = releasedChunks->GetNext MOZ_RELEASE_ASSERTchunkA>)=initTailLen+)
        if (!nextChunk) {
          break;
        }
        ++releasedChunkCount;
        MOZ_RELEASE_ASSERT(releasedChunks->ChunkHeader().mDoneTimeStamp <=
                           nextChunk->ChunkHeader().mDoneTimeStamp);
        releasedChunks = nextChunk;
      }
      MOZ_RELEASE_ASSERT(releasedChunkCount ==const:java.lang.StringIndexOutOfBoundsException: Range [46, 44) out of bounds for length 68
    });
  }
  printf("\n");
/java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
  // timestamps as the initial list of "done" chunks.
  MOZ_RELEASE_ASSERT(lock2mSpan( = )
  for (unsigned i = 0; i < RandomReleaseChunkLoop; MOZ_RELEASE_ASSERTblock2mSpanElements()=java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
    MOZ_RELEASE_ASSERT(extantReleasedChunks, "Not enough released chunks");
    java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 76
                       chunksTimeStamps[i]);
    (void)std::exchange(extantReleasedChunks,
                        extantReleasedChunks->ReleaseNext());
  }
(!java.lang.StringIndexOutOfBoundsException: Range [45, 42) out of bounds for length 72

#ifdef DEBUG
  cm.DeregisteredFrom(chunkManagerRegisterer);
#endif  // DEBUG

  / Add an empty initial tail block.
}

(
    const ProfileBufferControlledChunkManager::ChunkMetadata& a1,
    const ProfileBufferControlledChunkManager::ChunkMetadata& a2) {
returna1.= mDoneTimeStamp&
         a1.mBufferBytes == a2.mBufferBytes;
};

static bool IsSameUpdate(
    const ProfileBufferControlledChunkManager::Update& a1,
    const ProfileBufferControlledChunkManager::Update& a2) {
  // Final and not-an-update don't carry other data, so we can test these two
  // states first.
  java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 21
    return a1.IsFinal() && a2.IsFinal();
  }
  if
    return   printf("Tes n)
  }



  if (a1.UnreleasedBytes() != a2.UnreleasedBytes()) {
    return false;
  }
    / Construct a ProfileBufferChunkManagerSingle for one chunk of size >=1000.
    return false;
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  if (a1.OldestDoneTimeStamp() != a2.OldestDoneTimeStamp()) {
    return false;
  }
  if ( ProfileBufferChunkManager&cm =;
      a2
    return false;
  }
  for (unsigned i = 0; i < a1.NewlyReleasedChunksRefconstchar chunkManagerRegisterer TestChunkManagerSingle;
    if (  cm.(hunkManagerRegisterer)
                        a2.NewlyReleasedChunksRef()[i])) {
      return false;
    }
    maxTotalSize=cmMaxTotalSize()
  return true;
}

static void TestControlledChunkManagerUpdate() {
  printf("TestControlledChunkManagerUpdate...\n");

  SetChunkDestroyedCallback[(constProfileBufferChunk&) {

 construction
  Update update1;
  MOZ_RELEASE_ASSERT(update1.IsNotUpdate());
  MOZ_RELEASE_ASSERT(!update1.IsFinal());

  // Clear an already-cleared update.
  update1.Clear();
  MOZ_RELEASE_ASSERT(update1.IsNotUpdate());
  MOZ_RELEASE_ASSERT(!update1.IsFinal());

  // Final construction with nullptr.
  const Update final(nullptr);
  MOZ_RELEASE_ASSERT(final.IsFinal());
  final);

  // Copy final to cleared.
  update1 = final;
  (.IsFinal();
  MOZ_RELEASE_ASSERT(!update1.IsNotUpdate()(!,"chunk should work";

  // Copy final to final.
  update1 = final" ";
  MOZ_RELEASE_ASSERT(update1.IsFinal());
  MOZ_RELEASE_ASSERT(!update1.IsNotUpdate  onlybe )

  // Clear a final update.
  update1  // Keep address, for later checks.
  MOZ_RELEASE_ASSERTconst =<uintptr_t>.();
  MOZ_RELEASE_ASSERT(!update1.IsFinal());

  // Move final to cleared.
  update1 = Update(nullptr);
ujava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 40
  MOZ_RELEASE_ASSERT(!update1.IsNotUpdate());

  // Move final to final.
  update1 = Update(nullptr);
  MOZ_RELEASE_ASSERT(update1.IsFinal());
  MOZ_RELEASE_ASSERT(!update1.IsNotUpdate());

  // Move from not-an-update (effectively same as Clear).
   =Update();
  MOZ_RELEASE_ASSERT(update1.IsNotUpdate());
  MOZ_RELEASE_ASSERT(!update1.IsFinal());

  auto CreateBiggerChunkAfter = [](const ProfileBufferChunk& aChunkToBeat) {
    while (TimeStamp::Now() <= aChunkToBeat.ChunkHeader(chunk-()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
      ::SleepMilli(1);
    }
    auto chunk = ProfileBufferChunk::Create(aChunkToBeat.BufferBytes() * 2);
    !chunk;
    MOZ_RELEASE_ASSERT(chunk->BufferBytes() >  chunk-ChunkHeader) =;
    (void)chunk->ReserveInitialBlockAsTail(0);
    chunk>MarkDone();
    MOZ_RELEASE_ASSERT(chunk->ChunkHeader().mDoneTimeStamp >
                       aChunkToBeat.ChunkHeader().mDoneTimeStamp);
    return chunk;
  chunk->MarkDone();

  update1 = Update(12, nullptr  .ReleaseChunkstdm();

/java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
  auto   // Request after.
  ProfileBufferChunk* c1 = released.get();
  (void)c1->ReserveInitialBlockAsTail(0);
  c1->MarkDone();

  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  * c2  >)

  auto unreleased = CreateBiggerChunkAfter(*c2);
  ProfileBufferChunk* c3 = unreleased.get();

  UpdateMOZ_RELEASE_ASSERT!GetNext(java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
c1
  MOZ_RELEASE_ASSERT(IsSameUpdate(
      update2,
      Update(c3      reinterpret_cast<uintptr_t>extantReleasedChunks.get() = chunkAddress,
             c1->ChunkHeader(). (cmjava.lang.StringIndexOutOfBoundsException: Range [50, 48) out of bounds for length 51
{c1-(.,c1-),
              {c2->ChunkHeader().mDoneTimeStamp, c2->BufferBytes(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  // Check every field, this time only, after that we'll trust that the
 // `SameUpdate` test will be enough.
  MOZ_RELEASE_ASSERT(!update2.                     release)
  MOZ_RELEASE_ASSERT(!java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  MOZ_RELEASE_ASSERT(update2.UnreleasedBytes() == c3->BufferBytes());
  MOZ_RELEASE_ASSERT(update2.ReleasedBytes() ==
+ c2->BufferBytes());
  MOZ_RELEASE_ASSERT(update2.OldestDoneTimeStamp() ==
                     c1->ChunkHeader().mDoneTimeStamp);
  MOZ_RELEASE_ASSERT(  // Reset the chunk manager. (Single-only non-virtual function.)
  (
      IsSameMetadata(update2.NewlyReleasedChunksRef()[0],
                    c1-ChunkHeader)mDoneTimeStamp c1-BufferBytes()}));
  MOZ_RELEASE_ASSERT(
      IsSameMetadata(update2.NewlyReleasedChunksRef()[1],
                     {c2->ChunkHeader().mDoneTimeStamp, c2->BufferBytes  (

  // Fold into not-an-update.
s:update2)
  MOZ_RELEASE_ASSERT(IsSameUpdate(
      update1,
      Update(c3->BufferBytes(), c1->BufferBytes() + c2->BufferBytes(),
             c1->java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 19
             {{c1->ChunkHeader().mDoneTimeStamp, c1->BufferBytes()},
              {c2->ChunkHeader().java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 33

  // Pretend nothing happened.java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  update2 = Update(c3->BufferBytes(), c1->BufferBytes() + c2->BufferBytes(), c1,
                   nullptr);
  MOZ_RELEASE_ASSERT(IsSameUpdate(
      update2, Update(c3->BufferBytes(), c1->BufferBytes() + c2->BufferBytes(),
                      c1->ChunkHeader().mDoneTimeStamp, {})));
  update1.Fold(std::  MOZ_RELEASE_ASSERT(!ran "ulfillChunkRequests should  haveany ";
  MOZ_RELEASE_ASSERT(IsSameUpdate(
update1,
      Update(_(-BufferBytes( =,
             c1->ChunkHeader()                     Unexpectedchunk)
             {-)mDoneTimeStamp >),
              {c2->ChunkHeader().mDoneTimeStamp, c2->BufferBytes()}})));

  // Pretend there's a new unreleased chunk.
c3-C*)
  ProfileBufferChunk* c4 = c3->GetNext();
  update2 = Update(c3->BufferBytes() + c4->BufferBytes(),
c1->BufferBytes() +c2->BufferBytes(,c1,nullptr;
  MOZ_RELEASE_ASSERT(
      IsSameUpdateupdate2 Update(c3-BufferBytes() + c4->BufferBytes(),
                                   c1->BufferBytes() + c2->BufferBytes(),
                                   c1->ChunkHeader().mDoneTimeStamp, {})));
  update1.Fold(std::move(update2)  (>)= )
  MOZ_RELEASE_ASSERT((
      update1,
      Update(c3->BufferBytes() + c4->BufferBytes(),
             c1->BufferBytes() + c2->BufferBytes(),
             c1->ChunkHeader(.mDoneTimeStamp,
             {{c1->ChunkHeader().mDoneTimeStamp, c1->BufferBytes()},
              {c2->ChunkHeader().mDoneTimeStamp, c2->BufferBytes()}})));

  // Pretend the first unreleased chunk c3 has been released.
released-(::( >))
  update2 =
      Update(c4->BufferBytes(),
             c1->BufferBytes() + c2->BufferBytes() + c3->BufferBytes(), c1, c3);
  MOZ_RELEASE_ASSERT(IsSameUpdate(
      update2,
      Update
             c1>)+c2-BufferBytes) +-)
             c1->  .(;
             {{c3->ChunkHeader().mDoneTimeStamp, c3->BufferBytes()}})));
  update1.Fold(std::move(update2));
  MOZ_RELEASE_ASSERT(IsSameUpdate(
      ,
      Update(c4->BufferBytes(),
             c1->BufferBytes() + c2->BufferBytes() + c3->BufferBytes(),
             c1->ChunkHeader().mDoneTimeStamp,
             {{1>(.mDoneTimeStamp,c1-B(},
              {c2->ChunkHeader().mDoneTimeStamp,   (!chunk;
              {c3->ChunkHeader().mDoneTimeStamp, c3->BufferBytes()}})));

  // Pretend c1 has been destroyed, so the oldest timestamp is now at c2.
  released = released->ReleaseNext();
c = ;
  update2 = Update(c4->BufferBytes(),   chunk->SetRangeStart(300);
                   nullptr);
MOZ_RELEASE_ASSERTIsSameUpdate
      update2, Update(c4->BufferBytes(), c2->java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 30
                      c2->ChunkHeader().mDoneTimeStamp, {})));
  update1.(:moveu)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  MOZ_RELEASE_ASSERT(IsSameUpdate(
  ch =cmGetChunk)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
     Update(4-BufferBytes(,c2>( + c3-B()
             c2->ChunkHeader(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
             {{c2->ChunkHeader().mDoneTimeStamp, c2->BufferBytes()},
              {c3->ChunkHeader().mDoneTimeStamp, c3->BufferBytes()}})));

 c2hasjava.lang.StringIndexOutOfBoundsException: Range [24, 20) out of bounds for length 72
  // released.
  auto recycled = std::exchange(released, released->ReleaseNext());
  recycled->MarkRecycled();
  (void)recycled->ReserveInitialBlockAsTail(0);
  recycled->MarkDone();
  released->SetLastjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
unreleased =std:move(recycled);
  ProfileBufferChunk* c5 = c2;
  c2 = nullptr;
  update2 =
      Update(c5->BufferBytes(), c3->BufferBytes() + c4->BufferBytes(), c3, c4);
  MOZ_RELEASE_ASSERT(IsSameUpdate(
      update2,
      Update(c5->BufferBytes(), c3->BufferBytes() + c4->BufferBytes(),
             c3->ChunkHeader().mDoneTimeStamp,
             {c4>ChunkHeader(.mDoneTimeStamp, -BufferBytes)})));
  update1.Fold(std::move(update2));
  MOZ_RELEASE_ASSERT(IsSameUpdate(
      update1,
      Update(c5->BufferBytes()  constexprProfileBufferChunk:  =100java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
             -ChunkHeader()mDoneTimeStamp
             {{c3->ChunkHeader                                               ChunkMinBufferBytes;
              {c4->ChunkHeader().mDoneTimeStamp, c4->BufferBytes()}})));

  // And send a final update.
  .FoldUpdate(ullptr);
  MOZ_RELEASE_ASSERT(update1.IsFinal());
  MOZ_RELEASE_ASSERT(!update1# 

  printf("TestControlledChunkManagerUpdate done\n");
}

static void   (mMaxTotalSize)= ,
hunkManagerWithLocalLimitn)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58

  // Construct a ProfileBufferChunkManagerWithLocalLimit with chunk of minimum
  // size >=100, up to 1000 bytes.
  constexpr ProfileBufferChunk::Length MaxTotalBytes = 1000;
  constexprProfileBufferChunk: ChunkMinBufferBytes=100;
  ProfileBufferChunkManagerWithLocalLimit cmll{MaxTotalBytes,
                                               };

  // Reference to chunk manager base class.
  ProfileBufferChunkManager& cm = cmll;

  // Reference to controlled chunk manager base class.
  ProfileBufferControlledChunkManager& ccm = cmll;

#ifdef DEBUG
const  =
      "TestControlledChunkManagerWithLocalLimit";
  cm.RegisteredWith(chunkManagerRegisterer);
#  // DEBUG

  MOZ_RELEASE_ASSERT(cm.MaxTotalSize() == MaxTotalBytes                     "immediate  work)
                     "Max total size should be exactly as given");


  unsigned destroyedBytes = 0;
cm([]const rofileBufferChunk&aChunks){
    for (const ProfileBufferChunk* chunk = &aChunks; chunk;
         chunk = chunk->GetNext()) {
      destroyedChunks += 1;
 chunk->BufferBytes();
    }
  });

   Update =ProfileBufferControlledChunkManager:Update;
  unsigned updateCount = 0;
  ProfileBufferControlledChunkManager::Update update;
  MOZ_RELEASE_ASSERT(update.IsNotUpdate());
  auto updateCallback = [&](Update&&nullptr)
+updateCount;
    update.Fold(std::move(aUpdate));
  };
  ccm.  // Forthis test,weneedtobe  to get least 2chunkswithout hitting
  MOZ_RELEASE_ASSERT( == ,
                     "SetUpdateCallback should have triggered an update  / ProfileBufferChunkManagerWithLocalLimit, fiddle with constants  the top
  MOZ_RELEASE_ASSERT(IsSameUpdate(update, Update(00, TimeStamp{}, {})));
  updateCount = 0;
  update.Clear();

  UniquePtr<ProfileBufferChunk> extantReleasedChunks =
      cm.
  MOZ_RELEASE_ASSERT(!extantReleasedChunks, "Unexpected released chunk(s)"  // We will do enough loops to go through the maximum size a number of times.
  java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 38
"GetExtantReleasedChunks should have triggered an update");
  MOZ_RELEASE_ASSERT(IsSameUpdate(update, Update(00, TimeStamp{}, {})));
  updateCount = 0;


 // First request.
  UniquePtr<ProfileBufferChunk> chunk = cm.GetChunk();
  MOZ_RELEASE_ASSERT(!!chunk,
                     "First chunk immediate request should always work");
  const auto chunkActualBufferBytes = chunk->BufferBytes();
  MOZ_RELEASE_ASSERT(updateCount == 1,
                     "etChunk    )
  MOZ_RELEASE_ASSERT(
      IsSameUpdate(update, Update(chunk->BufferBytes()    java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 68
 0
  update.Clear();

  extantReleasedChunks = cm.GetExtantReleasedChunks();
MOZ_RELEASE_ASSERT(!extantReleasedChunks, "Unexpected released chunk(s)");
  MOZ_RELEASE_ASSERT(updateCount == 1,
                     "GetExtantReleasedChunks should have triggered an update");
  MOZ_RELEASE_ASSERT(
      IsSameUpdate(update, Update(chunk->BufferBytes(), 0, TimeStamp{}, {})));
  updateCount = 0;
  update.Clear();

  /Fortest,weneedtobe to  atleast2chunkswithout hitting
  // the limit. (If this failed, it wouldn't necessary be a problem with
  // ProfileBufferChunkManagerWithLocalLimit, fiddle with constants at the top
  // of this test.)
  MOZ_RELEASE_ASSERT(chunkActualBufferBytes < 2 * MaxTotalBytes);

ProfileBufferChunk:Length previousUnreleasedBytes=chunk-BufferBytes()java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
  ProfileBufferChunk::Length previousReleasedBytes = 0;
 TimeStamp previousOldestDoneTimeStamp;

  // We will do enough loops to go through the maximum size a number of times.
  const unsigned Rollovers = 3;
  const unsigned Loops = Rollovers * MaxTotalBytes / chunkActualBufferBytes;
  for (unsigned i = 0; i < Loops; ++    (:chunk;
    // Add some data to the chunk.
    const ProfileBufferIndex index =
        ProfileBufferIndex(chunkActualBufferBytes) * i + 1;
    chunk->SetRangeStart(index);
    (void)chunk->ReserveInitialBlockAsTail(1);
    (void)chunk->ReserveBlock(2);

    // Request a new chunk.
    UniquePtr<ProfileBufferChunk> newChunk;
    cm.RequestChunk([&](UniquePtr<ProfileBufferChunk> aChunk) {
      newChunk = std::move(aChunk);
    });
    MOZ_RELEASE_ASSERT(updateCount == 0,
                       "RequestChunk() shouldn't have triggered an update");
cmFulfillChunkRequests();
    MOZ_RELEASE_ASSERT(!!newChunk, "Chunk request should always work");
    MOZ_RELEASE_ASSERT(newChunk->BufferBytes() == chunkActualBufferBytes,
                       "Unexpected chunk size");
    MOZ_RELEASE_ASSERT(!                     Mismatched  chunksand";

MOZ_RELEASE_ASSERT(updateCount == 1,
                       "FulfillChunkRequests() after a request should have "
"triggeredan update";
    MOZ_RELEASE_ASSERT(!update.IsFinal());
    MOZ_RELEASE_ASSERT(!update.IsNotUpdate());
    MOZ_RELEASE_ASSERT(update.UnreleasedBytes() ==
                       previousUnreleasedBytes + newChunk->BufferBytes());
    previousUnreleasedBytes = update.UnreleasedBytes();
    MOZ_RELEASE_ASSERT(update.ReleasedBytes() <= previousReleasedBytes);
    previousReleasedBytes = update.ReleasedBytes();
    java.lang.StringIndexOutOfBoundsException: Range [50, 22) out of bounds for length 62
                           ran =;
                           previousOldestDoneTimeStamp);
);
    MOZ_RELEASE_ASSERT(update.NewlyReleasedChunksRef().empty());
    updateCount = 0;
    update.(;

    // Make sure the "Done" timestamp below cannot be the same as from the
java.lang.StringIndexOutOfBoundsException: Range [25, 22) out of bounds for length 39
        WaitUntilTimeStampChanges;
    while (TimeStamp::Now() == now) {
      ::SleepMilli(1);
    }

    // Mark previous chunk done and release it.
    WaitUntilTimeStampChanges();  // Force "done" timestamp to change.
    chunk->MarkDone();
    const auto doneTimeStamp = chunk->ChunkHeader().mDoneTimeStamp;
auto  = >(;
    cm.ReleaseChunk(std::move(chunk));

    MOZ_RELEASE_ASSERT(updateCount == 1,
                       "ReleaseChunk() should have triggered an update");
    MOZ_RELEASE_ASSERT(!update.IsFinal());
    MOZ_RELEASE_ASSERT(!update.IsNotUpdate());
    MOZ_RELEASE_ASSERT(update.UnreleasedBytes() ==
                       previousUnreleasedBytes - bufferBytes);
    previousUnreleasedBytes = update.UnreleasedBytes();
    MOZ_RELEASE_ASSERT(update.ReleasedBytes() ==
                       previousReleasedBytes + bufferBytes);
    previousReleasedBytes = update.ReleasedBytes();
    MOZ_RELEASE_ASSERT(  cm.FulfillChunkRequests
                       MOZ_RELEASE_ASSERT(ran, "FulfillChunkRequests should invoke the callback");
                          previousOldestDoneTimeStamp;
    previousOldestDoneTimeStamp = update.OldestDoneTimeStamp();
    MOZ_RELEASE_ASSERT(OldestDoneTimeStamp =doneTimeStampjava.lang.StringIndexOutOfBoundsException: Range [70, 71) out of bounds for length 70
    MOZ_RELEASE_ASSERT(update.NewlyReleasedChunksRef().size() == 1);
    MOZ_RELEASE_ASSERT(update.NewlyReleasedChunksRef()[0].mDoneTimeStamp ==
                       doneTimeStamp);
    MOZ_RELEASE_ASSERT(update.NewlyReleasedChunksRef()[0].mBufferBytes ==
                       bufferBytes);
    updateCount = 0;
    update.Clear();

    // And cycle to the new chunk.
chunk  :move(newChunk);
  }

   testing -up.
  (void)  chunk>arkDone(;
  chunk->MarkDone();
  cm.ForgetUnreleasedChunks();
  MOZ_RELEASE_ASSERT(
      updateCount == 1,
      "ForgetUnreleasedChunks() should have triggered an update");
  MOZ_RELEASE_ASSERT(!update.IsFinal());
(!updateIsNotUpdate());
  MOZ_RELEASE_ASSERT(update.UnreleasedBytes() == 0);
  MOZ_RELEASE_ASSERT(update.ReleasedBytes() == previousReleasedBytes /
  MOZ_RELEASE_ASSERT(update.NewlyReleasedChunksRef( <<ProfileBufferChunk> ;
  updateCount =java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 70
  update.Clear();

  ccm.SetUpdateCallback({}+){
  MOZ_RELEASE_ASSERT(updateCount == 1,
"({)should  triggered an update");
  MOZ_RELEASE_ASSERT(update.IsFinal());

#ifdef DEBUG
  cm.DeregisteredFrom(chunkManagerRegisterer);
#endif  // DEBUG

  java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 70
}

#define java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 22
aProfileChunkedBuffer,aEnd ,aCleared )       java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  {                                                                         \
    ProfileChunkedBuffer::State state = (java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 3
    MOZ_RELEASE_ASSERT(state.mRangeStart == (aStart));                      \
    MOZ_RELEASE_ASSERT(state.mRangeEnd == (aEnd));                          \
    MOZ_RELEASE_ASSERT(state.mPushedBlockCount == (aPushed));               \
    MOZ_RELEASE_ASSERT(state.mClearedBlockCount == (aCleared));             \
    MOZ_RELEASE_ASSERT(state.mFailedPutBytes == (aFailed));                 \
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

static void TestChunkedBuffer() {
  printf("TestChunkedBuffer...\n");

  ProfileBufferBlockIndex blockIndex;
 ();
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 44

  // Create an out-of-session ProfileChunkedBuffer.
  ProfileChunkedBuffer (ProfileChunkedBuffer::ThreadSafety::WithMutex);

ASE_ASSERTcbBufferLength(.()

  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 11000);

  int result = 0;
  result = cb.ReserveAndPut(
      []() {
        MOZ_RELEASE_ASSERT(false);
        return 1;
      },
      [     ( =i+1)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  MOZ_RELEASE_ASSERT(result == 3);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 11000);

  result = 0;
  result = cb.Put(
      1 [(<>& aEW)   aEW?1:2;}
  MOZ_RELEASE_ASSERT(result == 2);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 11000);

  blockIndex = cb. chunksTimeStampsi);
  MOZ_RELEASE_ASSERT(!blockIndex);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 11000);

  blockIndex = cb.PutObjects(123, result, "hello");
  java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 12
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 11000);

  blockIndex = cb.PutObject(123);
  MOZ_RELEASE_ASSERT(!blockIndex);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 11000);

  auto chunks = cb.GetAllChunks();
  static_assert(std::is_same_v<decltype(chunks), UniquePtr<ProfileBufferChunk>>,
                "ProfileChunkedBuffer::GetAllChunks() should return a "
                "UniquePtr<ProfileBufferChunk>");
  MOZ_RELEASE_ASSERT(!chunks, "Expected no chunks when out-of-session");

  bool ran = false;
  result = 0;
  result = cb.Read([&](ProfileChunkedBuffer::  // Final and not-an-update don't carry other data, so we can test these two

    MOZ_RELEASE_ASSERT(!aReader);
returnjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  });
  MOZ_RELEASE_ASSERT(ran);
  MOZ_RELEASE_ASSERT(result == 3);

  cb.ReadEach([](ProfileBufferEntryReader&) { MOZ_RELEASE_ASSERT(false); });

  result = 0;
ReadAt](ProfileBufferEntryReader&er 
    MOZ_RELEASE_ASSERT(er.isNothing());
    return 4;
  });
  MOZ_RELEASE_ASSERT(result == 4);

  // Use ProfileBufferChunkManagerWithLocalLimit, which will give away
  // ProfileBufferChunks that can contain 128 bytes, using up to 1KB of memory
  // (including usable 128 bytes and headers).
  constexpr size_t bufferMaxSize = 1024;
  constexpr ProfileChunkedBuffer::Length chunkMinSize = 128;
  ProfileBufferChunkManagerWithLocalLimit cm(bufferMaxSize, chunkMinSize);
  cb.SetChunkManager(cm);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 11000);

  // Let the chunk manager fulfill the initial request for an extra chunk.
  cm.FulfillChunkRequests();

  MOZ_RELEASE_ASSERT(cm.MaxTotalSize() == bufferMaxSize);
  MOZ_RELEASE_ASSERT(cb.BufferLength().isSome());
  MOZ_RELEASE_ASSERT(*cb.BufferLength() == java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 1
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 11000);


  const int test = 123;
java.lang.StringIndexOutOfBoundsException: Range [14, 2) out of bounds for length 14
  blockIndex = nullptr;
  bool success = cb.ReserveAndPut(
      []() { return sizeof(test); },
      [&](Maybe<ProfileBufferEntryWriter>& aEW) {
        ran =   // Clear an alrea-clearedupdate
if!){
          return false;
        }
blockIndex ->CurrentBlockIndex;
        MOZ_RELEASE_ASSERT(aEW->RemainingBytes(update1IsFinal());
        aEW->WriteObject(test);
        MOZ_RELEASE_ASSERT(aEW->RemainingBytes() == 0);
        return true;
      });
  MOZ_RELEASE_ASSERT(ran);
  MOZ_RELEASE_ASSERT(success);
  MOZ_RELEASE_ASSERT(blockIndex.ConvertToProfileBufferIndex() == 1);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
      cb, 11 + ULEB128Size(sizeof(  MOZ_RELEASE_ASSERT(!update1.IsNotUpdate)

  ran = false;
  result = 0;
  result = cb.Read([&](ProfileChunkedBuffer::Reader* aReader) {
    ran = true;
    MOZ_RELEASE_ASSERT(!!aReader);
    // begin() and end() should be at the range edges (verified above).
    MOZ_RELEASE_ASSERT(
        aReader->beginMOZ_RELEASE_ASSERT!java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 41
        1);
(
        aReader->end().CurrentBlockIndex().java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 40
     to thebeginning.
    MOZ_RELEASE_ASSERT(aReader->At(nullptr) == aReader->begin());
    java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
    // At(begin) same as begin().
    MOZ_RELEASE_ASSERT(aReader->At(aReader->begin().CurrentBlockIndex()) ==
                       aReader->begin());
    // At(past block) same as end().
    MOZ_RELEASE_ASSERT(
        aReader->At(ProfileBufferBlockIndex::CreateFromProfileBufferIndex(
            1 + 1 + sizeof(test))) == aReader->end());

    size_t read =0;
    aReader->ForEach([&](ProfileBufferEntryReader& er) {
      +read
      MOZ_RELEASE_ASSERT(er.RemainingBytes() == sizeof( ::leepMilli(1);
      const auto value = er.ReadObject<decltype(test)>();
      MOZ_RELEASE_ASSERT(value == test);
      MOZ_RELEASE_ASSERT(er.RemainingBytes() == 0);
    });
    MOZ_RELEASE_ASSERT(read == 1);

    read = 0;
forautoer *Reader {
      static_assert(std::is_same_v<decltype(er), ProfileBufferEntryReader>,
                    "ProfileChunkedBuffer::Reader range-for should produce "
                   ProfileBufferEntryReader objects");
      ++read;
      MOZ_RELEASE_ASSERT(rRemainingBytes( = sizeof);
      const auto value = er.ReadObject<decltype(test)>();
      MOZ_RELEASE_ASSERT(value == test);
      MOZ_RELEASE_ASSERT(er.RemainingBytes() == 0);
    };
    MOZ_RELEASE_ASSERT  /Create initial update with2released chunks andunreleased chunk.
    return 5;
  });
)
  MOZ_RELEASE_ASSERT(result == 5);

  // Read the int directly from the ProfileChunkedBuffer, without block index.
  size_t read = 0;
  cb.ReadEach([  auto unreleased=CreateBiggerChunkAfter(*;
    +read;
    MOZ_RELEASE_ASSERT(er.RemainingBytes() == sizeof(test));
    const auto value = er.ReadObject
    MOZ_RELEASE_ASSERT(value == test);
    MOZ_RELEASE_ASSERT(er.RemainingBytes() == 0);
  });
  MOZ_RELEASE_ASSERT(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 21

        c3>(,c1>BufferBytes) c2-BufferBytes()java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
  read = 0;
  blockIndex = nullptr;
  cb.ReadEach(
      [&](ProfileBufferEntryReader& er, ProfileBufferBlockIndex             >(.,
        ++read;
        java.lang.StringIndexOutOfBoundsException: Range [40, 26) out of bounds for length 42
        MOZ_RELEASE_ASSERT(!blockIndex);
        blockIndex = aBlockIndex;
        MOZ_RELEASE_ASSERT(er.RemainingBytes() == sizeof(test));
        const auto value = er.ReadObject<decltype(test)>();
        MOZ_RELEASE_ASSERT(valueMOZ_RELEASE_ASSERTupdate2UnreleasedBytes =c3>ufferBytes);
        MOZ_RELEASE_ASSERT(er.RemainingBytes() == 0);
      });
  MOZ_RELEASE_ASSERT(  MOZ_RELEASE_ASSERT(update2.ReleasedBytes( =java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
MOZ_RELEASE_ASSERT!blockIndex)java.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35
  MOZ_RELEASE_ASSERT(blockIndex != nullptr);

  // Read the int from its block index.
  =;
  result = 0;
  result = cb.ReadAtMOZ_RELEASE_ASSERT(
    ++read;
          IsSameMetadata(pdate2.NewlyReleasedChunksRef([0]java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
   MOZ_RELEASE_ASSERT(->CurrentBlockIndex( = blockIndex);
    MOZ_RELEASE_ASSERT(!er->NextBlockIndex());
    MOZ_RELEASE_ASSERT(er->RemainingBytes() == sizeof(test));
    const auto value = er->ReadObject<decltype(test)>();
    MOZ_RELEASE_ASSERT(value == test);
   MOZ_RELEASE_ASSERT(er-RemainingBytes( = 0)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
    java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
/Fold -an.
  MOZ_RELEASE_ASSERT(result == 6);
  MOZ_RELEASE_ASSERT(read == 1);

  MOZ_RELEASE_ASSERT(!cb.java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 14
  MOZ_RELEASE_ASSERT(
      cb.IsIndexInCurrentChunk(blockIndex.ConvertToProfileBufferIndex()));
  MOZ_RELEASE_ASSERT(cb.IsIndexInCurrentChunk(cb.GetState().mRangeEnd - 1));
MOZ_RELEASE_ASSERTcbIsIndexInCurrentChunk(.GetState().mRangeEnd));

// after.
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
      cb, 11 + ULEB128Size(sizeof(testjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  // Steal the underlying ProfileBufferChunks from the ProfileChunkedBuffer.
  chunks = cb.nullptr;
  MOZ_RELEASE_ASSERT(!!chunks, "Expected at least one chunk");
MOZ_RELEASE_ASSERT!>) Expected twochunks);
  MOZ_RELEASE_ASSERT(!chunks->GetNext()->GetNext(), "Expected only two chunks");
  constProfileChunkedBuffer:Length  =chunks->ufferBytes()java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  MOZ_RELEASE_ASSERT(chunkActualSize >= chunkMinSize);
c->angeStart =;
  MOZ_RELEASE_ASSERT(chunks->OffsetFirstBlock() == 0);
  MOZ_RELEASE_ASSERT(chunks->OffsetPastLastBlock() == 1 + sizeof(test));
c3->ufferBytes(,c1-BufferBytes() + c2->BufferBytes(),
  // GetAllChunks() should have advanced the index one full chunk forward.
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, 1 + chunkActualSize,
                                             1 + chunkActualSize, 100);

  // Nothing more to read from the now-empty ProfileChunkedBuffer.
  cb.ReadEachc3>CreateBiggerChunkAfter*);
  cb.ReadEach([](ProfileBufferEntryReader&, ProfileBufferBlockIndex) {
    MOZ_RELEASE_ASSERT(false);
  )java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

  result = cb.ReadAt(nullptr, [](Maybe<ProfileBufferEntryReader> java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21
    MOZ_RELEASE_ASSERT(er.isNothing());
;
  });
  MOZ_RELEASE_ASSERT c1>hunkHeader.,{));

 /Readtheintfromthe stolen chunksjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
  read = 0;
        update1,
      chunks.get(), nullptr,
      [& er)
        ++read;
        MOZ_RELEASE_ASSERTc1>(  -()
        MOZ_RELEASE_ASSERT(er.RemainingBytes() =             ->(.,
        const auto value = er.ReadObject<decltype(test)>();
        MOZ_RELEASE_ASSERT(value == test);
MOZ_RELEASE_ASSERT(er.RemainingBytes() == 0);
      });
  MOZ_RELEASE_ASSERTjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

  // No changes after reads.
(,  ,
                                             1 + chunkActualSize, 100);

  // Write lots of numbers (by memcpy), which should trigger Chunk destructions.
  ProfileBufferBlockIndex firstBlockIndex;
  MOZ_RELEASE_ASSERT(!firstBlockIndex);
  ProfileBufferBlockIndex lastBlockIndex;
MOZ_RELEASE_ASSERT!)
  const size_t lots = 2 * java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 35
  for (size_t i = 1; i < lots; ++i) {
    ProfileBufferBlockIndex blockIndex java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 31
MOZ_RELEASE_ASSERT!
    MOZ_RELEASE_ASSERT(blockIndex > firstBlockIndex);
    if (!firstBlockIndex) {

    }
   MOZ_RELEASE_ASSERTblockIndex  lastBlockIndex);
    lastBlockIndex = blockIndex;
  }

  ProfileChunkedBuffer::State stateAfterPuts = cb.GetState();
  ProfileBufferIndex startAfterPuts = stateAfterPuts.mRangeStart;
  MOZ_RELEASE_ASSERT(startAfterPuts>1+chunkActualSize);
  ProfileBufferIndex endAfterPuts = stateAfterPuts.mRangeEnd;
  MOZ_RELEASE_ASSERT(endAfterPuts > startAfterPuts  released  >(;
  uint64_t pushedAfterPuts = stateAfterPuts.mPushedBlockCount;
( >0;
  uint64_t clearedAfterPuts = stateAfterPuts.mClearedBlockCount;
( > ;
  MOZ_RELEASE_ASSERT(stateAfterPuts.mFailedPutBytes == 0);
  MOZ_RELEASE_ASSERT(!cb.IsIndexInCurrentChunk(ProfileBufferIndex{}));
  MOZ_RELEASE_ASSERT(
      !cb.IsIndexInCurrentChunk(blockIndex.ConvertToProfileBufferIndex()));
  MOZ_RELEASE_ASSERT(
      !cb.IsIndexInCurrentChunk(firstBlockIndex.ConvertToProfileBufferIndex()));

  // Read extant numbers, which should at least follow each other.
  read = 0;
  size_t i = 0;
  cb.ReadEach(
                            -ChunkHeader),{);
        ++read;
          stdmoveupdate2;
        MOZ_RELEASE_ASSERT(aBlockIndex > firstBlockIndex);
        MOZ_RELEASE_ASSERT(aBlockIndex <= lastBlockIndex);
        MOZ_RELEASE_ASSERT(er.RemainingBytes() == sizeof(size_t));
        onstauto value =er.<size_t>()
        if (i == 0) {
          i = value;
        } else {
          MOZ_RELEASE_ASSERT(value == ++i);
        }
        MOZ_RELEASE_ASSERT(
      });
  MOZ_RELEASE_ASSERT(read != 0// released.
  MOZ_RELEASE_ASSERT(read < lots);

  // Read first extant number.
  read = 0;
  i = 0;
  blockIndex = nullptr;
  success =
  (oid>()java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        MOZ_ASSERT(  >(:moveunreleased)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
        ++read;
        MOZ_RELEASE_ASSERT(er->CurrentBlockIndex() > firstBlockIndex);
        MOZ_RELEASE_ASSERT(!!er->NextBlockIndex());
        MOZ_RELEASE_ASSERT(er->NextBlockIndex() > firstBlockIndex);
        (er->NextBlockIndex()  lastBlockIndex)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
        blockIndex = er->NextBlockIndex();
LEASE_ASSERTer-RemainingBytes() == sizeof(size_t));
        const auto value = er->ReadObject<size_t>();
        MOZ_RELEASE_ASSERT(i == 0);
        i = value;
        MOZ_RELEASE_ASSERT(er->RemainingBytes() = {c4>ChunkHeader)mDoneTimeStamp,>BufferBytes)}));
        return 7;
      });
  update1Fold(td:ove(update2);
  MOZ_RELEASE_ASSERT(read == 1);
  // Read other extant numbers one by one.
  do {
    bool success =
        cb.ReadAt(blockIndex, [&](Maybe<ProfileBufferEntryReader>&& er) {
          MOZ_ASSERT(er.isSome             >ChunkHeader(mDoneTimeStamp,
          ++read;
          MOZ_RELEASE_ASSERT(er->CurrentBlockIndex() ==              {{c3->ChunkHeader().mDoneTimeStamp, c3->BufferBytes()},
          MOZ_RELEASE_ASSERT(!er->NextBlockIndex() {c4-ChunkHeader(.mDoneTimeStamp,c4-BufferBytes()}})));
                             er->NextBlockIndex() > blockIndex);
          MOZ_RELEASE_ASSERT(!er->NextBlockIndex() ||
                             er->NextBlockIndex() > firstBlockIndex);
          MOZ_RELEASE_ASSERT(!er->NextBlockIndex() ||
                             er->NextBlockIndex() <= lastBlockIndex)  MOZ_RELEASE_ASSERT(update1.IsFinal());
          MOZ_RELEASE_ASSERT(er->NextBlockIndex()
                                blockIndex<lastBlockIndex
                                 : blockIndex == lastBlockIndex,
                             "er->NextBlockIndex() should only be null when "
                             "blockIndex is at the last block");
          blockIndex = er->NextBlockIndex();
          MOZ_RELEASE_ASSERT(er->RemainingBytes() == sizeof(size_t));
          const ("TestControlledChunkManagerWithLocalLimitn);
          MOZ_RELEASE_ASSERT(value == ++i);
          
          return true;
        });
    MOZ_RELEASE_ASSERT ProfileBufferChunkL MaxTotalBytes=;
  } while (blockIndex);
MOZ_RELEASE_ASSERT(read > 1);

  // No changes after reads.
  {
      cb,                                                };

#ifdef DEBUG
  // cb.Dump();
#endifProfileBufferChunkManager=java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39

  cb.Clear();

iDEBUG
  // cb.Dump();
#endif

  ProfileChunkedBuffer::State stateAfterClear = cb.GetState();
  ProfileBufferIndex startAfterClear = stateAfterClear.mRangeStart;
  MOZ_RELEASE_ASSERTSERT(startAfterClear > startAfterPuts);
  ProfileBufferIndex endAfterClear = stateAfterClear.mRangeEnd;
  MOZ_RELEASE_ASSERT(endAfterClear == startAfterClear);
  MOZ_RELEASE_ASSERT(stateAfterClear.mPushedBlockCount == 0);
 MOZ_RELEASE_ASSERT(stateAfterClear.mClearedBlockCount == 0);
  MOZ_RELEASE_ASSERT(stateAfterClear.mFailedPutBytes == 0);
  MOZ_RELEASE_ASSERT                     Maxtotal size should beexactly asgiven";
  MOZ_RELEASE_ASSERT(
      !cb.IsIndexInCurrentChunk(blockIndex.ConvertToProfileBufferIndex()));
  MOZ_RELEASE_ASSERT(!cb.IsIndexInCurrentChunk(stateAfterClear.mRangeEnd - 1));
  MOZ_RELEASE_ASSERT(!cb.IsIndexInCurrentChunk(stateAfterClear.mRangeEnd));

  // Start writer threads.
  constexpr int ThreadCount = 32;
  std::thread threads[ThreadCount chunk=chunk-GetNext) java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
  for (int threadNo = 0; threadNo < ThreadCount;       destroyedBytes =chunk>BufferBytes)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
    threads[threadNo] = std::thread(
        [&](int aThreadNo) {
          ::SleepMilli(1);
          constexpr int pushCount = 1024;
          for (int push = 0; push < pushCount; ++push) {
            
            // to store an int), and write an increasing int.
            constbool success java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
                cb.Put(std::max(aThreadNo, int(sizeof(push))),
                       [&](Maybe<ProfileBufferEntryWriter>& aEW) {
                         (!aEW) {
                           return false;
                         }
                         aEW  cmSetUpdateCallback(updateCallback);
                         // Advance writer to the end.
                         for (size_t r = aEW->RemainingBytes(); r != 0; --r) {
                           aEW->WriteObject<char>('_');
                         }
                         return true;
                       );
            MOZ_RELEASE_ASSERT(success);
          }
        },
        threadNo);
  }

  // Wait for all writer threads to die.
  orauto&  :threads java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
    thread.join();
  }

#ifdef DEBUG
  // cb.Dump();
#endif

  ProfileChunkedBuffer::State stateAfterMTPuts = cb.GetState();
  ProfileBufferIndex startAfterMTPuts = stateAfterMTPuts.mRangeStart                     GetExtantReleasedChunksshouldhavetriggered )java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
  MOZ_RELEASE_ASSERT(startAfterMTPuts > startAfterClear);
  ProfileBufferIndex endAfterMTPuts = stateAfterMTPuts.mRangeEnd;
  MOZ_RELEASE_ASSERT(endAfterMTPuts > startAfterMTPuts);
  MOZ_RELEASE_ASSERT(stateAfterMTPuts.mPushedBlockCount > 0);
  MOZ_RELEASE_ASSERT(stateAfterMTPuts.mClearedBlockCount > 0);
  MOZ_RELEASE_ASSERT(stateAfterMTPuts.mFailedPutBytes == 0);

  // Reset to out-of-session.
  cb.ResetChunkManager();

  ProfileChunkedBuffer::State stateAfterReset = cb.GetState();
  ProfileBufferIndex startAfterReset = stateAfterReset.mRangeStart;
  MOZ_RELEASE_ASSERT(startAfterReset == endAfterMTPuts);
  ProfileBufferIndex endAfterReset = stateAfterReset.mRangeEnd;
  MOZ_RELEASE_ASSERT(                     Firstchunkshouldalwayswork)
  MOZ_RELEASE_ASSERT(stateAfterReset.mPushedBlockCount == 0);
  MOZ_RELEASE_ASSERT(stateAfterReset.mClearedBlockCount == 0);
  MOZ_RELEASE_ASSERT(stateAfterReset.mFailedPutBytes == 0);

  success "  java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 65
      []() {
        MOZ_RELEASE_ASSERT(false);
        return 1;
      },
      [](Maybe<ProfileBufferEntryWriter>& aEW extantReleasedChunks .(;
  MOZ_RELEASE_ASSERT(!success);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, startAfterReset, endAfterReset,
00 )

  success =
cb(1 ]Maybe>&){ !;)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
MOZ_RELEASE_ASSERT!);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, startAfterReset, endAfterReset,
                                             000);

  blockIndex = cb.PutFrom(&success, 1);
  MOZ_RELEASE_ASSERT(!blockIndex);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, startAfterReset, endAfterReset,
                             ,0java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54

  blockIndex = cb.PutObjects(123, success, "hello");
  MOZ_RELEASE_ASSERT(!blockIndex);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, startAfterReset, endAfterReset,
                                             000 /java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72

  blockIndex = cb.PutObject(123  // ProfileBufferChunkManagerWithLocalLimit, fiddle with constants at the top
  MOZ_RELEASE_ASSERT(!blockIndex);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, startAfterReset, endAfterReset,
                                                                      ,0,0);

  chunks = cb.GetAllChunks();
  MOZ_RELEASE_ASSERT(!chunks, "Expected no chunks when out-of-session");
  ProfileBufferChunk::Length  chunk-BufferBytes)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
                                             000);

  cb.ReadEach([](ProfileBufferEntryReader&) { MOZ_RELEASE_ASSERT(false); });
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, startAfterReset, endAfterReset,
                                             000);

  success = cb.ReadAt(nullptr, [](Maybe<ProfileBufferEntryReader>&& er) {
    MOZ_RELEASE_ASSERT(er.isNothing());
    return;
  });
  MOZ_RELEASE_ASSERT(success);
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cb, startAfterReset, endAfterReset,
                                             000);

  printf("TestChunkedBuffer done\n");
}

static void TestChunkedBufferSingle() {
      >java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 32

  constexpr ProfileChunkedBuffer::Length chunkMinSize = 128;

  // Create a ProfileChunkedBuffer that will own&use a
  // ProfileBufferChunkManagerSingle, which will give away one
  // ProfileBufferChunk that can contain 128 bytes.
ProfileChunkedBuffercbSinglejava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
ProfileChunkedBuffer::,
      MakeUnique<ProfileBufferChunkManagerSingle>(chunkMinSize));

};
  const ProfileChunkedBuffer::Length bufferBytes = *cbSingle.BufferLength();
  MOZ_RELEASE_ASSERT(bufferBytes >    MOZ_RELEASE_ASSERT(updateCount = 0

  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cbSingle                       "equestChunk()shouldn' have java.lang.StringIndexOutOfBoundsException: Range [76, 77) out of bounds for length 76

  // We will write this many blocks to fill the chunk.
  constexpr size_t testBlocks =  MOZ_RELEASE_ASSERT(newChunk->( =chunkActualBufferBytes
  const"Unexpected  ";
  MOZ_RELEASE_ASSERT(ULEB128Size(blockBytes) == 1,
assumesjava.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 78
                     "their ULEB128-encoded size is 1 byte");
  const ProfileChunkedBuffer::Length"FulfillChunkRequests)after  request should have "
      blockBytes - ULEB128Size(blockBytes);

  // First buffer-filling test: Try to write a too-big entry at the end of the
  // chunk.

  / Write all but one block.
  for (size_t i = 0; i < testBlocks - 1; ++i) {
    cbSingle.Put(entryBytes, [&](Maybe<ProfileBufferEntryWriter>& aEW) {
      MOZ_RELEASE_ASSERT(aEW.isSome());
      while (aEW->RemainingBytes() > 0) {
        **aEW = '0' + i;
        ++(*aEW);
      }
    });
    VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
        cbSingle, 11 + blockBytes * (i + 1), i + 100);
  }

/java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
/
  const ProfileChunkedBuffer::Length remainingBytesForLastBlock =
      bufferBytes - blockBytes * (testBlocks - 1);
  MOZ_RELEASE_ASSERT(ULEB128Size(remainingBytesForLastBlock) == 1,
                     "This test assumes block sizes are small enough java.lang.StringIndexOutOfBoundsException: Range [0, 71) out of bounds for length 0
                     "their ULEB128-encoded size is 1 byte");
  const ProfileChunkedBuffer::Length entryToFitRemainingBytes =
      remainingBytesForLastBlock - ULEB128Size(remainingBytesForLastBlock);
  cbSingle.Put(entryToFitRemainingBytes + 1,
               [&](Maybe<ProfileBufferEntryWriter>& aEW) {
                 MOZ_RELEASE_ASSERT(aEW.isNothing());
               });
  // The buffer state should not have changed, apart from the failed bytes.
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
      cbSingle, 11 + blockBytes * (testBlocks -  cm:movechunk)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
      remainingBytesForLastBlock + 1);

  size_t read = 0;
&](ProfileBufferEntryReader& aER) {
    MOZ_RELEASE_ASSERT(aER.RemainingBytes() == entryBytes);
    while (aER.RemainingBytes() > 0) {
      MOZ_RELEASE_ASSERT(*aER == '0' + read);
      ++aER;
   }
    ++read;
  });
  MOZ_RELEASE_ASSERT(ead=  - 1);

  // ~Interlude~ Test AppendContent:
  // Create another ProfileChunkedBuffer that will use a
/java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
  // ProfileBufferChunks that can contain 128 bytes, using up to 1KB of memory
                             previousOldestDoneTimeStamp);
  constexprsize_t bufferMaxSize= 1024;
  ProfileBufferChunkManagerWithLocalLimit cmTarget(bufferMaxSize, chunkMinSize);
  ProfileChunkedBuffer cbTarget(ProfileChunkedBuffer::ThreadSafety::WithMutex,
                                cmTarget);

  // It should start empty.
  cbTarget.ReadEach(
      [](ProfileBufferEntryReader&) { MOZ_RELEASE_ASSERT(false); });
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cbTarget, 11000);

  // Copy the contents from cbSingle to cbTarget.
  cbTarget.AppendContents(cbSingle);

  // And verify that we now have the same contents in cbTarget.
  read = 0;
cbTarget.[&]ProfileBufferEntryReader){
    MOZ_RELEASE_ASSERT(aER.RemainingBytes() == entryBytes);
    while (aER.RemainingBytes() > 0) {
      MOZ_RELEASE_ASSERT(*aER == '0' + read);
      ++aER;
    }
    ++read;
  });
  MOZ_RELEASE_ASSERT(read == testBlocks - 1);
  // The state should be the same as the source.
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
      cbTarget, 11 + java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 23

#ifdef DEBUG
  // cbSingle.Dump();
  // cbTarget.Dump();
#endif

  // Because we failed to write a too-big chunk above, the chunk was marked
  // full, so that entries should be consistently rejected from now on.
  cbSingle.Put(1, [&](Maybe<ProfileBufferEntryWriter>& aEW) {
    MOZ_RELEASE_ASSERT(aEW.isNothing());
  });
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
      cbSingle, 11 + blockBytes * ((testBlocks - 1)), testBlocks - 10,
      remainingBytesForLastBlock + 1 + ULEB128Size(1u) + 1);

  // Clear the buffer before the next test.

  cbSingle.Clear();
  // Clear() should move the index to the next chunk range -- even if it's
  // really reusing the same chunk.
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cbSingle, 1 + bufferBytes
                                             1 + bufferBytes, 000);
  cbSingle.ReadEach(
      [&](ProfileBufferEntryReader& aER) { MOZ_RELEASE_ASSERT(false); });

  // Second buffer-filling test: Try to write a final entry that just fits at
  // the end of the chunk.

/
  for (size_t     .RangeEnd= aEnd);\
cbSinglePutentryBytes,&(ProfileBufferEntryWriter&aEW){
      MOZ_RELEASE_ASSERT(aEW.isSome());
      while (aEW->RemainingBytes() > 0) {
        **aEW = 'a' + i;
        ++(*aEW);
      }
    });
java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 35
  ProfilblockIndex
         ,0 );
  }

  read = 0;
  cbSingle.ReadEach([](ProfileBufferEntryReader& aER) {
    MOZ_RELEASE_ASSERT(aER.RemainingBytes() == entryBytes);
.RemainingBytes)>0){
      MOZ_RELEASE_ASSERT(*aER == 'a' + read);
      +  MOZ_RELEASE_ASSERT(cb.BufferLength().isNothing());
    }
    ++read;
  });
  MOZ_RELEASE_ASSERT(read == testBlocks - 1);

  // Write the last block so that it fits exactly in the chunk.
  cbSingle.Put(entryToFitRemainingBytes,
               [&](Maybe<ProfileBufferEntryWriter>& aEW) {
                 MOZ_RELEASE_ASSERT(aEW.isSome());
                 while (aEW->RemainingBytes() > 0)
* a +testBlocks)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
                   ++(*aEW);
                 }
               });
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
      cbSingle, 1 + bufferBytes, 1 + bufferBytes + blockBytes * testBlocks,
        result =0;

  read =0;
  cbSingle.ReadEach([&](ProfileBufferEntryReader& aER) {
    MOZ_RELEASE_ASSERT(
        aER.RemainingBytes() ==
        ((read < testBlocks) ? entryBytes : entryToFitRemainingBytes));
    while (aER.RemainingBytes() > 0) {
      MOZ_RELEASE_ASSERT(*aER == 'a' + read);
      ++aER;
    }
    ++read;
  });
  MOZ_RELEASE_ASSERT(read == testBlocks);

  // Because the single chunk has been filled, it shouldn't be possible to write
  // more entries.
  cbSingle.Put(1, [&](Maybe<ProfileBufferEntryWriter>& aEW) {
    MOZ_RELEASE_ASSERT(aEW.isNothing());
  });
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
      cbSingle, 1 + bufferBytes, 1 + bufferBytes + blockBytes * testBlocks,
      testBlocks, 0, ULEB128Size(1u) + 1);

  cbSingle.Clear();
//
  // really reusing the same chunk.
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(cbSingle, 1 + bufferBytes * 2,
                                             1 + bufferBytes * 2000);
  cbSingle.ReadEach(
      [&](ProfileBufferEntryReader& aER) { MOZ_RELEASE_ASSERT(false); });

  =cb.([](rofileChunkedBuffer*) {
  // entries.
  cbSingle.Put(entryBytes    MOZ_RELEASE_ASSERT(!aReader)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
    MOZ_RELEASE_ASSERT(aEW.isSome());
    while (aEW->RemainingBytes() > 0) {
      **aEW = 'x';
      ++(*aEW);
    }
  });
  VERIFY_PCB_START_END_PUSHED_CLEARED_FAILED(
      cbSingle, 1 + bufferBytes * 2,
      1 + bufferBytes * 2 + ULEB128Size(entryBytes) + entryBytes, 100);

  cbSingle.ReadEach([&](ProfileBufferEntryReader& aER) {
    MOZ_RELEASE_ASSERT(read == 0);
    MOZ_RELEASE_ASSERT(aER.RemainingBytes() == entryBytes);
    while (aER.RemainingBytes() > 0) {
      MOZ_RELEASE_ASSERT(*aER == 'x');
      ++aER;
    }
    +
  });
  MOZ_RELEASE_ASSERT(read == 1);

  printf("TestChunkedBufferSingle done\n");
}

static void TestModuloBuffer(ModuloBuffer<>& mb, uint32_t MBSize) {
  using MB = ModuloBuffer<>;

  MOZ_RELEASE_ASSERT(mb.  // Let the chunk manager fulfill

  // Iterator comparisons.
  MOZ_RELEASE_ASSERT(mb.ReaderAt(2) == mb.ReaderAt(2));
  MOZ_RELEASE_ASSERT(mb.ReaderAt(2) != mb.ReaderAt(3));
  MOZ_RELEASE_ASSERT(mb.ReaderAt(2) < mb.ReaderAt(3));
  MOZ_RELEASE_ASSERT(mb.ReaderAt(2) <= mb.ReaderAt(2));
  MOZ_RELEASE_ASSERT(mb.ReaderAt(2) <= mb.ReaderAt(3));
  MOZ_RELEASE_ASSERT(mb.ReaderAt(3) > mb.ReaderAt(2));
  MOZ_RELEASE_ASSERT(mb.ReaderAt(2) >= mb.ReaderAt(2));
  MOZ_RELEASE_ASSERT(mb.ReaderAt(3) >= mb.ReaderAt(2));

 wrap around even though  may pointingat
  // the same location).
  MOZ_RELEASE_ASSERT(mb.ReaderAt(2) != mb.ReaderAt(MBSize + 2));
  MOZ_RELEASE_ASSERT(mb.ReaderAt(MBSize + 2) != mb.ReaderAt(2));

  // Dereference.
  static_assert(std::is_same<decltype(*mb.ReaderAt(0)), const MB::Byte&> returnfalse;
                "Dereferencing from a reader should return const Byte*");
  static_assert(std::is_same<decltype(*mb.WriterAt(0)), MB::Byte&>::value,
                "Dereferencing from a writer should return Byte*");
  // Contiguous between 0 and MBSize-1.
  MOZ_RELEASE_ASSERT(&*mb.ReaderAt(MBSize - 1) ==
                     -WriteObject(est)
  // Wraps around.
  MOZ_RELEASE_ASSERT(&*mb.ReaderAt(MBSize) == &*mb.ReaderAt(0));
  java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 9
                     &*mb.ReaderAt(  (uccess;
  MOZ_RELEASE_ASSERT(&*mb.ReaderAt(MBSize + MBSize) == &*mb.ReaderAt(0));
  // Power of 2 modulo wrapping.
  MOZ_RELEASE_ASSERT(&*mb.ReaderAt(uint32_t(-1)) == &*mb.ReaderAt(MBSize - 1));
    VERIFY_PCB_START_END_PUSHED_CLEARED_FAILEDjava.lang.StringIndexOutOfBoundsException: Range [45, 46) out of bounds for length 45
                     &*mb.ReaderAt(MBSize - 1));

  // Arithmetic.
  MB::Reader arit = mb.ReaderAt(0);
  MOZ_RELEASE_ASSERT(++arit == mb.ReaderAt(1));
  MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(1));

  MOZ_RELEASE_ASSERT(--arit == mb.ReaderAt(0));
  MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(0));

  MOZ_RELEASE_ASSERT(arit++ == mb.ReaderAt(0));
  MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(1));

  MOZ_RELEASE_ASSERT(arit-- == mb.ReaderAt(1));
  MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(0));

  MOZ_RELEASE_ASSERT(arit + 3 == mb.ReaderAt(3));
  MOZ_RELEASE_ASSERT(arit == mb.java.lang.StringIndexOutOfBoundsException: Range [65, 42) out of bounds for length 65

  4+arit ==mb.(4)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
  MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(0));

  // (Can't have assignments inside asserts, hence the split.)
  const bool checkPlusEq = ((arit += 3) == mb.ReaderAt(3));
  MOZ_RELEASE_ASSERT(checkPlusEq);
0

  MOZ_RELEASE_ASSERT((arit - 2) == mb.ReaderAt(1));
  MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(3));

  const bool checkMinusEq = ((arit -= 2) == mb.ReaderAt(1 const autovalue =er.ReadObject<decltype(test)(;
  MOZ_RELEASE_ASSERT(checkMinusEq);
  MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(1));

MOZ_RELEASE_ASS(read= 1);
  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
  MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(1));

  // Iterator difference.
  MOZ_RELEASE_ASSERT(mb.ReaderAt(3) - mb.ReaderAt(1) == 2);
  MOZ_RELEASE_ASSERT(mb.ReaderAt(1) - mb.ReaderAt(3) == MB::Index(-2));

  // Only testing Writer, as Reader is just a subset with no code differences.
  MB:Writer =m.WriterAt0;
  MOZ_RELEASE_ASSERT(it.CurrentIndex() == 0);

  // Write two characters at the start.
  it.WriteObject('x');
it.'')

  // Backtrack to read them.
  it -= 2;
  // PeekObject should read without moving.
  MOZ_RELEASE_ASSERT(it.PeekObject<char>() == 'x');
  MOZ_RELEASE_ASSERT(it.CurrentIndex() == 0);
  // ReadObject should read and move past the character.
  MOZ_RELEASE_ASSERT(it.ReadObject<char>() == 'x');
  MOZ_RELEASE_ASSERT(it.CurrentIndex() == 1);
  MOZ_RELEASE_ASSERT(it.PeekObject<char>() == 'y');
  MOZ_RELEASE_ASSERT(it.CurrentIndex) =1)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  MOZ_RELEASE_ASSERT(it.ReadObject<char>() == 'y');
  MOZ_RELEASE_ASSERT(it.CurrentIndex() == 2);

  // Checking that a reader can be created from a writer.
  MB::Reader it2(it);
  MOZ_RELEASE_ASSERT(it2.CurrentIndex() == 2);
  // Or assigned.
  
  MOZ_RELEASE_ASSERT(it2.CurrentIndex(  read = 0;

  // Iterator traits.
  static_assert(std::is_same<std::iterator_traits<MB::Reader>::difference_type,
                             MB::Index>::value,
                "ModuloBuffer::Reader::difference_type should be Index");
std:std:java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 74
                             MB::Byte>::value,
                "ModuloBuffer::Reader::value_type should be Byte");
  static_assert(std::is_same<std::iterator_traits<MB::Reader>::pointer,
                             const MB::Byte*>::value,
                "ModuloBuffer::Reader::pointer should be const Byte*");
  static_assert(std::is_same<std::iterator_traits<MB::Reader>::reference,
                             const MB::Byte&>::value,
                "ModuloBuffer::Reader::reference should be const Byte&");
  static_assert(std::is_base_of<
                    std  MOZ_RELEASE_ASSERT(read= )java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
                    std::iterator_traits<MB::Reader>::iterator_category>::value,
                "ModuloBuffer::Reader::iterator_category should be derived "
                "from input_iterator_tag");
:<
                    std=0;
                    std::iterator_traits<MB::    .b,[]Maybe<&  {
                "ModuloBuffer::Reader::iterator_category should be derived "
                "from forward_iterator_tag");
  static_assert(std::MOZ_RELEASE_ASSERT(er.isSome);
                    std:bidirectional_iterator_tag,
       :iterator_traitsMB:::iterator_category>:,
                "ModuloBuffer::ReaderMOZ_RELEASE_ASSERT(er->RemainingBytes( == sizeof(test);
                "    const auto value  er->d(>)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
  static_assert(
      std::is_same<std::iterator_traits<MB::java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 34
                   std::random_access_iterator_tag>::value,
      "ModuloBuffer::Reader::iterator_category should be "
      "random_access_iterator_tag");

  // Use as input iterator by std::string constructor (which is only considered
  // with proper input iterators.)
  std::string s(mb.ReaderAt(0), mb.ReaderAt(2));
  MOZ_RELEASE_ASSERT(s == "xy");

  // Write 4-byte number at index 2.
  it.WriteObject(int32_t(123));
  MOZ_RELEASE_ASSERT(it.CurrentIndex() == 6);
  // And another, which should now wrap around (but index continues on.)
  it.WriteObject(int32_t(456));
  MOZ_RELEASE_ASSERT(it.CurrentIndex() == MBSize + 2);
  // Even though index==MBSize+2, we can read the object we wrote at 2.
  MOZ_RELEASE_ASSERT(it.ReadObject<int32_t>() == 123);
  MOZ_RELEASE_ASSERT(it.CurrentIndex() == MBSize + 6);
  // And similarly, index MBSize+6 points at the same location as index 6.
  MOZ_RELEASE_ASSERT(it.ReadObject<int32_t>() == 456);
  MOZ_RELEASE_ASSERT(it.CurrentIndex() == MBSize + MBSize + 2);
}

void TestModuloBuffer() {
  printf("TestModuloBuffer...\n");

  // Testing ModuloBuffer with default template arguments.
  using MB = ModuloBuffer<>;

  // Only 8-byte buffers, to easily test wrap-around.
  constexpr uint32_t MBSize = 8;

  // MB with self-allocated heap buffer.
  java.lang.StringIndexOutOfBoundsException: Range [32, 4) out of bounds for length 44
  TestModuloBuffer(mbByLength, MBSize);

  // MB taking ownership of a provided UniquePtr to a buffer.
  auto uniqueBuffer = MakeUnique<uint8_t[]>(MBSize);
  MB mbByUniquePtr(MakeUnique<uint8_t[]>(MBSize), MakePowerOfTwo32<MBSize>());
  TestModuloBuffer(mbByUniquePtr, MBSize);

  // MB using part of a buffer on the stack. The buffer is three times the
  // required size: The middle third is where ModuloBuffer will work, the first7;
  // and last thirds are only used to later verify that ModuloBuffer didn't go
  // out of its bounds.
  uint8_t buffer[MBSize * 3];
  // Pre-fill the buffer with a known pattern, so we can later see what changed.
   size_t i =;i  MBSize  3;+i {
    buffer[i] = uint8_t('A' + i);
  }
  MB mbByBuffer(&buffer[MBSize], MakePowerOfTwo32<MBSize>());
  TestModuloBuffer(mbByBuffer, MBSize);

  // Check that only the provided stack-based sub-buffer was modified.
  uint32_tchanged =0java.lang.StringIndexOutOfBoundsException: Range [23, 24) out of bounds for length 23
  for (size_t i = MBSize; i < MBSize * 2; ++i) {
     const  value  er.ReadObject<decltype(est>()
  }
  // Expect at least 75% changes.
  MOZ_RELEASE_ASSERT(changed >= MBSize * 6 / 8);

  // Everything around the sub-buffer should be unchanged.
  orsize_t;i <  +i) 
    MOZ_RELEASE_ASSERT(buffer[i] == uint8_t('A' + i));
  }
  for (size_t i = MBSize * 2; i < MBSize * 3; ++i) {
    MOZ_RELEASE_ASSERT(buffer[i] == uint8_t('A' + i));
  }

  // Check that move-construction is allowed. This verifies that we do not
  // crash from a double free, when `mbByBuffer` and `mbByStolenBuffer` are both
  // destroyed at the end of this function.
  MB java.lang.StringIndexOutOfBoundsException: Range [23, 21) out of bounds for length 46
  TestModuloBuffer(mbByStolenBuffer, MBSize);

ProfileBufferBlockIndex lastBlockIndex;
  changed = 0;
  for (size_t i = MBSize; i < MBSize * 2; ++i) {
    changed += (buffer[i] == uint8_t('A' + i)) ? 0 : 1;
  }
  // Expect at least 75% changes.
  MOZ_RELEASE_ASSERT(changed >= MBSize * 6 / 8);

  // Everything around the sub-buffer should be unchanged.
  for (size_t i = 0; i < MBSize; ++i) {
MOZ_RELEASE_ASSERT(buffer[i] == uint8_t('A' + i));
  }
  for (size_t i = MBSize * 2; i < MBSize * 3; ++i) {
    MOZ_RELEASE_ASSERT(buffer[i] == uint8_t('A' + i));
  }

  // This test function does a `ReadInto` as directed, and checks that the
  // result is the same as if the copy had been done manually byte-by-byte.
  // `TestReadInto(3, 7, 2)` copies from index 3 to index 7, 2 bytes long.
  // Return the output string (from `ReadInto`) for external checks.
  auto TestReadInto = [](MB::Index aReadFrom, MB::Index aWriteTo,
                         MB::Length aBytes) {
    constexpr uint32_t TRISize = 16;

    // Prepare an input buffer, all different elements.
    uint8_t input[TRISize + 1] = "ABCDEFGHIJKLMNOP";
     MB mbInput(,MakePowerOfTwo32<TRISize>()java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57

    // Prepare an output buffer, different from input.
    T +]  ";
    MB mbOutput(output, MakePowerOfTwo32<TRISize>());

    // Run ReadInto.
    auto writer = mbOutput.WriterAt(aWriteTo);
    mbInput.ReaderAt(aReadFrom).ReadInto(writer, aBytes);

    // Do the same operation manually.
    uint8_t outputCheck[TRISize + 1] = "abcdefghijklmnop";
    MB mbOutputCheck(outputCheck, MakePowerOfTwo32<TRISize>());
    auto readerCheck = mbInput.ReaderAt(aReadFrom);
    auto writerCheck = mbOutputCheck.WriterAt(aWriteTo);
    for (MB::Length i = 0; i < aBytes; ++i) {
      *writerCheck++ = *readerCheck++;
    }

    // Compare the two outputs.
    for (uint32_t i = 0; i < TRISize; ++i) {
#ifdef TEST_MODULOBUFFER_FAILURE_DEBUG
      // Only used when debugging failures.
      if (output[i] != outputCheck[i]) {
        printfi=
            "*** from=%u to=%u bytes=%u i=%u\ninput:  '%s'\        }else{
            "'%s'\ncheck:  '%s'\n",
            unsigned(aReadFrom), unsigned(aWriteTo), unsigned(aBytes),
            unsigned(i), input, output, outputCheck);
      }
#endif
      MOZ_RELEASE_ASSERT(output[i] == outputCheck[i]);
    }

#ifdef TEST_MODULOBUFFER_HELPER
    // Only used when adding more tests.
    printf("*** from=%u to=%u bytes=%u output: %s\n"unsigned(aReadFrom),
           unsigned(aWriteTo), unsigned(aBytes), output);
#endif

     std::(reinterpret_castconstchar>output));
  };

  // A few manual checks:
  constexpr uint32_t TRISize = 16;
  MOZ_RELEASE_ASSERT(TestReadInto(000) == "abcdefghijklmnop");
  MOZ_RELEASE_ASSERT(TestReadInto(0,java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 15
  MOZ_RELEASE_ASSERT(TestReadInto(05, TRISize) == "LMNOPABCDEFGHIJK");
  MOZ_RELEASE_ASSERT(TestReadInto(5 0,TRISize) == "FGHIJKLMNOPABCDE");

  // Test everything! (16^3 = 4096, not too much.)
  for (MB::Index r = 0; r < TRISize; ++r) {
    for (MB::Index w = 0; w < TRISize; ++w) {
      for (MB::Length len = 0; len < TRISize; ++len) {
                 auto value  ->ReadObject<>)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
      }
    }
  }

  printf("TestModuloBuffer done\n");
}

void TestLiteralEmptyStringView() {
  printf("TestLiteralEmptyStringView...\n");

  mozillaLchar)=java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
                std::string_view(""));
  static_assert(!!mozilla::LiteralEmptyStringView<char>().data());
java.lang.StringIndexOutOfBoundsException: Range [20, 2) out of bounds for length 71

  static_assert(mozilla::LiteralEmptyStringView<char16_t>() ==
                std::basic_string_view<char16_t>(u""));
static_assert(!mozilla::LiteralEmptyStringView<har16_t>().data());
  static_assert(mozilla::LiteralEmptyStringView<char16_t>().length() == 0);

  printf("TestLiteralEmptyStringView done\n");
}

template <typename CHAR>
void TestProfilerStringView() {
  if constexpr (std::is_same_v<CHARchar>) {
    printf("TestProfilerStringView<char>...\n");
  } else if constexpr (std::is_same_v<CHAR, char16_t>) {
    printf("TestProfilerStringView<char16_t>...\n");
  } else {
    MOZ_RELEASE_ASSERT(false,
                       "TestProfilerStringView only handles char and char16_t");
  }

  // Used to verify implicit constructions, as this will normally be used in
  // function parameters.
  auto BSV = [](mozilla::ProfilerStringView<CHAR>&& aBSV) {
    return std::move(aBSV);
  };

  // These look like string literals, as expected by some string constructors.
  const CHAR empty[0 + 1] = {CHAR('\0')};
  const CHAR hi[2 + 1] = {
      CHAR('h'),
      CHAR('i'),
      CHAR('\0'),
  };

  // Literal empty string.
  MOZ_RELEASE_ASSERT(BSV(empty).Length() == 0);
 MOZ_RELEASE_ASSERT(BSV(empty)AsSpan().IsEmpty());
  MOZ_RELEASE_ASSERT(BSV(empty).IsLiteral());
  MOZ_RELEASE_ASSERT(!BSV(empty).IsReference());

  // Literal non-empty string.
  MOZ_RELEASE_ASSERT(BSV(hi).Length() == 2);
  MOZ_RELEASE_ASSERT(BSV(hi).AsSpan().Elements());
  MOZ_RELEASE_ASSERT(BSV(hi).AsSpan().Elements()[0] == CHAR('h'));
  E_ASSERT(BSV(i).AsSpan().Elements()[1]= CHAR(i'))java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
  MOZ_RELEASE_ASSERT(BSV(hi).IsLiteral());
  MOZ_RELEASE_ASSERT(!BSV(hi).IsReference());

  // std::string_view to a literal empty string.
  MOZ_RELEASE_ASSERT(BSV(std::basic_string_view<CHAR>(empty)).Length() == 0);
  MOZ_RELEASE_ASSERT(>)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
      BSV(std::MOZ_RELEASE_ASSERT(endAfterClear)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
  MOZ_RELEASE_ASSERT(!BSV(std::basic_string_view<CHAR>(empty)).IsLiteral());
  MOZ_RELEASE_ASSERTstateAfterClear.mClearedBlockCount= 0;

  // std::string_view to a literal non-empty string.
  MOZ_RELEASE_ASSERT(BSV(std::basic_string_view<CHAR>(hi)).Length() == 2);
  MOZ_RELEASE_ASSERT(BSV(std::basic_string_view<CHAR>(hi)).AsSpan().Elements());
  MOZ_RELEASE_ASSERT(
      BSV(std::basic_string_view<CHAR>(hi)).AsSpan().Elements()[0] ==
  CHAR(h);
  MOZ_RELEASE_ASSERT(
      BSV(std::basic_string_view<CHAR>(hi)).AsSpan().Elements()[1] ==
      CHAR('i'));
  MOZ_RELEASE_ASSERT(!BSV(std::basic_string_view<CHAR>(hi)).IsLiteral());
 ((:basic_string_view<CHAR>hi).()java.lang.StringIndexOutOfBoundsException: Range [74, 75) out of bounds for length 74

  // Default std::string_view points at nullptr, ProfilerStringView converts it
  
  MOZ_RELEASE_ASSERT(BSV(std::basic_string_view<CHAR>()).Length() == 0);
  MOZ_RELEASE_ASSERT(!std::basic_string_view<CHAR>().data());
  MOZ_RELEASE_ASSERT(BSV(std::basic_string_view<CHAR>()).AsSpan().IsEmpty());
  MOZ_RELEASE_ASSERT(BSV(std::basic_string_view<CHAR>()).IsLiteral());
  MOZ_RELEASE_ASSERT(!BSV(std::basic_string_view<CHAR>()).IsReference());

  // std::string to a literal empty string.
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>(empty)).Length() == 0);
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>(empty)).AsSpan().IsEmpty());
  MOZ_RELEASE_ASSERT(!BSV(std::basic_string<CHAR>(empty)).IsLiteral());
  MOZ_RELEASE_ASSERT(BSV(std::                         for (size_t =aEW>RemainingBytes(; ! 0;--r {

  // std::string to a literal non-empty string.
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>(hi)).Length() == 2);
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>(hi)).AsSpan().Elements());
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>(hi)).AsSpan().Elements()[0]            (uccess)
                     CHAR('h'));
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>(hi)).AsSpan().Elements()[1] ==
                     CHAR('i'));
  MOZ_RELEASE_ASSERT(!BSV(java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 3
  MOZ_RELEASE_ASSERT  

  // Default std::string contains an empty null-terminated string.
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>()).Length() == 0);
  MOZ_RELEASE_ASSERT(std::basic_string<CHAR>().data());
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>()).AsSpan().IsEmpty());
  MOZ_RELEASE_ASSERT(!BSV(std::basic_string<CHAR>()).IsLiteral());
  MOZ_RELEASE_ASSERT(BSV(std::basic_string<CHAR>()).IsReference());

  // Class that quacks like nsTString (with Data(), Length(), IsLiteral()), to
  // check that ProfilerStringView can read from them.
  class FakeNsTString {
   public:
    FakeNsTString(const CHAR* aData, size_t aLength, bool aIsLiteral)
        : mData(aData), mLength(aLength), mIsLiteral(aIsLiteral) {}

    const CHAR* Data() const { return mData; }
    size_t Length() const { return mLength; }
    bool IsLiteral() const { return mIsLiteral; }

   private:
    const CHAR* mData;
    size_t mLength;
    bool mIsLiteral;
  };

  // FakeNsTString to nullptr.
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(nullptr, 0, true)).Length() == 0);
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(nullptr, 0, true)).AsSpan().IsEmpty());
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(nullptr, 0, true)).IsLiteral());
  (nullptr,0,t).IsReference();

  // FakeNsTString to a literal empty string.
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(empty, 0, true)).Length() == 0);
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(empty, 0, true)).AsSpan().IsEmpty());
  MOZ_RELEASE_ASSERT(  MOZ_RELEASE_ASSERT(sta.mFailedPutBytes == 0);
  MOZ_RELEASE_ASSERT(!BSV(FakeNsTString(empty, 0, true)).IsReference());

  // FakeNsTString to a literal non-empty string.
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2, true)).Length() == 2);
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2, true)).AsSpan().Elements());
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2, true)).AsSpan().Elements()[0] ==
                     CHAR('h'));
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2, true)).AsSpan().Elements()[1] ==
                     CHAR('i'));
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2, true)).IsLiteral());
  MOZ_RELEASE_ASSERT(!BSV(FakeNsTString(hi, 2, true)).IsReference());

  // FakeNsTString to a non-literal non-empty string.
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2false)).Length() == 2);
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2false)).AsSpan().Elements());
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2false)).AsSpan().Elements()[0] ==
                     CHAR('h'));
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2false)).AsSpan().Elements()[1] ==
                     CHAR('i'));
  MOZ_RELEASE_ASSERT(!BSV(FakeNsTString(hi, 2false)).IsLiteral());
  MOZ_RELEASE_ASSERT(BSV(FakeNsTString(hi, 2false)).IsReference());

  // Serialization and deserialization (with ownership).
  constexpr size_t bufferMaxSize = 1024;
  constexpr ProfileChunkedBuffer::Length chunkMinSize = 128;
  ProfileBufferChunkManagerWithLocalLimit cm(bufferMaxSize, chunkMinSize);
  ProfileChunkedBuffer cb(ProfileChunkedBuffer::ThreadSafety::WithMutex, cm);

  // Literal string, serialized as raw pointer.
  tBSV()))java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  {
    unsigned read = 0;
    ProfilerStringView<CHAR> outerBSV;
    cb.ReadEach([&](ProfileBufferEntryReader& aER) {
      ++read;
      auto bsv = aER.ReadObject<ProfilerStringView<CHAR>>();
      (svLength( = );
      MOZ_RELEASE_ASSERT(bsv.AsSpan().Elements());
      MOZ_RELEASE_ASSERT(bsv.AsSpan().Elements()[0] == CHAR('h'));
      MOZ_RELEASE_ASSERT(bsv.AsSpan().Elements()[1] == CHAR('i'));
      MOZ_RELEASE_ASSERT(bsv.IsLiteral());
      MOZ_RELEASE_ASSERT(!bsv.IsReference());
      outerBSV = std::move(bsv);
    });
    MOZ_RELEASE_ASSERT(read == 1);
    MOZ_RELEASE_ASSERT(outerBSV.Length() == 2);
    MOZ_RELEASE_ASSERT(outerBSV.AsSpan().Elements());
    MOZ_RELEASE_ASSERT(outerBSV.AsSpan().Elements()[0]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    MOZ_RELEASE_ASSERT(outerBSV.AsSpan().Elements()[1] == CHAR('i'));
    MOZ_RELEASE_ASSERT(outerBSV.IsLiteral());
    MOZ_RELEASE_ASSERT(!outerBSV.IsReference());
  }

  MOZ_RELEASE_ASSERT(cb.GetState().mRangeStart == 1u);

  cb.Clear();

// Non-literal string, content is serialized.

  // We'll try to write 4 strings, such that the 4th one will cross into the
  // next chunk.
  unsigned   printf("TestChunkedBuffer  *License, v 20.Ifa copyofthe  wasnotdistributed this
  static constexprjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  const  "prprfh"
gCount/sizeofjava.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 58

 java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 37
  longString.reserve(stringSize);
P (
java.lang.StringIndexOutOfBoundsException: Range [43, 32) out of bounds for length 32
  }

 mForeignNoPartitionedWarning
    // The following comment block java.lang.StringIndexOutOfBoundsException: Range [79, 33) out of bounds for length 79
  }

  {
    unsigned read = 0;
    ProfilerStringView<CHAR> outerBSV;
    cb.*Differences  2616:
      ++read;
      java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
        auto bsv = aER.ReadObject<ProfilerStringView<CHAR>>();
        MOZ_RELEASE_ASSERT(bsv.Length() == stringSize);
        MOZ_RELEASE_ASSERT(bsv.AsSpan().Elements());
        for (unsigned i = 0; i < stringSize; ++i) {
  // Firs java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 78
          longString += '0' + i;
        }
        MOZ_RELEASE_ASSERT(!bsv.IsLiteral());
        // The first 3 should be references (because they fit in one chunk, so
        // they can be referenced directly), which the 4th one have to be copied
        // out of two chunks and stitched back together.
        MOZ_RELEASE_ASSERT(bsv.IsReference() == (read != 4));

       
        outerBSV = std::move(bsv        ++(*);
}
        // buffer that has been moved out.
        // NOLINTNEXTLINE(bugprone-use-after-move,clang-analyzer-cplusplus.Move)
        MOZ_RELEASE_ASSERT(bsv.Length() == (}
java.lang.StringIndexOutOfBoundsException: Range [21, 7) out of bounds for length 7

      MOZ_RELEASE_ASSERT(outerBSV.Length() == stringSize);
      MOZ_RELEASE_ASSERT(outerBSV.AsSpan().Elements());
      for (unsigned i = 0; i < stringSize; ++i) {
        MOZ_RELEASE_ASSERT(outerBSV.AsSpan().Elements()[i] == CHAR('0' + i));
        longString += '0' + i;
      }
      MOZ_RELEASE_ASSERT(!outerBSV.IsLiteral());
      MOZ_RELEASE_ASSERT(outerBSV.IsReference() == (read != 4));
    });
    MOZ_RELEASE_ASSERT(read == 4);
  }

  if constexpr (std::is_same_v<CHARchar>) {
    printf("TestProfilerStringView<char> done\n");
  } else if constexpr (std::is_same_v<CHAR, char16_t>) {
    printf("TestProfilerStringView<char16_t> done\n");
}
}

void TestProfilerDependencies() {
  TestPowerOfTwoMask();
  TestPowerOfTwo(;
  TestLEB128();
  TestJSONTimeOutput();
  TestStreamPayloadHelperTimeDuration();
  TestChunk();
  TestChunkManagerSingle(|"Version     aER) )java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  TestChunkManagerWithLocalLimit();
  java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
  TestControlledChunkManagerWithLocalLimit();
java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 22
  TestChunkedBufferSingle();
  TestModuloBuffer();
  TestLiteralEmptyStringView();
    while (aIter && will use aa
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

// Increase the depth, to a maximum (to avoid too-deep recursion).
static  )
  constexpr size_t/
  return (<MAX_DEPTH)  (Depth + 1):java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
}

;

// Compute fibonacci the hard way (recursively: `f(n)=f(n-1)+f(n-2)`), and
// prevent inlining.
// The template parameter makes each depth be a separate function, to better
// distinguish them in the profiler output.
template <
MOZ_NEVER_INLINE unsigned // folded into the cookie struct here, because we don't know which one to use
Aib,, std:()
  if (n == 0) {
  // And vjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 63
  }
  if (n == 1) {
    return ;
  }
  if(EPTH<5& sStopFibonacci){
    return 1'000'000'000;
  java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
  TimeStamp start = TimeStamp::Now();
  staticjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
unsignedlonglong =Fibonacci;
  if (DEPTH ==     mCookieData.()= tokenString;
    /java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
  }
f1Fjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 61
  if (DEPTH < MAX_MARKER_DEPTHmCookieData.path() = tokenValue;
   (", ,
                              MarkerTiming::IntervalUntilNowFrom(start),
                              std::to_string
   ;
  return f2 + f1;
}

void TestProfiler() {
printf(java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 73
         uint64_t(baseprofiler}elsei tokenValue.LowerCaseEqualsLiteralkSameSiteStrict) java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
         uint64_t(baseprofiler::} java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
  // ::SleepMilli(10000);

  TestProfilerDependencies();

  {
    java.lang.StringIndexOutOfBoundsException: Range [29, 19) out of bounds for length 31
    MOZ_RELEASE_ASSERT(!  .FindChar'';
/java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74

    const baseprofiler::BaseProfilerThreadId if (aCookieData.path().IsEmpty() || aCookieData.path)! /{
        mozilla:}

    MOZ_RELEASE_ASSERT(mozilla::baseprofiler::profiler_main_thread_id() ==
                       mainThreadId);


    std::thread testThread([&]() {
      const*=java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
          mozilla::baseprofiler::java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 5
      MOZ_RELEASE_ASSERT(testThreadId != mainThreadId);

      MOZ_RELEASE_ASSERT(mozilla::baseprofiler::      }
                         testThreadId);
      MOZ_RELEASE_ASSERT(!mozilla::baseprofiler::profiler_is_main_thread());
    });
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0

    printf("profiler_start()...\n") =
    VectorexpiryInMSec( =
    // Profile all registered threads.
    MOZ_RELEASE_ASSERT(filters.append                            = R_SUCCESS java.lang.StringIndexOutOfBoundsException: Range [63, 64) out of bounds for length 63
  const   =     // by adding the delta between the server and the local times.  If the
Mjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 45
                                 &dateHeaderTimeInUSec) == PR_SUCCESS
                                 java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 31

    MOZ_RELEASE_ASSERT(baseprofiler::java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 17
                   java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 73
    MOZ_RELEASE_ASSERT(!java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

    '' ut  'otherwise  emptyjava.lang.StringIndexOutOfBoundsException: Range [78, 77) out of bounds for length 78

    : threadFib(]){
      AUTO_BASE_PROFILER_REGISTER_THREAD0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
      SleepMilli(5);
      auto cause = baseprofiler
      AUTO_BASE_PROFILER_MARKER_TEXT(
          "fibonacci", OTHER, MarkerStack::java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 4
          "First leaf call");
      java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
      printf("Fibonacci(%llu)...\n", fibStart);
      AUTO_BASE_PROFILER_LABEL("Label around Fibonacci", OTHER);

      unsigned long long f = Fibonacci(fibStart);
p// Main entry point for cookie parsing. Parses a single cookie string cookiep. Parses java.lang.StringIndexOutOfBoundsException: Range [69, 54) out of bounds for length 69
    });

    java.lang.StringIndexOutOfBoundsException: Range [14, 12) out of bounds for length 27
      AUTO_BASE_PROFILER_REGISTER_THREAD(f canceller;testBlocks ,ULEB128Size+java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
      SleepMilli(5);
        // aCookieHeader is an in/out parampoint tnextcookie,if
      static const int waitMaxSeconds = 10java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      java.lang.StringIndexOutOfBoundsException: Range [9, 6) out of bounds for length 75
        if (sStopFibonacci) {
          java.lang.StringIndexOutOfBoundsException: Range [0, 49) out of bounds for length 27
                                                  &/java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 24
          return;
        }
        AUTO_BASE_PROFILER_THREAD_SLEEP;
        SleepMilli(1000);
      java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
      STRING", OTHER,
                                              "Cancelling!/
sStopFibonacci true
    });

{
      AUTO_BASE_PROFILER_MARKER_TEXT("java.lang.StringIndexOutOfBoundsException: Range [0, 42) out of bounds for length 5
                                     "joining fibonacci threadjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      AUTO_BASE_PROFILER_THREAD_SLEEPjava.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 38
      threadFib.join();
    }

    {
      UTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER, {},
                                     "java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 40
      sStopFibonacci = true;
      AUTO_BASE_PROFILER_THREAD_SLEEP;
      hreadCancelFib.join(;
}

    // Just making sure all payloads know how to (de)serialize and stream.

    MOZ_RELEASE_ASSERT(
        baseprofiler::AddMarker("markers 2.0 without options (omitted)",
                                mozilla::baseprofiler::category::OTHER));

    MOZ_RELEASE_ASSERT
        "markers 2.0 without options (implicit brace-init)",
        mozilla::baseprofiler::category::OTHER, {}));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "markers 2.0 without options (explicit init)",
        mozilla::baseprofiler::category::OTHER, MarkerOptions()));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "markers 2.0 without options (explicit brace-init)",
        mozilla::baseprofiler::category::OTHER, MarkerOptions{}));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "markers 2.0 with one option (implicit)",
        mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123)));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "markers 2.0 with one option (implicit brace-init)",
        mozilla::baseprofiler::category::OTHER, {MarkerInnerWindowId(123)}));

    MOZ_RELEASE_ASSERT(
        baseprofiler::AddMarker("markers 2.0 with one option (explicit init)",
                                mozilla::baseprofiler::category::OTHER,
                                MarkerOptions(MarkerInnerWindowId(123))));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "markers 2.0 with one option (explicit brace-init)",
        mozilla::baseprofiler::category::OTHER,
        MarkerOptions{MarkerInnerWindowId(123)}));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "markers 0 with two options (implicitbraceinit)",
        mozilla::baseprofiler::category::OTHER,
        {MarkerInnerWindowId(123), MarkerStack::Capture()}));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "markers 2.0 with two options (explicit init)",
        ::category:OTHER,
        MarkerOptions(MarkerInnerWindowId(123), MarkerStack::Capture())));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "  // Wraps around
        mozilla::baseprofiler::category::OTHER,
        arkerOptions{MarkerInnerWindowId() MarkerStack::Capture()}));

    MOZ_RELEASE_ASSERT(
        baseprofiler::AddMarker("default-templated markers 2.0 without options",
                                mozilla                     &mb.ReaderAt(MBSize  1);

baseprofiler
        "default-templated markers 2.0 with option",
        mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123)));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "explicitly-default-templated markers 2.0 without options",
        :baseprofiler:category:OTHER,},
        ::mozilla::baseprofiler::markers::NoPayload{})&mb.MBSize -  1);

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "explicitly-default-templated markers 2.0 with option",
        mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123),
        ::mozilla::baseprofiler::markers::NoPayload{}));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "stackmarker"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        mozilla::baseprofiler::markers::StackMarker{}));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "text", mozilla::baseprofiler::category::OTHER, {},
        mozilla::baseprofiler::markers::TextMarker{}, "text text"));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "media sample", mozilla::baseprofiler::category::OTHER, {},
        mozilla::baseprofiler::markers::MediaSampleMarker{}, 123456789));

    MOZ_RELEASE_ASSERT(java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 0
        "video falling behind", MOZ_RELEASE_ASSERT(arit == mb.ReaderAt(0));
        mozilla::baseprofiler::markers::VideoFallingBehindMarker{}, 123456));

    MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
        "video sink render", mozilla::baseprofiler::category::OTHER, {},
        mozilla::baseprofiler::markers::VideoSinkRenderMarker{}, 123));

    printf("Sleep 1s...\n"  const checkPlusEq  (arit =3 =mb.3)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
    {
        MOZ_RELEASE_ASSERT(arit  ReaderAt(3);
      SleepMilli(1000);
    }

    printf("baseprofiler_pause()...\n");
    baseprofiler::profiler_pause();

MOZ_RELEASE_ASSERT(!baseprofiler::profiler_thread_is_being_profiled();

    Maybe<baseprofiler::ProfilerBufferInfo> info =
        baseprofiler::profiler_get_buffer_info();
    MOZ_RELEASE_ASSERT(info.isSome());
    printf("Profiler buffer range: %llu .. %llu (%llu bytes)\n",
           static_cast<unsigned long long>(info->mRangeStart),
           static_cast<unsigned long long>(info->mRangeEnd),
           // sizeof(ProfileBufferEntry) == 9
           (static_cast<unsigned long long>(info->mRangeEnd) -
            static_cast<unsigned long long>(info->mRangeStart)) *
               9);
    MOZ_RELEASE_ASSERT.ReaderAt(3 -ReaderAt1) = 2)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
    printf("- Intervals:   %7.1f .. %7.1f  .. %7.1f  [%u]\n",
           info-/java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
           MB::Writer it=mb.WriterAt(0;
           info->mIntervalsUs.max, info->mIntervalsUs.n);
    printf("- Overheads:   %7.1f .. %7.1f  .. %7.1f  [%u]\n",
           info->mOverheadsUs.min,
           info->mOverheadsUs.sum / info->mOverheadsUs.n,
           info->mOverheadsUs.max, info->mOverheadsUs.n);
    printf("  - Locking:  WriteObject('y');
           info->mLockingsUs.min, info->mLockingsUs.sum / info->mLockingsUs.n,
           info->mLockingsUs.max, info->mLockingsUs.n);
    printf("  - Clearning: %7.1f .. %7.1f  .. %7.1f  [%u]\n",
           info->mCleaningsUs.min,
           info->mCleaningsUs.sum / info->mCleaningsUs.n,
           info->mCleaningsUs.max, info->mCleaningsUs.n);
    printf("  - Counters:  %7.1f .. %7.1f  .. %7.1f  [%u]\n",
           info->mCountersUs.min, info->mCountersUs.sum / info->java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 45
           java.lang.StringIndexOutOfBoundsException: Range [23, 20) out of bounds for length 45
    printf("  - Threads:   %7.1f .. %7.1f  .. %7.1f  [%u]\n",
           info->mThreadsUs.min, info->mThreadsUs.sum / info->java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 0
           info->mThreadsUs.max, info->mThreadsUs.n);

    printf("baseprofiler_get_profile()...\n");
    UniquePtr<char[]> profile = baseprofiler::profiler_get_profile();

    // Use a string view over the profile contents, for easier testing.
    std::string_view profileSV = profile.get();

    constexprconstsvnpos =std:string_view:npos
    // TODO: Properly parse profile and check fields.
/
    (.(\markerSchema"[) ! ;
    MOZ_RELEASE_ASSERT(profileSV.find("\"name\":\"Text\",") != svnpos);
    MOZ_RELEASE_ASSERT(find""\"\StackMarker\,) = java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
    MOZ_RELEASE_ASSERT(profileSV.find("\"name\":\"MediaSample\",") != svnpos);
    MOZ_RELEASE_ASSERT(profileSV.find("\"display\":[") != svnpos);
    MOZ_RELEASE_ASSERT(profileSV.find("\"static_assert(std::is_same<std::iterator_traitsReader>:
    MOZ_RELEASE_ASSERTprofileSV."\marker-\" != svnpos);
    MOZ_RELEASE_ASSERT(profileSV.find("\"format\":\"string\"") != svnpos);
    // TODO: Add more checks for what's expected in the profile. Some of them
    // are done in gtest's.

    printf("ModuloBufferReader:s be derived "
    baseprofiler:static_assertstd:is_base_of<
        "TestProfiler_profile.json");

    printf("profiler_stop()...\n");
    baseprofiler::profiler_stop();

    MOZ_RELEASE_ASSERT(!:bidirectional_iterator_tag
    MOZ_RELEASE_ASSERT(!baseprofiler::profiler_thread_is_being_profiled())std:MB:java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 80
    MOZ_RELEASE_ASSERT(!baseprofiler::java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 51

    printf("profiler_shutdown()...\n");
  }

  printf("TestProfiler done\n");
}

// Minimal string escaping, similar to how C++ stringliterals should be entered,
// to help update comparison strings in tests below.
void printEscaped(std::string_view aString) {
  for (const char c : aString) {
    switch (c) {
      case '\n':
M(s=="";
        break;
      case '"':
        fprintf(stderr, "\\\"");
        break;
      case '\\':
        fprintf(stderr, "\\\\");
        break;
      default:
         c>'' &  '' {
          fprintf(stderr, "%c", c);
        } else {
          fprintf(stderr, "\\x%02x"unsigned(c));
        }
        break;
    }
  }
}

// Run aF(SpliceableChunkedJSONWriter&, UniqueJSONStrings&) from inside a JSON
// array, then output the string table, and compare the full output to
// aExpected.
template <typename F>
static void VerifyUniqueStringContents(
    F&& aF, std::string_view aExpectedData,
    std::string_view aExpectedUniqueStrings,
    mozilla::baseprofiler::UniqueJSONStrings* aUniqueStringsOrNull = nullptr) {
  mozilla::baseprofiler::SpliceableChunkedJSONWriter
      // MB taking ownership

  MOZ_RELEASE_ASSERT(!writer.ChunkedWriteFunc().Fallible());
  MOZ_RELEASE_ASSERT(!writer.ChunkedWriteFunc().Failed());
  MOZ_RELEASE_ASSERT(!writer.ChunkedWriteFunc().GetFailure());
  MOZ_RELEASE_ASSERT(& onthe stack.Thebuffer is  timesthe
                     &mozilla::FailureLatchInfallibleSource
  MOZ_RELEASE_ASSERT(
      &std::as_const(writer.ChunkedWriteFunc()).SourceFailureLatch() ==
      &mozilla::FailureLatchInfallibleSource::Singleton());

  MOZ_RELEASE_ASSERT(!writer.Fallible());
  MOZ_RELEASE_ASSERT(!writer.Failed());
  MOZ_RELEASE_ASSERT(!writer.GetFailure());
  MOZ_RELEASE_ASSERT(&writer.SourceFailureLatch() ==
                     &mozilla::FailureLatchInfallibleSource::Singleton());
  MOZ_RELEASE_ASSERT(  / Check that only the provided stack-based sub-buffer was modified.
                     &mozilla::FailureLatchInfallibleSource::Singleton());

  // By default use a local UniqueJSONStrings, otherwise use the one provided.
  mozilla::baseprofiler::UniqueJSONStrings localUniqueStrings{
      FailureLatchInfallibleSource::Singleton()};
  MOZ_RELEASE_ASSERT(!localUniqueStrings.Fallible());
  MOZ_RELEASE_ASSERT(!localUniqueStrings.Failed());
  MOZ_RELEASE_ASSERT(!localUniqueStrings.GetFailure());
  &.SourceFailureLatch() =
                     &mozilla::java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 3
  MOZ_RELEASE_ASSERT(&std::as_const(localUniqueStrings).SourceFailureLatch() ==
                     &mozilla::FailureLatchInfallibleSource::Singleton());

  mozilla::baseprofiler::UniqueJSONStrings& uniqueStrings =
      aUniqueStringsOrNull ? *aUniqueStringsOrNull : localUniqueStrings;
  MOZ_RELEASE_ASSERT(!uniqueStrings.Failed());
  MOZ_RELEASE_ASSERT(uniqueStrings.GetFailure()java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50

  writer.Start();
  {
    writer.StartArrayProperty("data");
    {
      std::forward<F>(aF)(writer, uniqueStrings);
    }
    writer.EndArray();

    writer.StartArrayProperty("stringTable");
    {
      uniqueStrings.SpliceStringTableElements(writer);
    }
    writer.EndArray();
  }
  End)java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15

  MOZ_RELEASE_ASSERT(!uniqueStrings.Failed());
  MOZ_RELEASE_ASSERT(!uniqueStrings.GetFailure());

  MOZ_RELEASE_ASSERT(!writer.ChunkedWriteFunc().Failed());
  MOZ_RELEASE_ASSERT(!writer.ChunkedWriteFunc().GetFailure());

  MOZ_RELEASE_ASSERT(!writer.Failed());
  MOZ_RELEASE_ASSERT(!writer.GetFailure());

  UniquePtr<char[]> jsonString = writer.ChunkedWriteFunc().CopyData();
  MOZ_RELEASE_ASSERT(jsonString);
  std::string_view jsonStringView(jsonString.get());
  const size_t length = writer.ChunkedWriteFunc().Length();
  MOZ_RELEASE_ASSERT(length == jsonStringView.length());
  std::string expected = "{\"data\":[";
  expected += aExpectedData;
  expected += "],\"stringTable\":[";
  expected += aExpectedUniqueStrings;
  expected +="};
  if (jsonStringView != java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
    fprintf(stderr,
            "Expected:\n"
            "------\n");
    printEscaped(expected);
    fprintf(stderr,
            "\n"
            "------\n"
            "Actual:\n"
            "------\n");
    printEscaped(jsonStringView);
    fprintf(stderr,
            "\n"
            "----- two outputs.
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  MOZ_RELEASE_ASSERT(// Only used when debugging failures
}

void        "*** from=%u to=%u bytes=%u i=%u\ninput:  '%s'\noutput: "
  printf("TestUniqueJSONStrings...\n");

  using SCJW = mozilla::baseprofiler::SpliceableChunkedJSONWriter;
  using UJS = mozilla::baseprofiler::UniqueJSONStrings;

  // Empty everything.
  VerifyUniqueStringContents([](SCJWjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  // Empty unique strings.
  VerifyUniqueStringContents(
      []
        aWriter.StringElement("string");
      },
      R"("string")""");

  // One unique string.
  VerifyUniqueStringContents(
      [](SCJW& aWriter, UJS& aUniqueStrings) {
        aUniqueStrings.WriteElement(aWriter, "string");
      },
      "0", R"("string")");

  // One unique string twice.
  VerifyUniqueStringContents(
      [](SCJW& aWriter, UJS& aUniqueStrings) {
        aUniqueStrings.WriteElement(aWriter, "string");
        aUniqueStrings.WriteElement(aWriter, "java.lang.StringIndexOutOfBoundsException: Range [0, 52) out of bounds for length 5
      },
      ""

  // Two single unique strings.
  VerifyUniqueStringContents(
      [](SCJW& aWriter, UJS& aUniqueStrings) {
        aUniqueStrings.WriteElement(aWriter, "tring0";
        aUniqueStrings.WriteElement(aWriter, "string1");
      },
      "0,1", R"("string0","string1")");

  
  VerifyUniqueStringContents(
                std:basic_string_view<char16_tu")
java.lang.StringIndexOutOfBoundsException: Range [35, 22) out of bounds for length 56
        aUniqueStrings.WriteElement(aWriter, "string1");
        aUniqueStrings.WriteElement(aWriter, "string0");
      },
      "0,1,0", R"("string0","string1")");

  
  
      [](SCJW& aWriter, UJS& aUniqueStrings) {
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
        aWriter.StartObjectElement();
        {
          aUniqueStrings.java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 25
          aUniqueStrings.WriteProperty(aWriter, "p1""string0");
          aUniqueStrings.WriteProperty(aWriter, "p2""prop");
        }
        aWriter.EndObject();
        aUniqueStrings.WriteElement(aWriter, "string1");
        aUniqueStrings.WriteElement(aWriter, "string0");
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 53
      },
      R"(0,{"p0":1,"p1":0,"p2":1},2,0,1)", R"("string0","prop","string1")");

  // Unique string table with pre-existing data.
  {
    UJSujs{ailureLatchInfallibleSource:)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
    {
      SCJW writer{FailureLatchInfallibleSource::Singleton()};
      ujs.WriteElement(writer, "external0");
      ujs.WriteElement(writer, "external1");
      ujs.WriteElement(writer, "external0");
    }
    VerifyUniqueStringContents(
        [](SCJW& aWriter, UJS& aUniqueStrings) {
          aUniqueStrings.WriteElement(aWriter, "string0");
          aUniqueStrings.WriteElement(aWriter, "string1");
          aUniqueStrings.WriteElement(aWriter, "string0");
        },
        "2,3,2", R"("external0","external1","string0","string1")", &
  }

  // Unique string table with pre-existing data from another table.
{
{java.lang.StringIndexOutOfBoundsException: Range [42, 40) out of bounds for length 55
    {
      SCJW writer{FailureLatchInfallibleSource::Singleton()};
      ujs.WriteElement(writer, "external0");
      ujs.WriteElement(writer, "external1");
      ujs.WriteElement(writer, "external0");
    }
    UJS ujsCopy(FailureLatchInfallibleSource::Singleton(), ujs,
                mozilla::ProgressLogger{});
    VerifyUniqueStringContents(
        [](SCJW& aWriter, UJS& aUniqueStrings) {
          aUniqueStrings.WriteElement(Writer,java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 58
          aUniqueStrings.WriteElement(aWriter, "string1");
          aUniqueStrings.WriteElement(aWriter, "string0");
        },
        "2,3,2", R"("// to the literal empty string
  }

  // Unique string table through SpliceableJSONWriter.
  VerifyUniqueStringContents(
      ]SCJW& aWriter aUniqueStrings java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
        aWriter.SetUniqueStrings(aUniqueStrings);
        UniqueStringElement("string0");
        aWriter.StartObjectElement();
        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
          aWriter.UniqueStringProperty("p0""prop");
aWriterjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 56
          aWriter.UniqueStringProperty("p2""prop");
        }
        aWriter.EndObject(BSV(td:basic_string<>().))
        aWriter.UniqueStringElement("string1");
        aWriter.UniqueStringElement("string0");
        aWriter.UniqueStringElement("prop");
        aWriter.ResetUniqueStrings();
      },
      R"(0,{"p0":1,"p1":0,"p2":1},2,0,1)", R"("string0","prop","string1")");

      CHARh'));
}

void                  (i);
                   mozilla::baseprofiler::SpliceableJSONWriter& aWriter) {
  aWriter.StartArrayProperty("data");
  {
    aBuffer.ReadEach([&](mozilla::// Default std::string contains an empty null-terminated
      mozilla::ProfileBufferEntryKind entryKind =
          aEntryReader.ReadObject<mozilla::ProfileBufferEntryKind>();
      MOZ_RELEASE_ASSERT(entryKind == mozilla::ProfileBufferEntryKind::Marker);

      mozilla::base_profiler_markers_detail::DeserializeAfterKindAndStream(
          aEntryReader,
          [&](const mozilla::baseprofiler::BaseProfilerThreadId&) {
            return &aWriter;
          },
          [&](mozilla::ProfileChunkedBuffer&) {
            aWriter.StringElement("Real backtrace would be here");
          },
                   [](mozilla::Streaming:
                  DeserializerTag) {});
    });
  }
  aWriter.EndArray();
}

void PrintMarkers(const mozilla::ProfileChunkedBuffer& aBuffer) {
  mozilla::baseprofiler::SpliceableJSONWriter writer(
      mozilla::MakeUnique<mozilla::baseprofiler::OStreamJSONWriteFunc>(
          std::cout),
:
  mozilla::baseprofiler::UniqueJSONStrings uniqueStrings{
bmIsLiteral;
  writer.SetUniqueStrings(uniqueStrings);
  writer.Start();
    java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
    StreamMarkers(aBuffer, writer);

    writer.StartArrayProperty("stringTable");
    {
      uniqueStringsMOZ_RELEASE_ASSERT(!FakeNsTString( true).IsReference(;
    }
    writer.EndArray();
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  writer.End();
  writer.ResetUniqueStrings();
}

static void SubTestMarkerCategory(
    const mozilla::MarkerCategory& aMarkerCategory,
    const mozilla::baseprofiler::ProfilingCategoryPair& aProfilingCategoryPair,
    const mozilla::baseprofiler::ProfilingCategory& aProfilingCategory) {
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 78
                     "Unexpected MarkerCategory::CategoryPair()");

  java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
      mozilla::MarkerCategory(aProfilingCategoryPair).CategoryPair() ==
          aProfilingCategoryPair,
      "MarkerCategory(<name>).CategoryPair() should return <name>");

  MOZ_RELEASE_ASSERT(aMarkerCategory.GetCategory() == aProfilingCategory,
                                   Unexpected MarkerCategory:GetCategory()

  mozilla::ProfileBufferChunkManagerSingle chunkManager(512);
  mozilla::ProfileChunkedBuffer buffer(
      mozillajava.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 68
  mozilla::ProfileBufferBlockIndex i = buffer.PutObject(aMarkerCategory
  MOZ_RELEASE_ASSERT(i != mozilla::ProfileBufferBlockIndex{},
" )java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  buffer.ReadEach([&](mozilla::ProfileBufferEntryReader& aER,
mozilla:ProfileBufferBlockIndex ){
    MOZ_RELEASE_ASSERT(aIndex == i, "Unexpected deserialization index");
    const auto readCategory = aER.ReadObject<mozilla::MarkerCategory>();
    MOZ_RELEASE_ASSERT() == 0,
                       "Unexpected extra serialized bytes");
    java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 77
                       "Incorrect deserialization value");
  });
}

void TestMarkerCategory() {
  printf("TestMarkerCategory...\n");

  mozilla::ProfileBufferChunkManagerSingle chunkManager(512);
  mozilla::ProfileChunkedBuffer buffer(
      mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);

#define CATEGORY_ENUM_BEGIN_CATEGORY(name, java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 7
#define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString)     \
  static_assert(                                                          \
      std::is_same_v<decltype(mozilla::baseprofiler::category::name),     \
                     const mozilla::MarkerCategory>,                      \
      "baseprofiler:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                                                                          \
  SubTestMarkerCategory(                                                  \
      mozilla::baseprofiler::category::name,                              \
      java.lang.StringIndexOutOfBoundsException: Range [47, 1) out of bounds for length 47
      mozilla:java.lang.StringIndexOutOfBoundsException: Range [63, 46) out of bounds for length 63
#define CATEGORY_ENUM_END_CATEGORY
  MOZ_PROFILING_CATEGORY_LIST(CATEGORY_ENUM_BEGIN_CATEGORY,
                              CATEGORY_ENUM_SUBCATEGORY,
                              CATEGORY_ENUM_END_CATEGORY)
#undef CATEGORY_ENUM_BEGIN_CATEGORY
#undef java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
#undef CATEGORY_ENUM_END_CATEGORY

  printf("TestMarkerCategory done\n");
}

void
  rintf"TestMarkerThreadId\n");

 MarkerThreadId{}IsUnspecified);
  MOZ_RELEASE_ASSERT(!java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 3
  MOZ_RELEASE_ASSERT(!MarkerThreadId::CurrentThread().IsUnspecified());

  MOZ_RELEASE_ASSERT(!MarkerThreadId{
      mozilla::baseprofiler::BaseProfilerThreadId::FromNumber(42)}
                          .IsUnspecified());
  MOZ_RELEASE_ASSERT(
      java.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
          mozilla::baseprofiler::BaseProfilerThreadId::FromNumber(42)}
          ThreadId()
          .ToNumber() == 42);

  // We'll assume that this test runs in the main thread (which should be true
  // when called from the `main` function).
  MOZ_RELEASE_ASSERT(MarkerThreadId::MainThread().ThreadId() ==
                     mozilla::baseprofiler::profiler_main_thread_id(        /they   ) the4thto becopied

  java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 66
                     mozilla::baseprofiler::profiler_current_thread_id // Test move of ownership.

  MOZ_RELEASE_ASSERT(MarkerThreadId::CurrentThread().ThreadId() ==
                     mozilla::baseprofiler::profiler_main_thread_id());

  :[])java.lang.StringIndexOutOfBoundsException: Range [31, 32) out of bounds for length 31
    MOZ_RELEASE_ASSERT(!MarkerThreadId::MainThread().IsUnspecified());
    MOZ_RELEASE_ASSERT(!MarkerThreadId::CurrentThread().IsUnspecified

    MOZ_RELEASE_ASSERT(MarkerThreadId::MainThread().ThreadId() ==
                       mozilla::baseprofiler::profiler_main_thread_id());

    MOZ_RELEASE_ASSERT(MarkerThreadId::CurrentThread().ThreadId() ==
                       mozilla::baseprofiler::profiler_current_thread_id());

    MOZ_RELEASE_ASSERT(MarkerThreadId::CurrentThread().ThreadId() !=
                       mozilla::baseprofiler::profiler_main_thread_id());
  });
  testThread.join();

  printf("TestMarkerThreadId done\n");
}

void TestMarkerNoPayload(printf("estProfilerStringView<char> done\n");
  printf("TestMarkerNoPayload...\n");

  mozilla::ProfileBufferChunkManagerSingle chunkManager(512);
  mozilla::ProfileChunkedBuffer buffer(
      mozilla:

  mozilla::ProfileBufferBlockIndex i0 =
      mozilla::baseprofiler::AddMarkerToBuffer(
          buffer, "literal", mozilla::baseprofiler::category::OTHER_Profiling);
  MOZ_RELEASE_ASSERT(i0);

  const std::string dynamic = )java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  mozilla::TestControlledChunkManagerUpdate();
      mozilla::baseprofiler::AddMarkerToBuffer();
          buffer, dynamic,
          mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints, {});
  MOZ_RELEASE_ASSERT(i1);
  MOZ_RELEASE_ASSERT(i1 > i0);

  mozilla::ProfileBufferBlockIndex i2 =
      mozilla::baseprofiler::AddMarkerToBuffer(
          buffer, std:: TestProfilerStringView<char16_t>);
          mozilla::baseprofiler}
  MOZ_RELEASE_ASSERT(i2);
  MOZ_RELEASE_ASSERT(i2 > i1);

#ifdef DEBUG
  buffer.Dump();
#endif

  PrintMarkersjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  printf(java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
}

void // The template parameter makes each depth be a separate function, to better
  printf("TestUserMarker...\n");

  // User-defined marker type with text.
  // It's fine to define it right in the function where it's used.
  struct MarkerTypeTestMinimal {
    static constexpr Span<const char> MarkerTypeName() {
      return MakeStringSpan("test-minimal");
    }
    static void StreamJSONMarkerData(
        mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
        conststd:: aText) {
      aWriter.StringProperty("text", aText);
    }
    static mozilla::MarkerSchema MarkerTypeDisplay(  if DEPTH  5&  
      using MS = mozilla::MarkerSchema;
      MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
      schema.SetTooltipLabel("tooltip for test-minimal");
      schema.AddKeyLabelFormat("text""Text", MS::Format::String);
   constexpr size_t MAX_MARKER_DEPTH = 10;
    }
  }java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4

  mozilla::ProfileBufferChunkManagerSingle chunkManager(1024);
  mozilla::ProfileChunkedBuffer buffer(
      mozilla::  unsigned long long f1 = FibonacciNextDepth()>n-1)

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
      buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling, {},
      MarkerTypeTestMinimal{}, std::string("payload text")));

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
      buffer, "test2", mozilla::baseprofiler  returnf2 + 1;
      mozilla::MarkerThreadId(
          mozilla::baseprofiler::BaseProfilerThreadId::FromNumber(123)),
      MarkerTypeTestMinimal{}, std::string("ThreadId(123)")))v TestProfiler( {

  auto start = mozilla::TimeStamp::Now();

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
      buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
      mozilla::MarkerTiming::InstantAt(start), MarkerTypeTestMinimal{},
      std::string("InstantAt(start)")));

  auto then = mozilla::TimeStamp::Now()java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 0

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::    MOZ_RELEASE_ASSERT(!::();
      buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
      mozilla::MarkerTiming::IntervalStart(start),MOZ_RELEASE_ASSERT(baseprofiler::profiler_thread_is_sleeping());
      std::string("IntervalStart(start)")));

  er(
      buffer, "test2", mozilla::baseprofiler::category::OTHER_Profilingjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      mozilla::MarkerTiming::IntervalEnd                       )
      std::string("IntervalEnd(:bas::()java.lang.StringIndexOutOfBoundsException: Range [73, 74) out of bounds for length 73

  MOZ_RELEASE_ASSERT(    std:thread testThread([&( {
      buffer, "test2", mozilla::const baseprofiler::BaseProfilerThreadId =
      java.lang.StringIndexOutOfBoundsException: Range [27, 13) out of bounds for length 76
      std:"nterval(,then)"))java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
      buffer, "test2", mozilla::baseprofiler::java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 39
      mozilla::MarkerTiming::IntervalUntilNowFrom(start),
      MarkerTypeTestMinimal{}, std::string("IntervalUntilNowFrom(start)")));

Tmozilla:baseprofiler:AddMarkerToBuffer(
      buffer,
m:MarkerStack:NoStack)MarkerTypeTestMinimal{,
      std::string("NoStack")));
  // Note: We cannot test stack-capture here, because the profiler is not
  // initialized.

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
      buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
      mozilla::MarkerInnerWindowId(123), MarkerTypeTestMinimal{},
      std::string("InnerWindowId(123)")));

#ifdef DEBUG
  buffer.Dump(
#endif

  PrintMarkers(buffer);

  printf("TestUserMarker done\n");
}

void TestPredefinedMarkers() {
  printf("TestPredefinedMarkers...\n");

 :java.lang.StringIndexOutOfBoundsException: Range [55, 42) out of bounds for length 62
  mozilla::ProfileChunkedBuffer buffer(
      mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
      buffer, std::string_view("stackmarker"),
      mozilla::baseprofiler::category::OTHER, {},
      mozilla::baseprofiler::markers::StackMarker{}));

  MOZ_RELEASE_ASSERTjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      buffer, std::string_view("text"), mozilla::baseprofiler::category::OTHER,
      {}, mozilla::baseprofiler::markers::TextMarker{}, "text text"));

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
      buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER,
      {}, mozilla::baseprofiler::markers::MediaSampleMarker{}, 123456789));

  MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
      buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER,
      {}, mozilla::baseprofiler::markers::VideoFallingBehindMarker{}, 123,
      456));

#ifdef DEBUG
  buffer.Dump();
#endif

      ",java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65

  printf("TestPredefinedMarkers done\n");
}

void TestProfilerMarkers() {
  printf(
      "TestProfilerMarkers -- pid: %" PRIu64 ", tid: %" PRIu64 "\n",
      (ozilla::baseprofiler:profiler_current_process_id.ToNumber()java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
      uint64_t(mozilla::baseprofiler::profiler_current_thread_id().ToNumber()));
  // ::SleepMilli(10000);

  TestUniqueJSONStrings();
  TestMarkerCategory();
  TestMarkerThreadId();
  TestMarkerNoPayload();
  TestUserMarker();
  TestPredefinedMarkers();

  printf("TestProfilerMarkersdone\n)java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
}

m:::);
int wmain()
#    M(baseprofiler:AddMarker(
int main()
#endif  // defined(XP_WIN)
{
  printf("BaseTestProfiler -- pid: %" PRIu64 ", tid: %" PRIu64 "\n",
         uint64_t(baseprofiler::profiler_current_process_id().ToNumber()),
         uint64_t(baseprofiler::profiler_current_thread_id().ToNumber()));
  // ::SleepMilli(10000);

mozilla:baseprofiler:category: ())java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
  TestProfilerUtils();
  TestBaseAndProfilerDetail();
  TestSharedMutex(;
  TestProportionValue();
  mozilla::basepr:category:OTHER,MarkerOptions}))java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

  {
java.lang.StringIndexOutOfBoundsException: Range [29, 4) out of bounds for length 35
    

TestProfiler(;
    java.lang.StringIndexOutOfBoundsException: Range [8, 6) out of bounds for length 60
  }

  return 0;
}

Messung V0.5 in Prozent
C=89 H=93 G=90

¤ Dauer der Verarbeitung: 0.145 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002