Ignore:
Timestamp:
May 23, 2012, 5:05:21 PM (13 years ago)
Author:
[email protected]
Message:

DFG should be able to optimize foo.apply(bar, arguments)
https://bugs.webkit.org/show_bug.cgi?id=86306

Reviewed by Gavin Barraclough.

Merge r116912 from dfgopt.

Enables compilation of op_jneq_ptr and some forms of op_call_varargs.

Also includes a bunch of bug fixes that were made necessary by the increased
pressure on the CFG simplifier.

This is a 1-2% win on V8.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::printCallOp):
(JSC::CodeBlock::CodeBlock):
(JSC::ProgramCodeBlock::canCompileWithDFGInternal):
(JSC::EvalCodeBlock::canCompileWithDFGInternal):
(JSC::FunctionCodeBlock::canCompileWithDFGInternal):

  • bytecode/CodeBlock.h:

(CodeBlock):
(JSC::CodeBlock::canCompileWithDFG):
(JSC::CodeBlock::canCompileWithDFGState):
(ProgramCodeBlock):
(EvalCodeBlock):
(FunctionCodeBlock):

  • dfg/DFGAbstractState.cpp:

(JSC::DFG::AbstractState::execute):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::processPhiStack):
(JSC::DFG::ByteCodeParser::parse):

  • dfg/DFGCFGSimplificationPhase.cpp:

(JSC::DFG::CFGSimplificationPhase::run):
(JSC::DFG::CFGSimplificationPhase::fixPossibleGetLocal):
(JSC::DFG::CFGSimplificationPhase::fixTailOperand):
(JSC::DFG::CFGSimplificationPhase::mergeBlocks):

  • dfg/DFGCSEPhase.cpp:

(JSC::DFG::CSEPhase::getLocalLoadElimination):
(CSEPhase):
(JSC::DFG::CSEPhase::setReplacement):
(JSC::DFG::CSEPhase::performNodeCSE):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::debugFail):
(DFG):
(JSC::DFG::canHandleOpcodes):
(JSC::DFG::canCompileOpcodes):
(JSC::DFG::canInlineOpcodes):

  • dfg/DFGCapabilities.h:

(JSC::DFG::canCompileOpcode):
(JSC::DFG::canInlineOpcode):
(DFG):
(JSC::DFG::canCompileOpcodes):
(JSC::DFG::canCompileEval):
(JSC::DFG::canCompileProgram):
(JSC::DFG::canCompileFunctionForCall):
(JSC::DFG::canCompileFunctionForConstruct):

  • dfg/DFGCommon.h:
  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::dump):

  • dfg/DFGNodeType.h:

(DFG):

  • dfg/DFGPredictionPropagationPhase.cpp:

(JSC::DFG::PredictionPropagationPhase::propagate):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::emitCall):
(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGValidate.cpp:

(Validate):
(JSC::DFG::Validate::validate):
(JSC::DFG::Validate::checkOperand):
(JSC::DFG::Validate::reportValidationContext):

  • jit/JIT.cpp:

(JSC::JIT::emitOptimizationCheck):
(JSC::JIT::privateCompileSlowCases):
(JSC::JIT::privateCompile):

  • jit/JIT.h:
  • jit/JITArithmetic.cpp:

(JSC::JIT::compileBinaryArithOp):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::privateCompilePutByIdTransition):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::privateCompilePutByIdTransition):

  • tools/CodeProfile.cpp:

