Skip to content

Commit 5c353eb

Browse files
committed
In configuration settings of the V8 JS engine was added one new property - DisableDynamicBinding (default false)
1 parent 768bee3 commit 5c353eb

File tree

6 files changed

+49
-20
lines changed

6 files changed

+49
-20
lines changed

src/JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ This package does not contain the native ClearScript.V8 assemblies. Therefore, y
3030
* Microsoft.ClearScript.V8.Native.osx-arm64</Description>
3131
<PackageTags>$(PackageCommonTags);V8;ClearScript</PackageTags>
3232
<PackageIconFullPath>../../Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png</PackageIconFullPath>
33-
<PackageReleaseNotes>Fixed a error #102 “Resources should conform to correct ICU standard for naming”. Special thanks to Tim Heuer.</PackageReleaseNotes>
33+
<PackageReleaseNotes>1. Microsoft ClearScript.V8 was updated to version 7.3.2;
34+
2. In configuration settings of the V8 JS engine was added one new property - `DisableDynamicBinding` (default `false`).</PackageReleaseNotes>
3435
</PropertyGroup>
3536

3637
<ItemGroup>

src/JavaScriptEngineSwitcher.V8/V8JsEngine.cs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public V8JsEngine(V8Settings settings)
130130
{
131131
_jsEngine = new OriginalEngine(constraints, flags, debugPort)
132132
{
133+
DisableDynamicBinding = v8Settings.DisableDynamicBinding,
133134
MaxRuntimeHeapSize = v8Settings.MaxHeapSize,
134135
RuntimeHeapSizeSampleInterval = v8Settings.HeapSizeSampleInterval,
135136
MaxRuntimeStackUsage = v8Settings.MaxStackUsage

src/JavaScriptEngineSwitcher.V8/V8Settings.cs

+31-13
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,56 @@ public bool AwaitDebuggerAndPauseOnStart
1919
}
2020

2121
/// <summary>
22-
/// Gets or sets a flag for whether to enable script debugging features
23-
/// (allows a TCP-based debugging)
22+
/// Gets or sets a TCP port on which to listen for a debugger connection
2423
/// </summary>
25-
public bool EnableDebugging
24+
public ushort DebugPort
2625
{
2726
get;
2827
set;
2928
}
3029

3130
/// <summary>
32-
/// Gets or sets a flag for whether to enable remote script debugging.
33-
/// This property is ignored if value of the <see cref="EnableDebugging"/>
34-
/// property is false.
31+
/// Gets or sets a flag for whether to disable dynamic method binding
3532
/// </summary>
36-
public bool EnableRemoteDebugging
33+
/// <remarks>
34+
/// <para>
35+
/// When this property is set to <c>true</c>, the script engine bypasses the default method
36+
/// binding algorithm and uses reflection-based method binding instead. This approach
37+
/// abandons support for generic type inference and other features, but it avoids engaging
38+
/// the dynamic infrastructure.
39+
/// </para>
40+
/// </remarks>
41+
public bool DisableDynamicBinding
3742
{
3843
get;
3944
set;
4045
}
4146

4247
/// <summary>
43-
/// Gets or sets a TCP port on which to listen for a debugger connection
48+
/// Gets or sets a flag for whether to disable global members
4449
/// </summary>
45-
public ushort DebugPort
50+
public bool DisableGlobalMembers
4651
{
4752
get;
4853
set;
4954
}
5055

5156
/// <summary>
52-
/// Gets or sets a flag for whether to disable global members
57+
/// Gets or sets a flag for whether to enable script debugging features
58+
/// (allows a TCP-based debugging)
5359
/// </summary>
54-
public bool DisableGlobalMembers
60+
public bool EnableDebugging
61+
{
62+
get;
63+
set;
64+
}
65+
66+
/// <summary>
67+
/// Gets or sets a flag for whether to enable remote script debugging.
68+
/// This property is ignored if value of the <see cref="EnableDebugging"/>
69+
/// property is false.
70+
/// </summary>
71+
public bool EnableRemoteDebugging
5572
{
5673
get;
5774
set;
@@ -195,10 +212,11 @@ public UIntPtr MaxStackUsage
195212
public V8Settings()
196213
{
197214
AwaitDebuggerAndPauseOnStart = false;
198-
EnableDebugging = false;
199-
EnableRemoteDebugging = false;
200215
DebugPort = 9222;
216+
DisableDynamicBinding = false;
201217
DisableGlobalMembers = false;
218+
EnableDebugging = false;
219+
EnableRemoteDebugging = false;
202220
HeapExpansionMultiplier = 0;
203221
HeapSizeSampleInterval = TimeSpan.Zero;
204222
MaxArrayBufferAllocation = ulong.MaxValue;

src/JavaScriptEngineSwitcher.V8/readme.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
=============
3232
RELEASE NOTES
3333
=============
34-
Fixed a error #102 “Resources should conform to correct ICU standard for
35-
naming”. Special thanks to Tim Heuer.
34+
1. Microsoft ClearScript.V8 was updated to version 7.3.2;
35+
2. In configuration settings of the V8 JS engine was added one new property -
36+
`DisableDynamicBinding` (default `false`).
3637

3738
=============
3839
DOCUMENTATION

test/JavaScriptEngineSwitcher.Benchmarks/HostObjectsEmbeddingBenchmark.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,13 @@ public void NiL()
171171
}
172172

173173
[Benchmark]
174-
public void V8()
174+
[Arguments(false)]
175+
[Arguments(true)]
176+
public void V8(bool disableDynamicBinding)
175177
{
176-
Func<IJsEngine> createJsEngine = () => new V8JsEngine();
178+
Func<IJsEngine> createJsEngine = () => new V8JsEngine(
179+
new V8Settings { DisableDynamicBinding = disableDynamicBinding }
180+
);
177181
EmbedAndUseHostObjects(createJsEngine);
178182
}
179183
#endif

test/JavaScriptEngineSwitcher.Benchmarks/HostTypesEmbeddingBenchmark.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,13 @@ public void NiL()
151151
}
152152

153153
[Benchmark]
154-
public void V8()
154+
[Arguments(false)]
155+
[Arguments(true)]
156+
public void V8(bool disableDynamicBinding)
155157
{
156-
Func<IJsEngine> createJsEngine = () => new V8JsEngine();
158+
Func<IJsEngine> createJsEngine = () => new V8JsEngine(
159+
new V8Settings { DisableDynamicBinding = disableDynamicBinding }
160+
);
157161
EmbedAndUseHostTypes(createJsEngine);
158162
}
159163
#endif

0 commit comments

Comments
 (0)