Replace WTF::move with WTFMove
[WebKit-https.git] / Source / JavaScriptCore / jit / Repatch.cpp
index 94d68dd..66203d9 100644 (file)
@@ -28,9 +28,9 @@
 
 #if ENABLE(JIT)
 
-#include "AccessorCallJITStubRoutine.h"
 #include "BinarySwitch.h"
 #include "CCallHelpers.h"
+#include "CallFrameShuffler.h"
 #include "DFGOperations.h"
 #include "DFGSpeculativeJIT.h"
 #include "FTLThunks.h"
 #include "JITInlines.h"
 #include "LinkBuffer.h"
 #include "JSCInlines.h"
-#include "PolymorphicGetByIdList.h"
-#include "PolymorphicPutByIdList.h"
-#include "RegExpMatchesArray.h"
-#include "RepatchBuffer.h"
+#include "PolymorphicAccess.h"
 #include "ScratchRegisterAllocator.h"
 #include "StackAlignment.h"
 #include "StructureRareDataInlines.h"
 #include "StructureStubClearingWatchpoint.h"
 #include "ThunkGenerators.h"
+#include <wtf/CommaPrinter.h>
 #include <wtf/ListDump.h>
 #include <wtf/StringPrintStream.h>
 
@@ -59,26 +57,24 @@ namespace JSC {
 // - tagTypeNumberRegister
 // - tagMaskRegister
 
-static FunctionPtr readCallTarget(RepatchBuffer& repatchBuffer, CodeLocationCall call)
+static FunctionPtr readCallTarget(CodeBlock* codeBlock, CodeLocationCall call)
 {
     FunctionPtr result = MacroAssembler::readCallTarget(call);
 #if ENABLE(FTL_JIT)
-    CodeBlock* codeBlock = repatchBuffer.codeBlock();
     if (codeBlock->jitType() == JITCode::FTLJIT) {
         return FunctionPtr(codeBlock->vm()->ftlThunks->keyForSlowPathCallThunk(
             MacroAssemblerCodePtr::createFromExecutableAddress(
                 result.executableAddress())).callTarget());
     }
 #else
-    UNUSED_PARAM(repatchBuffer);
+    UNUSED_PARAM(codeBlock);
 #endif // ENABLE(FTL_JIT)
     return result;
 }
 
-static void repatchCall(RepatchBuffer& repatchBuffer, CodeLocationCall call, FunctionPtr newCalleeFunction)
+static void repatchCall(CodeBlock* codeBlock, CodeLocationCall call, FunctionPtr newCalleeFunction)
 {
 #if ENABLE(FTL_JIT)
-    CodeBlock* codeBlock = repatchBuffer.codeBlock();
     if (codeBlock->jitType() == JITCode::FTLJIT) {
         VM& vm = *codeBlock->vm();
         FTL::Thunks& thunks = *vm.ftlThunks;
@@ -89,524 +85,99 @@ static void repatchCall(RepatchBuffer& repatchBuffer, CodeLocationCall call, Fun
         newCalleeFunction = FunctionPtr(
             thunks.getSlowPathCallThunk(vm, key).code().executableAddress());
     }
+#else // ENABLE(FTL_JIT)
+    UNUSED_PARAM(codeBlock);
 #endif // ENABLE(FTL_JIT)
-    repatchBuffer.relink(call, newCalleeFunction);
-}
-
-static void repatchCall(CodeBlock* codeblock, CodeLocationCall call, FunctionPtr newCalleeFunction)
-{
-    RepatchBuffer repatchBuffer(codeblock);
-    repatchCall(repatchBuffer, call, newCalleeFunction);
+    MacroAssembler::repatchCall(call, newCalleeFunction);
 }
 
 static void repatchByIdSelfAccess(
-    VM& vm, CodeBlock* codeBlock, StructureStubInfo& stubInfo, Structure* structure,
-    const Identifier& propertyName, PropertyOffset offset, const FunctionPtr &slowPathFunction,
+    CodeBlock* codeBlock, StructureStubInfo& stubInfo, Structure* structure,
+    PropertyOffset offset, const FunctionPtr &slowPathFunction,
     bool compact)
 {
-    if (structure->typeInfo().newImpurePropertyFiresWatchpoints())
-        vm.registerWatchpointForImpureProperty(propertyName, stubInfo.addWatchpoint(codeBlock));
-    
-    RepatchBuffer repatchBuffer(codeBlock);
-
     // Only optimize once!
-    repatchCall(repatchBuffer, stubInfo.callReturnLocation, slowPathFunction);
+    repatchCall(codeBlock, stubInfo.callReturnLocation, slowPathFunction);
 
     // Patch the structure check & the offset of the load.
-    repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabel32AtOffset(-(intptr_t)stubInfo.patch.deltaCheckImmToCall), bitwise_cast<int32_t>(structure->id()));
-    repatchBuffer.setLoadInstructionIsActive(stubInfo.callReturnLocation.convertibleLoadAtOffset(stubInfo.patch.deltaCallToStorageLoad), isOutOfLineOffset(offset));
+    MacroAssembler::repatchInt32(
+        stubInfo.callReturnLocation.dataLabel32AtOffset(-(intptr_t)stubInfo.patch.deltaCheckImmToCall),
+        bitwise_cast<int32_t>(structure->id()));
 #if USE(JSVALUE64)
     if (compact)
-        repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToLoadOrStore), offsetRelativeToPatchedStorage(offset));
+        MacroAssembler::repatchCompact(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToLoadOrStore), offsetRelativeToBase(offset));
     else
-        repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToLoadOrStore), offsetRelativeToPatchedStorage(offset));
+        MacroAssembler::repatchInt32(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToLoadOrStore), offsetRelativeToBase(offset));
 #elif USE(JSVALUE32_64)
     if (compact) {
-        repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToTagLoadOrStore), offsetRelativeToPatchedStorage(offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
-        repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToPayloadLoadOrStore), offsetRelativeToPatchedStorage(offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
+        MacroAssembler::repatchCompact(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToTagLoadOrStore), offsetRelativeToBase(offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
+        MacroAssembler::repatchCompact(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToPayloadLoadOrStore), offsetRelativeToBase(offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
     } else {
-        repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToTagLoadOrStore), offsetRelativeToPatchedStorage(offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
-        repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToPayloadLoadOrStore), offsetRelativeToPatchedStorage(offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
+        MacroAssembler::repatchInt32(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToTagLoadOrStore), offsetRelativeToBase(offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
+        MacroAssembler::repatchInt32(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToPayloadLoadOrStore), offsetRelativeToBase(offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
     }
 #endif
 }
 
-static void addStructureTransitionCheck(
-    JSCell* object, Structure* structure, CodeBlock* codeBlock, StructureStubInfo& stubInfo,
-    MacroAssembler& jit, MacroAssembler::JumpList& failureCases, GPRReg scratchGPR)
+static void resetGetByIDCheckAndLoad(StructureStubInfo& stubInfo)
 {
-    if (object->structure() == structure && structure->transitionWatchpointSetIsStillValid()) {
-        structure->addTransitionWatchpoint(stubInfo.addWatchpoint(codeBlock));
-        if (!ASSERT_DISABLED) {
-            // If we execute this code, the object must have the structure we expect. Assert
-            // this in debug modes.
-            jit.move(MacroAssembler::TrustedImmPtr(object), scratchGPR);
-            MacroAssembler::Jump ok = branchStructure(
-                jit,
-                MacroAssembler::Equal,
-                MacroAssembler::Address(scratchGPR, JSCell::structureIDOffset()),
-                structure);
-            jit.abortWithReason(RepatchIneffectiveWatchpoint);
-            ok.link(&jit);
-        }
-        return;
+    CodeLocationDataLabel32 structureLabel = stubInfo.callReturnLocation.dataLabel32AtOffset(-(intptr_t)stubInfo.patch.deltaCheckImmToCall);
+    if (MacroAssembler::canJumpReplacePatchableBranch32WithPatch()) {
+        MacroAssembler::revertJumpReplacementToPatchableBranch32WithPatch(
+            MacroAssembler::startOfPatchableBranch32WithPatchOnAddress(structureLabel),
+            MacroAssembler::Address(
+                static_cast<MacroAssembler::RegisterID>(stubInfo.patch.baseGPR),
+                JSCell::structureIDOffset()),
+            static_cast<int32_t>(unusedPointer));
     }
-    
-    jit.move(MacroAssembler::TrustedImmPtr(object), scratchGPR);
-    failureCases.append(
-        branchStructure(jit,
-            MacroAssembler::NotEqual,
-            MacroAssembler::Address(scratchGPR, JSCell::structureIDOffset()),
-            structure));
+    MacroAssembler::repatchInt32(structureLabel, static_cast<int32_t>(unusedPointer));
+#if USE(JSVALUE64)
+    MacroAssembler::repatchCompact(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToLoadOrStore), 0);
+#else
+    MacroAssembler::repatchCompact(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToTagLoadOrStore), 0);
+    MacroAssembler::repatchCompact(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToPayloadLoadOrStore), 0);
+#endif
 }
 
-static void addStructureTransitionCheck(
-    JSValue prototype, CodeBlock* codeBlock, StructureStubInfo& stubInfo,
-    MacroAssembler& jit, MacroAssembler::JumpList& failureCases, GPRReg scratchGPR)
+static void resetPutByIDCheckAndLoad(StructureStubInfo& stubInfo)
 {
-    if (prototype.isNull())
-        return;
-    
-    ASSERT(prototype.isCell());
-    
-    addStructureTransitionCheck(
-        prototype.asCell(), prototype.asCell()->structure(), codeBlock, stubInfo, jit,
-        failureCases, scratchGPR);
+    CodeLocationDataLabel32 structureLabel = stubInfo.callReturnLocation.dataLabel32AtOffset(-(intptr_t)stubInfo.patch.deltaCheckImmToCall);
+    if (MacroAssembler::canJumpReplacePatchableBranch32WithPatch()) {
+        MacroAssembler::revertJumpReplacementToPatchableBranch32WithPatch(
+            MacroAssembler::startOfPatchableBranch32WithPatchOnAddress(structureLabel),
+            MacroAssembler::Address(
+                static_cast<MacroAssembler::RegisterID>(stubInfo.patch.baseGPR),
+                JSCell::structureIDOffset()),
+            static_cast<int32_t>(unusedPointer));
+    }
+    MacroAssembler::repatchInt32(structureLabel, static_cast<int32_t>(unusedPointer));
+#if USE(JSVALUE64)
+    MacroAssembler::repatchInt32(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToLoadOrStore), 0);
+#else
+    MacroAssembler::repatchInt32(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToTagLoadOrStore), 0);
+    MacroAssembler::repatchInt32(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToPayloadLoadOrStore), 0);
+#endif
 }
 
