Changeset 230444 in webkit


Ignore:
Timestamp:
Apr 9, 2018 10:42:01 AM (6 years ago)
Author:
mark.lam@apple.com
Message:

Add pointer profiling to the FTL and supporting code.
https://bugs.webkit.org/show_bug.cgi?id=184395
<rdar://problem/39264019>

Reviewed by Michael Saboff and Filip Pizlo.

  • assembler/CodeLocation.h:

(JSC::CodeLocationLabel::retagged):
(JSC::CodeLocationJump::retagged):

  • assembler/LinkBuffer.h:

(JSC::LinkBuffer::locationOf):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::linkOSRExits):
(JSC::DFG::JITCompiler::link):

  • ftl/FTLCompile.cpp:

(JSC::FTL::compile):

  • ftl/FTLExceptionTarget.cpp:

(JSC::FTL::ExceptionTarget::label):
(JSC::FTL::ExceptionTarget::jumps):

  • ftl/FTLExceptionTarget.h:
  • ftl/FTLJITCode.cpp:

(JSC::FTL::JITCode::executableAddressAtOffset):

  • ftl/FTLLazySlowPath.cpp:

(JSC::FTL::LazySlowPath::~LazySlowPath):
(JSC::FTL::LazySlowPath::initialize):
(JSC::FTL::LazySlowPath::generate):
(JSC::FTL::LazySlowPath::LazySlowPath): Deleted.

  • ftl/FTLLazySlowPath.h:
  • ftl/FTLLink.cpp:

(JSC::FTL::link):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::lower):
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstruct):
(JSC::FTL::DFG::LowerDFGToB3::compileDirectCallOrConstruct):
(JSC::FTL::DFG::LowerDFGToB3::compileTailCall):
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread):
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs):
(JSC::FTL::DFG::LowerDFGToB3::compileCallEval):
(JSC::FTL::DFG::LowerDFGToB3::lazySlowPath):

  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileStub):
(JSC::FTL::compileFTLOSRExit):

  • ftl/FTLOSRExitHandle.cpp:

(JSC::FTL::OSRExitHandle::emitExitThunk):

  • ftl/FTLOperations.cpp:

(JSC::FTL::compileFTLLazySlowPath):

  • ftl/FTLOutput.h:

(JSC::FTL::Output::callWithoutSideEffects):
(JSC::FTL::Output::operation):

  • ftl/FTLPatchpointExceptionHandle.cpp:

(JSC::FTL::PatchpointExceptionHandle::scheduleExitCreationForUnwind):

  • ftl/FTLSlowPathCall.cpp:

(JSC::FTL::SlowPathCallContext::makeCall):

  • ftl/FTLSlowPathCallKey.h:

(JSC::FTL::SlowPathCallKey::withCallTarget):
(JSC::FTL::SlowPathCallKey::callPtrTag const):

  • ftl/FTLThunks.cpp:

(JSC::FTL::genericGenerationThunkGenerator):
(JSC::FTL::osrExitGenerationThunkGenerator):
(JSC::FTL::lazySlowPathGenerationThunkGenerator):
(JSC::FTL::slowPathCallThunkGenerator):

  • jit/JITMathIC.h:

(JSC::isProfileEmpty):

  • jit/Repatch.cpp:

(JSC::readPutICCallTarget):
(JSC::ftlThunkAwareRepatchCall):
(JSC::tryCacheGetByID):
(JSC::repatchGetByID):
(JSC::tryCachePutByID):
(JSC::repatchPutByID):
(JSC::repatchIn):
(JSC::resetGetByID):
(JSC::resetPutByID):
(JSC::readCallTarget): Deleted.

  • jit/Repatch.h:
  • runtime/PtrTag.h:
