Ignore:
Timestamp:
Mar 5, 2012, 6:40:05 PM (13 years ago)
Author:
[email protected]
Message:

Add basic support for constant blinding to the JIT
https://bugs.webkit.org/show_bug.cgi?id=80354

Reviewed by Filip Pizlo.

This patch adds basic constant blinding support to the JIT, at the
MacroAssembler level. This means all JITs in JSC (Yarr, baseline, and DFG)
get constant blinding. Woo!

This patch only introduces blinding for Imm32, a later patch will do similar
for ImmPtr. In order to make misuse of Imm32 as a trusted type essentially
impossible, we make TrustedImm32 a private parent of Imm32 and add an explicit
accessor that's needed to access the actual value. This also means you cannot
accidentally pass an untrusted value to a function that does not perform
blinding.

To make everything work sensibly, this patch also corrects some code that was using
Imm32 when TrustedImm32 could be used, and refactors a few callers that use
untrusted immediates, so that they call slightly different varaints of the functions
that they used previously. This is largely necessary to deal with x86-32 not having
sufficient registers to handle the additional work required when we choose to blind
a constant.

  • assembler/AbstractMacroAssembler.h:

(JSC::AbstractMacroAssembler::Imm32::asTrustedImm32):
(Imm32):
(JSC::AbstractMacroAssembler::beginUninterruptedSequence):
(JSC::AbstractMacroAssembler::endUninterruptedSequence):
(JSC::AbstractMacroAssembler::AbstractMacroAssembler):
(AbstractMacroAssembler):
(JSC::AbstractMacroAssembler::inUninterruptedSequence):
(JSC::AbstractMacroAssembler::random):
(JSC::AbstractMacroAssembler::scratchRegisterForBlinding):
(JSC::AbstractMacroAssembler::shouldBlindForSpecificArch):

  • assembler/MacroAssembler.h:

(JSC::MacroAssembler::addressForPoke):
(MacroAssembler):
(JSC::MacroAssembler::poke):
(JSC::MacroAssembler::branchPtr):
(JSC::MacroAssembler::branch32):
(JSC::MacroAssembler::convertInt32ToDouble):
(JSC::MacroAssembler::shouldBlind):
(JSC::MacroAssembler::BlindedImm32::BlindedImm32):
(BlindedImm32):
(JSC::MacroAssembler::keyForConstant):
(JSC::MacroAssembler::xorBlindConstant):
(JSC::MacroAssembler::additionBlindedConstant):
(JSC::MacroAssembler::andBlindedConstant):
(JSC::MacroAssembler::orBlindedConstant):
(JSC::MacroAssembler::loadXorBlindedConstant):
(JSC::MacroAssembler::add32):
(JSC::MacroAssembler::addPtr):
(JSC::MacroAssembler::and32):
(JSC::MacroAssembler::andPtr):
(JSC::MacroAssembler::move):
(JSC::MacroAssembler::or32):
(JSC::MacroAssembler::store32):
(JSC::MacroAssembler::sub32):
(JSC::MacroAssembler::subPtr):
(JSC::MacroAssembler::xor32):
(JSC::MacroAssembler::branchAdd32):
(JSC::MacroAssembler::branchMul32):
(JSC::MacroAssembler::branchSub32):
(JSC::MacroAssembler::trustedImm32ForShift):
(JSC::MacroAssembler::lshift32):
(JSC::MacroAssembler::rshift32):
(JSC::MacroAssembler::urshift32):

  • assembler/MacroAssemblerARMv7.h:

(MacroAssemblerARMv7):
(JSC::MacroAssemblerARMv7::scratchRegisterForBlinding):
(JSC::MacroAssemblerARMv7::shouldBlindForSpecificArch):

  • assembler/MacroAssemblerX86_64.h:

(JSC::MacroAssemblerX86_64::branchSubPtr):
(MacroAssemblerX86_64):
(JSC::MacroAssemblerX86_64::scratchRegisterForBlinding):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::linkOSRExits):
(JSC::DFG::JITCompiler::compileBody):
(JSC::DFG::JITCompiler::compileFunction):

  • dfg/DFGOSRExitCompiler32_64.cpp:

(JSC::DFG::OSRExitCompiler::compileExit):

  • dfg/DFGOSRExitCompiler64.cpp:

(JSC::DFG::OSRExitCompiler::compileExit):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compile):
(JSC::DFG::SpeculativeJIT::compileArithSub):
(JSC::DFG::SpeculativeJIT::compileStrictEqForConstant):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::callOperation):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::emitCall):
(JSC::DFG::SpeculativeJIT::compileObjectEquality):
(JSC::DFG::SpeculativeJIT::compileDoubleCompare):
(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::emitCall):
(JSC::DFG::SpeculativeJIT::compileDoubleCompare):
(JSC::DFG::SpeculativeJIT::compile):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileSlowCases):
(JSC::JIT::privateCompile):

  • jit/JITArithmetic.cpp:

