Changeset 220298 in webkit


Ignore:
Timestamp:
Aug 4, 2017 3:03:54 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

Move DFG::OSRExitCompiler methods into DFG::OSRExit [step 1].
https://bugs.webkit.org/show_bug.cgi?id=175208
<rdar://problem/33732402>

Reviewed by Saam Barati.

This will minimize the code diff and make it easier to review the patch for
https://bugs.webkit.org/show_bug.cgi?id=175144 later. We'll do this patch in 3
steps:

  1. Do the code changes to move methods into OSRExit.
  2. Copy the 64-bit and common methods into DFGOSRExit.cpp, and delete the unused DFGOSRExitCompiler files.
  3. Merge the 32-bit OSRExitCompiler methods into the 64-bit version, and delete DFGOSRExitCompiler32_64.cpp.

Splitting this refactoring into these 3 steps also makes it easier to review this
patch and understand what is being changed.

  • dfg/DFGOSRExit.h:
  • dfg/DFGOSRExitCompiler.cpp:

(JSC::DFG::OSRExit::emitRestoreArguments):
(JSC::DFG::OSRExit::compileOSRExit):
(JSC::DFG::OSRExitCompiler::emitRestoreArguments): Deleted.
(): Deleted.

  • dfg/DFGOSRExitCompiler.h:

(JSC::DFG::OSRExitCompiler::OSRExitCompiler): Deleted.
(): Deleted.

  • dfg/DFGOSRExitCompiler32_64.cpp:

(JSC::DFG::OSRExit::compileExit):
(JSC::DFG::OSRExitCompiler::compileExit): Deleted.

  • dfg/DFGOSRExitCompiler64.cpp:

(JSC::DFG::OSRExit::compileExit):
(JSC::DFG::OSRExitCompiler::compileExit): Deleted.

  • dfg/DFGThunks.cpp:

