Bug 845519 - Use SkipRoots for jschar pointers until we need to start moving them. r=terrence

--HG--
extra : rebase_source : d337dba6972e78e1994dd5563f093622e4475fc8
This commit is contained in:
Steve Fink 2013-02-26 16:45:49 -08:00
parent 1035847a84
commit 7ed8fd38e9
2 changed files with 16 additions and 5 deletions

View File

@ -122,7 +122,7 @@ TokenStream::TokenStream(JSContext *cx, const CompileOptions &options,
flags(),
linebase(base),
prevLinebase(NULL),
userbuf(base, length),
userbuf(cx, base, length),
filename(options.filename),
sourceMap(NULL),
listenerTSData(),
@ -132,7 +132,9 @@ TokenStream::TokenStream(JSContext *cx, const CompileOptions &options,
originPrincipals(JSScript::normalizeOriginPrincipals(options.principals,
options.originPrincipals)),
strictModeGetter(smg),
tokenSkip(cx, &tokens)
tokenSkip(cx, &tokens),
linebaseSkip(cx, &linebase),
prevLinebaseSkip(cx, &prevLinebase)
{
if (originPrincipals)
JS_HoldPrincipals(originPrincipals);
@ -663,7 +665,7 @@ TokenStream::endOffset(const Token &tok)
JS_ASSERT(lineno <= tok.pos.end.lineno);
const jschar *end;
if (lineno < tok.pos.end.lineno) {
TokenBuf buf(tok.ptr, userbuf.addressOfNextRawChar() - userbuf.base());
TokenBuf buf(cx, tok.ptr, userbuf.addressOfNextRawChar() - userbuf.base());
for (; lineno < tok.pos.end.lineno; lineno++) {
jschar c;
do {

View File

@ -671,8 +671,10 @@ class TokenStream
*/
class TokenBuf {
public:
TokenBuf(const jschar *buf, size_t length)
: base_(buf), limit_(buf + length), ptr(buf) { }
TokenBuf(JSContext *cx, const jschar *buf, size_t length)
: base_(buf), limit_(buf + length), ptr(buf),
skipBase(cx, &base_), skipLimit(cx, &limit_), skipPtr(cx, &ptr)
{ }
bool hasRawChars() const {
return ptr < limit_;
@ -750,6 +752,9 @@ class TokenStream
const jschar *base_; /* base of buffer */
const jschar *limit_; /* limit for quick bounds check */
const jschar *ptr; /* next char to get */
// We are not yet moving strings
SkipRoot skipBase, skipLimit, skipPtr;
};
TokenKind getTokenInternal(); /* doesn't check for pushback or error flag. */
@ -820,6 +825,10 @@ class TokenStream
* exact rooting analysis to ignore the atoms in the tokens array.
*/
SkipRoot tokenSkip;
// Bug 846011
SkipRoot linebaseSkip;
SkipRoot prevLinebaseSkip;
};
struct KeywordInfo {