Ignore:
Timestamp:
Jun 8, 2009, 6:40:59 PM (16 years ago)
Author:
[email protected]
Message:

2009-06-08 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

Add (incomplete) support to YARR for running with the jit enabled
on Arm thumb2 platforms. Adds new Assembler/MacroAssembler classes,
along with cache flushing support, tweaks to MacroAssemblerCodePtr
to support decorated thumb code pointers, and new enter/exit code
to YARR jit for the platform.

Support for this platform is still under development - the assembler
currrently only supports planting and linking jumps with a 16Mb range.
As such, initially commiting in a disabled state.

Add new assembler files.

  • assembler/ARMv7Assembler.h: Added.

Add new Assembler.

  • assembler/AbstractMacroAssembler.h:

Tweaks to ensure sizes of pointer values planted in JIT code do not change.

  • assembler/MacroAssembler.h:

On ARMv7 platforms use MacroAssemblerARMv7.

  • assembler/MacroAssemblerARMv7.h: Added.

Add new MacroAssembler.

  • assembler/MacroAssemblerCodeRef.h: (JSC::FunctionPtr::FunctionPtr):

Add better ASSERT.

(JSC::ReturnAddressPtr::ReturnAddressPtr):

Add better ASSERT.

(JSC::MacroAssemblerCodePtr::MacroAssemblerCodePtr):

On ARMv7, MacroAssemblerCodePtr's mush be 'decorated' with a low bit set,
to indicate to the processor that the code is thumb code, not traditional
32-bit ARM.

(JSC::MacroAssemblerCodePtr::dataLocation):

On ARMv7, decoration must be removed.

  • jit/ExecutableAllocator.h: (JSC::ExecutableAllocator::makeWritable):

Reformatted, no change.

(JSC::ExecutableAllocator::makeExecutable):

When marking code executable also cache flush it, where necessary.

(JSC::ExecutableAllocator::MakeWritable::MakeWritable):

Only use the null implementation of this class if both !ASSEMBLER_WX_EXCLUSIVE
and running on x86(_64) - on other platforms we may also need ensure that
makeExecutable is called at the end to flush caches.

(JSC::ExecutableAllocator::reprotectRegion):

Reformatted, no change.

(JSC::ExecutableAllocator::cacheFlush):

Cache flush a region of memory, or platforms where this is necessary.

  • wtf/Platform.h:

Add changes necessary to allow YARR jit to build on this platform, disabled.

  • yarr/RegexJIT.cpp: (JSC::Yarr::RegexGenerator::generateEnter): (JSC::Yarr::RegexGenerator::generateReturn):

Add support to these methods for ARMv7.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/assembler/MacroAssemblerCodeRef.h

    r44455 r44514  
    3636#if ENABLE(ASSEMBLER)
    3737
     38// ASSERT_VALID_CODE_POINTER checks that ptr is a non-null pointer, and that it is a valid
     39// instruction address on the platform (for example, check any alignment requirements).
     40#if PLATFORM(ARM_V7)
     41// ARM/thumb instructions must be 16-bit aligned, but all code pointers to be loaded
     42// into the processor are decorated with the bottom bit set, indicating that this is
     43// thumb code (as oposed to 32-bit traditional ARM).  The first test checks for both
     44// decorated and undectorated null, and the second test ensures that the pointer is
     45// decorated.
     46#define ASSERT_VALID_CODE_POINTER(ptr) \
     47    ASSERT(reinterpret_cast<intptr_t>(ptr) & ~1); \
     48    ASSERT(reinterpret_cast<intptr_t>(ptr) & 1)
     49#else
     50#define ASSERT_VALID_CODE_POINTER(ptr) \
     51    ASSERT(ptr)
     52#endif
     53
    3854namespace JSC {
    3955
     
    5369        : m_value(reinterpret_cast<void*>(value))
    5470    {
    55         ASSERT(m_value);
     71        ASSERT_VALID_CODE_POINTER(m_value);
    5672    }
    5773
     
    8096        : m_value(value)
    8197    {
    82         ASSERT(m_value);
     98        ASSERT_VALID_CODE_POINTER(m_value);
    8399    }
    84100
     
    100116
    101117    explicit MacroAssemblerCodePtr(void* value)
     118#if PLATFORM(ARM_V7)
     119        // Decorate the pointer as a thumb code pointer.
     120        : m_value(reinterpret_cast<char*>(value) + 1)
     121#else
    102122        : m_value(value)
     123#endif
    103124    {
    104         ASSERT(m_value);
     125        ASSERT_VALID_CODE_POINTER(m_value);
    105126    }
    106127
     
    108129        : m_value(ra.value())
    109130    {
    110         ASSERT(m_value);
     131        ASSERT_VALID_CODE_POINTER(m_value);
    111132    }
    112133
    113134    void* executableAddress() const { return m_value; }
    114     void* dataLocation() const { ASSERT(m_value); return m_value; }
     135#if PLATFORM(ARM_V7)
     136    // To use this pointer as a data address remove the decoration.
     137    void* dataLocation() const { ASSERT_VALID_CODE_POINTER(m_value); return reinterpret_cast<char*>(m_value) - 1; }
     138#else
     139    void* dataLocation() const { ASSERT_VALID_CODE_POINTER(m_value); return m_value; }
     140#endif
    115141
    116142private:
Note: See TracChangeset for help on using the changeset viewer.