(JSC::DFG::osrExitGenerationThunkGenerator):

Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r220294 r220298  
     12017-08-04  Mark Lam  <mark.lam@apple.com>
     2
     3        Move DFG::OSRExitCompiler methods into DFG::OSRExit [step 1].
     4        https://bugs.webkit.org/show_bug.cgi?id=175208
     5        <rdar://problem/33732402>
     6
     7        Reviewed by Saam Barati.
     8
     9        This will minimize the code diff and make it easier to review the patch for
     10        https://bugs.webkit.org/show_bug.cgi?id=175144 later.  We'll do this patch in 3
     11        steps:
     12
     13        1. Do the code changes to move methods into OSRExit.
     14        2. Copy the 64-bit and common methods into DFGOSRExit.cpp, and delete the unused DFGOSRExitCompiler files.
     15        3. Merge the 32-bit OSRExitCompiler methods into the 64-bit version, and delete DFGOSRExitCompiler32_64.cpp.
     16
     17        Splitting this refactoring into these 3 steps also makes it easier to review this
     18        patch and understand what is being changed.
     19
     20        * dfg/DFGOSRExit.h:
     21        * dfg/DFGOSRExitCompiler.cpp:
     22        (JSC::DFG::OSRExit::emitRestoreArguments):
     23        (JSC::DFG::OSRExit::compileOSRExit):
     24        (JSC::DFG::OSRExitCompiler::emitRestoreArguments): Deleted.
     25        (): Deleted.
     26        * dfg/DFGOSRExitCompiler.h:
     27        (JSC::DFG::OSRExitCompiler::OSRExitCompiler): Deleted.
     28        (): Deleted.
     29        * dfg/DFGOSRExitCompiler32_64.cpp:
     30        (JSC::DFG::OSRExit::compileExit):
     31        (JSC::DFG::OSRExitCompiler::compileExit): Deleted.
     32        * dfg/DFGOSRExitCompiler64.cpp:
     33        (JSC::DFG::OSRExit::compileExit):
     34        (JSC::DFG::OSRExitCompiler::compileExit): Deleted.
     35        * dfg/DFGThunks.cpp:
     36        (JSC::DFG::osrExitGenerationThunkGenerator):
     37
    1382017-08-04  Devin Rousso  <drousso@apple.com>
    239
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExit.h

    r218794 r220298  
    11/*
    2  * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3232#include "MacroAssembler.h"
    3333#include "MethodOfGettingAValueProfile.h"
     34#include "Operands.h"
     35#include "ValueRecovery.h"
    3436
    35 namespace JSC { namespace DFG {
     37namespace JSC {
     38
     39class CCallHelpers;
     40
     41namespace DFG {
    3642
    3743class SpeculativeJIT;
     
    9399    OSRExit(ExitKind, JSValueSource, MethodOfGettingAValueProfile, SpeculativeJIT*, unsigned streamIndex, unsigned recoveryIndex = UINT_MAX);
    94100
     101    static void JIT_OPERATION compileOSRExit(ExecState*) WTF_INTERNAL;
     102
    95103    unsigned m_patchableCodeOffset { 0 };
    96104   
     
    112120        OSRExitBase::considerAddingAsFrequentExitSite(profiledCodeBlock, ExitFromDFG);
    113121    }
     122
     123private:
     124    static void compileExit(CCallHelpers&, VM&, const OSRExit&, const Operands<ValueRecovery>&, SpeculationRecovery*);
     125    static void emitRestoreArguments(CCallHelpers&, const Operands<ValueRecovery>&);
    114126};
    115127
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler.cpp

    r218794 r220298  
    11/*
    2  * Copyright (C) 2011-2013, 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4141namespace JSC { namespace DFG {
    4242
    43 void OSRExitCompiler::emitRestoreArguments(const Operands<ValueRecovery>& operands)
     43void OSRExit::emitRestoreArguments(CCallHelpers& jit, const Operands<ValueRecovery>& operands)
    4444{
    4545    HashMap<MinifiedID, int> alreadyAllocatedArguments; // Maps phantom arguments node ID to operand.
     
    5656        if (iter != alreadyAllocatedArguments.end()) {
    5757            JSValueRegs regs = JSValueRegs::withTwoAvailableRegs(GPRInfo::regT0, GPRInfo::regT1);
    58             m_jit.loadValue(CCallHelpers::addressFor(iter->value), regs);
    59             m_jit.storeValue(regs, CCallHelpers::addressFor(operand));
     58            jit.loadValue(CCallHelpers::addressFor(iter->value), regs);
     59            jit.storeValue(regs, CCallHelpers::addressFor(operand));
    6060            continue;
    6161        }
    6262       
    6363        InlineCallFrame* inlineCallFrame =
    64             m_jit.codeBlock()->jitCode()->dfg()->minifiedDFG.at(id)->inlineCallFrame();
     64            jit.codeBlock()->jitCode()->dfg()->minifiedDFG.at(id)->inlineCallFrame();
    6565
    6666        int stackOffset;
     
    7171       
    7272        if (!inlineCallFrame || inlineCallFrame->isClosureCall) {
    73             m_jit.loadPtr(
     73            jit.loadPtr(
    7474                AssemblyHelpers::addressFor(stackOffset + CallFrameSlot::callee),
    7575                GPRInfo::regT0);
    7676        } else {
    77             m_jit.move(
     77            jit.move(
    7878                AssemblyHelpers::TrustedImmPtr(inlineCallFrame->calleeRecovery.constant().asCell()),
    7979                GPRInfo::regT0);
     
    8181       
    8282        if (!inlineCallFrame || inlineCallFrame->isVarargs()) {
    83             m_jit.load32(
     83            jit.load32(
    8484                AssemblyHelpers::payloadFor(stackOffset + CallFrameSlot::argumentCount),
    8585                GPRInfo::regT1);
    8686        } else {
    87             m_jit.move(
     87            jit.move(
    8888                AssemblyHelpers::TrustedImm32(inlineCallFrame->arguments.size()),
    8989                GPRInfo::regT1);
    9090        }
    9191       
    92         m_jit.setupArgumentsWithExecState(
     92        jit.setupArgumentsWithExecState(
    9393            AssemblyHelpers::TrustedImmPtr(inlineCallFrame), GPRInfo::regT0, GPRInfo::regT1);
    9494        switch (recovery.technique()) {
    9595        case DirectArgumentsThatWereNotCreated:
    96             m_jit.move(AssemblyHelpers::TrustedImmPtr(bitwise_cast<void*>(operationCreateDirectArgumentsDuringExit)), GPRInfo::nonArgGPR0);
     96            jit.move(AssemblyHelpers::TrustedImmPtr(bitwise_cast<void*>(operationCreateDirectArgumentsDuringExit)), GPRInfo::nonArgGPR0);
    9797            break;
    9898        case ClonedArgumentsThatWereNotCreated:
    99             m_jit.move(AssemblyHelpers::TrustedImmPtr(bitwise_cast<void*>(operationCreateClonedArgumentsDuringExit)), GPRInfo::nonArgGPR0);
     99            jit.move(AssemblyHelpers::TrustedImmPtr(bitwise_cast<void*>(operationCreateClonedArgumentsDuringExit)), GPRInfo::nonArgGPR0);
    100100            break;
    101101        default:
     
    103103            break;
    104104        }
    105         m_jit.call(GPRInfo::nonArgGPR0);
    106         m_jit.storeCell(GPRInfo::returnValueGPR, AssemblyHelpers::addressFor(operand));
     105        jit.call(GPRInfo::nonArgGPR0);
     106        jit.storeCell(GPRInfo::returnValueGPR, AssemblyHelpers::addressFor(operand));
    107107       
    108108        alreadyAllocatedArguments.add(id, operand);
     
    110110}
    111111
    112 extern "C" {
    113 
    114 void compileOSRExit(ExecState* exec)
     112void OSRExit::compileOSRExit(ExecState* exec)
    115113{
    116114    VM* vm = &exec->vm();
     
    149147    {
    150148        CCallHelpers jit(codeBlock);
    151         OSRExitCompiler exitCompiler(jit);
    152149
    153150        if (exit.m_kind == GenericUnwind) {
     
    173170        }
    174171
    175         exitCompiler.compileExit(*vm, exit, operands, recovery);
    176        
     172        compileExit(jit, *vm, exit, operands, recovery);
     173
    177174        LinkBuffer patchBuffer(jit, codeBlock);
    178175        exit.m_code = FINALIZE_CODE_IF(
     
    190187}
    191188
    192 } // extern "C"
    193 
    194189} } // namespace JSC::DFG
    195190
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler.h

    r218794 r220298  
    11/*
    2  * Copyright (C) 2011, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3232#include "Operands.h"
    3333
    34 namespace JSC {
    35 
    36 class ExecState;
    37 
    38 namespace DFG {
    39 
    40 class OSRExitCompiler {
    41 public:
    42     OSRExitCompiler(CCallHelpers& jit)
    43         : m_jit(jit)
    44     {
    45     }
    46    
    47     void compileExit(VM&, const OSRExit&, const Operands<ValueRecovery>&, SpeculationRecovery*);
    48 
    49 private:
    50     void emitRestoreArguments(const Operands<ValueRecovery>&);
    51    
    52     CCallHelpers& m_jit;
    53 };
    54 
    55 extern "C" {
    56 void JIT_OPERATION compileOSRExit(ExecState*) WTF_INTERNAL;
    57 }
    58 
    59 } } // namespace JSC::DFG
    60 
    6134#endif // ENABLE(DFG_JIT)
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler32_64.cpp

    r214531 r220298  
    11/*
    2  * Copyright (C) 2011, 2013-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737namespace JSC { namespace DFG {
    3838
    39 void OSRExitCompiler::compileExit(VM& vm, const OSRExit& exit, const Operands<ValueRecovery>& operands, SpeculationRecovery* recovery)
     39void OSRExit::compileExit(CCallHelpers& jit, VM& vm, const OSRExit& exit, const Operands<ValueRecovery>& operands, SpeculationRecovery* recovery)
    4040{
    4141    // Pro-forma stuff.
    4242    if (Options::printEachOSRExit()) {
    4343        SpeculationFailureDebugInfo* debugInfo = new SpeculationFailureDebugInfo;
    44         debugInfo->codeBlock = m_jit.codeBlock();
     44        debugInfo->codeBlock = jit.codeBlock();
    4545        debugInfo->kind = exit.m_kind;
    4646        debugInfo->bytecodeOffset = exit.m_codeOrigin.bytecodeIndex;
    4747       
    48         m_jit.debugCall(vm, debugOperationPrintSpeculationFailure, debugInfo);
     48        jit.debugCall(vm, debugOperationPrintSpeculationFailure, debugInfo);
    4949    }
    5050
     
    5555        switch (recovery->type()) {
    5656        case SpeculativeAdd:
    57             m_jit.sub32(recovery->src(), recovery->dest());
     57            jit.sub32(recovery->src(), recovery->dest());
    5858            break;
    5959
    6060        case SpeculativeAddImmediate:
    61             m_jit.sub32(AssemblyHelpers::Imm32(recovery->immediate()), recovery->dest());
     61            jit.sub32(AssemblyHelpers::Imm32(recovery->immediate()), recovery->dest());
    6262            break;
    6363           
     
    8888           
    8989            CodeOrigin codeOrigin = exit.m_codeOriginForExitProfile;
    90             if (ArrayProfile* arrayProfile = m_jit.baselineCodeBlockFor(codeOrigin)->getArrayProfile(codeOrigin.bytecodeIndex)) {
     90            if (ArrayProfile* arrayProfile = jit.baselineCodeBlockFor(codeOrigin)->getArrayProfile(codeOrigin.bytecodeIndex)) {
    9191                GPRReg usedRegister1;
    9292                GPRReg usedRegister2;
     
    107107                scratch2 = AssemblyHelpers::selectScratchGPR(usedRegister1, usedRegister2, scratch1);
    108108               
    109                 m_jit.push(scratch1);
    110                 m_jit.push(scratch2);
     109                jit.push(scratch1);
     110                jit.push(scratch2);
    111111               
    112112                GPRReg value;
    113113                if (exit.m_jsValueSource.isAddress()) {
    114114                    value = scratch1;
    115                     m_jit.loadPtr(AssemblyHelpers::Address(exit.m_jsValueSource.asAddress()), value);
     115                    jit.loadPtr(AssemblyHelpers::Address(exit.m_jsValueSource.asAddress()), value);
    116116                } else
    117117                    value = exit.m_jsValueSource.payloadGPR();
    118118               
    119                 m_jit.loadPtr(AssemblyHelpers::Address(value, JSCell::structureIDOffset()), scratch1);
    120                 m_jit.storePtr(scratch1, arrayProfile->addressOfLastSeenStructureID());
    121                 m_jit.load8(AssemblyHelpers::Address(scratch1, Structure::indexingTypeIncludingHistoryOffset()), scratch1);
    122                 m_jit.move(AssemblyHelpers::TrustedImm32(1), scratch2);
    123                 m_jit.lshift32(scratch1, scratch2);
    124                 m_jit.or32(scratch2, AssemblyHelpers::AbsoluteAddress(arrayProfile->addressOfArrayModes()));
    125                
    126                 m_jit.pop(scratch2);
    127                 m_jit.pop(scratch1);
     119                jit.loadPtr(AssemblyHelpers::Address(value, JSCell::structureIDOffset()), scratch1);
     120                jit.storePtr(scratch1, arrayProfile->addressOfLastSeenStructureID());
     121                jit.load8(AssemblyHelpers::Address(scratch1, Structure::indexingTypeIncludingHistoryOffset()), scratch1);
     122                jit.move(AssemblyHelpers::TrustedImm32(1), scratch2);
     123                jit.lshift32(scratch1, scratch2);
     124                jit.or32(scratch2, AssemblyHelpers::AbsoluteAddress(arrayProfile->addressOfArrayModes()));
     125               
     126                jit.pop(scratch2);
     127                jit.pop(scratch1);
    128128            }
    129129        }
     
    134134                GPRReg scratchPayload = AssemblyHelpers::selectScratchGPR(exit.m_jsValueSource.base());
    135135                GPRReg scratchTag = AssemblyHelpers::selectScratchGPR(exit.m_jsValueSource.base(), scratchPayload);
    136                 m_jit.pushToSave(scratchPayload);
    137                 m_jit.pushToSave(scratchTag);
     136                jit.pushToSave(scratchPayload);
     137                jit.pushToSave(scratchTag);
    138138
    139139                JSValueRegs scratch(scratchTag, scratchPayload);
    140140               
    141                 m_jit.loadValue(exit.m_jsValueSource.asAddress(), scratch);
    142                 profile.emitReportValue(m_jit, scratch);
    143                
    144                 m_jit.popToRestore(scratchTag);
    145                 m_jit.popToRestore(scratchPayload);
     141                jit.loadValue(exit.m_jsValueSource.asAddress(), scratch);
     142                profile.emitReportValue(jit, scratch);
     143               
     144                jit.popToRestore(scratchTag);
     145                jit.popToRestore(scratchPayload);
    146146            } else if (exit.m_jsValueSource.hasKnownTag()) {
    147147                GPRReg scratchTag = AssemblyHelpers::selectScratchGPR(exit.m_jsValueSource.payloadGPR());
    148                 m_jit.pushToSave(scratchTag);
    149                 m_jit.move(AssemblyHelpers::TrustedImm32(exit.m_jsValueSource.tag()), scratchTag);
     148                jit.pushToSave(scratchTag);
     149                jit.move(AssemblyHelpers::TrustedImm32(exit.m_jsValueSource.tag()), scratchTag);
    150150                JSValueRegs value(scratchTag, exit.m_jsValueSource.payloadGPR());
    151                 profile.emitReportValue(m_jit, value);
    152                 m_jit.popToRestore(scratchTag);
     151                profile.emitReportValue(jit, value);
     152                jit.popToRestore(scratchTag);
    153153            } else
    154                 profile.emitReportValue(m_jit, exit.m_jsValueSource.regs());
     154                profile.emitReportValue(jit, exit.m_jsValueSource.regs());
    155155        }
    156156    }
     
    171171        case UnboxedBooleanInGPR:
    172172        case UnboxedCellInGPR:
    173             m_jit.store32(
     173            jit.store32(
    174174                recovery.gpr(),
    175175                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload);
     
    177177           
    178178        case InPair:
    179             m_jit.store32(
     179            jit.store32(
    180180                recovery.tagGPR(),
    181181                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.tag);
    182             m_jit.store32(
     182            jit.store32(
    183183                recovery.payloadGPR(),
    184184                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload);
     
    200200        case UnboxedDoubleInFPR:
    201201        case InFPR:
    202             m_jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
    203             m_jit.storeDouble(recovery.fpr(), MacroAssembler::Address(GPRInfo::regT0));
     202            jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
     203            jit.storeDouble(recovery.fpr(), MacroAssembler::Address(GPRInfo::regT0));
    204204            break;
    205205           
     
    224224        case CellDisplacedInJSStack:
    225225        case BooleanDisplacedInJSStack:
    226             m_jit.load32(
     226            jit.load32(
    227227                AssemblyHelpers::tagFor(recovery.virtualRegister()),
    228228                GPRInfo::regT0);
    229             m_jit.load32(
     229            jit.load32(
    230230                AssemblyHelpers::payloadFor(recovery.virtualRegister()),
    231231                GPRInfo::regT1);
    232             m_jit.store32(
     232            jit.store32(
    233233                GPRInfo::regT0,
    234234                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.tag);
    235             m_jit.store32(
     235            jit.store32(
    236236                GPRInfo::regT1,
    237237                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload);
     
    246246    // could toast some stack that the DFG used. We need to do it before storing to stack offsets
    247247    // used by baseline.
    248     m_jit.addPtr(
     248    jit.addPtr(
    249249        CCallHelpers::TrustedImm32(
    250             -m_jit.codeBlock()->jitCode()->dfgCommon()->requiredRegisterCountForExit * sizeof(Register)),
     250            -jit.codeBlock()->jitCode()->dfgCommon()->requiredRegisterCountForExit * sizeof(Register)),
    251251        CCallHelpers::framePointerRegister, CCallHelpers::stackPointerRegister);
    252252   
    253253    // Restore the DFG callee saves and then save the ones the baseline JIT uses.
    254     m_jit.emitRestoreCalleeSaves();
    255     m_jit.emitSaveCalleeSavesFor(m_jit.baselineCodeBlock());
     254    jit.emitRestoreCalleeSaves();
     255    jit.emitSaveCalleeSavesFor(jit.baselineCodeBlock());
    256256
    257257    if (exit.isExceptionHandler())
    258         m_jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(vm);
     258        jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(vm);
    259259
    260260    // Do all data format conversions and store the results into the stack.
     
    264264        VirtualRegister reg = operands.virtualRegisterForIndex(index);
    265265
    266         if (reg.isLocal() && reg.toLocal() < static_cast<int>(m_jit.baselineCodeBlock()->calleeSaveSpaceAsVirtualRegisters()))
     266        if (reg.isLocal() && reg.toLocal() < static_cast<int>(jit.baselineCodeBlock()->calleeSaveSpaceAsVirtualRegisters()))
    267267            continue;
    268268
     
    273273        case DisplacedInJSStack:
    274274        case InFPR:
    275             m_jit.load32(
     275            jit.load32(
    276276                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.tag,
    277277                GPRInfo::regT0);
    278             m_jit.load32(
     278            jit.load32(
    279279                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload,
    280280                GPRInfo::regT1);
    281             m_jit.store32(
     281            jit.store32(
    282282                GPRInfo::regT0,
    283283                AssemblyHelpers::tagFor(operand));
    284             m_jit.store32(
     284            jit.store32(
    285285                GPRInfo::regT1,
    286286                AssemblyHelpers::payloadFor(operand));
     
    289289        case UnboxedDoubleInFPR:
    290290        case DoubleDisplacedInJSStack:
    291             m_jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
    292             m_jit.loadDouble(MacroAssembler::Address(GPRInfo::regT0), FPRInfo::fpRegT0);
    293             m_jit.purifyNaN(FPRInfo::fpRegT0);
    294             m_jit.storeDouble(FPRInfo::fpRegT0, AssemblyHelpers::addressFor(operand));
     291            jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
     292            jit.loadDouble(MacroAssembler::Address(GPRInfo::regT0), FPRInfo::fpRegT0);
     293            jit.purifyNaN(FPRInfo::fpRegT0);
     294            jit.storeDouble(FPRInfo::fpRegT0, AssemblyHelpers::addressFor(operand));
    295295            break;
    296296
    297297        case UnboxedInt32InGPR:
    298298        case Int32DisplacedInJSStack:
    299             m_jit.load32(
     299            jit.load32(
    300300                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload,
    301301                GPRInfo::regT0);
    302             m_jit.store32(
     302            jit.store32(
    303303                AssemblyHelpers::TrustedImm32(JSValue::Int32Tag),
    304304                AssemblyHelpers::tagFor(operand));
    305             m_jit.store32(
     305            jit.store32(
    306306                GPRInfo::regT0,
    307307                AssemblyHelpers::payloadFor(operand));
     
    310310        case UnboxedCellInGPR:
    311311        case CellDisplacedInJSStack:
    312             m_jit.load32(
     312            jit.load32(
    313313                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload,
    314314                GPRInfo::regT0);
    315             m_jit.store32(
     315            jit.store32(
    316316                AssemblyHelpers::TrustedImm32(JSValue::CellTag),
    317317                AssemblyHelpers::tagFor(operand));
    318             m_jit.store32(
     318            jit.store32(
    319319                GPRInfo::regT0,
    320320                AssemblyHelpers::payloadFor(operand));
     
    323323        case UnboxedBooleanInGPR:
    324324        case BooleanDisplacedInJSStack:
    325             m_jit.load32(
     325            jit.load32(
    326326                &bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload,
    327327                GPRInfo::regT0);
    328             m_jit.store32(
     328            jit.store32(
    329329                AssemblyHelpers::TrustedImm32(JSValue::BooleanTag),
    330330                AssemblyHelpers::tagFor(operand));
    331             m_jit.store32(
     331            jit.store32(
    332332                GPRInfo::regT0,
    333333                AssemblyHelpers::payloadFor(operand));
     
    335335           
    336336        case Constant:
    337             m_jit.store32(
     337            jit.store32(
    338338                AssemblyHelpers::TrustedImm32(recovery.constant().tag()),
    339339                AssemblyHelpers::tagFor(operand));
    340             m_jit.store32(
     340            jit.store32(
    341341                AssemblyHelpers::TrustedImm32(recovery.constant().payload()),
    342342                AssemblyHelpers::payloadFor(operand));
     
    359359    // inline call frame scope - but for now the DFG wouldn't do that.
    360360   
    361     emitRestoreArguments(operands);
     361    emitRestoreArguments(jit, operands);
    362362
    363363    // Adjust the old JIT's execute counter. Since we are exiting OSR, we know
     
    397397    // counterValueForOptimizeAfterWarmUp().
    398398   
    399     handleExitCounts(m_jit, exit);
     399    handleExitCounts(jit, exit);
    400400   
    401401    // Reify inlined call frames.
    402402   
    403     reifyInlinedCallFrames(m_jit, exit);
     403    reifyInlinedCallFrames(jit, exit);
    404404   
    405405    // And finish.
    406     adjustAndJumpToTarget(vm, m_jit, exit);
     406    adjustAndJumpToTarget(vm, jit, exit);
    407407}
    408408
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp

    r214531 r220298  
    11/*
    2  * Copyright (C) 2011, 2013-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939namespace JSC { namespace DFG {
    4040
    41 void OSRExitCompiler::compileExit(VM& vm, const OSRExit& exit, const Operands<ValueRecovery>& operands, SpeculationRecovery* recovery)
     41void OSRExit::compileExit(CCallHelpers& jit, VM& vm, const OSRExit& exit, const Operands<ValueRecovery>& operands, SpeculationRecovery* recovery)
    4242{
    43     m_jit.jitAssertTagsInPlace();
     43    jit.jitAssertTagsInPlace();
    4444
    4545    // Pro-forma stuff.
    4646    if (Options::printEachOSRExit()) {
    4747        SpeculationFailureDebugInfo* debugInfo = new SpeculationFailureDebugInfo;
    48         debugInfo->codeBlock = m_jit.codeBlock();
     48        debugInfo->codeBlock = jit.codeBlock();
    4949        debugInfo->kind = exit.m_kind;
    5050        debugInfo->bytecodeOffset = exit.m_codeOrigin.bytecodeIndex;
    5151       
    52         m_jit.debugCall(vm, debugOperationPrintSpeculationFailure, debugInfo);
     52        jit.debugCall(vm, debugOperationPrintSpeculationFailure, debugInfo);
    5353    }
    5454
     
    5959        switch (recovery->type()) {
    6060        case SpeculativeAdd:
    61             m_jit.sub32(recovery->src(), recovery->dest());
    62             m_jit.or64(GPRInfo::tagTypeNumberRegister, recovery->dest());
     61            jit.sub32(recovery->src(), recovery->dest());
     62            jit.or64(GPRInfo::tagTypeNumberRegister, recovery->dest());
    6363            break;
    6464
    6565        case SpeculativeAddImmediate:
    66             m_jit.sub32(AssemblyHelpers::Imm32(recovery->immediate()), recovery->dest());
    67             m_jit.or64(GPRInfo::tagTypeNumberRegister, recovery->dest());
     66            jit.sub32(AssemblyHelpers::Imm32(recovery->immediate()), recovery->dest());
     67            jit.or64(GPRInfo::tagTypeNumberRegister, recovery->dest());
    6868            break;
    6969           
    7070        case BooleanSpeculationCheck:
    71             m_jit.xor64(AssemblyHelpers::TrustedImm32(static_cast<int32_t>(ValueFalse)), recovery->dest());
     71            jit.xor64(AssemblyHelpers::TrustedImm32(static_cast<int32_t>(ValueFalse)), recovery->dest());
    7272            break;
    7373           
     
    9191           
    9292            CodeOrigin codeOrigin = exit.m_codeOriginForExitProfile;
    93             if (ArrayProfile* arrayProfile = m_jit.baselineCodeBlockFor(codeOrigin)->getArrayProfile(codeOrigin.bytecodeIndex)) {
     93            if (ArrayProfile* arrayProfile = jit.baselineCodeBlockFor(codeOrigin)->getArrayProfile(codeOrigin.bytecodeIndex)) {
    9494                GPRReg usedRegister;
    9595                if (exit.m_jsValueSource.isAddress())
     
    104104               
    105105                if (isARM64()) {
    106                     m_jit.pushToSave(scratch1);
    107                     m_jit.pushToSave(scratch2);
     106                    jit.pushToSave(scratch1);
     107                    jit.pushToSave(scratch2);
    108108                } else {
    109                     m_jit.push(scratch1);
    110                     m_jit.push(scratch2);
     109                    jit.push(scratch1);
     110                    jit.push(scratch2);
    111111                }
    112112               
     
    114114                if (exit.m_jsValueSource.isAddress()) {
    115115                    value = scratch1;
    116                     m_jit.loadPtr(AssemblyHelpers::Address(exit.m_jsValueSource.asAddress()), value);
     116                    jit.loadPtr(AssemblyHelpers::Address(exit.m_jsValueSource.asAddress()), value);
    117117                } else
    118118                    value = exit.m_jsValueSource.gpr();
    119119               
    120                 m_jit.load32(AssemblyHelpers::Address(value, JSCell::structureIDOffset()), scratch1);
    121                 m_jit.store32(scratch1, arrayProfile->addressOfLastSeenStructureID());
    122                 m_jit.load8(AssemblyHelpers::Address(value, JSCell::indexingTypeAndMiscOffset()), scratch1);
    123                 m_jit.move(AssemblyHelpers::TrustedImm32(1), scratch2);
    124                 m_jit.lshift32(scratch1, scratch2);
    125                 m_jit.or32(scratch2, AssemblyHelpers::AbsoluteAddress(arrayProfile->addressOfArrayModes()));
     120                jit.load32(AssemblyHelpers::Address(value, JSCell::structureIDOffset()), scratch1);
     121                jit.store32(scratch1, arrayProfile->addressOfLastSeenStructureID());
     122                jit.load8(AssemblyHelpers::Address(value, JSCell::indexingTypeAndMiscOffset()), scratch1);
     123                jit.move(AssemblyHelpers::TrustedImm32(1), scratch2);
     124                jit.lshift32(scratch1, scratch2);
     125                jit.or32(scratch2, AssemblyHelpers::AbsoluteAddress(arrayProfile->addressOfArrayModes()));
    126126               
    127127                if (isARM64()) {
    128                     m_jit.popToRestore(scratch2);
    129                     m_jit.popToRestore(scratch1);
     128                    jit.popToRestore(scratch2);
     129                    jit.popToRestore(scratch1);
    130130                } else {
    131                     m_jit.pop(scratch2);
    132                     m_jit.pop(scratch1);
     131                    jit.pop(scratch2);
     132                    jit.pop(scratch1);
    133133                }
    134134            }
     
    139139                // We can't be sure that we have a spare register. So use the tagTypeNumberRegister,
    140140                // since we know how to restore it.
    141                 m_jit.load64(AssemblyHelpers::Address(exit.m_jsValueSource.asAddress()), GPRInfo::tagTypeNumberRegister);
    142                 profile.emitReportValue(m_jit, JSValueRegs(GPRInfo::tagTypeNumberRegister));
    143                 m_jit.move(AssemblyHelpers::TrustedImm64(TagTypeNumber), GPRInfo::tagTypeNumberRegister);
     141                jit.load64(AssemblyHelpers::Address(exit.m_jsValueSource.asAddress()), GPRInfo::tagTypeNumberRegister);
     142                profile.emitReportValue(jit, JSValueRegs(GPRInfo::tagTypeNumberRegister));
     143                jit.move(AssemblyHelpers::TrustedImm64(TagTypeNumber), GPRInfo::tagTypeNumberRegister);
    144144            } else
    145                 profile.emitReportValue(m_jit, JSValueRegs(exit.m_jsValueSource.gpr()));
     145                profile.emitReportValue(jit, JSValueRegs(exit.m_jsValueSource.gpr()));
    146146        }
    147147    }
     
    197197        case UnboxedStrictInt52InGPR:
    198198        case UnboxedCellInGPR:
    199             m_jit.store64(recovery.gpr(), scratch + index);
     199            jit.store64(recovery.gpr(), scratch + index);
    200200            break;
    201201           
     
    215215        case UnboxedDoubleInFPR:
    216216        case InFPR:
    217             m_jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
    218             m_jit.storeDouble(recovery.fpr(), MacroAssembler::Address(GPRInfo::regT0));
     217            jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
     218            jit.storeDouble(recovery.fpr(), MacroAssembler::Address(GPRInfo::regT0));
    219219            break;
    220220           
     
    241241        case Int52DisplacedInJSStack:
    242242        case StrictInt52DisplacedInJSStack:
    243             m_jit.load64(AssemblyHelpers::addressFor(recovery.virtualRegister()), GPRInfo::regT0);
    244             m_jit.store64(GPRInfo::regT0, scratch + index);
     243            jit.load64(AssemblyHelpers::addressFor(recovery.virtualRegister()), GPRInfo::regT0);
     244            jit.store64(GPRInfo::regT0, scratch + index);
    245245            break;
    246246           
     
    253253    // could toast some stack that the DFG used. We need to do it before storing to stack offsets
    254254    // used by baseline.
    255     m_jit.addPtr(
     255    jit.addPtr(
    256256        CCallHelpers::TrustedImm32(
    257             -m_jit.codeBlock()->jitCode()->dfgCommon()->requiredRegisterCountForExit * sizeof(Register)),
     257            -jit.codeBlock()->jitCode()->dfgCommon()->requiredRegisterCountForExit * sizeof(Register)),
    258258        CCallHelpers::framePointerRegister, CCallHelpers::stackPointerRegister);
    259259   
    260260    // Restore the DFG callee saves and then save the ones the baseline JIT uses.
    261     m_jit.emitRestoreCalleeSaves();
    262     m_jit.emitSaveCalleeSavesFor(m_jit.baselineCodeBlock());
     261    jit.emitRestoreCalleeSaves();
     262    jit.emitSaveCalleeSavesFor(jit.baselineCodeBlock());
    263263
    264264    // The tag registers are needed to materialize recoveries below.
    265     m_jit.emitMaterializeTagCheckRegisters();
     265    jit.emitMaterializeTagCheckRegisters();
    266266
    267267    if (exit.isExceptionHandler())
    268         m_jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(vm);
     268        jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(vm);
    269269
    270270    // Do all data format conversions and store the results into the stack.
     
    274274        VirtualRegister reg = operands.virtualRegisterForIndex(index);
    275275
    276         if (reg.isLocal() && reg.toLocal() < static_cast<int>(m_jit.baselineCodeBlock()->calleeSaveSpaceAsVirtualRegisters()))
     276        if (reg.isLocal() && reg.toLocal() < static_cast<int>(jit.baselineCodeBlock()->calleeSaveSpaceAsVirtualRegisters()))
    277277            continue;
    278278
     
    286286        case BooleanDisplacedInJSStack:
    287287        case InFPR:
    288             m_jit.load64(scratch + index, GPRInfo::regT0);
    289             m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
     288            jit.load64(scratch + index, GPRInfo::regT0);
     289            jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
    290290            break;
    291291           
    292292        case UnboxedInt32InGPR:
    293293        case Int32DisplacedInJSStack:
    294             m_jit.load64(scratch + index, GPRInfo::regT0);
    295             m_jit.zeroExtend32ToPtr(GPRInfo::regT0, GPRInfo::regT0);
    296             m_jit.or64(GPRInfo::tagTypeNumberRegister, GPRInfo::regT0);
    297             m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
     294            jit.load64(scratch + index, GPRInfo::regT0);
     295            jit.zeroExtend32ToPtr(GPRInfo::regT0, GPRInfo::regT0);
     296            jit.or64(GPRInfo::tagTypeNumberRegister, GPRInfo::regT0);
     297            jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
    298298            break;
    299299           
    300300        case UnboxedInt52InGPR:
    301301        case Int52DisplacedInJSStack:
    302             m_jit.load64(scratch + index, GPRInfo::regT0);
    303             m_jit.rshift64(
     302            jit.load64(scratch + index, GPRInfo::regT0);
     303            jit.rshift64(
    304304                AssemblyHelpers::TrustedImm32(JSValue::int52ShiftAmount), GPRInfo::regT0);
    305             m_jit.boxInt52(GPRInfo::regT0, GPRInfo::regT0, GPRInfo::regT1, FPRInfo::fpRegT0);
    306             m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
     305            jit.boxInt52(GPRInfo::regT0, GPRInfo::regT0, GPRInfo::regT1, FPRInfo::fpRegT0);
     306            jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
    307307            break;
    308308           
    309309        case UnboxedStrictInt52InGPR:
    310310        case StrictInt52DisplacedInJSStack:
    311             m_jit.load64(scratch + index, GPRInfo::regT0);
    312             m_jit.boxInt52(GPRInfo::regT0, GPRInfo::regT0, GPRInfo::regT1, FPRInfo::fpRegT0);
    313             m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
     311            jit.load64(scratch + index, GPRInfo::regT0);
     312            jit.boxInt52(GPRInfo::regT0, GPRInfo::regT0, GPRInfo::regT1, FPRInfo::fpRegT0);
     313            jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
    314314            break;
    315315           
    316316        case UnboxedDoubleInFPR:
    317317        case DoubleDisplacedInJSStack:
    318             m_jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
    319             m_jit.loadDouble(MacroAssembler::Address(GPRInfo::regT0), FPRInfo::fpRegT0);
    320             m_jit.purifyNaN(FPRInfo::fpRegT0);
    321             m_jit.boxDouble(FPRInfo::fpRegT0, GPRInfo::regT0);
    322             m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
     318            jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
     319            jit.loadDouble(MacroAssembler::Address(GPRInfo::regT0), FPRInfo::fpRegT0);
     320            jit.purifyNaN(FPRInfo::fpRegT0);
     321            jit.boxDouble(FPRInfo::fpRegT0, GPRInfo::regT0);
     322            jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(operand));
    323323            break;
    324324           
    325325        case Constant:
    326             m_jit.store64(
     326            jit.store64(
    327327                AssemblyHelpers::TrustedImm64(JSValue::encode(recovery.constant())),
    328328                AssemblyHelpers::addressFor(operand));
     
    346346    // inline call frame scope - but for now the DFG wouldn't do that.
    347347   
    348     emitRestoreArguments(operands);
     348    emitRestoreArguments(jit, operands);
    349349   
    350350    // Adjust the old JIT's execute counter. Since we are exiting OSR, we know
     
    384384    // counterValueForOptimizeAfterWarmUp().
    385385   
    386     handleExitCounts(m_jit, exit);
     386    handleExitCounts(jit, exit);
    387387   
    388388    // Reify inlined call frames.
    389389   
    390     reifyInlinedCallFrames(m_jit, exit);
     390    reifyInlinedCallFrames(jit, exit);
    391391
    392392    // And finish.
    393     adjustAndJumpToTarget(vm, m_jit, exit);
     393    adjustAndJumpToTarget(vm, jit, exit);
    394394}
    395395
  • trunk/Source/JavaScriptCore/dfg/DFGThunks.cpp

    r220219 r220298  
    9696    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
    9797   
    98     patchBuffer.link(functionCall, compileOSRExit);
     98    patchBuffer.link(functionCall, OSRExit::compileOSRExit);
    9999   
    100100    return FINALIZE_CODE(patchBuffer, ("DFG OSR exit generation thunk"));
Note: See TracChangeset for help on using the changeset viewer.