Skip to content

Commit cb1697b

Browse files
committed
Version 1.2.3:
1. In JavaScriptEngineSwitcher.ConfigurationIntelliSense added definitions for configuration settings of V8 JavaScript engine; 2. In JavaScriptEngineSwitcher.V8: 2.1. Added support of Microsoft ClearScript.V8 version 5.4.1 (support of V8 version 3.30.33.16); 2.2. Added the ability to change configuration settings of V8 JavaScript engine: `EnableDebugging` (default `false`), `DebugPort` (default `9222`), `DisableGlobalMembers` (default `false`), `MaxNewSpaceSize` (default `0`), `MaxOldSpaceSize` (default `0`) and `MaxExecutableSize` (default `0`); 3. In JavaScriptEngineSwitcher.Jint added support of Jint version of February 14, 2015.
1 parent 584610a commit cb1697b

28 files changed

+280
-41
lines changed

Binaries/ClearScript/ClearScript.dll

62.5 KB
Binary file not shown.

Binaries/ClearScript/MS-PL.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ use the software.
5353
may have additional consumer rights under your local laws which this
5454
license cannot change. To the extent permitted under your local laws,
5555
the contributors exclude the implied warranties of merchantability,
56-
fitness for a particular purpose and non-infringement.
56+
fitness for a particular purpose and non-infringement.
-144 KB
Binary file not shown.

Binaries/ClearScript/x64/v8-x64.dll

354 KB
Binary file not shown.
-166 KB
Binary file not shown.

Binaries/ClearScript/x86/v8-ia32.dll

531 KB
Binary file not shown.

Binaries/Jint/Jint.dll

-512 Bytes
Binary file not shown.

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Change log
22
==========
33

4+
## February 16, 2015 - v1.2.3
5+
* In JavaScriptEngineSwitcher.ConfigurationIntelliSense added definitions for configuration settings of V8 JavaScript engine
6+
* In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 5.4.1 (support of V8 version 3.30.33.16) and added the ability to change configuration settings of V8 JavaScript engine: `EnableDebugging` (default `false`), `DebugPort` (default `9222`), `DisableGlobalMembers` (default `false`), `MaxNewSpaceSize` (default `0`), `MaxOldSpaceSize` (default `0`) and `MaxExecutableSize` (default `0`)
7+
* In JavaScriptEngineSwitcher.Jint added support of Jint version of February 14, 2015
8+
49
## January 13, 2015 - v1.2.2
510
* In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 1.5.1
611

JavaScriptEngineSwitcher.Jint/JintJsEngine.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public sealed class JintJsEngine : JsEngineBase
2626
/// <summary>
2727
/// Version of original JavaScript engine
2828
/// </summary>
29-
private const string ENGINE_VERSION = "Oct 21, 2014";
29+
private const string ENGINE_VERSION = "Feb 14, 2015";
3030

