Skip to content

Commit f1696fd

Browse files
author
Jianchun Xu
committed
apply -BaselineMode for -regexDebug dump
-regexDebug tests dump instruction offsets which are based on C++ `sizeof(struct ...)`. The results vary on different arch/compiler, thus do not suit baseline based tests. Add a common switch `-BaselineMode` to test harnesses. Change Regex code to not dump real instruction offsets in this mode in order to do baseline diff.
1 parent 3f04b9f commit f1696fd

8 files changed

+86
-1755
lines changed

lib/Common/ConfigFlagsList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ FLAGNR(Boolean, AssertIgnore , "Ignores asserts if set", false)
756756
FLAGNR(Boolean, AsyncDebugging, "Enable async debugging feature (default: false)", DEFAULT_CONFIG_AsyncDebugging)
757757
FLAGNR(Number, BailOnNoProfileLimit, "The limit of bailout on no profile info before triggering a rejit", DEFAULT_CONFIG_BailOnNoProfileLimit)
758758
FLAGNR(Number, BailOnNoProfileRejitLimit, "The limit of bailout on no profile info before we disable the bailouts", DEFAULT_CONFIG_BailOnNoProfileRejitLimit)
759+
FLAGNR(Boolean, BaselineMode , "Dump only stable content that can be used for baseline comparison", false)
759760
FLAGNR(String, DumpOnCrash , "generate heap dump on asserts or unhandled exception if set", nullptr)
760761
FLAGNR(String, FullMemoryDump , "Will perform a full memory dump when -DumpOnCrash is supplied.", nullptr)
761762
#ifdef BAILOUT_INJECTION

lib/Parser/RegexRuntime.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,18 @@ namespace UnifiedRegex
325325
ResetGroup(i);
326326
}
327327

328+
#if ENABLE_REGEX_CONFIG_OPTIONS
329+
bool Inst::IsBaselineMode()
330+
{
331+
return Js::Configuration::Global.flags.BaselineMode;
332+
}
333+
334+
Label Inst::GetPrintLabel(Label label)
335+
{
336+
return IsBaselineMode() ? (Label)0xFFFF : label;
337+
}
338+
#endif
339+
328340
// ----------------------------------------------------------------------
329341
// Mixins
330342
// ----------------------------------------------------------------------
@@ -657,7 +669,7 @@ namespace UnifiedRegex
657669
#if ENABLE_REGEX_CONFIG_OPTIONS
658670
void JumpMixin::Print(DebugWriter* w, const char16* litbuf) const
659671
{
660-
w->Print(_u("targetLabel: L%04x"), targetLabel);
672+
w->Print(_u("targetLabel: L%04x"), Inst::GetPrintLabel(targetLabel));
661673
}
662674
#endif
663675

@@ -673,21 +685,22 @@ namespace UnifiedRegex
673685
{
674686
w->Print(_u("loopId: %d, repeats: "), loopId);
675687
repeats.Print(w);
676-
w->Print(_u(", exitLabel: L%04x, hasOuterLoops: %s, hasInnerNondet: %s"), exitLabel, hasOuterLoops ? _u("true") : _u("false"), hasInnerNondet ? _u("true") : _u("false"));
688+
w->Print(_u(", exitLabel: L%04x, hasOuterLoops: %s, hasInnerNondet: %s"),
689+
Inst::GetPrintLabel(exitLabel), hasOuterLoops ? _u("true") : _u("false"), hasInnerNondet ? _u("true") : _u("false"));
677690
}
678691
#endif
679692

680693
#if ENABLE_REGEX_CONFIG_OPTIONS
681694
void RepeatLoopMixin::Print(DebugWriter* w, const char16* litbuf) const
682695
{
683-
w->Print(_u("beginLabel: L%04x"), beginLabel);
696+
w->Print(_u("beginLabel: L%04x"), Inst::GetPrintLabel(beginLabel));
684697
}
685698
#endif
686699

687700
#if ENABLE_REGEX_CONFIG_OPTIONS
688701
void TryMixin::Print(DebugWriter* w, const char16* litbuf) const
689702
{
690-
w->Print(_u("failLabel: L%04x"), failLabel);
703+
w->Print(_u("failLabel: L%04x"), Inst::GetPrintLabel(failLabel));
691704
}
692705
#endif
693706

@@ -3825,7 +3838,8 @@ namespace UnifiedRegex
38253838
#if ENABLE_REGEX_CONFIG_OPTIONS
38263839
int BeginAssertionInst::Print(DebugWriter* w, Label label, const Char* litbuf) const
38273840
{
3828-
w->Print(_u("L%04x: BeginAssertion(isNegation: %s, nextLabel: L%04x, "), label, isNegation ? _u("true") : _u("false"), nextLabel);
3841+
w->Print(_u("L%04x: BeginAssertion(isNegation: %s, nextLabel: L%04x, "),
3842+
label, isNegation ? _u("true") : _u("false"), GetPrintLabel(nextLabel));
38293843
BodyGroupsMixin::Print(w, litbuf);
38303844
w->PrintEOL(_u(")"));
38313845
return sizeof(*this);
@@ -5009,6 +5023,7 @@ namespace UnifiedRegex
50095023
#if ENABLE_REGEX_CONFIG_OPTIONS
50105024
void Program::Print(DebugWriter* w)
50115025
{
5026+
const bool isBaselineMode = Js::Configuration::Global.flags.BaselineMode;
50125027
w->PrintEOL(_u("Program {"));
50135028
w->Indent();
50145029
w->PrintEOL(_u("source: %s"), source);
@@ -5034,8 +5049,9 @@ namespace UnifiedRegex
50345049
}
50355050
uint8* instsLim = rep.insts.insts + rep.insts.instsLen;
50365051
uint8* curr = rep.insts.insts;
5052+
int i = 0;
50375053
while (curr != instsLim)
5038-
curr += ((Inst*)curr)->Print(w, (Label)(curr - rep.insts.insts), rep.insts.litbuf);
5054+
curr += ((Inst*)curr)->Print(w, (Label)(isBaselineMode ? i++ : curr - rep.insts.insts), rep.insts.litbuf);
50395055
w->Unindent();
50405056
w->PrintEOL(_u("}"));
50415057
}

lib/Parser/RegexRuntime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ namespace UnifiedRegex
633633
void FreeBody(ArenaAllocator* rtAllocator) {}
634634

635635
#if ENABLE_REGEX_CONFIG_OPTIONS
636+
static bool IsBaselineMode();
637+
static Label GetPrintLabel(Label label);
636638
virtual int Print(DebugWriter*w, Label label, const Char* litbuf) const = 0;
637639
#endif
638640
};

0 commit comments

Comments
 (0)