Ignore:
Timestamp:
Sep 3, 2013, 5:26:57 PM (12 years ago)
Author:
[email protected]
Message:

Converting StackIterator to a callback interface.
https://bugs.webkit.org/show_bug.cgi?id=120564.

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

  • API/JSContextRef.cpp:

(BacktraceFunctor::BacktraceFunctor):
(BacktraceFunctor::operator()):
(JSContextCreateBacktrace):

  • interpreter/CallFrame.cpp:
  • interpreter/CallFrame.h:
  • interpreter/Interpreter.cpp:

(JSC::DumpRegisterFunctor::DumpRegisterFunctor):
(JSC::DumpRegisterFunctor::operator()):
(JSC::Interpreter::dumpRegisters):
(JSC::unwindCallFrame):
(JSC::GetStackTraceFunctor::GetStackTraceFunctor):
(JSC::GetStackTraceFunctor::operator()):
(JSC::Interpreter::getStackTrace):
(JSC::Interpreter::stackTraceAsString):
(JSC::UnwindFunctor::UnwindFunctor):
(JSC::UnwindFunctor::operator()):
(JSC::Interpreter::unwind):

  • interpreter/Interpreter.h:
  • interpreter/StackIterator.cpp:

(JSC::StackIterator::numberOfFrames):
(JSC::StackIterator::gotoFrameAtIndex):
(JSC::StackIterator::gotoNextFrameWithFilter):
(JSC::StackIterator::resetIterator):
(JSC::StackIterator::Frame::print):
(debugPrintCallFrame):
(DebugPrintStackFunctor::operator()):
(debugPrintStack): Added for debugging convenience.

  • interpreter/StackIterator.h:

(JSC::StackIterator::Frame::index):
(JSC::StackIterator::iterate):

  • jsc.cpp:

(FunctionJSCStackFunctor::FunctionJSCStackFunctor):
(FunctionJSCStackFunctor::operator()):
(functionJSCStack):

  • profiler/ProfileGenerator.cpp:

(JSC::AddParentForConsoleStartFunctor::AddParentForConsoleStartFunctor):
(JSC::AddParentForConsoleStartFunctor::foundParent):
(JSC::AddParentForConsoleStartFunctor::operator()):
(JSC::ProfileGenerator::addParentForConsoleStart):

  • runtime/JSFunction.cpp:

(JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor):
(JSC::RetrieveArgumentsFunctor::result):
(JSC::RetrieveArgumentsFunctor::operator()):
(JSC::retrieveArguments):
(JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor):
(JSC::RetrieveCallerFunctionFunctor::result):
(JSC::RetrieveCallerFunctionFunctor::operator()):
(JSC::retrieveCallerFunction):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::GlobalFuncProtoGetterFunctor::GlobalFuncProtoGetterFunctor):
(JSC::GlobalFuncProtoGetterFunctor::result):
(JSC::GlobalFuncProtoGetterFunctor::operator()):
(JSC::globalFuncProtoGetter):
(JSC::GlobalFuncProtoSetterFunctor::GlobalFuncProtoSetterFunctor):
(JSC::GlobalFuncProtoSetterFunctor::allowsAccess):
(JSC::GlobalFuncProtoSetterFunctor::operator()):
(JSC::globalFuncProtoSetter):

  • runtime/ObjectConstructor.cpp:

(JSC::ObjectConstructorGetPrototypeOfFunctor::ObjectConstructorGetPrototypeOfFunctor):
(JSC::ObjectConstructorGetPrototypeOfFunctor::result):
(JSC::ObjectConstructorGetPrototypeOfFunctor::operator()):
(JSC::objectConstructorGetPrototypeOf):

Source/WebCore:

No new tests.

  • bindings/js/JSXMLHttpRequestCustom.cpp:

(WebCore::SendFunctor::SendFunctor):
(WebCore::SendFunctor::hasViableFrame):
(WebCore::SendFunctor::operator()):
(WebCore::JSXMLHttpRequest::send):

  • bindings/js/ScriptCallStackFactory.cpp:

(WebCore::CreateScriptCallStackFunctor::CreateScriptCallStackFunctor):
(WebCore::CreateScriptCallStackFunctor::operator()):
(WebCore::createScriptCallStack):
(WebCore::CreateScriptCallStackForConsoleFunctor::CreateScriptCallStackForConsoleFunctor):
(WebCore::CreateScriptCallStackForConsoleFunctor::operator()):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r154902 r155013  
    707707}
    708708
     709class GlobalFuncProtoGetterFunctor {
     710public:
     711    GlobalFuncProtoGetterFunctor(JSObject* thisObject)
     712        : m_hasSkippedFirstFrame(false)
     713        , m_thisObject(thisObject)
     714        , m_result(JSValue::encode(jsUndefined()))
     715    {
     716    }
     717
     718    EncodedJSValue result() { return m_result; }
     719
     720    StackIterator::Status operator()(StackIterator& iter)
     721    {
     722        if (!m_hasSkippedFirstFrame) {
     723            m_hasSkippedFirstFrame = true;
     724            return StackIterator::Continue;
     725        }
     726
     727        if (m_thisObject->allowsAccessFrom(iter->callFrame()))
     728            m_result = JSValue::encode(m_thisObject->prototype());
     729
     730        return StackIterator::Done;
     731    }
     732
     733private:
     734    bool m_hasSkippedFirstFrame;
     735    JSObject* m_thisObject;
     736    EncodedJSValue m_result;
     737};
     738
    709739EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState* exec)
    710740{
     
    714744        return JSValue::encode(exec->thisValue().synthesizePrototype(exec));
    715745
     746    GlobalFuncProtoGetterFunctor functor(thisObject);
    716747    StackIterator iter = exec->begin();
    717     ++iter;
    718     if ((iter == exec->end()) || !thisObject->allowsAccessFrom(iter->callFrame()))
    719         return JSValue::encode(jsUndefined());
    720 
    721     return JSValue::encode(thisObject->prototype());
    722 }
     748    iter.iterate(functor);
     749    return functor.result();
     750}
     751
     752class GlobalFuncProtoSetterFunctor {
     753public:
     754    GlobalFuncProtoSetterFunctor(JSObject* thisObject)
     755        : m_hasSkippedFirstFrame(false)
     756        , m_allowsAccess(false)
     757        , m_thisObject(thisObject)
     758    {
     759    }
     760
     761    bool allowsAccess() const { return m_allowsAccess; }
     762
     763    StackIterator::Status operator()(StackIterator& iter)
     764    {
     765        if (!m_hasSkippedFirstFrame) {
     766            m_hasSkippedFirstFrame = true;
     767            return StackIterator::Continue;
     768        }
     769
     770        m_allowsAccess = m_thisObject->allowsAccessFrom(iter->callFrame());
     771        return StackIterator::Done;
     772    }
     773
     774private:
     775    bool m_hasSkippedFirstFrame;
     776    bool m_allowsAccess;
     777    JSObject* m_thisObject;
     778};
    723779
    724780EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState* exec)
     
    732788        return JSValue::encode(jsUndefined());
    733789
     790    GlobalFuncProtoSetterFunctor functor(thisObject);
    734791    StackIterator iter = exec->begin();
    735     ++iter;
    736     if ((iter == exec->end()) || !thisObject->allowsAccessFrom(iter->callFrame()))
     792    iter.iterate(functor);
     793    if (!functor.allowsAccess())
    737794        return JSValue::encode(jsUndefined());
    738795
Note: See TracChangeset for help on using the changeset viewer.