Changeset 229767 in webkit


Ignore:
Timestamp:
Mar 20, 2018 11:10:16 AM (6 years ago)
Author:
mark.lam@apple.com
Message:

Improve FunctionPtr and use it in the JIT CallRecord.
https://bugs.webkit.org/show_bug.cgi?id=183756
<rdar://problem/38641335>

Reviewed by JF Bastien.

  1. FunctionPtr hold a C/C++ function pointer by default. Change its default PtrTag to reflect that.
  1. Delete the FunctionPtr::value() method. It is effectively a duplicate of executableAddress().
  1. Fix the FunctionPtr constructor that takes arbitrary pointers to be able to take "any" pointer. "any" in this case means that the pointer may not be typed as a C/C++ function to the C++ compiler (due to upstream casting or usage of void* as a storage type), but it is still expected to be pointing to a C/C++ function.
  1. Added a FunctionPtr constructor that takes another FunctionPtr. This is a convenience constructor that lets us retag the underlying pointer. The other FunctionPtr is still expected to point to a C/C++ function.
  1. Added PtrTag assertion placeholder functions to be implemented later.
  1. Change the JIT CallRecord to embed a FunctionPtr callee instead of a void* to pointer. This improves type safety, and assists in getting pointer tagging right later.
  1. Added versions of JIT callOperations methods that will take a PtrTag. This is preparation for more more pointer tagging work later.
  • assembler/MacroAssemblerARM.h:

(JSC::MacroAssemblerARM::linkCall):

  • assembler/MacroAssemblerARMv7.h:

(JSC::MacroAssemblerARMv7::linkCall):

  • assembler/MacroAssemblerCodeRef.h:

(JSC::FunctionPtr::FunctionPtr):
(JSC::FunctionPtr::operator bool const):
(JSC::FunctionPtr::operator! const):
(JSC::ReturnAddressPtr::ReturnAddressPtr):
(JSC::MacroAssemblerCodePtr::retagged const):
(JSC::MacroAssemblerCodeRef::retaggedCode const):
(JSC::FunctionPtr::value const): Deleted.

  • assembler/MacroAssemblerMIPS.h:

(JSC::MacroAssemblerMIPS::linkCall):

  • assembler/MacroAssemblerX86.h:

(JSC::MacroAssemblerX86::linkCall):

  • assembler/MacroAssemblerX86_64.h:

(JSC::MacroAssemblerX86_64::callWithSlowPathReturnType):
(JSC::MacroAssemblerX86_64::linkCall):

  • bytecode/AccessCase.cpp:

(JSC::AccessCase::generateImpl):

  • ftl/FTLSlowPathCall.cpp:

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

  • ftl/FTLSlowPathCall.h:

(JSC::FTL::callOperation):

  • ftl/FTLThunks.cpp:

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

  • jit/JIT.cpp:

(JSC::JIT::link):
(JSC::JIT::privateCompileExceptionHandlers):

  • jit/JIT.h:

(JSC::CallRecord::CallRecord):
(JSC::JIT::appendCall):
(JSC::JIT::appendCallWithSlowPathReturnType):
(JSC::JIT::callOperation):
(JSC::JIT::callOperationWithProfile):
(JSC::JIT::callOperationWithResult):
(JSC::JIT::callOperationNoExceptionCheck):
(JSC::JIT::callOperationWithCallFrameRollbackOnException):

  • jit/JITArithmetic.cpp:

(JSC::JIT::emitMathICFast):
(JSC::JIT::emitMathICSlow):

  • jit/JITInlines.h:

(JSC::JIT::emitNakedCall):
(JSC::JIT::emitNakedTailCall):
(JSC::JIT::appendCallWithExceptionCheck):
(JSC::JIT::appendCallWithExceptionCheckAndSlowPathReturnType):
(JSC::JIT::appendCallWithCallFrameRollbackOnException):
(JSC::JIT::appendCallWithExceptionCheckSetJSValueResult):
(JSC::JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emitSlow_op_get_by_val):
(JSC::JIT::emitSlow_op_put_by_val):
(JSC::JIT::privateCompileGetByValWithCachedId):
(JSC::JIT::privateCompilePutByVal):
(JSC::JIT::privateCompilePutByValWithCachedId):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::emitSlow_op_put_by_val):

  • jit/Repatch.cpp:

(JSC::linkPolymorphicCall):

  • jit/SlowPathCall.h:

(JSC::JITSlowPathCall::JITSlowPathCall):
(JSC::JITSlowPathCall::call):

  • jit/ThunkGenerators.cpp:

(JSC::nativeForGenerator):

  • runtime/PtrTag.h:

(JSC::nextPtrTagID):
(JSC::assertIsCFunctionPtr):
(JSC::assertIsNullOrCFunctionPtr):
(JSC::assertIsNotTagged):
(JSC::assertIsTagged):
(JSC::assertIsNullOrTagged):
(JSC::assertIsTaggedWith):
(JSC::assertIsNullOrTaggedWith):
(JSC::uniquePtrTagID): Deleted.

