Commit 06d6197a authored by barraclough@apple.com's avatar barraclough@apple.com

2009-06-19 Gavin Barraclough <barraclough@apple.com>

        Reviewed by Oliver Hunt.

        Fix armv7 JIT build issues.

        Unfortunate the arm compiler does not like the use of offsetof on JITStackFrame (since it now contains non POD types),
        and the FIELD_OFFSET macro does not appear constantish enough for it to be happy with its use in COMPILE_ASSERT macros.

        * Replace offsetofs with FIELD_OFFSETs (safe on C++ objects).
        * Move COMPILE_ASSERTs defending layout of JITStackFrame structure on armv7 into JITThunks constructor.

        * jit/JIT.cpp:
        * jit/JIT.h:
        * jit/JITInlineMethods.h:
        (JSC::JIT::restoreArgumentReference):
        * jit/JITOpcodes.cpp:
        (JSC::JIT::emit_op_catch):
        * jit/JITStubs.cpp:
        (JSC::JITThunks::JITThunks):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44884 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 58003b76
2009-06-19 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
Fix armv7 JIT build issues.
Unfortunate the arm compiler does not like the use of offsetof on JITStackFrame (since it now contains non POD types),
and the FIELD_OFFSET macro does not appear constantish enough for it to be happy with its use in COMPILE_ASSERT macros.
* Replace offsetofs with FIELD_OFFSETs (safe on C++ objects).
* Move COMPILE_ASSERTs defending layout of JITStackFrame structure on armv7 into JITThunks constructor.
* jit/JIT.cpp:
* jit/JIT.h:
* jit/JITInlineMethods.h:
(JSC::JIT::restoreArgumentReference):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_catch):
* jit/JITStubs.cpp:
(JSC::JITThunks::JITThunks):
2009-06-19 Adam Treat <adam.treat@torchmobile.com>
Blind attempt at build fix.
......
......@@ -835,7 +835,7 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
storePtr(regT1, regT2);
move(ImmPtr(reinterpret_cast<void*>(ctiVMThrowTrampoline)), regT2);
emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
poke(callFrameRegister, offsetof(struct JITStackFrame, callFrame) / sizeof (void*));
poke(callFrameRegister, FIELD_OFFSET(struct JITStackFrame, callFrame) / sizeof (void*));
restoreReturnAddressBeforeReturn(regT2);
ret();
......
......@@ -28,6 +28,11 @@
#include <wtf/Platform.h>
// FIELD_OFFSET: Like the C++ offsetof macro, but you can use it with classes.
// The magic number 0x4000 is insignificant. We use it to avoid using NULL, since
// NULL can cause compiler problems, especially in cases of multiple inheritance.
#define FIELD_OFFSET(class, field) (reinterpret_cast<ptrdiff_t>(&(reinterpret_cast<class*>(0x4000)->field)) - 0x4000)
#if ENABLE(JIT)
// We've run into some problems where changing the size of the class JIT leads to
......
......@@ -34,11 +34,6 @@
#undef FIELD_OFFSET // Fix conflict with winnt.h.
#endif
// FIELD_OFFSET: Like the C++ offsetof macro, but you can use it with classes.
// The magic number 0x4000 is insignificant. We use it to avoid using NULL, since
// NULL can cause compiler problems, especially in cases of multiple inheritance.
#define FIELD_OFFSET(class, field) (reinterpret_cast<ptrdiff_t>(&(reinterpret_cast<class*>(0x4000)->field)) - 0x4000)
namespace JSC {
ALWAYS_INLINE void JIT::killLastResultRegister()
......@@ -225,14 +220,14 @@ ALWAYS_INLINE void JIT::restoreReturnAddressBeforeReturn(Address address)
#if USE(JIT_STUB_ARGUMENT_VA_LIST)
ALWAYS_INLINE void JIT::restoreArgumentReference()
{
poke(callFrameRegister, offsetof(struct JITStackFrame, callFrame) / sizeof (void*));
poke(callFrameRegister, FIELD_OFFSET(struct JITStackFrame, callFrame) / sizeof (void*));
}
ALWAYS_INLINE void JIT::restoreArgumentReferenceForTrampoline() {}
#else
ALWAYS_INLINE void JIT::restoreArgumentReference()
{
move(stackPointerRegister, firstArgumentRegister);
poke(callFrameRegister, offsetof(struct JITStackFrame, callFrame) / sizeof (void*));
poke(callFrameRegister, FIELD_OFFSET(struct JITStackFrame, callFrame) / sizeof (void*));
}
ALWAYS_INLINE void JIT::restoreArgumentReferenceForTrampoline()
{
......
......@@ -689,7 +689,7 @@ void JIT::emit_op_push_new_scope(Instruction* currentInstruction)
void JIT::emit_op_catch(Instruction* currentInstruction)
{
killLastResultRegister(); // FIXME: Implicitly treat op_catch as a labeled statement, and remove this line of code.
peek(callFrameRegister, offsetof(struct JITStackFrame, callFrame) / sizeof (void*));
peek(callFrameRegister, FIELD_OFFSET(struct JITStackFrame, callFrame) / sizeof (void*));
emitPutVirtualRegister(currentInstruction[1].u.operand);
}
......
......@@ -195,17 +195,6 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
#error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7."
#endif
COMPILE_ASSERT(offsetof(struct JITStackFrame, preservedReturnAddress) == 0x20, JITStackFrame_outerReturnAddress_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, preservedR4) == 0x24, JITStackFrame_outerReturnAddress_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, preservedR5) == 0x28, JITStackFrame_outerReturnAddress_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, preservedR6) == 0x2c, JITStackFrame_outerReturnAddress_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, registerFile) == 0x30, JITStackFrame_registerFile_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x34, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, exception) == 0x38, JITStackFrame_exception_offset_matches_ctiTrampoline);
// The fifth argument is the first item already on the stack.
COMPILE_ASSERT(offsetof(struct JITStackFrame, enabledProfilerReference) == 0x3c, JITStackFrame_enabledProfilerReference_offset_matches_ctiTrampoline);
asm volatile (
".text" "\n"
".align 2" "\n"
......@@ -338,6 +327,24 @@ extern "C" {
JITThunks::JITThunks(JSGlobalData* globalData)
{
JIT::compileCTIMachineTrampolines(globalData, &m_executablePool, &m_ctiArrayLengthTrampoline, &m_ctiStringLengthTrampoline, &m_ctiVirtualCallPreLink, &m_ctiVirtualCallLink, &m_ctiVirtualCall, &m_ctiNativeCallThunk);
#if PLATFORM(ARM_V7)
// Unfortunate the arm compiler does not like the use of offsetof on JITStackFrame (since it contains non POD types),
// and the FIELD_OFFSET macro does not appear constantish enough for it to be happy with its use in COMPILE_ASSERT
// macros.
ASSERT(FIELD_OFFSET(struct JITStackFrame, preservedReturnAddress) == 0x20);
ASSERT(FIELD_OFFSET(struct JITStackFrame, preservedR4) == 0x24);
ASSERT(FIELD_OFFSET(struct JITStackFrame, preservedR5) == 0x28);
ASSERT(FIELD_OFFSET(struct JITStackFrame, preservedR6) == 0x2c);
ASSERT(FIELD_OFFSET(struct JITStackFrame, registerFile) == 0x30);
ASSERT(FIELD_OFFSET(struct JITStackFrame, callFrame) == 0x34);
ASSERT(FIELD_OFFSET(struct JITStackFrame, exception) == 0x38);
// The fifth argument is the first item already on the stack.
ASSERT(FIELD_OFFSET(struct JITStackFrame, enabledProfilerReference) == 0x3c);
ASSERT(FIELD_OFFSET(struct JITStackFrame, thunkReturnAddress) == 0x1C);
#endif
}
#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
......@@ -564,8 +571,6 @@ namespace JITStubs {
#if PLATFORM(ARM_V7)
COMPILE_ASSERT(offsetof(struct JITStackFrame, thunkReturnAddress) == 0x1C, JITStackFrame_outerReturnAddress_offset_matches_ctiTrampoline);
#define DEFINE_STUB_FUNCTION(rtype, op) \
extern "C" { \
rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment