Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit ab8fd54

Browse files
author
Jianchun Xu
committed
chakrashim: update chakracore (2016-07-22)
Update chakracore to linux HEAD at chakra-core/ChakraCore@814d084 PR-URL: #100 Reviewed-By: Kunal Pathak <Kunal.Pathak@microsoft.com>
1 parent 5021d49 commit ab8fd54

File tree

124 files changed

+3271
-821
lines changed

Some content is hidden

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

124 files changed

+3271
-821
lines changed

deps/chakrashim/core/Build/Chakra.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
%(PreprocessorDefinitions);
2525
DISABLE_JIT=1
2626
</PreprocessorDefinitions>
27+
<PreprocessorDefinitions Condition="'$(ENABLE_CODECOVERAGE)'=='true'">
28+
%(PreprocessorDefinitions);
29+
BYTECODE_TESTING=1
30+
</PreprocessorDefinitions>
2731
<!-- REVIEW: These are warning are introduced when moving to VS2015 tools, may want to clean these up -->
2832
<DisableSpecificWarnings>
2933
%(DisableSpecificWarnings);

deps/chakrashim/core/Build/scripts/init_build.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ if ($BranchPath.StartsWith("build")) {
112112
$BuildIdentifier = "${buildPushIdString}_${PushDate}_${Username}_${CommitHash}"
113113
$ComputedDropPathSegment = "${BranchPath}\${YearAndMonth}${BuildIdentifier}"
114114
$BinariesDirectory = "${Env:BUILD_SOURCESDIRECTORY}\Build\VcBuild"
115+
$ObjectDirectory = "${BinariesDirectory}\obj\${BuildPlatform}_${BuildConfiguration}"
115116

116117
# Create a sentinel file for each build flavor to track whether the build is complete.
117118
# * ${arch}_${flavor}.incomplete # will be deleted when the build of this flavor completes
@@ -178,7 +179,7 @@ set TF_BUILD_SOURCEGETVERSION=LG:${branch}:${CommitHash}
178179
set TF_BUILD_DROPLOCATION=${BinariesDirectory}
179180
180181
set TF_BUILD_SOURCESDIRECTORY=${Env:BUILD_SOURCESDIRECTORY}
181-
REM set TF_BUILD_BUILDDIRECTORY=${Env:AGENT_BUILDDIRECTORY}\b # note: inferred location works
182+
set TF_BUILD_BUILDDIRECTORY=${ObjectDirectory}
182183
set TF_BUILD_BINARIESDIRECTORY=${BinariesDirectory}
183184
184185
set TF_BUILD_BUILDDEFINITIONNAME=${Env:BUILD_DEFINITIONNAME}

deps/chakrashim/core/CODE_OF_CONDUCT.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

deps/chakrashim/core/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ Contributions to ChakraCore are welcome. Here is how you can contribute to Chak
9797
* [Submit pull requests](https://github.com/Microsoft/ChakraCore/pulls) for bug fixes and features and discuss existing proposals
9898
* Chat about [@ChakraCore](https://twitter.com/ChakraCore) on Twitter
9999

100-
Please refer to [Contribution guidelines](CONTRIBUTING.md) and the [Code of Conduct](CODE_OF_CONDUCT.md) for more details.
100+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
101+
102+
Please refer to [Contribution guidelines](CONTRIBUTING.md) for more details.
101103

102104
### License
103105

deps/chakrashim/core/bin/ChakraCore/ChakraCore.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ JsTTDNotifyYield
3838
JsTTDPrepContextsForTopLevelEventMove
3939
JsTTDMoveToTopLevelEvent
4040
JsTTDReplayExecution
41+
42+
JsInitializeModuleRecord
43+
JsParseModuleSource
44+
JsModuleEvaluation
45+
JsSetModuleHostInfo
46+
JsGetModuleHostInfo
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
#include "stdafx.h"
6+
#include "catch.hpp"
7+
#include <process.h>
8+
#include "Codex\Utf8Codex.h"
9+
10+
#pragma warning(disable:4100) // unreferenced formal parameter
11+
#pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs
12+
#pragma warning(disable:6262) // CATCH is using stack variables to report errors, suppressing the preFAST warning.
13+
14+
namespace CodexTest
15+
{
16+
///
17+
/// The following test verifies that for invalid characters, we replace them
18+
/// with the unicode replacement character
19+
///
20+
21+
// Verify single utf8-encoded codepoint
22+
void CheckIsUnicodeReplacementChar(const utf8char_t* encodedBuffer)
23+
{
24+
CHECK(encodedBuffer[0] == 0xEF);
25+
CHECK(encodedBuffer[1] == 0xBF);
26+
CHECK(encodedBuffer[2] == 0xBD);
27+
}
28+
29+
//
30+
// Following test cases are based on the Utf-8 decoder tests
31+
// suggested by Markus Kuhn at https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
32+
//
33+
TEST_CASE("CodexTest_EncodeTrueUtf8_SingleSurrogates", "[CodexTest]")
34+
{
35+
const charcount_t charCount = 1;
36+
utf8char_t encodedBuffer[(charCount + 1) * 3]; // +1 since the buffer will be null-terminated
37+
38+
char16 testValues[] = { 0xD800, 0xDB7F, 0xDB80, 0xDBFF, 0xDC00, 0xDF80, 0xDFFF };
39+
const int numTestCases = _countof(testValues);
40+
41+
for (int i = 0; i < numTestCases; i++)
42+
{
43+
size_t numEncodedBytes = utf8::EncodeTrueUtf8IntoAndNullTerminate(encodedBuffer, &testValues[i], charCount);
44+
CHECK(numEncodedBytes == 3);
45+
CheckIsUnicodeReplacementChar(encodedBuffer);
46+
}
47+
}
48+
49+
//
50+
// Test encoding of given utf16-encoded strings into another encoding
51+
//
52+
// In the expected encoded string, extra bytes are represented as 0
53+
//
54+
55+
template <typename TTestCase, typename TEncodingFunc>
56+
void RunUtf8EncodingTestCase(const TTestCase &testCases, const TEncodingFunc func)
57+
{
58+
const int numTestCases = _countof(testCases);
59+
const charcount_t charCount = _countof(testCases[0].surrogatePair);
60+
const charcount_t maxEncodedByteCount = _countof(testCases[0].utf8Encoding);
61+
utf8char_t encodedBuffer[maxEncodedByteCount + 1]; // +1 in case a null-terminating func is passed in
62+
63+
for (int i = 0; i < numTestCases; i++)
64+
{
65+
size_t numEncodedBytes = func(encodedBuffer, testCases[i].surrogatePair, charCount);
66+
CHECK(numEncodedBytes <= maxEncodedByteCount);
67+
for (size_t j = 0; j < numEncodedBytes; j++)
68+
{
69+
CHECK(encodedBuffer[j] == testCases[i].utf8Encoding[j]);
70+
}
71+
72+
// Check and make sure there were no other bytes expected in the encoded string
73+
if (numEncodedBytes < maxEncodedByteCount)
74+
{
75+
for (size_t j = numEncodedBytes; j < maxEncodedByteCount; j++)
76+
{
77+
CHECK(testCases[i].utf8Encoding[j] == 0);
78+
}
79+
}
80+
}
81+
}
82+
83+
TEST_CASE("CodexTest_EncodeCesu_PairedSurrogates", "[CodexTest]")
84+
{
85+
// Each of these test cases verifies the encoding
86+
// of a single surrogate pair into a 6 byte CESU string
87+
// Each surrogate-pair unit is encoded seperately into utf8
88+
struct TestCase
89+
{
90+
char16 surrogatePair[2];
91+
utf8char_t utf8Encoding[6];
92+
};
93+
94+
TestCase testCases[] = {
95+
{ { 0xD800, 0xDC00 }, { 0xED, 0xA0, 0x80, 0xED, 0xB0, 0x80 } }, // U+010000 LINEAR B SYLLABLE B008 A character
96+
{ { 0xD800, 0xDFFF }, { 0xED, 0xA0, 0x80, 0xED, 0xBF, 0xBF } }, // U+0103FF
97+
{ { 0xDB7F, 0xDC00 }, { 0xED, 0xAD, 0xBF, 0xED, 0xB0, 0x80 } }, // U+0EFC00
98+
{ { 0xDB7F, 0xDFFF }, { 0xED, 0xAD, 0xBF, 0xED, 0xBF, 0xBF } }, // U+0EFFFF
99+
{ { 0xDB80, 0xDC00 }, { 0xED, 0xAE, 0x80, 0xED, 0xB0, 0x80 } }, // U+0F0000 Plane 15 Private Use First
100+
{ { 0xDB80, 0xDFFF }, { 0xED, 0xAE, 0x80, 0xED, 0xBF, 0xBF } }, // U+0F03FF
101+
{ { 0xDBFF, 0xDC00 }, { 0xED, 0xAF, 0xBF, 0xED, 0xB0, 0x80 } }, // U+10FC00
102+
{ { 0xDBFF, 0xDFFF }, { 0xED, 0xAF, 0xBF, 0xED, 0xBF, 0xBF } } // U+10FFFF
103+
};
104+
105+
RunUtf8EncodingTestCase(testCases, static_cast<size_t (*)(utf8char_t*, const char16*, charcount_t)>(utf8::EncodeInto));
106+
}
107+
108+
TEST_CASE("CodexTest_EncodeUtf8_PairedSurrogates", "[CodexTest]")
109+
{
110+
// Each of these test cases verifies the encoding
111+
// of a single surrogate pair into a 4 byte utf8 string
112+
// Each surrogate-pair unit is decoded to its original codepoint
113+
// and then encoded into utf8
114+
struct TestCase
115+
{
116+
char16 surrogatePair[2];
117+
utf8char_t utf8Encoding[4];
118+
};
119+
120+
TestCase testCases[] = {
121+
{ { 0xD800, 0xDC00 }, { 0xF0, 0x90, 0x80, 0x80 } }, // U+010000 LINEAR B SYLLABLE B008 A character
122+
{ { 0xD800, 0xDFFF }, { 0xF0, 0x90, 0x8F, 0xBF } }, // U+0103FF
123+
{ { 0xDB7F, 0xDC00 }, { 0xF3, 0xAF, 0xB0, 0x80 } }, // U+0EFC00
124+
{ { 0xDB7F, 0xDFFF }, { 0xF3, 0xAF, 0xBF, 0xBF } }, // U+0EFFFF
125+
{ { 0xDB80, 0xDC00 }, { 0xF3, 0xB0, 0x80, 0x80 } }, // U+0F0000 Plane 15 Private Use First
126+
{ { 0xDB80, 0xDFFF }, { 0xF3, 0xB0, 0x8F, 0xBF } }, // U+0F03FF
127+
{ { 0xDBFF, 0xDC00 }, { 0xF4, 0x8F, 0xB0, 0x80 } }, // U+10FC00
128+
{ { 0xDBFF, 0xDFFF }, { 0xF4, 0x8F, 0xBF, 0xBF } } // U+10FFFF
129+
};
130+
131+
RunUtf8EncodingTestCase(testCases, utf8::EncodeTrueUtf8IntoAndNullTerminate);
132+
}
133+
134+
TEST_CASE("CodexTest_EncodeUtf8_NonCharacters", "[CodexTest]")
135+
{
136+
// Each of these test cases verifies the encoding
137+
// of certain problematic codepoints that do not represent
138+
// characters
139+
struct TestCase
140+
{
141+
char16 surrogatePair[1];
142+
utf8char_t utf8Encoding[3];
143+
};
144+
145+
TestCase testCases[] = {
146+
{ { 0xFFFE }, { 0xEF, 0xBF, 0xBE } }, // U+FFFE
147+
{ { 0xFFFF }, { 0xEF, 0xBF, 0xBF } } // U+FFFF
148+
};
149+
150+
RunUtf8EncodingTestCase(testCases, utf8::EncodeTrueUtf8IntoAndNullTerminate);
151+
}
152+
153+
TEST_CASE("CodexTest_EncodeUtf8_BoundaryChars", "[CodexTest]")
154+
{
155+
// Each of these test cases verifies the encoding
156+
// of boundary conditions
157+
struct SingleChar16TestCase
158+
{
159+
char16 surrogatePair[1];
160+
utf8char_t utf8Encoding[3];
161+
};
162+
163+
SingleChar16TestCase testCases[] = {
164+
{ { 0xD7FF }, { 0xED, 0x9F, 0xBF } }, // U+D7FF
165+
{ { 0xE000 }, { 0xEE, 0x80, 0x80 } }, // U+E000
166+
{ { 0xFFFD }, { 0xEF, 0xBF, 0xBD } } // U+FFFD
167+
};
168+
169+
struct TwoChar16TestCase
170+
{
171+
char16 surrogatePair[2];
172+
utf8char_t utf8Encoding[4];
173+
};
174+
175+
TwoChar16TestCase testCases2[] = {
176+
{ { 0xDBFF, 0xDFFF }, { 0xF4, 0x8F, 0xBF, 0xBF } } // U+10FFFF
177+
};
178+
179+
RunUtf8EncodingTestCase(testCases, utf8::EncodeTrueUtf8IntoAndNullTerminate);
180+
RunUtf8EncodingTestCase(testCases2, utf8::EncodeTrueUtf8IntoAndNullTerminate);
181+
}
182+
183+
TEST_CASE("CodexTest_EncodeUtf8_SimpleCharacters", "[CodexTest]")
184+
{
185+
// Each of these test cases verifies the encoding
186+
// of certain problematic codepoints that do not represent
187+
// characters
188+
struct TestCase
189+
{
190+
char16 surrogatePair[1];
191+
utf8char_t utf8Encoding[3];
192+
};
193+
194+
TestCase testCases[] = {
195+
{ { 0x0024 }, { 0x24 } }, // U+0024 - Dollar Symbol
196+
{ { 0x00A2 }, { 0xC2, 0xA2 } }, // U+00A2 - Cent symbol
197+
{ { 0x20AC }, { 0xE2, 0x82, 0xAC } } // U+20AC - Euro symbol
198+
};
199+
200+
RunUtf8EncodingTestCase(testCases, utf8::EncodeTrueUtf8IntoAndNullTerminate);
201+
}
202+
203+
TEST_CASE("CodexTest_EncodeTrueUtf8_SimpleString", "[CodexTest]")
204+
{
205+
const charcount_t charCount = 3;
206+
utf8char_t encodedBuffer[(charCount + 1) * 3]; // +1 since the buffer will be null terminated
207+
char16* sourceBuffer = L"abc";
208+
size_t numEncodedBytes = utf8::EncodeTrueUtf8IntoAndNullTerminate(encodedBuffer, sourceBuffer, charCount);
209+
CHECK(numEncodedBytes == charCount);
210+
for (int i = 0; i < charCount; i++)
211+
{
212+
CHECK(sourceBuffer[i] == (char16)encodedBuffer[i]);
213+
}
214+
}
215+
};

deps/chakrashim/core/bin/NativeTests/NativeTests.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<ClInclude Include="stdafx.h" />
4343
</ItemGroup>
4444
<ItemGroup>
45+
<ClCompile Include="CodexTests.cpp" />
4546
<ClCompile Include="FileLoadHelpers.cpp" />
4647
<ClCompile Include="CodexAssert.cpp" />
4748
<ClCompile Include="JsRTApiTest.cpp" />

deps/chakrashim/core/bin/ch/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(ch_source_files
1+
set(ch_source_files
22
ch.cpp
33
ChakraRtInterface.cpp
44
CodexAssert.cpp
@@ -67,6 +67,8 @@ if(STATIC_LIBRARY)
6767
icucore
6868
"-framework CoreFoundation"
6969
"-framework Security"
70+
# set stack size to 64Mb for stack tests
71+
-Wl,-stack_size,0x04000000
7072
)
7173
endif() # Linux ?
7274
else() # // !from shared library
@@ -78,7 +80,7 @@ else() # // !from shared library
7880
endif()
7981

8082
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
81-
set(lib_target "${lib_target}"
83+
set(lib_target "${lib_target}"
8284
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/ch.version
8385
)
8486
endif()

deps/chakrashim/core/bin/ch/ChakraRtInterface.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
115115
m_jsApiHooks.pfJsrtSetPromiseContinuationCallback = (JsAPIHooks::JsrtSetPromiseContinuationCallbackPtr)GetChakraCoreSymbol(library, "JsSetPromiseContinuationCallback");
116116
m_jsApiHooks.pfJsrtGetContextOfObject = (JsAPIHooks::JsrtGetContextOfObject)GetChakraCoreSymbol(library, "JsGetContextOfObject");
117117
m_jsApiHooks.pfJsrtParseScriptWithAttributesUtf8 = (JsAPIHooks::JsrtParseScriptWithAttributesUtf8)GetChakraCoreSymbol(library, "JsParseScriptWithAttributesUtf8");
118+
m_jsApiHooks.pfJsrtInitializeModuleRecord = (JsAPIHooks::JsInitializeModuleRecordPtr)GetChakraCoreSymbol(library, "JsInitializeModuleRecord");
119+
m_jsApiHooks.pfJsrtParseModuleSource = (JsAPIHooks::JsParseModuleSourcePtr)GetChakraCoreSymbol(library, "JsParseModuleSource");
120+
m_jsApiHooks.pfJsrtSetModuleHostInfo = (JsAPIHooks::JsSetModuleHostInfoPtr)GetChakraCoreSymbol(library, "JsSetModuleHostInfo");
121+
m_jsApiHooks.pfJsrtGetModuleHostInfo = (JsAPIHooks::JsGetModuleHostInfoPtr)GetChakraCoreSymbol(library, "JsGetModuleHostInfo");
122+
m_jsApiHooks.pfJsrtModuleEvaluation = (JsAPIHooks::JsModuleEvaluationPtr)GetChakraCoreSymbol(library, "JsModuleEvaluation");
118123
m_jsApiHooks.pfJsrtDiagStartDebugging = (JsAPIHooks::JsrtDiagStartDebugging)GetChakraCoreSymbol(library, "JsDiagStartDebugging");
119124
m_jsApiHooks.pfJsrtDiagStopDebugging = (JsAPIHooks::JsrtDiagStopDebugging)GetChakraCoreSymbol(library, "JsDiagStopDebugging");
120125
m_jsApiHooks.pfJsrtDiagGetSource = (JsAPIHooks::JsrtDiagGetSource)GetChakraCoreSymbol(library, "JsDiagGetSource");
@@ -135,7 +140,6 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
135140
m_jsApiHooks.pfJsrtRunScriptUtf8 = (JsAPIHooks::JsrtRunScriptUtf8)GetChakraCoreSymbol(library, "JsRunScriptUtf8");
136141
m_jsApiHooks.pfJsrtSerializeScriptUtf8 = (JsAPIHooks::JsrtSerializeScriptUtf8)GetChakraCoreSymbol(library, "JsSerializeScriptUtf8");
137142
m_jsApiHooks.pfJsrtRunSerializedScriptUtf8 = (JsAPIHooks::JsrtRunSerializedScriptUtf8)GetChakraCoreSymbol(library, "JsRunSerializedScriptUtf8");
138-
m_jsApiHooks.pfJsrtExperimentalApiRunModuleUtf8 = (JsAPIHooks::JsrtRunModuleUtf8Ptr)GetChakraCoreSymbol(library, "JsExperimentalApiRunModuleUtf8");
139143
m_jsApiHooks.pfJsrtGetPropertyIdFromNameUtf8 = (JsAPIHooks::JsrtGetPropertyIdFromNameUtf8Ptr)GetChakraCoreSymbol(library, "JsGetPropertyIdFromNameUtf8");
140144
m_jsApiHooks.pfJsrtStringFree = (JsAPIHooks::JsrtStringFreePtr)GetChakraCoreSymbol(library, "JsStringFree");
141145

0 commit comments

Comments
 (0)