(JSC::CodeProfile::sample):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.h

    r118240 r118270  
    11/*
    2  * Copyright (C) 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#include "Intrinsic.h"
     30#include "DFGCommon.h"
    3031#include "DFGNode.h"
    3132#include "Executable.h"
     
    6869
    6970// Opcode checking.
    70 inline bool canCompileOpcode(OpcodeID opcodeID)
     71inline CapabilityLevel canCompileOpcode(OpcodeID opcodeID, CodeBlock*, Instruction*)
    7172{
    7273    switch (opcodeID) {
     
    170171    case op_get_argument_by_val:
    171172    case op_get_arguments_length:
    172         return true;
    173        
     173    case op_jneq_ptr:
     174        return CanCompile;
     175       
     176    case op_call_varargs:
     177        return ShouldProfile;
     178
    174179    default:
    175         return false;
     180        return CannotCompile;
    176181    }
    177182}
    178183
    179 inline bool canInlineOpcode(OpcodeID opcodeID)
     184inline bool canInlineOpcode(OpcodeID opcodeID, CodeBlock* codeBlock, Instruction* pc)
    180185{
    181186    switch (opcodeID) {
     
    195200    // Inlining doesn't correctly remap regular expression operands.
    196201    case op_new_regexp:
    197         return false;
    198202       
    199203    // We don't support inlining code that creates activations or has nested functions.
     
    204208        return false;
    205209       
     210    // Inlining supports op_call_varargs if it's a call that just forwards the caller's
     211    // arguments.
     212    case op_call_varargs:
     213        return pc[3].u.operand == codeBlock->argumentsRegister();
     214       
    206215    default:
    207         return canCompileOpcode(opcodeID);
     216        return canCompileOpcode(opcodeID, codeBlock, pc) == CanCompile;
    208217    }
    209218}
    210219
    211 bool canCompileOpcodes(CodeBlock*);
     220CapabilityLevel canCompileOpcodes(CodeBlock*);
    212221bool canInlineOpcodes(CodeBlock*);
    213222#else // ENABLE(DFG_JIT)
     
    219228inline bool mightInlineFunctionForConstruct(CodeBlock*) { return false; }
    220229
    221 inline bool canCompileOpcode(OpcodeID) { return false; }
    222 inline bool canInlineOpcode(OpcodeID) { return false; }
    223 inline bool canCompileOpcodes(CodeBlock*) { return false; }
     230inline CapabilityLevel canCompileOpcode(OpcodeID, CodeBlock*, Instruction*) { return false; }
     231inline bool canInlineOpcode(OpcodeID, CodeBlock*, Instruction*) { return false; }
     232inline CapabilityLevel canCompileOpcodes(CodeBlock*) { return false; }
    224233inline bool canInlineOpcodes(CodeBlock*) { return false; }
    225234#endif // ENABLE(DFG_JIT)
    226235
    227 inline bool canCompileEval(CodeBlock* codeBlock)
    228 {
    229     return mightCompileEval(codeBlock) && canCompileOpcodes(codeBlock);
    230 }
    231 
    232 inline bool canCompileProgram(CodeBlock* codeBlock)
    233 {
    234     return mightCompileProgram(codeBlock) && canCompileOpcodes(codeBlock);
    235 }
    236 
    237 inline bool canCompileFunctionForCall(CodeBlock* codeBlock)
    238 {
    239     return mightCompileFunctionForCall(codeBlock) && canCompileOpcodes(codeBlock);
    240 }
    241 
    242 inline bool canCompileFunctionForConstruct(CodeBlock* codeBlock)
    243 {
    244     return mightCompileFunctionForConstruct(codeBlock) && canCompileOpcodes(codeBlock);
     236inline CapabilityLevel canCompileEval(CodeBlock* codeBlock)
     237{
     238    if (!mightCompileEval(codeBlock))
     239        return CannotCompile;
     240   
     241    return canCompileOpcodes(codeBlock);
     242}
     243
     244inline CapabilityLevel canCompileProgram(CodeBlock* codeBlock)
     245{
     246    if (!mightCompileProgram(codeBlock))
     247        return CannotCompile;
     248   
     249    return canCompileOpcodes(codeBlock);
     250}
     251
     252inline CapabilityLevel canCompileFunctionForCall(CodeBlock* codeBlock)
     253{
     254    if (!mightCompileFunctionForCall(codeBlock))
     255        return CannotCompile;
     256   
     257    return canCompileOpcodes(codeBlock);
     258}
     259
     260inline CapabilityLevel canCompileFunctionForConstruct(CodeBlock* codeBlock)
     261{
     262    if (!mightCompileFunctionForConstruct(codeBlock))
     263        return CannotCompile;
     264   
     265    return canCompileOpcodes(codeBlock);
    245266}
    246267
Note: See TracChangeset for help on using the changeset viewer.