Changeset 38430 in webkit for trunk/JavaScriptCore/bytecompiler


Ignore:
Timestamp:
Nov 15, 2008, 2:33:58 PM (17 years ago)
Author:
[email protected]
Message:

2008-11-15 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Renamed LabelID to Label, Label::isForwardLabel to Label::isForward.

  • VM/LabelID.h: (JSC::Label::Label): (JSC::Label::isForward):
  • bytecompiler/CodeGenerator.cpp: (JSC::BytecodeGenerator::newLabel): (JSC::BytecodeGenerator::emitLabel): (JSC::BytecodeGenerator::emitJump): (JSC::BytecodeGenerator::emitJumpIfTrue): (JSC::BytecodeGenerator::emitJumpIfFalse): (JSC::BytecodeGenerator::pushFinallyContext): (JSC::BytecodeGenerator::emitComplexJumpScopes): (JSC::BytecodeGenerator::emitJumpScopes): (JSC::BytecodeGenerator::emitNextPropertyName): (JSC::BytecodeGenerator::emitCatch): (JSC::BytecodeGenerator::emitJumpSubroutine): (JSC::prepareJumpTableForImmediateSwitch): (JSC::prepareJumpTableForCharacterSwitch): (JSC::prepareJumpTableForStringSwitch): (JSC::BytecodeGenerator::endSwitch):
  • bytecompiler/CodeGenerator.h:
  • bytecompiler/LabelScope.h: (JSC::LabelScope::LabelScope): (JSC::LabelScope::breakTarget): (JSC::LabelScope::continueTarget):
  • parser/Nodes.cpp: (JSC::LogicalOpNode::emitBytecode): (JSC::ConditionalNode::emitBytecode): (JSC::IfNode::emitBytecode): (JSC::IfElseNode::emitBytecode): (JSC::DoWhileNode::emitBytecode): (JSC::WhileNode::emitBytecode): (JSC::ForNode::emitBytecode): (JSC::ForInNode::emitBytecode): (JSC::ReturnNode::emitBytecode): (JSC::CaseBlockNode::emitBytecodeForBlock): (JSC::TryNode::emitBytecode):
