Bug 118242 - Fix cast-align warnings in JavaScriptCore/heap/HandleBlockInlines.h
Summary: Fix cast-align warnings in JavaScriptCore/heap/HandleBlockInlines.h
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Csaba Osztrogonác
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-01 06:37 PDT by Csaba Osztrogonác
Modified: 2013-07-01 08:39 PDT (History)
3 users (show)

See Also:


Attachments
Patch (1.28 KB, patch)
2013-07-01 06:39 PDT, Csaba Osztrogonác
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Csaba Osztrogonác 2013-07-01 06:37:48 PDT
/home/oszi/Source/JavaScriptCore/heap/HandleBlockInlines.h:58:51: warning: cast from 'char*' to 'JSC::HandleNode*' increases required alignment of target type [-Wcast-align]

This code introduced in http://trac.webkit.org/changeset/146734 :

...
inline char* HandleBlock::payload()
{
    return reinterpret_cast<char*>(this) + WTF::roundUpToMultipleOf<sizeof(double)>(sizeof(HandleBlock));
}

inline HandleNode* HandleBlock::nodes()
{
    return reinterpret_cast<HandleNode*>(payload());    <------ line 58
}
...

This part of JSC isn't quite clear for me. As far as I understand a 
HandleBlock is 4K sized block on JSC heap, which contains HandleNode 
instances on int payload. And the payload is 64 bit aligned after
the HandleBlock instance. Am I correct?

If yes, I think this casting is safe and can be supressed by using
reinterpret_cast_ptr instead of reinterpret_cast, because HandleNode
has two following members: JSValue, HandleNode* and HandleNode* .
Comment 1 Csaba Osztrogonác 2013-07-01 06:39:28 PDT
Created attachment 205807 [details]
Patch
Comment 2 Mark Hahnenberg 2013-07-01 08:10:01 PDT
Comment on attachment 205807 [details]
Patch

r=me. We use char* to make the pointer arithmetic easier, so it's fine that the cast changes the alignment. Thanks for fixing this!
Comment 3 Csaba Osztrogonác 2013-07-01 08:39:41 PDT
Comment on attachment 205807 [details]
Patch

Clearing flags on attachment: 205807

Committed r152225: <http://trac.webkit.org/changeset/152225>
Comment 4 Csaba Osztrogonác 2013-07-01 08:39:47 PDT
All reviewed patches have been landed.  Closing bug.