-static void replaceWithJump(RepatchBuffer& repatchBuffer, StructureStubInfo& stubInfo, const MacroAssemblerCodePtr target)
+static void replaceWithJump(StructureStubInfo& stubInfo, const MacroAssemblerCodePtr target)
 {
     if (MacroAssembler::canJumpReplacePatchableBranch32WithPatch()) {
-        repatchBuffer.replaceWithJump(
-            RepatchBuffer::startOfPatchableBranch32WithPatchOnAddress(
+        MacroAssembler::replaceWithJump(
+            MacroAssembler::startOfPatchableBranch32WithPatchOnAddress(
                 stubInfo.callReturnLocation.dataLabel32AtOffset(
                     -(intptr_t)stubInfo.patch.deltaCheckImmToCall)),
             CodeLocationLabel(target));
         return;
     }
+
+    resetGetByIDCheckAndLoad(stubInfo);
     
-    repatchBuffer.relink(
+    MacroAssembler::repatchJump(
         stubInfo.callReturnLocation.jumpAtOffset(
             stubInfo.patch.deltaCallToJump),
         CodeLocationLabel(target));
 }
 
-static void emitRestoreScratch(MacroAssembler& stubJit, bool needToRestoreScratch, GPRReg scratchGPR, MacroAssembler::Jump& success, MacroAssembler::Jump& fail, MacroAssembler::JumpList failureCases)
-{
-    if (needToRestoreScratch) {
-        stubJit.popToRestore(scratchGPR);
-        
-        success = stubJit.jump();
-        
-        // link failure cases here, so we can pop scratchGPR, and then jump back.
-        failureCases.link(&stubJit);
-        
-        stubJit.popToRestore(scratchGPR);
-        
-        fail = stubJit.jump();
-        return;
-    }
-    
-    success = stubJit.jump();
-}
-
-static void linkRestoreScratch(LinkBuffer& patchBuffer, bool needToRestoreScratch, MacroAssembler::Jump success, MacroAssembler::Jump fail, MacroAssembler::JumpList failureCases, CodeLocationLabel successLabel, CodeLocationLabel slowCaseBegin)
-{
-    patchBuffer.link(success, successLabel);
-        
-    if (needToRestoreScratch) {
-        patchBuffer.link(fail, slowCaseBegin);
-        return;
-    }
-    
-    // link failure cases directly back to normal path
-    patchBuffer.link(failureCases, slowCaseBegin);
-}
-
-static void linkRestoreScratch(LinkBuffer& patchBuffer, bool needToRestoreScratch, StructureStubInfo& stubInfo, MacroAssembler::Jump success, MacroAssembler::Jump fail, MacroAssembler::JumpList failureCases)
-{
-    linkRestoreScratch(patchBuffer, needToRestoreScratch, success, fail, failureCases, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
-}
-
-enum ByIdStubKind {
-    GetValue,
-    GetUndefined,
-    CallGetter,
-    CallCustomGetter,
-    CallSetter,
-    CallCustomSetter
-};
-
-static const char* toString(ByIdStubKind kind)
-{
-    switch (kind) {
-    case GetValue:
-        return "GetValue";
-    case GetUndefined:
-        return "GetUndefined";
-    case CallGetter:
-        return "CallGetter";
-    case CallCustomGetter:
-        return "CallCustomGetter";
-    case CallSetter:
-        return "CallSetter";
-    case CallCustomSetter:
-        return "CallCustomSetter";
-    default:
-        RELEASE_ASSERT_NOT_REACHED();
-        return nullptr;
-    }
-}
-
-static ByIdStubKind kindFor(const PropertySlot& slot)
-{
-    if (slot.isCacheableValue())
-        return GetValue;
-    if (slot.isUnset())
-        return GetUndefined;
-    if (slot.isCacheableCustom())
-        return CallCustomGetter;
-    RELEASE_ASSERT(slot.isCacheableGetter());
-    return CallGetter;
-}
-
-static FunctionPtr customFor(const PropertySlot& slot)
-{
-    if (!slot.isCacheableCustom())
-        return FunctionPtr();
-    return FunctionPtr(slot.customGetter());
-}
-
-static ByIdStubKind kindFor(const PutPropertySlot& slot)
-{
-    RELEASE_ASSERT(!slot.isCacheablePut());
-    if (slot.isCacheableSetter())
-        return CallSetter;
-    RELEASE_ASSERT(slot.isCacheableCustom());
-    return CallCustomSetter;
-}
-
-static FunctionPtr customFor(const PutPropertySlot& slot)
-{
-    if (!slot.isCacheableCustom())
-        return FunctionPtr();
-    return FunctionPtr(slot.customSetter());
-}
-
-static bool generateByIdStub(
-    ExecState* exec, ByIdStubKind kind, const Identifier& propertyName,
-    FunctionPtr custom, StructureStubInfo& stubInfo, StructureChain* chain, size_t count,
-    PropertyOffset offset, Structure* structure, bool loadTargetFromProxy, WatchpointSet* watchpointSet,
-    CodeLocationLabel successLabel, CodeLocationLabel slowCaseLabel, RefPtr<JITStubRoutine>& stubRoutine)
-{
-
-    VM* vm = &exec->vm();
-    GPRReg baseGPR = static_cast<GPRReg>(stubInfo.patch.baseGPR);
-    JSValueRegs valueRegs = JSValueRegs(
-#if USE(JSVALUE32_64)
-        static_cast<GPRReg>(stubInfo.patch.valueTagGPR),
-#endif
-        static_cast<GPRReg>(stubInfo.patch.valueGPR));
-    GPRReg scratchGPR = TempRegisterSet(stubInfo.patch.usedRegisters).getFreeGPR();
-    bool needToRestoreScratch = scratchGPR == InvalidGPRReg;
-    RELEASE_ASSERT(!needToRestoreScratch || (kind == GetValue || kind == GetUndefined));
-    
-    CCallHelpers stubJit(&exec->vm(), exec->codeBlock());
-    if (needToRestoreScratch) {
-        scratchGPR = AssemblyHelpers::selectScratchGPR(
-            baseGPR, valueRegs.tagGPR(), valueRegs.payloadGPR());
-        stubJit.pushToSave(scratchGPR);
-        needToRestoreScratch = true;
-    }
-    
-    MacroAssembler::JumpList failureCases;
-
-    GPRReg baseForGetGPR;
-    if (loadTargetFromProxy) {
-        baseForGetGPR = valueRegs.payloadGPR();
-        failureCases.append(stubJit.branch8(
-            MacroAssembler::NotEqual, 
-            MacroAssembler::Address(baseGPR, JSCell::typeInfoTypeOffset()), 
-            MacroAssembler::TrustedImm32(PureForwardingProxyType)));
-
-        stubJit.loadPtr(MacroAssembler::Address(baseGPR, JSProxy::targetOffset()), scratchGPR);
-        
-        failureCases.append(branchStructure(stubJit,
-            MacroAssembler::NotEqual, 
-            MacroAssembler::Address(scratchGPR, JSCell::structureIDOffset()),
-            structure));
-    } else {
-        baseForGetGPR = baseGPR;
-
-        failureCases.append(branchStructure(stubJit,
-            MacroAssembler::NotEqual, 
-            MacroAssembler::Address(baseForGetGPR, JSCell::structureIDOffset()), 
-            structure));
-    }
-
-    CodeBlock* codeBlock = exec->codeBlock();
-    if (structure->typeInfo().newImpurePropertyFiresWatchpoints())
-        vm->registerWatchpointForImpureProperty(propertyName, stubInfo.addWatchpoint(codeBlock));
-
-    if (watchpointSet)
-        watchpointSet->add(stubInfo.addWatchpoint(codeBlock));
-
-    Structure* currStructure = structure; 
-    JSObject* protoObject = 0;
-    if (chain) {
-        WriteBarrier<Structure>* it = chain->head();
-        for (unsigned i = 0; i < count; ++i, ++it) {
-            protoObject = asObject(currStructure->prototypeForLookup(exec));
-            Structure* protoStructure = protoObject->structure();
-            if (protoStructure->typeInfo().newImpurePropertyFiresWatchpoints())
-                vm->registerWatchpointForImpureProperty(propertyName, stubInfo.addWatchpoint(codeBlock));
-            addStructureTransitionCheck(
-                protoObject, protoStructure, codeBlock, stubInfo, stubJit,
-                failureCases, scratchGPR);
-            currStructure = it->get();
-        }
-        ASSERT(!protoObject || protoObject->structure() == currStructure);
-    }
-    
-    currStructure->startWatchingPropertyForReplacements(*vm, offset);
-    GPRReg baseForAccessGPR = InvalidGPRReg;
-    if (kind != GetUndefined) {
-        if (chain) {
-            // We could have clobbered scratchGPR earlier, so we have to reload from baseGPR to get the target.
-            if (loadTargetFromProxy)
-                stubJit.loadPtr(MacroAssembler::Address(baseGPR, JSProxy::targetOffset()), baseForGetGPR);
-            stubJit.move(MacroAssembler::TrustedImmPtr(protoObject), scratchGPR);
-            baseForAccessGPR = scratchGPR;
-        } else {
-            // For proxy objects, we need to do all the Structure checks before moving the baseGPR into
-            // baseForGetGPR because if we fail any of the checks then we would have the wrong value in baseGPR
-            // on the slow path.
-            if (loadTargetFromProxy)
-                stubJit.move(scratchGPR, baseForGetGPR);
-            baseForAccessGPR = baseForGetGPR;
-        }
-    }
-
-    GPRReg loadedValueGPR = InvalidGPRReg;
-    if (kind == GetUndefined)
-        stubJit.moveTrustedValue(jsUndefined(), valueRegs);
-    else if (kind != CallCustomGetter && kind != CallCustomSetter) {
-        if (kind == GetValue)
-            loadedValueGPR = valueRegs.payloadGPR();
-        else
-            loadedValueGPR = scratchGPR;
-        
-        GPRReg storageGPR;
-        if (isInlineOffset(offset))
-            storageGPR = baseForAccessGPR;
-        else {
-            stubJit.loadPtr(MacroAssembler::Address(baseForAccessGPR, JSObject::butterflyOffset()), loadedValueGPR);
-            storageGPR = loadedValueGPR;
-        }
-        
-#if USE(JSVALUE64)
-        stubJit.load64(MacroAssembler::Address(storageGPR, offsetRelativeToBase(offset)), loadedValueGPR);
-#else
-        if (kind == GetValue)
-            stubJit.load32(MacroAssembler::Address(storageGPR, offsetRelativeToBase(offset) + TagOffset), valueRegs.tagGPR());
-        stubJit.load32(MacroAssembler::Address(storageGPR, offsetRelativeToBase(offset) + PayloadOffset), loadedValueGPR);
-#endif
-    }
-
-    // Stuff for custom getters.
-    MacroAssembler::Call operationCall;
-    MacroAssembler::Call handlerCall;
-
-    // Stuff for JS getters.
-    MacroAssembler::DataLabelPtr addressOfLinkFunctionCheck;
-    MacroAssembler::Call fastPathCall;
-    MacroAssembler::Call slowPathCall;
-    std::unique_ptr<CallLinkInfo> callLinkInfo;
-
-    MacroAssembler::Jump success, fail;
-    if (kind != GetValue && kind != GetUndefined) {
-        // Need to make sure that whenever this call is made in the future, we remember the
-        // place that we made it from. It just so happens to be the place that we are at
-        // right now!
-        stubJit.store32(MacroAssembler::TrustedImm32(exec->locationAsRawBits()),
-            CCallHelpers::tagFor(static_cast<VirtualRegister>(JSStack::ArgumentCount)));
-
-        if (kind == CallGetter || kind == CallSetter) {
-            // Create a JS call using a JS call inline cache. Assume that:
-            //
-            // - SP is aligned and represents the extent of the calling compiler's stack usage.
-            //
-            // - FP is set correctly (i.e. it points to the caller's call frame header).
-            //
-            // - SP - FP is an aligned difference.
-            //
-            // - Any byte between FP (exclusive) and SP (inclusive) could be live in the calling
-            //   code.
-            //
-            // Therefore, we temporarily grow the stack for the purpose of the call and then
-            // shrink it after.
-            
-            callLinkInfo = std::make_unique<CallLinkInfo>();
-            callLinkInfo->callType = CallLinkInfo::Call;
-            callLinkInfo->codeOrigin = stubInfo.codeOrigin;
-            callLinkInfo->calleeGPR = loadedValueGPR;
-            
-            MacroAssembler::JumpList done;
-            
-            // There is a 'this' argument but nothing else.
-            unsigned numberOfParameters = 1;
-            // ... unless we're calling a setter.
-            if (kind == CallSetter)
-                numberOfParameters++;
-            
-            // Get the accessor; if there ain't one then the result is jsUndefined().
-            if (kind == CallSetter) {
-                stubJit.loadPtr(
-                    MacroAssembler::Address(loadedValueGPR, GetterSetter::offsetOfSetter()),
-                    loadedValueGPR);
-            } else {
-                stubJit.loadPtr(
-                    MacroAssembler::Address(loadedValueGPR, GetterSetter::offsetOfGetter()),
-                    loadedValueGPR);
-            }
-            MacroAssembler::Jump returnUndefined = stubJit.branchTestPtr(
-                MacroAssembler::Zero, loadedValueGPR);
-            
-            unsigned numberOfRegsForCall =
-                JSStack::CallFrameHeaderSize + numberOfParameters;
-            
-            unsigned numberOfBytesForCall =
-                numberOfRegsForCall * sizeof(Register) - sizeof(CallerFrameAndPC);
-            
-            unsigned alignedNumberOfBytesForCall =
-                WTF::roundUpToMultipleOf(stackAlignmentBytes(), numberOfBytesForCall);
-            
-            stubJit.subPtr(
-                MacroAssembler::TrustedImm32(alignedNumberOfBytesForCall),
-                MacroAssembler::stackPointerRegister);
-            
-            MacroAssembler::Address calleeFrame = MacroAssembler::Address(
-                MacroAssembler::stackPointerRegister,
-                -static_cast<ptrdiff_t>(sizeof(CallerFrameAndPC)));
-            
-            stubJit.store32(
-                MacroAssembler::TrustedImm32(numberOfParameters),
-                calleeFrame.withOffset(
-                    JSStack::ArgumentCount * sizeof(Register) + PayloadOffset));
-            
-            stubJit.storeCell(
-                loadedValueGPR, calleeFrame.withOffset(JSStack::Callee * sizeof(Register)));
-
-            stubJit.storeCell(
-                baseForGetGPR,
-                calleeFrame.withOffset(
-                    virtualRegisterForArgument(0).offset() * sizeof(Register)));
-            
-            if (kind == CallSetter) {
-                stubJit.storeValue(
-                    valueRegs,
-                    calleeFrame.withOffset(
-                        virtualRegisterForArgument(1).offset() * sizeof(Register)));
-            }
-            
-            MacroAssembler::Jump slowCase = stubJit.branchPtrWithPatch(
-                MacroAssembler::NotEqual, loadedValueGPR, addressOfLinkFunctionCheck,
-                MacroAssembler::TrustedImmPtr(0));
-            
-            fastPathCall = stubJit.nearCall();
-            
-            stubJit.addPtr(
-                MacroAssembler::TrustedImm32(alignedNumberOfBytesForCall),
-                MacroAssembler::stackPointerRegister);
-            if (kind == CallGetter)
-                stubJit.setupResults(valueRegs);
-            
-            done.append(stubJit.jump());
-            slowCase.link(&stubJit);
-            
-            stubJit.move(loadedValueGPR, GPRInfo::regT0);
-#if USE(JSVALUE32_64)
-            stubJit.move(MacroAssembler::TrustedImm32(JSValue::CellTag), GPRInfo::regT1);
-#endif
-            stubJit.move(MacroAssembler::TrustedImmPtr(callLinkInfo.get()), GPRInfo::regT2);
-            slowPathCall = stubJit.nearCall();
-            
-            stubJit.addPtr(
-                MacroAssembler::TrustedImm32(alignedNumberOfBytesForCall),
-                MacroAssembler::stackPointerRegister);
-            if (kind == CallGetter)
-                stubJit.setupResults(valueRegs);
-            
-            done.append(stubJit.jump());
-            returnUndefined.link(&stubJit);
-            
-            if (kind == CallGetter)
-                stubJit.moveTrustedValue(jsUndefined(), valueRegs);
-            
-            done.link(&stubJit);
-        } else {
-            // getter: EncodedJSValue (*GetValueFunc)(ExecState*, JSObject* slotBase, EncodedJSValue thisValue, PropertyName);
-            // setter: void (*PutValueFunc)(ExecState*, JSObject* base, EncodedJSValue thisObject, EncodedJSValue value);
-#if USE(JSVALUE64)
-            if (kind == CallCustomGetter)
-                stubJit.setupArgumentsWithExecState(baseForAccessGPR, baseForGetGPR, MacroAssembler::TrustedImmPtr(propertyName.impl()));
-            else
-                stubJit.setupArgumentsWithExecState(baseForAccessGPR, baseForGetGPR, valueRegs.gpr());
-#else
-            if (kind == CallCustomGetter)
-                stubJit.setupArgumentsWithExecState(baseForAccessGPR, baseForGetGPR, MacroAssembler::TrustedImm32(JSValue::CellTag), MacroAssembler::TrustedImmPtr(propertyName.impl()));
-            else
-                stubJit.setupArgumentsWithExecState(baseForAccessGPR, baseForGetGPR, MacroAssembler::TrustedImm32(JSValue::CellTag), valueRegs.payloadGPR(), valueRegs.tagGPR());
-#endif
-            stubJit.storePtr(GPRInfo::callFrameRegister, &vm->topCallFrame);
-
-            operationCall = stubJit.call();
-            if (kind == CallCustomGetter)
-                stubJit.setupResults(valueRegs);
-            MacroAssembler::Jump noException = stubJit.emitExceptionCheck(CCallHelpers::InvertedExceptionCheck);
-            
-            stubJit.setupArguments(CCallHelpers::TrustedImmPtr(vm), GPRInfo::callFrameRegister);
-            handlerCall = stubJit.call();
-            stubJit.jumpToExceptionHandler();
-            
-            noException.link(&stubJit);
-        }
-    }
-    emitRestoreScratch(stubJit, needToRestoreScratch, scratchGPR, success, fail, failureCases);
-    
-    LinkBuffer patchBuffer(*vm, stubJit, exec->codeBlock(), JITCompilationCanFail);
-    if (patchBuffer.didFailToAllocate())
-        return false;
-    
-    linkRestoreScratch(patchBuffer, needToRestoreScratch, success, fail, failureCases, successLabel, slowCaseLabel);
-    if (kind == CallCustomGetter || kind == CallCustomSetter) {
-        patchBuffer.link(operationCall, custom);
-        patchBuffer.link(handlerCall, lookupExceptionHandler);
-    } else if (kind == CallGetter || kind == CallSetter) {
-        callLinkInfo->hotPathOther = patchBuffer.locationOfNearCall(fastPathCall);
-        callLinkInfo->hotPathBegin = patchBuffer.locationOf(addressOfLinkFunctionCheck);
-        callLinkInfo->callReturnLocation = patchBuffer.locationOfNearCall(slowPathCall);
-
-        ThunkGenerator generator = linkThunkGeneratorFor(
-            CodeForCall, RegisterPreservationNotRequired);
-        patchBuffer.link(
-            slowPathCall, CodeLocationLabel(vm->getCTIStub(generator).code()));
-    }
-    
-    MacroAssemblerCodeRef code = FINALIZE_CODE_FOR(
-        exec->codeBlock(), patchBuffer,
-        ("%s access stub for %s, return point %p",
-            toString(kind), toCString(*exec->codeBlock()).data(),
-            successLabel.executableAddress()));
-    
-    if (kind == CallGetter || kind == CallSetter)
-        stubRoutine = adoptRef(new AccessorCallJITStubRoutine(code, *vm, WTF::move(callLinkInfo)));
-    else
-        stubRoutine = createJITStubRoutine(code, *vm, codeBlock->ownerExecutable(), true);
-    
-    return true;
-}
-
 enum InlineCacheAction {
     GiveUpOnCache,
     RetryCacheLater,
@@ -628,147 +199,128 @@ static InlineCacheAction actionForCell(VM& vm, JSCell* cell)
         asObject(cell)->flattenDictionaryObject(vm);
         return RetryCacheLater;
     }
-    ASSERT(!structure->isUncacheableDictionary());
     
-    if (typeInfo.hasImpureGetOwnPropertySlot() && !typeInfo.newImpurePropertyFiresWatchpoints())
+    if (!structure->propertyAccessesAreCacheable())
         return GiveUpOnCache;
 
     return AttemptToCache;
 }
 
+static bool forceICFailure(ExecState*)
+{
+    return Options::forceICFailure();
+}
+
 static InlineCacheAction tryCacheGetByID(ExecState* exec, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo& stubInfo)
 {
-    if (Options::forceICFailure())
+    if (forceICFailure(exec))
         return GiveUpOnCache;
     
-    // FIXME: Write a test that proves we need to check for recursion here just
-    // like the interpreter does, then add a check for recursion.
+    // FIXME: Cache property access for immediates.
+    if (!baseValue.isCell())
+        return GiveUpOnCache;
 
     CodeBlock* codeBlock = exec->codeBlock();
-    VM* vm = &exec->vm();
+    VM& vm = exec->vm();
 
-    if ((isJSArray(baseValue) || isJSString(baseValue)) && propertyName == exec->propertyNames().length) {
-        GPRReg baseGPR = static_cast<GPRReg>(stubInfo.patch.baseGPR);
-#if USE(JSVALUE32_64)
-        GPRReg resultTagGPR = static_cast<GPRReg>(stubInfo.patch.valueTagGPR);
-#endif
-        GPRReg resultGPR = static_cast<GPRReg>(stubInfo.patch.valueGPR);
+    std::unique_ptr<AccessCase> newCase;
 
-        MacroAssembler stubJit;
-
-        if (isJSArray(baseValue)) {
-            GPRReg scratchGPR = TempRegisterSet(stubInfo.patch.usedRegisters).getFreeGPR();
-            bool needToRestoreScratch = false;
-
-            if (scratchGPR == InvalidGPRReg) {
-#if USE(JSVALUE64)
-                scratchGPR = AssemblyHelpers::selectScratchGPR(baseGPR, resultGPR);
-#else
-                scratchGPR = AssemblyHelpers::selectScratchGPR(baseGPR, resultGPR, resultTagGPR);
-#endif
-                stubJit.pushToSave(scratchGPR);
-                needToRestoreScratch = true;
-            }
-
-            MacroAssembler::JumpList failureCases;
+    if (isJSArray(baseValue) && propertyName == exec->propertyNames().length)
+        newCase = AccessCase::getLength(vm, codeBlock, AccessCase::ArrayLength);
+    else if (isJSString(baseValue) && propertyName == exec->propertyNames().length)
+        newCase = AccessCase::getLength(vm, codeBlock, AccessCase::StringLength);
+    else {
+        if (!slot.isCacheable() && !slot.isUnset())
+            return GiveUpOnCache;
 
-            stubJit.load8(MacroAssembler::Address(baseGPR, JSCell::indexingTypeOffset()), scratchGPR);
-            failureCases.append(stubJit.branchTest32(MacroAssembler::Zero, scratchGPR, MacroAssembler::TrustedImm32(IsArray)));
-            failureCases.append(stubJit.branchTest32(MacroAssembler::Zero, scratchGPR, MacroAssembler::TrustedImm32(IndexingShapeMask)));
+        ObjectPropertyConditionSet conditionSet;
+        JSCell* baseCell = baseValue.asCell();
+        Structure* structure = baseCell->structure(vm);
 
-            stubJit.loadPtr(MacroAssembler::Address(baseGPR, JSObject::butterflyOffset()), scratchGPR);
-            stubJit.load32(MacroAssembler::Address(scratchGPR, ArrayStorage::lengthOffset()), scratchGPR);
-            failureCases.append(stubJit.branch32(MacroAssembler::LessThan, scratchGPR, MacroAssembler::TrustedImm32(0)));
+        bool loadTargetFromProxy = false;
+        if (baseCell->type() == PureForwardingProxyType) {
+            baseValue = jsCast<JSProxy*>(baseCell)->target();
+            baseCell = baseValue.asCell();
+            structure = baseCell->structure(vm);
+            loadTargetFromProxy = true;
+        }
 
-            stubJit.move(scratchGPR, resultGPR);
-#if USE(JSVALUE64)
-            stubJit.or64(AssemblyHelpers::TrustedImm64(TagTypeNumber), resultGPR);
-#elif USE(JSVALUE32_64)
-            stubJit.move(AssemblyHelpers::TrustedImm32(JSValue::Int32Tag), resultTagGPR);
-#endif
+        InlineCacheAction action = actionForCell(vm, baseCell);
+        if (action != AttemptToCache)
+            return action;
+        
+        // Optimize self access.
+        if (stubInfo.cacheType == CacheType::Unset
+            && slot.isCacheableValue()
+            && slot.slotBase() == baseValue
+            && !slot.watchpointSet()
+            && isInlineOffset(slot.cachedOffset())
+            && MacroAssembler::isCompactPtrAlignedAddressOffset(maxOffsetRelativeToBase(slot.cachedOffset()))
+            && action == AttemptToCache
+            && !structure->needImpurePropertyWatchpoint()
+            && !loadTargetFromProxy) {
+            structure->startWatchingPropertyForReplacements(vm, slot.cachedOffset());
+            repatchByIdSelfAccess(codeBlock, stubInfo, structure, slot.cachedOffset(), operationGetByIdOptimize, true);
+            stubInfo.initGetByIdSelf(codeBlock, structure, slot.cachedOffset());
+            return RetryCacheLater;
+        }
 
-            MacroAssembler::Jump success, fail;
+        PropertyOffset offset = slot.isUnset() ? invalidOffset : slot.cachedOffset();
 
-            emitRestoreScratch(stubJit, needToRestoreScratch, scratchGPR, success, fail, failureCases);
+        if (slot.isUnset() || slot.slotBase() != baseValue) {
+            if (structure->typeInfo().prohibitsPropertyCaching() || structure->isDictionary())
+                return GiveUpOnCache;
             
-            LinkBuffer patchBuffer(*vm, stubJit, codeBlock, JITCompilationCanFail);
-            if (patchBuffer.didFailToAllocate())
+            if (slot.isUnset() && structure->typeInfo().getOwnPropertySlotIsImpureForPropertyAbsence())
                 return GiveUpOnCache;
 
-            linkRestoreScratch(patchBuffer, needToRestoreScratch, stubInfo, success, fail, failureCases);
-
-            stubInfo.stubRoutine = FINALIZE_CODE_FOR_STUB(
-                exec->codeBlock(), patchBuffer,
-                ("GetById array length stub for %s, return point %p",
-                    toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset(
-                        stubInfo.patch.deltaCallToDone).executableAddress()));
-
-            RepatchBuffer repatchBuffer(codeBlock);
-            replaceWithJump(repatchBuffer, stubInfo, stubInfo.stubRoutine->code().code());
-            repatchCall(repatchBuffer, stubInfo.callReturnLocation, operationGetById);
+            if (slot.isUnset()) {
+                conditionSet = generateConditionsForPropertyMiss(
+                    vm, codeBlock, exec, structure, propertyName.impl());
+            } else {
+                conditionSet = generateConditionsForPrototypePropertyHit(
+                    vm, codeBlock, exec, structure, slot.slotBase(),
+                    propertyName.impl());
+            }
+            
+            if (!conditionSet.isValid())
+                return GiveUpOnCache;
 
-            return RetryCacheLater;
+            offset = slot.isUnset() ? invalidOffset : conditionSet.slotBaseCondition().offset();
         }
 
-        // String.length case
-        MacroAssembler::Jump failure = stubJit.branch8(MacroAssembler::NotEqual, MacroAssembler::Address(baseGPR, JSCell::typeInfoTypeOffset()), MacroAssembler::TrustedImm32(StringType));
-
-        stubJit.load32(MacroAssembler::Address(baseGPR, JSString::offsetOfLength()), resultGPR);
-
-#if USE(JSVALUE64)
-        stubJit.or64(AssemblyHelpers::TrustedImm64(TagTypeNumber), resultGPR);
-#elif USE(JSVALUE32_64)
-        stubJit.move(AssemblyHelpers::TrustedImm32(JSValue::Int32Tag), resultTagGPR);
-#endif
-
-        MacroAssembler::Jump success = stubJit.jump();
-
-        LinkBuffer patchBuffer(*vm, stubJit, codeBlock, JITCompilationCanFail);
-        if (patchBuffer.didFailToAllocate())
-            return GiveUpOnCache;
-        
-        patchBuffer.link(success, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone));
-        patchBuffer.link(failure, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
-
-        stubInfo.stubRoutine = FINALIZE_CODE_FOR_STUB(
-            exec->codeBlock(), patchBuffer,
-            ("GetById string length stub for %s, return point %p",
-                toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset(
-                    stubInfo.patch.deltaCallToDone).executableAddress()));
+        JSFunction* getter = nullptr;
+        if (slot.isCacheableGetter())
+            getter = jsDynamicCast<JSFunction*>(slot.getterSetter()->getter());
 
-        RepatchBuffer repatchBuffer(codeBlock);
-        replaceWithJump(repatchBuffer, stubInfo, stubInfo.stubRoutine->code().code());
-        repatchCall(repatchBuffer, stubInfo.callReturnLocation, operationGetById);
+        if (!loadTargetFromProxy && getter && AccessCase::canEmitIntrinsicGetter(getter, structure))
+            newCase = AccessCase::getIntrinsic(vm, codeBlock, getter, slot.cachedOffset(), structure, conditionSet);
+        else {
+            AccessCase::AccessType type;
+            if (slot.isCacheableValue())
+                type = AccessCase::Load;
+            else if (slot.isUnset())
+                type = AccessCase::Miss;
+            else if (slot.isCacheableGetter())
+                type = AccessCase::Getter;
+            else
+                type = AccessCase::CustomGetter;
 
-        return RetryCacheLater;
+            newCase = AccessCase::get(
+                vm, codeBlock, type, offset, structure, conditionSet, loadTargetFromProxy,
+                slot.watchpointSet(), slot.isCacheableCustom() ? slot.customGetter() : nullptr,
+                slot.isCacheableCustom() ? slot.slotBase() : nullptr);
+        }
     }
 
-    // FIXME: Cache property access for immediates.
-    if (!baseValue.isCell())
-        return GiveUpOnCache;
+    MacroAssemblerCodePtr codePtr =
+        stubInfo.addAccessCase(codeBlock, propertyName, WTFMove(newCase));
 
-    if (!slot.isCacheable() && !slot.isUnset())
+    if (!codePtr)
         return GiveUpOnCache;
 
-    JSCell* baseCell = baseValue.asCell();
-    Structure* structure = baseCell->structure(*vm);
-
-    InlineCacheAction action = actionForCell(*vm, baseCell);
-    if (action != AttemptToCache)
-        return action;
-
-    // Optimize self access.
-    if (slot.isCacheableValue()
-        && slot.slotBase() == baseValue
-        && !slot.watchpointSet()
-        && MacroAssembler::isCompactPtrAlignedAddressOffset(maxOffsetRelativeToPatchedStorage(slot.cachedOffset()))) {
-        structure->startWatchingPropertyForReplacements(*vm, slot.cachedOffset());
-        repatchByIdSelfAccess(*vm, codeBlock, stubInfo, structure, propertyName, slot.cachedOffset(), operationGetByIdBuildList, true);
-        stubInfo.initGetByIdSelf(*vm, codeBlock->ownerExecutable(), structure);
-        return RetryCacheLater;
-    }
-
-    repatchCall(codeBlock, stubInfo.callReturnLocation, operationGetByIdBuildList);
+    replaceWithJump(stubInfo, codePtr);
+    
     return RetryCacheLater;
 }
 
@@ -780,113 +332,6 @@ void repatchGetByID(ExecState* exec, JSValue baseValue, const Identifier& proper
         repatchCall(exec->codeBlock(), stubInfo.callReturnLocation, operationGetById);
 }
 
-static void patchJumpToGetByIdStub(CodeBlock* codeBlock, StructureStubInfo& stubInfo, JITStubRoutine* stubRoutine)
-{
-    RELEASE_ASSERT(stubInfo.accessType == access_get_by_id_list);
-    RepatchBuffer repatchBuffer(codeBlock);
-    if (stubInfo.u.getByIdList.list->didSelfPatching()) {
-        repatchBuffer.relink(
-            stubInfo.callReturnLocation.jumpAtOffset(
-                stubInfo.patch.deltaCallToJump),
-            CodeLocationLabel(stubRoutine->code().code()));
-        return;
-    }
-    
-    replaceWithJump(repatchBuffer, stubInfo, stubRoutine->code().code());
-}
-
-static InlineCacheAction tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identifier& ident, const PropertySlot& slot, StructureStubInfo& stubInfo)
-{
-    if (!baseValue.isCell()
-        || (!slot.isCacheable() && !slot.isUnset()))
-        return GiveUpOnCache;
-
-    JSCell* baseCell = baseValue.asCell();
-    bool loadTargetFromProxy = false;
-    if (baseCell->type() == PureForwardingProxyType) {
-        baseValue = jsCast<JSProxy*>(baseCell)->target();
-        baseCell = baseValue.asCell();
-        loadTargetFromProxy = true;
-    }
-
-    VM* vm = &exec->vm();
-    CodeBlock* codeBlock = exec->codeBlock();
-
-    InlineCacheAction action = actionForCell(*vm, baseCell);
-    if (action != AttemptToCache)
-        return action;
-
-    Structure* structure = baseCell->structure(*vm);
-    TypeInfo typeInfo = structure->typeInfo();
-
-    if (stubInfo.patch.spillMode == NeedToSpill) {
-        // We cannot do as much inline caching if the registers were not flushed prior to this GetById. In particular,
-        // non-Value cached properties require planting calls, which requires registers to have been flushed. Thus,
-        // if registers were not flushed, don't do non-Value caching.
-        if (!slot.isCacheableValue() && !slot.isUnset())
-            return GiveUpOnCache;
-    }
-
-    PropertyOffset offset = slot.isUnset() ? invalidOffset : slot.cachedOffset();
-    StructureChain* prototypeChain = 0;
-    size_t count = 0;
-    
-    if (slot.isUnset() || slot.slotBase() != baseValue) {
-        if (typeInfo.prohibitsPropertyCaching() || structure->isDictionary())
-            return GiveUpOnCache;
-
-        if (slot.isUnset())
-            count = normalizePrototypeChain(exec, structure);
-        else
-            count = normalizePrototypeChainForChainAccess(
-                exec, structure, slot.slotBase(), ident, offset);
-        if (count == InvalidPrototypeChain)
-            return GiveUpOnCache;
-        prototypeChain = structure->prototypeChain(exec);
-    }
-    
-    PolymorphicGetByIdList* list = PolymorphicGetByIdList::from(stubInfo);
-    if (list->isFull()) {
-        // We need this extra check because of recursion.
-        return GiveUpOnCache;
-    }
-    
-    RefPtr<JITStubRoutine> stubRoutine;
-    bool result = generateByIdStub(
-        exec, kindFor(slot), ident, customFor(slot), stubInfo, prototypeChain, count, offset, 
-        structure, loadTargetFromProxy, slot.watchpointSet(), 
-        stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone),
-        CodeLocationLabel(list->currentSlowPathTarget(stubInfo)), stubRoutine);
-    if (!result)
-        return GiveUpOnCache;
-    
-    GetByIdAccess::AccessType accessType;
-    if (slot.isCacheableValue())
-        accessType = slot.watchpointSet() ? GetByIdAccess::WatchedStub : GetByIdAccess::SimpleStub;
-    else if (slot.isUnset())
-        accessType = GetByIdAccess::SimpleMiss;
-    else if (slot.isCacheableGetter())
-        accessType = GetByIdAccess::Getter;
-    else
-        accessType = GetByIdAccess::CustomGetter;
-    
-    list->addAccess(GetByIdAccess(
-        *vm, codeBlock->ownerExecutable(), accessType, stubRoutine, structure,
-        prototypeChain, count));
-    
-    patchJumpToGetByIdStub(codeBlock, stubInfo, stubRoutine.get());
-    
-    return list->isFull() ? GiveUpOnCache : RetryCacheLater;
-}
-
-void buildGetByIDList(ExecState* exec, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo& stubInfo)
-{
-    GCSafeConcurrentJITLocker locker(exec->codeBlock()->m_lock, exec->vm().heap);
-    
-    if (tryBuildGetByIDList(exec, baseValue, propertyName, slot, stubInfo) == GiveUpOnCache)
-        repatchCall(exec->codeBlock(), stubInfo.callReturnLocation, operationGetById);
-}
-
 static V_JITOperation_ESsiJJI appropriateGenericPutByIdFunction(const PutPropertySlot &slot, PutKind putKind)
 {
     if (slot.isStrictMode()) {
@@ -899,376 +344,25 @@ static V_JITOperation_ESsiJJI appropriateGenericPutByIdFunction(const PutPropert
     return operationPutByIdNonStrict;
 }
 
-static V_JITOperation_ESsiJJI appropriateListBuildingPutByIdFunction(const PutPropertySlot &slot, PutKind putKind)
+static V_JITOperation_ESsiJJI appropriateOptimizingPutByIdFunction(const PutPropertySlot &slot, PutKind putKind)
 {
     if (slot.isStrictMode()) {
         if (putKind == Direct)
-            return operationPutByIdDirectStrictBuildList;
-        return operationPutByIdStrictBuildList;
+            return operationPutByIdDirectStrictOptimize;
+        return operationPutByIdStrictOptimize;
     }
     if (putKind == Direct)
-        return operationPutByIdDirectNonStrictBuildList;
-    return operationPutByIdNonStrictBuildList;
-}
-
-static bool emitPutReplaceStub(
-    ExecState* exec,
-    const Identifier&,
-    const PutPropertySlot& slot,
-    StructureStubInfo& stubInfo,
-    Structure* structure,
-    CodeLocationLabel failureLabel,
-    RefPtr<JITStubRoutine>& stubRoutine)
-{
-    VM* vm = &exec->vm();
-    GPRReg baseGPR = static_cast<GPRReg>(stubInfo.patch.baseGPR);
-#if USE(JSVALUE32_64)
-    GPRReg valueTagGPR = static_cast<GPRReg>(stubInfo.patch.valueTagGPR);
-#endif
-    GPRReg valueGPR = static_cast<GPRReg>(stubInfo.patch.valueGPR);
-
-    ScratchRegisterAllocator allocator(stubInfo.patch.usedRegisters);
-    allocator.lock(baseGPR);
-#if USE(JSVALUE32_64)
-    allocator.lock(valueTagGPR);
-#endif
-    allocator.lock(valueGPR);
-    
-    GPRReg scratchGPR1 = allocator.allocateScratchGPR();
-
-    CCallHelpers stubJit(vm, exec->codeBlock());
-
-    allocator.preserveReusedRegistersByPushing(stubJit);
-
-    MacroAssembler::Jump badStructure = branchStructure(stubJit,
-        MacroAssembler::NotEqual,
-        MacroAssembler::Address(baseGPR, JSCell::structureIDOffset()),
-        structure);
-
-#if USE(JSVALUE64)
-    if (isInlineOffset(slot.cachedOffset()))
-        stubJit.store64(valueGPR, MacroAssembler::Address(baseGPR, JSObject::offsetOfInlineStorage() + offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue)));
-    else {
-        stubJit.loadPtr(MacroAssembler::Address(baseGPR, JSObject::butterflyOffset()), scratchGPR1);
-        stubJit.store64(valueGPR, MacroAssembler::Address(scratchGPR1, offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue)));
-    }
-#elif USE(JSVALUE32_64)
-    if (isInlineOffset(slot.cachedOffset())) {
-        stubJit.store32(valueGPR, MacroAssembler::Address(baseGPR, JSObject::offsetOfInlineStorage() + offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)));
-        stubJit.store32(valueTagGPR, MacroAssembler::Address(baseGPR, JSObject::offsetOfInlineStorage() + offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)));
-    } else {
-        stubJit.loadPtr(MacroAssembler::Address(baseGPR, JSObject::butterflyOffset()), scratchGPR1);
-        stubJit.store32(valueGPR, MacroAssembler::Address(scratchGPR1, offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)));
-        stubJit.store32(valueTagGPR, MacroAssembler::Address(scratchGPR1, offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)));
-    }
-#endif
-    
-    MacroAssembler::Jump success;
-    MacroAssembler::Jump failure;
-    
-    if (allocator.didReuseRegisters()) {
-        allocator.restoreReusedRegistersByPopping(stubJit);
-        success = stubJit.jump();
-        
-        badStructure.link(&stubJit);
-        allocator.restoreReusedRegistersByPopping(stubJit);
-        failure = stubJit.jump();
-    } else {
-        success = stubJit.jump();
-        failure = badStructure;
-    }
-    
-    LinkBuffer patchBuffer(*vm, stubJit, exec->codeBlock(), JITCompilationCanFail);
-    if (patchBuffer.didFailToAllocate())
-        return false;
-    
-    patchBuffer.link(success, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone));
-    patchBuffer.link(failure, failureLabel);
-            
-    stubRoutine = FINALIZE_CODE_FOR_STUB(
-        exec->codeBlock(), patchBuffer,
-        ("PutById replace stub for %s, return point %p",
-            toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset(
-                stubInfo.patch.deltaCallToDone).executableAddress()));
-    
-    return true;
-}
-
-static Structure* emitPutTransitionStubAndGetOldStructure(ExecState* exec, VM* vm, Structure*& structure, const Identifier& ident, 
-    const PutPropertySlot& slot, StructureStubInfo& stubInfo, PutKind putKind)
-{
-    PropertyName pname(ident);
-    Structure* oldStructure = structure;
-    if (!oldStructure->isObject() || oldStructure->isDictionary() || pname.asIndex() != PropertyName::NotAnIndex)
-        return nullptr;
-
-    PropertyOffset propertyOffset;
-    structure = Structure::addPropertyTransitionToExistingStructureConcurrently(oldStructure, ident.impl(), 0, propertyOffset);
-
-    if (!structure || !structure->isObject() || structure->isDictionary() || !structure->propertyAccessesAreCacheable())
-        return nullptr;
-
-    // Skip optimizing the case where we need a realloc, if we don't have
-    // enough registers to make it happen.
-    if (GPRInfo::numberOfRegisters < 6
-        && oldStructure->outOfLineCapacity() != structure->outOfLineCapacity()
-        && oldStructure->outOfLineCapacity()) {
-        return nullptr;
-    }
-
-    // Skip optimizing the case where we need realloc, and the structure has
-    // indexing storage.
-    // FIXME: We shouldn't skip this! Implement it!
-    // https://bugs.webkit.org/show_bug.cgi?id=130914
-    if (oldStructure->couldHaveIndexingHeader())
-        return nullptr;
-
-    if (normalizePrototypeChain(exec, structure) == InvalidPrototypeChain)
-        return nullptr;
-
-    StructureChain* prototypeChain = structure->prototypeChain(exec);
-
-    // emitPutTransitionStub
-
-    CodeLocationLabel failureLabel = stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase);
-    RefPtr<JITStubRoutine>& stubRoutine = stubInfo.stubRoutine;
-
-    GPRReg baseGPR = static_cast<GPRReg>(stubInfo.patch.baseGPR);
-#if USE(JSVALUE32_64)
-    GPRReg valueTagGPR = static_cast<GPRReg>(stubInfo.patch.valueTagGPR);
-#endif
-    GPRReg valueGPR = static_cast<GPRReg>(stubInfo.patch.valueGPR);
-    
-    ScratchRegisterAllocator allocator(stubInfo.patch.usedRegisters);
-    allocator.lock(baseGPR);
-#if USE(JSVALUE32_64)
-    allocator.lock(valueTagGPR);
-#endif
-    allocator.lock(valueGPR);
-    
-    CCallHelpers stubJit(vm);
-    
-    bool needThirdScratch = false;
-    if (structure->outOfLineCapacity() != oldStructure->outOfLineCapacity()
-        && oldStructure->outOfLineCapacity()) {
-        needThirdScratch = true;
-    }
-
-    GPRReg scratchGPR1 = allocator.allocateScratchGPR();
-    ASSERT(scratchGPR1 != baseGPR);
-    ASSERT(scratchGPR1 != valueGPR);
-    
-    GPRReg scratchGPR2 = allocator.allocateScratchGPR();
-    ASSERT(scratchGPR2 != baseGPR);
-    ASSERT(scratchGPR2 != valueGPR);
-    ASSERT(scratchGPR2 != scratchGPR1);
-
-    GPRReg scratchGPR3;
-    if (needThirdScratch) {
-        scratchGPR3 = allocator.allocateScratchGPR();
-        ASSERT(scratchGPR3 != baseGPR);
-        ASSERT(scratchGPR3 != valueGPR);
-        ASSERT(scratchGPR3 != scratchGPR1);
-        ASSERT(scratchGPR3 != scratchGPR2);
-    } else
-        scratchGPR3 = InvalidGPRReg;
-    
-    allocator.preserveReusedRegistersByPushing(stubJit);
-
-    MacroAssembler::JumpList failureCases;
-            
-    ASSERT(oldStructure->transitionWatchpointSetHasBeenInvalidated());
-    
-    failureCases.append(branchStructure(stubJit,
-        MacroAssembler::NotEqual, 
-        MacroAssembler::Address(baseGPR, JSCell::structureIDOffset()), 
-        oldStructure));
-    
-    addStructureTransitionCheck(
-        oldStructure->storedPrototype(), exec->codeBlock(), stubInfo, stubJit, failureCases,
-        scratchGPR1);
-            
-    if (putKind == NotDirect) {
-        for (WriteBarrier<Structure>* it = prototypeChain->head(); *it; ++it) {
-            addStructureTransitionCheck(
-                (*it)->storedPrototype(), exec->codeBlock(), stubInfo, stubJit, failureCases,
-                scratchGPR1);
-        }
-    }
-
-    MacroAssembler::JumpList slowPath;
-    
-    bool scratchGPR1HasStorage = false;
-    
-    if (structure->outOfLineCapacity() != oldStructure->outOfLineCapacity()) {
-        size_t newSize = structure->outOfLineCapacity() * sizeof(JSValue);
-        CopiedAllocator* copiedAllocator = &vm->heap.storageAllocator();
-        
-        if (!oldStructure->outOfLineCapacity()) {
-            stubJit.loadPtr(&copiedAllocator->m_currentRemaining, scratchGPR1);
-            slowPath.append(stubJit.branchSubPtr(MacroAssembler::Signed, MacroAssembler::TrustedImm32(newSize), scratchGPR1));
-            stubJit.storePtr(scratchGPR1, &copiedAllocator->m_currentRemaining);
-            stubJit.negPtr(scratchGPR1);
-            stubJit.addPtr(MacroAssembler::AbsoluteAddress(&copiedAllocator->m_currentPayloadEnd), scratchGPR1);
-            stubJit.addPtr(MacroAssembler::TrustedImm32(sizeof(JSValue)), scratchGPR1);
-        } else {
-            size_t oldSize = oldStructure->outOfLineCapacity() * sizeof(JSValue);
-            ASSERT(newSize > oldSize);
-            
-            stubJit.loadPtr(MacroAssembler::Address(baseGPR, JSObject::butterflyOffset()), scratchGPR3);
-            stubJit.loadPtr(&copiedAllocator->m_currentRemaining, scratchGPR1);
-            slowPath.append(stubJit.branchSubPtr(MacroAssembler::Signed, MacroAssembler::TrustedImm32(newSize), scratchGPR1));
-            stubJit.storePtr(scratchGPR1, &copiedAllocator->m_currentRemaining);
-            stubJit.negPtr(scratchGPR1);
-            stubJit.addPtr(MacroAssembler::AbsoluteAddress(&copiedAllocator->m_currentPayloadEnd), scratchGPR1);
-            stubJit.addPtr(MacroAssembler::TrustedImm32(sizeof(JSValue)), scratchGPR1);
-            // We have scratchGPR1 = new storage, scratchGPR3 = old storage, scratchGPR2 = available
-            for (size_t offset = 0; offset < oldSize; offset += sizeof(void*)) {
-                stubJit.loadPtr(MacroAssembler::Address(scratchGPR3, -static_cast<ptrdiff_t>(offset + sizeof(JSValue) + sizeof(void*))), scratchGPR2);
-                stubJit.storePtr(scratchGPR2, MacroAssembler::Address(scratchGPR1, -static_cast<ptrdiff_t>(offset + sizeof(JSValue) + sizeof(void*))));
-            }
-        }
-        
-        stubJit.storePtr(scratchGPR1, MacroAssembler::Address(baseGPR, JSObject::butterflyOffset()));
-        scratchGPR1HasStorage = true;
-    }
-
-    ASSERT(oldStructure->typeInfo().type() == structure->typeInfo().type());
-    ASSERT(oldStructure->typeInfo().inlineTypeFlags() == structure->typeInfo().inlineTypeFlags());
-    ASSERT(oldStructure->indexingType() == structure->indexingType());
-#if USE(JSVALUE64)
-    uint32_t val = structure->id();
-#else
-    uint32_t val = reinterpret_cast<uint32_t>(structure->id());
-#endif
-    stubJit.store32(MacroAssembler::TrustedImm32(val), MacroAssembler::Address(baseGPR, JSCell::structureIDOffset()));
-#if USE(JSVALUE64)
-    if (isInlineOffset(slot.cachedOffset()))
-        stubJit.store64(valueGPR, MacroAssembler::Address(baseGPR, JSObject::offsetOfInlineStorage() + offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue)));
-    else {
-        if (!scratchGPR1HasStorage)
-            stubJit.loadPtr(MacroAssembler::Address(baseGPR, JSObject::butterflyOffset()), scratchGPR1);
-        stubJit.store64(valueGPR, MacroAssembler::Address(scratchGPR1, offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue)));
-    }
-#elif USE(JSVALUE32_64)
-    if (isInlineOffset(slot.cachedOffset())) {
-        stubJit.store32(valueGPR, MacroAssembler::Address(baseGPR, JSObject::offsetOfInlineStorage() + offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)));
-        stubJit.store32(valueTagGPR, MacroAssembler::Address(baseGPR, JSObject::offsetOfInlineStorage() + offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)));
-    } else {
-        if (!scratchGPR1HasStorage)
-            stubJit.loadPtr(MacroAssembler::Address(baseGPR, JSObject::butterflyOffset()), scratchGPR1);
-        stubJit.store32(valueGPR, MacroAssembler::Address(scratchGPR1, offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)));
-        stubJit.store32(valueTagGPR, MacroAssembler::Address(scratchGPR1, offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)));
-    }
-#endif
-    
-    ScratchBuffer* scratchBuffer = nullptr;
-
-#if ENABLE(GGC)
-    MacroAssembler::Call callFlushWriteBarrierBuffer;
-    MacroAssembler::Jump ownerIsRememberedOrInEden = stubJit.jumpIfIsRememberedOrInEden(baseGPR);
-    {
-        WriteBarrierBuffer* writeBarrierBuffer = &stubJit.vm()->heap.writeBarrierBuffer();
-        stubJit.move(MacroAssembler::TrustedImmPtr(writeBarrierBuffer), scratchGPR1);
-        stubJit.load32(MacroAssembler::Address(scratchGPR1, WriteBarrierBuffer::currentIndexOffset()), scratchGPR2);
-        MacroAssembler::Jump needToFlush =
-            stubJit.branch32(MacroAssembler::AboveOrEqual, scratchGPR2, MacroAssembler::Address(scratchGPR1, WriteBarrierBuffer::capacityOffset()));
-
-        stubJit.add32(MacroAssembler::TrustedImm32(1), scratchGPR2);
-        stubJit.store32(scratchGPR2, MacroAssembler::Address(scratchGPR1, WriteBarrierBuffer::currentIndexOffset()));
-
-        stubJit.loadPtr(MacroAssembler::Address(scratchGPR1, WriteBarrierBuffer::bufferOffset()), scratchGPR1);
-        // We use an offset of -sizeof(void*) because we already added 1 to scratchGPR2.
-        stubJit.storePtr(baseGPR, MacroAssembler::BaseIndex(scratchGPR1, scratchGPR2, MacroAssembler::ScalePtr, static_cast<int32_t>(-sizeof(void*))));
-
-        MacroAssembler::Jump doneWithBarrier = stubJit.jump();
-        needToFlush.link(&stubJit);
-
-        scratchBuffer = vm->scratchBufferForSize(allocator.desiredScratchBufferSizeForCall());
-        allocator.preserveUsedRegistersToScratchBufferForCall(stubJit, scratchBuffer, scratchGPR2);
-        stubJit.setupArgumentsWithExecState(baseGPR);
-        callFlushWriteBarrierBuffer = stubJit.call();
-        allocator.restoreUsedRegistersFromScratchBufferForCall(stubJit, scratchBuffer, scratchGPR2);
-
-        doneWithBarrier.link(&stubJit);
-    }
-    ownerIsRememberedOrInEden.link(&stubJit);
-#endif
-
-    MacroAssembler::Jump success;
-    MacroAssembler::Jump failure;
-            
-    if (allocator.didReuseRegisters()) {
-        allocator.restoreReusedRegistersByPopping(stubJit);
-        success = stubJit.jump();
-
-        failureCases.link(&stubJit);
-        allocator.restoreReusedRegistersByPopping(stubJit);
-        failure = stubJit.jump();
-    } else
-        success = stubJit.jump();
-    
-    MacroAssembler::Call operationCall;
-    MacroAssembler::Jump successInSlowPath;
-    
-    if (structure->outOfLineCapacity() != oldStructure->outOfLineCapacity()) {
-        slowPath.link(&stubJit);
-        
-        allocator.restoreReusedRegistersByPopping(stubJit);
-        if (!scratchBuffer)
-            scratchBuffer = vm->scratchBufferForSize(allocator.desiredScratchBufferSizeForCall());
-        allocator.preserveUsedRegistersToScratchBufferForCall(stubJit, scratchBuffer, scratchGPR1);
-#if USE(JSVALUE64)
-        stubJit.setupArgumentsWithExecState(baseGPR, MacroAssembler::TrustedImmPtr(structure), MacroAssembler::TrustedImm32(slot.cachedOffset()), valueGPR);
-#else
-        stubJit.setupArgumentsWithExecState(baseGPR, MacroAssembler::TrustedImmPtr(structure), MacroAssembler::TrustedImm32(slot.cachedOffset()), valueGPR, valueTagGPR);
-#endif
-        operationCall = stubJit.call();
-        allocator.restoreUsedRegistersFromScratchBufferForCall(stubJit, scratchBuffer, scratchGPR1);
-        successInSlowPath = stubJit.jump();
-    }
-    
-    LinkBuffer patchBuffer(*vm, stubJit, exec->codeBlock(), JITCompilationCanFail);
-    if (patchBuffer.didFailToAllocate())
-        return nullptr;
-    
-    patchBuffer.link(success, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone));
-    if (allocator.didReuseRegisters())
-        patchBuffer.link(failure, failureLabel);
-    else
-        patchBuffer.link(failureCases, failureLabel);
-#if ENABLE(GGC)
-    patchBuffer.link(callFlushWriteBarrierBuffer, operationFlushWriteBarrierBuffer);
-#endif
-    if (structure->outOfLineCapacity() != oldStructure->outOfLineCapacity()) {
-        patchBuffer.link(operationCall, operationReallocateStorageAndFinishPut);
-        patchBuffer.link(successInSlowPath, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone));
-    }
-    
-    stubRoutine =
-        createJITStubRoutine(
-            FINALIZE_CODE_FOR(
-                exec->codeBlock(), patchBuffer,
-                ("PutById %stransition stub (%p -> %p) for %s, return point %p",
-                    structure->outOfLineCapacity() != oldStructure->outOfLineCapacity() ? "reallocating " : "",
-                    oldStructure, structure,
-                    toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset(
-                        stubInfo.patch.deltaCallToDone).executableAddress())),
-            *vm,
-            exec->codeBlock()->ownerExecutable(),
-            structure->outOfLineCapacity() != oldStructure->outOfLineCapacity(),
-            structure);
-
-    return oldStructure;
+        return operationPutByIdDirectNonStrictOptimize;
+    return operationPutByIdNonStrictOptimize;
 }
 
 static InlineCacheAction tryCachePutByID(ExecState* exec, JSValue baseValue, Structure* structure, const Identifier& ident, const PutPropertySlot& slot, StructureStubInfo& stubInfo, PutKind putKind)
 {
-    if (Options::forceICFailure())
+    if (forceICFailure(exec))
         return GiveUpOnCache;
     
     CodeBlock* codeBlock = exec->codeBlock();
-    VM* vm = &exec->vm();
+    VM& vm = exec->vm();
 
     if (!baseValue.isCell())
         return GiveUpOnCache;
@@ -1279,194 +373,107 @@ static InlineCacheAction tryCachePutByID(ExecState* exec, JSValue baseValue, Str
     if (!structure->propertyAccessesAreCacheable())
         return GiveUpOnCache;
 
-    // Optimize self access.
-    if (slot.base() == baseValue && slot.isCacheablePut()) {
-        if (slot.type() == PutPropertySlot::NewProperty) {
+    std::unique_ptr<AccessCase> newCase;
 
-            Structure* oldStructure = emitPutTransitionStubAndGetOldStructure(exec, vm, structure, ident, slot, stubInfo, putKind);
-            if (!oldStructure)
-                return GiveUpOnCache;
-            
-            StructureChain* prototypeChain = structure->prototypeChain(exec);
-            
-            RepatchBuffer repatchBuffer(codeBlock);
-            repatchBuffer.relink(
-                stubInfo.callReturnLocation.jumpAtOffset(
-                    stubInfo.patch.deltaCallToJump),
-                CodeLocationLabel(stubInfo.stubRoutine->code().code()));
-            repatchCall(repatchBuffer, stubInfo.callReturnLocation, appropriateListBuildingPutByIdFunction(slot, putKind));
-            
-            stubInfo.initPutByIdTransition(*vm, codeBlock->ownerExecutable(), oldStructure, structure, prototypeChain, putKind == Direct);
-            
-            return RetryCacheLater;
-        }
-
-        if (!MacroAssembler::isPtrAlignedAddressOffset(offsetRelativeToPatchedStorage(slot.cachedOffset())))
-            return GiveUpOnCache;
-
-        structure->didCachePropertyReplacement(*vm, slot.cachedOffset());
-        repatchByIdSelfAccess(*vm, codeBlock, stubInfo, structure, ident, slot.cachedOffset(), appropriateListBuildingPutByIdFunction(slot, putKind), false);
-        stubInfo.initPutByIdReplace(*vm, codeBlock->ownerExecutable(), structure);
-        return RetryCacheLater;
-    }
+    if (slot.base() == baseValue && slot.isCacheablePut()) {
+        if (slot.type() == PutPropertySlot::ExistingProperty) {
+            structure->didCachePropertyReplacement(vm, slot.cachedOffset());
+        
+            if (stubInfo.cacheType == CacheType::Unset
+                && isInlineOffset(slot.cachedOffset())
+                && MacroAssembler::isPtrAlignedAddressOffset(maxOffsetRelativeToBase(slot.cachedOffset()))
+                && !structure->needImpurePropertyWatchpoint()
+                && !structure->inferredTypeFor(ident.impl())) {
+
+                repatchByIdSelfAccess(
+                    codeBlock, stubInfo, structure, slot.cachedOffset(),
+                    appropriateOptimizingPutByIdFunction(slot, putKind), false);
+                stubInfo.initPutByIdReplace(codeBlock, structure, slot.cachedOffset());
+                return RetryCacheLater;
+            }
 
-    if ((slot.isCacheableCustom() || slot.isCacheableSetter())
-        && stubInfo.patch.spillMode == DontSpill) {
-        RefPtr<JITStubRoutine> stubRoutine;
+            newCase = AccessCase::replace(vm, codeBlock, structure, slot.cachedOffset());
+        } else {
+            ASSERT(slot.type() == PutPropertySlot::NewProperty);
 
-        StructureChain* prototypeChain = 0;
-        PropertyOffset offset = slot.cachedOffset();
-        size_t count = 0;
-        if (baseValue != slot.base()) {
-            count = normalizePrototypeChainForChainAccess(exec, structure, slot.base(), ident, offset);
-            if (count == InvalidPrototypeChain)
+            if (!structure->isObject() || structure->isDictionary())
                 return GiveUpOnCache;
-            prototypeChain = structure->prototypeChain(exec);
-        }
-        PolymorphicPutByIdList* list;
-        list = PolymorphicPutByIdList::from(putKind, stubInfo);
-
-        bool result = generateByIdStub(
-            exec, kindFor(slot), ident, customFor(slot), stubInfo, prototypeChain, count,
-            offset, structure, false, nullptr,
-            stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone),
-            stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase),
-            stubRoutine);
-        if (!result)
-            return GiveUpOnCache;
-        
-        list->addAccess(PutByIdAccess::setter(
-            *vm, codeBlock->ownerExecutable(),
-            slot.isCacheableSetter() ? PutByIdAccess::Setter : PutByIdAccess::CustomSetter,
-            structure, prototypeChain, count, slot.customSetter(), stubRoutine));
-
-        RepatchBuffer repatchBuffer(codeBlock);
-        repatchBuffer.relink(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), CodeLocationLabel(stubRoutine->code().code()));
-        repatchCall(repatchBuffer, stubInfo.callReturnLocation, appropriateListBuildingPutByIdFunction(slot, putKind));
-        RELEASE_ASSERT(!list->isFull());
-        return RetryCacheLater;
-    }
-
-    return GiveUpOnCache;
-}
 
