Skip to content

Commit

Permalink
Version 7.1.7: Fixed a crash affecting JavaScript iteration protocols…
Browse files Browse the repository at this point in the history
… in V8 (GitHub Issue microsoft#299); disabled V8 pointer compression to improve performance and fix GitHub Issue microsoft#291; added support for Visual Studio 2022; added symbols to managed component packages. Tested with V8 9.5.172.21.
  • Loading branch information
ClearScriptLib committed Oct 21, 2021
1 parent ced3162 commit 176b139
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 34 deletions.
5 changes: 2 additions & 3 deletions ClearScript/DocumentLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -406,9 +405,9 @@ private async Task<Document> LoadDocumentAsync(DocumentSettings settings, Uri ur
}
else
{
using (var client = new WebClient())
using (var client = new HttpClient())
{
contents = await client.DownloadStringTaskAsync(uri).ConfigureAwait(false);
contents = await client.GetStringAsync(uri).ConfigureAwait(false);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ClearScript/Exports/VersionSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

#define CLEARSCRIPT_VERSION_STRING "7.1.7"
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 7,1,7
#define CLEARSCRIPT_VERSION_STRING_INFORMATIONAL "7.1.7-preview"
#define CLEARSCRIPT_FILE_FLAGS VS_FF_PRERELEASE
#define CLEARSCRIPT_VERSION_STRING_INFORMATIONAL "7.1.7"
#define CLEARSCRIPT_FILE_FLAGS 0L
4 changes: 2 additions & 2 deletions ClearScript/Properties/AssemblyInfo.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("7.1.7")]
[assembly: AssemblyFileVersion("7.1.7")]
[assembly: AssemblyInformationalVersion("7.1.7-preview")]
[assembly: AssemblyInformationalVersion("7.1.7")]

namespace Microsoft.ClearScript.Properties
{
internal static class ClearScriptVersion
{
public const string Triad = "7.1.7";
public const string Informational = "7.1.7-preview";
public const string Informational = "7.1.7";
}
}
2 changes: 1 addition & 1 deletion ClearScript/Properties/AssemblyInfo.V8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("7.1.7")]
[assembly: AssemblyFileVersion("7.1.7")]
[assembly: AssemblyInformationalVersion("7.1.7-preview")]
[assembly: AssemblyInformationalVersion("7.1.7")]
2 changes: 1 addition & 1 deletion ClearScript/Properties/AssemblyInfo.Windows.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("7.1.7")]
[assembly: AssemblyFileVersion("7.1.7")]
[assembly: AssemblyInformationalVersion("7.1.7-preview")]
[assembly: AssemblyInformationalVersion("7.1.7")]
2 changes: 1 addition & 1 deletion ClearScript/Properties/AssemblyInfo.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("7.1.7")]
[assembly: AssemblyFileVersion("7.1.7")]
[assembly: AssemblyInformationalVersion("7.1.7-preview")]
[assembly: AssemblyInformationalVersion("7.1.7")]
2 changes: 1 addition & 1 deletion ClearScriptBenchmarks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("7.1.7")]
[assembly: AssemblyFileVersion("7.1.7")]
[assembly: AssemblyInformationalVersion("7.1.7-preview")]
[assembly: AssemblyInformationalVersion("7.1.7")]
6 changes: 3 additions & 3 deletions ClearScriptBenchmarks/SunSpider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;

namespace Microsoft.ClearScript.Test
Expand Down Expand Up @@ -113,9 +113,9 @@ private static int RunTest(ScriptEngine engine, MockDOM mockDOM, int index)

private static string DownloadFileAsString(string name)
{
using (var client = new WebClient())
using (var client = new HttpClient())
{
return client.DownloadString(baseUrl + name);
return client.GetStringAsync(baseUrl + name).Result;
}
}

Expand Down
4 changes: 4 additions & 0 deletions ClearScriptConsole/ConsoleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ public static unsafe void BugFix_V8StackLimitIntegerOverflow()

public static void BugFix_MultipleAppDomains()
{
#pragma warning disable SYSLIB0024 // Creating and unloading AppDomains is not supported and throws an exception

var domain1 = AppDomain.CreateDomain("domain1");
var domain2 = AppDomain.CreateDomain("domain2");

#pragma warning restore SYSLIB0024 // Creating and unloading AppDomains is not supported and throws an exception

var obj1 = (MultiAppDomainTest)domain1.CreateInstanceAndUnwrap(Assembly.GetEntryAssembly().FullName, typeof(MultiAppDomainTest).FullName);
var obj2 = (MultiAppDomainTest)domain2.CreateInstanceAndUnwrap(Assembly.GetEntryAssembly().FullName, typeof(MultiAppDomainTest).FullName);

Expand Down
2 changes: 1 addition & 1 deletion ClearScriptConsole/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("7.1.7")]
[assembly: AssemblyFileVersion("7.1.7")]
[assembly: AssemblyInformationalVersion("7.1.7-preview")]
[assembly: AssemblyInformationalVersion("7.1.7")]
23 changes: 21 additions & 2 deletions ClearScriptTest/BugFixTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,25 @@ public void BugFix_DefaultDocumentLoader_RedundantWebChecks()
Assert.AreEqual(10, statistics.WebCheckCount);
}

