Bug 1528320 - Ensure correct record/replay progress flag after XDR-decoding a script, r=tcampbell.

--HG--
extra : rebase_source : 8c89ccde2627022a2d9d6becc66586d2a106b34d
This commit is contained in:
Brian Hackett 2019-02-21 17:32:59 -10:00
Родитель f92f45d7b6
Коммит 95d63e80b2
6 изменённых файлов: 52 добавлений и 12 удалений

Просмотреть файл

@ -1549,6 +1549,17 @@ MOZ_MUST_USE bool BaselineCompilerCodeGen::emitTestScriptFlag(
return true;
}
template <>
template <typename F>
MOZ_MUST_USE bool BaselineCompilerCodeGen::emitTestScriptFlag(
JSScript::MutableFlags flag, bool value, const F& emit,
Register scratch) {
if (handler.script()->hasFlag(flag) == value) {
return emit();
}
return true;
}
template <>
template <typename F>
MOZ_MUST_USE bool BaselineInterpreterCodeGen::emitTestScriptFlag(
@ -1569,6 +1580,26 @@ MOZ_MUST_USE bool BaselineInterpreterCodeGen::emitTestScriptFlag(
return true;
}
template <>
template <typename F>
MOZ_MUST_USE bool BaselineInterpreterCodeGen::emitTestScriptFlag(
JSScript::MutableFlags flag, bool value, const F& emit,
Register scratch) {
Label done;
loadScript(scratch);
masm.branchTest32(value ? Assembler::Zero : Assembler::NonZero,
Address(scratch, JSScript::offsetOfMutableFlags()),
Imm32(uint32_t(flag)), &done);
{
if (!emit()) {
return false;
}
}
masm.bind(&done);
return true;
}
template <typename Handler>
bool BaselineCodeGen<Handler>::emit_JSOP_GOTO() {
frame.syncStack(0);
@ -1722,7 +1753,7 @@ bool BaselineCodeGen<Handler>::emit_JSOP_LOOPENTRY() {
AbsoluteAddress(mozilla::recordreplay::ExecutionProgressCounter()));
return true;
};
return emitTestScriptFlag(JSScript::ImmutableFlags::TrackRecordReplayProgress,
return emitTestScriptFlag(JSScript::MutableFlags::TrackRecordReplayProgress,
true, incCounter, R2.scratchReg());
}
@ -5855,7 +5886,7 @@ bool BaselineCodeGen<Handler>::emitPrologue() {
AbsoluteAddress(mozilla::recordreplay::ExecutionProgressCounter()));
return true;
};
if (!emitTestScriptFlag(JSScript::ImmutableFlags::TrackRecordReplayProgress,
if (!emitTestScriptFlag(JSScript::MutableFlags::TrackRecordReplayProgress,
true, incCounter, R2.scratchReg())) {
return false;
}

Просмотреть файл

@ -379,6 +379,10 @@ class BaselineCodeGen {
MOZ_MUST_USE bool emitTestScriptFlag(JSScript::ImmutableFlags flag,
bool value, const F& emit,
Register scratch);
template <typename F>
MOZ_MUST_USE bool emitTestScriptFlag(JSScript::MutableFlags flag,
bool value, const F& emit,
Register scratch);
MOZ_MUST_USE bool emitCheckThis(ValueOperand val, bool reinit = false);
void emitLoadReturnValue(ValueOperand val);

Просмотреть файл

@ -183,6 +183,7 @@ class CompileInfo {
hadOverflowBailout_(script->hadOverflowBailout()),
hadFrequentBailouts_(script->hadFrequentBailouts()),
mayReadFrameArgsDirectly_(script->mayReadFrameArgsDirectly()),
trackRecordReplayProgress_(script->trackRecordReplayProgress()),
inlineScriptTree_(inlineScriptTree) {
MOZ_ASSERT_IF(osrPc, JSOp(*osrPc) == JSOP_LOOPENTRY);
@ -243,6 +244,7 @@ class CompileInfo {
hadOverflowBailout_(false),
hadFrequentBailouts_(false),
mayReadFrameArgsDirectly_(false),
trackRecordReplayProgress_(false),
inlineScriptTree_(nullptr),
needsBodyEnvironmentObject_(false),
funNeedsSomeEnvironmentObject_(false) {
@ -499,6 +501,7 @@ class CompileInfo {
bool hadOverflowBailout() const { return hadOverflowBailout_; }
bool hadFrequentBailouts() const { return hadFrequentBailouts_; }
bool mayReadFrameArgsDirectly() const { return mayReadFrameArgsDirectly_; }
bool trackRecordReplayProgress() const { return trackRecordReplayProgress_; }
private:
unsigned nimplicit_;
@ -523,6 +526,7 @@ class CompileInfo {
bool hadFrequentBailouts_;
bool mayReadFrameArgsDirectly_;
bool trackRecordReplayProgress_;
InlineScriptTree* inlineScriptTree_;

Просмотреть файл

@ -121,7 +121,7 @@ bool CodeGeneratorShared::generatePrologue() {
masm.profilerEnterFrame(masm.getStackPointer(), CallTempReg0);
}
if (gen->info().script()->trackRecordReplayProgress()) {
if (gen->info().trackRecordReplayProgress()) {
masm.inc64(
AbsoluteAddress(mozilla::recordreplay::ExecutionProgressCounter()));
}

Просмотреть файл

@ -3274,7 +3274,7 @@ static bool ShouldTrackRecordReplayProgress(JSScript* script) {
script->setFlag(MutableFlags::HideScriptFromDebugger,
options.hideScriptFromDebugger);
script->setFlag(ImmutableFlags::TrackRecordReplayProgress,
script->setFlag(MutableFlags::TrackRecordReplayProgress,
ShouldTrackRecordReplayProgress(script));
if (cx->runtime()->lcovOutput().isEnabled()) {

Просмотреть файл

@ -1725,15 +1725,11 @@ class JSScript : public js::gc::TenuredCell {
// Script came from eval().
IsForEval = 1 << 22,
// Whether the record/replay execution progress counter (see RecordReplay.h)
// should be updated as this script runs.
TrackRecordReplayProgress = 1 << 23,
// Whether this is a top-level module script.
IsModule = 1 << 24,
IsModule = 1 << 23,
// Whether this function needs a call object or named lambda environment.
NeedsFunctionEnvironmentObjects = 1 << 25,
NeedsFunctionEnvironmentObjects = 1 << 24,
};
private:
@ -1754,7 +1750,11 @@ class JSScript : public js::gc::TenuredCell {
// Script has been reused for a clone.
HasBeenCloned = 1 << 2,
// (1 << 3) and (1 << 4) are unused.
// Whether the record/replay execution progress counter (see RecordReplay.h)
// should be updated as this script runs.
TrackRecordReplayProgress = 1 << 3,
// (1 << 4) is unused.
// Script has an entry in Realm::scriptCountsMap.
HasScriptCounts = 1 << 5,
@ -1896,6 +1896,7 @@ class JSScript : public js::gc::TenuredCell {
private:
// Assert that jump targets are within the code array of the script.
void assertValidJumpTargets() const;
public:
#endif
// MutableFlags accessors.
@ -2800,7 +2801,7 @@ class JSScript : public js::gc::TenuredCell {
};
bool trackRecordReplayProgress() const {
return hasFlag(ImmutableFlags::TrackRecordReplayProgress);
return hasFlag(MutableFlags::TrackRecordReplayProgress);
}
};