-void repatchPutByID(ExecState* exec, JSValue baseValue, Structure* structure, const Identifier& propertyName, const PutPropertySlot& slot, StructureStubInfo& stubInfo, PutKind putKind)
-{
-    GCSafeConcurrentJITLocker locker(exec->codeBlock()->m_lock, exec->vm().heap);
-    
-    if (tryCachePutByID(exec, baseValue, structure, propertyName, slot, stubInfo, putKind) == GiveUpOnCache)
-        repatchCall(exec->codeBlock(), stubInfo.callReturnLocation, appropriateGenericPutByIdFunction(slot, putKind));
-}
-
-static InlineCacheAction tryBuildPutByIdList(ExecState* exec, JSValue baseValue, Structure* structure, const Identifier& propertyName, const PutPropertySlot& slot, StructureStubInfo& stubInfo, PutKind putKind)
-{
-    CodeBlock* codeBlock = exec->codeBlock();
-    VM* vm = &exec->vm();
-
-    if (!baseValue.isCell())
-        return GiveUpOnCache;
-
-    if (!slot.isCacheablePut() && !slot.isCacheableCustom() && !slot.isCacheableSetter())
-        return GiveUpOnCache;
-
-    if (!structure->propertyAccessesAreCacheable())
-        return GiveUpOnCache;
-
-    // Optimize self access.
-    if (slot.base() == baseValue && slot.isCacheablePut()) {
-        PolymorphicPutByIdList* list;
-        RefPtr<JITStubRoutine> stubRoutine;
-        
-        if (slot.type() == PutPropertySlot::NewProperty) {
-            list = PolymorphicPutByIdList::from(putKind, stubInfo);
-            if (list->isFull())
-                return GiveUpOnCache; // Will get here due to recursion.
-
-            Structure* oldStructure = emitPutTransitionStubAndGetOldStructure(exec, vm, structure, propertyName, slot, stubInfo, putKind);
-
-            if (!oldStructure) 
+            PropertyOffset offset;
+            Structure* newStructure =
+                Structure::addPropertyTransitionToExistingStructureConcurrently(
+                    structure, ident.impl(), 0, offset);
+            if (!newStructure || !newStructure->propertyAccessesAreCacheable())
                 return GiveUpOnCache;
 
-            StructureChain* prototypeChain = structure->prototypeChain(exec);
-            stubRoutine = stubInfo.stubRoutine;
-            list->addAccess(
-                PutByIdAccess::transition(
-                    *vm, codeBlock->ownerExecutable(),
-                    oldStructure, structure, prototypeChain,
-                    stubRoutine));
+            ASSERT(newStructure->previousID() == structure);
+            ASSERT(!newStructure->isDictionary());
+            ASSERT(newStructure->isObject());
+            
+            ObjectPropertyConditionSet conditionSet;
+            if (putKind == NotDirect) {
+                conditionSet =
+                    generateConditionsForPropertySetterMiss(
+                        vm, codeBlock, exec, newStructure, ident.impl());
+                if (!conditionSet.isValid())
+                    return GiveUpOnCache;
+            }
 
-        } else {
-            list = PolymorphicPutByIdList::from(putKind, stubInfo);
-            if (list->isFull())
-                return GiveUpOnCache; // Will get here due to recursion.
-            
-            structure->didCachePropertyReplacement(*vm, slot.cachedOffset());
-            
-            // We're now committed to creating the stub. Mogrify the meta-data accordingly.
-            bool result = emitPutReplaceStub(
-                exec, propertyName, slot, stubInfo, 
-                structure, CodeLocationLabel(list->currentSlowPathTarget()), stubRoutine);
-            if (!result)
-                return GiveUpOnCache;
-            
-            list->addAccess(
-                PutByIdAccess::replace(
-                    *vm, codeBlock->ownerExecutable(),
-                    structure, stubRoutine));
+            newCase = AccessCase::transition(vm, codeBlock, structure, newStructure, offset, conditionSet);
         }
-        RepatchBuffer repatchBuffer(codeBlock);
-        repatchBuffer.relink(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), CodeLocationLabel(stubRoutine->code().code()));
-        if (list->isFull())
-            repatchCall(repatchBuffer, stubInfo.callReturnLocation, appropriateGenericPutByIdFunction(slot, putKind));
-
-        return RetryCacheLater;
-    }
+    } else if (slot.isCacheableCustom() || slot.isCacheableSetter()) {
+        if (slot.isCacheableCustom()) {
+            ObjectPropertyConditionSet conditionSet;
+
+            if (slot.base() != baseValue) {
+                conditionSet =
+                    generateConditionsForPrototypePropertyHitCustom(
+                        vm, codeBlock, exec, structure, slot.base(), ident.impl());
+                if (!conditionSet.isValid())
+                    return GiveUpOnCache;
+            }
 
-    if ((slot.isCacheableCustom() || slot.isCacheableSetter())
-        && stubInfo.patch.spillMode == DontSpill) {
-        RefPtr<JITStubRoutine> stubRoutine;
-        StructureChain* prototypeChain = 0;
-        PropertyOffset offset = slot.cachedOffset();
-        size_t count = 0;
-        if (baseValue != slot.base()) {
-            count = normalizePrototypeChainForChainAccess(exec, structure, slot.base(), propertyName, offset);
-            if (count == InvalidPrototypeChain)
-                return GiveUpOnCache;
-            prototypeChain = structure->prototypeChain(exec);
+            newCase = AccessCase::setter(
+                vm, codeBlock, AccessCase::CustomSetter, structure, invalidOffset, conditionSet,
+                slot.customSetter(), slot.base());
+        } else {
+            ObjectPropertyConditionSet conditionSet;
+            PropertyOffset offset;
+
+            if (slot.base() != baseValue) {
+                conditionSet =
+                    generateConditionsForPrototypePropertyHit(
+                        vm, codeBlock, exec, structure, slot.base(), ident.impl());
+                if (!conditionSet.isValid())
+                    return GiveUpOnCache;
+                offset = conditionSet.slotBaseCondition().offset();
+            } else
+                offset = slot.cachedOffset();
+
+            newCase = AccessCase::setter(
+                vm, codeBlock, AccessCase::Setter, structure, offset, conditionSet);
         }
-        
-        PolymorphicPutByIdList* list;
-        list = PolymorphicPutByIdList::from(putKind, stubInfo);
-
-        bool result = generateByIdStub(
-            exec, kindFor(slot), propertyName, customFor(slot), stubInfo, prototypeChain, count,
-            offset, structure, false, nullptr,
-            stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone),
-            CodeLocationLabel(list->currentSlowPathTarget()),
-            stubRoutine);
-        if (!result)
-            return GiveUpOnCache;
-        
-        list->addAccess(PutByIdAccess::setter(
-            *vm, codeBlock->ownerExecutable(),
-            slot.isCacheableSetter() ? PutByIdAccess::Setter : PutByIdAccess::CustomSetter,
-            structure, prototypeChain, count, slot.customSetter(), stubRoutine));
+    }
 
-        RepatchBuffer repatchBuffer(codeBlock);
-        repatchBuffer.relink(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), CodeLocationLabel(stubRoutine->code().code()));
-        if (list->isFull())
-            repatchCall(repatchBuffer, stubInfo.callReturnLocation, appropriateGenericPutByIdFunction(slot, putKind));
+    MacroAssemblerCodePtr codePtr = stubInfo.addAccessCase(codeBlock, ident, WTFMove(newCase));
+    
+    if (!codePtr)
+        return GiveUpOnCache;
 
