Changeset 210007 in webkit


Ignore:
Timestamp:
Dec 19, 2016 5:48:52 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

Rolling out r209974 and r209952. They break some websites in mysterious ways. Step 1: Rollout r209974.
https://bugs.webkit.org/show_bug.cgi?id=166049

Not reviewed.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitEnumeration):
(JSC::BytecodeGenerator::emitJumpViaFinallyIfNeeded):
(JSC::BytecodeGenerator::emitReturnViaFinallyIfNeeded):
(JSC::BytecodeGenerator::emitFinallyCompletion):
(JSC::BytecodeGenerator::allocateFinallyRegisters):
(JSC::BytecodeGenerator::releaseFinallyRegisters):
(JSC::BytecodeGenerator::emitCompareFinallyActionAndJumpIf):
(JSC::BytecodeGenerator::allocateCompletionRecordRegisters): Deleted.
(JSC::BytecodeGenerator::releaseCompletionRecordRegisters): Deleted.
(JSC::BytecodeGenerator::emitJumpIfCompletionType): Deleted.

  • bytecompiler/BytecodeGenerator.h:

(JSC::FinallyJump::FinallyJump):
(JSC::FinallyContext::registerJump):
(JSC::BytecodeGenerator::FinallyRegistersScope::FinallyRegistersScope):
(JSC::BytecodeGenerator::FinallyRegistersScope::~FinallyRegistersScope):
(JSC::BytecodeGenerator::finallyActionRegister):
(JSC::BytecodeGenerator::finallyReturnValueRegister):
(JSC::BytecodeGenerator::emitSetFinallyActionToNormalCompletion):
(JSC::BytecodeGenerator::emitSetFinallyActionToReturnCompletion):
(JSC::BytecodeGenerator::emitSetFinallyActionToJumpID):
(JSC::BytecodeGenerator::emitSetFinallyReturnValueRegister):
(JSC::BytecodeGenerator::emitJumpIfFinallyActionIsNormalCompletion):
(JSC::BytecodeGenerator::emitJumpIfFinallyActionIsNotJump):
(JSC::BytecodeGenerator::emitJumpIfFinallyActionIsReturnCompletion):
(JSC::BytecodeGenerator::emitJumpIfFinallyActionIsNotReturnCompletion):
(JSC::BytecodeGenerator::emitJumpIfFinallyActionIsNotThrowCompletion):
(JSC::BytecodeGenerator::emitJumpIfCompletionTypeIsThrow):
(JSC::BytecodeGenerator::bytecodeOffsetToJumpID):
(JSC::bytecodeOffsetToJumpID): Deleted.
(JSC::BytecodeGenerator::CompletionRecordScope::CompletionRecordScope): Deleted.
(JSC::BytecodeGenerator::CompletionRecordScope::~CompletionRecordScope): Deleted.
(JSC::BytecodeGenerator::completionTypeRegister): Deleted.
(JSC::BytecodeGenerator::completionValueRegister): Deleted.
(JSC::BytecodeGenerator::emitSetCompletionType): Deleted.
(JSC::BytecodeGenerator::emitSetCompletionValue): Deleted.

  • bytecompiler/NodesCodegen.cpp:

