Skip to content

Commit 54cd16d

Browse files
committed
Improve internal library serialized byte code versioning
- Use different byte code versioning scheme value for chakracore from chakra in release build as well. - Separate release flags between chakra/chakracore so that they can go into release mode independently. - Make library byte code always use the release versioning scheme. - Update the no jit version of the Intl byte code. - Change the top level output directory for the no jit version to have the ".NoJIT" suffix so it can be built independently of the with jit verison.
1 parent f337c17 commit 54cd16d

11 files changed

+8904
-8729
lines changed

Build/Common.Build.Default.props

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<PropertyGroup>
5757
<OutBaseDir Condition="'$(OutBaseDir)'!=''">$(OutBaseDir)\$(SolutionName)</OutBaseDir>
5858
<OutBaseDir Condition="'$(OutBaseDir)'==''">$(SolutionDir)VcBuild</OutBaseDir>
59+
<OutBaseDir Condition="'$(BuildJIT)'=='false'">$(OutBaseDir).NoJIT</OutBaseDir>
5960
<IntBaseDir Condition="'$(IntBaseDir)'==''">$(OutBaseDir)</IntBaseDir>
6061
</PropertyGroup>
6162

bin/ChakraCore/ChakraCore.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<ClCompile Include="$(MsBuildThisFileDirectory)ConfigParserExternals.cpp" />
7070
<ClCompile Include="$(MsBuildThisFileDirectory)ChakraCoreDLLFunc.cpp" />
7171
<ClCompile Include="TestHooks.cpp" />
72-
<None Include="CoreCommon.ver" />
72+
<None Include="..\CoreCommon.ver" />
7373
</ItemGroup>
7474
<ItemGroup>
7575
<ResourceCompile Include="$(MsBuildThisFileDirectory)ChakraCore.rc">

bin/CoreCommon.ver

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
#define VER_DEBUG 0
2020
#endif
2121

22-
#if CHAKRA_VERSION_BUILD_RELEASE
22+
#if CHAKRA_CORE_VERSION_RELEASE
2323
#define VER_PRIVATE 0
2424
#else
2525
#define VER_PRIVATE VS_FF_PRIVATEBUILD
2626
#endif
2727

28-
#if CHAKRA_VERSION_BUILD_RELEASE && CHAKRA_VERSION_BUILD_PRERELEASE
28+
#if CHAKRA_CORE_VERSION_RELEASE && CHAKRA_CORE_VERSION_PRERELEASE
2929
#define VER_PRERELEASE VS_FF_PRERELEASE
3030
#else
3131
#define VER_PRERELEASE 0
@@ -38,22 +38,22 @@
3838
#define VER_FILEDESCRIPTION_SUFFIX1_STR L"Test"
3939
#endif
4040

41-
#if !CHAKRA_VERSION_BUILD_RELEASE
41+
#if !CHAKRA_CORE_VERSION_RELEASE
4242
#define VER_FILEDESCRIPTION_SUFFIX2_STR L"Private"
43-
#elif CHAKRA_VERSION_BUILD_PRERELEASE
43+
#elif CHAKRA_CORE_VERSION_PRERELEASE
4444
#define VER_FILEDESCRIPTION_SUFFIX2_STR L"Pre-release"
4545
#endif
4646

47-
#if CHAKRA_VERSION_BUILD_RELEASE
47+
#if CHAKRA_CORE_VERSION_RELEASE
4848
#define VER_PRODUCTBUILD 0
4949
#elif CHAKRA_VERSION_BUILD_NUMBER
5050
#define VER_PRODUCTBUILD CHAKRA_VERSION_BUILD_NUMBER
5151
#else
5252
#define VER_PRODUCTBUILD 65535
5353
#endif
5454

55-
#if CHAKRA_VERSION_BUILD_RELEASE
56-
#define VER_PRODUCTBUILD_QFE CHAKRA_VERSION_BUILD_RELEASE_QFE
55+
#if CHAKRA_CORE_VERSION_RELEASE
56+
#define VER_PRODUCTBUILD_QFE CHAKRA_CORE_VERSION_RELEASE_QFE
5757
#elif CHAKRA_VERSION_BUILD_QFE
5858
#define VER_PRODUCTBUILD_QFE CHAKRA_VERSION_BUILD_QFE
5959
#else

lib/Runtime/ByteCode/ByteCodeSerializer.cpp