-        return RetryCacheLater;
-    }
-    return GiveUpOnCache;
+    resetPutByIDCheckAndLoad(stubInfo);
+    MacroAssembler::repatchJump(
+        stubInfo.callReturnLocation.jumpAtOffset(
+            stubInfo.patch.deltaCallToJump),
+        CodeLocationLabel(codePtr));
+    
+    return RetryCacheLater;
 }
 
-void buildPutByIdList(ExecState* exec, JSValue baseValue, Structure* structure, const Identifier& propertyName, const PutPropertySlot& slot, StructureStubInfo& stubInfo, PutKind putKind)
+void repatchPutByID(ExecState* exec, JSValue baseValue, Structure* structure, const Identifier& propertyName, const PutPropertySlot& slot, StructureStubInfo& stubInfo, PutKind putKind)
 {
     GCSafeConcurrentJITLocker locker(exec->codeBlock()->m_lock, exec->vm().heap);
     
-    if (tryBuildPutByIdList(exec, baseValue, structure, propertyName, slot, stubInfo, putKind) == GiveUpOnCache)
+    if (tryCachePutByID(exec, baseValue, structure, propertyName, slot, stubInfo, putKind) == GiveUpOnCache)
         repatchCall(exec->codeBlock(), stubInfo.callReturnLocation, appropriateGenericPutByIdFunction(slot, putKind));
 }
 
