wraitii
66cc595c53
Encapsulate runtime creation.
...
- Makes it easier to change down the line (and change is coming)
- Allows making g_ScriptRuntime thread-local easily.
- Remove ParentRuntime, which is not used at the moment.
Part of the SM52 migration, stage: SM45 compatible.
Patch by: Itms
Tested By: Freagarach
Refs #4893
Differential Revision: https://code.wildfiregames.com/D3087
This was SVN commit r24171.
2020-11-12 09:34:40 +00:00
wraitii
4b1a4ef4cf
Rework ScriptInterface EnumeratePropertyNames to support non-enumerable properties.
...
This lets it support the JSClass syntax, introduced for components in
5fb88172a2/D2492, which required a workaround before.
As cleanup, remove the prefix logic which was too specific to be in
ScriptInterface, and use an upstream-compatible API that also does more
of what we want.
Based on a patch by: elexis
Differential Revision: https://code.wildfiregames.com/D2644
This was SVN commit r23771.
2020-06-14 09:49:32 +00:00
elexis
734d21464b
Fix missing JSAutoRequest before JS_ReportError in various commits.
...
Differential Revision: https://code.wildfiregames.com/D2256
Tested on: clang 8.0.1, Jenkins
This was SVN commit r22949.
2019-09-20 19:18:07 +00:00
elexis
a84e2e57df
Use ScriptInterface::CreateObject for ToJSVal<CColor>, and for ToJSVal<Grid<u8> >, ToJSVal<Grid<u16> > used by the AIManager obtaining the pathfinder grid.
...
Make that function static, so that it can be used for these functions
without slowly having to obtain the ScriptInterface instance using
GetScriptInterfaceAndCBData just to get the JSContext again.
Remove few redundant conversions for CreateObject arguments.
Differential Revision: https://code.wildfiregames.com/D2128
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Tedious performance testing in: D2128, D2127
This was SVN commit r22894.
2019-09-13 00:56:51 +00:00
elexis
742f361b2d
Improve performance of ScriptInterface::CreateObject from b4626359f5 / D2080 by creating the JSAutoRequest struct only once instead of once per property.
...
Differential Revision: https://code.wildfiregames.com/D2127
Comments By: Vladislav
This was SVN commit r22680.
2019-08-17 03:30:07 +00:00
elexis
64e80471d0
Replace JS_THIS_OBJECT and JS::CallReceiver in preparation for SpiderMonkey 49 and 61.
...
Differential Revision: https://code.wildfiregames.com/D2173
Refs #4893 , D1699, D2142, D844, 7c2e9027c2 , ...
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1270977
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1255800
Tested on: clang 8, VS2015, Jenkins
This was SVN commit r22661.
2019-08-13 14:11:43 +00:00
Itms
9325992232
Revert use of the isRunOnce flag after removal in 64b477625d of compile'n go, refs #4893 .
...
This breaked a SM assertion, which was only caught in debug mode. It
could have led to subtle bugs during the compilation of JS scripts.
Still set the flag to its default value, because SM devs wanted to
change the default in the future.
This was SVN commit r22629.
2019-08-08 09:05:42 +00:00
Itms
64b477625d
Upgrade SpiderMonkey to version 45.0.2, refs #4893 .
...
- Various build changes, in particular NSPR is not needed on Unix
anymore
- Add js/Initialization.h to source/scriptinterface/ScriptEngine.h
- Use nullptr instead of JS::NullPtr(), see
https://bugzilla.mozilla.org/show_bug.cgi?id=1164602
- Remove `JS::RuntimeOptionsRef.varObjFix`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1171177
- Remove uses of `AutoIdArray`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1191529
- `JS_InternUCStringN` has been renamed, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1178581
- `JS::Evaluate` now takes scope chains explicitly, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1097987
- Array functions (such as `JS_IsArrayObject`) are fallible and output
to params, see https://bugzilla.mozilla.org/show_bug.cgi?id=f3d35d8
- Remove `JSCLASS_CACHED_PROTO_WIDTH` workaround in our code, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1236373
- Remove compile'n go (`setCompileAndGo`) and replace it by
`setIsRunOnce` which will become the default in the future, see
https://bugzilla.mozilla.org/show_bug.cgi?id=679939
- Mark shared memory in direct access operations
(`JS_GetUint16ArrayData` and `JS_GetUint8ArrayData`), see
https://bugzilla.mozilla.org/show_bug.cgi?id=1176214
- Use new `JS::ObjectOpResult`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1113369
Thanks to wraitii, elexis, Krinkle and historic_bruno for contributions
and comments, and to gentz, madpilot, s0600204 and Stan for testing and
indirect contributions.
Differential Revision: https://code.wildfiregames.com/D1510
This was SVN commit r22627.
2019-08-07 22:37:43 +00:00
elexis
eb20fe3626
Replace ScriptInterface ErrorReporter layered hack from 5e15a0279e with proper code, refs f6c1d98c9a.
...
Avoids preparation for the SpiderMonkey 45 update, refs #4893 / D1510 .
Add JSAutoRequest missing from 5e15a0279e too.
Differential Revision: https://code.wildfiregames.com/D2152
Reviewed By: Itms
This was SVN commit r22622.
2019-08-06 22:13:06 +00:00
elexis
b4626359f5
Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later.
...
Differential Revision: https://code.wildfiregames.com/D2080
Previous version reviewed By: Krinkle
Comments By: historic_bruno, wraitii
This was SVN commit r22528.
2019-07-22 19:35:14 +00:00
Itms
cca7627d88
Improvements to simulation hotloading before the SM upgrade, refs #4893 .
...
SM45 will enforce property attributes described at
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/Property_attributes .
We thus cannot hotload properties with the DontDelete attribute.
Fix an oversight in the hotloading code.
Rename a confusing parameter.
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1844
This was SVN commit r22516.
2019-07-19 21:58:58 +00:00
elexis
65b02395b3
Remove Vector2D/Vector3D prototype workaround from EngineScriptConversions.
...
Fixes #5376 , refs #2394 .
Differential Revision: https://code.wildfiregames.com/D1991
Patch By: Krinkle
Comments By: Vladislav, wraitii
This was SVN commit r22487.
2019-07-16 21:52:49 +00:00
Itms
db5d4bb5f1
SpiderMonkey-related changes in preparation for the upgrade to SpiderMonkey 45, refs #4893 .
...
- Remove JSVAL_ZERO and JSVAL_NULL
https://bugzilla.mozilla.org/show_bug.cgi?id=1177825
- Remove *_TO_JSVAL https://bugzilla.mozilla.org/show_bug.cgi?id=1177892
- Drop support for parent object in the deserializer
https://bugzilla.mozilla.org/show_bug.cgi?id=1136345 ,
https://bugzilla.mozilla.org/show_bug.cgi?id=805052
- Correctly use boolean values in JS::RuntimeOptionsRef
- Use JS_FN instead of JS_FS: in future versions, JS_FS is not public
because it isn't supposed to be used in JSAPI code
- Allow to select flags for global objects, and correctly mark progress
bars in the loading screen as not readonly+permanent
- Remove empty JSI_props in IGUIObject
Reviewed By: wraitii, elexis
Differential Revision: https://code.wildfiregames.com/D1716
This was SVN commit r22052.
2019-01-13 16:37:41 +00:00
elexis
9f0484e5ce
Delete unused SpiderMonkey GarbageCollection ScriptFunctions ForceGC in the AI and GUI context ( e9e05f4efc) and MaybeGC in the random mapgen context ( 942a45372c).
...
Optimizing the memory footprint requires likely different functions
following the new SM versions and a lot of testing,
so having these doesn't lower the effort to achieve optimization while
confusing the reader.
Differential Revision: https://code.wildfiregames.com/D1073
Reviewed By: Yves
This was SVN commit r20572.
2017-12-03 12:48:21 +00:00
leper
f7206dc77d
More ScriptInterface const.
...
Reviewed By: elexis; some comments by bb
Differential Revision: https://code.wildfiregames.com/D863
This was SVN commit r20519.
2017-11-25 06:49:58 +00:00
elexis
e95f4e9744
Unify deepcopy and clone.
...
Delete clone globalscripts function introduced by 9f47ed536d .
Rename the better supported deepcopy function to clone.
Delete unused Vector2D and Vector3D clone prototype functions that can
just use clone if needed.
Differential Revision: https://code.wildfiregames.com/D870
Reviewed By: leper
This was SVN commit r20125.
2017-09-06 20:58:27 +00:00
elexis
1b47451d32
Add deepfreeze function to recursively mark JS Objects as read-only.
...
Refs #4257 , D829
Proofread By: leper
This was SVN commit r20099.
2017-09-03 12:50:45 +00:00
elexis
1b44946078
Replace deprecated jsval with JS::Value.
...
Remove unused SGUIBaseSettings and GUI comment.
Fix indentation of a macro, refs D794.
Differential Revision: https://code.wildfiregames.com/D838
Review by: leper.
Itms came up with the same patch for the SpiderMonkey 45 update
independently.
This was SVN commit r20062.
2017-08-28 10:27:36 +00:00
leper
9defd11440
Pass ScriptInterface as a const ref where possible.
...
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D739
This was SVN commit r20028.
2017-08-24 00:32:42 +00:00
leper
3648ba448d
Some const for scriptinterface.
...
Reviewed By: Itms
Differential Revision: https://code.wildfiregames.com/D155
This was SVN commit r19339.
2017-03-24 18:47:03 +00:00
leper
6ae2db53db
Employ some variadic macros to make some of the C++ -> JS function calling code nicer.
...
Template-ize CallFunctionVoid.
Changes CallFunction parameter order to make template parameter
deduction with
variadic parameters work nicely.
Reviewed By: Itms, wraitii, Yves
Differential Revision: https://code.wildfiregames.com/D77
This was SVN commit r19183.
2017-01-28 23:37:15 +00:00
leper
be1a205f91
Add support for const methods in components and make those that can be const const.
...
Reviewed By: Itms
Differential Revision: https://code.wildfiregames.com/D75
This was SVN commit r19156.
2017-01-20 02:25:19 +00:00
elexis
417c84870c
Actually remove trailing tabs from source/.
...
This was SVN commit r18991.
2016-11-23 14:09:58 +00:00
elexis
6149dd3841
Actually remove trailing whitespace for non-header files as well.
...
This was SVN commit r18989.
2016-11-23 13:02:58 +00:00
Itms
0cc23c1964
SpiderMonkey 38 upgrade: 33/35
...
Remove a workaround. Note that this removal is incomplete. Based on
patch by leper.
This was SVN commit r18687.
2016-09-02 16:53:22 +00:00
Itms
9b794593db
SpiderMonkey 38 upgrade: 32/35
...
JS_GetStringCharsAndLength was removed, use
JS_Get{Latin1,TwoByte}StringCharsAndLength instead.
Actually handle strings in both the Latin1 and TwoByte cases since we
need to.
This saves some space when serializing and also when running as they are
stored that way in the vm.
Also handle the error case.
Patch by leper.
For more information:
https://blog.mozilla.org/javascript/2014/07/21/slimmer-and-faster-javascript-strings-in-firefox/
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1037869
This was SVN commit r18686.
2016-09-02 16:51:09 +00:00
Itms
f06eb5536b
SpiderMonkey 38 upgrade: 30/35
...
Upstream added a compartment option to preserve JIT code during
non-shrinking GCs, so use it. Patch by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1068697
This was SVN commit r18684.
2016-09-02 16:48:41 +00:00
Itms
58cace1156
SpiderMonkey 38 upgrade: 26/35
...
JS_Define{,UC}Property{,ById} has the attrs parameter moved in front of
the getter and setter params. Patch by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=959787
https://bugzilla.mozilla.org/show_bug.cgi?id=1088002 and
https://bugzilla.mozilla.org/show_bug.cgi?id=1211607
This was SVN commit r18680.
2016-09-02 16:44:33 +00:00
Itms
99534a15f1
SpiderMonkey 38 upgrade: 25/35
...
Remove the proto parameter from JS_DefineObject. Patch by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1127494
This was SVN commit r18679.
2016-09-02 16:41:36 +00:00
Itms
c396155ad8
SpiderMonkey 38 upgrade: 22/35
...
Parallel compilation was renamed to Offthread compilation. Patch by
leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1020364
This was SVN commit r18676.
2016-09-02 16:37:35 +00:00
Itms
f77441fb10
SpiderMonkey 38 upgrade: 20/35
...
Some options have been moved from ctxt to runtime. Patch by leper.
This was SVN commit r18674.
2016-09-02 16:35:58 +00:00
Itms
8f7ba9acf8
SpiderMonkey 38 upgrade: 18/35
...
JS_SetErrorReporter now takes a JSRuntime instead of a JSContext. Patch
by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=981198
This was SVN commit r18673.
2016-09-02 16:35:03 +00:00
Itms
2aa75a05d4
SpiderMonkey 38 upgrade: 18/35
...
Renamed JS_Compile{,UC}Function to JS::CompileFunction. Patch by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1089026
This was SVN commit r18672.
2016-09-02 16:34:02 +00:00
Itms
c3710c9632
SpiderMonkey 38 upgrade: 14/35
...
JS_NewObject has no parent or proto arg anymore, use
JS_NewObjectWithGivenProto instead. Patch by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1136906
https://bugzilla.mozilla.org/show_bug.cgi?id=1127443 and
https://bugzilla.mozilla.org/show_bug.cgi?id=1136345
This was SVN commit r18668.
2016-09-02 16:29:21 +00:00
Itms
c99ae7ca1c
SpiderMonkey 38 upgrade: 12/35
...
Major update to the JSClass stubs. Based on patch by leper.
https://bugzilla.mozilla.org/show_bug.cgi?id=1103152
This was SVN commit r18666.
2016-09-02 16:26:54 +00:00
Yves
9e4f0cc543
Properly shut down SpiderMonkey using JS_ShutDown.
...
This also adds some validation to ensure the correct order of JS_Init,
JS_NewRuntime, JS_DestroyRuntime and JS_ShutDown calls.
Refs #3708
This was SVN commit r18584.
2016-08-06 15:41:59 +00:00
Itms
72ca6c5f80
Style cleanup by leper, preparing the SpiderMonkey update. Refs #3708
...
This was SVN commit r18579.
2016-08-02 16:12:11 +00:00
wraitii
a4a45e4dc4
Fix compiler warning, thanks to elexis. Refs #4056
...
This was SVN commit r18442.
2016-06-26 16:51:52 +00:00
wraitii
898ab5229b
Change profiling calls to get a better view of what is actually slow and what is not.
...
This was SVN commit r18438.
2016-06-25 13:12:35 +00:00
wraitii
3cbe96d24c
Revamp Profiler2 to make it more usable.
...
Features include new graphs to compare runtime of functions and runtimes
across reports, as well as new profiling functions that only profile
spikes.
This was SVN commit r18423.
2016-06-22 13:38:05 +00:00
Yves
5f86beea6f
Replace HandleWrapper and avoid repoint function
...
JS::Handle<T>::repoint gets removed with SpiderMonkey 38, so the
existing solution has to be replaced. The new approach should also be a
bit clearer. Named Return Value Optimization (NRVO) should avoid a
superfluous temporary for the return value in the generic template
function implementation of AssignOrFromJSVal.
Refs #3708
This was SVN commit r17695.
2016-01-23 14:42:59 +00:00
leper
cfb2216b8c
Remove JSDebugger. Closes #2419 , #2973 . Refs #410 , #2348 , #3708 .
...
https://bugzilla.mozilla.org/show_bug.cgi?id=1069694
This was SVN commit r17655.
2016-01-17 00:34:33 +00:00
leper
39eb7fb243
Fix JS_SetGCZeal call.
...
https://bugzilla.mozilla.org/show_bug.cgi?id=650978
https://bugzilla.mozilla.org/show_bug.cgi?id=742570
This was SVN commit r17632.
2016-01-11 20:03:31 +00:00
leper
d08044c8ad
JS_DumpHeap is removed in SpiderMonkey 38, since we have nothing using it remove it. Refs #3708 .
...
https://bugzilla.mozilla.org/show_bug.cgi?id=1105069
https://bugzilla.mozilla.org/show_bug.cgi?id=1122842
This was SVN commit r17630.
2016-01-11 20:03:09 +00:00
leper
b18cd3254c
Test FixedVector{2,3}D script conversions, and test calling functions of the prototypes.
...
Also ENSURE that the given value identifier is actually present in the
cache instead of creating one if it is not.
This was SVN commit r17603.
2016-01-04 21:41:40 +00:00
leper
848efb56b3
Make a method const.
...
This was SVN commit r17527.
2015-12-22 14:08:32 +00:00
leper
509028d738
CompileOptions::setFileAndLine does not copy the string, so create a copy for it.
...
This was SVN commit r17512.
2015-12-19 02:55:30 +00:00
leper
190f9176df
SpiderMonkey 38 removes JS_NewPropertyIterator, use JS_Enumerate instead.
...
https://bugzilla.mozilla.org/show_bug.cgi?id=1081660
This was SVN commit r17510.
2015-12-19 02:21:22 +00:00
leper
753936e7df
SpiderMonkey 38 removes JS_Evaluate{,UC}Script, use JS::Evaluate.
...
https://bugzilla.mozilla.org/show_bug.cgi?id=1100579
This was SVN commit r17508.
2015-12-19 01:58:03 +00:00
leper
2239fe338c
The jschar typedef is removed in SpiderMonkey 38.
...
Since it already is char16_t in 31 replace it by that.
https://bugzilla.mozilla.org/show_bug.cgi?id=1063962
This was SVN commit r17506.
2015-12-19 01:29:55 +00:00