(JSC::JIT::compileBinaryArithOp):
(JSC::JIT::emit_op_add):
(JSC::JIT::emit_op_mul):
(JSC::JIT::emit_op_div):

  • jit/JITArithmetic32_64.cpp:

(JSC::JIT::emitAdd32Constant):
(JSC::JIT::emitSub32Constant):
(JSC::JIT::emitBinaryDoubleOp):
(JSC::JIT::emitSlow_op_mul):
(JSC::JIT::emit_op_div):

  • jit/JITCall.cpp:

(JSC::JIT::compileLoadVarargs):

  • jit/JITCall32_64.cpp:

(JSC::JIT::compileLoadVarargs):

  • jit/JITInlineMethods.h:

(JSC::JIT::updateTopCallFrame):
(JSC::JIT::emitValueProfilingSite):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emitSlow_op_jfalse):
(JSC::JIT::emitSlow_op_jtrue):

  • jit/JITStubCall.h:

(JITStubCall):
(JSC::JITStubCall::addArgument):

  • yarr/YarrJIT.cpp:

(JSC::Yarr::YarrGenerator::backtrack):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r109824 r109834  
     12012-03-05  Oliver Hunt  <[email protected]>
     2
     3        Add basic support for constant blinding to the JIT
     4        https://bugs.webkit.org/show_bug.cgi?id=80354
     5
     6        Reviewed by Filip Pizlo.
     7
     8        This patch adds basic constant blinding support to the JIT, at the
     9        MacroAssembler level.  This means all JITs in JSC (Yarr, baseline, and DFG)
     10        get constant blinding.  Woo!
     11
     12        This patch only introduces blinding for Imm32, a later patch will do similar
     13        for ImmPtr.  In order to make misuse of Imm32 as a trusted type essentially
     14        impossible, we make TrustedImm32 a private parent of Imm32 and add an explicit
     15        accessor that's needed to access the actual value.  This also means you cannot
     16        accidentally pass an untrusted value to a function that does not perform
     17        blinding.
     18
     19        To make everything work sensibly, this patch also corrects some code that was using
     20        Imm32 when TrustedImm32 could be used, and refactors a few callers that use
     21        untrusted immediates, so that they call slightly different varaints of the functions
     22        that they used previously.  This is largely necessary to deal with x86-32 not having
     23        sufficient registers to handle the additional work required when we choose to blind
     24        a constant.
     25
     26        * assembler/AbstractMacroAssembler.h:
     27        (JSC::AbstractMacroAssembler::Imm32::asTrustedImm32):
     28        (Imm32):
     29        (JSC::AbstractMacroAssembler::beginUninterruptedSequence):
     30        (JSC::AbstractMacroAssembler::endUninterruptedSequence):
     31        (JSC::AbstractMacroAssembler::AbstractMacroAssembler):
     32        (AbstractMacroAssembler):
     33        (JSC::AbstractMacroAssembler::inUninterruptedSequence):
     34        (JSC::AbstractMacroAssembler::random):
     35        (JSC::AbstractMacroAssembler::scratchRegisterForBlinding):
     36        (JSC::AbstractMacroAssembler::shouldBlindForSpecificArch):
     37        * assembler/MacroAssembler.h:
     38        (JSC::MacroAssembler::addressForPoke):
     39        (MacroAssembler):
     40        (JSC::MacroAssembler::poke):
     41        (JSC::MacroAssembler::branchPtr):
     42        (JSC::MacroAssembler::branch32):
     43        (JSC::MacroAssembler::convertInt32ToDouble):
     44        (JSC::MacroAssembler::shouldBlind):
     45        (JSC::MacroAssembler::BlindedImm32::BlindedImm32):
     46        (BlindedImm32):
     47        (JSC::MacroAssembler::keyForConstant):
     48        (JSC::MacroAssembler::xorBlindConstant):
     49        (JSC::MacroAssembler::additionBlindedConstant):
     50        (JSC::MacroAssembler::andBlindedConstant):
     51        (JSC::MacroAssembler::orBlindedConstant):
     52        (JSC::MacroAssembler::loadXorBlindedConstant):
     53        (JSC::MacroAssembler::add32):
     54        (JSC::MacroAssembler::addPtr):
     55        (JSC::MacroAssembler::and32):
     56        (JSC::MacroAssembler::andPtr):
     57        (JSC::MacroAssembler::move):
     58        (JSC::MacroAssembler::or32):
     59        (JSC::MacroAssembler::store32):
     60        (JSC::MacroAssembler::sub32):
     61        (JSC::MacroAssembler::subPtr):
     62        (JSC::MacroAssembler::xor32):
     63        (JSC::MacroAssembler::branchAdd32):
     64        (JSC::MacroAssembler::branchMul32):
     65        (JSC::MacroAssembler::branchSub32):
     66        (JSC::MacroAssembler::trustedImm32ForShift):
     67        (JSC::MacroAssembler::lshift32):
     68        (JSC::MacroAssembler::rshift32):
     69        (JSC::MacroAssembler::urshift32):
     70        * assembler/MacroAssemblerARMv7.h:
     71        (MacroAssemblerARMv7):
     72        (JSC::MacroAssemblerARMv7::scratchRegisterForBlinding):
     73        (JSC::MacroAssemblerARMv7::shouldBlindForSpecificArch):
     74        * assembler/MacroAssemblerX86_64.h:
     75        (JSC::MacroAssemblerX86_64::branchSubPtr):
     76        (MacroAssemblerX86_64):
     77        (JSC::MacroAssemblerX86_64::scratchRegisterForBlinding):
     78        * dfg/DFGJITCompiler.cpp:
     79        (JSC::DFG::JITCompiler::linkOSRExits):
     80        (JSC::DFG::JITCompiler::compileBody):
     81        (JSC::DFG::JITCompiler::compileFunction):
     82        * dfg/DFGOSRExitCompiler32_64.cpp:
     83        (JSC::DFG::OSRExitCompiler::compileExit):
     84        * dfg/DFGOSRExitCompiler64.cpp:
     85        (JSC::DFG::OSRExitCompiler::compileExit):
     86        * dfg/DFGSpeculativeJIT.cpp:
     87        (JSC::DFG::SpeculativeJIT::compile):
     88        (JSC::DFG::SpeculativeJIT::compileArithSub):
     89        (JSC::DFG::SpeculativeJIT::compileStrictEqForConstant):
     90        * dfg/DFGSpeculativeJIT.h:
     91        (JSC::DFG::SpeculativeJIT::callOperation):
     92        * dfg/DFGSpeculativeJIT32_64.cpp:
     93        (JSC::DFG::SpeculativeJIT::emitCall):
     94        (JSC::DFG::SpeculativeJIT::compileObjectEquality):
     95        (JSC::DFG::SpeculativeJIT::compileDoubleCompare):
     96        (JSC::DFG::SpeculativeJIT::compile):
     97        * dfg/DFGSpeculativeJIT64.cpp:
     98        (JSC::DFG::SpeculativeJIT::emitCall):
     99        (JSC::DFG::SpeculativeJIT::compileDoubleCompare):
     100        (JSC::DFG::SpeculativeJIT::compile):
     101        * jit/JIT.cpp:
     102        (JSC::JIT::privateCompileSlowCases):
     103        (JSC::JIT::privateCompile):
     104        * jit/JITArithmetic.cpp:
     105        (JSC::JIT::compileBinaryArithOp):
     106        (JSC::JIT::emit_op_add):
     107        (JSC::JIT::emit_op_mul):
     108        (JSC::JIT::emit_op_div):
     109        * jit/JITArithmetic32_64.cpp:
     110        (JSC::JIT::emitAdd32Constant):
     111        (JSC::JIT::emitSub32Constant):
     112        (JSC::JIT::emitBinaryDoubleOp):
     113        (JSC::JIT::emitSlow_op_mul):
     114        (JSC::JIT::emit_op_div):
     115        * jit/JITCall.cpp:
     116        (JSC::JIT::compileLoadVarargs):
     117        * jit/JITCall32_64.cpp:
     118        (JSC::JIT::compileLoadVarargs):
     119        * jit/JITInlineMethods.h:
     120        (JSC::JIT::updateTopCallFrame):
     121        (JSC::JIT::emitValueProfilingSite):
     122        * jit/JITOpcodes32_64.cpp:
     123        (JSC::JIT::emitSlow_op_jfalse):
     124        (JSC::JIT::emitSlow_op_jtrue):
     125        * jit/JITStubCall.h:
     126        (JITStubCall):
     127        (JSC::JITStubCall::addArgument):
     128        * yarr/YarrJIT.cpp:
     129        (JSC::Yarr::YarrGenerator::backtrack):
     130
    11312012-03-05  Gavin Barraclough  <[email protected]>
    2132
Note: See TracChangeset for help on using the changeset viewer.