@@ -1474,10 +481,10 @@ static InlineCacheAction tryRepatchIn(
     ExecState* exec, JSCell* base, const Identifier& ident, bool wasFound,
     const PropertySlot& slot, StructureStubInfo& stubInfo)
 {
-    if (Options::forceICFailure())
+    if (forceICFailure(exec))
         return GiveUpOnCache;
     
-    if (!base->structure()->propertyAccessesAreCacheable())
+    if (!base->structure()->propertyAccessesAreCacheable() || (!wasFound && !base->structure()->propertyAccessesAreCacheableForAbsence()))
         return GiveUpOnCache;
     
     if (wasFound) {
@@ -1486,112 +493,34 @@ static InlineCacheAction tryRepatchIn(
     }
     
     CodeBlock* codeBlock = exec->codeBlock();
-    VM* vm = &exec->vm();
-    Structure* structure = base->structure(*vm);
-    
-    PropertyOffset offsetIgnored;
-    JSValue foundSlotBase = wasFound ? slot.slotBase() : JSValue();
-    size_t count = !foundSlotBase || foundSlotBase != base ? 
-        normalizePrototypeChainForChainAccess(exec, structure, foundSlotBase, ident, offsetIgnored) : 0;
-    if (count == InvalidPrototypeChain)
-        return GiveUpOnCache;
-    
-    PolymorphicAccessStructureList* polymorphicStructureList;
-    int listIndex;
-    
-    CodeLocationLabel successLabel = stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone);
-    CodeLocationLabel slowCaseLabel;
-    
-    if (stubInfo.accessType == access_unset) {
-        polymorphicStructureList = new PolymorphicAccessStructureList();
-        stubInfo.initInList(polymorphicStructureList, 0);
-        slowCaseLabel = stubInfo.callReturnLocation.labelAtOffset(
-            stubInfo.patch.deltaCallToSlowCase);
-        listIndex = 0;
-    } else {
-        RELEASE_ASSERT(stubInfo.accessType == access_in_list);
-        polymorphicStructureList = stubInfo.u.inList.structureList;
-        listIndex = stubInfo.u.inList.listSize;
-        slowCaseLabel = CodeLocationLabel(polymorphicStructureList->list[listIndex - 1].stubRoutine->code().code());
-        
-        if (listIndex == POLYMORPHIC_LIST_CACHE_SIZE)
-            return GiveUpOnCache;
-    }
-    
-    StructureChain* chain = structure->prototypeChain(exec);
-    RefPtr<JITStubRoutine> stubRoutine;
+    VM& vm = exec->vm();
+    Structure* structure = base->structure(vm);
     
-    {
-        GPRReg baseGPR = static_cast<GPRReg>(stubInfo.patch.baseGPR);
-        GPRReg resultGPR = static_cast<GPRReg>(stubInfo.patch.valueGPR);
-        GPRReg scratchGPR = TempRegisterSet(stubInfo.patch.usedRegisters).getFreeGPR();
-        
-        CCallHelpers stubJit(vm);
-        
-        bool needToRestoreScratch;
-        if (scratchGPR == InvalidGPRReg) {
-            scratchGPR = AssemblyHelpers::selectScratchGPR(baseGPR, resultGPR);
-            stubJit.pushToSave(scratchGPR);
-            needToRestoreScratch = true;
-        } else
-            needToRestoreScratch = false;
-        
-        MacroAssembler::JumpList failureCases;
-        failureCases.append(branchStructure(stubJit,
-            MacroAssembler::NotEqual,
-            MacroAssembler::Address(baseGPR, JSCell::structureIDOffset()),
-            structure));
-
-        CodeBlock* codeBlock = exec->codeBlock();
-        if (structure->typeInfo().newImpurePropertyFiresWatchpoints())
-            vm->registerWatchpointForImpureProperty(ident, stubInfo.addWatchpoint(codeBlock));
-
-        if (slot.watchpointSet())
-            slot.watchpointSet()->add(stubInfo.addWatchpoint(codeBlock));
-
-        Structure* currStructure = structure;
-        WriteBarrier<Structure>* it = chain->head();
-        for (unsigned i = 0; i < count; ++i, ++it) {
-            JSObject* prototype = asObject(currStructure->prototypeForLookup(exec));
-            Structure* protoStructure = prototype->structure();
-            addStructureTransitionCheck(
-                prototype, protoStructure, exec->codeBlock(), stubInfo, stubJit,
-                failureCases, scratchGPR);
-            if (protoStructure->typeInfo().newImpurePropertyFiresWatchpoints())
-                vm->registerWatchpointForImpureProperty(ident, stubInfo.addWatchpoint(codeBlock));
-            currStructure = it->get();
+    ObjectPropertyConditionSet conditionSet;
+    if (wasFound) {
+        if (slot.slotBase() != base) {
+            conditionSet = generateConditionsForPrototypePropertyHit(
+                vm, codeBlock, exec, structure, slot.slotBase(), ident.impl());
         }
-        
-#if USE(JSVALUE64)
-        stubJit.move(MacroAssembler::TrustedImm64(JSValue::encode(jsBoolean(wasFound))), resultGPR);
-#else
-        stubJit.move(MacroAssembler::TrustedImm32(wasFound), resultGPR);
-#endif
-        
-        MacroAssembler::Jump success, fail;
-        
-        emitRestoreScratch(stubJit, needToRestoreScratch, scratchGPR, success, fail, failureCases);
-        
-        LinkBuffer patchBuffer(*vm, stubJit, exec->codeBlock(), JITCompilationCanFail);
-        if (patchBuffer.didFailToAllocate())
-            return GiveUpOnCache;
-        
-        linkRestoreScratch(patchBuffer, needToRestoreScratch, success, fail, failureCases, successLabel, slowCaseLabel);
-        
-        stubRoutine = FINALIZE_CODE_FOR_STUB(
-            exec->codeBlock(), patchBuffer,
-            ("In (found = %s) stub for %s, return point %p",
-                wasFound ? "yes" : "no", toCString(*exec->codeBlock()).data(),
-                successLabel.executableAddress()));
+    } else {
+        conditionSet = generateConditionsForPropertyMiss(
+            vm, codeBlock, exec, structure, ident.impl());
     }
+    if (!conditionSet.isValid())
+        return GiveUpOnCache;
+
+    std::unique_ptr<AccessCase> newCase = AccessCase::in(
+        vm, codeBlock, wasFound ? AccessCase::InHit : AccessCase::InMiss, structure, conditionSet);
+
+    MacroAssemblerCodePtr codePtr = stubInfo.addAccessCase(codeBlock, ident, WTFMove(newCase));
+    if (!codePtr)
+        return GiveUpOnCache;
+
+    MacroAssembler::repatchJump(
+        stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump),
+        CodeLocationLabel(codePtr));
     
-    polymorphicStructureList->list[listIndex].set(*vm, codeBlock->ownerExecutable(), stubRoutine, structure, true);
-    stubInfo.u.inList.listSize++;
-    
-    RepatchBuffer repatchBuffer(codeBlock);
-    repatchBuffer.relink(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), CodeLocationLabel(stubRoutine->code().code()));
-    
-    return listIndex < (POLYMORPHIC_LIST_CACHE_SIZE - 1) ? RetryCacheLater : GiveUpOnCache;
+    return RetryCacheLater;
 }
 
 void repatchIn(
@@ -1602,106 +531,94 @@ void repatchIn(
         repatchCall(exec->codeBlock(), stubInfo.callReturnLocation, operationIn);
 }
 
-static void linkSlowFor(
-    RepatchBuffer& repatchBuffer, VM* vm, CallLinkInfo& callLinkInfo, ThunkGenerator generator)
+static void linkSlowFor(VM*, CallLinkInfo& callLinkInfo, MacroAssemblerCodeRef codeRef)
+{
+    MacroAssembler::repatchNearCall(callLinkInfo.callReturnLocation(), CodeLocationLabel(codeRef.code()));
+}
+
+static void linkSlowFor(VM* vm, CallLinkInfo& callLinkInfo, ThunkGenerator generator)
 {
-    repatchBuffer.relink(
-        callLinkInfo.callReturnLocation, vm->getCTIStub(generator).code());
+    linkSlowFor(vm, callLinkInfo, vm->getCTIStub(generator));
 }
 
-static void linkSlowFor(
-    RepatchBuffer& repatchBuffer, VM* vm, CallLinkInfo& callLinkInfo,
-    CodeSpecializationKind kind, RegisterPreservationMode registers)
+static void linkSlowFor(VM* vm, CallLinkInfo& callLinkInfo)
 {
-    linkSlowFor(repatchBuffer, vm, callLinkInfo, virtualThunkGeneratorFor(kind, registers));
+    MacroAssemblerCodeRef virtualThunk = virtualThunkFor(vm, callLinkInfo);
+    linkSlowFor(vm, callLinkInfo, virtualThunk);
+    callLinkInfo.setSlowStub(createJITStubRoutine(virtualThunk, *vm, nullptr, true));
 }
 
 void linkFor(
     ExecState* exec, CallLinkInfo& callLinkInfo, CodeBlock* calleeCodeBlock,
-    JSFunction* callee, MacroAssemblerCodePtr codePtr, CodeSpecializationKind kind,
-    RegisterPreservationMode registers)
+    JSFunction* callee, MacroAssemblerCodePtr codePtr)
 {
-    ASSERT(!callLinkInfo.stub);
+    ASSERT(!callLinkInfo.stub());
     
     CodeBlock* callerCodeBlock = exec->callerFrame()->codeBlock();
 
     VM* vm = callerCodeBlock->vm();
     
-    RepatchBuffer repatchBuffer(callerCodeBlock);
-    
     ASSERT(!callLinkInfo.isLinked());
-    callLinkInfo.callee.set(exec->callerFrame()->vm(), callLinkInfo.hotPathBegin, callerCodeBlock->ownerExecutable(), callee);
-    callLinkInfo.lastSeenCallee.set(exec->callerFrame()->vm(), callerCodeBlock->ownerExecutable(), callee);
-    if (shouldShowDisassemblyFor(callerCodeBlock))
-        dataLog("Linking call in ", *callerCodeBlock, " at ", callLinkInfo.codeOrigin, " to ", pointerDump(calleeCodeBlock), ", entrypoint at ", codePtr, "\n");
-    repatchBuffer.relink(callLinkInfo.hotPathOther, codePtr);
+    callLinkInfo.setCallee(exec->callerFrame()->vm(), callLinkInfo.hotPathBegin(), callerCodeBlock, callee);
+    callLinkInfo.setLastSeenCallee(exec->callerFrame()->vm(), callerCodeBlock, callee);
+    if (shouldDumpDisassemblyFor(callerCodeBlock))
+        dataLog("Linking call in ", *callerCodeBlock, " at ", callLinkInfo.codeOrigin(), " to ", pointerDump(calleeCodeBlock), ", entrypoint at ", codePtr, "\n");
+    MacroAssembler::repatchNearCall(callLinkInfo.hotPathOther(), CodeLocationLabel(codePtr));
     
     if (calleeCodeBlock)
         calleeCodeBlock->linkIncomingCall(exec->callerFrame(), &callLinkInfo);
     
-    if (kind == CodeForCall) {
-        linkSlowFor(
-            repatchBuffer, vm, callLinkInfo, linkPolymorphicCallThunkGeneratorFor(registers));
+    if (callLinkInfo.specializationKind() == CodeForCall && callLinkInfo.allowStubs()) {
+        linkSlowFor(vm, callLinkInfo, linkPolymorphicCallThunkGenerator);
         return;
     }
     
-    ASSERT(kind == CodeForConstruct);
-    linkSlowFor(repatchBuffer, vm, callLinkInfo, CodeForConstruct, registers);
+    linkSlowFor(vm, callLinkInfo);
 }
 
 void linkSlowFor(
-    ExecState* exec, CallLinkInfo& callLinkInfo, CodeSpecializationKind kind,
-    RegisterPreservationMode registers)
+    ExecState* exec, CallLinkInfo& callLinkInfo)
 {
     CodeBlock* callerCodeBlock = exec->callerFrame()->codeBlock();
     VM* vm = callerCodeBlock->vm();
     
-    RepatchBuffer repatchBuffer(callerCodeBlock);
-    
-    linkSlowFor(repatchBuffer, vm, callLinkInfo, kind, registers);
+    linkSlowFor(vm, callLinkInfo);
 }
 