+31-40
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,31 @@ namespace Js
8686
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
8787
// Byte Code Serializer Versioning scheme
8888
// Version number is a GUID (128 bits). There are two versioning modes--Engineering and Release. Engineering mode is for day-to-day development. Every time chakra.dll is built a
89-
// fresh new version is generated by hashing the build date and time. This means that a byte code file saved to disk is exactly tied to the chakra.dll that generated it. This works
89+
// fresh new version is generated by hashing the build date and time. This means that a byte code file saved to disk is exactly tied to the binary that generated it. This works
9090
// well for QA test runs and buddy tests because there is no chance of effects between runs.
9191
//
9292
// Release mode is used when chakra.dll is close to public release where there are actual changes to chakra. The GUID is a fixed number from build-to-build. This number will stay
93-
// the same for releases where there is no change to jscript9. The reason for this is that we don't want to invalidate compatible byte code that has already been cached.
93+
// the same for releases where there is no change to chakra.dll. The reason for this is that we don't want to invalidate compatible byte code that has already been cached.
9494
enum FileVersionScheme : byte
9595
{
96-
// Even Chakra and ChakraCore may have the same version, their byte code may not be compatible. Give them different value.
96+
// Currently Chakra and ChakraCore versioning scheme is different.
97+
// Same version number for Chakra and ChakraCore doesn't mean they are the same.
98+
// Give the versioning scheme different value, so that byte code generate from one won't be use in the other.
9799
#ifdef NTBUILD
98100
EngineeringVersioningScheme = 10,
101+
ReleaseVersioningScheme = 20,
99102
#else
100103
EngineeringVersioningScheme = 11,
104+
ReleaseVersioningScheme = 21,
105+
#endif
106+
107+
#if (defined(NTBUILD) && CHAKRA_VERSION_RELEASE) || (!defined(NTBUILD) && CHAKRA_CORE_VERSION_RELEASE)
108+
CurrentFileVersionScheme = ReleaseVersioningScheme
109+
#else
110+
CurrentFileVersionScheme = EngineeringVersioningScheme
101111
#endif
102-
LibraryEngineeringVersioningScheme = 12,
103-
ReleaseVersioningScheme = 20
104112
};
105113

106-
const FileVersionScheme currentFileVersionScheme = EngineeringVersioningScheme;
107-
const FileVersionScheme currentFileVersionSchemeLibrary = LibraryEngineeringVersioningScheme;
108114

109115
// it should be in separate file for testing
110116
#include "byteCodeCacheReleaseFileVersion.h"
@@ -411,7 +417,8 @@ class ByteCodeBufferBuilder
411417
expectedOpCodeCount.value = 0;
412418
}
413419