[TestMethod, TestCategory("BugFix")]
public void BugFix_V8_DisableGlobalMembers_IterationProtocol()
{
engine.Script.test = new[] { "one", "two", "three" };
Assert.AreEqual(3, ((dynamic)engine.Evaluate("Array.from(test)")).length);
Assert.AreEqual("one", ((dynamic)engine.Evaluate("Array.from(test)"))[0]);
Assert.AreEqual("two", ((dynamic)engine.Evaluate("Array.from(test)"))[1]);
Assert.AreEqual("three", ((dynamic)engine.Evaluate("Array.from(test)"))[2]);

engine.Dispose();
engine = new V8ScriptEngine(V8ScriptEngineFlags.EnableDebugging | V8ScriptEngineFlags.DisableGlobalMembers);

engine.Script.data = new[] { "foo", "bar", "baz" };
Assert.AreEqual(3, ((dynamic)engine.Evaluate("Array.from(data)")).length);
Assert.AreEqual("foo", ((dynamic)engine.Evaluate("Array.from(data)"))[0]);
Assert.AreEqual("bar", ((dynamic)engine.Evaluate("Array.from(data)"))[1]);
Assert.AreEqual("baz", ((dynamic)engine.Evaluate("Array.from(data)"))[2]);
}

// ReSharper restore InconsistentNaming

#endregion
Expand Down Expand Up @@ -1820,14 +1839,14 @@ public static async Task<string> GetStringAsync()
return "foo";
}

#pragma warning disable 1998
#pragma warning disable 1998 // This async method lacks 'await' operators and will run synchronously

public static async Task<string> GetStringQuicklyAsync()
{
return "foo";
}

#pragma warning restore 1998
#pragma warning restore 1998 // This async method lacks 'await' operators and will run synchronously

}

Expand Down
2 changes: 1 addition & 1 deletion ClearScriptTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("7.1.7")]
[assembly: AssemblyFileVersion("7.1.7")]
[assembly: AssemblyInformationalVersion("7.1.7-preview")]
[assembly: AssemblyInformationalVersion("7.1.7")]
17 changes: 6 additions & 11 deletions ClearScriptV8/V8ContextImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,7 @@ V8ContextImpl::V8ContextImpl(SharedPtr<V8IsolateImpl>&& spIsolateImpl, const Std
auto hGlobal = ::ValueAsObject(m_hContext->Global()->GetPrototype());
if (!hGlobal.IsEmpty() && (hGlobal->InternalFieldCount() > 0))
{
m_hGlobal = CreatePersistent(hGlobal);
m_hGlobal->SetAlignedPointerInInternalField(0, this);
hGlobal->SetAlignedPointerInInternalField(0, this);
}
}

Expand Down Expand Up @@ -1491,14 +1490,10 @@ void V8ContextImpl::Teardown()
// As of V8 3.16.0, the global property getter for a disposed context
// may be invoked during GC after the V8ContextImpl instance is gone.

if (!m_hGlobal.IsEmpty())
auto hGlobal = ::ValueAsObject(m_hContext->Global()->GetPrototype());
if (!hGlobal.IsEmpty() && (hGlobal->InternalFieldCount() > 0))
{
if (m_hGlobal->InternalFieldCount() > 0)
{
m_hGlobal->SetAlignedPointerInInternalField(0, nullptr);
}

Dispose(m_hGlobal);
hGlobal->SetAlignedPointerInInternalField(0, nullptr);
}

