Ignore:
Timestamp:
Jul 24, 2013, 9:00:58 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: rationalize DFG::CapabilityLevel and DFGCapabilities.[h|cpp]
https://bugs.webkit.org/show_bug.cgi?id=116696

Reviewed by Sam Weinig.

Make it so that all capability calculation is funneled through one function, which tells
you everything you wanted to know: can it be inlined, and can it be compiled.

This work will help with https://bugs.webkit.org/show_bug.cgi?id=116557, since now the
JIT has a fairly authoritative answer to the "can it be inlined" question.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):
(JSC::ProgramCodeBlock::capabilityLevelInternal):
(JSC::EvalCodeBlock::capabilityLevelInternal):
(JSC::FunctionCodeBlock::capabilityLevelInternal):

  • bytecode/CodeBlock.h:

(CodeBlock):
(JSC::CodeBlock::capabilityLevel):
(JSC::CodeBlock::capabilityLevelState):
(ProgramCodeBlock):
(EvalCodeBlock):
(FunctionCodeBlock):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::debugFail):
(DFG):
(JSC::DFG::canInlineResolveOperations):
(JSC::DFG::capabilityLevel):

  • dfg/DFGCapabilities.h:

(DFG):
(JSC::DFG::capabilityLevel):
(JSC::DFG::evalCapabilityLevel):
(JSC::DFG::programCapabilityLevel):
(JSC::DFG::functionForCallCapabilityLevel):
(JSC::DFG::functionForConstructCapabilityLevel):
(JSC::DFG::canInlineFunctionForCall):
(JSC::DFG::canInlineFunctionForClosureCall):
(JSC::DFG::canInlineFunctionForConstruct):

  • dfg/DFGCommon.h:

(JSC::DFG::canCompile):
(DFG):
(JSC::DFG::canInline):
(JSC::DFG::leastUpperBound):

  • dfg/DFGDriver.cpp:

