CallIdentifier createCallIdentifierFromFunctionImp(ExecState* exec, JSObject* function, const String& defaultSourceURL, int defaultLineNumber) { const String& name = getCalculatedDisplayName(exec, function); JSFunction* jsFunction = jsDynamicCast<JSFunction*>(function); if (jsFunction && !jsFunction->isHostFunction()) return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, jsFunction->jsExecutable()->sourceURL(), jsFunction->jsExecutable()->lineNo()); return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, defaultSourceURL, defaultLineNumber); }
CallIdentifier Profiler::createCallIdentifier(ExecState* exec, JSValue functionValue, const String& defaultSourceURL, int defaultLineNumber) { if (!functionValue) return CallIdentifier(GlobalCodeExecution, defaultSourceURL, defaultLineNumber); if (!functionValue.isObject()) return CallIdentifier("(unknown)", defaultSourceURL, defaultLineNumber); if (asObject(functionValue)->inherits(&JSFunction::s_info) || asObject(functionValue)->inherits(&InternalFunction::s_info)) return createCallIdentifierFromFunctionImp(exec, asObject(functionValue), defaultSourceURL, defaultLineNumber); return CallIdentifier(makeString("(", asObject(functionValue)->methodTable()->className(asObject(functionValue)), " object)"), defaultSourceURL, defaultLineNumber); }
CallIdentifier createCallIdentifier(JSObject* calledFunction) { if (calledFunction->inherits(&JSFunction::info)) return createCallIdentifierFromFunctionImp(static_cast<JSFunction*>(calledFunction)); if (calledFunction->inherits(&InternalFunction::info)) return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->functionName().ustring(), "", 0); UString name = "(" + calledFunction->className() + " object)"; return CallIdentifier(name, 0, 0); }
CallIdentifier LegacyProfiler::createCallIdentifier(ExecState* exec, JSValue functionValue, const String& defaultSourceURL, unsigned defaultLineNumber, unsigned defaultColumnNumber) { if (!functionValue) return CallIdentifier(ASCIILiteral(GlobalCodeExecution), defaultSourceURL, defaultLineNumber, defaultColumnNumber); if (!functionValue.isObject()) return CallIdentifier(ASCIILiteral("(unknown)"), defaultSourceURL, defaultLineNumber, defaultColumnNumber); if (asObject(functionValue)->inherits(JSFunction::info()) || asObject(functionValue)->inherits(InternalFunction::info())) return createCallIdentifierFromFunctionImp(exec, asObject(functionValue), defaultSourceURL, defaultLineNumber, defaultColumnNumber); return CallIdentifier(asObject(functionValue)->methodTable()->className(asObject(functionValue)), defaultSourceURL, defaultLineNumber, defaultColumnNumber); }
CallIdentifier Profiler::createCallIdentifier(ExecState* exec, JSObject* calledFunction, const UString& defaultSourceURL, int defaultLineNumber) { if (!calledFunction) return CallIdentifier(GlobalCodeExecution, defaultSourceURL, defaultLineNumber); if (calledFunction->inherits(&JSFunction::info)) return createCallIdentifierFromFunctionImp(exec, static_cast<JSFunction*>(calledFunction)); if (calledFunction->inherits(&InternalFunction::info)) return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->name(exec), defaultSourceURL, defaultLineNumber); UString name = "(" + calledFunction->className() + " object)"; return CallIdentifier(name, defaultSourceURL, defaultLineNumber); }
CallIdentifier Profiler::createCallIdentifier(TiExcState* exec, TiValue functionValue, const UString& defaultSourceURL, int defaultLineNumber) { if (!functionValue) return CallIdentifier(GlobalCodeExecution, defaultSourceURL, defaultLineNumber); if (!functionValue.isObject()) return CallIdentifier("(unknown)", defaultSourceURL, defaultLineNumber); if (asObject(functionValue)->inherits(&TiFunction::info)) { TiFunction* function = asFunction(functionValue); if (!function->executable()->isHostFunction()) return createCallIdentifierFromFunctionImp(exec, function); } if (asObject(functionValue)->inherits(&InternalFunction::info)) return CallIdentifier(static_cast<InternalFunction*>(asObject(functionValue))->name(exec), defaultSourceURL, defaultLineNumber); return CallIdentifier(makeString("(", asObject(functionValue)->className(), " object)"), defaultSourceURL, defaultLineNumber); }
void Profiler::didExecute(TiExcState* callerCallFrame, const UString& ident) { ASSERT(!m_currentProfiles.isEmpty()); CallIdentifier callIdentifier = CallIdentifier(ident, "", 0); dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::didExecute, callIdentifier, callerCallFrame->lexicalGlobalObject()->profileGroup()); }
Profile::Profile(const UString& title, unsigned uid) : m_title(title) , m_uid(uid) { // FIXME: When multi-threading is supported this will be a vector and calls // into the profiler will need to know which thread it is executing on. m_head = ProfileNode::create(CallIdentifier("Thread_1", 0, 0), 0, 0); }
CallIdentifier createCallIdentifierFromFunctionImp(JSFunction* functionImp) { UString name = functionImp->functionName().ustring(); if (name.isEmpty()) name = AnonymousFunction; return CallIdentifier(name, functionImp->m_body->sourceURL(), functionImp->m_body->lineNo()); }
Profile::Profile(const String& title, unsigned uid) : m_title(title) , m_uid(uid) { // FIXME: When multi-threading is supported this will be a vector and calls // into the profiler will need to know which thread it is executing on. m_rootNode = ProfileNode::create(nullptr, CallIdentifier(ASCIILiteral("Thread_1"), String(), 0, 0), nullptr); m_rootNode->appendCall(ProfileNode::Call(0.0)); }
void ProfileGenerator::stopProfiling() { m_profile->forEach(&ProfileNode::stopProfiling); removeProfileStart(); removeProfileEnd(); ASSERT(m_currentNode); // Set the current node to the parent, because we are in a call that // will not get didExecute call. m_currentNode = m_currentNode->parent(); if (double headSelfTime = m_head->selfTime()) { RefPtr<ProfileNode> idleNode = ProfileNode::create(0, CallIdentifier(NonJSExecution, UString(), 0), m_head.get(), m_head.get()); idleNode->setTotalTime(headSelfTime); idleNode->setSelfTime(headSelfTime); idleNode->setVisible(true); m_head->setSelfTime(0.0); m_head->addChild(idleNode.release()); } }
CallIdentifier createCallIdentifierFromFunctionImp(ExecState* exec, JSFunction* function) { ASSERT(!function->isHostFunction()); const UString& name = function->calculatedDisplayName(exec); return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->jsExecutable()->sourceURL(), function->jsExecutable()->lineNo()); }
CallIdentifier createCallIdentifierFromFunctionImp(ExecState* exec, JSFunction* function) { const UString& name = function->name(exec); return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->m_body->sourceURL(), function->m_body->lineNo()); }
CallIdentifier createCallIdentifier(const UString& sourceURL, int startingLineNumber) { return CallIdentifier(GlobalCodeExecution, sourceURL, startingLineNumber); }