Location:
trunk/Source/JavaScriptCore
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r229766 r229767  
     12018-03-20  Mark Lam  <mark.lam@apple.com>
     2
     3        Improve FunctionPtr and use it in the JIT CallRecord.
     4        https://bugs.webkit.org/show_bug.cgi?id=183756
     5        <rdar://problem/38641335>
     6
     7        Reviewed by JF Bastien.
     8
     9        1. FunctionPtr hold a C/C++ function pointer by default.  Change its default
     10           PtrTag to reflect that.
     11
     12        2. Delete the FunctionPtr::value() method.  It is effectively a duplicate of
     13           executableAddress().
     14
     15        3. Fix the FunctionPtr constructor that takes arbitrary pointers to be able to
     16           take "any" pointer.  "any" in this case means that the pointer may not be typed
     17           as a C/C++ function to the C++ compiler (due to upstream casting or usage of
     18           void* as a storage type), but it is still expected to be pointing to a C/C++
     19           function.
     20
     21        4. Added a FunctionPtr constructor that takes another FunctionPtr.  This is a
     22           convenience constructor that lets us retag the underlying pointer.  The other
     23           FunctionPtr is still expected to point to a C/C++ function.
     24
     25        5. Added PtrTag assertion placeholder functions to be implemented later.
     26
     27        6. Change the JIT CallRecord to embed a FunctionPtr callee instead of a void* to
     28           pointer.  This improves type safety, and assists in getting pointer tagging
     29           right later.
     30
     31        7. Added versions of JIT callOperations methods that will take a PtrTag.
     32           This is preparation for more more pointer tagging work later.
     33
     34        * assembler/MacroAssemblerARM.h:
     35        (JSC::MacroAssemblerARM::linkCall):
     36        * assembler/MacroAssemblerARMv7.h:
     37        (JSC::MacroAssemblerARMv7::linkCall):
     38        * assembler/MacroAssemblerCodeRef.h:
     39        (JSC::FunctionPtr::FunctionPtr):
     40        (JSC::FunctionPtr::operator bool const):
     41        (JSC::FunctionPtr::operator! const):
     42        (JSC::ReturnAddressPtr::ReturnAddressPtr):
     43        (JSC::MacroAssemblerCodePtr::retagged const):
     44        (JSC::MacroAssemblerCodeRef::retaggedCode const):
     45        (JSC::FunctionPtr::value const): Deleted.
     46        * assembler/MacroAssemblerMIPS.h:
     47        (JSC::MacroAssemblerMIPS::linkCall):
     48        * assembler/MacroAssemblerX86.h:
     49        (JSC::MacroAssemblerX86::linkCall):
     50        * assembler/MacroAssemblerX86_64.h:
     51        (JSC::MacroAssemblerX86_64::callWithSlowPathReturnType):
     52        (JSC::MacroAssemblerX86_64::linkCall):
     53        * bytecode/AccessCase.cpp:
     54        (JSC::AccessCase::generateImpl):
     55        * ftl/FTLSlowPathCall.cpp:
     56        (JSC::FTL::SlowPathCallContext::makeCall):
     57        * ftl/FTLSlowPathCall.h:
     58        (JSC::FTL::callOperation):
     59        * ftl/FTLThunks.cpp:
     60        (JSC::FTL::osrExitGenerationThunkGenerator):
     61        (JSC::FTL::lazySlowPathGenerationThunkGenerator):
     62        (JSC::FTL::slowPathCallThunkGenerator):
     63        * jit/JIT.cpp:
     64        (JSC::JIT::link):
     65        (JSC::JIT::privateCompileExceptionHandlers):
     66        * jit/JIT.h:
     67        (JSC::CallRecord::CallRecord):
     68        (JSC::JIT::appendCall):
     69        (JSC::JIT::appendCallWithSlowPathReturnType):
     70        (JSC::JIT::callOperation):
     71        (JSC::JIT::callOperationWithProfile):
     72        (JSC::JIT::callOperationWithResult):
     73        (JSC::JIT::callOperationNoExceptionCheck):
     74        (JSC::JIT::callOperationWithCallFrameRollbackOnException):
     75        * jit/JITArithmetic.cpp:
     76        (JSC::JIT::emitMathICFast):
     77        (JSC::JIT::emitMathICSlow):
     78        * jit/JITInlines.h:
     79        (JSC::JIT::emitNakedCall):
     80        (JSC::JIT::emitNakedTailCall):
     81        (JSC::JIT::appendCallWithExceptionCheck):
     82        (JSC::JIT::appendCallWithExceptionCheckAndSlowPathReturnType):
     83        (JSC::JIT::appendCallWithCallFrameRollbackOnException):
     84        (JSC::JIT::appendCallWithExceptionCheckSetJSValueResult):
     85        (JSC::JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile):
     86        * jit/JITPropertyAccess.cpp:
     87        (JSC::JIT::emitSlow_op_get_by_val):
     88        (JSC::JIT::emitSlow_op_put_by_val):
     89        (JSC::JIT::privateCompileGetByValWithCachedId):
     90        (JSC::JIT::privateCompilePutByVal):
     91        (JSC::JIT::privateCompilePutByValWithCachedId):
     92        * jit/JITPropertyAccess32_64.cpp:
     93        (JSC::JIT::emitSlow_op_put_by_val):
     94        * jit/Repatch.cpp:
     95        (JSC::linkPolymorphicCall):
     96        * jit/SlowPathCall.h:
     97        (JSC::JITSlowPathCall::JITSlowPathCall):
     98        (JSC::JITSlowPathCall::call):
     99        * jit/ThunkGenerators.cpp:
     100        (JSC::nativeForGenerator):
     101        * runtime/PtrTag.h:
     102        (JSC::nextPtrTagID):
     103        (JSC::assertIsCFunctionPtr):
     104        (JSC::assertIsNullOrCFunctionPtr):
     105        (JSC::assertIsNotTagged):
     106        (JSC::assertIsTagged):
     107        (JSC::assertIsNullOrTagged):
     108        (JSC::assertIsTaggedWith):
     109        (JSC::assertIsNullOrTaggedWith):
     110        (JSC::uniquePtrTagID): Deleted.
     111
    11122018-03-20  Stanislav Ocovaj  <stanislav.ocovaj@rt-rk.com>
    2113
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM.h

    r229609 r229767  
    16151615    {
    16161616        if (call.isFlagSet(Call::Tail))
    1617             ARMAssembler::linkJump(code, call.m_label, function.value());
     1617            ARMAssembler::linkJump(code, call.m_label, function.executableAddress());
    16181618        else
    1619             ARMAssembler::linkCall(code, call.m_label, function.value());
     1619            ARMAssembler::linkCall(code, call.m_label, function.executableAddress());
    16201620    }
    16211621
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r229609 r229767  
    21292129    {
    21302130        if (call.isFlagSet(Call::Tail))
    2131             ARMv7Assembler::linkJump(code, call.m_label, function.value());
     2131            ARMv7Assembler::linkJump(code, call.m_label, function.executableAddress());
    21322132        else
    2133             ARMv7Assembler::linkCall(code, call.m_label, function.value());
     2133            ARMv7Assembler::linkCall(code, call.m_label, function.executableAddress());
    21342134    }
    21352135
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h

    r229709 r229767  
    6666
    6767    template<typename ReturnType, typename... Arguments>
    68     FunctionPtr(ReturnType(*value)(Arguments...), PtrTag tag = SlowPathPtrTag)
     68    FunctionPtr(ReturnType(*value)(Arguments...), PtrTag tag = CFunctionPtrTag)
    6969        : m_value(tagCFunctionPtr<void*>(value, tag))
    7070    {
     71        assertIsCFunctionPtr(value);
    7172        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    7273        ASSERT_VALID_CODE_POINTER(m_value);
     
    7879
    7980    template<typename ReturnType, typename... Arguments>
    80     FunctionPtr(ReturnType(CDECL *value)(Arguments...), PtrTag tag = SlowPathPtrTag)
     81    FunctionPtr(ReturnType(CDECL *value)(Arguments...), PtrTag tag = CFunctionPtrTag)
    8182        : m_value(tagCFunctionPtr<void*>(value, tag))
    8283    {
     84        assertIsCFunctionPtr(value);
    8385        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    8486        ASSERT_VALID_CODE_POINTER(m_value);
     
    9092
    9193    template<typename ReturnType, typename... Arguments>
    92     FunctionPtr(ReturnType(FASTCALL *value)(Arguments...), PtrTag tag = SlowPathPtrTag)
     94    FunctionPtr(ReturnType(FASTCALL *value)(Arguments...), PtrTag tag = CFunctionPtrTag)
    9395        : m_value(tagCFunctionPtr<void*>(value, tag))
    9496    {
     97        assertIsCFunctionPtr(value);
    9598        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    9699        ASSERT_VALID_CODE_POINTER(m_value);
     
    99102#endif // COMPILER_SUPPORTS(FASTCALL_CALLING_CONVENTION)
    100103
    101     template<typename FunctionType>
    102     explicit FunctionPtr(FunctionType* value, PtrTag tag = SlowPathPtrTag)
     104    template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_function<typename std::remove_pointer<PtrType>::type>::value>>
     105    explicit FunctionPtr(PtrType value, PtrTag tag)
    103106        // Using a C-ctyle cast here to avoid compiler error on RVTC:
    104107        // Error:  #694: reinterpret_cast cannot cast away const or other type qualifiers
    105108        // (I guess on RVTC function pointers have a different constness to GCC/MSVC?)
    106         : m_value(tagCodePtr<void*>(value, tag))
    107     {
     109        : m_value(tagCFunctionPtr<void*>(value, tag))
     110    {
     111        assertIsCFunctionPtr(value);
     112        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
     113        ASSERT_VALID_CODE_POINTER(m_value);
     114    }
     115
     116    explicit FunctionPtr(FunctionPtr other, PtrTag tag)
     117        : m_value(tagCFunctionPtr<void*>(other.executableAddress(), tag))
     118    {
     119        assertIsCFunctionPtr(other.executableAddress());
    108120        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    109121        ASSERT_VALID_CODE_POINTER(m_value);
     
    112124    explicit FunctionPtr(MacroAssemblerCodePtr);
    113125
    114     void* value() const
    115     {
    116         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    117         return removeCodePtrTag(m_value);
    118     }
    119126    void* executableAddress() const
    120127    {
     
    122129        return m_value;
    123130    }
     131
     132    explicit operator bool() const { return !!m_value; }
     133    bool operator!() const { return !m_value; }
    124134
    125135private:
     
    148158
    149159    explicit ReturnAddressPtr(FunctionPtr function)
    150         : m_value(function.value())
     160        : m_value(function.executableAddress())
    151161    {
    152162        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
     
    210220
    211221    PoisonedMasmPtr poisonedPtr() const { return m_value; }
     222
     223    MacroAssemblerCodePtr retagged(PtrTag oldTag, PtrTag newTag) const
     224    {
     225        return MacroAssemblerCodePtr(retagCodePtr(executableAddress(), oldTag, newTag));
     226    }
    212227
    213228    template<typename T = void*>
     
    352367    MacroAssemblerCodePtr retaggedCode(PtrTag oldTag, PtrTag newTag) const
    353368    {
    354         return MacroAssemblerCodePtr(retagCodePtr(m_codePtr.executableAddress(), oldTag, newTag));
     369        return m_codePtr.retagged(oldTag, newTag);
    355370    }
    356371
     
    381396{
    382397    PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    383     ASSERT_VALID_CODE_POINTER(m_value);
    384398}
    385399
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h

    r229766 r229767  
    33213321    {
    33223322        if (call.isFlagSet(Call::Tail))
    3323             MIPSAssembler::linkJump(code, call.m_label, function.value());
     3323            MIPSAssembler::linkJump(code, call.m_label, function.executableAddress());
    33243324        else
    3325             MIPSAssembler::linkCall(code, call.m_label, function.value());
     3325            MIPSAssembler::linkCall(code, call.m_label, function.executableAddress());
    33263326    }
    33273327
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h

    r229609 r229767  
    370370    {
    371371        if (call.isFlagSet(Call::Tail))
    372             X86Assembler::linkJump(code, call.m_label, function.value());
     372            X86Assembler::linkJump(code, call.m_label, function.executableAddress());
    373373        else
    374             X86Assembler::linkCall(code, call.m_label, function.value());
     374            X86Assembler::linkCall(code, call.m_label, function.executableAddress());
    375375    }
    376376};
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h

    r229609 r229767  
    153153
    154154#if OS(WINDOWS)
    155     Call callWithSlowPathReturnType()
     155    Call callWithSlowPathReturnType(PtrTag)
    156156    {
    157157        // On Win64, when the return type is larger than 8 bytes, we need to allocate space on the stack for the return value.
     
    178178
    179179        DataLabelPtr label = moveWithPatch(TrustedImmPtr(nullptr), scratchRegister());
    180         Call result = Call(m_assembler.call(scratchRegister()), Call::Linkable);
     180        Call result = Call(m_assembler.call(scratchRegister(), tag), Call::Linkable);
    181181
    182182        add64(TrustedImm32(8 * sizeof(int64_t)), X86Registers::esp);
     
    19541954    {
    19551955        if (!call.isFlagSet(Call::Near))
    1956             X86Assembler::linkPointer(code, call.m_label.labelAtOffset(-REPATCH_OFFSET_CALL_R11), function.value());
     1956            X86Assembler::linkPointer(code, call.m_label.labelAtOffset(-REPATCH_OFFSET_CALL_R11), function.executableAddress());
    19571957        else if (call.isFlagSet(Call::Tail))
    1958             X86Assembler::linkJump(code, call.m_label, function.value());
     1958            X86Assembler::linkJump(code, call.m_label, function.executableAddress());
    19591959        else
    1960             X86Assembler::linkCall(code, call.m_label, function.value());
     1960            X86Assembler::linkCall(code, call.m_label, function.executableAddress());
    19611961    }
    19621962};
  • trunk/Source/JavaScriptCore/bytecode/AccessCase.cpp

    r229609 r229767  
    864864            jit.storePtr(GPRInfo::callFrameRegister, &vm.topCallFrame);
    865865
    866             operationCall = jit.call(NoPtrTag);
     866            PtrTag callTag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     867            operationCall = jit.call(callTag);
    867868            jit.addLinkTask([=] (LinkBuffer& linkBuffer) {
    868                 linkBuffer.link(operationCall, FunctionPtr(this->as<GetterSetterAccessCase>().m_customAccessor.opaque));
     869                linkBuffer.link(operationCall, FunctionPtr(this->as<GetterSetterAccessCase>().m_customAccessor.opaque, callTag));
    869870            });
    870871
     
    10081009                    jit.setupArguments<decltype(operationReallocateButterflyToHavePropertyStorageWithInitialCapacity)>(baseGPR);
    10091010                   
    1010                     CCallHelpers::Call operationCall = jit.call(NoPtrTag);
     1011                    PtrTag callTag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     1012                    CCallHelpers::Call operationCall = jit.call(callTag);
    10111013                    jit.addLinkTask([=] (LinkBuffer& linkBuffer) {
    10121014                        linkBuffer.link(
    10131015                            operationCall,
    1014                             FunctionPtr(operationReallocateButterflyToHavePropertyStorageWithInitialCapacity));
     1016                            FunctionPtr(operationReallocateButterflyToHavePropertyStorageWithInitialCapacity, callTag));
    10151017                    });
    10161018                } else {
     
    10201022                        baseGPR, CCallHelpers::TrustedImm32(newSize / sizeof(JSValue)));
    10211023                   
    1022                     CCallHelpers::Call operationCall = jit.call(NoPtrTag);
     1024                    PtrTag callTag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     1025                    CCallHelpers::Call operationCall = jit.call(callTag);
    10231026                    jit.addLinkTask([=] (LinkBuffer& linkBuffer) {
    10241027                        linkBuffer.link(
    10251028                            operationCall,
    1026                             FunctionPtr(operationReallocateButterflyToGrowPropertyStorage));
     1029                            FunctionPtr(operationReallocateButterflyToGrowPropertyStorage, callTag));
    10271030                    });
    10281031                }
  • trunk/Source/JavaScriptCore/ftl/FTLSlowPathCall.cpp

    r229609 r229767  
    11/*
    2  * Copyright (C) 2013-2015 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
     
    119119}
    120120
    121 SlowPathCall SlowPathCallContext::makeCall(VM& vm, void* callTarget)
     121SlowPathCall SlowPathCallContext::makeCall(VM& vm, FunctionPtr callTarget)
    122122{
    123     SlowPathCall result = SlowPathCall(m_jit.call(NoPtrTag), keyWithTarget(callTarget));
     123    void* executableAddress = callTarget.executableAddress();
     124    assertIsCFunctionPtr(executableAddress);
     125    SlowPathCall result = SlowPathCall(m_jit.call(NoPtrTag), keyWithTarget(executableAddress));
    124126
    125127    m_jit.addLinkTask(
  • trunk/Source/JavaScriptCore/ftl/FTLSlowPathCall.h

    r229391 r229767  
    11/*
    2  * Copyright (C) 2013-2015 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
     
    6060    // NOTE: The call that this returns is already going to be linked by the JIT using addLinkTask(),
    6161    // so there is no need for you to link it yourself.
    62     SlowPathCall makeCall(VM&, void* callTarget);
     62    SlowPathCall makeCall(VM&, FunctionPtr callTarget);
    6363
    6464private:
     
    8585        SlowPathCallContext context(usedRegisters, jit, sizeof...(ArgumentTypes) + 1, resultGPR);
    8686        jit.setupArguments<void(ExecState*, ArgumentTypes...)>(arguments...);
    87         call = context.makeCall(vm, function.value());
     87        call = context.makeCall(vm, function);
    8888    }
    8989    if (exceptionTarget)
  • trunk/Source/JavaScriptCore/ftl/FTLThunks.cpp

    r229609 r229767  
    126126{
    127127    unsigned extraPopsToRestore = 0;
     128    PtrTag tag = ptrTag(JITThunkPtrTag, nextPtrTagID());
    128129    return genericGenerationThunkGenerator(
    129         vm, FunctionPtr(compileFTLOSRExit, NoPtrTag), "FTL OSR exit generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::Needed);
     130        vm, FunctionPtr(compileFTLOSRExit, tag), "FTL OSR exit generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::Needed);
    130131}
    131132
     
    133134{
    134135    unsigned extraPopsToRestore = 1;
     136    PtrTag tag = ptrTag(JITThunkPtrTag, nextPtrTagID());
    135137    return genericGenerationThunkGenerator(
    136         vm, FunctionPtr(compileFTLLazySlowPath, NoPtrTag), "FTL lazy slow path generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::NotNeeded);
     138        vm, FunctionPtr(compileFTLLazySlowPath, tag), "FTL lazy slow path generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::NotNeeded);
    137139}
    138140
     
    198200    registerClobberCheck(jit, key.argumentRegisters());
    199201   
    200     AssemblyHelpers::Call call = jit.call(NoPtrTag);
     202    PtrTag callTag = ptrTag(JITThunkPtrTag, nextPtrTagID());
     203    AssemblyHelpers::Call call = jit.call(callTag);
    201204
    202205    jit.loadPtr(AssemblyHelpers::Address(MacroAssembler::stackPointerRegister, key.offset()), GPRInfo::nonPreservedNonReturnGPR);
     
    224227
    225228    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
    226     patchBuffer.link(call, FunctionPtr(key.callTarget()));
     229    patchBuffer.link(call, FunctionPtr(key.callTarget(), callTag));
    227230    return FINALIZE_CODE(patchBuffer, NoPtrTag, "FTL slow path call thunk for %s", toCString(key).data());
    228231}
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r229609 r229767  
    805805
    806806    for (auto& record : m_calls) {
    807         if (record.to)
    808             patchBuffer.link(record.from, FunctionPtr(record.to, SlowPathPtrTag));
     807        if (record.callee)
     808            patchBuffer.link(record.from, record.callee);
    809809    }
    810810
     
    918918        poke(GPRInfo::argumentGPR1, 1);
    919919#endif
    920         m_calls.append(CallRecord(call(SlowPathPtrTag), std::numeric_limits<unsigned>::max(), FunctionPtr(lookupExceptionHandlerFromCallerFrame, SlowPathPtrTag).value()));
     920        PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     921        m_calls.append(CallRecord(call(tag), std::numeric_limits<unsigned>::max(), FunctionPtr(lookupExceptionHandlerFromCallerFrame, tag)));
    921922        jumpToExceptionHandler(*vm());
    922923    }
     
    937938        poke(GPRInfo::argumentGPR1, 1);
    938939#endif
    939         m_calls.append(CallRecord(call(SlowPathPtrTag), std::numeric_limits<unsigned>::max(), FunctionPtr(lookupExceptionHandler, SlowPathPtrTag).value()));
     940        PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     941        m_calls.append(CallRecord(call(tag), std::numeric_limits<unsigned>::max(), FunctionPtr(lookupExceptionHandler, tag)));
    940942        jumpToExceptionHandler(*vm());
    941943    }
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r229709 r229767  
    7171        MacroAssembler::Call from;
    7272        unsigned bytecodeOffset;
    73         void* to;
     73        FunctionPtr callee;
    7474
    7575        CallRecord()
     
    7777        }
    7878
    79         CallRecord(MacroAssembler::Call from, unsigned bytecodeOffset, void* to = 0)
     79        CallRecord(MacroAssembler::Call from, unsigned bytecodeOffset, FunctionPtr callee)
    8080            : from(from)
    8181            , bytecodeOffset(bytecodeOffset)
    82             , to(to)
     82            , callee(callee)
    8383        {
    8484        }
     
    268268
    269269        // Add a call out from JIT code, without an exception check.
    270         Call appendCall(const FunctionPtr function)
    271         {
    272             Call functionCall = call(NoPtrTag);
    273             m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));
     270        Call appendCall(const FunctionPtr function, PtrTag tag)
     271        {
     272            Call functionCall = call(tag);
     273            m_calls.append(CallRecord(functionCall, m_bytecodeOffset, FunctionPtr(function, tag)));
    274274            return functionCall;
    275275        }
    276276
    277277#if OS(WINDOWS) && CPU(X86_64)
    278         Call appendCallWithSlowPathReturnType(const FunctionPtr function)
    279         {
    280             Call functionCall = callWithSlowPathReturnType();
    281             m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));
     278        Call appendCallWithSlowPathReturnType(const FunctionPtr function, PtrTag tag)
     279        {
     280            Call functionCall = callWithSlowPathReturnType(tag);
     281            m_calls.append(CallRecord(functionCall, m_bytecodeOffset, FunctionPtr(function, tag)));
    282282            return functionCall;
    283283        }
     
    705705        }
    706706
    707         MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr);
     707        MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr, PtrTag);
    708708#if OS(WINDOWS) && CPU(X86_64)
    709         MacroAssembler::Call appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr);
    710 #endif
    711         MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr);
    712         MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr, int);
    713         MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr, int);
    714        
     709        MacroAssembler::Call appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr, PtrTag = NoPtrTag);
     710#endif
     711        MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr, PtrTag);
     712        MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr, PtrTag, int);
     713        MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr, PtrTag, int);
     714       
     715        template<typename OperationType, typename... Args>
     716        std::enable_if_t<FunctionTraits<OperationType>::hasResult, MacroAssembler::Call>
     717        callOperation(OperationType operation, PtrTag tag, int result, Args... args)
     718        {
     719            setupArguments<OperationType>(args...);
     720            return appendCallWithExceptionCheckSetJSValueResult(operation, tag, result);
     721        }
     722
    715723        template<typename OperationType, typename... Args>
    716724        std::enable_if_t<FunctionTraits<OperationType>::hasResult, MacroAssembler::Call>
    717725        callOperation(OperationType operation, int result, Args... args)
    718726        {
     727            PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     728            return callOperation(operation, tag, result, args...);
     729        }
     730
     731        template<typename OperationType, typename... Args>
     732        MacroAssembler::Call callOperation(OperationType operation, PtrTag tag, Args... args)
     733        {
    719734            setupArguments<OperationType>(args...);
    720             return appendCallWithExceptionCheckSetJSValueResult(operation, result);
     735            return appendCallWithExceptionCheck(operation, tag);
    721736        }
    722737
     
    724739        MacroAssembler::Call callOperation(OperationType operation, Args... args)
    725740        {
     741            PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     742            return callOperation(operation, tag, args...);
     743        }
     744
     745        template<typename OperationType, typename... Args>
     746        std::enable_if_t<FunctionTraits<OperationType>::hasResult, MacroAssembler::Call>
     747        callOperationWithProfile(OperationType operation, PtrTag tag, int result, Args... args)
     748        {
    726749            setupArguments<OperationType>(args...);
    727             return appendCallWithExceptionCheck(operation);
    728         }
    729 
     750            return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, tag, result);
     751        }
    730752
    731753        template<typename OperationType, typename... Args>
     
    733755        callOperationWithProfile(OperationType operation, int result, Args... args)
    734756        {
     757            PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     758            return callOperationWithProfile(operation, tag, result, args...);
     759        }
     760
     761        template<typename OperationType, typename... Args>
     762        MacroAssembler::Call callOperationWithResult(OperationType operation, PtrTag tag, JSValueRegs resultRegs, Args... args)
     763        {
    735764            setupArguments<OperationType>(args...);
    736             return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, result);
    737         }
    738 
    739         template<typename OperationType, typename... Args>
    740         MacroAssembler::Call callOperationWithResult(OperationType operation, JSValueRegs resultRegs, Args... args)
    741         {
    742             setupArguments<OperationType>(args...);
    743             auto result = appendCallWithExceptionCheck(operation);
     765            auto result = appendCallWithExceptionCheck(operation, tag);
    744766            setupResults(resultRegs);
    745767            return result;
     
    747769
    748770        template<typename OperationType, typename... Args>
    749         MacroAssembler::Call callOperationNoExceptionCheck(OperationType operation, Args... args)
     771        MacroAssembler::Call callOperationWithResult(OperationType operation, JSValueRegs resultRegs, Args... args)
     772        {
     773            PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     774            return callOperationWithResult(operation, tag, resultRegs, args...);
     775        }
     776
     777        template<typename OperationType, typename... Args>
     778        MacroAssembler::Call callOperationNoExceptionCheck(OperationType operation, PtrTag tag, Args... args)
    750779        {
    751780            setupArguments<OperationType>(args...);
    752781            updateTopCallFrame();
    753             return appendCall(operation);
     782            return appendCall(operation, tag);
     783        }
     784
     785        template<typename OperationType, typename... Args>
     786        MacroAssembler::Call callOperationNoExceptionCheck(OperationType operation, Args... args)
     787        {
     788            PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     789            return callOperationNoExceptionCheck(operation, tag, args...);
     790        }
     791
     792        template<typename OperationType, typename... Args>
     793        MacroAssembler::Call callOperationWithCallFrameRollbackOnException(OperationType operation, PtrTag tag, Args... args)
     794        {
     795            setupArguments<OperationType>(args...);
     796            return appendCallWithCallFrameRollbackOnException(operation, tag);
    754797        }
    755798
     
    757800        MacroAssembler::Call callOperationWithCallFrameRollbackOnException(OperationType operation, Args... args)
    758801        {
    759             setupArguments<OperationType>(args...);
    760             return appendCallWithCallFrameRollbackOnException(operation);
     802            PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID());
     803            return callOperationWithCallFrameRollbackOnException(operation, tag, args...);
    761804        }
    762805
  • trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp

    r229391 r229767  
    708708        ArithProfile* arithProfile = mathIC->arithProfile();
    709709        if (arithProfile && shouldEmitProfiling())
    710             callOperationWithResult(profiledFunction, resultRegs, srcRegs, arithProfile);
     710            callOperationWithResult(profiledFunction, NoPtrTag, resultRegs, srcRegs, arithProfile);
    711711        else
    712             callOperationWithResult(nonProfiledFunction, resultRegs, srcRegs);
     712            callOperationWithResult(nonProfiledFunction, NoPtrTag, resultRegs, srcRegs);
    713713    } else
    714714        addSlowCase(mathICGenerationState.slowPathJumps);
     
    781781        ArithProfile* arithProfile = mathIC->arithProfile();
    782782        if (arithProfile && shouldEmitProfiling())
    783             callOperationWithResult(profiledFunction, resultRegs, leftRegs, rightRegs, arithProfile);
     783            callOperationWithResult(profiledFunction, NoPtrTag, resultRegs, leftRegs, rightRegs, arithProfile);
    784784        else
    785             callOperationWithResult(nonProfiledFunction, resultRegs, leftRegs, rightRegs);
     785            callOperationWithResult(nonProfiledFunction, NoPtrTag, resultRegs, leftRegs, rightRegs);
    786786    } else
    787787        addSlowCase(mathICGenerationState.slowPathJumps);
     
    821821    if (arithProfile && shouldEmitProfiling()) {
    822822        if (mathICGenerationState.shouldSlowPathRepatch)
    823             mathICGenerationState.slowPathCall = callOperationWithResult(reinterpret_cast<J_JITOperation_EJMic>(profiledRepatchFunction), resultRegs, srcRegs, TrustedImmPtr(mathIC));
     823            mathICGenerationState.slowPathCall = callOperationWithResult(reinterpret_cast<J_JITOperation_EJMic>(profiledRepatchFunction), NoPtrTag, resultRegs, srcRegs, TrustedImmPtr(mathIC));
    824824        else
    825             mathICGenerationState.slowPathCall = callOperationWithResult(profiledFunction, resultRegs, srcRegs, arithProfile);
     825            mathICGenerationState.slowPathCall = callOperationWithResult(profiledFunction, NoPtrTag, resultRegs, srcRegs, arithProfile);
    826826    } else
    827         mathICGenerationState.slowPathCall = callOperationWithResult(reinterpret_cast<J_JITOperation_EJMic>(repatchFunction), resultRegs, srcRegs, TrustedImmPtr(mathIC));
     827        mathICGenerationState.slowPathCall = callOperationWithResult(reinterpret_cast<J_JITOperation_EJMic>(repatchFunction), NoPtrTag, resultRegs, srcRegs, TrustedImmPtr(mathIC));
    828828
    829829#if ENABLE(MATH_IC_STATS)
     
    887887    if (arithProfile && shouldEmitProfiling()) {
    888888        if (mathICGenerationState.shouldSlowPathRepatch)
    889             mathICGenerationState.slowPathCall = callOperationWithResult(bitwise_cast<J_JITOperation_EJJMic>(profiledRepatchFunction), resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC));
     889            mathICGenerationState.slowPathCall = callOperationWithResult(bitwise_cast<J_JITOperation_EJJMic>(profiledRepatchFunction), NoPtrTag, resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC));
    890890        else
    891             mathICGenerationState.slowPathCall = callOperationWithResult(profiledFunction, resultRegs, leftRegs, rightRegs, arithProfile);
     891            mathICGenerationState.slowPathCall = callOperationWithResult(profiledFunction, NoPtrTag, resultRegs, leftRegs, rightRegs, arithProfile);
    892892    } else
    893         mathICGenerationState.slowPathCall = callOperationWithResult(bitwise_cast<J_JITOperation_EJJMic>(repatchFunction), resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC));
     893        mathICGenerationState.slowPathCall = callOperationWithResult(bitwise_cast<J_JITOperation_EJJMic>(repatchFunction), NoPtrTag, resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC));
    894894
    895895#if ENABLE(MATH_IC_STATS)
  • trunk/Source/JavaScriptCore/jit/JITInlines.h

    r229709 r229767  
    11/*
    2  * Copyright (C) 2008, 2012-2013, 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    121121    ASSERT(m_bytecodeOffset != std::numeric_limits<unsigned>::max()); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
    122122    Call nakedCall = nearCall();
    123     m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, function.executableAddress()));
     123    assertIsNullOrTaggedWith(function.executableAddress(), NearCallPtrTag);
     124    m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, FunctionPtr(function)));
    124125    return nakedCall;
    125126}
     
    129130    ASSERT(m_bytecodeOffset != std::numeric_limits<unsigned>::max()); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
    130131    Call nakedCall = nearTailCall();
    131     m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, function.executableAddress()));
     132    assertIsNullOrTaggedWith(function.executableAddress(), NearCallPtrTag);
     133    m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, FunctionPtr(function)));
    132134    return nakedCall;
    133135}
     
    150152}
    151153
    152 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheck(const FunctionPtr function)
     154ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheck(const FunctionPtr function, PtrTag tag)
    153155{
    154156    updateTopCallFrame();
    155     MacroAssembler::Call call = appendCall(function);
     157    MacroAssembler::Call call = appendCall(function, tag);
    156158    exceptionCheck();
    157159    return call;
     
    159161
    160162#if OS(WINDOWS) && CPU(X86_64)
    161 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr function)
     163ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr function, PtrTag  tag)
    162164{
    163165    updateTopCallFrame();
    164     MacroAssembler::Call call = appendCallWithSlowPathReturnType(function);
     166    MacroAssembler::Call call = appendCallWithSlowPathReturnType(function, tag);
    165167    exceptionCheck();
    166168    return call;
     
    168170#endif
    169171
    170 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithCallFrameRollbackOnException(const FunctionPtr function)
     172ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithCallFrameRollbackOnException(const FunctionPtr function, PtrTag tag)
    171173{
    172174    updateTopCallFrame(); // The callee is responsible for setting topCallFrame to their caller
    173     MacroAssembler::Call call = appendCall(function);
     175    MacroAssembler::Call call = appendCall(function, tag);
    174176    exceptionCheckWithCallFrameRollback();
    175177    return call;
    176178}
    177179
    178 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr function, int dst)
    179 {
    180     MacroAssembler::Call call = appendCallWithExceptionCheck(function);
     180ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr function, PtrTag tag, int dst)
     181{
     182    MacroAssembler::Call call = appendCallWithExceptionCheck(function, tag);
    181183#if USE(JSVALUE64)
    182184    emitPutVirtualRegister(dst, returnValueGPR);
     
    187189}
    188190
    189 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr function, int dst)
    190 {
    191     MacroAssembler::Call call = appendCallWithExceptionCheck(function);
     191ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr function, PtrTag tag, int dst)
     192{
     193    MacroAssembler::Call call = appendCallWithExceptionCheck(function, tag);
    192194    emitValueProfilingSite();
    193195#if USE(JSVALUE64)
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp

    r229609 r229767  
    276276    emitGetVirtualRegister(base, regT0);
    277277    emitGetVirtualRegister(property, regT1);
    278     Call call = callOperation(operationGetByValOptimize, dst, regT0, regT1, byValInfo);
     278    Call call = callOperation(operationGetByValOptimize, NoPtrTag, dst, regT0, regT1, byValInfo);
    279279
    280280    m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath;
     
    493493    emitGetVirtualRegister(value, regT2);
    494494    bool isDirect = Interpreter::getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct;
    495     Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, regT0, regT1, regT2, byValInfo);
     495    Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, NoPtrTag, regT0, regT1, regT2, byValInfo);
    496496
    497497    m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath;
     
    12921292
    12931293    for (const auto& callSite : m_calls) {
    1294         if (callSite.to)
    1295             patchBuffer.link(callSite.from, FunctionPtr(callSite.to, SlowPathPtrTag));
     1294        if (callSite.callee)
     1295            patchBuffer.link(callSite.from, callSite.callee);
    12961296    }
    12971297    gen.finalize(patchBuffer);
     
    13461346    patchBuffer.link(done, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
    13471347    if (needsLinkForWriteBarrier) {
    1348         ASSERT(m_calls.last().to == operationWriteBarrierSlowPath);
    1349         patchBuffer.link(m_calls.last().from, operationWriteBarrierSlowPath, SlowPathPtrTag);
     1348        ASSERT(m_calls.last().callee.executableAddress() == operationWriteBarrierSlowPath);
     1349        patchBuffer.link(m_calls.last().from, FunctionPtr(operationWriteBarrierSlowPath, SlowPathPtrTag));
    13501350    }
    13511351   
     
    13821382
    13831383    for (const auto& callSite : m_calls) {
    1384         if (callSite.to)
    1385             patchBuffer.link(callSite.from, FunctionPtr(callSite.to, SlowPathPtrTag));
     1384        if (callSite.callee)
     1385            patchBuffer.link(callSite.from, callSite.callee);
    13861386    }
    13871387    gen.finalize(patchBuffer);
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp

    r229609 r229767  
    569569    poke(regT0, pokeOffset++);
    570570    poke(TrustedImmPtr(byValInfo), pokeOffset++);
    571     Call call = appendCallWithExceptionCheck(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize);
     571    Call call = appendCallWithExceptionCheck(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, NoPtrTag);
    572572#else
    573573    // The register selection below is chosen to reduce register swapping on ARM.
     
    576576    emitLoad(property, regT3, regT0);
    577577    emitLoad(value, regT5, regT4);
    578     Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, JSValueRegs(regT2, regT1), JSValueRegs(regT3, regT0), JSValueRegs(regT5, regT4), byValInfo);
     578    Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, NoPtrTag, JSValueRegs(regT2, regT1), JSValueRegs(regT3, regT0), JSValueRegs(regT5, regT4), byValInfo);
    579579#endif
    580580
  • trunk/Source/JavaScriptCore/jit/Repatch.cpp

    r229609 r229767  
    10681068    RELEASE_ASSERT(callCases.size() == calls.size());
    10691069    for (CallToCodePtr callToCodePtr : calls) {
     1070#if CPU(ARM_THUMB2)
    10701071        // Tail call special-casing ensures proper linking on ARM Thumb2, where a tail call jumps to an address
    10711072        // with a non-decorated bottom bit but a normal call calls an address with a decorated bottom bit.
    10721073        bool isTailCall = callToCodePtr.call.isFlagSet(CCallHelpers::Call::Tail);
    1073         patchBuffer.link(
    1074             callToCodePtr.call, FunctionPtr(tagCodePtr(isTailCall ? callToCodePtr.codePtr.dataLocation() : callToCodePtr.codePtr.executableAddress(), CodeEntryPtrTag)));
     1074        void* target = isTailCall ? callToCodePtr.codePtr.dataLocation() : callToCodePtr.codePtr.executableAddress();
     1075        patchBuffer.link(callToCodePtr.call, FunctionPtr(MacroAssemblerCodePtr(target)));
     1076#else
     1077        patchBuffer.link(callToCodePtr.call, FunctionPtr(callToCodePtr.codePtr.retagged(CodeEntryPtrTag, NearCallPtrTag)));
     1078#endif
    10751079    }
    10761080    if (isWebAssembly || JITCode::isOptimizingJIT(callerCodeBlock->jitType()))
  • trunk/Source/JavaScriptCore/jit/SlowPathCall.h

    r229609 r229767  
    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
     
    3535class JITSlowPathCall {
    3636public:
    37     JITSlowPathCall(JIT* jit, Instruction* pc, SlowPathFunction stub)
     37    JITSlowPathCall(JIT* jit, Instruction* pc, SlowPathFunction slowPathFunction)
    3838        : m_jit(jit)
    39         , m_stub(stub)
     39        , m_slowPathFunction(slowPathFunction)
    4040        , m_pc(pc)
    4141    {
     42        assertIsCFunctionPtr(slowPathFunction);
    4243    }
    4344
     
    6263        m_jit->move(JIT::TrustedImmPtr(m_pc), JIT::argumentGPR1);
    6364#endif
    64         JIT::Call call = m_jit->call(NoPtrTag);
    65         m_jit->m_calls.append(CallRecord(call, m_jit->m_bytecodeOffset, m_stub.value()));
     65        PtrTag tag = ptrTag(SlowPathPtrTag, nextPtrTagID());
     66        JIT::Call call = m_jit->call(tag);
     67        m_jit->m_calls.append(CallRecord(call, m_jit->m_bytecodeOffset, FunctionPtr(m_slowPathFunction, tag)));
    6668
    6769#if CPU(X86) && USE(JSVALUE32_64)
     
    8385private:
    8486    JIT* m_jit;
    85     FunctionPtr m_stub;
     87    SlowPathFunction m_slowPathFunction;
    8688    Instruction* m_pc;
    8789};
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r229609 r229767  
    416416    jit.move(JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::argumentGPR0);
    417417#endif
    418     jit.move(JSInterfaceJIT::TrustedImmPtr(FunctionPtr(operationVMHandleException, NoPtrTag).value()), JSInterfaceJIT::regT3);
    419     jit.call(JSInterfaceJIT::regT3, NoPtrTag);
     418    PtrTag tag = ptrTag(ExceptionHandlerPtrTag, nextPtrTagID());
     419    jit.move(JSInterfaceJIT::TrustedImmPtr(tagCFunctionPtr(operationVMHandleException, tag)), JSInterfaceJIT::regT3);
     420    jit.call(JSInterfaceJIT::regT3, tag);
    420421#if CPU(X86) && USE(JSVALUE32_64)
    421422    jit.addPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::stackPointerRegister);
  • trunk/Source/JavaScriptCore/runtime/PtrTag.h

    r229609 r229767  
    4343    ExceptionHandlerPtrTag,
    4444    JITCodePtrTag,
     45    JITOperationPtrTag,
     46    JITThunkPtrTag,
    4547    NativeCodePtrTag,
    4648    SlowPathPtrTag,
     
    5355};
    5456
     57uintptr_t nextPtrTagID();
     58
    5559#if !USE(POINTER_PROFILING)
    56 inline uintptr_t uniquePtrTagID() { return 0; }
     60inline uintptr_t nextPtrTagID() { return 0; }
    5761
    5862template<typename... Arguments>
     
    9599inline PtrType untagCFunctionPtr(PtrType ptr, PtrTag) { return ptr; }
    96100
     101template<typename PtrType> void assertIsCFunctionPtr(PtrType) { }
     102template<typename PtrType> void assertIsNullOrCFunctionPtr(PtrType) { }
     103
     104template<typename PtrType> void assertIsNotTagged(PtrType) { }
     105template<typename PtrType> void assertIsTagged(PtrType) { }
     106template<typename PtrType> void assertIsNullOrTagged(PtrType) { }
     107
     108template<typename PtrType> void assertIsTaggedWith(PtrType, PtrTag) { }
     109template<typename PtrType> void assertIsNullOrTaggedWith(PtrType, PtrTag) { }
     110
    97111#endif // !USE(POINTER_PROFILING)
    98112
Note: See TracChangeset for help on using the changeset viewer.