Bug 112952 - JSC: Fix lexer charPosition computation when “rewind"ing the lexer
Summary: JSC: Fix lexer charPosition computation when “rewind"ing the lexer
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-03-21 12:41 PDT by Mark Lam
Modified: 2013-03-21 13:09 PDT (History)
7 users (show)

See Also:


Attachments
the patch (4.28 KB, patch)
2013-03-21 12:50 PDT, Mark Lam
msaboff: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2013-03-21 12:41:21 PDT
Currently, the lexer keeps a m_charPosition field which is supposed to track the m_code pointer.   m_charPosition used to be m_column which cannot be computed directly from the m_code pointer.  Now that we’re computing the char position instead of the column, we can get rid of m_charPosition and just compute it as m_code - m_codeStartPlusOffset, where m_codeStartPlusOffset is m_codeStart + the SourceCode offset.

This fixes a bug where m_charPosition gets out of sync with m_code when we “rewind” the lexer by setting m_code back to an earlier position in the source string.

ref: <rdar://problem/13467032>.
Comment 1 Mark Lam 2013-03-21 12:50:41 PDT
Created attachment 194322 [details]
the patch
Comment 2 Michael Saboff 2013-03-21 13:04:42 PDT
Comment on attachment 194322 [details]
the patch

Looks good.
Comment 3 Mark Lam 2013-03-21 13:09:02 PDT
Thanks for the review.  Landed in r146505: <http://trac.webkit.org/changeset/146505>.