File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 22using System . Collections . Generic ;
33using System . Threading ;
44
5+ using MsieJavaScriptEngine . Utilities ;
6+
57namespace MsieJavaScriptEngine
68{
79 /// <summary>
@@ -11,9 +13,14 @@ internal sealed class ScriptDispatcher : IDisposable
1113 {
1214#if ! NETSTANDARD1_3
1315 /// <summary>
14- /// The stack size is sufficient to run the code of modern JavaScript libraries
16+ /// The stack size is sufficient to run the code of modern JavaScript libraries in 32-bit process
1517 /// </summary>
16- const int SUFFICIENT_STACK_SIZE = 2 * 1024 * 1024 ;
18+ const int STACK_SIZE_32 = 492 * 1024 ; // like 32-bit Node.js
19+
20+ /// <summary>
21+ /// The stack size is sufficient to run the code of modern JavaScript libraries in 64-bit process
22+ /// </summary>
23+ const int STACK_SIZE_64 = 984 * 1024 ; // like 64-bit Node.js
1724
1825#endif
1926 /// <summary>
@@ -29,7 +36,7 @@ internal sealed class ScriptDispatcher : IDisposable
2936 /// <summary>
3037 /// Queue of script tasks
3138 /// </summary>
32- private Queue < ScriptTask > _taskQueue = new Queue < ScriptTask > ( ) ;
39+ private readonly Queue < ScriptTask > _taskQueue = new Queue < ScriptTask > ( ) ;
3340
3441 /// <summary>
3542 /// Synchronizer of script task queue
@@ -50,7 +57,9 @@ public ScriptDispatcher()
5057#if NETSTANDARD1_3
5158 _thread = new Thread ( StartThread )
5259#else
53- _thread = new Thread ( StartThread , SUFFICIENT_STACK_SIZE )
60+ int sufficientStackSize = Utils. Is64BitProcess ( ) ? STACK_SIZE_64 : STACK_SIZE_32 ;
61+
62+ _thread = new Thread ( StartThread , sufficientStackSize )
5463#endif
5564 {
5665 IsBackground = true
You can’t perform that action at this time.
0 commit comments