Skip to content

Commit 5ebc1dd

Browse files
Version 5.4.8: Added support for V8 parser and code caching; added ScriptObject to ease script object identification; fixed argument validation for interop interface parameters; fixed V8 crash when exceptions are thrown during script interruption (Issue ClearFoundry#112); fixed V8 crash when code that consumes iterable host objects is optimized; fixed intermittent deadlocks during V8 runtime teardown; added a 64-bit OS check in V8Update.cmd; added tests for bug fixes and new APIs. Tested with V8 5.4.500.40.
1 parent 26ec250 commit 5ebc1dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1305
-153
lines changed

ClearScript/ClearScript.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<Compile Include="ScriptMemberFlags.cs" />
8989
<Compile Include="ScriptMethod.cs" />
9090
<Compile Include="ScriptMemberAttribute.cs" />
91+
<Compile Include="ScriptObject.cs" />
9192
<Compile Include="ScriptUsageAttribute.cs" />
9293
<Compile Include="Util\AssemblyHelpers.cs" />
9394
<Compile Include="Util\Collateral.cs" />
@@ -111,6 +112,7 @@
111112
<Compile Include="V8\IV8DebugListener.cs" />
112113
<Compile Include="V8\V8ArrayBufferOrViewInfo.cs" />
113114
<Compile Include="V8\V8ArrayBufferOrViewKind.cs" />
115+
<Compile Include="V8\V8CacheKind.cs" />
114116
<Compile Include="V8\V8DebugAgent.cs" />
115117
<Compile Include="V8\V8RuntimeHeapInfo.cs" />
116118
<Compile Include="V8\V8Script.cs" />

ClearScript/Exports/VersionSymbols.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@
6363

6464
#pragma once
6565

66-
#define CLEARSCRIPT_VERSION_STRING "5.4.7.0"
67-
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 5,4,7,0
66+
#define CLEARSCRIPT_VERSION_STRING "5.4.8.0"
67+
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 5,4,8,0

ClearScript/HostFunctions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public object func(int argCount, object scriptFunc)
464464
/// <returns>The <see cref="System.Type"/> for the specified host type.</returns>
465465
/// <remarks>
466466
/// <para>
467-
/// This function is similar to the C#
467+
/// This function is similar to C#'s
468468
/// <c><see href="http://msdn.microsoft.com/en-us/library/58918ffs(VS.71).aspx">typeof</see></c>
469469
/// operator. It is overloaded with <see cref="typeOf(object)"/> and selected at runtime if
470470
/// <typeparamref name="T"/> can be used as a type argument.
@@ -499,7 +499,7 @@ public Type typeOf<T>()
499499
/// <returns>The <see cref="System.Type"/> for the specified host type.</returns>
500500
/// <remarks>
501501
/// <para>
502-
/// This function is similar to the C#
502+
/// This function is similar to C#'s
503503
/// <c><see href="http://msdn.microsoft.com/en-us/library/58918ffs(VS.71).aspx">typeof</see></c>
504504
/// operator. It is overloaded with <see cref="typeOf{T}"/> and selected at runtime if
505505
/// <paramref name="value"/> cannot be used as a type argument. Note that this applies to
@@ -534,7 +534,7 @@ public Type typeOf(object value)
534534
/// <param name="value">The object to test for compatibility with the specified host type.</param>
535535
/// <returns><c>True</c> if <paramref name="value"/> is compatible with the specified type, <c>false</c> otherwise.</returns>
536536
/// <remarks>
537-
/// This function is similar to the C#
537+
/// This function is similar to C#'s
538538
/// <c><see href="http://msdn.microsoft.com/en-us/library/scekt9xw(VS.71).aspx">is</see></c>
539539
/// operator.
540540
/// </remarks>
@@ -565,7 +565,7 @@ public bool isType<T>(object value)
565565
/// <param name="value">The object to cast to the specified host type.</param>
566566
/// <returns>The result of the cast if successful, <c>null</c> otherwise.</returns>
567567
/// <remarks>
568-
/// This function is similar to the C#
568+
/// This function is similar to C#'s
569569
/// <c><see href="http://msdn.microsoft.com/en-us/library/cscsdfbt(VS.71).aspx">as</see></c>
570570
/// operator.
571571
/// </remarks>

ClearScript/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@
7575
[assembly: InternalsVisibleTo("ClearScriptTest")]
7676

7777
[assembly: ComVisible(false)]
78-
[assembly: AssemblyVersion("5.4.7.0")]
79-
[assembly: AssemblyFileVersion("5.4.7.0")]
78+
[assembly: AssemblyVersion("5.4.8.0")]
79+
[assembly: AssemblyFileVersion("5.4.8.0")]

ClearScript/ScriptEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ public object Evaluate(string documentName, string code)
11311131
/// </item>
11321132
/// <item>
11331133
/// <term><b>Script&#xA0;Object</b></term>
1134-
/// <term><see href="http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject.aspx">System.Dynamic.DynamicObject</see></term>
1134+
/// <term><see cref="ScriptObject"/></term>
11351135
/// <description>
11361136
/// This includes all native script objects that have no .NET representation. C#'s
11371137
/// <see href="http://msdn.microsoft.com/en-us/library/dd264741.aspx">dynamic</see>

ClearScript/ScriptItem.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
namespace Microsoft.ClearScript
7474
{
75-
internal abstract class ScriptItem : DynamicObject, IExpando, IDynamic, IScriptMarshalWrapper
75+
internal abstract class ScriptItem : ScriptObject, IExpando, IDynamic, IScriptMarshalWrapper
7676
{
7777
private static readonly MethodInfo throwLastScriptErrorMethod = typeof(ScriptItem).GetMethod("ThrowLastScriptError");
7878
private static readonly MethodInfo clearLastScriptErrorMethod = typeof(ScriptItem).GetMethod("ClearLastScriptError");
@@ -419,8 +419,6 @@ public object GetProperty(string name, object[] args, out bool isCacheable)
419419

420420
#region IScriptMarshalWrapper implementation (abstract)
421421

422-
public abstract ScriptEngine Engine { get; }
423-
424422
public abstract object Unwrap();
425423

426424
#endregion

ClearScript/ScriptObject.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Dynamic;
2+
3+
namespace Microsoft.ClearScript
4+
{
5+
/// <summary>
6+
/// Represents a script object.
7+
/// </summary>
8+
/// <remarks>
9+
/// Use this class in conjunction with C#'s
10+
/// <c><see href="http://msdn.microsoft.com/en-us/library/scekt9xw(VS.71).aspx">is</see></c>
11+
/// operator to identify script objects.
12+
/// </remarks>
13+
/// <seealso cref="ScriptEngine.Evaluate(string, bool, string)"/>
14+
public abstract class ScriptObject : DynamicObject
15+
{
16+
internal ScriptObject()
17+
{
18+
}
19+
20+
/// <summary>
21+
/// Gets the script engine that owns the object.
22+
/// </summary>
23+
public abstract ScriptEngine Engine { get; }
24+
}
25+
}

ClearScript/Util/TypeHelpers.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
using System.Linq;
6767
using System.Reflection;
6868
using System.Runtime.CompilerServices;
69+
using System.Runtime.InteropServices;
6970

7071
namespace Microsoft.ClearScript.Util
7172
{
@@ -204,7 +205,32 @@ public static bool IsAssignableFrom(this Type type, ref object value)
204205

205206
if (!type.IsValueType)
206207
{
207-
return type.IsAssignableFrom(valueType);
208+
if (type.IsAssignableFrom(valueType))
209+
{
210+
return true;
211+
}
212+
213+
if (type.IsInterface && type.IsImport && valueType.IsCOMObject)
214+
{
215+
var result = false;
216+
var pUnknown = Marshal.GetIUnknownForObject(value);
217+
218+
var iid = type.GUID;
219+
if (iid != Guid.Empty)
220+
{
221+
IntPtr pInterface;
222+
if (RawCOMHelpers.HResult.Succeeded(Marshal.QueryInterface(pUnknown, ref iid, out pInterface)))
223+
{
224+
Marshal.Release(pInterface);
225+
result = true;
226+
}
227+
}
228+
229+
Marshal.Release(pUnknown);
230+
return result;
231+
}
232+
233+
return false;
208234
}
209235

210236
if (!valueType.IsValueType)

ClearScript/V8/ClearScriptV8/32/ClearScriptV8-32.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
<ClInclude Include="..\SharedPtr.h" />
227227
<ClInclude Include="..\StdString.h" />
228228
<ClInclude Include="..\Timer.h" />
229+
<ClInclude Include="..\V8CacheType.h" />
229230
<ClInclude Include="..\V8Context.h" />
230231
<ClInclude Include="..\V8ContextImpl.h" />
231232
<ClInclude Include="..\V8ContextProxyImpl.h" />

ClearScript/V8/ClearScriptV8/32/ClearScriptV8-32.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,8 @@
199199
<ClInclude Include="..\NativeCallbackImpl.h">
200200
<Filter>Header Files</Filter>
201201
</ClInclude>
202+
<ClInclude Include="..\V8CacheType.h">
203+
<Filter>Header Files</Filter>
204+
</ClInclude>
202205
</ItemGroup>
203206
</Project>

0 commit comments

Comments
 (0)