diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg
index c44c0b12cd..89641ace11 100644
--- a/binaries/data/config/default.cfg
+++ b/binaries/data/config/default.cfg
@@ -372,7 +372,6 @@ netwarnings = "true" ; Show warnings if the network connection is b
[profiler2]
autoenable = false ; Enable HTTP server output at startup (default off for security/performance)
-script.enable = false ; Enable Javascript profiling. Needs to be set before startup and can't be changed later. (default off for performance)
gpu.arb.enable = true ; Allow GL_ARB_timer_query timing mode when available
gpu.ext.enable = true ; Allow GL_EXT_timer_query timing mode when available
gpu.intel.enable = true ; Allow GL_INTEL_performance_queries timing mode when available
diff --git a/source/graphics/CinemaManager.cpp b/source/graphics/CinemaManager.cpp
index 019627c9ef..86e4991e0b 100644
--- a/source/graphics/CinemaManager.cpp
+++ b/source/graphics/CinemaManager.cpp
@@ -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
@@ -15,7 +15,6 @@
* along with 0 A.D. If not, see .
*/
-
#include "precompiled.h"
#include
@@ -35,6 +34,7 @@
#include "ps/CLogger.h"
#include "ps/CStr.h"
#include "ps/Game.h"
+#include "ps/GameSetup/Config.h"
#include "ps/Hotkey.h"
#include "simulation2/components/ICmpOverlayRenderer.h"
#include "simulation2/components/ICmpRangeManager.h"
@@ -294,4 +294,4 @@ bool CCinemaManager::GetPathsDrawing() const
void CCinemaManager::SetPathsDrawing(const bool drawPath)
{
m_DrawPaths = drawPath;
-}
\ No newline at end of file
+}
diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp
index 53eecae9bf..09c33868f8 100644
--- a/source/gui/CGUI.cpp
+++ b/source/gui/CGUI.cpp
@@ -47,6 +47,7 @@
#include "lib/utf8.h"
#include "ps/CLogger.h"
#include "ps/Filesystem.h"
+#include "ps/GameSetup/Config.h"
#include "ps/Globals.h"
#include "ps/Hotkey.h"
#include "ps/Profile.h"
diff --git a/source/gui/CInput.cpp b/source/gui/CInput.cpp
index d4722ba356..82afe0ef24 100644
--- a/source/gui/CInput.cpp
+++ b/source/gui/CInput.cpp
@@ -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
@@ -32,6 +32,7 @@
#include "lib/utf8.h"
#include "ps/CLogger.h"
#include "ps/ConfigDB.h"
+#include "ps/GameSetup/Config.h"
#include "ps/Globals.h"
#include "ps/Hotkey.h"
#include "renderer/Renderer.h"
diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp
index 5df1c2f578..2c0f63f5a4 100644
--- a/source/gui/GUIutil.cpp
+++ b/source/gui/GUIutil.cpp
@@ -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
@@ -22,6 +22,7 @@
#include "maths/Matrix3D.h"
#include "ps/CLogger.h"
+#include "ps/GameSetup/Config.h"
extern int g_xres, g_yres;
diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp
index 2cc86196f3..08026ef20c 100644
--- a/source/gui/IGUIObject.cpp
+++ b/source/gui/IGUIObject.cpp
@@ -21,6 +21,8 @@
#include "gui/scripting/JSInterface_GUITypes.h"
#include "gui/scripting/JSInterface_IGUIObject.h"
+
+#include "ps/GameSetup/Config.h"
#include "ps/CLogger.h"
#include "ps/Profile.h"
#include "scriptinterface/ScriptInterface.h"
diff --git a/source/gui/MiniMap.cpp b/source/gui/MiniMap.cpp
index fe690856fc..d15f1500aa 100644
--- a/source/gui/MiniMap.cpp
+++ b/source/gui/MiniMap.cpp
@@ -37,6 +37,7 @@
#include "ps/ConfigDB.h"
#include "ps/Filesystem.h"
#include "ps/Game.h"
+#include "ps/GameSetup/Config.h"
#include "ps/Profile.h"
#include "ps/World.h"
#include "ps/XML/Xeromyces.h"
diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp
index 8f9e54a4e4..2482823523 100644
--- a/source/ps/CConsole.cpp
+++ b/source/ps/CConsole.cpp
@@ -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
@@ -38,6 +38,7 @@
#include "network/NetServer.h"
#include "ps/CLogger.h"
#include "ps/Filesystem.h"
+#include "ps/GameSetup/Config.h"
#include "ps/Globals.h"
#include "ps/Hotkey.h"
#include "ps/Profile.h"
diff --git a/source/ps/GameSetup/Config.cpp b/source/ps/GameSetup/Config.cpp
index f075ca6409..d27cf8ec2d 100644
--- a/source/ps/GameSetup/Config.cpp
+++ b/source/ps/GameSetup/Config.cpp
@@ -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
@@ -66,8 +66,6 @@ bool g_VSync = false;
bool g_Quickstart = false;
bool g_DisableAudio = false;
-bool g_ScriptProfilingEnabled = false;
-
// flag to switch on drawing terrain overlays
bool g_ShowPathfindingOverlay = false;
@@ -111,8 +109,6 @@ static void LoadGlobals()
CFG_GET_VAL("postproc", g_PostProc);
CFG_GET_VAL("smoothlos", g_SmoothLOS);
CFG_GET_VAL("gui.scale", g_GuiScale);
-
- CFG_GET_VAL("profiler2.script.enable", g_ScriptProfilingEnabled);
}
diff --git a/source/ps/GameSetup/Config.h b/source/ps/GameSetup/Config.h
index d09f9fd232..9173fb258f 100644
--- a/source/ps/GameSetup/Config.h
+++ b/source/ps/GameSetup/Config.h
@@ -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
@@ -91,8 +91,6 @@ extern bool g_VSync;
extern bool g_Quickstart;
extern bool g_DisableAudio;
-extern bool g_ScriptProfilingEnabled;
-
extern CStrW g_CursorName;
class CmdLineArgs;
diff --git a/source/ps/scripting/JSInterface_VisualReplay.cpp b/source/ps/scripting/JSInterface_VisualReplay.cpp
index 8506c13bf0..1804b1e0af 100644
--- a/source/ps/scripting/JSInterface_VisualReplay.cpp
+++ b/source/ps/scripting/JSInterface_VisualReplay.cpp
@@ -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
@@ -17,9 +17,11 @@
#include "precompiled.h"
+#include "ps/scripting/JSInterface_VisualReplay.h"
+
+#include "ps/CStr.h"
#include "ps/Profile.h"
#include "ps/VisualReplay.h"
-#include "ps/scripting/JSInterface_VisualReplay.h"
void JSI_VisualReplay::StartVisualReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const CStrW& directory)
{
diff --git a/source/scriptinterface/NativeWrapperDefns.h b/source/scriptinterface/NativeWrapperDefns.h
index 8bc8d34835..ab8238bc17 100644
--- a/source/scriptinterface/NativeWrapperDefns.h
+++ b/source/scriptinterface/NativeWrapperDefns.h
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
-#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 {
#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 \
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::template call(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(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
diff --git a/source/scriptinterface/ScriptExtraHeaders.h b/source/scriptinterface/ScriptExtraHeaders.h
index 1ab53f05b8..3df401757d 100644
--- a/source/scriptinterface/ScriptExtraHeaders.h
+++ b/source/scriptinterface/ScriptExtraHeaders.h
@@ -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"
diff --git a/source/scriptinterface/ScriptRuntime.cpp b/source/scriptinterface/ScriptRuntime.cpp
index 5c97208ccf..65f87108e1 100644
--- a/source/scriptinterface/ScriptRuntime.cpp
+++ b/source/scriptinterface/ScriptRuntime.cpp
@@ -122,29 +122,13 @@ ScriptRuntime::ScriptRuntime(shared_ptr 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)
diff --git a/source/scriptinterface/ScriptRuntime.h b/source/scriptinterface/ScriptRuntime.h
index 7bc0a509af..68fe21c8f7 100644
--- a/source/scriptinterface/ScriptRuntime.h
+++ b/source/scriptinterface/ScriptRuntime.h
@@ -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
diff --git a/source/simulation2/components/CCmpUnitRenderer.cpp b/source/simulation2/components/CCmpUnitRenderer.cpp
index 481937b84d..5c1595737a 100644
--- a/source/simulation2/components/CCmpUnitRenderer.cpp
+++ b/source/simulation2/components/CCmpUnitRenderer.cpp
@@ -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
@@ -35,6 +35,7 @@
#include "graphics/Unit.h"
#include "maths/BoundingSphere.h"
#include "maths/Matrix3D.h"
+#include "ps/GameSetup/Config.h"
#include "ps/Profile.h"
#include "renderer/Scene.h"
diff --git a/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp
index c6ad41563c..4bcfc76ff3 100644
--- a/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp
+++ b/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp
@@ -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
@@ -24,6 +24,7 @@
#include "graphics/LightEnv.h"
#include "graphics/Terrain.h"
#include "maths/MathUtil.h"
+#include "ps/CStr.h"
#include "ps/Game.h"
#include "ps/World.h"
#include "renderer/PostprocManager.h"