(JSC::TryNode::emitBytecode):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r209998 r210007  
     12016-12-19  Mark Lam  <mark.lam@apple.com>
     2
     3        Rolling out r209974 and r209952. They break some websites in mysterious ways. Step 1: Rollout r209974.
     4        https://bugs.webkit.org/show_bug.cgi?id=166049
     5
     6        Not reviewed.
     7
     8        * bytecompiler/BytecodeGenerator.cpp:
     9        (JSC::BytecodeGenerator::emitEnumeration):
     10        (JSC::BytecodeGenerator::emitJumpViaFinallyIfNeeded):
     11        (JSC::BytecodeGenerator::emitReturnViaFinallyIfNeeded):
     12        (JSC::BytecodeGenerator::emitFinallyCompletion):
     13        (JSC::BytecodeGenerator::allocateFinallyRegisters):
     14        (JSC::BytecodeGenerator::releaseFinallyRegisters):
     15        (JSC::BytecodeGenerator::emitCompareFinallyActionAndJumpIf):
     16        (JSC::BytecodeGenerator::allocateCompletionRecordRegisters): Deleted.
     17        (JSC::BytecodeGenerator::releaseCompletionRecordRegisters): Deleted.
     18        (JSC::BytecodeGenerator::emitJumpIfCompletionType): Deleted.
     19        * bytecompiler/BytecodeGenerator.h:
     20        (JSC::FinallyJump::FinallyJump):
     21        (JSC::FinallyContext::registerJump):
     22        (JSC::BytecodeGenerator::FinallyRegistersScope::FinallyRegistersScope):
     23        (JSC::BytecodeGenerator::FinallyRegistersScope::~FinallyRegistersScope):
     24        (JSC::BytecodeGenerator::finallyActionRegister):
     25        (JSC::BytecodeGenerator::finallyReturnValueRegister):
     26        (JSC::BytecodeGenerator::emitSetFinallyActionToNormalCompletion):
     27        (JSC::BytecodeGenerator::emitSetFinallyActionToReturnCompletion):
     28        (JSC::BytecodeGenerator::emitSetFinallyActionToJumpID):
     29        (JSC::BytecodeGenerator::emitSetFinallyReturnValueRegister):
     30        (JSC::BytecodeGenerator::emitJumpIfFinallyActionIsNormalCompletion):
     31        (JSC::BytecodeGenerator::emitJumpIfFinallyActionIsNotJump):
     32        (JSC::BytecodeGenerator::emitJumpIfFinallyActionIsReturnCompletion):
     33        (JSC::BytecodeGenerator::emitJumpIfFinallyActionIsNotReturnCompletion):
     34        (JSC::BytecodeGenerator::emitJumpIfFinallyActionIsNotThrowCompletion):
     35        (JSC::BytecodeGenerator::emitJumpIfCompletionTypeIsThrow):
     36        (JSC::BytecodeGenerator::bytecodeOffsetToJumpID):
     37        (JSC::bytecodeOffsetToJumpID): Deleted.
     38        (JSC::BytecodeGenerator::CompletionRecordScope::CompletionRecordScope): Deleted.
     39        (JSC::BytecodeGenerator::CompletionRecordScope::~CompletionRecordScope): Deleted.
     40        (JSC::BytecodeGenerator::completionTypeRegister): Deleted.
     41        (JSC::BytecodeGenerator::completionValueRegister): Deleted.
     42        (JSC::BytecodeGenerator::emitSetCompletionType): Deleted.
     43        (JSC::BytecodeGenerator::emitSetCompletionValue): Deleted.
     44        * bytecompiler/NodesCodegen.cpp:
     45        (JSC::TryNode::emitBytecode):
     46
    1472016-12-19  Joseph Pecoraro  <pecoraro@apple.com>
    248
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r209974 r210007  
    41274127void BytecodeGenerator::emitEnumeration(ThrowableExpressionData* node, ExpressionNode* subjectNode, const std::function<void(BytecodeGenerator&, RegisterID*)>& callBack, ForOfNode* forLoopNode, RegisterID* forLoopSymbolTable)
    41284128{
    4129     CompletionRecordScope completionRecordScope(*this);
     4129    FinallyRegistersScope finallyRegistersScope(*this);
    41304130
    41314131    RefPtr<RegisterID> subject = newTemporary();
     
    41704170            popTry(tryData, finallyViaThrowLabel.get());
    41714171
    4172             RefPtr<Label> finallyBodyLabel = newLabel();
    4173             RefPtr<RegisterID> finallyExceptionRegister = newTemporary();
    41744172            RegisterID* unused = newTemporary();
    4175 
    4176             emitCatch(completionValueRegister(), unused);
    4177             emitSetCompletionType(CompletionType::Throw);
    4178             emitMove(finallyExceptionRegister.get(), completionValueRegister());
    4179             emitJump(finallyBodyLabel.get());
     4173            emitCatch(finallyActionRegister(), unused);
     4174            // Setting the finallyActionRegister to the caught exception here implies CompletionType::Throw.
    41804175
    41814176            emitLabel(finallyLabel.get());
    4182             emitMoveEmptyValue(finallyExceptionRegister.get());
    4183 
    4184             emitLabel(finallyBodyLabel.get());
    41854177            restoreScopeRegister();
    41864178
     
    41894181            RefPtr<RegisterID> returnMethod = emitGetById(newTemporary(), iterator.get(), propertyNames().returnKeyword);
    41904182            emitJumpIfTrue(emitIsUndefined(newTemporary(), returnMethod.get()), finallyDone.get());
     4183
     4184            RefPtr<RegisterID> originalFinallyActionRegister = newTemporary();
     4185            emitMove(originalFinallyActionRegister.get(), finallyActionRegister());
    41914186
    41924187            RefPtr<Label> returnCallTryStart = newLabel();
     
    42154210                RegisterID* unused = newTemporary();
    42164211                emitCatch(exceptionRegister.get(), unused);
    4217                 // Since this is a synthesized catch block and we're guaranteed to never need
    4218                 // to resolve any symbols from the scope, we can skip restoring the scope
    4219                 // register here.
     4212                restoreScopeRegister();
    42204213
    42214214                RefPtr<Label> throwLabel = newLabel();
    4222                 emitJumpIfTrue(emitIsEmpty(newTemporary(), finallyExceptionRegister.get()), throwLabel.get());
    4223                 emitMove(exceptionRegister.get(), finallyExceptionRegister.get());
     4215                emitJumpIfCompletionTypeIsThrow(originalFinallyActionRegister.get(), throwLabel.get());
     4216                emitMove(originalFinallyActionRegister.get(), exceptionRegister.get());
    42244217
    42254218                emitLabel(throwLabel.get());
    4226                 emitThrow(exceptionRegister.get());
     4219                emitThrow(originalFinallyActionRegister.get());
    42274220
    42284221                emitLabel(endCatchLabel.get());
     
    48274820        return false; // No finallys to thread through.
    48284821
    4829     auto jumpID = bytecodeOffsetToJumpID(instructions().size());
     4822    int jumpID = bytecodeOffsetToJumpID(instructions().size());
    48304823    int lexicalScopeIndex = labelScopeDepthToLexicalScopeIndex(targetLabelScopeDepth);
    48314824    outermostFinallyContext->registerJump(jumpID, lexicalScopeIndex, jumpTarget);
    48324825
    4833     emitSetCompletionType(jumpID);
     4826    emitSetFinallyActionToJumpID(jumpID);
    48344827    emitJump(innermostFinallyContext->finallyLabel());
    48354828    return true; // We'll be jumping to a finally block.
     
    48574850        return false; // No finallys to thread through.
    48584851
    4859     emitSetCompletionType(CompletionType::Return);
    4860     emitSetCompletionValue(returnRegister);
     4852    emitSetFinallyActionToReturnCompletion();
     4853    emitSetFinallyReturnValueRegister(returnRegister);
    48614854    emitJump(innermostFinallyContext->finallyLabel());
    48624855    return true; // We'll be jumping to a finally block.
     
    48654858void BytecodeGenerator::emitFinallyCompletion(FinallyContext& context, Label* normalCompletionLabel)
    48664859{
    4867     emitJumpIfCompletionType(op_stricteq, CompletionType::Normal, normalCompletionLabel);
     4860    // FIXME: switch the finallyActionRegister to only store int values for all CompletionTypes. This is more optimal for JIT type speculation.
     4861    // https://bugs.webkit.org/show_bug.cgi?id=165979
     4862    emitJumpIfFinallyActionIsNormalCompletion(normalCompletionLabel);
    48684863
    48694864    if (context.numberOfBreaksOrContinues() || context.handlesReturns()) {
     
    48754870                RefPtr<Label> nextLabel = newLabel();
    48764871                auto& jump = context.jumps(i);
    4877                 emitJumpIfCompletionType(op_nstricteq, jump.jumpID, nextLabel.get());
     4872                emitJumpIfFinallyActionIsNotJump(jump.jumpID, nextLabel.get());
    48784873
    48794874                restoreScopeRegister(jump.targetLexicalScopeIndex);
    4880                 emitSetCompletionType(CompletionType::Normal);
     4875                emitSetFinallyActionToNormalCompletion();
    48814876                emitJump(jump.targetLabel.get());
    48824877
     
    48864881            bool hasBreaksOrContinuesNotCoveredByJumps = context.numberOfBreaksOrContinues() > numberOfJumps;
    48874882            if (hasBreaksOrContinuesNotCoveredByJumps || context.handlesReturns())
    4888                 emitJumpIfCompletionType(op_nstricteq, CompletionType::Throw, outerContext->finallyLabel());
     4883                emitJumpIfFinallyActionIsNotThrowCompletion(outerContext->finallyLabel());
    48894884
    48904885        } else {
     
    48964891                RefPtr<Label> nextLabel = newLabel();
    48974892                auto& jump = context.jumps(i);
    4898                 emitJumpIfCompletionType(op_nstricteq, jump.jumpID, nextLabel.get());
     4893                emitJumpIfFinallyActionIsNotJump(jump.jumpID, nextLabel.get());
    48994894
    49004895                restoreScopeRegister(jump.targetLexicalScopeIndex);
    4901                 emitSetCompletionType(CompletionType::Normal);
     4896                emitSetFinallyActionToNormalCompletion();
    49024897                emitJump(jump.targetLabel.get());
    49034898
     
    49074902            if (context.handlesReturns()) {
    49084903                RefPtr<Label> notReturnLabel = newLabel();
    4909                 emitJumpIfCompletionType(op_nstricteq, CompletionType::Return, notReturnLabel.get());
     4904                emitJumpIfFinallyActionIsNotReturnCompletion(notReturnLabel.get());
    49104905
    49114906                emitWillLeaveCallFrameDebugHook();
    4912                 emitReturn(completionValueRegister(), ReturnFrom::Finally);
     4907                emitReturn(finallyReturnValueRegister(), ReturnFrom::Finally);
    49134908               
    49144909                emitLabel(notReturnLabel.get());
     
    49164911        }
    49174912    }
    4918     emitThrow(completionValueRegister());
    4919 }
    4920 
    4921 bool BytecodeGenerator::allocateCompletionRecordRegisters()
    4922 {
    4923     if (m_completionTypeRegister)
     4913    emitThrow(finallyActionRegister());
     4914}
     4915
     4916bool BytecodeGenerator::allocateFinallyRegisters()
     4917{
     4918    if (m_finallyActionRegister)
    49244919        return false;
    49254920
    4926     ASSERT(!m_completionValueRegister);
    4927     m_completionTypeRegister = newTemporary();
    4928     m_completionValueRegister = newTemporary();
    4929 
    4930     emitSetCompletionType(CompletionType::Normal);
    4931     emitMoveEmptyValue(m_completionValueRegister.get());
     4921    ASSERT(!m_finallyReturnValueRegister);
     4922    m_finallyActionRegister = newTemporary();
     4923    m_finallyReturnValueRegister = newTemporary();
     4924
     4925    emitSetFinallyActionToNormalCompletion();
     4926    emitMoveEmptyValue(m_finallyReturnValueRegister.get());
    49324927    return true;
    49334928}
    49344929
    4935 void BytecodeGenerator::releaseCompletionRecordRegisters()
    4936 {
    4937     ASSERT(m_completionTypeRegister && m_completionValueRegister);
    4938     m_completionTypeRegister = nullptr;
    4939     m_completionValueRegister = nullptr;
    4940 }
    4941 
    4942 void BytecodeGenerator::emitJumpIfCompletionType(OpcodeID compareOpcode, CompletionType type, Label* jumpTarget)
     4930void BytecodeGenerator::releaseFinallyRegisters()
     4931{
     4932    ASSERT(m_finallyActionRegister && m_finallyReturnValueRegister);
     4933    m_finallyActionRegister = nullptr;
     4934    m_finallyReturnValueRegister = nullptr;
     4935}
     4936
     4937void BytecodeGenerator::emitCompareFinallyActionAndJumpIf(OpcodeID compareOpcode, int value, Label* jumpTarget)
    49434938{
    49444939    RefPtr<RegisterID> tempRegister = newTemporary();
    4945     RegisterID* valueConstant = addConstantValue(JSValue(static_cast<int>(type)));
     4940    RegisterID* valueConstant = addConstantValue(JSValue(value));
    49464941    OperandTypes operandTypes = OperandTypes(ResultType::numberTypeIsInt32(), ResultType::unknownType());
    49474942
    4948     auto equivalenceResult = emitBinaryOp(compareOpcode, tempRegister.get(), valueConstant, completionTypeRegister(), operandTypes);
     4943    auto equivalenceResult = emitBinaryOp(compareOpcode, tempRegister.get(), valueConstant, finallyActionRegister(), operandTypes);
    49494944    emitJumpIfTrue(equivalenceResult, jumpTarget);
    49504945}
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r209974 r210007  
    8181    };
    8282
    83     // https://tc39.github.io/ecma262/#sec-completion-record-specification-type
    84     //
    85     // For the Break and Continue cases, instead of using the Break and Continue enum values
    86     // below, we use the unique jumpID of the break and continue statement as the encoding
    87     // for the CompletionType value. emitFinallyCompletion() uses this jumpID value later
    88     // to determine the appropriate jump target to jump to after executing the relevant finally
    89     // blocks. The jumpID is computed as:
    90     //     jumpID = bytecodeOffset (of the break/continue node) + CompletionType::NumberOfTypes.
    91     // Hence, there won't be any collision between jumpIDs and CompletionType enums.
    92     enum class CompletionType : int {
    93         Normal,
    94         Break,
    95         Continue,
    96         Return,
    97         Throw,
    98        
    99         NumberOfTypes
    100     };
    101 
    102     inline CompletionType bytecodeOffsetToJumpID(unsigned offset)
    103     {
    104         int jumpIDAsInt = offset + static_cast<int>(CompletionType::NumberOfTypes);
    105         ASSERT(jumpIDAsInt >= static_cast<int>(CompletionType::NumberOfTypes));
    106         return static_cast<CompletionType>(jumpIDAsInt);
    107     }
    108 
    10983    struct FinallyJump {
    110         FinallyJump(CompletionType jumpID, int targetLexicalScopeIndex, Label* targetLabel)
     84        FinallyJump(int jumpID, int targetLexicalScopeIndex, Label* targetLabel)
    11185            : jumpID(jumpID)
    11286            , targetLexicalScopeIndex(targetLexicalScopeIndex)
     
    11488        { }
    11589
    116         CompletionType jumpID;
    117         int targetLexicalScopeIndex;
     90        int jumpID { 0 };
     91        int targetLexicalScopeIndex { 0 };
    11892        RefPtr<Label> targetLabel;
    11993    };
     
    143117        void setHandlesReturns() { m_handlesReturns = true; }
    144118
    145         void registerJump(CompletionType jumpID, int lexicalScopeIndex, Label* targetLabel)
     119        void registerJump(int jumpID, int lexicalScopeIndex, Label* targetLabel)
    146120        {
    147121            if (!m_jumps)
     
    802776        void emitWillLeaveCallFrameDebugHook();
    803777
    804         class CompletionRecordScope {
     778        class FinallyRegistersScope {
    805779        public:
    806             CompletionRecordScope(BytecodeGenerator& generator, bool needCompletionRecordRegisters = true)
     780            FinallyRegistersScope(BytecodeGenerator& generator, bool needFinallyRegisters = true)
    807781                : m_generator(generator)
    808782            {
    809                 if (needCompletionRecordRegisters && m_generator.allocateCompletionRecordRegisters())
     783                if (needFinallyRegisters && m_generator.allocateFinallyRegisters())
    810784                    m_needToReleaseOnDestruction = true;
    811785            }
    812             ~CompletionRecordScope()
     786            ~FinallyRegistersScope()
    813787            {
    814788                if (m_needToReleaseOnDestruction)
    815                     m_generator.releaseCompletionRecordRegisters();
     789                    m_generator.releaseFinallyRegisters();
    816790            }
    817791
     
    821795        };
    822796
    823         RegisterID* completionTypeRegister() const
    824         {
    825             ASSERT(m_completionTypeRegister);
    826             return m_completionTypeRegister.get();
    827         }
    828         RegisterID* completionValueRegister() const
    829         {
    830             ASSERT(m_completionValueRegister);
    831             return m_completionValueRegister.get();
    832         }
    833 
    834         void emitSetCompletionType(CompletionType type)
    835         {
    836             emitLoad(completionTypeRegister(), JSValue(static_cast<int>(type)));
    837         }
    838         void emitSetCompletionValue(RegisterID* reg)
    839         {
    840             emitMove(completionValueRegister(), reg);
    841         }
    842 
    843         void emitJumpIfCompletionType(OpcodeID compareOpcode, CompletionType, Label* jumpTarget);
     797        RegisterID* finallyActionRegister() const
     798        {
     799            ASSERT(m_finallyActionRegister);
     800            return m_finallyActionRegister.get();
     801        }
     802        RegisterID* finallyReturnValueRegister() const
     803        {
     804            ASSERT(m_finallyReturnValueRegister);
     805            return m_finallyReturnValueRegister.get();
     806        }
     807
     808        void emitSetFinallyActionToNormalCompletion()
     809        {
     810            emitMoveEmptyValue(m_finallyActionRegister.get());
     811        }
     812        void emitSetFinallyActionToReturnCompletion()
     813        {
     814            emitLoad(finallyActionRegister(), JSValue(static_cast<int>(CompletionType::Return)));
     815        }
     816        void emitSetFinallyActionToJumpID(int jumpID)
     817        {
     818            emitLoad(finallyActionRegister(), JSValue(jumpID));
     819        }
     820        void emitSetFinallyReturnValueRegister(RegisterID* reg)
     821        {
     822            emitMove(finallyReturnValueRegister(), reg);
     823        }
     824
     825        void emitJumpIfFinallyActionIsNormalCompletion(Label* jumpTarget)
     826        {
     827            emitJumpIfTrue(emitIsEmpty(newTemporary(), finallyActionRegister()), jumpTarget);
     828        }
     829
     830        void emitJumpIfFinallyActionIsNotJump(int jumpID, Label* jumpTarget)
     831        {
     832            emitCompareFinallyActionAndJumpIf(op_nstricteq, jumpID, jumpTarget);
     833        }
     834
     835        void emitJumpIfFinallyActionIsReturnCompletion(Label* jumpTarget)
     836        {
     837            emitCompareFinallyActionAndJumpIf(op_stricteq, static_cast<int>(CompletionType::Return), jumpTarget);
     838        }
     839        void emitJumpIfFinallyActionIsNotReturnCompletion(Label* jumpTarget)
     840        {
     841            emitCompareFinallyActionAndJumpIf(op_nstricteq, static_cast<int>(CompletionType::Return), jumpTarget);
     842        }
     843
     844        void emitJumpIfFinallyActionIsNotThrowCompletion(Label* jumpTarget)
     845        {
     846            emitJumpIfTrue(emitIsNumber(newTemporary(), finallyActionRegister()), jumpTarget);
     847        }
     848        void emitJumpIfCompletionTypeIsThrow(RegisterID* reg, Label* jumpTarget)
     849        {
     850            emitJumpIfFalse(emitIsNumber(newTemporary(), reg), jumpTarget);
     851        }
    844852
    845853        bool emitJumpViaFinallyIfNeeded(int targetLabelScopeDepth, Label* jumpTarget);
     
    848856
    849857    private:
    850         bool allocateCompletionRecordRegisters();
    851         void releaseCompletionRecordRegisters();
     858        void emitCompareFinallyActionAndJumpIf(OpcodeID compareOpcode, int value, Label* jumpTarget);
     859
     860        int bytecodeOffsetToJumpID(unsigned offset)
     861        {
     862            int jumpID = offset + static_cast<int>(CompletionType::NumberOfTypes);
     863            ASSERT(jumpID >= static_cast<int>(CompletionType::NumberOfTypes));
     864            return jumpID;
     865        }
     866
     867        bool allocateFinallyRegisters();
     868        void releaseFinallyRegisters();
    852869
    853870    public:
     
    10841101        RegisterID* m_promiseCapabilityRegister { nullptr };
    10851102
    1086         RefPtr<RegisterID> m_completionTypeRegister;
    1087         RefPtr<RegisterID> m_completionValueRegister;
     1103        // The spec at https://tc39.github.io/ecma262/#sec-completion-record-specification-type says
     1104        // that there are 5 types of completions. Conceptually, we'll set m_finallyActionRegister
     1105        // to one of these completion types. However, to optimize our implementation, we'll encode
     1106        // these type info as follows:
     1107        //
     1108        //     CompletionType::Normal   - m_finallyActionRegister is empty.
     1109        //     CompletionType::Break    - m_finallyActionRegister is an int JSValue jumpID.
     1110        //     CompletionType::Continue - m_finallyActionRegister is an int JSValue jumpID.
     1111        //     CompletionType::Return   - m_finallyActionRegister is the Return enum as an int JSValue.
     1112        //     CompletionType::Throw    - m_finallyActionRegister is the Exception object to rethrow.
     1113        //
     1114        // Hence, of the 5 completion types, only the CompletionType::Return enum value is used in
     1115        // our implementation. The rest are just provided for completeness.
     1116
     1117        enum class CompletionType : int {
     1118            Normal,
     1119            Break,
     1120            Continue,
     1121            Return,
     1122            Throw,
     1123
     1124            NumberOfTypes
     1125        };
     1126
     1127        RefPtr<RegisterID> m_finallyActionRegister;
     1128        RefPtr<RegisterID> m_finallyReturnValueRegister;
    10881129
    10891130        FinallyContext* m_currentFinallyContext { nullptr };
     
    11031144        void popLocalControlFlowScope();
    11041145
    1105         // FIXME: Restore overflow checking with UnsafeVectorOverflow once SegmentVector supports it.
     1146        // FIXME: Restore overflow checking with UnsafeVectorOverflow once SegmentVector supports it. 
    11061147        // https://bugs.webkit.org/show_bug.cgi?id=165980
    11071148        SegmentedVector<ControlFlowScope, 16> m_controlFlowScopeStack;
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r209974 r210007  
    32883288
    32893289    ASSERT(m_catchBlock || m_finallyBlock);
    3290     BytecodeGenerator::CompletionRecordScope completionRecordScope(generator, m_finallyBlock);
     3290    BytecodeGenerator::FinallyRegistersScope finallyRegistersScope(generator, m_finallyBlock);
    32913291
    32923292    RefPtr<Label> catchLabel;
     
    33173317    generator.emitNode(dst, m_tryBlock);
    33183318
     3319    // The finallyActionRegister is an empty value by default, which implies CompletionType::Normal.
    33193320    if (m_finallyBlock)
    33203321        generator.emitJump(finallyLabel.get());
     
    33513352
    33523353        if (m_finallyBlock) {
    3353             generator.emitSetCompletionType(CompletionType::Normal);
     3354            generator.emitSetFinallyActionToNormalCompletion();
    33543355            generator.emitJump(finallyLabel.get());
    33553356            generator.popTry(tryData, finallyViaThrowLabel.get());
     
    33663367        generator.emitLabel(finallyViaThrowLabel.get());
    33673368        RegisterID* unused = generator.newTemporary();
    3368         generator.emitCatch(generator.completionValueRegister(), unused);
    3369         generator.emitSetCompletionType(CompletionType::Throw);
     3369        generator.emitCatch(generator.finallyActionRegister(), unused);
     3370        // Setting the finallyActionRegister to the caught exception here implies CompletionType::Throw.
    33703371
    33713372        // Entry to the finally block for CompletionTypes other than Throw.
Note: See TracChangeset for help on using the changeset viewer.