Ignore:
Timestamp:
Jun 15, 2008, 2:30:56 AM (17 years ago)
Author:
[email protected]
Message:

2008-06-15 Cameron Zwarich <[email protected]>

Reviewed by Maciej.

Bug 19484: More instructions needs to use temporary registers
<https://bugs.webkit.org/show_bug.cgi?id=19484>

Fix codegen for all binary operations so that temporaries are used if
necessary. This was done by making BinaryOpNode and ReverseBinaryOpNode
subclasses of ExpressionNode, and eliminating the custom emitCode()
methods for the individual node classes.

This only adds 3 new instructions to SunSpider code, and there is no
difference in SunSpider execution time.

JavaScriptCore:

  • VM/CodeGenerator.cpp: (KJS::CodeGenerator::emitBitNot): (KJS::CodeGenerator::emitBinaryOp):
  • VM/CodeGenerator.h:
  • kjs/grammar.y:
  • kjs/nodes.cpp: (KJS::PreIncResolveNode::emitCode): (KJS::PreDecResolveNode::emitCode): (KJS::BinaryOpNode::emitCode): (KJS::ReverseBinaryOpNode::emitCode): (KJS::emitReadModifyAssignment): (KJS::CaseBlockNode::emitCodeForBlock):
  • kjs/nodes.h: (KJS::BinaryOpNode::BinaryOpNode): (KJS::ReverseBinaryOpNode::ReverseBinaryOpNode): (KJS::MultNode::): (KJS::DivNode::): (KJS::DivNode::precedence): (KJS::ModNode::): (KJS::ModNode::precedence): (KJS::AddNode::): (KJS::AddNode::precedence): (KJS::SubNode::): (KJS::SubNode::precedence): (KJS::LeftShiftNode::): (KJS::LeftShiftNode::precedence): (KJS::RightShiftNode::): (KJS::RightShiftNode::precedence): (KJS::UnsignedRightShiftNode::): (KJS::UnsignedRightShiftNode::precedence): (KJS::LessNode::): (KJS::LessNode::precedence): (KJS::GreaterNode::): (KJS::GreaterNode::precedence): (KJS::LessEqNode::): (KJS::LessEqNode::precedence): (KJS::GreaterEqNode::): (KJS::GreaterEqNode::precedence): (KJS::InstanceOfNode::): (KJS::InstanceOfNode::precedence): (KJS::InNode::): (KJS::InNode::precedence): (KJS::EqualNode::): (KJS::EqualNode::precedence): (KJS::NotEqualNode::): (KJS::NotEqualNode::precedence): (KJS::StrictEqualNode::): (KJS::StrictEqualNode::precedence): (KJS::NotStrictEqualNode::): (KJS::NotStrictEqualNode::precedence): (KJS::BitAndNode::): (KJS::BitAndNode::precedence): (KJS::BitOrNode::): (KJS::BitOrNode::precedence): (KJS::BitXOrNode::): (KJS::BitXOrNode::precedence):
  • kjs/nodes2string.cpp: (KJS::LessNode::streamTo): (KJS::GreaterNode::streamTo): (KJS::LessEqNode::streamTo): (KJS::GreaterEqNode::streamTo): (KJS::InstanceOfNode::streamTo): (KJS::InNode::streamTo): (KJS::EqualNode::streamTo): (KJS::NotEqualNode::streamTo): (KJS::StrictEqualNode::streamTo): (KJS::NotStrictEqualNode::streamTo): (KJS::BitAndNode::streamTo): (KJS::BitXOrNode::streamTo): (KJS::BitOrNode::streamTo):

LayoutTests:

  • fast/js/codegen-temporaries-expected.txt:
  • fast/js/resources/codegen-temporaries.js:
File:
1 edited

