Changeset 36412 in webkit for trunk/JavaScriptCore/VM/CTI.cpp


Ignore:
Timestamp:
Sep 14, 2008, 5:26:08 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-14 Cameron Zwarich <[email protected]>

Reviewed by Maciej Stachowiak.

Bug 20827: the 'typeof' operator is slow
<https://bugs.webkit.org/show_bug.cgi?id=20827>

Optimize the 'typeof' operator when its result is compared to a constant
string.

This is a 5.5% speedup on the V8 Earley-Boyer test.

JavaScriptCore:

  • VM/CTI.cpp: (JSC::CTI::privateCompileMainPass):
  • VM/CodeBlock.cpp: (JSC::CodeBlock::dump):
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitEqualityOp):
  • VM/CodeGenerator.h:
  • VM/Machine.cpp: (JSC::jsIsObjectType): (JSC::jsIsFunctionType): (JSC::Machine::privateExecute): (JSC::Machine::cti_op_is_undefined): (JSC::Machine::cti_op_is_boolean): (JSC::Machine::cti_op_is_number): (JSC::Machine::cti_op_is_string): (JSC::Machine::cti_op_is_object): (JSC::Machine::cti_op_is_function):
  • VM/Machine.h:
  • VM/Opcode.h:
  • kjs/nodes.cpp: (JSC::BinaryOpNode::emitCode): (JSC::EqualNode::emitCode): (JSC::StrictEqualNode::emitCode):
  • kjs/nodes.h:

LayoutTests:

  • fast/js/resources/typeof-codegen-crash.js: Added.
  • fast/js/typeof-codegen-crash-expected.txt: Added.
  • fast/js/typeof-codegen-crash.html: Added.
File:
1 edited

Legend:

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

    r36408 r36412  
    375375    }
    376376
     377#define CTI_COMPILE_UNARY_OP(name) \
     378    case name: { \
     379        emitGetPutArg(instruction[i + 2].u.operand, 0, X86::ecx); \
     380        emitCall(i, Machine::cti_##name); \
     381        emitPutResult(instruction[i + 1].u.operand); \
     382        i += 3; \
     383        break; \
     384    }
     385
    377386#if ENABLE(SAMPLING_TOOL)
    378387OpcodeID currentOpcodeID = static_cast<OpcodeID>(-1);
     
    11511160            break;
    11521161        }
    1153         case op_typeof: {
    1154             emitGetPutArg(instruction[i + 2].u.operand, 0, X86::ecx);
    1155             emitCall(i, Machine::cti_op_typeof);
    1156             emitPutResult(instruction[i + 1].u.operand);
    1157             i += 3;
    1158             break;
    1159         }
     1162        CTI_COMPILE_UNARY_OP(op_typeof)
     1163        CTI_COMPILE_UNARY_OP(op_is_undefined)
     1164        CTI_COMPILE_UNARY_OP(op_is_boolean)
     1165        CTI_COMPILE_UNARY_OP(op_is_number)
     1166        CTI_COMPILE_UNARY_OP(op_is_string)
     1167        CTI_COMPILE_UNARY_OP(op_is_object)
     1168        CTI_COMPILE_UNARY_OP(op_is_function)
    11601169        CTI_COMPILE_BINARY_OP(op_stricteq)
    11611170        CTI_COMPILE_BINARY_OP(op_nstricteq)
Note: See TracChangeset for help on using the changeset viewer.