From 24d68f4706b3bea207aa8bba5938f4876e390ebf Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Tue, 26 Feb 2013 16:45:49 -0800 Subject: [PATCH] Bug 845519 - Use SkipRoots for jschar pointers until we need to start moving them. r=terrence --HG-- extra : rebase_source : d337dba6972e78e1994dd5563f093622e4475fc8 --- js/src/frontend/TokenStream.cpp | 8 +++++--- js/src/frontend/TokenStream.h | 13 +++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp index 99cae273ba9..12453f31e70 100644 --- a/js/src/frontend/TokenStream.cpp +++ b/js/src/frontend/TokenStream.cpp @@ -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 { diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h index c45aab3334f..70e68aec6ad 100644 --- a/js/src/frontend/TokenStream.h +++ b/js/src/frontend/TokenStream.h @@ -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 {