Changeset 38430 in webkit for trunk/JavaScriptCore/bytecompiler
- Timestamp:
- Nov 15, 2008, 2:33:58 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/bytecompiler
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/bytecompiler/CodeGenerator.cpp
r38428 r38430 485 485 } 486 486 487 PassRefPtr<Label ID> BytecodeGenerator::newLabel()487 PassRefPtr<Label> BytecodeGenerator::newLabel() 488 488 { 489 489 // Reclaim free label IDs. … … 496 496 } 497 497 498 PassRefPtr<Label ID> BytecodeGenerator::emitLabel(LabelID* l0)498 PassRefPtr<Label> BytecodeGenerator::emitLabel(Label* l0) 499 499 { 500 500 unsigned newLabelIndex = instructions().size(); … … 552 552 } 553 553 554 PassRefPtr<Label ID> BytecodeGenerator::emitJump(LabelID* target)555 { 556 emitOpcode(target->isForward Label() ? op_jmp : op_loop);554 PassRefPtr<Label> BytecodeGenerator::emitJump(Label* target) 555 { 556 emitOpcode(target->isForward() ? op_jmp : op_loop); 557 557 instructions().append(target->offsetFrom(instructions().size())); 558 558 return target; 559 559 } 560 560 561 PassRefPtr<Label ID> BytecodeGenerator::emitJumpIfTrue(RegisterID* cond, LabelID* target)562 { 563 if (m_lastOpcodeID == op_less && !target->isForward Label()) {561 PassRefPtr<Label> BytecodeGenerator::emitJumpIfTrue(RegisterID* cond, Label* target) 562 { 563 if (m_lastOpcodeID == op_less && !target->isForward()) { 564 564 int dstIndex; 565 565 int src1Index; … … 576 576 return target; 577 577 } 578 } else if (m_lastOpcodeID == op_lesseq && !target->isForward Label()) {578 } else if (m_lastOpcodeID == op_lesseq && !target->isForward()) { 579 579 int dstIndex; 580 580 int src1Index; … … 591 591 return target; 592 592 } 593 } else if (m_lastOpcodeID == op_eq_null && target->isForward Label()) {593 } else if (m_lastOpcodeID == op_eq_null && target->isForward()) { 594 594 int dstIndex; 595 595 int srcIndex; … … 604 604 return target; 605 605 } 606 } else if (m_lastOpcodeID == op_neq_null && target->isForward Label()) {606 } else if (m_lastOpcodeID == op_neq_null && target->isForward()) { 607 607 int dstIndex; 608 608 int srcIndex; … … 619 619 } 620 620 621 emitOpcode(target->isForward Label() ? op_jtrue : op_loop_if_true);621 emitOpcode(target->isForward() ? op_jtrue : op_loop_if_true); 622 622 instructions().append(cond->index()); 623 623 instructions().append(target->offsetFrom(instructions().size())); … … 625 625 } 626 626 627 PassRefPtr<Label ID> BytecodeGenerator::emitJumpIfFalse(RegisterID* cond, LabelID* target)628 { 629 ASSERT(target->isForward Label());627 PassRefPtr<Label> BytecodeGenerator::emitJumpIfFalse(RegisterID* cond, Label* target) 628 { 629 ASSERT(target->isForward()); 630 630 631 631 if (m_lastOpcodeID == op_less) { … … 1414 1414 } 1415 1415 1416 void BytecodeGenerator::pushFinallyContext(Label ID* target, RegisterID* retAddrDst)1416 void BytecodeGenerator::pushFinallyContext(Label* target, RegisterID* retAddrDst) 1417 1417 { 1418 1418 ControlFlowContext scope; … … 1501 1501 } 1502 1502 1503 PassRefPtr<Label ID> BytecodeGenerator::emitComplexJumpScopes(LabelID* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope)1503 PassRefPtr<Label> BytecodeGenerator::emitComplexJumpScopes(Label* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope) 1504 1504 { 1505 1505 while (topScope > bottomScope) { … … 1529 1529 // Otherwise we just use jmp_scopes to pop a group of scopes and go 1530 1530 // to the next instruction 1531 RefPtr<Label ID> nextInsn = newLabel();1531 RefPtr<Label> nextInsn = newLabel(); 1532 1532 instructions().append(nextInsn->offsetFrom(instructions().size())); 1533 1533 emitLabel(nextInsn.get()); … … 1546 1546 } 1547 1547 1548 PassRefPtr<Label ID> BytecodeGenerator::emitJumpScopes(LabelID* target, int targetScopeDepth)1548 PassRefPtr<Label> BytecodeGenerator::emitJumpScopes(Label* target, int targetScopeDepth) 1549 1549 { 1550 1550 ASSERT(scopeDepth() - targetScopeDepth >= 0); 1551 ASSERT(target->isForward Label());1551 ASSERT(target->isForward()); 1552 1552 1553 1553 size_t scopeDelta = scopeDepth() - targetScopeDepth; … … 1565 1565 } 1566 1566 1567 RegisterID* BytecodeGenerator::emitNextPropertyName(RegisterID* dst, RegisterID* iter, Label ID* target)1567 RegisterID* BytecodeGenerator::emitNextPropertyName(RegisterID* dst, RegisterID* iter, Label* target) 1568 1568 { 1569 1569 emitOpcode(op_next_pname); … … 1574 1574 } 1575 1575 1576 RegisterID* BytecodeGenerator::emitCatch(RegisterID* targetRegister, Label ID* start, LabelID* end)1576 RegisterID* BytecodeGenerator::emitCatch(RegisterID* targetRegister, Label* start, Label* end) 1577 1577 { 1578 1578 HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth, 0 }; … … 1592 1592 } 1593 1593 1594 PassRefPtr<Label ID> BytecodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, LabelID* finally)1594 PassRefPtr<Label> BytecodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, Label* finally) 1595 1595 { 1596 1596 emitOpcode(op_jsr); … … 1655 1655 } 1656 1656 1657 static void prepareJumpTableForImmediateSwitch(SimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label ID>* labels, ExpressionNode** nodes, int32_t min, int32_t max)1657 static void prepareJumpTableForImmediateSwitch(SimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, int32_t min, int32_t max) 1658 1658 { 1659 1659 jumpTable.min = min; … … 1663 1663 // We're emitting this after the clause labels should have been fixed, so 1664 1664 // the labels should not be "forward" references 1665 ASSERT(!labels[i]->isForward Label());1665 ASSERT(!labels[i]->isForward()); 1666 1666 jumpTable.add(keyForImmediateSwitch(nodes[i], min, max), labels[i]->offsetFrom(switchAddress)); 1667 1667 } … … 1681 1681 } 1682 1682 1683 static void prepareJumpTableForCharacterSwitch(SimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label ID>* labels, ExpressionNode** nodes, int32_t min, int32_t max)1683 static void prepareJumpTableForCharacterSwitch(SimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, int32_t min, int32_t max) 1684 1684 { 1685 1685 jumpTable.min = min; … … 1689 1689 // We're emitting this after the clause labels should have been fixed, so 1690 1690 // the labels should not be "forward" references 1691 ASSERT(!labels[i]->isForward Label());1691 ASSERT(!labels[i]->isForward()); 1692 1692 jumpTable.add(keyForCharacterSwitch(nodes[i], min, max), labels[i]->offsetFrom(switchAddress)); 1693 1693 } 1694 1694 } 1695 1695 1696 static void prepareJumpTableForStringSwitch(StringJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label ID>* labels, ExpressionNode** nodes)1696 static void prepareJumpTableForStringSwitch(StringJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes) 1697 1697 { 1698 1698 for (uint32_t i = 0; i < clauseCount; ++i) { 1699 1699 // We're emitting this after the clause labels should have been fixed, so 1700 1700 // the labels should not be "forward" references 1701 ASSERT(!labels[i]->isForward Label());1701 ASSERT(!labels[i]->isForward()); 1702 1702 1703 1703 ASSERT(nodes[i]->isString()); … … 1712 1712 } 1713 1713 1714 void BytecodeGenerator::endSwitch(uint32_t clauseCount, RefPtr<Label ID>* labels, ExpressionNode** nodes, LabelID* defaultLabel, int32_t min, int32_t max)1714 void BytecodeGenerator::endSwitch(uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, Label* defaultLabel, int32_t min, int32_t max) 1715 1715 { 1716 1716 SwitchInfo switchInfo = m_switchContextStack.last(); -
trunk/JavaScriptCore/bytecompiler/CodeGenerator.h
r38428 r38430 52 52 53 53 struct FinallyContext { 54 Label ID* finallyAddr;54 Label* finallyAddr; 55 55 RegisterID* retAddrDst; 56 56 }; … … 151 151 152 152 PassRefPtr<LabelScope> newLabelScope(LabelScope::Type, const Identifier* = 0); 153 PassRefPtr<Label ID> newLabel();153 PassRefPtr<Label> newLabel(); 154 154 155 155 // The emitNode functions are just syntactic sugar for calling … … 282 282 RegisterID* emitConstruct(RegisterID* dst, RegisterID* func, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset); 283 283 284 PassRefPtr<Label ID> emitLabel(LabelID*);285 PassRefPtr<Label ID> emitJump(LabelID* target);286 PassRefPtr<Label ID> emitJumpIfTrue(RegisterID* cond, LabelID* target);287 PassRefPtr<Label ID> emitJumpIfFalse(RegisterID* cond, LabelID* target);288 PassRefPtr<Label ID> emitJumpScopes(LabelID* target, int targetScopeDepth);289 290 PassRefPtr<Label ID> 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*); 291 291 void emitSubroutineReturn(RegisterID* retAddrSrc); 292 292 293 293 RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base) { return emitUnaryOp(op_get_pnames, dst, base, ResultType::unknown()); } 294 RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* iter, Label ID* target);295 296 RegisterID* emitCatch(RegisterID*, Label ID* start, LabelID* end);294 RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* iter, Label* target); 295 296 RegisterID* emitCatch(RegisterID*, Label* start, Label* end); 297 297 void emitThrow(RegisterID* exc) { emitUnaryNoDstOp(op_throw, exc); } 298 298 RegisterID* emitNewError(RegisterID* dst, ErrorType type, JSValue* message); … … 306 306 int scopeDepth() { return m_dynamicScopeDepth + m_finallyDepth; } 307 307 308 void pushFinallyContext(Label ID* target, RegisterID* returnAddrDst);308 void pushFinallyContext(Label* target, RegisterID* returnAddrDst); 309 309 void popFinallyContext(); 310 310 … … 313 313 314 314 void beginSwitch(RegisterID*, SwitchInfo::SwitchType); 315 void endSwitch(uint32_t clauseCount, RefPtr<Label ID>*, 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); 316 316 317 317 CodeType codeType() const { return m_codeType; } … … 324 324 void rewindUnaryOp(); 325 325 326 PassRefPtr<Label ID> emitComplexJumpScopes(LabelID* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope);326 PassRefPtr<Label> emitComplexJumpScopes(Label* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope); 327 327 328 328 struct JSValueHashTraits : HashTraits<JSValue*> { … … 424 424 SegmentedVector<RegisterID, 512> m_globals; 425 425 SegmentedVector<LabelScope, 256> m_labelScopes; 426 SegmentedVector<Label ID, 256> m_labels;426 SegmentedVector<Label, 256> m_labels; 427 427 RefPtr<RegisterID> m_lastConstant; 428 428 int m_finallyDepth; -
trunk/JavaScriptCore/bytecompiler/LabelScope.h
r38196 r38430 41 41 enum Type { Loop, Switch, NamedLabel }; 42 42 43 LabelScope(Type type, const Identifier* name, int scopeDepth, PassRefPtr<Label ID> breakTarget, PassRefPtr<LabelID> continueTarget)43 LabelScope(Type type, const Identifier* name, int scopeDepth, PassRefPtr<Label> breakTarget, PassRefPtr<Label> continueTarget) 44 44 : m_refCount(0) 45 45 , m_type(type) … … 59 59 int refCount() const { return m_refCount; } 60 60 61 Label ID* breakTarget() const { return m_breakTarget.get(); }62 Label ID* continueTarget() const { return m_continueTarget.get(); }61 Label* breakTarget() const { return m_breakTarget.get(); } 62 Label* continueTarget() const { return m_continueTarget.get(); } 63 63 64 64 Type type() const { return m_type; } … … 71 71 const Identifier* m_name; 72 72 int m_scopeDepth; 73 RefPtr<Label ID> m_breakTarget;74 RefPtr<Label ID> m_continueTarget;73 RefPtr<Label> m_breakTarget; 74 RefPtr<Label> m_continueTarget; 75 75 }; 76 76
Note:
See TracChangeset
for help on using the changeset viewer.