Ignore:
Timestamp:
Sep 6, 2013, 10:47:57 PM (12 years ago)
Author:
[email protected]
Message:

FTL should support Call/Construct in the worst way possible
https://bugs.webkit.org/show_bug.cgi?id=120916

Reviewed by Oliver Hunt.

This adds support for Call/Construct by just calling out to C code that uses
the JSC::call/JSC::construct runtime functions for making calls. This is slow
and terrible, but it dramatically extends FTL coverage.

Supporting calls in a meaningful way meant also supporting
GlobalVarWatchpoint.

The extension of coverage helped to find a bunch of bugs:

  • ObjectOrOtherUse was claimed to be supported in the FTL but speculate() didn't support it. That means that any node with an ObjectOrOtherUse edge that got DCE'd would cause the FTL to ICE.


  • There was a bad fall-through compileCompareStrictEq() that led to ICE.


  • The OSR exit reconstruction code was assuming it could do fast checks on node->child1() before even determining the type of node; that crashes if the node is HasVarArgs. Fixed by checking HasVarArgs first.


  • The OSR exit compiler was using the wrong peekOffset for CArgumentGetter. The default is 1, which assumes that you didn't push anything onto the stack after getting called. The OSR exit thunks push FP, so the offset should be 2.


This passes stress tests and is probably huge performance regression if you
--useExperimentalFTL=true. The regression will be fixed in
https://bugs.webkit.org/show_bug.cgi?id=113621.

  • dfg/DFGOperations.cpp:
  • dfg/DFGOperations.h:
  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLIntrinsicRepository.h:
  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileGlobalVarWatchpoint):
(JSC::FTL::LowerDFGToLLVM::compileCompareStrictEq):
(JSC::FTL::LowerDFGToLLVM::compileCallOrConstruct):
(JSC::FTL::LowerDFGToLLVM::speculate):
(JSC::FTL::LowerDFGToLLVM::speculateObjectOrOther):
(JSC::FTL::LowerDFGToLLVM::addExitArgumentForNode):

  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileStub):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r155023 r155243  
    22002200        jitCode->optimizeAfterWarmUp(codeBlock);
    22012201    return static_cast<char*>(address);
     2202}
     2203
     2204// FIXME: Make calls work well. Currently they're a pure regression.
     2205// https://bugs.webkit.org/show_bug.cgi?id=113621
     2206EncodedJSValue DFG_OPERATION operationFTLCall(ExecState* exec)
     2207{
     2208    ExecState* callerExec = exec->callerFrame();
     2209   
     2210    VM* vm = &callerExec->vm();
     2211    NativeCallFrameTracer tracer(vm, callerExec);
     2212   
     2213    JSValue callee = exec->calleeAsValue();
     2214    CallData callData;
     2215    CallType callType = getCallData(callee, callData);
     2216    if (callType == CallTypeNone) {
     2217        vm->throwException(callerExec, createNotAFunctionError(callerExec, callee));
     2218        return JSValue::encode(jsUndefined());
     2219    }
     2220   
     2221    return JSValue::encode(call(callerExec, callee, callType, callData, exec->thisValue(), exec));
     2222}
     2223
     2224// FIXME: Make calls work well. Currently they're a pure regression.
     2225// https://bugs.webkit.org/show_bug.cgi?id=113621
     2226EncodedJSValue DFG_OPERATION operationFTLConstruct(ExecState* exec)
     2227{
     2228    ExecState* callerExec = exec->callerFrame();
     2229   
     2230    VM* vm = &callerExec->vm();
     2231    NativeCallFrameTracer tracer(vm, callerExec);
     2232   
     2233    JSValue callee = exec->calleeAsValue();
     2234    ConstructData constructData;
     2235    ConstructType constructType = getConstructData(callee, constructData);
     2236    if (constructType == ConstructTypeNone) {
     2237        vm->throwException(callerExec, createNotAFunctionError(callerExec, callee));
     2238        return JSValue::encode(jsUndefined());
     2239    }
     2240   
     2241    return JSValue::encode(construct(callerExec, callee, constructType, constructData, exec));
    22022242}
    22032243#endif // ENABLE(FTL_JIT)
Note: See TracChangeset for help on using the changeset viewer.