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

Commit

Permalink
chakrashim: update chakracore (2016-07-22)
Browse files Browse the repository at this point in the history
Update chakracore to linux HEAD at
chakra-core/ChakraCore@814d084

PR-URL: #100
Reviewed-By: Kunal Pathak <Kunal.Pathak@microsoft.com>
  • Loading branch information
Jianchun Xu committed Jul 23, 2016
1 parent 5021d49 commit ab8fd54
Show file tree
Hide file tree
Showing 124 changed files with 3,271 additions and 821 deletions.
4 changes: 4 additions & 0 deletions deps/chakrashim/core/Build/Chakra.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
%(PreprocessorDefinitions);
DISABLE_JIT=1
</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(ENABLE_CODECOVERAGE)'=='true'">
%(PreprocessorDefinitions);
BYTECODE_TESTING=1
</PreprocessorDefinitions>
<!-- REVIEW: These are warning are introduced when moving to VS2015 tools, may want to clean these up -->
<DisableSpecificWarnings>
%(DisableSpecificWarnings);
Expand Down
3 changes: 2 additions & 1 deletion deps/chakrashim/core/Build/scripts/init_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ if ($BranchPath.StartsWith("build")) {
$BuildIdentifier = "${buildPushIdString}_${PushDate}_${Username}_${CommitHash}"
$ComputedDropPathSegment = "${BranchPath}\${YearAndMonth}${BuildIdentifier}"
$BinariesDirectory = "${Env:BUILD_SOURCESDIRECTORY}\Build\VcBuild"
$ObjectDirectory = "${BinariesDirectory}\obj\${BuildPlatform}_${BuildConfiguration}"

# Create a sentinel file for each build flavor to track whether the build is complete.
# * ${arch}_${flavor}.incomplete # will be deleted when the build of this flavor completes
Expand Down Expand Up @@ -178,7 +179,7 @@ set TF_BUILD_SOURCEGETVERSION=LG:${branch}:${CommitHash}
set TF_BUILD_DROPLOCATION=${BinariesDirectory}
set TF_BUILD_SOURCESDIRECTORY=${Env:BUILD_SOURCESDIRECTORY}
REM set TF_BUILD_BUILDDIRECTORY=${Env:AGENT_BUILDDIRECTORY}\b # note: inferred location works
set TF_BUILD_BUILDDIRECTORY=${ObjectDirectory}
set TF_BUILD_BINARIESDIRECTORY=${BinariesDirectory}
set TF_BUILD_BUILDDEFINITIONNAME=${Env:BUILD_DEFINITIONNAME}
Expand Down
51 changes: 0 additions & 51 deletions deps/chakrashim/core/CODE_OF_CONDUCT.md

This file was deleted.

4 changes: 3 additions & 1 deletion deps/chakrashim/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ Contributions to ChakraCore are welcome. Here is how you can contribute to Chak
* [Submit pull requests](https://github.com/Microsoft/ChakraCore/pulls) for bug fixes and features and discuss existing proposals
* Chat about [@ChakraCore](https://twitter.com/ChakraCore) on Twitter

Please refer to [Contribution guidelines](CONTRIBUTING.md) and the [Code of Conduct](CODE_OF_CONDUCT.md) for more details.
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.

Please refer to [Contribution guidelines](CONTRIBUTING.md) for more details.

### License

Expand Down
6 changes: 6 additions & 0 deletions deps/chakrashim/core/bin/ChakraCore/ChakraCore.def
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ JsTTDNotifyYield
JsTTDPrepContextsForTopLevelEventMove
JsTTDMoveToTopLevelEvent
JsTTDReplayExecution

JsInitializeModuleRecord
JsParseModuleSource
JsModuleEvaluation
JsSetModuleHostInfo
JsGetModuleHostInfo
215 changes: 215 additions & 0 deletions deps/chakrashim/core/bin/NativeTests/CodexTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include "catch.hpp"
#include <process.h>
#include "Codex\Utf8Codex.h"

#pragma warning(disable:4100) // unreferenced formal parameter
#pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs
#pragma warning(disable:6262) // CATCH is using stack variables to report errors, suppressing the preFAST warning.

namespace CodexTest
{
///
/// The following test verifies that for invalid characters, we replace them
/// with the unicode replacement character
///

// Verify single utf8-encoded codepoint
void CheckIsUnicodeReplacementChar(const utf8char_t* encodedBuffer)
{
CHECK(encodedBuffer[0] == 0xEF);
CHECK(encodedBuffer[1] == 0xBF);
CHECK(encodedBuffer[2] == 0xBD);
}

//
// Following test cases are based on the Utf-8 decoder tests
// suggested by Markus Kuhn at https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
//
TEST_CASE("CodexTest_EncodeTrueUtf8_SingleSurrogates", "[CodexTest]")
{
const charcount_t charCount = 1;
utf8char_t encodedBuffer[(charCount + 1) * 3]; // +1 since the buffer will be null-terminated

char16 testValues[] = { 0xD800, 0xDB7F, 0xDB80, 0xDBFF, 0xDC00, 0xDF80, 0xDFFF };
const int numTestCases = _countof(testValues);

for (int i = 0; i < numTestCases; i++)
{
size_t numEncodedBytes = utf8::EncodeTrueUtf8IntoAndNullTerminate(encodedBuffer, &testValues[i], charCount);
CHECK(numEncodedBytes == 3);
CheckIsUnicodeReplacementChar(encodedBuffer);
}
}

//
// Test encoding of given utf16-encoded strings into another encoding
//
// In the expected encoded string, extra bytes are represented as 0
//

template <typename TTestCase, typename TEncodingFunc>
void RunUtf8EncodingTestCase(const TTestCase &testCases, const TEncodingFunc func)
{
const int numTestCases = _countof(testCases);
const charcount_t charCount = _countof(testCases[0].surrogatePair);
const charcount_t maxEncodedByteCount = _countof(testCases[0].utf8Encoding);
utf8char_t encodedBuffer[maxEncodedByteCount + 1]; // +1 in case a null-terminating func is passed in

for (int i = 0; i < numTestCases; i++)
{
size_t numEncodedBytes = func(encodedBuffer, testCases[i].surrogatePair, charCount);
CHECK(numEncodedBytes <= maxEncodedByteCount);
for (size_t j = 0; j < numEncodedBytes; j++)
{
CHECK(encodedBuffer[j] == testCases[i].utf8Encoding[j]);
}

// Check and make sure there were no other bytes expected in the encoded string
if (numEncodedBytes < maxEncodedByteCount)
{
for (size_t j = numEncodedBytes; j < maxEncodedByteCount; j++)
{
CHECK(testCases[i].utf8Encoding[j] == 0);
}
}
}
}

TEST_CASE("CodexTest_EncodeCesu_PairedSurrogates", "[CodexTest]")
{
// Each of these test cases verifies the encoding
// of a single surrogate pair into a 6 byte CESU string
// Each surrogate-pair unit is encoded seperately into utf8
struct TestCase
{
char16 surrogatePair[2];
utf8char_t utf8Encoding[6];
};

TestCase testCases[] = {
{ { 0xD800, 0xDC00 }, { 0xED, 0xA0, 0x80, 0xED, 0xB0, 0x80 } }, // U+010000 LINEAR B SYLLABLE B008 A character
{ { 0xD800, 0xDFFF }, { 0xED, 0xA0, 0x80, 0xED, 0xBF, 0xBF } }, // U+0103FF
{ { 0xDB7F, 0xDC00 }, { 0xED, 0xAD, 0xBF, 0xED, 0xB0, 0x80 } }, // U+0EFC00
{ { 0xDB7F, 0xDFFF }, { 0xED, 0xAD, 0xBF, 0xED, 0xBF, 0xBF } }, // U+0EFFFF
{ { 0xDB80, 0xDC00 }, { 0xED, 0xAE, 0x80, 0xED, 0xB0, 0x80 } }, // U+0F0000 Plane 15 Private Use First
{ { 0xDB80, 0xDFFF }, { 0xED, 0xAE, 0x80, 0xED, 0xBF, 0xBF } }, // U+0F03FF
{ { 0xDBFF, 0xDC00 }, { 0xED, 0xAF, 0xBF, 0xED, 0xB0, 0x80 } }, // U+10FC00
{ { 0xDBFF, 0xDFFF }, { 0xED, 0xAF, 0xBF, 0xED, 0xBF, 0xBF } } // U+10FFFF
};

RunUtf8EncodingTestCase(testCases, static_cast<size_t (*)(utf8char_t*, const char16*, charcount_t)>(utf8::EncodeInto));
}

TEST_CASE("CodexTest_EncodeUtf8_PairedSurrogates", "[CodexTest]")
{
// Each of these test cases verifies the encoding
// of a single surrogate pair into a 4 byte utf8 string
// Each surrogate-pair unit is decoded to its original codepoint
// and then encoded into utf8
struct TestCase
{
char16 surrogatePair[2];
utf8char_t utf8Encoding[4];
};

TestCase testCases[] = {
{ { 0xD800, 0xDC00 }, { 0xF0, 0x90, 0x80, 0x80 } }, // U+010000 LINEAR B SYLLABLE B008 A character
{ { 0xD800, 0xDFFF }, { 0xF0, 0x90, 0x8F, 0xBF } }, // U+0103FF
{ { 0xDB7F, 0xDC00 }, { 0xF3, 0xAF, 0xB0, 0x80 } }, // U+0EFC00
{ { 0xDB7F, 0xDFFF }, { 0xF3, 0xAF, 0xBF, 0xBF } }, // U+0EFFFF
{ { 0xDB80, 0xDC00 }, { 0xF3, 0xB0, 0x80, 0x80 } }, // U+0F0000 Plane 15 Private Use First
{ { 0xDB80, 0xDFFF }, { 0xF3, 0xB0, 0x8F, 0xBF } }, // U+0F03FF
{ { 0xDBFF, 0xDC00 }, { 0xF4, 0x8F, 0xB0, 0x80 } }, // U+10FC00
{ { 0xDBFF, 0xDFFF }, { 0xF4, 0x8F, 0xBF, 0xBF } } // U+10FFFF
};

RunUtf8EncodingTestCase(testCases, utf8::EncodeTrueUtf8IntoAndNullTerminate);
}

TEST_CASE("CodexTest_EncodeUtf8_NonCharacters", "[CodexTest]")
{
// Each of these test cases verifies the encoding
// of certain problematic codepoints that do not represent
// characters
struct TestCase
{
char16 surrogatePair[1];
utf8char_t utf8Encoding[3];
};

TestCase testCases[] = {
{ { 0xFFFE }, { 0xEF, 0xBF, 0xBE } }, // U+FFFE
{ { 0xFFFF }, { 0xEF, 0xBF, 0xBF } } // U+FFFF
};

RunUtf8EncodingTestCase(testCases, utf8::EncodeTrueUtf8IntoAndNullTerminate);
}

TEST_CASE("CodexTest_EncodeUtf8_BoundaryChars", "[CodexTest]")
{
// Each of these test cases verifies the encoding
// of boundary conditions
struct SingleChar16TestCase
{
char16 surrogatePair[1];
utf8char_t utf8Encoding[3];
};

SingleChar16TestCase testCases[] = {
{ { 0xD7FF }, { 0xED, 0x9F, 0xBF } }, // U+D7FF
{ { 0xE000 }, { 0xEE, 0x80, 0x80 } }, // U+E000
{ { 0xFFFD }, { 0xEF, 0xBF, 0xBD } } // U+FFFD
};

struct TwoChar16TestCase
{
char16 surrogatePair[2];
utf8char_t utf8Encoding[4];
};

TwoChar16TestCase testCases2[] = {
{ { 0xDBFF, 0xDFFF }, { 0xF4, 0x8F, 0xBF, 0xBF } } // U+10FFFF
};

RunUtf8EncodingTestCase(testCases, utf8::EncodeTrueUtf8IntoAndNullTerminate);
RunUtf8EncodingTestCase(testCases2, utf8::EncodeTrueUtf8IntoAndNullTerminate);
}

TEST_CASE("CodexTest_EncodeUtf8_SimpleCharacters", "[CodexTest]")
{
// Each of these test cases verifies the encoding
// of certain problematic codepoints that do not represent
// characters
struct TestCase
{
char16 surrogatePair[1];
utf8char_t utf8Encoding[3];
};

TestCase testCases[] = {
{ { 0x0024 }, { 0x24 } }, // U+0024 - Dollar Symbol
{ { 0x00A2 }, { 0xC2, 0xA2 } }, // U+00A2 - Cent symbol
{ { 0x20AC }, { 0xE2, 0x82, 0xAC } } // U+20AC - Euro symbol
};

RunUtf8EncodingTestCase(testCases, utf8::EncodeTrueUtf8IntoAndNullTerminate);
}

TEST_CASE("CodexTest_EncodeTrueUtf8_SimpleString", "[CodexTest]")
{
const charcount_t charCount = 3;
utf8char_t encodedBuffer[(charCount + 1) * 3]; // +1 since the buffer will be null terminated
char16* sourceBuffer = L"abc";
size_t numEncodedBytes = utf8::EncodeTrueUtf8IntoAndNullTerminate(encodedBuffer, sourceBuffer, charCount);
CHECK(numEncodedBytes == charCount);
for (int i = 0; i < charCount; i++)
{
CHECK(sourceBuffer[i] == (char16)encodedBuffer[i]);
}
}
};
1 change: 1 addition & 0 deletions deps/chakrashim/core/bin/NativeTests/NativeTests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CodexTests.cpp" />
<ClCompile Include="FileLoadHelpers.cpp" />
<ClCompile Include="CodexAssert.cpp" />
<ClCompile Include="JsRTApiTest.cpp" />
Expand Down
6 changes: 4 additions & 2 deletions deps/chakrashim/core/bin/ch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(ch_source_files
set(ch_source_files
ch.cpp
ChakraRtInterface.cpp
CodexAssert.cpp
Expand Down Expand Up @@ -67,6 +67,8 @@ if(STATIC_LIBRARY)
icucore
"-framework CoreFoundation"
"-framework Security"
# set stack size to 64Mb for stack tests
-Wl,-stack_size,0x04000000
)
endif() # Linux ?
else() # // !from shared library
Expand All @@ -78,7 +80,7 @@ else() # // !from shared library
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(lib_target "${lib_target}"
set(lib_target "${lib_target}"
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/ch.version
)
endif()
Expand Down
6 changes: 5 additions & 1 deletion deps/chakrashim/core/bin/ch/ChakraRtInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
m_jsApiHooks.pfJsrtSetPromiseContinuationCallback = (JsAPIHooks::JsrtSetPromiseContinuationCallbackPtr)GetChakraCoreSymbol(library, "JsSetPromiseContinuationCallback");
m_jsApiHooks.pfJsrtGetContextOfObject = (JsAPIHooks::JsrtGetContextOfObject)GetChakraCoreSymbol(library, "JsGetContextOfObject");
m_jsApiHooks.pfJsrtParseScriptWithAttributesUtf8 = (JsAPIHooks::JsrtParseScriptWithAttributesUtf8)GetChakraCoreSymbol(library, "JsParseScriptWithAttributesUtf8");
m_jsApiHooks.pfJsrtInitializeModuleRecord = (JsAPIHooks::JsInitializeModuleRecordPtr)GetChakraCoreSymbol(library, "JsInitializeModuleRecord");
m_jsApiHooks.pfJsrtParseModuleSource = (JsAPIHooks::JsParseModuleSourcePtr)GetChakraCoreSymbol(library, "JsParseModuleSource");
m_jsApiHooks.pfJsrtSetModuleHostInfo = (JsAPIHooks::JsSetModuleHostInfoPtr)GetChakraCoreSymbol(library, "JsSetModuleHostInfo");
m_jsApiHooks.pfJsrtGetModuleHostInfo = (JsAPIHooks::JsGetModuleHostInfoPtr)GetChakraCoreSymbol(library, "JsGetModuleHostInfo");
m_jsApiHooks.pfJsrtModuleEvaluation = (JsAPIHooks::JsModuleEvaluationPtr)GetChakraCoreSymbol(library, "JsModuleEvaluation");
m_jsApiHooks.pfJsrtDiagStartDebugging = (JsAPIHooks::JsrtDiagStartDebugging)GetChakraCoreSymbol(library, "JsDiagStartDebugging");
m_jsApiHooks.pfJsrtDiagStopDebugging = (JsAPIHooks::JsrtDiagStopDebugging)GetChakraCoreSymbol(library, "JsDiagStopDebugging");
m_jsApiHooks.pfJsrtDiagGetSource = (JsAPIHooks::JsrtDiagGetSource)GetChakraCoreSymbol(library, "JsDiagGetSource");
Expand All @@ -135,7 +140,6 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
m_jsApiHooks.pfJsrtRunScriptUtf8 = (JsAPIHooks::JsrtRunScriptUtf8)GetChakraCoreSymbol(library, "JsRunScriptUtf8");
m_jsApiHooks.pfJsrtSerializeScriptUtf8 = (JsAPIHooks::JsrtSerializeScriptUtf8)GetChakraCoreSymbol(library, "JsSerializeScriptUtf8");
m_jsApiHooks.pfJsrtRunSerializedScriptUtf8 = (JsAPIHooks::JsrtRunSerializedScriptUtf8)GetChakraCoreSymbol(library, "JsRunSerializedScriptUtf8");
m_jsApiHooks.pfJsrtExperimentalApiRunModuleUtf8 = (JsAPIHooks::JsrtRunModuleUtf8Ptr)GetChakraCoreSymbol(library, "JsExperimentalApiRunModuleUtf8");
m_jsApiHooks.pfJsrtGetPropertyIdFromNameUtf8 = (JsAPIHooks::JsrtGetPropertyIdFromNameUtf8Ptr)GetChakraCoreSymbol(library, "JsGetPropertyIdFromNameUtf8");
m_jsApiHooks.pfJsrtStringFree = (JsAPIHooks::JsrtStringFreePtr)GetChakraCoreSymbol(library, "JsStringFree");

Expand Down
Loading

0 comments on commit ab8fd54

Please sign in to comment.