Legend:

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

    r34555 r34562  
    518518}
    519519
    520 RegisterID* CodeGenerator::emitEqual(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    521 {
    522     emitOpcode(op_eq);
    523     instructions().append(dst->index());
    524     instructions().append(src1->index());
    525     instructions().append(src2->index());
    526     return dst;
    527 }
    528 
    529 RegisterID* CodeGenerator::emitNotEqual(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    530 {
    531     emitOpcode(op_neq);
    532     instructions().append(dst->index());
    533     instructions().append(src1->index());
    534     instructions().append(src2->index());
    535     return dst;
    536 }
    537 
    538 RegisterID* CodeGenerator::emitStrictEqual(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    539 {
    540     emitOpcode(op_stricteq);
    541     instructions().append(dst->index());
    542     instructions().append(src1->index());
    543     instructions().append(src2->index());
    544     return dst;
    545 }
    546 
    547 RegisterID* CodeGenerator::emitNotStrictEqual(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    548 {
    549     emitOpcode(op_nstricteq);
    550     instructions().append(dst->index());
    551     instructions().append(src1->index());
    552     instructions().append(src2->index());
    553     return dst;
    554 }
    555 
    556 RegisterID* CodeGenerator::emitLess(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    557 {
    558     emitOpcode(op_less);
    559     instructions().append(dst->index());
    560     instructions().append(src1->index());
    561     instructions().append(src2->index());
    562     return dst;
    563 }
    564 
    565 RegisterID* CodeGenerator::emitLessEq(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    566 {
    567     emitOpcode(op_lesseq);
    568     instructions().append(dst->index());
    569     instructions().append(src1->index());
    570     instructions().append(src2->index());
    571     return dst;
    572 }
    573 
    574520RegisterID* CodeGenerator::emitPreInc(RegisterID* srcDst)
    575521{
     
    618564}
    619565
    620 RegisterID* CodeGenerator::emitAdd(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    621 {
    622     emitOpcode(op_add);
     566RegisterID* CodeGenerator::emitBitNot(RegisterID* dst, RegisterID* src)
     567{
     568    emitOpcode(op_bitnot);
     569    instructions().append(dst->index());
     570    instructions().append(src->index());
     571    return dst;
     572}
     573
     574RegisterID* CodeGenerator::emitBinaryOp(OpcodeID opcode, RegisterID* dst, RegisterID* src1, RegisterID* src2)
     575{
     576    emitOpcode(opcode);
    623577    instructions().append(dst->index());
    624578    instructions().append(src1->index());
    625579    instructions().append(src2->index());
    626     return dst;
    627 }
    628 
    629 RegisterID* CodeGenerator::emitMul(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    630 {
    631     emitOpcode(op_mul);
    632     instructions().append(dst->index());
    633     instructions().append(src1->index());
    634     instructions().append(src2->index());
    635     return dst;
    636 }
    637 
    638 RegisterID* CodeGenerator::emitDiv(RegisterID* dst, RegisterID* dividend, RegisterID* divisor)
    639 {
    640     emitOpcode(op_div);
    641     instructions().append(dst->index());
    642     instructions().append(dividend->index());
    643     instructions().append(divisor->index());
    644     return dst;
    645 }
    646 
    647 RegisterID* CodeGenerator::emitMod(RegisterID* dst, RegisterID* dividend, RegisterID* divisor)
    648 {
    649     emitOpcode(op_mod);
    650     instructions().append(dst->index());
    651     instructions().append(dividend->index());
    652     instructions().append(divisor->index());
    653     return dst;
    654 }
    655 
    656 RegisterID* CodeGenerator::emitSub(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    657 {
    658     emitOpcode(op_sub);
    659     instructions().append(dst->index());
    660     instructions().append(src1->index());
    661     instructions().append(src2->index());
    662     return dst;
    663 }
    664 
    665 RegisterID* CodeGenerator::emitLeftShift(RegisterID* dst, RegisterID* val, RegisterID* shift)
    666 {
    667     emitOpcode(op_lshift);
    668     instructions().append(dst->index());
    669     instructions().append(val->index());
    670     instructions().append(shift->index());
    671     return dst;
    672 }
    673 
    674 RegisterID* CodeGenerator::emitRightShift(RegisterID* dst, RegisterID* val, RegisterID* shift)
    675 {
    676     emitOpcode(op_rshift);
    677     instructions().append(dst->index());
    678     instructions().append(val->index());
    679     instructions().append(shift->index());
    680     return dst;
    681 }
    682 
    683 RegisterID* CodeGenerator::emitUnsignedRightShift(RegisterID* dst, RegisterID* val, RegisterID* shift)
    684 {
    685     emitOpcode(op_urshift);
    686     instructions().append(dst->index());
    687     instructions().append(val->index());
    688     instructions().append(shift->index());
    689     return dst;
    690 }
    691 
    692 RegisterID* CodeGenerator::emitBitAnd(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    693 {
    694     emitOpcode(op_bitand);
    695     instructions().append(dst->index());
    696     instructions().append(src1->index());
    697     instructions().append(src2->index());
    698     return dst;
    699 }
    700 
    701 RegisterID* CodeGenerator::emitBitXOr(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    702 {
    703     emitOpcode(op_bitxor);
    704     instructions().append(dst->index());
    705     instructions().append(src1->index());
    706     instructions().append(src2->index());
    707     return dst;
    708 }
    709 
    710 RegisterID* CodeGenerator::emitBitOr(RegisterID* dst, RegisterID* src1, RegisterID* src2)
    711 {
    712     emitOpcode(op_bitor);
    713     instructions().append(dst->index());
    714     instructions().append(src1->index());
    715     instructions().append(src2->index());
    716     return dst;
    717 }
    718 
    719 RegisterID* CodeGenerator::emitBitNot(RegisterID* dst, RegisterID* src)
    720 {
    721     emitOpcode(op_bitnot);
    722     instructions().append(dst->index());
    723     instructions().append(src->index());
    724580    return dst;
    725581}
Note: See TracChangeset for help on using the changeset viewer.