Ignore:
Timestamp:
Mar 10, 2017, 11:17:48 PM (8 years ago)
Author:
[email protected]
Message:

The JITs should be able to emit fast TLS loads
https://bugs.webkit.org/show_bug.cgi?id=169483

Reviewed by Keith Miller.

Source/JavaScriptCore:

Added loadFromTLS32/64/Ptr to the MacroAssembler and added a B3 test for this.

  • assembler/ARM64Assembler.h:

(JSC::ARM64Assembler::mrs_TPIDRRO_EL0):

  • assembler/MacroAssembler.h:

(JSC::MacroAssembler::loadFromTLSPtr):

  • assembler/MacroAssemblerARM64.h:

(JSC::MacroAssemblerARM64::loadFromTLS32):
(JSC::MacroAssemblerARM64::loadFromTLS64):

  • assembler/MacroAssemblerX86Common.h:

(JSC::MacroAssemblerX86Common::loadFromTLS32):

  • assembler/MacroAssemblerX86_64.h:

(JSC::MacroAssemblerX86_64::loadFromTLS64):

  • assembler/X86Assembler.h:

(JSC::X86Assembler::adcl_im):
(JSC::X86Assembler::addl_mr):
(JSC::X86Assembler::addl_im):
(JSC::X86Assembler::andl_im):
(JSC::X86Assembler::orl_im):
(JSC::X86Assembler::orl_rm):
(JSC::X86Assembler::subl_im):
(JSC::X86Assembler::cmpb_im):
(JSC::X86Assembler::cmpl_rm):
(JSC::X86Assembler::cmpl_im):
(JSC::X86Assembler::testb_im):
(JSC::X86Assembler::movb_i8m):
(JSC::X86Assembler::movb_rm):
(JSC::X86Assembler::movl_mr):
(JSC::X86Assembler::movq_mr):
(JSC::X86Assembler::movsxd_rr):
(JSC::X86Assembler::gs):
(JSC::X86Assembler::X86InstructionFormatter::SingleInstructionBufferWriter::memoryModRM):

  • b3/testb3.cpp:

(JSC::B3::testFastTLS):
(JSC::B3::run):

Source/WTF:

Consolidated what we know about fast TLS in FastTLS.h.

  • WTF.xcodeproj/project.pbxproj:
  • wtf/CMakeLists.txt:
  • wtf/FastTLS.h: Added.

(WTF::loadFastTLS):
(WTF::fastTLSOffsetForKey):

  • wtf/Platform.h:
  • wtf/WTFThreadData.cpp:

(WTF::WTFThreadData::createAndRegisterForGetspecificDirect):

  • wtf/WTFThreadData.h:

(WTF::wtfThreadData):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/b3/testb3.cpp

    r213714 r213753  
    7070#include <cmath>
    7171#include <string>
     72#include <wtf/FastTLS.h>
    7273#include <wtf/ListDump.h>
    7374#include <wtf/Lock.h>
     
    1520915210    for (unsigned value : values)
    1521015211        CHECK_EQ(numToStore, value);
     15212}
     15213
     15214void testFastTLS()
     15215{
     15216#if ENABLE(FAST_TLS_JIT)
     15217    _pthread_setspecific_direct(WTF_TESTING_KEY, bitwise_cast<void*>(static_cast<uintptr_t>(0xbeef)));
     15218   
     15219    Procedure proc;
     15220    BasicBlock* root = proc.addBlock();
     15221   
     15222    PatchpointValue* patchpoint = root->appendNew<PatchpointValue>(proc, pointerType(), Origin());
     15223    patchpoint->clobber(RegisterSet::macroScratchRegisters());
     15224    patchpoint->setGenerator(
     15225        [&] (CCallHelpers& jit, const StackmapGenerationParams& params) {
     15226            AllowMacroScratchRegisterUsage allowScratch(jit);
     15227            jit.loadFromTLSPtr(fastTLSOffsetForKey(WTF_TESTING_KEY), params[0].gpr());
     15228        });
     15229   
     15230    root->appendNew<Value>(proc, Return, Origin(), patchpoint);
     15231   
     15232    CHECK_EQ(compileAndRun<uintptr_t>(proc), static_cast<uintptr_t>(0xbeef));
     15233#endif
    1521115234}
    1521215235
     
    1673716760    RUN(testWasmBoundsCheck(std::numeric_limits<unsigned>::max() - 5));
    1673816761    RUN(testWasmAddress());
     16762   
     16763    RUN(testFastTLS());
    1673916764
    1674016765    if (isX86()) {
Note: See TracChangeset for help on using the changeset viewer.