mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
Bug 1465470
Part 5 - Avoid recording time events at non-deterministic points in the JS engine, r=jonco.
--HG-- extra : rebase_source : ed238c0ad5861a3149f695a5e46d221cf22cb27d
This commit is contained in:
parent
d1fdeae425
commit
871f2e4852
@ -799,7 +799,7 @@ frontend::CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const cha
|
||||
// syntax parsing and start of full parsing, so we do this now rather than
|
||||
// after parsing below.
|
||||
if (!lazy->scriptSource()->parseEnded().IsNull()) {
|
||||
const mozilla::TimeDuration delta = mozilla::TimeStamp::Now() -
|
||||
const mozilla::TimeDuration delta = ReallyNow() -
|
||||
lazy->scriptSource()->parseEnded();
|
||||
|
||||
// Differentiate between web-facing and privileged code, to aid
|
||||
|
@ -954,7 +954,7 @@ GCRuntime::GCRuntime(JSRuntime* rt) :
|
||||
numArenasFreeCommitted(0),
|
||||
verifyPreData(nullptr),
|
||||
chunkAllocationSinceLastGC(false),
|
||||
lastGCTime(mozilla::TimeStamp::Now()),
|
||||
lastGCTime(ReallyNow()),
|
||||
mode(TuningDefaults::Mode),
|
||||
numActiveZoneIters(0),
|
||||
cleanUpEverything(false),
|
||||
@ -3247,7 +3247,7 @@ SliceBudget::SliceBudget(TimeBudget time)
|
||||
makeUnlimited();
|
||||
} else {
|
||||
// Note: TimeBudget(0) is equivalent to WorkBudget(CounterReset).
|
||||
deadline = mozilla::TimeStamp::Now() + mozilla::TimeDuration::FromMilliseconds(time.budget);
|
||||
deadline = ReallyNow() + mozilla::TimeDuration::FromMilliseconds(time.budget);
|
||||
counter = CounterReset;
|
||||
}
|
||||
}
|
||||
@ -3280,7 +3280,7 @@ SliceBudget::checkOverBudget()
|
||||
if (deadline.IsNull())
|
||||
return true;
|
||||
|
||||
bool over = mozilla::TimeStamp::Now() >= deadline;
|
||||
bool over = ReallyNow() >= deadline;
|
||||
if (!over)
|
||||
counter = CounterReset;
|
||||
return over;
|
||||
@ -4238,7 +4238,7 @@ GCRuntime::prepareZonesForCollection(JS::gcreason::Reason reason, bool* isFullOu
|
||||
*isFullOut = true;
|
||||
bool any = false;
|
||||
|
||||
auto currentTime = mozilla::TimeStamp::Now();
|
||||
auto currentTime = ReallyNow();
|
||||
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
/* Set up which zones will be collected. */
|
||||
|
@ -375,13 +375,13 @@ js::Nursery::allocate(size_t size)
|
||||
if (chunkno == maxChunkCount())
|
||||
return nullptr;
|
||||
if (MOZ_UNLIKELY(chunkno == allocatedChunkCount())) {
|
||||
mozilla::TimeStamp start = TimeStamp::Now();
|
||||
mozilla::TimeStamp start = ReallyNow();
|
||||
{
|
||||
AutoLockGCBgAlloc lock(runtime());
|
||||
if (!allocateNextChunk(chunkno, lock))
|
||||
return nullptr;
|
||||
}
|
||||
timeInChunkAlloc_ += TimeStamp::Now() - start;
|
||||
timeInChunkAlloc_ += ReallyNow() - start;
|
||||
MOZ_ASSERT(chunkno < allocatedChunkCount());
|
||||
}
|
||||
setCurrentChunk(chunkno);
|
||||
|
@ -1547,7 +1547,7 @@ static inline
|
||||
TimeDuration
|
||||
TimeSince(TimeStamp prev)
|
||||
{
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
TimeStamp now = ReallyNow();
|
||||
// Sadly this happens sometimes.
|
||||
MOZ_ASSERT(now >= prev);
|
||||
if (now < prev)
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "vm/Scope.h"
|
||||
#include "vm/Shape.h"
|
||||
#include "vm/SharedImmutableStringsCache.h"
|
||||
#include "vm/Time.h"
|
||||
|
||||
namespace JS {
|
||||
struct ScriptSourceInfo;
|
||||
@ -682,7 +683,7 @@ class ScriptSource
|
||||
// Inform `this` source that it has been fully parsed.
|
||||
void recordParseEnded() {
|
||||
MOZ_ASSERT(parseEnded_.IsNull());
|
||||
parseEnded_ = mozilla::TimeStamp::Now();
|
||||
parseEnded_ = ReallyNow();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -7,6 +7,9 @@
|
||||
#ifndef vm_Time_h
|
||||
#define vm_Time_h
|
||||
|
||||
#include "mozilla/RecordReplay.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@ -167,4 +170,16 @@ ReadTimestampCounter(void)
|
||||
|
||||
#endif
|
||||
|
||||
namespace js {
|
||||
|
||||
// Get the current time, bypassing any record/replay instrumentation.
|
||||
static inline mozilla::TimeStamp
|
||||
ReallyNow()
|
||||
{
|
||||
mozilla::recordreplay::AutoPassThroughThreadEvents pt;
|
||||
return mozilla::TimeStamp::Now();
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
#endif /* vm_Time_h */
|
||||
|
Loading…
Reference in New Issue
Block a user