The old debug API has been removed in SpiderMonkey 38, so remove profiler1 script profiling.

Patch by leper, refs #3708

See also https://bugzilla.mozilla.org/show_bug.cgi?id=1069694

This was SVN commit r18580.
This commit is contained in:
Itms
2016-08-02 16:58:30 +00:00
parent 72ca6c5f80
commit 4e87fef3da
17 changed files with 27 additions and 121 deletions
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ps/GameSetup/Config.h"
#include "ps/Profile.h"
// Use the macro below to define types that will be passed by value to C++ functions.
@@ -118,29 +117,12 @@ struct ScriptInterface_NativeMethodWrapper<void, TC> {
#undef OVERLOADS
};
// Fast natives don't trigger the hook we use for profiling, so explicitly
// notify the profiler when these functions are being called.
// ScriptInterface_impl::Register stores the name in a reserved slot.
#define SCRIPT_PROFILE \
if (g_ScriptProfilingEnabled) \
{ \
std::string name = "(unknown)"; \
JS::RootedString str(cx, JS_GetFunctionId(JS_ValueToFunction(cx, args.calleev()))); \
if (str) \
{ \
JS::RootedValue strVal(cx, JS::StringValue(str)); \
ScriptInterface::FromJSVal(cx, strVal, name); \
} \
CProfileSampleScript profile(StringFlyweight(name).get().c_str()); \
}
// JSFastNative-compatible function that wraps the function identified in the template argument list
#define OVERLOADS(z, i, data) \
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
bool ScriptInterface::call(JSContext* cx, uint argc, jsval* vp) { \
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
JSAutoRequest rq(cx); \
SCRIPT_PROFILE \
BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \
JS::RootedValue rval(cx); \
ScriptInterface_NativeWrapper<R>::template call<T0_HEAD(z,i) R( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i))>(cx, &rval, fptr A0_TAIL(z,i)); \
@@ -156,7 +138,6 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
bool ScriptInterface::callMethod(JSContext* cx, uint argc, jsval* vp) { \
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
JSAutoRequest rq(cx); \
SCRIPT_PROFILE \
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); \
if (ScriptInterface::GetClass(thisObj) != CLS) return false; \
TC* c = static_cast<TC*>(ScriptInterface::GetPrivate(thisObj)); \
@@ -227,7 +208,6 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
#undef ASSIGN_OR_TO_JS_VAL
// Clean up our mess
#undef SCRIPT_PROFILE
#undef NUMBERED_LIST_HEAD
#undef NUMBERED_LIST_TAIL
#undef NUMBERED_LIST_TAIL_MAYBE_REF
+1 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2015 Wildfire Games.
/* Copyright (C) 2016 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -46,7 +46,6 @@
#endif
#include "jsfriendapi.h"
#include "js/OldDebugAPI.h"
#include "js/GCAPI.h"
#include "js/StructuredClone.h"
+2 -70
View File
@@ -122,29 +122,13 @@ ScriptRuntime::ScriptRuntime(shared_ptr<ScriptRuntime> parentRuntime, int runtim
m_rt = JS_NewRuntime(runtimeSize, JS_USE_HELPER_THREADS, parentJSRuntime);
ENSURE(m_rt); // TODO: error handling
if (g_ScriptProfilingEnabled)
{
// Execute and call hooks are disabled if the runtime debug mode is disabled
JS_SetRuntimeDebugMode(m_rt, true);
// Profiler isn't thread-safe, so only enable this on the main thread
if (ThreadUtil::IsMainThread())
{
if (CProfileManager::IsInitialised())
{
JS_SetExecuteHook(m_rt, jshook_script, this);
JS_SetCallHook(m_rt, jshook_function, this);
}
}
}
JS::SetGCSliceCallback(m_rt, GCSliceCallbackHook);
JS_SetGCCallback(m_rt, ScriptRuntime::GCCallback, this);
JS_SetGCParameter(m_rt, JSGC_MAX_MALLOC_BYTES, m_RuntimeSize);
JS_SetGCParameter(m_rt, JSGC_MAX_BYTES, m_RuntimeSize);
JS_SetGCParameter(m_rt, JSGC_MODE, JSGC_MODE_INCREMENTAL);
// The whole heap-growth mechanism seems to work only for non-incremental GCs.
// We disable it to make it more clear if full GCs happen triggered by this JSAPI internal mechanism.
JS_SetGCParameter(m_rt, JSGC_DYNAMIC_HEAP_GROWTH, false);
@@ -279,58 +263,6 @@ void ScriptRuntime::ShrinkingGC()
JS_SetGCParameter(m_rt, JSGC_MODE, JSGC_MODE_INCREMENTAL);
}
void* ScriptRuntime::jshook_script(JSContext* UNUSED(cx), JSAbstractFramePtr UNUSED(fp), bool UNUSED(isConstructing), bool before, bool* UNUSED(ok), void* closure)
{
if (before)
g_Profiler.StartScript("script invocation");
else
g_Profiler.Stop();
return closure;
}
void* ScriptRuntime::jshook_function(JSContext* cx, JSAbstractFramePtr fp, bool UNUSED(isConstructing), bool before, bool* UNUSED(ok), void* closure)
{
JSAutoRequest rq(cx);
if (!before)
{
g_Profiler.Stop();
return closure;
}
JS::RootedFunction fn(cx, fp.maybeFun());
if (!fn)
{
g_Profiler.StartScript("(function)");
return closure;
}
// Try to get the name of non-anonymous functions
JS::RootedString name(cx, JS_GetFunctionId(fn));
if (name)
{
char* chars = JS_EncodeString(cx, name);
if (chars)
{
g_Profiler.StartScript(StringFlyweight(chars).get().c_str());
JS_free(cx, chars);
return closure;
}
}
// No name - use fileName and line instead
JS::AutoFilename fileName;
unsigned lineno;
JS::DescribeScriptedCaller(cx, &fileName, &lineno);
std::stringstream ss;
ss << "(" << fileName.get() << ":" << lineno << ")";
g_Profiler.StartScript(StringFlyweight(ss.str()).get().c_str());
return closure;
}
void ScriptRuntime::PrepareContextsForIncrementalGC()
{
for (JSContext* const& ctx : m_Contexts)
+1 -10
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2014 Wildfire Games.
/* Copyright (C) 2016 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -87,15 +87,6 @@ private:
double m_LastGCCheck;
static void GCCallback(JSRuntime *rt, JSGCStatus status, void *data);
static void* jshook_script(JSContext* UNUSED(cx), JSAbstractFramePtr UNUSED(fp),
bool UNUSED(isConstructing), bool before,
bool* UNUSED(ok), void* closure);
static void* jshook_function(JSContext* cx, JSAbstractFramePtr fp,
bool UNUSED(isConstructing), bool before,
bool* UNUSED(ok), void* closure);
};
#endif // INCLUDED_SCRIPTRUNTIME