-static void revertCall(
-    RepatchBuffer& repatchBuffer, VM* vm, CallLinkInfo& callLinkInfo, ThunkGenerator generator)
+static void revertCall(VM* vm, CallLinkInfo& callLinkInfo, MacroAssemblerCodeRef codeRef)
 {
-    repatchBuffer.revertJumpReplacementToBranchPtrWithPatch(
-        RepatchBuffer::startOfBranchPtrWithPatchOnRegister(callLinkInfo.hotPathBegin),
-        static_cast<MacroAssembler::RegisterID>(callLinkInfo.calleeGPR), 0);
-    linkSlowFor(repatchBuffer, vm, callLinkInfo, generator);
-    callLinkInfo.hasSeenShouldRepatch = false;
-    callLinkInfo.callee.clear();
-    callLinkInfo.stub.clear();
+    MacroAssembler::revertJumpReplacementToBranchPtrWithPatch(
+        MacroAssembler::startOfBranchPtrWithPatchOnRegister(callLinkInfo.hotPathBegin()),
+        static_cast<MacroAssembler::RegisterID>(callLinkInfo.calleeGPR()), 0);
+    linkSlowFor(vm, callLinkInfo, codeRef);
+    callLinkInfo.clearSeen();
+    callLinkInfo.clearCallee();
+    callLinkInfo.clearStub();
+    callLinkInfo.clearSlowStub();
     if (callLinkInfo.isOnList())
         callLinkInfo.remove();
 }
 