(JSC::DFG::compile):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • 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

    r153145 r153179  
    11/*
    2  * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4848bool mightInlineFunctionForConstruct(CodeBlock*);
    4949
    50 // Opcode checking.
    51 inline bool canInlineResolveOperations(ResolveOperations* operations)
    52 {
    53     for (unsigned i = 0; i < operations->size(); i++) {
    54         switch (operations->data()[i].m_operation) {
    55         case ResolveOperation::ReturnGlobalObjectAsBase:
    56         case ResolveOperation::SetBaseToGlobal:
    57         case ResolveOperation::SetBaseToUndefined:
    58         case ResolveOperation::GetAndReturnGlobalProperty:
    59         case ResolveOperation::GetAndReturnGlobalVar:
    60         case ResolveOperation::GetAndReturnGlobalVarWatchable:
    61         case ResolveOperation::SkipScopes:
    62         case ResolveOperation::SetBaseToScope:
    63         case ResolveOperation::ReturnScopeAsBase:
    64         case ResolveOperation::GetAndReturnScopedVar:
    65             continue;
     50inline CapabilityLevel capabilityLevel(OpcodeID opcodeID, CodeBlock* codeBlock, Instruction* pc);
    6651
    67         case ResolveOperation::Fail:
    68             // Fall-back resolves don't know how to deal with the ExecState* having a different
    69             // global object (and scope) than the inlined code that is invoking that resolve.
    70             return false;
    71 
    72         case ResolveOperation::SkipTopScopeNode:
    73             // We don't inline code blocks that create activations. Creation of
    74             // activations is the only thing that leads to SkipTopScopeNode.
    75             return false;
    76 
    77         case ResolveOperation::CheckForDynamicEntriesBeforeGlobalScope:
    78             // This would be easy to support in all cases.
    79             return false;
    80         }
    81     }
    82     return true;
    83 }
    84 
    85 inline CapabilityLevel canCompileOpcode(OpcodeID opcodeID, CodeBlock*, Instruction*)
    86 {
    87     switch (opcodeID) {
    88     case op_enter:
    89     case op_to_this:
    90     case op_create_this:
    91     case op_get_callee:
    92     case op_bitand:
    93     case op_bitor:
    94     case op_bitxor:
    95     case op_rshift:
    96     case op_lshift:
    97     case op_urshift:
    98     case op_inc:
    99     case op_dec:
    100     case op_add:
    101     case op_sub:
    102     case op_negate:
    103     case op_mul:
    104     case op_mod:
    105     case op_div:
    106 #if ENABLE(DEBUG_WITH_BREAKPOINT)
    107     case op_debug:
    108 #endif
    109     case op_mov:
    110     case op_check_has_instance:
    111     case op_instanceof:
    112     case op_is_undefined:
    113     case op_is_boolean:
    114     case op_is_number:
    115     case op_is_string:
    116     case op_is_object:
    117     case op_is_function:
    118     case op_not:
    119     case op_less:
    120     case op_lesseq:
    121     case op_greater:
    122     case op_greatereq:
    123     case op_eq:
    124     case op_eq_null:
    125     case op_stricteq:
    126     case op_neq:
    127     case op_neq_null:
    128     case op_nstricteq:
    129     case op_get_by_val:
    130     case op_put_by_val:
    131     case op_get_by_id:
    132     case op_get_by_id_out_of_line:
    133     case op_get_array_length:
    134     case op_put_by_id:
    135     case op_put_by_id_out_of_line:
    136     case op_put_by_id_transition_direct:
    137     case op_put_by_id_transition_direct_out_of_line:
    138     case op_put_by_id_transition_normal:
    139     case op_put_by_id_transition_normal_out_of_line:
    140     case op_init_global_const_nop:
    141     case op_init_global_const:
    142     case op_init_global_const_check:
    143     case op_jmp:
    144     case op_jtrue:
    145     case op_jfalse:
    146     case op_jeq_null:
    147     case op_jneq_null:
    148     case op_jless:
    149     case op_jlesseq:
    150     case op_jgreater:
    151     case op_jgreatereq:
    152     case op_jnless:
    153     case op_jnlesseq:
    154     case op_jngreater:
    155     case op_jngreatereq:
    156     case op_loop_hint:
    157     case op_ret:
    158     case op_end:
    159     case op_call_put_result:
    160     case op_new_object:
    161     case op_new_array:
    162     case op_new_array_with_size:
    163     case op_new_array_buffer:
    164     case op_strcat:
    165     case op_to_primitive:
    166     case op_throw:
    167     case op_throw_static_error:
    168     case op_call:
    169     case op_construct:
    170     case op_new_regexp:
    171     case op_init_lazy_reg:
    172     case op_create_activation:
    173     case op_tear_off_activation:
    174     case op_create_arguments:
    175     case op_tear_off_arguments:
    176     case op_new_func:
    177     case op_new_func_exp:
    178     case op_get_argument_by_val:
    179     case op_get_arguments_length:
    180     case op_jneq_ptr:
    181     case op_put_to_base_variable:
    182     case op_put_to_base:
    183     case op_typeof:
    184     case op_to_number:
    185         return CanCompile;
    186        
    187     case op_call_varargs:
    188         return MayInline;
    189 
    190     case op_resolve:
    191     case op_resolve_global_property:
    192     case op_resolve_global_var:
    193     case op_resolve_scoped_var:
    194     case op_resolve_scoped_var_on_top_scope:
    195     case op_resolve_scoped_var_with_top_scope_check:
    196         return CanCompile;
    197 
    198     case op_get_scoped_var:
    199     case op_put_scoped_var:
    200         return CanCompile;
    201 
    202     case op_resolve_base_to_global:
    203     case op_resolve_base_to_global_dynamic:
    204     case op_resolve_base_to_scope:
    205     case op_resolve_base_to_scope_with_top_scope_check:
    206     case op_resolve_base:
    207     case op_resolve_with_base:
    208     case op_resolve_with_this:
    209         return CanCompile;
    210 
    211     default:
    212         return CannotCompile;
    213     }
    214 }
    215 
    216 inline bool canInlineOpcode(OpcodeID opcodeID, CodeBlock* codeBlock, Instruction* pc)
    217 {
    218     switch (opcodeID) {
    219     case op_resolve:
    220     case op_resolve_global_property:
    221     case op_resolve_global_var:
    222     case op_resolve_scoped_var:
    223     case op_resolve_scoped_var_on_top_scope:
    224     case op_resolve_scoped_var_with_top_scope_check:
    225         return canInlineResolveOperations(pc[3].u.resolveOperations);
    226 
    227     case op_resolve_base_to_global:
    228     case op_resolve_base_to_global_dynamic:
    229     case op_resolve_base_to_scope:
    230     case op_resolve_base_to_scope_with_top_scope_check:
    231     case op_resolve_base:
    232     case op_resolve_with_base:
    233     case op_resolve_with_this:
    234         return canInlineResolveOperations(pc[4].u.resolveOperations);
    235 
    236     case op_get_scoped_var:
    237     case op_put_scoped_var:
    238         return !codeBlock->needsFullScopeChain();
    239 
    240     // Inlining doesn't correctly remap regular expression operands.
    241     case op_new_regexp:
    242        
    243     // We don't support inlining code that creates activations or has nested functions.
    244     case op_create_activation:
    245     case op_tear_off_activation:
    246     case op_new_func:
    247     case op_new_func_exp:
    248         return false;
    249        
    250     // Inlining supports op_call_varargs if it's a call that just forwards the caller's
    251     // arguments.
    252     case op_call_varargs:
    253         return codeBlock->usesArguments() && pc[3].u.operand == codeBlock->argumentsRegister();
    254        
    255     default:
    256         return canCompileOpcode(opcodeID, codeBlock, pc) == CanCompile;
    257     }
    258 }
    259 
    260 CapabilityLevel canCompileOpcodes(CodeBlock*);
    261 bool canInlineOpcodes(CodeBlock*);
     52CapabilityLevel capabilityLevel(CodeBlock*);
    26253#else // ENABLE(DFG_JIT)
    26354inline bool mightCompileEval(CodeBlock*) { return false; }
     
    26960inline bool mightInlineFunctionForConstruct(CodeBlock*) { return false; }
    27061
    271 inline CapabilityLevel canCompileOpcode(OpcodeID, CodeBlock*, Instruction*) { return CannotCompile; }
    272 inline bool canInlineOpcode(OpcodeID, CodeBlock*, Instruction*) { return false; }
    273 inline CapabilityLevel canCompileOpcodes(CodeBlock*) { return CannotCompile; }
    274 inline bool canInlineOpcodes(CodeBlock*) { return false; }
     62inline CapabilityLevel capabilityLevel(OpcodeID, CodeBlock*, Instruction*) { return CannotCompile; }
     63inline CapabilityLevel capabilityLevel(CodeBlock*) { return CannotCompile; }
    27564#endif // ENABLE(DFG_JIT)
    27665
    277 inline CapabilityLevel canCompileEval(CodeBlock* codeBlock)
     66inline CapabilityLevel evalCapabilityLevel(CodeBlock* codeBlock)
    27867{
    27968    if (!mightCompileEval(codeBlock))
    28069        return CannotCompile;
    28170   
    282     return canCompileOpcodes(codeBlock);
     71    return capabilityLevel(codeBlock);
    28372}
    28473
    285 inline CapabilityLevel canCompileProgram(CodeBlock* codeBlock)
     74inline CapabilityLevel programCapabilityLevel(CodeBlock* codeBlock)
    28675{
    28776    if (!mightCompileProgram(codeBlock))
    28877        return CannotCompile;
    28978   
    290     return canCompileOpcodes(codeBlock);
     79    return capabilityLevel(codeBlock);
    29180}
    29281
    293 inline CapabilityLevel canCompileFunctionForCall(CodeBlock* codeBlock)
     82inline CapabilityLevel functionForCallCapabilityLevel(CodeBlock* codeBlock)
    29483{
    29584    if (!mightCompileFunctionForCall(codeBlock))
    29685        return CannotCompile;
    29786   
    298     return canCompileOpcodes(codeBlock);
     87    return capabilityLevel(codeBlock);
    29988}
    30089
    301 inline CapabilityLevel canCompileFunctionForConstruct(CodeBlock* codeBlock)
     90inline CapabilityLevel functionForConstructCapabilityLevel(CodeBlock* codeBlock)
    30291{
    30392    if (!mightCompileFunctionForConstruct(codeBlock))
    30493        return CannotCompile;
    30594   
    306     return canCompileOpcodes(codeBlock);
     95    return capabilityLevel(codeBlock);
    30796}
    30897
    30998inline bool canInlineFunctionForCall(CodeBlock* codeBlock)
    31099{
    311     return mightInlineFunctionForCall(codeBlock) && canInlineOpcodes(codeBlock);
     100    return mightInlineFunctionForCall(codeBlock) && canInline(capabilityLevel(codeBlock));
    312101}
    313102
    314103inline bool canInlineFunctionForClosureCall(CodeBlock* codeBlock)
    315104{
    316     return mightInlineFunctionForClosureCall(codeBlock) && canInlineOpcodes(codeBlock);
     105    return mightInlineFunctionForClosureCall(codeBlock) && canInline(capabilityLevel(codeBlock));
    317106}
    318107
    319108inline bool canInlineFunctionForConstruct(CodeBlock* codeBlock)
    320109{
    321     return mightInlineFunctionForConstruct(codeBlock) && canInlineOpcodes(codeBlock);
     110    return mightInlineFunctionForConstruct(codeBlock) && canInline(capabilityLevel(codeBlock));
    322111}
    323112
Note: See TracChangeset for help on using the changeset viewer.