Location:
trunk/Source/JavaScriptCore
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r230403 r230444  
     12018-04-08  Mark Lam  <mark.lam@apple.com>
     2
     3        Add pointer profiling to the FTL and supporting code.
     4        https://bugs.webkit.org/show_bug.cgi?id=184395
     5        <rdar://problem/39264019>
     6
     7        Reviewed by Michael Saboff and Filip Pizlo.
     8
     9        * assembler/CodeLocation.h:
     10        (JSC::CodeLocationLabel::retagged):
     11        (JSC::CodeLocationJump::retagged):
     12        * assembler/LinkBuffer.h:
     13        (JSC::LinkBuffer::locationOf):
     14        * dfg/DFGJITCompiler.cpp:
     15        (JSC::DFG::JITCompiler::linkOSRExits):
     16        (JSC::DFG::JITCompiler::link):
     17        * ftl/FTLCompile.cpp:
     18        (JSC::FTL::compile):
     19        * ftl/FTLExceptionTarget.cpp:
     20        (JSC::FTL::ExceptionTarget::label):
     21        (JSC::FTL::ExceptionTarget::jumps):
     22        * ftl/FTLExceptionTarget.h:
     23        * ftl/FTLJITCode.cpp:
     24        (JSC::FTL::JITCode::executableAddressAtOffset):
     25        * ftl/FTLLazySlowPath.cpp:
     26        (JSC::FTL::LazySlowPath::~LazySlowPath):
     27        (JSC::FTL::LazySlowPath::initialize):
     28        (JSC::FTL::LazySlowPath::generate):
     29        (JSC::FTL::LazySlowPath::LazySlowPath): Deleted.
     30        * ftl/FTLLazySlowPath.h:
     31        * ftl/FTLLink.cpp:
     32        (JSC::FTL::link):
     33        * ftl/FTLLowerDFGToB3.cpp:
     34        (JSC::FTL::DFG::LowerDFGToB3::lower):
     35        (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstruct):
     36        (JSC::FTL::DFG::LowerDFGToB3::compileDirectCallOrConstruct):
     37        (JSC::FTL::DFG::LowerDFGToB3::compileTailCall):
     38        (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread):
     39        (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs):
     40        (JSC::FTL::DFG::LowerDFGToB3::compileCallEval):
     41        (JSC::FTL::DFG::LowerDFGToB3::lazySlowPath):
     42        * ftl/FTLOSRExitCompiler.cpp:
     43        (JSC::FTL::compileStub):
     44        (JSC::FTL::compileFTLOSRExit):
     45        * ftl/FTLOSRExitHandle.cpp:
     46        (JSC::FTL::OSRExitHandle::emitExitThunk):
     47        * ftl/FTLOperations.cpp:
     48        (JSC::FTL::compileFTLLazySlowPath):
     49        * ftl/FTLOutput.h:
     50        (JSC::FTL::Output::callWithoutSideEffects):
     51        (JSC::FTL::Output::operation):
     52        * ftl/FTLPatchpointExceptionHandle.cpp:
     53        (JSC::FTL::PatchpointExceptionHandle::scheduleExitCreationForUnwind):
     54        * ftl/FTLSlowPathCall.cpp:
     55        (JSC::FTL::SlowPathCallContext::makeCall):
     56        * ftl/FTLSlowPathCallKey.h:
     57        (JSC::FTL::SlowPathCallKey::withCallTarget):
     58        (JSC::FTL::SlowPathCallKey::callPtrTag const):
     59        * ftl/FTLThunks.cpp:
     60        (JSC::FTL::genericGenerationThunkGenerator):
     61        (JSC::FTL::osrExitGenerationThunkGenerator):
     62        (JSC::FTL::lazySlowPathGenerationThunkGenerator):
     63        (JSC::FTL::slowPathCallThunkGenerator):
     64        * jit/JITMathIC.h:
     65        (JSC::isProfileEmpty):
     66        * jit/Repatch.cpp:
     67        (JSC::readPutICCallTarget):
     68        (JSC::ftlThunkAwareRepatchCall):
     69        (JSC::tryCacheGetByID):
     70        (JSC::repatchGetByID):
     71        (JSC::tryCachePutByID):
     72        (JSC::repatchPutByID):
     73        (JSC::repatchIn):
     74        (JSC::resetGetByID):
     75        (JSC::resetPutByID):
     76        (JSC::readCallTarget): Deleted.
     77        * jit/Repatch.h:
     78        * runtime/PtrTag.h:
     79
    1802018-04-08  Yusuke Suzuki  <utatane.tea@gmail.com>
    281
  • trunk/Source/JavaScriptCore/assembler/CodeLocation.h

    r225363 r230444  
    11/*
    2  * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9494    explicit CodeLocationLabel(void* location)
    9595        : CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
     96
     97    CodeLocationLabel retagged(PtrTag oldTag, PtrTag newTag) { return CodeLocationLabel(MacroAssemblerCodePtr::retagged(oldTag, newTag)); }
    9698};
    9799
     
    103105    explicit CodeLocationJump(void* location)
    104106        : CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
     107
     108    CodeLocationJump retagged(PtrTag oldTag, PtrTag newTag) { return CodeLocationJump(MacroAssemblerCodePtr::retagged(oldTag, newTag)); }
    105109};
    106110
  • trunk/Source/JavaScriptCore/assembler/LinkBuffer.h

    r230129 r230444  
    187187    }
    188188
    189     CodeLocationLabel locationOf(PatchableJump jump)
    190     {
    191         return CodeLocationLabel(MacroAssembler::getLinkerAddress(code(), applyOffset(jump.m_jump.m_label)));
     189    CodeLocationLabel locationOf(PatchableJump jump, PtrTag tag = NoPtrTag)
     190    {
     191        return CodeLocationLabel(MacroAssembler::getLinkerAddress(code(), applyOffset(jump.m_jump.m_label), tag));
    192192    }
    193193
  • trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp

    r230294 r230444  
    11/*
    2  * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8787   
    8888    MacroAssemblerCodeRef osrExitThunk = vm()->getCTIStub(osrExitThunkGenerator);
    89     CodeLocationLabel osrExitThunkLabel = CodeLocationLabel(osrExitThunk.code());
     89    PtrTag osrExitThunkTag = ptrTag(DFGOSRExitPtrTag, vm());
     90    CodeLocationLabel osrExitThunkLabel = CodeLocationLabel(osrExitThunk.retaggedCode(osrExitThunkTag, NearJumpPtrTag));
    9091    for (unsigned i = 0; i < m_jitCode->osrExit.size(); ++i) {
    9192        OSRExitCompilationInfo& info = m_exitCompilationInfo[i];
     
    321322   
    322323    MacroAssemblerCodeRef osrExitThunk = vm()->getCTIStub(osrExitGenerationThunkGenerator);
    323     CodeLocationLabel target = CodeLocationLabel(osrExitThunk.code());
     324    PtrTag osrExitThunkTag = ptrTag(DFGOSRExitPtrTag, vm());
     325    CodeLocationLabel target = CodeLocationLabel(osrExitThunk.retaggedCode(osrExitThunkTag, NearJumpPtrTag));
    324326    for (unsigned i = 0; i < m_jitCode->osrExit.size(); ++i) {
    325327        OSRExitCompilationInfo& info = m_exitCompilationInfo[i];
  • trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp

    r229609 r230444  
    11/*
    2  * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8080        std::make_unique<RegisterAtOffsetList>(state.proc->calleeSaveRegisterAtOffsetList());
    8181    if (shouldDumpDisassembly())
    82         dataLog("Unwind info for ", CodeBlockWithJITType(state.graph.m_codeBlock, JITCode::FTLJIT), ": ", *registerOffsets, "\n");
    83     state.graph.m_codeBlock->setCalleeSaveRegisters(WTFMove(registerOffsets));
     82        dataLog("Unwind info for ", CodeBlockWithJITType(codeBlock, JITCode::FTLJIT), ": ", *registerOffsets, "\n");
     83    codeBlock->setCalleeSaveRegisters(WTFMove(registerOffsets));
    8484    ASSERT(!(state.proc->frameSize() % sizeof(EncodedJSValue)));
    8585    state.jitCode->common.frameRegisterCount = state.proc->frameSize() / sizeof(EncodedJSValue);
     
    135135    jit.move(MacroAssembler::TrustedImmPtr(&vm), GPRInfo::argumentGPR0);
    136136    jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
    137     CCallHelpers::Call call = jit.call(NoPtrTag);
     137    PtrTag callTag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     138    CCallHelpers::Call call = jit.call(callTag);
    138139    jit.jumpToExceptionHandler(vm);
    139140    jit.addLinkTask(
    140141        [=] (LinkBuffer& linkBuffer) {
    141             linkBuffer.link(call, FunctionPtr(lookupExceptionHandler));
     142            linkBuffer.link(call, FunctionPtr(lookupExceptionHandler, callTag));
    142143        });
    143144
     
    153154        codeBlock->setPCToCodeOriginMap(std::make_unique<PCToCodeOriginMap>(PCToCodeOriginMapBuilder(vm, WTFMove(originMap)), *state.finalizer->b3CodeLinkBuffer));
    154155
    155     CodeLocationLabel label = state.finalizer->b3CodeLinkBuffer->locationOf(state.proc->entrypointLabel(0));
     156    PtrTag entryTag = ptrTag(FTLCodePtrTag, codeBlock);
     157    CodeLocationLabel label = state.finalizer->b3CodeLinkBuffer->locationOf(state.proc->entrypointLabel(0), entryTag);
    156158    state.generatedFunction = label.executableAddress<GeneratedFunction>();
    157159    state.jitCode->initializeB3Byproducts(state.proc->releaseByproducts());
     
    162164        Vector<FlushFormat> argumentFormats = state.graph.m_argumentFormats[entrypointIndex];
    163165        state.jitCode->common.appendCatchEntrypoint(
    164             catchBytecodeOffset, state.finalizer->b3CodeLinkBuffer->locationOf(state.proc->entrypointLabel(entrypointIndex)).executableAddress(), WTFMove(argumentFormats));
     166            catchBytecodeOffset, state.finalizer->b3CodeLinkBuffer->locationOf(state.proc->entrypointLabel(entrypointIndex), ExceptionHandlerPtrTag).executableAddress(), WTFMove(argumentFormats));
    165167    }
    166168    state.jitCode->common.finalizeCatchEntrypoints();
  • trunk/Source/JavaScriptCore/ftl/FTLExceptionTarget.cpp

    r196729 r230444  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737}
    3838
    39 CodeLocationLabel ExceptionTarget::label(LinkBuffer& linkBuffer)
     39CodeLocationLabel ExceptionTarget::label(LinkBuffer& linkBuffer, PtrTag handlerTag)
    4040{
    4141    if (m_isDefaultHandler)
    42         return linkBuffer.locationOf(*m_defaultHandler);
    43     return linkBuffer.locationOf(m_handle->label);
     42        return linkBuffer.locationOf(*m_defaultHandler, handlerTag);
     43    return linkBuffer.locationOf(m_handle->label, handlerTag);
    4444}
    4545
     
    5151        jit.addLinkTask(
    5252            [=] (LinkBuffer& linkBuffer) {
    53                 linkBuffer.link(*result, linkBuffer.locationOf(*defaultHandler));
     53                linkBuffer.link(*result, linkBuffer.locationOf(*defaultHandler, ExceptionHandlerPtrTag));
    5454            });
    5555    } else {
     
    5757        jit.addLinkTask(
    5858            [=] (LinkBuffer& linkBuffer) {
    59                 linkBuffer.link(*result, linkBuffer.locationOf(handle->label));
     59                linkBuffer.link(*result, linkBuffer.locationOf(handle->label, DFGOSRExitPtrTag));
    6060            });
    6161    }
  • trunk/Source/JavaScriptCore/ftl/FTLExceptionTarget.h

    r206525 r230444  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444
    4545    // It's OK to call this during linking, but not any sooner.
    46     CodeLocationLabel label(LinkBuffer&);
     46    CodeLocationLabel label(LinkBuffer&, PtrTag handlerTag);
    4747
    4848    // Or, you can get a JumpList at any time. Anything you add to this JumpList will be linked to
  • trunk/Source/JavaScriptCore/ftl/FTLJITCode.cpp

    r225363 r230444  
    11/*
    2  * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030
    3131#include "FTLState.h"
     32#include "PtrTag.h"
    3233
    3334namespace JSC { namespace FTL {
     
    8687{
    8788    return m_addressForCall.executableAddress<char*>() + offset;
     89    assertIsTaggedWith(m_addressForCall.executableAddress(), CodeEntryPtrTag);
     90    if (!offset)
     91        return m_addressForCall.executableAddress();
     92
     93    char* executableAddress = untagCodePtr<char*>(m_addressForCall.executableAddress(), CodeEntryPtrTag);
     94    return tagCodePtr(executableAddress + offset, CodeEntryPtrTag);
    8895}
    8996
  • trunk/Source/JavaScriptCore/ftl/FTLLazySlowPath.cpp

    r229609 r230444  
    3434namespace JSC { namespace FTL {
    3535
    36 LazySlowPath::LazySlowPath(
     36LazySlowPath::~LazySlowPath()
     37{
     38}
     39
     40void LazySlowPath::initialize(
    3741    CodeLocationJump patchableJump, CodeLocationLabel done,
    3842    CodeLocationLabel exceptionTarget,
    3943    const RegisterSet& usedRegisters, CallSiteIndex callSiteIndex, RefPtr<Generator> generator
    4044    )
    41     : m_patchableJump(patchableJump)
    42     , m_done(done)
    43     , m_exceptionTarget(exceptionTarget)
    44     , m_usedRegisters(usedRegisters)
    45     , m_callSiteIndex(callSiteIndex)
    46     , m_generator(generator)
    4745{
    48 }
    49 
    50 LazySlowPath::~LazySlowPath()
    51 {
     46    m_patchableJump = patchableJump;
     47    m_done = done;
     48    m_exceptionTarget = exceptionTarget;
     49    m_usedRegisters = usedRegisters;
     50    m_callSiteIndex = callSiteIndex;
     51    m_generator = generator;
    5252}
    5353
     
    6464    m_generator->run(jit, params);
    6565
     66    PtrTag slowPathTag = ptrTag(FTLLazySlowPathPtrTag, bitwise_cast<PtrTag>(this));
    6667    LinkBuffer linkBuffer(jit, codeBlock, JITCompilationMustSucceed);
    67     linkBuffer.link(params.doneJumps, m_done);
     68    linkBuffer.link(params.doneJumps, m_done.retagged(slowPathTag, NearJumpPtrTag));
    6869    if (m_exceptionTarget)
    69         linkBuffer.link(exceptionJumps, m_exceptionTarget);
    70     m_stub = FINALIZE_CODE_FOR(codeBlock, linkBuffer, NoPtrTag, "Lazy slow path call stub");
     70        linkBuffer.link(exceptionJumps, m_exceptionTarget.retagged(slowPathTag, NearJumpPtrTag));
     71    m_stub = FINALIZE_CODE_FOR(codeBlock, linkBuffer, slowPathTag, "Lazy slow path call stub");
    7172
    72     MacroAssembler::repatchJump(m_patchableJump, CodeLocationLabel(m_stub.code()));
     73    MacroAssembler::repatchJump(m_patchableJump.retagged(slowPathTag, NearJumpPtrTag), CodeLocationLabel(m_stub.retaggedCode(slowPathTag, NearJumpPtrTag)));
    7374}
    7475
  • trunk/Source/JavaScriptCore/ftl/FTLLazySlowPath.h

    r206525 r230444  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6464        return createSharedTask<GeneratorFunction>(functor);
    6565    }
    66    
    67     LazySlowPath(
     66
     67    LazySlowPath() = default;
     68
     69    ~LazySlowPath();
     70
     71    void initialize(
    6872        CodeLocationJump patchableJump, CodeLocationLabel done,
    6973        CodeLocationLabel exceptionTarget, const RegisterSet& usedRegisters,
    7074        CallSiteIndex, RefPtr<Generator>
    7175        );
    72 
    73     ~LazySlowPath();
    7476
    7577    CodeLocationJump patchableJump() const { return m_patchableJump; }
  • trunk/Source/JavaScriptCore/ftl/FTLLink.cpp

    r229609 r230444  
    11/*
    2  * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    141141            jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
    142142            jit.storePtr(GPRInfo::callFrameRegister, &vm.topCallFrame);
    143             CCallHelpers::Call callArityCheck = jit.call(NoPtrTag);
     143            PtrTag callTag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     144            CCallHelpers::Call callArityCheck = jit.call(callTag);
    144145
    145146            auto noException = jit.branch32(CCallHelpers::GreaterThanOrEqual, GPRInfo::returnValueGPR, CCallHelpers::TrustedImm32(0));
     
    147148            jit.move(CCallHelpers::TrustedImmPtr(&vm), GPRInfo::argumentGPR0);
    148149            jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
    149             CCallHelpers::Call callLookupExceptionHandlerFromCallerFrame = jit.call(NoPtrTag);
     150            PtrTag lookupTag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     151            CCallHelpers::Call callLookupExceptionHandlerFromCallerFrame = jit.call(lookupTag);
    150152            jit.jumpToExceptionHandler(vm);
    151153            noException.link(&jit);
     
    158160            jit.move(GPRInfo::returnValueGPR, GPRInfo::argumentGPR0);
    159161            jit.emitFunctionEpilogue();
     162            jit.untagReturnAddress();
    160163            mainPathJumps.append(jit.branchTest32(CCallHelpers::Zero, GPRInfo::argumentGPR0));
    161164            jit.emitFunctionPrologue();
    162             CCallHelpers::Call callArityFixup = jit.call(NoPtrTag);
     165            CCallHelpers::Call callArityFixup = jit.nearCall();
    163166            jit.emitFunctionEpilogue();
     167            jit.untagReturnAddress();
    164168            mainPathJumps.append(jit.jump());
    165169
     
    169173                return;
    170174            }
    171             linkBuffer->link(callArityCheck, codeBlock->m_isConstructor ? operationConstructArityCheck : operationCallArityCheck);
    172             linkBuffer->link(callLookupExceptionHandlerFromCallerFrame, lookupExceptionHandlerFromCallerFrame);
    173             linkBuffer->link(callArityFixup, FunctionPtr((vm.getCTIStub(arityFixupGenerator)).code()));
     175            linkBuffer->link(callArityCheck, FunctionPtr(codeBlock->m_isConstructor ? operationConstructArityCheck : operationCallArityCheck, callTag));
     176            linkBuffer->link(callLookupExceptionHandlerFromCallerFrame, FunctionPtr(lookupExceptionHandlerFromCallerFrame, lookupTag));
     177            linkBuffer->link(callArityFixup, FunctionPtr(vm.getCTIStub(arityFixupGenerator).retaggedCode(ptrTag(ArityFixupPtrTag, &vm), NearCallPtrTag)));
    174178            linkBuffer->link(mainPathJumps, CodeLocationLabel(bitwise_cast<void*>(state.generatedFunction)));
    175179        }
    176180       
    177         state.jitCode->initializeAddressForCall(MacroAssemblerCodePtr(bitwise_cast<void*>(state.generatedFunction)));
     181        PtrTag entryTag = ptrTag(FTLCodePtrTag, codeBlock);
     182        state.jitCode->initializeAddressForCall(MacroAssemblerCodePtr(retagCodePtr<void*>(state.generatedFunction, entryTag, CodeEntryPtrTag)));
    178183        break;
    179184    }
     
    186191        CCallHelpers::Label start = jit.label();
    187192        jit.emitFunctionEpilogue();
     193        jit.untagReturnAddress();
    188194        CCallHelpers::Jump mainPathJump = jit.jump();
    189195       
     
    195201        linkBuffer->link(mainPathJump, CodeLocationLabel(bitwise_cast<void*>(state.generatedFunction)));
    196202
    197         state.jitCode->initializeAddressForCall(linkBuffer->locationOf(start));
     203        state.jitCode->initializeAddressForCall(linkBuffer->locationOf(start, CodeEntryPtrTag));
    198204        break;
    199205    }
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r230376 r230444  
    287287                    jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
    288288                    jit.move(CCallHelpers::TrustedImmPtr(jit.codeBlock()), GPRInfo::argumentGPR1);
    289                     CCallHelpers::Call throwCall = jit.call(NoPtrTag);
     289                    PtrTag throwTag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     290                    CCallHelpers::Call throwCall = jit.call(throwTag);
    290291
    291292                    jit.move(CCallHelpers::TrustedImmPtr(vm), GPRInfo::argumentGPR0);
    292293                    jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
    293                     CCallHelpers::Call lookupExceptionHandlerCall = jit.call(NoPtrTag);
     294                    PtrTag lookupTag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     295                    CCallHelpers::Call lookupExceptionHandlerCall = jit.call(lookupTag);
    294296                    jit.jumpToExceptionHandler(*vm);
    295297
    296298                    jit.addLinkTask(
    297299                        [=] (LinkBuffer& linkBuffer) {
    298                             linkBuffer.link(throwCall, FunctionPtr(operationThrowStackOverflowError));
    299                             linkBuffer.link(lookupExceptionHandlerCall, FunctionPtr(lookupExceptionHandlerFromCallerFrame));
     300                            linkBuffer.link(throwCall, FunctionPtr(operationThrowStackOverflowError, throwTag));
     301                            linkBuffer.link(lookupExceptionHandlerCall, FunctionPtr(lookupExceptionHandlerFromCallerFrame, lookupTag));
    300302                    });
    301303                });
     
    364366                jit.addLinkTask(
    365367                    [=] (LinkBuffer& linkBuffer) {
    366                         linkBuffer.link(jump, linkBuffer.locationOf(*exceptionHandler));
     368                        linkBuffer.link(jump, linkBuffer.locationOf(*exceptionHandler, ExceptionHandlerPtrTag));
    367369                    });
    368370            });
     
    71467148                jit.addLinkTask(
    71477149                    [=] (LinkBuffer& linkBuffer) {
     7150                        PtrTag linkTag = ptrTag(LinkCallPtrTag, vm);
    71487151                        MacroAssemblerCodePtr linkCall =
    7149                             vm->getCTIStub(linkCallThunkGenerator).code();
     7152                            vm->getCTIStub(linkCallThunkGenerator).retaggedCode(linkTag, NearCallPtrTag);
    71507153                        linkBuffer.link(slowCall, FunctionPtr(linkCall));
    71517154
     
    72957298                            CodeLocationLabel patchableJumpLocation = linkBuffer.locationOf(patchableJump);
    72967299                            CodeLocationNearCall callLocation = linkBuffer.locationOfNearCall(call);
    7297                             CodeLocationLabel slowPathLocation = linkBuffer.locationOf(slowPath);
     7300                            CodeLocationLabel slowPathLocation = linkBuffer.locationOf(slowPath, SlowPathPtrTag);
    72987301                           
    72997302                            callLinkInfo->setCallLocations(
     
    73437346                            [=] (LinkBuffer& linkBuffer) {
    73447347                                CodeLocationNearCall callLocation = linkBuffer.locationOfNearCall(call);
    7345                                 CodeLocationLabel slowPathLocation = linkBuffer.locationOf(slowPath);
     7348                                CodeLocationLabel slowPathLocation = linkBuffer.locationOf(slowPath, NearCallPtrTag);
    73467349                               
    73477350                                linkBuffer.link(call, slowPathLocation);
     
    74677470                jit.addLinkTask(
    74687471                    [=] (LinkBuffer& linkBuffer) {
     7472                        PtrTag linkTag = ptrTag(LinkCallPtrTag, vm);
    74697473                        MacroAssemblerCodePtr linkCall =
    7470                             vm->getCTIStub(linkCallThunkGenerator).code();
     7474                            vm->getCTIStub(linkCallThunkGenerator).retaggedCode(linkTag, NearCallPtrTag);
    74717475                        linkBuffer.link(slowCall, FunctionPtr(linkCall));
    74727476
     
    76117615
    76127616                auto callWithExceptionCheck = [&] (void* callee) {
    7613                     jit.move(CCallHelpers::TrustedImmPtr(callee), GPRInfo::nonPreservedNonArgumentGPR0);
    7614                     jit.call(GPRInfo::nonPreservedNonArgumentGPR0, NoPtrTag);
     7617                    PtrTag tag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     7618                    jit.move(CCallHelpers::TrustedImmPtr(tagCFunctionPtr(callee, tag)), GPRInfo::nonPreservedNonArgumentGPR0);
     7619                    jit.call(GPRInfo::nonPreservedNonArgumentGPR0, tag);
    76157620                    exceptions->append(jit.emitExceptionCheck(*vm, AssemblyHelpers::NormalExceptionCheck, AssemblyHelpers::FarJumpWidth));
    76167621                };
     
    77667771                jit.addLinkTask(
    77677772                    [=] (LinkBuffer& linkBuffer) {
     7773                        PtrTag linkTag = ptrTag(LinkCallPtrTag, vm);
    77687774                        MacroAssemblerCodePtr linkCall =
    7769                             vm->getCTIStub(linkCallThunkGenerator).code();
     7775                            vm->getCTIStub(linkCallThunkGenerator).retaggedCode(linkTag, NearCallPtrTag);
    77707776                        linkBuffer.link(slowCall, FunctionPtr(linkCall));
    77717777                       
     
    79507956
    79517957                auto callWithExceptionCheck = [&] (void* callee) {
    7952                     jit.move(CCallHelpers::TrustedImmPtr(callee), GPRInfo::nonPreservedNonArgumentGPR0);
    7953                     jit.call(GPRInfo::nonPreservedNonArgumentGPR0, NoPtrTag);
     7958                    PtrTag tag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     7959                    jit.move(CCallHelpers::TrustedImmPtr(tagCFunctionPtr(callee, tag)), GPRInfo::nonPreservedNonArgumentGPR0);
     7960                    jit.call(GPRInfo::nonPreservedNonArgumentGPR0, tag);
    79547961                    exceptions->append(jit.emitExceptionCheck(*vm, AssemblyHelpers::NormalExceptionCheck, AssemblyHelpers::FarJumpWidth));
    79557962                };
     
    80498056                jit.addLinkTask(
    80508057                    [=] (LinkBuffer& linkBuffer) {
     8058                        PtrTag linkTag = ptrTag(LinkCallPtrTag, vm);
    80518059                        MacroAssemblerCodePtr linkCall =
    8052                             vm->getCTIStub(linkCallThunkGenerator).code();
     8060                            vm->getCTIStub(linkCallThunkGenerator).retaggedCode(linkTag, NearCallPtrTag);
    80538061                        linkBuffer.link(slowCall, FunctionPtr(linkCall));
    80548062                       
     
    81388146                jit.subPtr(CCallHelpers::TrustedImm32(requiredBytes), CCallHelpers::stackPointerRegister);
    81398147                jit.setupArguments<decltype(operationCallEval)>(GPRInfo::regT1);
    8140                 jit.move(CCallHelpers::TrustedImmPtr(bitwise_cast<void*>(operationCallEval)), GPRInfo::nonPreservedNonArgumentGPR0);
    8141                 jit.call(GPRInfo::nonPreservedNonArgumentGPR0, NoPtrTag);
     8148                PtrTag tag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     8149                jit.move(CCallHelpers::TrustedImmPtr(tagCFunctionPtr(operationCallEval, tag)), GPRInfo::nonPreservedNonArgumentGPR0);
     8150                jit.call(GPRInfo::nonPreservedNonArgumentGPR0, tag);
    81428151                exceptions->append(jit.emitExceptionCheck(state->vm(), AssemblyHelpers::NormalExceptionCheck, AssemblyHelpers::FarJumpWidth));
    81438152               
     
    1395813967                        jit.addLinkTask(
    1395913968                            [=] (LinkBuffer& linkBuffer) {
     13969                                PtrTag thunkTag = ptrTag(FTLLazySlowPathPtrTag, vm);
    1396013970                                linkBuffer.link(
    1396113971                                    generatorJump, CodeLocationLabel(
    1396213972                                        vm->getCTIStub(
    13963                                             lazySlowPathGenerationThunkGenerator).code()));
     13973                                            lazySlowPathGenerationThunkGenerator).retaggedCode(thunkTag, NearJumpPtrTag)));
    1396413974                               
     13975                                std::unique_ptr<LazySlowPath> lazySlowPath = std::make_unique<LazySlowPath>();
     13976
     13977                                PtrTag slowPathTag = ptrTag(FTLLazySlowPathPtrTag, bitwise_cast<PtrTag>(lazySlowPath.get()));
    1396513978                                CodeLocationJump linkedPatchableJump = CodeLocationJump(
    13966                                     linkBuffer.locationOf(patchableJump));
    13967                                 CodeLocationLabel linkedDone = linkBuffer.locationOf(done);
     13979                                    linkBuffer.locationOf(patchableJump, slowPathTag));
     13980
     13981                                CodeLocationLabel linkedDone = linkBuffer.locationOf(done, slowPathTag);
    1396813982
    1396913983                                CallSiteIndex callSiteIndex =
    1397013984                                    jitCode->common.addUniqueCallSiteIndex(origin);
    1397113985                                   
    13972                                 std::unique_ptr<LazySlowPath> lazySlowPath =
    13973                                     std::make_unique<LazySlowPath>(
     13986                                lazySlowPath->initialize(
    1397413987                                        linkedPatchableJump, linkedDone,
    13975                                         exceptionTarget->label(linkBuffer), usedRegisters,
     13988                                        exceptionTarget->label(linkBuffer, slowPathTag), usedRegisters,
    1397613989                                        callSiteIndex, generator);
    1397713990                                   
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp

    r229609 r230444  
    177177
    178178static void compileStub(
    179     unsigned exitID, JITCode* jitCode, OSRExit& exit, VM* vm, CodeBlock* codeBlock)
     179    unsigned exitID, JITCode* jitCode, OSRExit& exit, VM* vm, CodeBlock* codeBlock, PtrTag exitSiteTag)
    180180{
    181181    // This code requires framePointerRegister is the same as callFrameRegister
     
    339339                CCallHelpers::TrustedImmPtr(materialization),
    340340                CCallHelpers::TrustedImmPtr(materializationArguments));
    341             jit.move(CCallHelpers::TrustedImmPtr(bitwise_cast<void*>(operationMaterializeObjectInOSR)), GPRInfo::nonArgGPR0);
    342             jit.call(GPRInfo::nonArgGPR0, NoPtrTag);
     341            PtrTag tag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     342            jit.move(CCallHelpers::TrustedImmPtr(tagCFunctionPtr(operationMaterializeObjectInOSR, tag)), GPRInfo::nonArgGPR0);
     343            jit.call(GPRInfo::nonArgGPR0, tag);
    343344            jit.storePtr(GPRInfo::returnValueGPR, materializationToPointer.get(materialization));
    344345
     
    367368            CCallHelpers::TrustedImmPtr(materializationToPointer.get(materialization)),
    368369            CCallHelpers::TrustedImmPtr(materializationArguments));
    369         jit.move(CCallHelpers::TrustedImmPtr(bitwise_cast<void*>(operationPopulateObjectInOSR)), GPRInfo::nonArgGPR0);
    370         jit.call(GPRInfo::nonArgGPR0, NoPtrTag);
     370        PtrTag tag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     371        jit.move(CCallHelpers::TrustedImmPtr(tagCFunctionPtr(operationPopulateObjectInOSR, tag)), GPRInfo::nonArgGPR0);
     372        jit.call(GPRInfo::nonArgGPR0, tag);
    371373    }
    372374
     
    495497    exit.m_code = FINALIZE_CODE_IF(
    496498        shouldDumpDisassembly() || Options::verboseOSR() || Options::verboseFTLOSRExit(),
    497         patchBuffer, NoPtrTag,
     499        patchBuffer, exitSiteTag,
    498500        "FTL OSR exit #%u (%s, %s) from %s, with operands = %s",
    499501            exitID, toCString(exit.m_codeOrigin).data(),
     
    543545    prepareCodeOriginForOSRExit(exec, exit.m_codeOrigin);
    544546
    545     compileStub(exitID, jitCode, exit, &vm, codeBlock);
     547    PtrTag thunkTag = ptrTag(FTLOSRExitPtrTag, &exit);
     548    compileStub(exitID, jitCode, exit, &vm, codeBlock, thunkTag);
    546549
    547550    MacroAssembler::repatchJump(
    548         exit.codeLocationForRepatch(codeBlock), CodeLocationLabel(exit.m_code.code()));
    549    
    550     return exit.m_code.code().executableAddress();
     551        exit.codeLocationForRepatch(codeBlock), CodeLocationLabel(exit.m_code.retaggedCode(thunkTag, NearJumpPtrTag)));
     552   
     553    return exit.m_code.retaggedCode(thunkTag, bitwise_cast<PtrTag>(exec)).executableAddress();
    551554}
    552555
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExitHandle.cpp

    r214571 r230444  
    11/*
    2  * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5050            self->exit.m_patchableJump = CodeLocationJump(linkBuffer.locationOf(jump));
    5151
     52            PtrTag thunkTag = ptrTag(FTLOSRExitPtrTag, &vm);
    5253            linkBuffer.link(
    5354                jump.m_jump,
    54                 CodeLocationLabel(vm.getCTIStub(osrExitGenerationThunkGenerator).code()));
     55                CodeLocationLabel(vm.getCTIStub(osrExitGenerationThunkGenerator).retaggedCode(thunkTag, NearJumpPtrTag)));
    5556            if (compilation)
    5657                compilation->addOSRExitSite({ linkBuffer.locationOf(myLabel).executableAddress() });
  • trunk/Source/JavaScriptCore/ftl/FTLOperations.cpp

    r229842 r230444  
    11/*
    2  * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    582582    lazySlowPath.generate(codeBlock);
    583583
    584     return lazySlowPath.stub().code().executableAddress();
     584    PtrTag slowPathTag = ptrTag(FTLLazySlowPathPtrTag, bitwise_cast<PtrTag>(&lazySlowPath));
     585    return lazySlowPath.stub().retaggedCode(slowPathTag, bitwise_cast<PtrTag>(exec)).executableAddress();
    585586}
    586587
  • trunk/Source/JavaScriptCore/ftl/FTLOutput.h

    r228420 r230444  
    11/*
    2  * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    402402    {
    403403        return m_block->appendNew<B3::CCallValue>(m_proc, type, origin(), B3::Effects::none(),
    404             constIntPtr(bitwise_cast<void*>(function)), arg1, args...);
    405     }
    406 
     404            constIntPtr(tagCFunctionPtr<void*>(function, B3CCallPtrTag)), arg1, args...);
     405    }
     406
     407    // FIXME: Consider enhancing this to allow the client to choose the target PtrTag to use.
     408    // https://bugs.webkit.org/show_bug.cgi?id=184324
    407409    template<typename FunctionType>
    408     LValue operation(FunctionType function) { return constIntPtr(bitwise_cast<void*>(function)); }
     410    LValue operation(FunctionType function) { return constIntPtr(tagCFunctionPtr<void*>(function, B3CCallPtrTag)); }
    409411
    410412    void jump(LBasicBlock);
  • trunk/Source/JavaScriptCore/ftl/FTLPatchpointExceptionHandle.cpp

    r196729 r230444  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9292                    newHandler.start = callSiteIndex.bits();
    9393                    newHandler.end = callSiteIndex.bits() + 1;
    94                     newHandler.nativeCode = linkBuffer.locationOf(handle->label);
     94                    newHandler.nativeCode = linkBuffer.locationOf(handle->label, ExceptionHandlerPtrTag);
    9595                    codeBlock->appendExceptionHandler(newHandler);
    9696                });
  • trunk/Source/JavaScriptCore/ftl/FTLSlowPathCall.cpp

    r229767 r230444  
    123123    void* executableAddress = callTarget.executableAddress();
    124124    assertIsCFunctionPtr(executableAddress);
    125     SlowPathCall result = SlowPathCall(m_jit.call(NoPtrTag), keyWithTarget(executableAddress));
     125    SlowPathCallKey key = keyWithTarget(executableAddress);
     126    PtrTag callTag = key.callPtrTag();
     127    SlowPathCall result = SlowPathCall(m_jit.call(callTag), key);
    126128
    127129    m_jit.addLinkTask(
  • trunk/Source/JavaScriptCore/ftl/FTLSlowPathCallKey.h

    r206525 r230444  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if ENABLE(FTL_JIT)
    2929
     30#include "PtrTag.h"
    3031#include "RegisterSet.h"
    3132
     
    6768    SlowPathCallKey withCallTarget(void* callTarget)
    6869    {
     70        assertIsTaggedWith(callTarget, CFunctionPtrTag);
    6971        return SlowPathCallKey(usedRegisters(), callTarget, argumentRegisters(), offset());
    7072    }
     
    103105    }
    104106
     107    PtrTag callPtrTag() const
     108    {
     109        // We should only include factors which are invariant for the same slow path site.
     110        // m_callTarget can vary and should be excluded.
     111        return ptrTag(FTLSlowPathPtrTag, m_usedRegisters.hash(), m_offset);
     112    }
     113
    105114private:
    106115    RegisterSet m_usedRegisters;
  • trunk/Source/JavaScriptCore/ftl/FTLThunks.cpp

    r229767 r230444  
    4848
    4949static MacroAssemblerCodeRef genericGenerationThunkGenerator(
    50     VM* vm, FunctionPtr generationFunction, const char* name, unsigned extraPopsToRestore, FrameAndStackAdjustmentRequirement frameAndStackAdjustmentRequirement)
     50    VM* vm, FunctionPtr generationFunction, PtrTag resultThunkTag, const char* name, unsigned extraPopsToRestore, FrameAndStackAdjustmentRequirement frameAndStackAdjustmentRequirement)
    5151{
    5252    AssemblyHelpers jit(nullptr);
     
    8787        GPRInfo::argumentGPR1,
    8888        (stackMisalignment - MacroAssembler::pushToSaveByteOffset()) / sizeof(void*));
    89     MacroAssembler::Call functionCall = jit.call(NoPtrTag);
     89    PtrTag generatorCallTag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
     90    MacroAssembler::Call functionCall = jit.call(generatorCallTag);
    9091   
    9192    // At this point we want to make a tail call to what was returned to us in the
     
    116117    restoreAllRegisters(jit, buffer);
    117118
     119#if CPU(ARM64) && USE(POINTER_PROFILING)
     120    jit.untagPtr(AssemblyHelpers::linkRegister, GPRInfo::callFrameRegister);
     121    jit.tagReturnAddress();
     122#endif
    118123    jit.ret();
    119124   
    120125    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
    121     patchBuffer.link(functionCall, generationFunction);
    122     return FINALIZE_CODE(patchBuffer, NoPtrTag, "%s", name);
     126    patchBuffer.link(functionCall, FunctionPtr(generationFunction, generatorCallTag));
     127    return FINALIZE_CODE(patchBuffer, resultThunkTag, "%s", name);
    123128}
    124129
     
    126131{
    127132    unsigned extraPopsToRestore = 0;
    128     PtrTag tag = ptrTag(JITThunkPtrTag, nextPtrTagID());
     133    PtrTag thunkTag = ptrTag(FTLOSRExitPtrTag, vm);
    129134    return genericGenerationThunkGenerator(
    130         vm, FunctionPtr(compileFTLOSRExit, tag), "FTL OSR exit generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::Needed);
     135        vm, FunctionPtr(compileFTLOSRExit), thunkTag, "FTL OSR exit generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::Needed);
    131136}
    132137
     
    134139{
    135140    unsigned extraPopsToRestore = 1;
    136     PtrTag tag = ptrTag(JITThunkPtrTag, nextPtrTagID());
     141    PtrTag thunkTag = ptrTag(FTLLazySlowPathPtrTag, vm);
    137142    return genericGenerationThunkGenerator(
    138         vm, FunctionPtr(compileFTLLazySlowPath, tag), "FTL lazy slow path generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::NotNeeded);
     143        vm, FunctionPtr(compileFTLLazySlowPath), thunkTag, "FTL lazy slow path generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::NotNeeded);
    139144}
    140145
     
    170175{
    171176    AssemblyHelpers jit(nullptr);
    172    
     177    jit.tagReturnAddress();
     178
    173179    // We want to save the given registers at the given offset, then we want to save the
    174180    // old return address somewhere past that offset, and then finally we want to make the
     
    200206    registerClobberCheck(jit, key.argumentRegisters());
    201207   
    202     PtrTag callTag = ptrTag(JITThunkPtrTag, nextPtrTagID());
     208    PtrTag callTag = ptrTag(FTLOperationPtrTag, nextPtrTagID());
    203209    AssemblyHelpers::Call call = jit.call(callTag);
    204210
     
    228234    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
    229235    patchBuffer.link(call, FunctionPtr(key.callTarget(), callTag));
    230     return FINALIZE_CODE(patchBuffer, NoPtrTag, "FTL slow path call thunk for %s", toCString(key).data());
     236    return FINALIZE_CODE(patchBuffer, key.callPtrTag(), "FTL slow path call thunk for %s", toCString(key).data());
    231237}
    232238
  • trunk/Source/JavaScriptCore/jit/JITMathIC.h

    r230294 r230444  
    145145
    146146        auto replaceCall = [&] () {
    147             PtrTag tag = ptrTag(MathICPtrTag, m_instruction);
    148             ftlThunkAwareRepatchCall(codeBlock, slowPathCallLocation(), FunctionPtr(callReplacement, tag));
     147            PtrTag callTag = ptrTag(MathICPtrTag, m_instruction);
     148            ftlThunkAwareRepatchCall(codeBlock, slowPathCallLocation(), callReplacement, callTag);
    149149        };
    150150
     
    229229            start, linkBuffer.locationOf(state.slowPathCall));
    230230        m_deltaFromStartToSlowPathStart = MacroAssembler::differenceBetweenCodePtr(
    231             start, linkBuffer.locationOf(state.slowPathStart, NoPtrTag));
     231            start, linkBuffer.locationOf(state.slowPathStart));
    232232    }
    233233
  • trunk/Source/JavaScriptCore/jit/Repatch.cpp

    r230376 r230444  
    6767namespace JSC {
    6868
    69 static FunctionPtr readCallTarget(CodeBlock* codeBlock, CodeLocationCall call)
    70 {
    71     FunctionPtr result = MacroAssembler::readCallTarget(call);
     69static FunctionPtr readPutICCallTarget(CodeBlock* codeBlock, CodeLocationCall call)
     70{
     71    FunctionPtr target = MacroAssembler::readCallTarget(call);
    7272#if ENABLE(FTL_JIT)
    7373    if (codeBlock->jitType() == JITCode::FTLJIT) {
    74         return FunctionPtr(codeBlock->vm()->ftlThunks->keyForSlowPathCallThunk(
    75             MacroAssemblerCodePtr::createFromExecutableAddress(
    76                 result.executableAddress())).callTarget(), CodeEntryPtrTag);
     74        MacroAssemblerCodePtr slowPathThunk = MacroAssemblerCodePtr::createFromExecutableAddress(target.executableAddress());
     75        auto* callTarget = codeBlock->vm()->ftlThunks->keyForSlowPathCallThunk(slowPathThunk).callTarget();
     76        return FunctionPtr(callTarget, CFunctionPtrTag);
    7777    }
    7878#else
    7979    UNUSED_PARAM(codeBlock);
    8080#endif // ENABLE(FTL_JIT)
    81     return result;
    82 }
    83 
    84 void ftlThunkAwareRepatchCall(CodeBlock* codeBlock, CodeLocationCall call, FunctionPtr newCalleeFunction)
     81    return FunctionPtr(untagCFunctionPtr(target.executableAddress(), PutPropertyPtrTag), CFunctionPtrTag);
     82}
     83
     84void ftlThunkAwareRepatchCall(CodeBlock* codeBlock, CodeLocationCall call, FunctionPtr newCalleeFunction, PtrTag callTag)
    8585{
    8686#if ENABLE(FTL_JIT)
     
    8888        VM& vm = *codeBlock->vm();
    8989        FTL::Thunks& thunks = *vm.ftlThunks;
    90         FTL::SlowPathCallKey key = thunks.keyForSlowPathCallThunk(
    91             MacroAssemblerCodePtr::createFromExecutableAddress(
    92                 MacroAssembler::readCallTarget(call).executableAddress()));
     90        FunctionPtr target = MacroAssembler::readCallTarget(call);
     91        MacroAssemblerCodePtr slowPathThunk = MacroAssemblerCodePtr::createFromExecutableAddress(target.executableAddress());
     92        FTL::SlowPathCallKey key = thunks.keyForSlowPathCallThunk(slowPathThunk);
    9393        key = key.withCallTarget(newCalleeFunction.executableAddress());
    9494        newCalleeFunction = FunctionPtr(thunks.getSlowPathCallThunk(key).code());
     95        assertIsTaggedWith(newCalleeFunction.executableAddress(), key.callPtrTag());
     96        MacroAssembler::repatchCall(call, newCalleeFunction);
     97        return;
    9598    }
    9699#else // ENABLE(FTL_JIT)
    97100    UNUSED_PARAM(codeBlock);
    98101#endif // ENABLE(FTL_JIT)
    99     MacroAssembler::repatchCall(call, newCalleeFunction);
     102    MacroAssembler::repatchCall(call, FunctionPtr(newCalleeFunction, callTag));
    100103}
    101104
     
    208211                    bool generatedCodeInline = InlineAccess::generateArrayLength(stubInfo, jsCast<JSArray*>(baseCell));
    209212                    if (generatedCodeInline) {
    210                         ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), FunctionPtr(appropriateOptimizingGetByIdFunction(kind), GetPropertyPtrTag));
     213                        ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), appropriateOptimizingGetByIdFunction(kind), GetPropertyPtrTag);
    211214                        stubInfo.initArrayLength();
    212215                        return RetryCacheLater;
     
    265268                    LOG_IC((ICEvent::GetByIdSelfPatch, structure->classInfo(), propertyName));
    266269                    structure->startWatchingPropertyForReplacements(vm, slot.cachedOffset());
    267                     ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), FunctionPtr(appropriateOptimizingGetByIdFunction(kind), GetPropertyPtrTag));
     270                    ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), appropriateOptimizingGetByIdFunction(kind), GetPropertyPtrTag);
    268271                    stubInfo.initGetByIdSelf(codeBlock, structure, slot.cachedOffset());
    269272                    return RetryCacheLater;
     
    389392    if (tryCacheGetByID(exec, baseValue, propertyName, slot, stubInfo, kind) == GiveUpOnCache) {
    390393        CodeBlock* codeBlock = exec->codeBlock();
    391         ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), FunctionPtr(appropriateGetByIdFunction(kind), GetPropertyPtrTag));
     394        ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), appropriateGetByIdFunction(kind), GetPropertyPtrTag);
    392395    }
    393396}
     
    461464                    if (generatedCodeInline) {
    462465                        LOG_IC((ICEvent::PutByIdSelfPatch, structure->classInfo(), ident));
    463                         ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), FunctionPtr(appropriateOptimizingPutByIdFunction(slot, putKind), PutPropertyPtrTag));
     466                        ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), appropriateOptimizingPutByIdFunction(slot, putKind), PutPropertyPtrTag);
    464467                        stubInfo.initPutByIdReplace(codeBlock, structure, slot.cachedOffset());
    465468                        return RetryCacheLater;
     
    595598    if (tryCachePutByID(exec, baseValue, structure, propertyName, slot, stubInfo, putKind) == GiveUpOnCache) {
    596599        CodeBlock* codeBlock = exec->codeBlock();
    597         ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), FunctionPtr(appropriateGenericPutByIdFunction(slot, putKind), PutPropertyPtrTag));
     600        ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), appropriateGenericPutByIdFunction(slot, putKind), PutPropertyPtrTag);
    598601    }
    599602}
     
    684687    SuperSamplerScope superSamplerScope(false);
    685688    if (tryCacheIn(exec, base, ident, wasFound, slot, stubInfo) == GiveUpOnCache)
    686         ftlThunkAwareRepatchCall(exec->codeBlock(), stubInfo.slowPathCallLocation(), operationIn);
     689        ftlThunkAwareRepatchCall(exec->codeBlock(), stubInfo.slowPathCallLocation(), operationIn, CFunctionPtrTag);
    687690}
    688691
     
    11371140void resetGetByID(CodeBlock* codeBlock, StructureStubInfo& stubInfo, GetByIDKind kind)
    11381141{
    1139     ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), FunctionPtr(appropriateOptimizingGetByIdFunction(kind), GetPropertyPtrTag));
     1142    ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), appropriateOptimizingGetByIdFunction(kind), GetPropertyPtrTag);
    11401143    InlineAccess::rewireStubAsJump(stubInfo, stubInfo.slowPathStartLocation());
    11411144}
     
    11431146void resetPutByID(CodeBlock* codeBlock, StructureStubInfo& stubInfo)
    11441147{
    1145     V_JITOperation_ESsiJJI unoptimizedFunction = untagCFunctionPtr<V_JITOperation_ESsiJJI>(readCallTarget(codeBlock, stubInfo.slowPathCallLocation()).executableAddress(), PutPropertyPtrTag);
     1148    V_JITOperation_ESsiJJI unoptimizedFunction = reinterpret_cast<V_JITOperation_ESsiJJI>(readPutICCallTarget(codeBlock, stubInfo.slowPathCallLocation()).executableAddress());
    11461149    V_JITOperation_ESsiJJI optimizedFunction;
    11471150    if (unoptimizedFunction == operationPutByIdStrict || unoptimizedFunction == operationPutByIdStrictOptimize)
     
    11561159    }
    11571160
    1158     ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), FunctionPtr(optimizedFunction, PutPropertyPtrTag));
     1161    ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation(), optimizedFunction, PutPropertyPtrTag);
    11591162    InlineAccess::rewireStubAsJump(stubInfo, stubInfo.slowPathStartLocation());
    11601163}
  • trunk/Source/JavaScriptCore/jit/Repatch.h

    r230376 r230444  
    5555void resetPutByID(CodeBlock*, StructureStubInfo&);
    5656void resetIn(CodeBlock*, StructureStubInfo&);
    57 void ftlThunkAwareRepatchCall(CodeBlock*, CodeLocationCall, FunctionPtr newCalleeFunction);
     57void ftlThunkAwareRepatchCall(CodeBlock*, CodeLocationCall, FunctionPtr newCalleeFunction, PtrTag callTag);
    5858
    5959} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/PtrTag.h

    r230294 r230444  
    4646    v(DFGOperationPtrTag) \
    4747    v(ExceptionHandlerPtrTag) \
     48    v(FTLCodePtrTag) \
     49    v(FTLLazySlowPathPtrTag) \
     50    v(FTLOSRExitPtrTag) \
     51    v(FTLOperationPtrTag) \
     52    v(FTLSlowPathPtrTag) \
    4853    v(GetPropertyPtrTag) \
    4954    v(GetterSetterPtrTag) \
     
    6772    v(SwitchTablePtrTag) \
    6873    v(ThrowExceptionPtrTag) \
    69     \
    7074    v(Yarr8BitPtrTag) \
    7175    v(Yarr16BitPtrTag) \
     
    7377    v(YarrMatchOnly16BitPtrTag) \
    7478    v(YarrBacktrackPtrTag) \
    75     \
    7679    v(WasmCallPtrTag) \
    7780    v(WasmHelperPtrTag) \
Note: See TracChangeset for help on using the changeset viewer.