2008-06-24 Cameron Zwarich <cwzwarich@uwaterloo.ca>
authorcwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jun 2008 00:41:40 +0000 (00:41 +0000)
committercwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jun 2008 00:41:40 +0000 (00:41 +0000)
        Reviewed by Maciej.

        Make the conversion of the pair (less, jtrue) to jless use register
        reference counting information for safety instead of requiring callers
        to decide whether it is safe.

        No changes on SunSpider codegen.

        * VM/CodeGenerator.cpp:
        (KJS::CodeGenerator::emitJumpIfTrue):
        * VM/CodeGenerator.h:
        * kjs/nodes.cpp:
        (KJS::DoWhileNode::emitCode):
        (KJS::WhileNode::emitCode):
        (KJS::ForNode::emitCode):
        (KJS::CaseBlockNode::emitCodeForBlock):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34784 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/VM/CodeGenerator.cpp
JavaScriptCore/VM/CodeGenerator.h
JavaScriptCore/kjs/nodes.cpp

index fa6a2779350712edba1e47b5489f9090ef333975..21a2cb29b4cbac8529797ec4fd0d680f1697572b 100644 (file)
@@ -1,3 +1,22 @@
+2008-06-24  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
+
+        Reviewed by Maciej.
+
+        Make the conversion of the pair (less, jtrue) to jless use register
+        reference counting information for safety instead of requiring callers
+        to decide whether it is safe.
+
+        No changes on SunSpider codegen.
+
+        * VM/CodeGenerator.cpp:
+        (KJS::CodeGenerator::emitJumpIfTrue):
+        * VM/CodeGenerator.h:
+        * kjs/nodes.cpp:
+        (KJS::DoWhileNode::emitCode):
+        (KJS::WhileNode::emitCode):
+        (KJS::ForNode::emitCode):
+        (KJS::CaseBlockNode::emitCodeForBlock):
+
 2008-06-24  Kevin McCullough  <kmccullough@apple.com>
 
         Reviewed by Tim.
index b5f3e5a006015c0111bd4240eef4897c636939a4..8b8335e660ef9964e439a1a332f8f067e97411d3 100644 (file)
@@ -425,7 +425,7 @@ PassRefPtr<LabelID> CodeGenerator::emitJump(LabelID* target)
     return target;
 }
 
-PassRefPtr<LabelID> CodeGenerator::emitJumpIfTrueMayCombine(RegisterID* cond, LabelID* target)
+PassRefPtr<LabelID> CodeGenerator::emitJumpIfTrue(RegisterID* cond, LabelID* target)
 {
     if (m_lastOpcodeID == op_less) {
         int dstIndex;
@@ -434,7 +434,7 @@ PassRefPtr<LabelID> CodeGenerator::emitJumpIfTrueMayCombine(RegisterID* cond, La
         
         retrieveLastBinaryOp(dstIndex, src1Index, src2Index);
         
-        if (cond->index() == dstIndex) {
+        if (cond->index() == dstIndex && !cond->refCount()) {
             rewindBinaryOp();
             emitOpcode(op_jless);
             instructions().append(src1Index);
@@ -444,11 +444,6 @@ PassRefPtr<LabelID> CodeGenerator::emitJumpIfTrueMayCombine(RegisterID* cond, La
         }
     }
     
-    return emitJumpIfTrue(cond, target);
-}
-
-PassRefPtr<LabelID> CodeGenerator::emitJumpIfTrue(RegisterID* cond, LabelID* target)
-{
     emitOpcode(op_jtrue);
     instructions().append(cond->index());
     instructions().append(target->offsetFrom(instructions().size()));
index 5ec4e35b4d88e098c8b3fff703658d4f69bdfc3d..1856cf100116d21ccd779d3671d7c8b1b977109d 100644 (file)
@@ -245,7 +245,6 @@ namespace KJS {
 
         PassRefPtr<LabelID> emitLabel(LabelID*);
         PassRefPtr<LabelID> emitJump(LabelID* target);
-        PassRefPtr<LabelID> emitJumpIfTrueMayCombine(RegisterID* cond, LabelID* target);
         PassRefPtr<LabelID> emitJumpIfTrue(RegisterID* cond, LabelID* target);
         PassRefPtr<LabelID> emitJumpIfFalse(RegisterID* cond, LabelID* target);
         PassRefPtr<LabelID> emitJumpScopes(LabelID* target, int targetScopeDepth);
index 48215c385b454ea6aeba7dfe21a84bc8838246ee..79e26230d1ffb650969f2ee583866f287661d11e 100644 (file)
@@ -1200,7 +1200,7 @@ RegisterID* DoWhileNode::emitCode(CodeGenerator& generator, RegisterID* dst)
     
     generator.emitLabel(continueTarget.get());
     RegisterID* cond = generator.emitNode(m_expr.get());
-    generator.emitJumpIfTrueMayCombine(cond, topOfLoop.get());
+    generator.emitJumpIfTrue(cond, topOfLoop.get());
     generator.emitLabel(breakTarget.get());
     return result.get();
 }
@@ -1222,7 +1222,7 @@ RegisterID* WhileNode::emitCode(CodeGenerator& generator, RegisterID* dst)
 
     generator.emitLabel(continueTarget.get());
     RegisterID* cond = generator.emitNode(m_expr.get());
-    generator.emitJumpIfTrueMayCombine(cond, topOfLoop.get());
+    generator.emitJumpIfTrue(cond, topOfLoop.get());
 
     generator.emitLabel(breakTarget.get());
     
@@ -1254,7 +1254,7 @@ RegisterID* ForNode::emitCode(CodeGenerator& generator, RegisterID* dst)
     generator.emitLabel(beforeCondition.get());
     if (m_expr2) {
         RegisterID* cond = generator.emitNode(m_expr2.get());
-        generator.emitJumpIfTrueMayCombine(cond, topOfLoop.get());
+        generator.emitJumpIfTrue(cond, topOfLoop.get());
     } else {
         generator.emitJump(topOfLoop.get());
     }
@@ -1422,14 +1422,14 @@ RegisterID* CaseBlockNode::emitCodeForBlock(CodeGenerator& generator, RegisterID
         RegisterID* clauseVal = generator.emitNode(list->getClause()->expr());
         generator.emitBinaryOp(op_stricteq, clauseVal, clauseVal, switchExpression);
         labelVector.append(generator.newLabel());
-        generator.emitJumpIfTrueMayCombine(clauseVal, labelVector[labelVector.size() - 1].get());
+        generator.emitJumpIfTrue(clauseVal, labelVector[labelVector.size() - 1].get());
     }
 
     for (ClauseListNode* list = m_list2.get(); list; list = list->getNext()) {
         RegisterID* clauseVal = generator.emitNode(list->getClause()->expr());
         generator.emitBinaryOp(op_stricteq, clauseVal, clauseVal, switchExpression);
         labelVector.append(generator.newLabel());
-        generator.emitJumpIfTrueMayCombine(clauseVal, labelVector[labelVector.size() - 1].get());
+        generator.emitJumpIfTrue(clauseVal, labelVector[labelVector.size() - 1].get());
     }
 
     RefPtr<LabelID> defaultLabel;