Changeset 86919 in webkit


Ignore:
Timestamp:
May 19, 2011 6:33:46 PM (13 years ago)
Author:
oliver@apple.com
Message:

2011-05-19 Oliver Hunt <oliver@apple.com>

Reviewed by Gavin Barraclough.

Randomise code starting location a little
https://bugs.webkit.org/show_bug.cgi?id=61161

Add a nop() function to the Assemblers so that we
can randomise code offsets slightly at no real cost.

  • assembler/ARMAssembler.h: (JSC::ARMAssembler::nop):
  • assembler/ARMv7Assembler.h: (JSC::ARMv7Assembler::nop):
  • assembler/MacroAssemblerARM.h: (JSC::MacroAssemblerARM::nop):
  • assembler/MacroAssemblerARMv7.h: (JSC::MacroAssemblerARMv7::nop):
  • assembler/MacroAssemblerMIPS.h: (JSC::MacroAssemblerMIPS::nop):
  • assembler/MacroAssemblerSH4.h: (JSC::MacroAssemblerSH4::nop):
  • assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::nop):
  • assembler/X86Assembler.h: (JSC::X86Assembler::nop):
  • jit/JIT.cpp: (JSC::JIT::JIT): (JSC::JIT::privateCompile):
  • jit/JIT.h:
  • runtime/WeakRandom.h: (JSC::WeakRandom::getUint32):
Location:
trunk/Source/JavaScriptCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r86908 r86919  
     12011-05-19  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Randomise code starting location a little
     6        https://bugs.webkit.org/show_bug.cgi?id=61161
     7
     8        Add a nop() function to the Assemblers so that we
     9        can randomise code offsets slightly at no real cost.
     10
     11        * assembler/ARMAssembler.h:
     12        (JSC::ARMAssembler::nop):
     13        * assembler/ARMv7Assembler.h:
     14        (JSC::ARMv7Assembler::nop):
     15        * assembler/MacroAssemblerARM.h:
     16        (JSC::MacroAssemblerARM::nop):
     17        * assembler/MacroAssemblerARMv7.h:
     18        (JSC::MacroAssemblerARMv7::nop):
     19        * assembler/MacroAssemblerMIPS.h:
     20        (JSC::MacroAssemblerMIPS::nop):
     21        * assembler/MacroAssemblerSH4.h:
     22        (JSC::MacroAssemblerSH4::nop):
     23        * assembler/MacroAssemblerX86Common.h:
     24        (JSC::MacroAssemblerX86Common::nop):
     25        * assembler/X86Assembler.h:
     26        (JSC::X86Assembler::nop):
     27        * jit/JIT.cpp:
     28        (JSC::JIT::JIT):
     29        (JSC::JIT::privateCompile):
     30        * jit/JIT.h:
     31        * runtime/WeakRandom.h:
     32        (JSC::WeakRandom::getUint32):
     33
    1342011-05-19  Oliver Hunt  <oliver@apple.com>
    235
  • trunk/Source/JavaScriptCore/assembler/ARMAssembler.h

    r86699 r86919  
    168168            BKPT = 0xe1200070,
    169169            BLX = 0x012fff30,
     170            NOP_T2 = 0xf3af8000,
    170171#endif
    171172#if WTF_ARM_ARCH_AT_LEAST(7)
     
    572573#endif
    573574        }
     575       
     576        void nop()
     577        {
     578            m_buffer.putInt(OP_NOP_T2);
     579        }
    574580
    575581        void bx(int rm, Condition cc = AL)
  • trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r86699 r86919  
    15271527    }
    15281528
     1529    void nop()
     1530    {
     1531        m_formatter.oneWordOp8Imm8(OP_NOP_T1, 0);
     1532    }
     1533
    15291534    AssemblerLabel label()
    15301535    {
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM.h

    r86699 r86919  
    934934        convertInt32ToDouble(ARMRegisters::S0, scratch);
    935935        return branchDouble(DoubleEqualOrUnordered, reg, scratch);
     936    }
     937
     938    void nop()
     939    {
     940        m_assembler.nop();
    936941    }
    937942
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r86699 r86919  
    820820    }
    821821
     822    void nop()
     823    {
     824        m_assembler.nop();
     825    }
    822826
    823827    // Forwards / external control flow operations:
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h

    r86699 r86919  
    17721772    }
    17731773
     1774    void nop()
     1775    {
     1776        m_assembler.nop();
     1777    }
    17741778
    17751779private:
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h

    r86699 r86919  
    17351735        return tailRecursiveCall();
    17361736    }
     1737
     1738    void nop()
     1739    {
     1740        m_assembler.nop();
     1741    }
     1742
    17371743protected:
    17381744    SH4Assembler::Condition SH4Condition(RelationalCondition cond)
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h

    r86699 r86919  
    12141214        ASSERT(cond == Below || cond == BelowOrEqual || cond == Above || cond == AboveOrEqual);
    12151215        return static_cast<RelationalCondition>(X86Assembler::ConditionB + X86Assembler::ConditionA - cond);
     1216    }
     1217   
     1218    void nop()
     1219    {
     1220        m_assembler.nop();
    12161221    }
    12171222
  • trunk/Source/JavaScriptCore/assembler/X86Assembler.h

    r86699 r86919  
    139139        OP_LEA                          = 0x8D,
    140140        OP_GROUP1A_Ev                   = 0x8F,
     141        OP_NOP                          = 0x90,
    141142        OP_CDQ                          = 0x99,
    142143        OP_MOV_EAXOv                    = 0xA1,
     
    15931594    unsigned debugOffset() { return m_formatter.debugOffset(); }
    15941595#endif
     1596
     1597    void nop()
     1598    {
     1599        m_formatter.oneByteOp(OP_NOP);
     1600    }
    15951601
    15961602private:
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r85432 r86919  
    3636
    3737#include "CodeBlock.h"
     38#include "CryptographicallyRandomNumber.h"
    3839#include "Interpreter.h"
    3940#include "JITInlineMethods.h"
     
    8687    , m_lastResultBytecodeRegister(std::numeric_limits<int>::max())
    8788    , m_jumpTargetsPosition(0)
     89#endif
     90#if USE(OS_RANDOMNESS)
     91    , m_randomGenerator(cryptographicallyRandomNumber())
     92#else
     93    , m_randomGenerator(static_cast<unsigned>(randomNumber() * 0xFFFFFFF))
    8894#endif
    8995{
     
    459465JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck)
    460466{
     467    // Just add a little bit of randomness to the codegen
     468    if (m_randomGenerator.getUint32() & 1)
     469        nop();
     470
    461471    // Could use a pop_m, but would need to offset the following instruction if so.
    462472    preserveReturnAddressAfterCall(regT2);
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r86699 r86919  
    998998#endif
    999999#endif
     1000        WeakRandom m_randomGenerator;
    10001001        static CodePtr stringGetByValStubGenerator(JSGlobalData* globalData, ExecutablePool* pool);
    10011002    } JIT_CLASS_ALIGNMENT;
  • trunk/Source/JavaScriptCore/runtime/WeakRandom.h

    r50791 r86919  
    6969    }
    7070
     71    unsigned getUint32()
     72    {
     73        return advance();
     74    }
     75
    7176private:
    7277    unsigned advance()
Note: See TracChangeset for help on using the changeset viewer.