Location:
trunk/JavaScriptCore/bytecompiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecompiler/CodeGenerator.cpp

    r38428 r38430  
    485485}
    486486
    487 PassRefPtr<LabelID> BytecodeGenerator::newLabel()
     487PassRefPtr<Label> BytecodeGenerator::newLabel()
    488488{
    489489    // Reclaim free label IDs.
     
    496496}
    497497
    498 PassRefPtr<LabelID> BytecodeGenerator::emitLabel(LabelID* l0)
     498PassRefPtr<Label> BytecodeGenerator::emitLabel(Label* l0)
    499499{
    500500    unsigned newLabelIndex = instructions().size();
     
    552552}
    553553
    554 PassRefPtr<LabelID> BytecodeGenerator::emitJump(LabelID* target)
    555 {
    556     emitOpcode(target->isForwardLabel() ? op_jmp : op_loop);
     554PassRefPtr<Label> BytecodeGenerator::emitJump(Label* target)
     555{
     556    emitOpcode(target->isForward() ? op_jmp : op_loop);
    557557    instructions().append(target->offsetFrom(instructions().size()));
    558558    return target;
    559559}
    560560
    561 PassRefPtr<LabelID> BytecodeGenerator::emitJumpIfTrue(RegisterID* cond, LabelID* target)
    562 {
    563     if (m_lastOpcodeID == op_less && !target->isForwardLabel()) {
     561PassRefPtr<Label> BytecodeGenerator::emitJumpIfTrue(RegisterID* cond, Label* target)
     562{
     563    if (m_lastOpcodeID == op_less && !target->isForward()) {
    564564        int dstIndex;
    565565        int src1Index;
     
    576576            return target;
    577577        }
    578     } else if (m_lastOpcodeID == op_lesseq && !target->isForwardLabel()) {
     578    } else if (m_lastOpcodeID == op_lesseq && !target->isForward()) {
    579579        int dstIndex;
    580580        int src1Index;
     
    591591            return target;
    592592        }
    593     } else if (m_lastOpcodeID == op_eq_null && target->isForwardLabel()) {
     593    } else if (m_lastOpcodeID == op_eq_null && target->isForward()) {
    594594        int dstIndex;
    595595        int srcIndex;
     
    604604            return target;
    605605        }
    606     } else if (m_lastOpcodeID == op_neq_null && target->isForwardLabel()) {
     606    } else if (m_lastOpcodeID == op_neq_null && target->isForward()) {
    607607        int dstIndex;
    608608        int srcIndex;
     
    619619    }
    620620
    621     emitOpcode(target->isForwardLabel() ? op_jtrue : op_loop_if_true);
     621    emitOpcode(target->isForward() ? op_jtrue : op_loop_if_true);
    622622    instructions().append(cond->index());
    623623    instructions().append(target->offsetFrom(instructions().size()));
     
    625625}
    626626
    627 PassRefPtr<LabelID> BytecodeGenerator::emitJumpIfFalse(RegisterID* cond, LabelID* target)
    628 {
    629     ASSERT(target->isForwardLabel());
     627PassRefPtr<Label> BytecodeGenerator::emitJumpIfFalse(RegisterID* cond, Label* target)
     628{
     629    ASSERT(target->isForward());
    630630
    631631    if (m_lastOpcodeID == op_less) {
     
    14141414}
    14151415
    1416 void BytecodeGenerator::pushFinallyContext(LabelID* target, RegisterID* retAddrDst)
     1416void BytecodeGenerator::pushFinallyContext(Label* target, RegisterID* retAddrDst)
    14171417{
    14181418    ControlFlowContext scope;
     
    15011501}
    15021502
    1503 PassRefPtr<LabelID> BytecodeGenerator::emitComplexJumpScopes(LabelID* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope)
     1503PassRefPtr<Label> BytecodeGenerator::emitComplexJumpScopes(Label* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope)
    15041504{
    15051505    while (topScope > bottomScope) {
     
    15291529            // Otherwise we just use jmp_scopes to pop a group of scopes and go
    15301530            // to the next instruction
    1531             RefPtr<LabelID> nextInsn = newLabel();
     1531            RefPtr<Label> nextInsn = newLabel();
    15321532            instructions().append(nextInsn->offsetFrom(instructions().size()));
    15331533            emitLabel(nextInsn.get());
     
    15461546}
    15471547
    1548 PassRefPtr<LabelID> BytecodeGenerator::emitJumpScopes(LabelID* target, int targetScopeDepth)
     1548PassRefPtr<Label> BytecodeGenerator::emitJumpScopes(Label* target, int targetScopeDepth)
    15491549{
    15501550    ASSERT(scopeDepth() - targetScopeDepth >= 0);
    1551     ASSERT(target->isForwardLabel());
     1551    ASSERT(target->isForward());
    15521552
    15531553    size_t scopeDelta = scopeDepth() - targetScopeDepth;
     
    15651565}
    15661566
    1567 RegisterID* BytecodeGenerator::emitNextPropertyName(RegisterID* dst, RegisterID* iter, LabelID* target)
     1567RegisterID* BytecodeGenerator::emitNextPropertyName(RegisterID* dst, RegisterID* iter, Label* target)
    15681568{
    15691569    emitOpcode(op_next_pname);
     
    15741574}
    15751575
    1576 RegisterID* BytecodeGenerator::emitCatch(RegisterID* targetRegister, LabelID* start, LabelID* end)
     1576RegisterID* BytecodeGenerator::emitCatch(RegisterID* targetRegister, Label* start, Label* end)
    15771577{
    15781578    HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth, 0 };
     
    15921592}
    15931593
    1594 PassRefPtr<LabelID> BytecodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, LabelID* finally)
     1594PassRefPtr<Label> BytecodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, Label* finally)
    15951595{
    15961596    emitOpcode(op_jsr);
     
    16551655}
    16561656
    1657 static void prepareJumpTableForImmediateSwitch(SimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<LabelID>* labels, ExpressionNode** nodes, int32_t min, int32_t max)
     1657static void prepareJumpTableForImmediateSwitch(SimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, int32_t min, int32_t max)
    16581658{
    16591659    jumpTable.min = min;
     
    16631663        // We're emitting this after the clause labels should have been fixed, so
    16641664        // the labels should not be "forward" references
    1665         ASSERT(!labels[i]->isForwardLabel());
     1665        ASSERT(!labels[i]->isForward());
    16661666        jumpTable.add(keyForImmediateSwitch(nodes[i], min, max), labels[i]->offsetFrom(switchAddress));
    16671667    }
     
    16811681}
    16821682
    1683 static void prepareJumpTableForCharacterSwitch(SimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<LabelID>* labels, ExpressionNode** nodes, int32_t min, int32_t max)
     1683static void prepareJumpTableForCharacterSwitch(SimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, int32_t min, int32_t max)
    16841684{
    16851685    jumpTable.min = min;
     
    16891689        // We're emitting this after the clause labels should have been fixed, so
    16901690        // the labels should not be "forward" references
    1691         ASSERT(!labels[i]->isForwardLabel());
     1691        ASSERT(!labels[i]->isForward());
    16921692        jumpTable.add(keyForCharacterSwitch(nodes[i], min, max), labels[i]->offsetFrom(switchAddress));
    16931693    }
    16941694}
    16951695
    1696 static void prepareJumpTableForStringSwitch(StringJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<LabelID>* labels, ExpressionNode** nodes)
     1696static void prepareJumpTableForStringSwitch(StringJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes)
    16971697{
    16981698    for (uint32_t i = 0; i < clauseCount; ++i) {
    16991699        // We're emitting this after the clause labels should have been fixed, so
    17001700        // the labels should not be "forward" references
    1701         ASSERT(!labels[i]->isForwardLabel());
     1701        ASSERT(!labels[i]->isForward());
    17021702       
    17031703        ASSERT(nodes[i]->isString());
     
    17121712}
    17131713
    1714 void BytecodeGenerator::endSwitch(uint32_t clauseCount, RefPtr<LabelID>* labels, ExpressionNode** nodes, LabelID* defaultLabel, int32_t min, int32_t max)
     1714void BytecodeGenerator::endSwitch(uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, Label* defaultLabel, int32_t min, int32_t max)
    17151715{
    17161716    SwitchInfo switchInfo = m_switchContextStack.last();
  • trunk/JavaScriptCore/bytecompiler/CodeGenerator.h

    r38428 r38430  
    5252
    5353    struct FinallyContext {
    54         LabelID* finallyAddr;
     54        Label* finallyAddr;
    5555        RegisterID* retAddrDst;
    5656    };
     
    151151
    152152        PassRefPtr<LabelScope> newLabelScope(LabelScope::Type, const Identifier* = 0);
    153         PassRefPtr<LabelID> newLabel();
     153        PassRefPtr<Label> newLabel();
    154154
    155155        // The emitNode functions are just syntactic sugar for calling
     
    282282        RegisterID* emitConstruct(RegisterID* dst, RegisterID* func, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
    283283
    284         PassRefPtr<LabelID> emitLabel(LabelID*);
    285         PassRefPtr<LabelID> emitJump(LabelID* target);
    286         PassRefPtr<LabelID> emitJumpIfTrue(RegisterID* cond, LabelID* target);
    287         PassRefPtr<LabelID> emitJumpIfFalse(RegisterID* cond, LabelID* target);
    288         PassRefPtr<LabelID> emitJumpScopes(LabelID* target, int targetScopeDepth);
    289 
    290         PassRefPtr<LabelID> emitJumpSubroutine(RegisterID* retAddrDst, LabelID*);
     284        PassRefPtr<Label> emitLabel(Label*);
     285        PassRefPtr<Label> emitJump(Label* target);
     286        PassRefPtr<Label> emitJumpIfTrue(RegisterID* cond, Label* target);
     287        PassRefPtr<Label> emitJumpIfFalse(RegisterID* cond, Label* target);
     288        PassRefPtr<Label> emitJumpScopes(Label* target, int targetScopeDepth);
     289
     290        PassRefPtr<Label> emitJumpSubroutine(RegisterID* retAddrDst, Label*);
    291291        void emitSubroutineReturn(RegisterID* retAddrSrc);
    292292
    293293        RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base) { return emitUnaryOp(op_get_pnames, dst, base, ResultType::unknown()); }
    294         RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* iter, LabelID* target);
    295 
    296         RegisterID* emitCatch(RegisterID*, LabelID* start, LabelID* end);
     294        RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* iter, Label* target);
     295
     296        RegisterID* emitCatch(RegisterID*, Label* start, Label* end);
    297297        void emitThrow(RegisterID* exc) { emitUnaryNoDstOp(op_throw, exc); }
    298298        RegisterID* emitNewError(RegisterID* dst, ErrorType type, JSValue* message);
     
    306306        int scopeDepth() { return m_dynamicScopeDepth + m_finallyDepth; }
    307307
    308         void pushFinallyContext(LabelID* target, RegisterID* returnAddrDst);
     308        void pushFinallyContext(Label* target, RegisterID* returnAddrDst);
    309309        void popFinallyContext();
    310310
     
    313313
    314314        void beginSwitch(RegisterID*, SwitchInfo::SwitchType);
    315         void endSwitch(uint32_t clauseCount, RefPtr<LabelID>*, ExpressionNode**, LabelID* defaultLabel, int32_t min, int32_t range);
     315        void endSwitch(uint32_t clauseCount, RefPtr<Label>*, ExpressionNode**, Label* defaultLabel, int32_t min, int32_t range);
    316316
    317317        CodeType codeType() const { return m_codeType; }
     
    324324        void rewindUnaryOp();
    325325
    326         PassRefPtr<LabelID> emitComplexJumpScopes(LabelID* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
     326        PassRefPtr<Label> emitComplexJumpScopes(Label* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
    327327
    328328        struct JSValueHashTraits : HashTraits<JSValue*> {
     
    424424        SegmentedVector<RegisterID, 512> m_globals;
    425425        SegmentedVector<LabelScope, 256> m_labelScopes;
    426         SegmentedVector<LabelID, 256> m_labels;
     426        SegmentedVector<Label, 256> m_labels;
    427427        RefPtr<RegisterID> m_lastConstant;
    428428        int m_finallyDepth;
  • trunk/JavaScriptCore/bytecompiler/LabelScope.h

    r38196 r38430  
    4141        enum Type { Loop, Switch, NamedLabel };
    4242
    43         LabelScope(Type type, const Identifier* name, int scopeDepth, PassRefPtr<LabelID> breakTarget, PassRefPtr<LabelID> continueTarget)
     43        LabelScope(Type type, const Identifier* name, int scopeDepth, PassRefPtr<Label> breakTarget, PassRefPtr<Label> continueTarget)
    4444            : m_refCount(0)
    4545            , m_type(type)
     
    5959        int refCount() const { return m_refCount; }
    6060
    61         LabelID* breakTarget() const { return m_breakTarget.get(); }
    62         LabelID* continueTarget() const { return m_continueTarget.get(); }
     61        Label* breakTarget() const { return m_breakTarget.get(); }
     62        Label* continueTarget() const { return m_continueTarget.get(); }
    6363
    6464        Type type() const { return m_type; }
     
    7171        const Identifier* m_name;
    7272        int m_scopeDepth;
    73         RefPtr<LabelID> m_breakTarget;
    74         RefPtr<LabelID> m_continueTarget;
     73        RefPtr<Label> m_breakTarget;
     74        RefPtr<Label> m_continueTarget;
    7575    };
    7676
Note: See TracChangeset for help on using the changeset viewer.