[Webkit-unassigned] [Bug 38045] Fix VectorBuffer's alignment on ARM

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon May 3 07:23:06 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=38045


Thiago Macieira <thiago.macieira at nokia.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thiago.macieira at nokia.com




--- Comment #5 from Thiago Macieira <thiago.macieira at nokia.com>  2010-05-03 07:23:05 PST ---
I think this is a GCC problem.

$ cat test.cpp
struct Foo
{
    char __attribute__((aligned(4))) c;
};

char junk;
Foo f;
char junk2;

int main()
{
    int *i = reinterpret_cast<int *>(&f.c);
}

$ arm-none-linux-gnueabi-g++ -Wcast-align -fsyntax-only /tmp/test.cpp
/tmp/test.cpp: In function 'int main()':
/tmp/test.cpp:8: warning: cast from 'char*' to 'int*' increases required
alignment of target type

$ arm-none-linux-gnueabi-g++ -dumpversion 
4.4.1

Reading the assembly output, we can even see:
junk:
        .space  1
        .space  3
        .type   f, %object
        .size   f, 4
f:
        .space  4

Which proves that "f" was aligned to a 4-byte boundary. (note the 3-byte
padding)

In Vector.h, we have:
    template <size_t size, size_t alignment> struct AlignedBuffer;
    template <size_t size> struct AlignedBuffer<size, 1> { AlignedBufferChar
buffer[size]; };
    template <size_t size> struct AlignedBuffer<size, 2> {
WTF_ALIGNED(AlignedBufferChar, buffer[size], 2);  };
    template <size_t size> struct AlignedBuffer<size, 4> {
WTF_ALIGNED(AlignedBufferChar, buffer[size], 4);  };
    template <size_t size> struct AlignedBuffer<size, 8> {
WTF_ALIGNED(AlignedBufferChar, buffer[size], 8);  };
[...]

lines 484 to 486:
        T* inlineBuffer() { return reinterpret_cast<T*>(m_inlineBuffer.buffer);
}

        AlignedBuffer<m_inlineBufferSize, WTF_ALIGN_OF(T)> m_inlineBuffer;

So, by construction, m_inlineBuffer::buffer has the same alignment as T.

GCC threw the same warning as my example above, despite the type having the
proper alignment.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list