Dispose(m_hContext);
Expand Down Expand Up @@ -2049,7 +2044,7 @@ void V8ContextImpl::GetHostObjectIterator(const v8::FunctionCallbackInfo<v8::Val
{
if (pContextImpl->m_hToIteratorFunction.IsEmpty())
{
auto hEngineInternal = FROM_MAYBE(pContextImpl->m_hGlobal->Get(pContextImpl->m_hContext, FROM_MAYBE(pContextImpl->CreateString(StdString(SL("EngineInternal")))))).As<v8::Object>();
auto hEngineInternal = FROM_MAYBE(pContextImpl->m_hContext->Global()->Get(pContextImpl->m_hContext, FROM_MAYBE(pContextImpl->CreateString(StdString(SL("EngineInternal")))))).As<v8::Object>();
pContextImpl->m_hToIteratorFunction = pContextImpl->CreatePersistent(FROM_MAYBE(hEngineInternal->Get(pContextImpl->m_hContext, FROM_MAYBE(pContextImpl->CreateString(StdString(SL("toIterator")))))).As<v8::Function>());
}

Expand Down Expand Up @@ -2083,7 +2078,7 @@ void V8ContextImpl::GetHostObjectAsyncIterator(const v8::FunctionCallbackInfo<v8
{
if (pContextImpl->m_hToAsyncIteratorFunction.IsEmpty())
{
auto hEngineInternal = FROM_MAYBE(pContextImpl->m_hGlobal->Get(pContextImpl->m_hContext, FROM_MAYBE(pContextImpl->CreateString(StdString(SL("EngineInternal")))))).As<v8::Object>();
auto hEngineInternal = FROM_MAYBE(pContextImpl->m_hContext->Global()->Get(pContextImpl->m_hContext, FROM_MAYBE(pContextImpl->CreateString(StdString(SL("EngineInternal")))))).As<v8::Object>();
pContextImpl->m_hToAsyncIteratorFunction = pContextImpl->CreatePersistent(FROM_MAYBE(hEngineInternal->Get(pContextImpl->m_hContext, FROM_MAYBE(pContextImpl->CreateString(StdString(SL("toAsyncIterator")))))).As<v8::Function>());
}

Expand Down
1 change: 0 additions & 1 deletion ClearScriptV8/V8ContextImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ class V8ContextImpl final: public V8Context
SharedPtr<V8IsolateImpl> m_spIsolateImpl;
bool m_DateTimeConversionEnabled;
Persistent<v8::Context> m_hContext;
Persistent<v8::Object> m_hGlobal;
std::vector<std::pair<StdString, Persistent<v8::Object>>> m_GlobalMembersStack;
Persistent<v8::Symbol> m_hIsHostObjectKey;
Persistent<v8::String> m_hHostExceptionKey;
Expand Down
6 changes: 6 additions & 0 deletions ClearScriptV8/win-arm64/ClearScriptV8.win-arm64.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)'=='17.0'">
<PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)'==''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)'=='16.0'">
<PlatformToolset>v142</PlatformToolset>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)'==''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
Expand Down Expand Up @@ -83,6 +87,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='17.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='16.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='15.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='14.0'">true</GenerateDebugInformation>
Expand Down Expand Up @@ -119,6 +124,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='17.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='16.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='15.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='14.0'">true</GenerateDebugInformation>
Expand Down
6 changes: 6 additions & 0 deletions ClearScriptV8/win-x64/ClearScriptV8.win-x64.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)'=='17.0'">
<PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)'==''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)'=='16.0'">
<PlatformToolset>v142</PlatformToolset>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)'==''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
Expand Down Expand Up @@ -83,6 +87,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='17.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='16.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='15.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='14.0'">true</GenerateDebugInformation>
Expand Down Expand Up @@ -119,6 +124,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='17.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='16.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='15.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='14.0'">true</GenerateDebugInformation>
Expand Down
6 changes: 6 additions & 0 deletions ClearScriptV8/win-x86/ClearScriptV8.win-x86.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)'=='17.0'">
<PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)'==''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)'=='16.0'">
<PlatformToolset>v142</PlatformToolset>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)'==''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
Expand Down Expand Up @@ -82,6 +86,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='17.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='16.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='15.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='14.0'">true</GenerateDebugInformation>
Expand Down Expand Up @@ -118,6 +123,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='17.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='16.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='15.0'">DebugFull</GenerateDebugInformation>
<GenerateDebugInformation Condition="'$(VisualStudioVersion)'=='14.0'">true</GenerateDebugInformation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Unix/V8Update.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

v8testedrev=9.5.172.13
v8testedrev=9.5.172.21
v8testedcommit=

if [[ $v8testedcommit == "" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion V8/V8Patch.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/BUILD.gn b/BUILD.gn
index 5c7d931b27..d64217a502 100644
index 5c7d931b27..665f145a6a 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -970,7 +970,7 @@ config("toolchain") {
Expand Down
2 changes: 1 addition & 1 deletion V8Update.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
setlocal

set v8testedrev=9.5.172.13
set v8testedrev=9.5.172.21
set v8testedcommit=

if not "%v8testedcommit%"=="" goto ProcessArgs
Expand Down
2 changes: 1 addition & 1 deletion Version.tt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<#
var version = new Version(7, 1, 7);
var versionSuffix = "-preview";
var versionSuffix = string.Empty;
new Random(versionSuffix.Length); // suppress "versionSuffix not used" warning
#>

0 comments on commit 176b139

Please sign in to comment.