Bug 129657 - AbstractMacroAssembler::CachedTempRegister should start out invalid
Summary: AbstractMacroAssembler::CachedTempRegister should start out invalid
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-03-03 21:18 PST by Michael Saboff
Modified: 2014-04-24 16:46 PDT (History)
0 users

See Also:


Attachments
Patch (1.51 KB, patch)
2014-03-03 21:30 PST, Michael Saboff
msaboff: review-
Details | Formatted Diff | Diff
Updated patch (1.30 KB, patch)
2014-03-03 22:01 PST, Michael Saboff
fpizlo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2014-03-03 21:18:30 PST
Currently AbstractMacroAssembler::CachedTempRegister() are initialized with a value of 0 and that the contents are valid.  Instead they should be mark as invalid as we don't know the prior contents before the first use.
Comment 1 Michael Saboff 2014-03-03 21:27:52 PST
<rdar://problem/16214527>
Comment 2 Michael Saboff 2014-03-03 21:30:28 PST
Created attachment 225738 [details]
Patch
Comment 3 Mark Lam 2014-03-03 21:39:39 PST
Comment on attachment 225738 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=225738&action=review

> Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:881
> +            , m_validBit(0 << static_cast<unsigned>(registerID))

Why not just "m_validBit(0)”?
Comment 4 Michael Saboff 2014-03-03 21:43:49 PST
(In reply to comment #3)
> (From update of attachment 225738 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=225738&action=review
> 
> > Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:881
> > +            , m_validBit(0 << static_cast<unsigned>(registerID))
> 
> Why not just "m_validBit(0)”?

Actually, the is the wrong value to clear.  Updated patch coming.
Comment 5 Geoffrey Garen 2014-03-03 21:55:53 PST
Comment on attachment 225738 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=225738&action=review

> Source/JavaScriptCore/ChangeLog:12
> +        - Changed the setting of the valid bit to 0 (not valid) in the constructor as
> +          we don't know the contents of the register at the entry to the block we
> +          are going to generate code for.

Are you assuming that all JITs -- including the baseline JIT, the DFG, and the CSS selector JIT -- instantiate a new MacroAssembler at the head of each basic block?
Comment 6 Michael Saboff 2014-03-03 22:01:50 PST
Created attachment 225741 [details]
Updated patch

Updated after Mark caught that I was invalidating incorrectly.

(In reply to comment #5)
> (From update of attachment 225738 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=225738&action=review
> 
> > Source/JavaScriptCore/ChangeLog:12
> > +        - Changed the setting of the valid bit to 0 (not valid) in the constructor as
> > +          we don't know the contents of the register at the entry to the block we
> > +          are going to generate code for.
> 
> Are you assuming that all JITs -- including the baseline JIT, the DFG, and the CSS selector JIT -- instantiate a new MacroAssembler at the head of each basic block?

Poor choice of words.  I changed "block" to "code".  This fix has nothing to do with basic blocks.

Whenever we create a MacroAssembler, we need to start with the cached register values as invalid.  In the case that triggered this issue, we were generating small stubs and used the temporary registers to materialize constants that fit in 16 bits.
Comment 7 Michael Saboff 2014-03-03 22:32:45 PST
Committed r165038: <http://trac.webkit.org/changeset/165038>
Comment 8 Darin Adler 2014-04-24 16:46:03 PDT
Moving all JavaScriptGlue bugs to JavaScriptCore. The JavaScriptGlue framework itself is long gone. And most of the more recent bugs put in this component were put there by people who thought this was for some other aspect of “JavaScript glue” and have nothing to do with the actual original reason for the existence of this component, which was an OS-X-only framework named JavaScriptGlue.