-void unlinkFor(
-    RepatchBuffer& repatchBuffer, CallLinkInfo& callLinkInfo,
-    CodeSpecializationKind kind, RegisterPreservationMode registers)
+void unlinkFor(VM& vm, CallLinkInfo& callLinkInfo)
 {
-    if (Options::showDisassembly())
-        dataLog("Unlinking call from ", callLinkInfo.callReturnLocation, " in request from ", pointerDump(repatchBuffer.codeBlock()), "\n");
+    if (Options::dumpDisassembly())
+        dataLog("Unlinking call from ", callLinkInfo.callReturnLocation(), "\n");
     
-    revertCall(
-        repatchBuffer, repatchBuffer.codeBlock()->vm(), callLinkInfo,
-        linkThunkGeneratorFor(kind, registers));
+    revertCall(&vm, callLinkInfo, vm.getCTIStub(linkCallThunkGenerator));
 }
 
 void linkVirtualFor(
-    ExecState* exec, CallLinkInfo& callLinkInfo,
-    CodeSpecializationKind kind, RegisterPreservationMode registers)
+    ExecState* exec, CallLinkInfo& callLinkInfo)
 {
-    // FIXME: We could generate a virtual call stub here. This would lead to faster virtual calls
-    // by eliminating the branch prediction bottleneck inside the shared virtual call thunk.
-    
     CodeBlock* callerCodeBlock = exec->callerFrame()->codeBlock();
     VM* vm = callerCodeBlock->vm();
-    
-    if (shouldShowDisassemblyFor(callerCodeBlock))
+
+    if (shouldDumpDisassemblyFor(callerCodeBlock))
         dataLog("Linking virtual call at ", *callerCodeBlock, " ", exec->callerFrame()->codeOrigin(), "\n");
     
-    RepatchBuffer repatchBuffer(callerCodeBlock);
-    revertCall(repatchBuffer, vm, callLinkInfo, virtualThunkGeneratorFor(kind, registers));
+    MacroAssemblerCodeRef virtualThunk = virtualThunkFor(vm, callLinkInfo);
+    revertCall(vm, callLinkInfo, virtualThunk);
+    callLinkInfo.setSlowStub(createJITStubRoutine(virtualThunk, *vm, nullptr, true));
 }
 
 namespace {
@@ -1712,13 +629,14 @@ struct CallToCodePtr {
 } // annonymous namespace
 
 void linkPolymorphicCall(
-    ExecState* exec, CallLinkInfo& callLinkInfo, CallVariant newVariant,
-    RegisterPreservationMode registers)
+    ExecState* exec, CallLinkInfo& callLinkInfo, CallVariant newVariant)
 {
+    RELEASE_ASSERT(callLinkInfo.allowStubs());
+    
     // Currently we can't do anything for non-function callees.
     // https://bugs.webkit.org/show_bug.cgi?id=140685
     if (!newVariant || !newVariant.executable()) {
-        linkVirtualFor(exec, callLinkInfo, CodeForCall, registers);
+        linkVirtualFor(exec, callLinkInfo);
         return;
     }
     
@@ -1726,9 +644,9 @@ void linkPolymorphicCall(
     VM* vm = callerCodeBlock->vm();
     
     CallVariantList list;
-    if (PolymorphicCallStubRoutine* stub = callLinkInfo.stub.get())
+    if (PolymorphicCallStubRoutine* stub = callLinkInfo.stub())
         list = stub->variants();
-    else if (JSFunction* oldCallee = callLinkInfo.callee.get())
+    else if (JSFunction* oldCallee = callLinkInfo.callee())
         list = CallVariantList{ CallVariant(oldCallee) };
     
     list = variantListWithVariant(list, newVariant);
@@ -1745,6 +663,9 @@ void linkPolymorphicCall(
         }
     }
     
+    if (isClosureCall)
+        callLinkInfo.setHasSeenClosure();
+    
     Vector<PolymorphicCallCase> callCases;
     
     // Figure out what our cases are.
@@ -1753,12 +674,17 @@ void linkPolymorphicCall(
         if (variant.executable()->isHostFunction())
             codeBlock = nullptr;
         else {
-            codeBlock = jsCast<FunctionExecutable*>(variant.executable())->codeBlockForCall();
-            
-            // If we cannot handle a callee, assume that it's better for this whole thing to be a
-            // virtual call.
-            if (exec->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()) || callLinkInfo.callType == CallLinkInfo::CallVarargs || callLinkInfo.callType == CallLinkInfo::ConstructVarargs) {
-                linkVirtualFor(exec, callLinkInfo, CodeForCall, registers);
+            ExecutableBase* executable = variant.executable();
+#if ENABLE(WEBASSEMBLY)
+            if (executable->isWebAssemblyExecutable())
+                codeBlock = jsCast<WebAssemblyExecutable*>(executable)->codeBlockForCall();
+            else
+#endif
+                codeBlock = jsCast<FunctionExecutable*>(executable)->codeBlockForCall();
+            // If we cannot handle a callee, either because we don't have a CodeBlock or because arity mismatch,
+            // assume that it's better for this whole thing to be a virtual call.
+            if (!codeBlock || exec->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()) || callLinkInfo.isVarargs()) {
+                linkVirtualFor(exec, callLinkInfo);
                 return;
             }
         }
@@ -1773,36 +699,42 @@ void linkPolymorphicCall(
     else
         maxPolymorphicCallVariantListSize = Options::maxPolymorphicCallVariantListSize();
     if (list.size() > maxPolymorphicCallVariantListSize) {
-        linkVirtualFor(exec, callLinkInfo, CodeForCall, registers);
+        linkVirtualFor(exec, callLinkInfo);
         return;
     }
     
-    GPRReg calleeGPR = static_cast<GPRReg>(callLinkInfo.calleeGPR);
+    GPRReg calleeGPR = static_cast<GPRReg>(callLinkInfo.calleeGPR());
     
     CCallHelpers stubJit(vm, callerCodeBlock);
     
     CCallHelpers::JumpList slowPath;
     
-    ptrdiff_t offsetToFrame = -sizeof(CallerFrameAndPC);
-
-    if (!ASSERT_DISABLED) {
-        CCallHelpers::Jump okArgumentCount = stubJit.branch32(
-            CCallHelpers::Below, CCallHelpers::Address(CCallHelpers::stackPointerRegister, static_cast<ptrdiff_t>(sizeof(Register) * JSStack::ArgumentCount) + offsetToFrame + PayloadOffset), CCallHelpers::TrustedImm32(10000000));
-        stubJit.abortWithReason(RepatchInsaneArgumentCount);
-        okArgumentCount.link(&stubJit);
+    std::unique_ptr<CallFrameShuffler> frameShuffler;
+    if (callLinkInfo.frameShuffleData()) {
+        ASSERT(callLinkInfo.isTailCall());
+        frameShuffler = std::make_unique<CallFrameShuffler>(stubJit, *callLinkInfo.frameShuffleData());
+#if USE(JSVALUE32_64)
+        // We would have already checked that the callee is a cell, and we can
+        // use the additional register this buys us.
+        frameShuffler->assumeCalleeIsCell();
+#endif
+        frameShuffler->lockGPR(calleeGPR);
     }
-    
-    GPRReg scratch = AssemblyHelpers::selectScratchGPR(calleeGPR);
     GPRReg comparisonValueGPR;
     
     if (isClosureCall) {
-        // Verify that we have a function and stash the executable in scratch.
+        GPRReg scratchGPR;
+        if (frameShuffler)
+            scratchGPR = frameShuffler->acquireGPR();
+        else
+            scratchGPR = AssemblyHelpers::selectScratchGPR(calleeGPR);
+        // Verify that we have a function and stash the executable in scratchGPR.
 
 #if USE(JSVALUE64)
-        // We can safely clobber everything except the calleeGPR. We can't rely on tagMaskRegister
-        // being set. So we do this the hard way.
-        stubJit.move(MacroAssembler::TrustedImm64(TagMask), scratch);
-        slowPath.append(stubJit.branchTest64(CCallHelpers::NonZero, calleeGPR, scratch));
+        // We can't rely on tagMaskRegister being set, so we do this the hard
+        // way.
+        stubJit.move(MacroAssembler::TrustedImm64(TagMask), scratchGPR);
+        slowPath.append(stubJit.branchTest64(CCallHelpers::NonZero, calleeGPR, scratchGPR));
 #else
         // We would have already checked that the callee is a cell.
 #endif
@@ -1815,9 +747,9 @@ void linkPolymorphicCall(
     
         stubJit.loadPtr(
             CCallHelpers::Address(calleeGPR, JSFunction::offsetOfExecutable()),
-            scratch);
+            scratchGPR);
         
-        comparisonValueGPR = scratch;
+        comparisonValueGPR = scratchGPR;
     } else
         comparisonValueGPR = calleeGPR;
     
@@ -1828,21 +760,47 @@ void linkPolymorphicCall(
     if (callerCodeBlock->jitType() != JITCode::topTierJIT())
         fastCounts = std::make_unique<uint32_t[]>(callCases.size());
     
-    for (size_t i = callCases.size(); i--;) {
+    for (size_t i = 0; i < callCases.size(); ++i) {
         if (fastCounts)
             fastCounts[i] = 0;
         
         CallVariant variant = callCases[i].variant();
+        int64_t newCaseValue;
         if (isClosureCall)
-            caseValues[i] = bitwise_cast<intptr_t>(variant.executable());
+            newCaseValue = bitwise_cast<intptr_t>(variant.executable());
         else
-            caseValues[i] = bitwise_cast<intptr_t>(variant.function());
+            newCaseValue = bitwise_cast<intptr_t>(variant.function());
+        
+        if (!ASSERT_DISABLED) {
+            for (size_t j = 0; j < i; ++j) {
+                if (caseValues[j] != newCaseValue)
+                    continue;
+
+                dataLog("ERROR: Attempt to add duplicate case value.\n");
+                dataLog("Existing case values: ");
+                CommaPrinter comma;
+                for (size_t k = 0; k < i; ++k)
+                    dataLog(comma, caseValues[k]);
+                dataLog("\n");
+                dataLog("Attempting to add: ", newCaseValue, "\n");
+                dataLog("Variant list: ", listDump(callCases), "\n");
+                RELEASE_ASSERT_NOT_REACHED();
+            }
+        }
+        
+        caseValues[i] = newCaseValue;
     }
     
-    GPRReg fastCountsBaseGPR =
-        AssemblyHelpers::selectScratchGPR(calleeGPR, comparisonValueGPR, GPRInfo::regT3);
+    GPRReg fastCountsBaseGPR;
+    if (frameShuffler)
+        fastCountsBaseGPR = frameShuffler->acquireGPR();
+    else {
+        fastCountsBaseGPR =
+            AssemblyHelpers::selectScratchGPR(calleeGPR, comparisonValueGPR, GPRInfo::regT3);
+    }
     stubJit.move(CCallHelpers::TrustedImmPtr(fastCounts.get()), fastCountsBaseGPR);
-    
+    if (!frameShuffler && callLinkInfo.isTailCall())
+        stubJit.emitRestoreCalleeSaves();
     BinarySwitch binarySwitch(comparisonValueGPR, caseValues, BinarySwitch::IntPtr);
     CCallHelpers::JumpList done;
     while (binarySwitch.advance(stubJit)) {
@@ -1852,34 +810,53 @@ void linkPolymorphicCall(
         
         ASSERT(variant.executable()->hasJITCodeForCall());
         MacroAssemblerCodePtr codePtr =
-            variant.executable()->generatedJITCodeForCall()->addressForCall(
-                *vm, variant.executable(), ArityCheckNotRequired, registers);
+            variant.executable()->generatedJITCodeForCall()->addressForCall(ArityCheckNotRequired);
         
         if (fastCounts) {
             stubJit.add32(
                 CCallHelpers::TrustedImm32(1),
                 CCallHelpers::Address(fastCountsBaseGPR, caseIndex * sizeof(uint32_t)));
         }
-        calls[caseIndex].call = stubJit.nearCall();
+        if (frameShuffler) {
+            CallFrameShuffler(stubJit, frameShuffler->snapshot()).prepareForTailCall();
+            calls[caseIndex].call = stubJit.nearTailCall();
+        } else if (callLinkInfo.isTailCall()) {
+            stubJit.prepareForTailCallSlow();
+            calls[caseIndex].call = stubJit.nearTailCall();
+        } else
+            calls[caseIndex].call = stubJit.nearCall();
         calls[caseIndex].codePtr = codePtr;
         done.append(stubJit.jump());
     }
     
     slowPath.link(&stubJit);
     binarySwitch.fallThrough().link(&stubJit);
-    stubJit.move(calleeGPR, GPRInfo::regT0);
+
+    if (frameShuffler) {
+        frameShuffler->releaseGPR(calleeGPR);
+        frameShuffler->releaseGPR(comparisonValueGPR);
+        frameShuffler->releaseGPR(fastCountsBaseGPR);
+#if USE(JSVALUE32_64)
+        frameShuffler->setCalleeJSValueRegs(JSValueRegs(GPRInfo::regT1, GPRInfo::regT0));
+#else
+        frameShuffler->setCalleeJSValueRegs(JSValueRegs(GPRInfo::regT0));
+#endif
+        frameShuffler->prepareForSlowPath();
+    } else {
+        stubJit.move(calleeGPR, GPRInfo::regT0);
 #if USE(JSVALUE32_64)
-    stubJit.move(CCallHelpers::TrustedImm32(JSValue::CellTag), GPRInfo::regT1);
+        stubJit.move(CCallHelpers::TrustedImm32(JSValue::CellTag), GPRInfo::regT1);
 #endif
+    }
     stubJit.move(CCallHelpers::TrustedImmPtr(&callLinkInfo), GPRInfo::regT2);
-    stubJit.move(CCallHelpers::TrustedImmPtr(callLinkInfo.callReturnLocation.executableAddress()), GPRInfo::regT4);
+    stubJit.move(CCallHelpers::TrustedImmPtr(callLinkInfo.callReturnLocation().executableAddress()), GPRInfo::regT4);
     
     stubJit.restoreReturnAddressBeforeReturn(GPRInfo::regT4);
     AssemblyHelpers::Jump slow = stubJit.jump();
         
     LinkBuffer patchBuffer(*vm, stubJit, callerCodeBlock, JITCompilationCanFail);
     if (patchBuffer.didFailToAllocate()) {
-        linkVirtualFor(exec, callLinkInfo, CodeForCall, registers);
+        linkVirtualFor(exec, callLinkInfo);
         return;
     }
     
@@ -1889,31 +866,31 @@ void linkPolymorphicCall(
             callToCodePtr.call, FunctionPtr(callToCodePtr.codePtr.executableAddress()));
     }
     if (JITCode::isOptimizingJIT(callerCodeBlock->jitType()))
-        patchBuffer.link(done, callLinkInfo.callReturnLocation.labelAtOffset(0));
+        patchBuffer.link(done, callLinkInfo.callReturnLocation().labelAtOffset(0));
     else
-        patchBuffer.link(done, callLinkInfo.hotPathOther.labelAtOffset(0));
-    patchBuffer.link(slow, CodeLocationLabel(vm->getCTIStub(linkPolymorphicCallThunkGeneratorFor(registers)).code()));
+        patchBuffer.link(done, callLinkInfo.hotPathOther().labelAtOffset(0));
+    patchBuffer.link(slow, CodeLocationLabel(vm->getCTIStub(linkPolymorphicCallThunkGenerator).code()));
     
     RefPtr<PolymorphicCallStubRoutine> stubRoutine = adoptRef(new PolymorphicCallStubRoutine(
         FINALIZE_CODE_FOR(
             callerCodeBlock, patchBuffer,
             ("Polymorphic call stub for %s, return point %p, targets %s",
-                toCString(*callerCodeBlock).data(), callLinkInfo.callReturnLocation.labelAtOffset(0).executableAddress(),
+                toCString(*callerCodeBlock).data(), callLinkInfo.callReturnLocation().labelAtOffset(0).executableAddress(),
                 toCString(listDump(callCases)).data())),
-        *vm, callerCodeBlock->ownerExecutable(), exec->callerFrame(), callLinkInfo, callCases,
-        WTF::move(fastCounts)));
+        *vm, callerCodeBlock, exec->callerFrame(), callLinkInfo, callCases,
+        WTFMove(fastCounts)));
     
-    RepatchBuffer repatchBuffer(callerCodeBlock);
-    
-    repatchBuffer.replaceWithJump(
-        RepatchBuffer::startOfBranchPtrWithPatchOnRegister(callLinkInfo.hotPathBegin),
+    MacroAssembler::replaceWithJump(
+        MacroAssembler::startOfBranchPtrWithPatchOnRegister(callLinkInfo.hotPathBegin()),
         CodeLocationLabel(stubRoutine->code().code()));
-    // This is weird. The original slow path should no longer be reachable.
-    linkSlowFor(repatchBuffer, vm, callLinkInfo, CodeForCall, registers);
+    // The original slow path is unreachable on 64-bits, but still
+    // reachable on 32-bits since a non-cell callee will always
+    // trigger the slow path
+    linkSlowFor(vm, callLinkInfo);
     
     // If there had been a previous stub routine, that one will die as soon as the GC runs and sees
     // that it's no longer on stack.
-    callLinkInfo.stub = stubRoutine.release();
+    callLinkInfo.setStub(stubRoutine.release());
     
     // The call link info no longer has a call cache apart from the jump to the polymorphic call
     // stub.
@@ -1921,65 +898,35 @@ void linkPolymorphicCall(
         callLinkInfo.remove();
 }
 
-void resetGetByID(RepatchBuffer& repatchBuffer, StructureStubInfo& stubInfo)
+void resetGetByID(CodeBlock* codeBlock, StructureStubInfo& stubInfo)
 {
-    repatchCall(repatchBuffer, stubInfo.callReturnLocation, operationGetByIdOptimize);
-    CodeLocationDataLabel32 structureLabel = stubInfo.callReturnLocation.dataLabel32AtOffset(-(intptr_t)stubInfo.patch.deltaCheckImmToCall);
-    if (MacroAssembler::canJumpReplacePatchableBranch32WithPatch()) {
-        repatchBuffer.revertJumpReplacementToPatchableBranch32WithPatch(
-            RepatchBuffer::startOfPatchableBranch32WithPatchOnAddress(structureLabel),
-            MacroAssembler::Address(
-                static_cast<MacroAssembler::RegisterID>(stubInfo.patch.baseGPR),
-                JSCell::structureIDOffset()),
-            static_cast<int32_t>(unusedPointer));
-    }
-    repatchBuffer.repatch(structureLabel, static_cast<int32_t>(unusedPointer));
-#if USE(JSVALUE64)
-    repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToLoadOrStore), 0);
-#else
-    repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToTagLoadOrStore), 0);
-    repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabelCompactAtOffset(stubInfo.patch.deltaCallToPayloadLoadOrStore), 0);
-#endif
-    repatchBuffer.relink(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
+    repatchCall(codeBlock, stubInfo.callReturnLocation, operationGetByIdOptimize);
+    resetGetByIDCheckAndLoad(stubInfo);
+    MacroAssembler::repatchJump(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
 }
 
-void resetPutByID(RepatchBuffer& repatchBuffer, StructureStubInfo& stubInfo)
+void resetPutByID(CodeBlock* codeBlock, StructureStubInfo& stubInfo)
 {
-    V_JITOperation_ESsiJJI unoptimizedFunction = bitwise_cast<V_JITOperation_ESsiJJI>(readCallTarget(repatchBuffer, stubInfo.callReturnLocation).executableAddress());
+    V_JITOperation_ESsiJJI unoptimizedFunction = bitwise_cast<V_JITOperation_ESsiJJI>(readCallTarget(codeBlock, stubInfo.callReturnLocation).executableAddress());
     V_JITOperation_ESsiJJI optimizedFunction;
-    if (unoptimizedFunction == operationPutByIdStrict || unoptimizedFunction == operationPutByIdStrictBuildList)
+    if (unoptimizedFunction == operationPutByIdStrict || unoptimizedFunction == operationPutByIdStrictOptimize)
         optimizedFunction = operationPutByIdStrictOptimize;
-    else if (unoptimizedFunction == operationPutByIdNonStrict || unoptimizedFunction == operationPutByIdNonStrictBuildList)
+    else if (unoptimizedFunction == operationPutByIdNonStrict || unoptimizedFunction == operationPutByIdNonStrictOptimize)
         optimizedFunction = operationPutByIdNonStrictOptimize;
-    else if (unoptimizedFunction == operationPutByIdDirectStrict || unoptimizedFunction == operationPutByIdDirectStrictBuildList)
+    else if (unoptimizedFunction == operationPutByIdDirectStrict || unoptimizedFunction == operationPutByIdDirectStrictOptimize)
         optimizedFunction = operationPutByIdDirectStrictOptimize;
     else {
-        ASSERT(unoptimizedFunction == operationPutByIdDirectNonStrict || unoptimizedFunction == operationPutByIdDirectNonStrictBuildList);
+        ASSERT(unoptimizedFunction == operationPutByIdDirectNonStrict || unoptimizedFunction == operationPutByIdDirectNonStrictOptimize);
         optimizedFunction = operationPutByIdDirectNonStrictOptimize;
     }
-    repatchCall(repatchBuffer, stubInfo.callReturnLocation, optimizedFunction);
-    CodeLocationDataLabel32 structureLabel = stubInfo.callReturnLocation.dataLabel32AtOffset(-(intptr_t)stubInfo.patch.deltaCheckImmToCall);
-    if (MacroAssembler::canJumpReplacePatchableBranch32WithPatch()) {
-        repatchBuffer.revertJumpReplacementToPatchableBranch32WithPatch(
-            RepatchBuffer::startOfPatchableBranch32WithPatchOnAddress(structureLabel),
-            MacroAssembler::Address(
-                static_cast<MacroAssembler::RegisterID>(stubInfo.patch.baseGPR),
-                JSCell::structureIDOffset()),
-            static_cast<int32_t>(unusedPointer));
-    }
-    repatchBuffer.repatch(structureLabel, static_cast<int32_t>(unusedPointer));
-#if USE(JSVALUE64)
-    repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToLoadOrStore), 0);
-#else
-    repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToTagLoadOrStore), 0);
-    repatchBuffer.repatch(stubInfo.callReturnLocation.dataLabel32AtOffset(stubInfo.patch.deltaCallToPayloadLoadOrStore), 0);
-#endif
-    repatchBuffer.relink(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
+    repatchCall(codeBlock, stubInfo.callReturnLocation, optimizedFunction);
+    resetPutByIDCheckAndLoad(stubInfo);
+    MacroAssembler::repatchJump(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
 }
 
-void resetIn(RepatchBuffer& repatchBuffer, StructureStubInfo& stubInfo)
+void resetIn(CodeBlock*, StructureStubInfo& stubInfo)
 {
-    repatchBuffer.relink(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
+    MacroAssembler::repatchJump(stubInfo.callReturnLocation.jumpAtOffset(stubInfo.patch.deltaCallToJump), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
 }
 
 } // namespace JSC