3131
/// <summary>
3232
/// Jint JS engine
@@ -57,7 +57,7 @@ public JintJsEngine()
5757
{
5858
try
5959
{
60-
_jsEngine = new OriginalJsEngine();
60+
_jsEngine = new OriginalJsEngine(c => c.LimitRecursion(20678));
6161
}
6262
catch (Exception e)
6363
{

JavaScriptEngineSwitcher.Jint/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
[assembly: AssemblyConfiguration("")]
77
[assembly: AssemblyCompany("")]
88
[assembly: AssemblyProduct("JavaScript Engine Switcher for .Net: Jint")]
9-
[assembly: AssemblyCopyright("Copyright © Andrey Taritsyn 2014")]
9+
[assembly: AssemblyCopyright("Copyright © 2013-2015 Andrey Taritsyn")]
1010
[assembly: AssemblyTrademark("")]
1111
[assembly: AssemblyCulture("")]
1212

1313
[assembly: ComVisible(false)]
1414
[assembly: Guid("4b51319e-014f-4731-8a80-15b5c58f3a72")]
1515

16-
[assembly: AssemblyVersion("1.2.1.0")]
17-
[assembly: AssemblyFileVersion("1.2.1.0")]
16+
[assembly: AssemblyVersion("1.2.3.0")]
17+
[assembly: AssemblyFileVersion("1.2.3.0")]

JavaScriptEngineSwitcher.Tests/App.config

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
type="JavaScriptEngineSwitcher.Core.Configuration.CoreConfiguration, JavaScriptEngineSwitcher.Core" />
77
<section name="msie"
88
type="JavaScriptEngineSwitcher.Msie.Configuration.MsieConfiguration, JavaScriptEngineSwitcher.Msie" />
9+
<section name="v8"
10+
type="JavaScriptEngineSwitcher.V8.Configuration.V8Configuration, JavaScriptEngineSwitcher.V8" />
911
</sectionGroup>
1012
</configSections>
1113
<jsEngineSwitcher xmlns="http://tempuri.org/JavaScriptEngineSwitcher.Configuration.xsd">
@@ -22,6 +24,8 @@
2224
</engines>
2325
</core>
2426
<msie engineMode="Auto" />
27+
<v8 enableDebugging="false" debugPort="9222" disableGlobalMembers="false"
28+
maxNewSpaceSize="0" maxOldSpaceSize="0" maxExecutableSize="0" />
2529
</jsEngineSwitcher>
2630
<startup>
2731
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>

JavaScriptEngineSwitcher.Tests/JavaScriptEngineSwitcher.Configuration.xsd

+72
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@
1414
<xs:all>
1515
<xs:element name="core" type="CoreConfiguration_SchemaType" minOccurs="0" maxOccurs="1" />
1616
<xs:element name="msie" type="MsieConfiguration_SchemaType" minOccurs="0" maxOccurs="1" />
17+
<xs:element name="v8" type="V8Configuration_SchemaType" minOccurs="0" maxOccurs="1" />
1718
</xs:all>
1819
</xs:complexType>
1920
</xs:element>
2021

22+
<!-- Simple types -->
23+
<xs:simpleType name="Boolean_SchemaType">
24+
<xs:restriction base="xs:NMTOKEN">
25+
<xs:enumeration value="true" />
26+
<xs:enumeration value="false" />
27+
</xs:restriction>
28+
</xs:simpleType>
29+
<!-- /Simple types -->
30+
2131
<!-- Core configuration settings -->
2232
<xs:complexType name="CoreConfiguration_SchemaType">
2333
<xs:annotation>
@@ -114,4 +124,66 @@
114124
</xs:attribute>
115125
</xs:complexType>
116126
<!--/ MSIE configuration settings -->
127+
128+
<!-- V8 configuration settings -->
129+
<xs:complexType name="V8Configuration_SchemaType">
130+
<xs:annotation>
131+
<xs:documentation>Configuration settings of V8 JavaScript engine</xs:documentation>
132+
</xs:annotation>
133+
<xs:attribute name="enableDebugging" type="Boolean_SchemaType" use="optional" default="false">
134+
<xs:annotation>
135+
<xs:documentation>Flag for whether to enable script debugging features</xs:documentation>
136+
</xs:annotation>
137+
</xs:attribute>
138+
<xs:attribute name="debugPort" use="optional" default="9222">
139+
<xs:annotation>
140+
<xs:documentation>TCP/IP port on which to listen for a debugger connection</xs:documentation>
141+
</xs:annotation>
142+
<xs:simpleType>
143+
<xs:restriction base="xs:int">
144+
<xs:minInclusive value="0" />
145+
<xs:maxInclusive value="65535" />
146+
</xs:restriction>
147+
</xs:simpleType>
148+
</xs:attribute>
149+
<xs:attribute name="disableGlobalMembers" type="Boolean_SchemaType" use="optional" default="false">
150+
<xs:annotation>
151+
<xs:documentation>Flag for whether to disable global members</xs:documentation>
152+
</xs:annotation>
153+
</xs:attribute>
154+
<xs:attribute name="maxNewSpaceSize" use="optional" default="0">
155+
<xs:annotation>
156+
<xs:documentation>Maximum size of the new object heap in bytes</xs:documentation>
157+
</xs:annotation>
158+
<xs:simpleType>
159+
<xs:restriction base="xs:int">
160+
<xs:minInclusive value="0" />
161+
<xs:maxInclusive value="2147483647" />
162+
</xs:restriction>
163+
</xs:simpleType>
164+
</xs:attribute>
165+
<xs:attribute name="maxOldSpaceSize" use="optional" default="0">
166+
<xs:annotation>
167+
<xs:documentation>Maximum size of the old object heap in bytes</xs:documentation>
168+
</xs:annotation>
169+
<xs:simpleType>
170+
<xs:restriction base="xs:int">
171+
<xs:minInclusive value="0" />
172+
<xs:maxInclusive value="2147483647" />
173+
</xs:restriction>
174+
</xs:simpleType>
175+
</xs:attribute>
176+
<xs:attribute name="maxExecutableSize" use="optional" default="0">
177+
<xs:annotation>
178+
<xs:documentation>Maximum size of the executable code heap in bytes</xs:documentation>
179+
</xs:annotation>
180+
<xs:simpleType>
181+
<xs:restriction base="xs:int">
182+
<xs:minInclusive value="0" />
183+
<xs:maxInclusive value="2147483647" />
184+
</xs:restriction>
185+
</xs:simpleType>
186+
</xs:attribute>
187+
</xs:complexType>
188+
<!--/ V8 configuration settings -->
117189
</xs:schema>

JavaScriptEngineSwitcher.Tests/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
[assembly: AssemblyConfiguration("")]
77
[assembly: AssemblyCompany("")]
88
[assembly: AssemblyProduct("JavaScript Engine Switcher for .Net: Tests")]
9-
[assembly: AssemblyCopyright("Copyright © 2012-2015 Andrey Taritsyn")]
9+
[assembly: AssemblyCopyright("Copyright © 2013-2015 Andrey Taritsyn")]
1010
[assembly: AssemblyTrademark("")]
1111
[assembly: AssemblyCulture("")]
1212

1313
[assembly: ComVisible(false)]
1414
[assembly: Guid("4cfa9f30-6718-4b7e-8329-7602278b8e31")]
1515

16-
[assembly: AssemblyVersion("1.2.2.0")]
17-
[assembly: AssemblyFileVersion("1.2.2.0")]
16+
[assembly: AssemblyVersion("1.2.3.0")]
17+
[assembly: AssemblyFileVersion("1.2.3.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
namespace JavaScriptEngineSwitcher.V8.Configuration
2+
{
3+
using System.Configuration;
4+
5+
/// <summary>
6+
/// Configuration settings of V8 JavaScript engine
7+
/// </summary>
8+
public sealed class V8Configuration : ConfigurationSection
9+
{
10+
/// <summary>
11+
/// Gets or sets a flag for whether to enable script debugging features
12+
/// </summary>
13+
[ConfigurationProperty("enableDebugging", DefaultValue = false)]
14+
public bool EnableDebugging
15+
{
16+
get { return (bool)this["enableDebugging"]; }
17+
set { this["enableDebugging"] = value; }
18+
}
19+
20+
/// <summary>
21+
/// Gets or sets a TCP/IP port on which to listen for a debugger connection
22+
/// </summary>
23+
[ConfigurationProperty("debugPort", DefaultValue = 9222)]
24+
[IntegerValidator(MinValue = 0, MaxValue = 65535, ExcludeRange = false)]
25+
public int DebugPort
26+
{
27+
get { return (int)this["debugPort"]; }
28+
set { this["debugPort"] = value; }
29+
}
30+
31+
/// <summary>
32+
/// Gets or sets a flag for whether to disable global members
33+
/// </summary>
34+
[ConfigurationProperty("disableGlobalMembers", DefaultValue = false)]
35+
public bool DisableGlobalMembers
36+
{
37+
get { return (bool)this["disableGlobalMembers"]; }
38+
set { this["disableGlobalMembers"] = value; }
39+
}
40+
41+
/// <summary>
42+
/// Gets or sets a maximum size of the new object heap in bytes
43+
/// </summary>
44+
[ConfigurationProperty("maxNewSpaceSize", DefaultValue = 0)]
45+
[IntegerValidator(MinValue = 0, MaxValue = int.MaxValue, ExcludeRange = false)]
46+
public int MaxNewSpaceSize
47+
{
48+
get { return (int)this["maxNewSpaceSize"]; }
49+
set { this["maxNewSpaceSize"] = value; }
50+
}
51+
52+
/// <summary>
53+
/// Gets or sets a maximum size of the old object heap in bytes
54+
/// </summary>
55+
[ConfigurationProperty("maxOldSpaceSize", DefaultValue = 0)]
56+
[IntegerValidator(MinValue = 0, MaxValue = int.MaxValue, ExcludeRange = false)]
57+
public int MaxOldSpaceSize
58+
{
59+
get { return (int)this["maxOldSpaceSize"]; }
60+
set { this["maxOldSpaceSize"] = value; }
61+
}
62+
63+
/// <summary>
64+
/// Gets or sets a maximum size of the executable code heap in bytes
65+
/// </summary>
66+
[ConfigurationProperty("maxExecutableSize", DefaultValue = 0)]
67+
[IntegerValidator(MinValue = 0, MaxValue = int.MaxValue, ExcludeRange = false)]
68+
public int MaxExecutableSize
69+
{
70+
get { return (int)this["maxExecutableSize"]; }
71+
set { this["maxExecutableSize"] = value; }
72+
}
73+
}
74+
}

JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@
4242
<HintPath>..\Binaries\ClearScript\ClearScript.dll</HintPath>
4343
</Reference>
4444
<Reference Include="System" />
45+
<Reference Include="System.configuration" />
4546
<Reference Include="System.Core" />
4647
<Reference Include="Microsoft.CSharp" />
4748
</ItemGroup>
4849
<ItemGroup>
4950
<Compile Include="AssemblyResolver.cs" />
51+
<Compile Include="Configuration\V8Configuration.cs" />
52+
<Compile Include="JsEngineSwitcherExtensions.cs" />
5053
<Compile Include="Properties\AssemblyInfo.cs" />
5154
<Compile Include="Resources\Strings.Designer.cs">
5255
<AutoGen>True</AutoGen>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace JavaScriptEngineSwitcher.V8
2+
{
3+
using System;
4+
using System.Configuration;
5+
6+
using Core;
7+
using Configuration;
8+
9+
/// <summary>
10+
/// JavaScript engine switcher extensions
11+
/// </summary>
12+
public static class JsEngineSwitcherExtensions
13+
{
14+
/// <summary>
15+
/// Configuration settings of V8 JavaScript engine
16+
/// </summary>
17+
private static readonly Lazy<V8Configuration> _v8Config =
18+
new Lazy<V8Configuration>(() => (V8Configuration)ConfigurationManager.GetSection("jsEngineSwitcher/v8"));
19+
20+
/// <summary>
21+
/// Gets a V8 JavaScript engine configuration settings
22+
/// </summary>
23+
/// <param name="switcher">JavaScript engine switcher</param>>
24+
/// <returns>Configuration settings of V8 JavaScript engine</returns>
25+
public static V8Configuration GetV8Configuration(this JsEngineSwitcher switcher)
26+
{
27+
return _v8Config.Value;
28+
}
29+
}
30+
}

JavaScriptEngineSwitcher.V8/Properties/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
[assembly: AssemblyConfiguration("")]
77
[assembly: AssemblyCompany("")]
88
[assembly: AssemblyProduct("JavaScript Engine Switcher for .Net: V8")]
9-
[assembly: AssemblyCopyright("Copyright © Andrey Taritsyn 2014")]
9+
[assembly: AssemblyCopyright("Copyright © 2013-2015 Andrey Taritsyn")]
1010
[assembly: AssemblyTrademark("")]
1111
[assembly: AssemblyCulture("")]
1212

1313
[assembly: ComVisible(false)]
1414
[assembly: Guid("684edd94-43fe-4486-a4f3-6b9197d10ebf")]
1515

16-
[assembly: AssemblyVersion("1.2.1.0")]
17-
[assembly: AssemblyFileVersion("1.2.1.0")]
16+
[assembly: AssemblyVersion("1.2.3.0")]
17+
[assembly: AssemblyFileVersion("1.2.3.0")]

JavaScriptEngineSwitcher.V8/V8JsEngine.cs

+33-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Core.Utilities;
1313
using CoreStrings = Core.Resources.Strings;
1414

15+
using Configuration;
1516
using Resources;
1617

1718
/// <summary>
@@ -27,7 +28,7 @@ public sealed class V8JsEngine : JsEngineBase
2728
/// <summary>
2829
/// Version of original JavaScript engine
2930
/// </summary>
30-
private const string ENGINE_VERSION = "3.26.31.15";
31+
private const string ENGINE_VERSION = "3.30.33.16";
3132

3233
/// <summary>
3334
/// JS-engine
@@ -43,12 +44,12 @@ public sealed class V8JsEngine : JsEngineBase
4344
/// Information about `InvokeMethod` method of `Microsoft.ClearScript.Windows.WindowsScriptItem` type
4445
/// </summary>
4546
private static MethodInfo _winScriptItemInvokeMethodInfo;
46-
47+
4748
/// <summary>
4849
/// Regular expression for working with the string representation of error
4950
/// </summary>
5051
private static readonly Regex _errorStringRegex =
51-
new Regex(@"at (?:[A-Za-z_\$][0-9A-Za-z_\$]* )?" +
52+
new Regex(@"at (?:[A-Za-z_\$][0-9A-Za-z_\$]* )?" +
5253
@"\(?Script Document(?:\s*\[\d+\])?:(?<lineNumber>\d+):(?<columnNumber>\d+)\)?");
5354

5455
/// <summary>
@@ -87,10 +88,38 @@ static V8JsEngine()
8788
/// Constructs instance of adapter for Microsoft ClearScript.V8
8889
/// </summary>
8990
public V8JsEngine()
91+
: this(JsEngineSwitcher.Current.GetV8Configuration())
92+
{ }
93+
94+
/// <summary>
95+
/// Constructs instance of adapter for Microsoft ClearScript.V8
96+
/// </summary>
97+
/// <param name="v8Config">Configuration settings of V8 JavaScript engine</param>
98+
public V8JsEngine(V8Configuration v8Config)
9099
{
100+
V8RuntimeConstraints constraints = new V8RuntimeConstraints
101+
{
102+
MaxNewSpaceSize = v8Config.MaxNewSpaceSize,
103+
MaxOldSpaceSize = v8Config.MaxOldSpaceSize,
104+
MaxExecutableSize = v8Config.MaxExecutableSize
105+
};
106+
107+
V8ScriptEngineFlags flags = V8ScriptEngineFlags.None;
108+
if (v8Config.EnableDebugging && v8Config.DisableGlobalMembers)
109+
{
110+
flags = V8ScriptEngineFlags.EnableDebugging | V8ScriptEngineFlags.DisableGlobalMembers;
111+
}
112+
else if (v8Config.EnableDebugging || v8Config.DisableGlobalMembers)
113+
{
114+
flags = v8Config.EnableDebugging ?
115+
V8ScriptEngineFlags.EnableDebugging : V8ScriptEngineFlags.DisableGlobalMembers;
116+
}
117+
118+
int debugPort = v8Config.DebugPort;
119+
91120
try
92121
{
93-
_jsEngine = new V8ScriptEngine();
122+
_jsEngine = new V8ScriptEngine(constraints, flags, debugPort);
94123
}
95124
catch (Exception e)
96125
{

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2012-2015 Andrey Taritsyn - http://www.taritsyn.ru
1+
Copyright (c) 2013-2015 Andrey Taritsyn - http://www.taritsyn.ru
22

33
Apache License
44
Version 2.0, January 2004

0 commit comments

Comments
 (0)