Changeset 243966 in webkit


Ignore:
Timestamp:
Apr 7, 2019 12:25:59 PM (5 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] CallLinkInfo should clear Callee or CodeBlock even if it is unlinked by jettison
https://bugs.webkit.org/show_bug.cgi?id=196683

Reviewed by Saam Barati.

JSTests:

  • stress/clear-callee-or-codeblock-in-calllinkinfo-even-cleared-by-jettison.js: Added.

(foo):

Source/JavaScriptCore:

In r243626, we stop repatching CallLinkInfo when the CallLinkInfo is held by jettisoned CodeBlock.
But we still need to clear the Callee or CodeBlock since they are now dead. Otherwise, CodeBlock's
visitWeak eventually accesses this dead cells and crashes because the owner CodeBlock of CallLinkInfo
can be still live.

We also move all repatching operations from CallLinkInfo.cpp to Repatch.cpp for consistency because the
other repatching operations in CallLinkInfo are implemented in Repatch.cpp side.

  • bytecode/CallLinkInfo.cpp:

(JSC::CallLinkInfo::setCallee):
(JSC::CallLinkInfo::clearCallee):

  • jit/Repatch.cpp:

(JSC::linkFor):
(JSC::revertCall):

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r243959 r243966  
     12019-04-07  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] CallLinkInfo should clear Callee or CodeBlock even if it is unlinked by jettison
     4        https://bugs.webkit.org/show_bug.cgi?id=196683
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/clear-callee-or-codeblock-in-calllinkinfo-even-cleared-by-jettison.js: Added.
     9        (foo):
     10
    1112019-04-05  Yusuke Suzuki  <ysuzuki@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r243959 r243966  
     12019-04-07  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] CallLinkInfo should clear Callee or CodeBlock even if it is unlinked by jettison
     4        https://bugs.webkit.org/show_bug.cgi?id=196683
     5
     6        Reviewed by Saam Barati.
     7
     8        In r243626, we stop repatching CallLinkInfo when the CallLinkInfo is held by jettisoned CodeBlock.
     9        But we still need to clear the Callee or CodeBlock since they are now dead. Otherwise, CodeBlock's
     10        visitWeak eventually accesses this dead cells and crashes because the owner CodeBlock of CallLinkInfo
     11        can be still live.
     12
     13        We also move all repatching operations from CallLinkInfo.cpp to Repatch.cpp for consistency because the
     14        other repatching operations in CallLinkInfo are implemented in Repatch.cpp side.
     15
     16        * bytecode/CallLinkInfo.cpp:
     17        (JSC::CallLinkInfo::setCallee):
     18        (JSC::CallLinkInfo::clearCallee):
     19        * jit/Repatch.cpp:
     20        (JSC::linkFor):
     21        (JSC::revertCall):
     22
    1232019-04-05  Yusuke Suzuki  <ysuzuki@apple.com>
    224
  • trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp

    r243626 r243966  
    3232#include "FunctionCodeBlock.h"
    3333#include "JSCInlines.h"
    34 #include "MacroAssembler.h"
    3534#include "Opcode.h"
    3635#include "Repatch.h"
     
    126125{
    127126    RELEASE_ASSERT(!isDirect());
    128     MacroAssembler::repatchPointer(hotPathBegin(), callee);
    129127    m_calleeOrCodeBlock.set(vm, owner, callee);
    130128}
     
    133131{
    134132    RELEASE_ASSERT(!isDirect());
    135     MacroAssembler::repatchPointer(hotPathBegin(), nullptr);
    136133    m_calleeOrCodeBlock.clear();
    137134}
  • trunk/Source/JavaScriptCore/jit/Repatch.cpp

    r243886 r243966  
    845845    ASSERT(!callLinkInfo.isLinked());
    846846    callLinkInfo.setCallee(vm, owner, callee);
     847    MacroAssembler::repatchPointer(callLinkInfo.hotPathBegin(), callee);
    847848    callLinkInfo.setLastSeenCallee(vm, owner, callee);
    848849    if (shouldDumpDisassemblyFor(callerCodeBlock))
     
    896897static void revertCall(VM* vm, CallLinkInfo& callLinkInfo, MacroAssemblerCodeRef<JITStubRoutinePtrTag> codeRef)
    897898{
    898     if (!callLinkInfo.clearedByJettison()) {
    899         if (callLinkInfo.isDirect()) {
    900             callLinkInfo.clearCodeBlock();
     899    if (callLinkInfo.isDirect()) {
     900        callLinkInfo.clearCodeBlock();
     901        if (!callLinkInfo.clearedByJettison()) {
    901902            if (callLinkInfo.callType() == CallLinkInfo::DirectTailCall)
    902903                MacroAssembler::repatchJump(callLinkInfo.patchableJump(), callLinkInfo.slowPathStart());
    903904            else
    904905                MacroAssembler::repatchNearCall(callLinkInfo.hotPathOther(), callLinkInfo.slowPathStart());
    905         } else {
     906        }
     907    } else {
     908        if (!callLinkInfo.clearedByJettison()) {
    906909            MacroAssembler::revertJumpReplacementToBranchPtrWithPatch(
    907910                MacroAssembler::startOfBranchPtrWithPatchOnRegister(callLinkInfo.hotPathBegin()),
    908911                static_cast<MacroAssembler::RegisterID>(callLinkInfo.calleeGPR()), 0);
    909912            linkSlowFor(vm, callLinkInfo, codeRef);
    910             callLinkInfo.clearCallee();
    911         }
     913            MacroAssembler::repatchPointer(callLinkInfo.hotPathBegin(), nullptr);
     914        }
     915        callLinkInfo.clearCallee();
    912916    }
    913917    callLinkInfo.clearSeen();
Note: See TracChangeset for help on using the changeset viewer.