mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 916564 - Move countFinalSourceNotes to a better place (r=jorendorff)
--HG-- extra : rebase_source : c0b10f87f1e10499586fed2e4fa570edfcaaf510
This commit is contained in:
parent
44832b6251
commit
4ee663ce3c
@ -6740,36 +6740,37 @@ SetSrcNoteOffset(ExclusiveContext *cx, BytecodeEmitter *bce, unsigned index, uns
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_notme
|
||||
#define DEBUG_srcnotesize
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_srcnotesize
|
||||
#define NBINS 10
|
||||
static uint32_t hist[NBINS];
|
||||
|
||||
static void
|
||||
DumpSrcNoteSizeHist()
|
||||
/*
|
||||
* Finish taking source notes in cx's notePool, copying final notes to the new
|
||||
* stable store allocated by the caller and passed in via notes. Return false
|
||||
* on malloc failure, which means this function reported an error.
|
||||
*
|
||||
* Use this to compute the number of jssrcnotes to allocate and pass in via
|
||||
* notes. This method knows a lot about details of FinishTakingSrcNotes, so
|
||||
* DON'T CHANGE js::frontend::FinishTakingSrcNotes WITHOUT CHECKING WHETHER
|
||||
* THIS METHOD NEEDS CORRESPONDING CHANGES!
|
||||
*/
|
||||
ptrdiff_t
|
||||
BytecodeEmitter::countFinalSourceNotes()
|
||||
{
|
||||
static FILE *fp;
|
||||
int i, n;
|
||||
|
||||
if (!fp) {
|
||||
fp = fopen("/tmp/srcnotes.hist", "w");
|
||||
if (!fp)
|
||||
return;
|
||||
setvbuf(fp, nullptr, _IONBF, 0);
|
||||
ptrdiff_t diff = prologOffset() - prolog.lastNoteOffset;
|
||||
ptrdiff_t cnt = prolog.notes.length() + main.notes.length() + 1;
|
||||
if (prolog.notes.length() && prolog.currentLine != firstLine) {
|
||||
if (diff > SN_DELTA_MASK)
|
||||
cnt += JS_HOWMANY(diff - SN_DELTA_MASK, SN_XDELTA_MASK);
|
||||
cnt += 2 + ((firstLine > SN_3BYTE_OFFSET_MASK) << 1);
|
||||
} else if (diff > 0) {
|
||||
if (main.notes.length()) {
|
||||
jssrcnote *sn = main.notes.begin();
|
||||
diff -= SN_IS_XDELTA(sn)
|
||||
? SN_XDELTA_MASK - (*sn & SN_XDELTA_MASK)
|
||||
: SN_DELTA_MASK - (*sn & SN_DELTA_MASK);
|
||||
}
|
||||
if (diff > 0)
|
||||
cnt += JS_HOWMANY(diff, SN_XDELTA_MASK);
|
||||
}
|
||||
fprintf(fp, "SrcNote size histogram:\n");
|
||||
for (i = 0; i < NBINS; i++) {
|
||||
fprintf(fp, "%4u %4u ", JS_BIT(i), hist[i]);
|
||||
for (n = (int) JS_HOWMANY(hist[i], 10); n > 0; --n)
|
||||
fputc('*', fp);
|
||||
fputc('\n', fp);
|
||||
}
|
||||
fputc('\n', fp);
|
||||
return cnt;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fill in the storage at notes with prolog and main srcnotes; the space at
|
||||
|
@ -216,7 +216,7 @@ struct BytecodeEmitter
|
||||
unsigned currentLine() const { return current->currentLine; }
|
||||
unsigned lastColumn() const { return current->lastColumn; }
|
||||
|
||||
inline ptrdiff_t countFinalSourceNotes();
|
||||
ptrdiff_t countFinalSourceNotes();
|
||||
|
||||
bool reportError(ParseNode *pn, unsigned errorNumber, ...);
|
||||
bool reportStrictWarning(ParseNode *pn, unsigned errorNumber, ...);
|
||||
@ -282,38 +282,6 @@ AddToSrcNoteDelta(ExclusiveContext *cx, BytecodeEmitter *bce, jssrcnote *sn, ptr
|
||||
bool
|
||||
FinishTakingSrcNotes(ExclusiveContext *cx, BytecodeEmitter *bce, jssrcnote *notes);
|
||||
|
||||
/*
|
||||
* Finish taking source notes in cx's notePool, copying final notes to the new
|
||||
* stable store allocated by the caller and passed in via notes. Return false
|
||||
* on malloc failure, which means this function reported an error.
|
||||
*
|
||||
* Use this to compute the number of jssrcnotes to allocate and pass in via
|
||||
* notes. This method knows a lot about details of FinishTakingSrcNotes, so
|
||||
* DON'T CHANGE js::frontend::FinishTakingSrcNotes WITHOUT CHECKING WHETHER
|
||||
* THIS METHOD NEEDS CORRESPONDING CHANGES!
|
||||
*/
|
||||
inline ptrdiff_t
|
||||
BytecodeEmitter::countFinalSourceNotes()
|
||||
{
|
||||
ptrdiff_t diff = prologOffset() - prolog.lastNoteOffset;
|
||||
ptrdiff_t cnt = prolog.notes.length() + main.notes.length() + 1;
|
||||
if (prolog.notes.length() && prolog.currentLine != firstLine) {
|
||||
if (diff > SN_DELTA_MASK)
|
||||
cnt += JS_HOWMANY(diff - SN_DELTA_MASK, SN_XDELTA_MASK);
|
||||
cnt += 2 + ((firstLine > SN_3BYTE_OFFSET_MASK) << 1);
|
||||
} else if (diff > 0) {
|
||||
if (main.notes.length()) {
|
||||
jssrcnote *sn = main.notes.begin();
|
||||
diff -= SN_IS_XDELTA(sn)
|
||||
? SN_XDELTA_MASK - (*sn & SN_XDELTA_MASK)
|
||||
: SN_DELTA_MASK - (*sn & SN_DELTA_MASK);
|
||||
}
|
||||
if (diff > 0)
|
||||
cnt += JS_HOWMANY(diff, SN_XDELTA_MASK);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
} /* namespace frontend */
|
||||
} /* namespace js */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user