|
|
|
|
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.1000_ 0)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 char* const
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 char* const filters[] = {"main", "pid:123"};
MOZ_RELEASE_ASSERT(FiltersExcludePid(ilters pid123);
}
{
const char* const filters[] = {"main", "pid:456"};
MOZ_RELEASE_ASSERT(!FiltersExcludePid(filters, pid123));
}
{
const char* const 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 char* const filters[] = {" STATIC_ASSERT((50_pc - ProportionValue().()java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
MOZ_RELEASE_ASSERT(FiltersExcludePid // Multiplication.
}
{
const char* const 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(p 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 = {0, 0};
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[] = {
{ 0, 0 },
{ 1, 1 },
{ 2, 3 },
{ 3, 3 },
{ 4, 7 },
{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[] = {
{ 0, 1, 0 },
{ stati(<int32_t xFFFFFFFFu).askValue)=
{ 2, 2, 1 },
{ 3, 4, 3 },
{ 4, 4, 3 },
{ 5, 8, 7 }
{ (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:FromMicroseconds5) 5000)
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::FromMicroseconds5) 5")
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(1, 2, 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
| | |