diff options
author | David Boddie <dboddie@trolltech.com> | 2009-06-24 15:17:08 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-06-24 15:17:08 (GMT) |
commit | 962d3938380dde01e2bd4915c51c95f47fafa0ec (patch) | |
tree | 24524e62fa3c40930a0c6335bfab4d1276aa3f22 /src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h | |
parent | f98829ae299e1f3c1f21b4bf2628601008e5141a (diff) | |
parent | dab9d7c67ed2eda150c8da9e41db75f7eeeecd0d (diff) | |
download | Qt-962d3938380dde01e2bd4915c51c95f47fafa0ec.zip Qt-962d3938380dde01e2bd4915c51c95f47fafa0ec.tar.gz Qt-962d3938380dde01e2bd4915c51c95f47fafa0ec.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h index 0603060..50fca5b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h @@ -35,6 +35,25 @@ #if ENABLE(ASSEMBLER) +// ASSERT_VALID_CODE_POINTER checks that ptr is a non-null pointer, and that it is a valid +// instruction address on the platform (for example, check any alignment requirements). +#if PLATFORM_ARM_ARCH(7) +// ARM/thumb instructions must be 16-bit aligned, but all code pointers to be loaded +// into the processor are decorated with the bottom bit set, indicating that this is +// thumb code (as oposed to 32-bit traditional ARM). The first test checks for both +// decorated and undectorated null, and the second test ensures that the pointer is +// decorated. +#define ASSERT_VALID_CODE_POINTER(ptr) \ + ASSERT(reinterpret_cast<intptr_t>(ptr) & ~1); \ + ASSERT(reinterpret_cast<intptr_t>(ptr) & 1) +#define ASSERT_VALID_CODE_OFFSET(offset) \ + ASSERT(!(offset & 1)) // Must be multiple of 2. +#else +#define ASSERT_VALID_CODE_POINTER(ptr) \ + ASSERT(ptr) +#define ASSERT_VALID_CODE_OFFSET(offset) // Anything goes! +#endif + namespace JSC { // FunctionPtr: @@ -52,7 +71,7 @@ public: explicit FunctionPtr(FunctionType* value) : m_value(reinterpret_cast<void*>(value)) { - ASSERT(m_value); + ASSERT_VALID_CODE_POINTER(m_value); } void* value() const { return m_value; } @@ -79,7 +98,13 @@ public: explicit ReturnAddressPtr(void* value) : m_value(value) { - ASSERT(m_value); + ASSERT_VALID_CODE_POINTER(m_value); + } + + explicit ReturnAddressPtr(FunctionPtr function) + : m_value(function.value()) + { + ASSERT_VALID_CODE_POINTER(m_value); } void* value() const { return m_value; } @@ -99,19 +124,34 @@ public: } explicit MacroAssemblerCodePtr(void* value) +#if PLATFORM_ARM_ARCH(7) + // Decorate the pointer as a thumb code pointer. + : m_value(reinterpret_cast<char*>(value) + 1) +#else : m_value(value) +#endif { - ASSERT(m_value); + ASSERT_VALID_CODE_POINTER(m_value); } explicit MacroAssemblerCodePtr(ReturnAddressPtr ra) : m_value(ra.value()) { - ASSERT(m_value); + ASSERT_VALID_CODE_POINTER(m_value); } void* executableAddress() const { return m_value; } - void* dataLocation() const { ASSERT(m_value); return m_value; } +#if PLATFORM_ARM_ARCH(7) + // To use this pointer as a data address remove the decoration. + void* dataLocation() const { ASSERT_VALID_CODE_POINTER(m_value); return reinterpret_cast<char*>(m_value) - 1; } +#else + void* dataLocation() const { ASSERT_VALID_CODE_POINTER(m_value); return m_value; } +#endif + + bool operator!() + { + return !m_value; + } private: void* m_value; |