414-
byte actualFileVersionScheme = GenerateLibraryByteCode()? currentFileVersionSchemeLibrary : currentFileVersionScheme;
420+
// library alaways use the release versioning scheme
421+
byte actualFileVersionScheme = GenerateLibraryByteCode()? ReleaseVersioningScheme : CurrentFileVersionScheme;
415422
#if ENABLE_DEBUG_CONFIG_OPTIONS
416423
if (Js::Configuration::Global.flags.ForceSerializedBytecodeVersionSchema)
417424
{
@@ -421,22 +428,14 @@ class ByteCodeBufferBuilder
421428
fileVersionKind.value = actualFileVersionScheme;
422429
if (actualFileVersionScheme != ReleaseVersioningScheme)
423430
{
424-
if (GenerateLibraryByteCode())
425-
{
426-
Assert(actualFileVersionScheme == LibraryEngineeringVersioningScheme);
427-
// Library code always follows the ChakraCore version
428-
V1.value = CHAKRA_CORE_MAJOR_VERSION << 16 | CHAKRA_CORE_MINOR_VERSION;
429-
}
430-
else
431-
{
432-
Assert(actualFileVersionScheme == EngineeringVersioningScheme);
433-
DWORD jscriptMajor, jscriptMinor, buildDateHash, buildTimeHash;
434-
Js::VerifyOkCatastrophic(AutoSystemInfo::GetJscriptFileVersion(&jscriptMajor, &jscriptMinor, &buildDateHash, &buildTimeHash));
435-
V1.value = jscriptMajor;
436-
V2.value = jscriptMinor;
437-
V3.value = buildDateHash;
438-
V4.value = buildTimeHash;
439-
}
431+
Assert(!GenerateLibraryByteCode());
432+
Assert(actualFileVersionScheme == EngineeringVersioningScheme);
433+
DWORD jscriptMajor, jscriptMinor, buildDateHash, buildTimeHash;
434+
Js::VerifyOkCatastrophic(AutoSystemInfo::GetJscriptFileVersion(&jscriptMajor, &jscriptMinor, &buildDateHash, &buildTimeHash));
435+
V1.value = jscriptMajor;
436+
V2.value = jscriptMinor;
437+
V3.value = buildDateHash;
438+
V4.value = buildTimeHash;
440439
}
441440
else
442441
{
@@ -2595,15 +2594,15 @@ class ByteCodeBufferReader
25952594
HRESULT ReadHeader()
25962595
{
25972596
auto current = ReadConstantSizedInt32NoSize(raw, &magic);
2598-
if (magic!=magicConstant)
2597+
if (magic != magicConstant)
25992598
{
26002599
AssertMsg(false, "Unrecognized magic constant in byte code file header. Is this really a bytecode file?");
26012600
return E_FAIL;
26022601
}
26032602
current = ReadConstantSizedInt32NoSize(current, &totalSize);
26042603
current = ReadByte(current, &fileVersionScheme);
26052604

2606-
byte expectedFileVersionScheme = isLibraryCode? currentFileVersionSchemeLibrary : currentFileVersionScheme;
2605+
byte expectedFileVersionScheme = isLibraryCode? ReleaseVersioningScheme : CurrentFileVersionScheme;
26072606
#if ENABLE_DEBUG_CONFIG_OPTIONS
26082607
if (Js::Configuration::Global.flags.ForceSerializedBytecodeVersionSchema)
26092608
{
@@ -2623,17 +2622,9 @@ class ByteCodeBufferReader
26232622

26242623
if (expectedFileVersionScheme != ReleaseVersioningScheme)
26252624
{
2626-
if (isLibraryCode)
2627-
{
2628-
Js::VerifyCatastrophic(expectedFileVersionScheme == LibraryEngineeringVersioningScheme);
2629-
// Library code always use the ChakraCore version
2630-
expectedV1 = CHAKRA_CORE_MAJOR_VERSION << 16 | CHAKRA_CORE_MINOR_VERSION;
2631-
}
2632-
else
2633-
{
2634-
Js::VerifyCatastrophic(expectedFileVersionScheme == EngineeringVersioningScheme);
2635-
Js::VerifyOkCatastrophic(AutoSystemInfo::GetJscriptFileVersion(&expectedV1, &expectedV2, &expectedV3, &expectedV4));
2636-
}
2625+
Js::VerifyCatastrophic(!isLibraryCode);
2626+
Js::VerifyCatastrophic(expectedFileVersionScheme == EngineeringVersioningScheme);
2627+
Js::VerifyOkCatastrophic(AutoSystemInfo::GetJscriptFileVersion(&expectedV1, &expectedV2, &expectedV3, &expectedV4));
26372628
}
26382629
else
26392630
{
@@ -2682,7 +2673,7 @@ class ByteCodeBufferReader
26822673
current = ReadByte(current, &architecture);
26832674
if (architecture!=magicArchitecture)
26842675
{
2685-
// This byte cache file was created with against a jscript running under a different architecture. It is incompatible.
2676+
// This byte cache file was created with against a chakra running under a different architecture. It is incompatible.
26862677
return ByteCodeSerializer::InvalidByteCode;
26872678
}
26882679

@@ -2696,13 +2687,13 @@ class ByteCodeBufferReader
26962687
current = ReadInt32(current, &buildInPropertyCount);
26972688
if (buildInPropertyCount!=expectedBuildInPropertyCount)
26982689
{
2699-
// This byte cache file was created with against a jscript that has a different number of built in properties. It is incompatible.
2690+
// This byte cache file was created with against a chakra that has a different number of built in properties. It is incompatible.
27002691
return ByteCodeSerializer::InvalidByteCode;
27012692
}
27022693
current = ReadInt32(current, &opCodeCount);
27032694
if (opCodeCount != expectedOpCodeCount)
27042695
{
2705-
// This byte cache file was created with against a jscript that has a different number of built in properties. It is incompatible.
2696+
// This byte cache file was created with against a chakra that has a different number of built in properties. It is incompatible.
27062697
return ByteCodeSerializer::InvalidByteCode;
27072698
}
27082699
current = ReadInt32(current, &sourceSize);

lib/Runtime/ByteCode/byteCodeCacheReleaseFileVersion.h

+3-14
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
//-------------------------------------------------------------------------------------------------------
55
// NOTE: If there is a merge conflict the correct fix is to make a new GUID.
66

7-
const GUID byteCodeCacheReleaseFileVersion = { /* 52B8F09F-7CFC-43E4-9D50-FC7D3503305B */
8-
0x52b8f09f,
9-
0x7cfc,
10-
0x43e4,
11-
{ 0x9d, 0x50, 0xfc, 0x7d, 0x35, 0x3, 0x30, 0x5b }
12-
};
13-
14-
// Touching file in order to pass unit-tests (they expect this file to be edited for all inetcore/jscript/... changes
15-
// Enabling version unittest for Servicing branch
16-
// Editing file without updating GUID, bytecode is not changed by this changeset
17-
// Editing file without updating GUID, bytecode is not changed by this changeset
18-
// Editing file without updating GUID, bytecode is not changed by this changeset
19-
// Editing file without updating GUID, bytecode is not changed by this changeset
20-
// Editing file without updating GUID, bytecode is not changed by this changeset
7+
// {A1B09088-45E7-42DB-8D65-FB739F559946}
8+
const GUID byteCodeCacheReleaseFileVersion =
9+
{ 0xa1b09088, 0x45e7, 0x42db,{ 0x8d, 0x65, 0xfb, 0x73, 0x9f, 0x55, 0x99, 0x46 } };

lib/Runtime/Library/InJavascript/GenByteCode.cmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ if "%1"=="-nojit" (
88
)
99

1010
:: This script will expect ch.exe to be built for x86_debug and x64_debug
11-
set _BinLocation=%~dp0..\..\..\..\Build\VcBuild\bin
11+
set _BinLocation=%~dp0..\..\..\..\Build\VcBuild%_suffix%\bin
1212
if "%OutBaseDir%" NEQ "" (
13-
set _BinLocation=%OutBaseDir%\Chakra.Core\bin
13+
set _BinLocation=%OutBaseDir%\Chakra.Core%_suffix%\bin
1414
)
1515

1616
if not exist %_BinLocation%\x86_debug\ch.exe (

0 commit comments

Comments
 (0)