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

Commit

Permalink
chakrashim: Updated ChakraCore to release/2.0
Browse files Browse the repository at this point in the history
Updated ChakraCore to chakra-core/ChakraCore@9f1bc75

PR-URL: #243
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
  • Loading branch information
kfarnung committed May 13, 2017
1 parent f9f10b4 commit ad6108e
Show file tree
Hide file tree
Showing 69 changed files with 1,140 additions and 1,098 deletions.
2 changes: 1 addition & 1 deletion deps/chakrashim/core/Build/NuGet/.pack-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.3
2.0.0
1 change: 1 addition & 0 deletions deps/chakrashim/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ if(CLR_CMAKE_PLATFORM_XPLAT)
-Wno-null-conversion\
-Wno-return-type\
-Wno-switch\
-Wno-implicit-function-declaration\
-Wno-int-to-pointer-cast"
)
# notes..
Expand Down
31 changes: 31 additions & 0 deletions deps/chakrashim/core/bin/NativeTests/JsRTApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,37 @@ namespace JsRTApiTest
JsRTApiTest::RunWithAttributes(JsRTApiTest::ReferenceCountingTest);
}

void WeakReferenceTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
{
JsValueRef valueRef = JS_INVALID_REFERENCE;
REQUIRE(JsCreateString("test", strlen("test"), &valueRef) == JsNoError);

JsWeakRef weakRef = JS_INVALID_REFERENCE;
REQUIRE(JsCreateWeakReference(valueRef, &weakRef) == JsNoError);

// JsGetWeakReferenceValue should return the original value reference.
JsValueRef valueRefFromWeakRef = JS_INVALID_REFERENCE;
CHECK(JsGetWeakReferenceValue(weakRef, &valueRefFromWeakRef) == JsNoError);
CHECK(valueRefFromWeakRef != JS_INVALID_REFERENCE);
CHECK(valueRefFromWeakRef == valueRef);

// Clear the references on the stack, so that the value will be GC'd.
valueRef = JS_INVALID_REFERENCE;
valueRefFromWeakRef = JS_INVALID_REFERENCE;

CHECK(JsCollectGarbage(runtime) == JsNoError);

// JsGetWeakReferenceValue should return an invalid reference after the value was GC'd.
JsValueRef valueRefAfterGC = JS_INVALID_REFERENCE;
CHECK(JsGetWeakReferenceValue(weakRef, &valueRefAfterGC) == JsNoError);
CHECK(valueRefAfterGC == JS_INVALID_REFERENCE);
}

TEST_CASE("ApiTest_WeakReferenceTest", "[ApiTest]")
{
JsRTApiTest::RunWithAttributes(JsRTApiTest::WeakReferenceTest);
}

void ObjectsAndPropertiesTest1(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
{
JsValueRef object = JS_INVALID_REFERENCE;
Expand Down
16 changes: 16 additions & 0 deletions deps/chakrashim/core/bin/ch/ChakraRtInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ class ChakraRTInterface
HostPrintUsageFuncPtr hostPrintUsage;
char* filename;

ArgInfo() :
argc(0),
argv(nullptr),
hostPrintUsage(nullptr),
filename(nullptr)
{
}

ArgInfo(int argc, LPWSTR* argv, HostPrintUsageFuncPtr hostPrintUsage, char* filename) :
argc(argc),
argv(argv),
hostPrintUsage(hostPrintUsage),
filename(filename)
{
}

~ArgInfo()
{
if (filename != nullptr)
Expand Down
2 changes: 1 addition & 1 deletion deps/chakrashim/core/jenkins/check_copyright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rm -f $ERRFILE
rm -f $ERRFILETEMP

echo "Check Copyright > Begin Checking..."
git diff --name-only `git merge-base origin/master HEAD` HEAD |
git diff --name-only `git merge-base origin/$ghprbTargetBranch HEAD` HEAD |
grep -v -E '\.git.*' |
grep -v -E '\.xml$' |
grep -v -E '\.props$' |
Expand Down
4 changes: 2 additions & 2 deletions deps/chakrashim/core/lib/Common/ChakraCoreVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
// * Does not add anything to the file description

// ChakraCore RELEASE and PRERELEASE flags
#define CHAKRA_CORE_VERSION_RELEASE 0
#define CHAKRA_CORE_VERSION_PRERELEASE 0
#define CHAKRA_CORE_VERSION_RELEASE 1
#define CHAKRA_CORE_VERSION_PRERELEASE 1

// Chakra RELEASE flag
// Mostly redundant with CHAKRA_CORE_VERSION_RELEASE,
Expand Down
4 changes: 2 additions & 2 deletions deps/chakrashim/core/lib/Common/Common/NumberUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ namespace Js
{
mov eax, lu1
mul lu2
mov ebx, pluHi
mov DWORD PTR[ebx], edx
mov ebx, pluHi
mov DWORD PTR[ebx], edx
}
#else //!I386_ASM
DWORDLONG llu = UInt32x32To64(lu1, lu2);
Expand Down
2 changes: 2 additions & 0 deletions deps/chakrashim/core/lib/Common/CommonPal.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,12 @@ extern "C" PVOID _ReturnAddress(VOID);
extern "C" void * _AddressOfReturnAddress(void);
#elif defined(__GNUC__) || defined(__clang__)
#define _ReturnAddress() __builtin_return_address(0)
#if !__has_builtin(_AddressOfReturnAddress)
__forceinline void * _AddressOfReturnAddress()
{
return (void*)((char*) __builtin_frame_address(0) + sizeof(void*));
}
#endif
#else
#error _AddressOfReturnAddress and _ReturnAddress not defined for this platform
#endif
Expand Down
3 changes: 2 additions & 1 deletion deps/chakrashim/core/lib/Common/Core/SysInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ AutoSystemInfo::Initialize()
disableDebugScopeCapture = false;
}

this->shouldQCMoreFrequently = false;
this->supportsOnlyMultiThreadedCOM = false;
#if defined(__ANDROID__) || defined(__IOS__)
this->isLowMemoryDevice = true;
this->shouldQCMoreFrequently = true;
#else
this->shouldQCMoreFrequently = false;
this->isLowMemoryDevice = false;
#endif

Expand Down
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Common/Memory/Allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,5 +561,5 @@ operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, bool n
char * buffer = (alloc->*AllocFunc)(AllocSizeMath::Add(plusSize, byteSize));

// This seems to generate the most compact code
return buffer + (buffer > 0 ? plusSize : (size_t)buffer);
return buffer + ((uintptr_t)buffer > 0 ? plusSize : (size_t)buffer);
}
46 changes: 42 additions & 4 deletions deps/chakrashim/core/lib/Jsrt/ChakraCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,47 @@ CHAKRA_API
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
/// </returns>
CHAKRA_API
JsCreatePromise(
_Out_ JsValueRef *promise,
_Out_ JsValueRef *resolveFunction,
_Out_ JsValueRef *rejectFunction);
JsCreatePromise(
_Out_ JsValueRef *promise,
_Out_ JsValueRef *resolveFunction,
_Out_ JsValueRef *rejectFunction);

/// <summary>
/// A weak reference to a JavaScript value.
/// </summary>
/// <remarks>
/// A value with only weak references is available for garbage-collection. A strong reference
/// to the value (<c>JsValueRef</c>) may be obtained from a weak reference if the value happens
/// to still be available.
/// </remarks>
typedef JsRef JsWeakRef;

/// <summary>
/// Creates a weak reference to a value.
/// </summary>
/// <param name="value">The value to be referenced.</param>
/// <param name="weakRef">Weak reference to the value.</param>
/// <returns>
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
/// </returns>
CHAKRA_API
JsCreateWeakReference(
_In_ JsValueRef value,
_Out_ JsWeakRef* weakRef);

/// <summary>
/// Gets a strong reference to the value referred to by a weak reference.
/// </summary>
/// <param name="weakRef">A weak reference.</param>
/// <param name="value">Reference to the value, or <c>JS_INVALID_REFERENCE</c> if the value is
/// no longer available.</param>
/// <returns>
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
/// </returns>
CHAKRA_API
JsGetWeakReferenceValue(
_In_ JsWeakRef weakRef,
_Out_ JsValueRef* value);

#endif // CHAKRACOREBUILD_
#endif // _CHAKRACORE_H_
53 changes: 49 additions & 4 deletions deps/chakrashim/core/lib/Jsrt/Jsrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ CHAKRA_API JsSetCurrentContext(_In_ JsContextRef newContext)
}
else
{
if(oldScriptContext->IsTTDRecordModeEnabled())
if(oldScriptContext->IsTTDRecordModeEnabled())
{
//already know newScriptContext != oldScriptContext so don't check again
if(oldScriptContext->ShouldPerformRecordAction())
Expand Down Expand Up @@ -3904,7 +3904,7 @@ CHAKRA_API JsTTDPreExecuteSnapShotInterval(_In_ JsRuntimeHandle runtimeHandle, _
return inflateStatus;
}

//If we are in the "active" segment set the continue breakpoint
//If we are in the "active" segment set the continue breakpoint
if((moveMode & JsTTDMoveMode::JsTTDMoveScanIntervalForContinueInActiveBreakpointSegment) == JsTTDMoveMode::JsTTDMoveScanIntervalForContinueInActiveBreakpointSegment)
{
GlobalAPIWrapper_NoRecord([&]() -> JsErrorCode
Expand Down Expand Up @@ -3944,7 +3944,7 @@ CHAKRA_API JsTTDPreExecuteSnapShotInterval(_In_ JsRuntimeHandle runtimeHandle, _
elog->PopMode(TTD::TTDMode::DebuggerLogBreakpoints);
elog->PopMode(TTD::TTDMode::DebuggerSuppressBreakpoints);

//If we are in the "active" segment un-set the continue breakpoint
//If we are in the "active" segment un-set the continue breakpoint
if((moveMode & JsTTDMoveMode::JsTTDMoveScanIntervalForContinueInActiveBreakpointSegment) == JsTTDMoveMode::JsTTDMoveScanIntervalForContinueInActiveBreakpointSegment)
{
GlobalAPIWrapper_NoRecord([&]() -> JsErrorCode
Expand Down Expand Up @@ -4036,7 +4036,7 @@ CHAKRA_API JsTTDReplayExecution(_Inout_ JsTTDMoveMode* moveMode, _Out_ int64_t*
return JsNoError;
});

if(bpstatus != JsNoError)
if(bpstatus != JsNoError)
{
return bpstatus;
}
Expand Down Expand Up @@ -4545,4 +4545,49 @@ CHAKRA_API JsCreatePromise(_Out_ JsValueRef *promise, _Out_ JsValueRef *resolve,
return JsNoError;
});
}

CHAKRA_API JsCreateWeakReference(
_In_ JsValueRef value,
_Out_ JsWeakRef* weakRef)
{
VALIDATE_JSREF(value);
PARAM_NOT_NULL(weakRef);
*weakRef = nullptr;

return GlobalAPIWrapper_NoRecord([&]() -> JsErrorCode {
ThreadContext* threadContext = ThreadContext::GetContextForCurrentThread();
if (threadContext == nullptr)
{
return JsErrorNoCurrentContext;
}

Recycler* recycler = threadContext->GetRecycler();
if (recycler->IsInObjectBeforeCollectCallback())
{
return JsErrorInObjectBeforeCollectCallback;
}

recycler->FindOrCreateWeakReferenceHandle<char>(
reinterpret_cast<char*>(value),
reinterpret_cast<Memory::RecyclerWeakReference<char>**>(weakRef));
return JsNoError;
});
}

CHAKRA_API JsGetWeakReferenceValue(
_In_ JsWeakRef weakRef,
_Out_ JsValueRef* value)
{
VALIDATE_JSREF(weakRef);
PARAM_NOT_NULL(value);
*value = JS_INVALID_REFERENCE;

return GlobalAPIWrapper_NoRecord([&]() -> JsErrorCode {
Memory::RecyclerWeakReference<char>* recyclerWeakReference =
reinterpret_cast<Memory::RecyclerWeakReference<char>*>(weakRef);
*value = reinterpret_cast<JsValueRef>(recyclerWeakReference->Get());
return JsNoError;
});
}

#endif // CHAKRACOREBUILD_
2 changes: 2 additions & 0 deletions deps/chakrashim/core/lib/Jsrt/JsrtCommonExports.inc
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@
JsCreatePropertyId
JsCopyPropertyId
JsCreatePromise
JsCreateWeakReference
JsGetWeakReferenceValue
#endif
6 changes: 3 additions & 3 deletions deps/chakrashim/core/lib/Jsrt/JsrtInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ void HandleScriptCompileError(Js::ScriptContext * scriptContext, CompileScriptEx
#else
#define PERFORM_JSRT_TTD_RECORD_ACTION_CHECK(CTX) false

#define PERFORM_JSRT_TTD_RECORD_ACTION(CTX, ACTION_CODE, ...)
#define PERFORM_JSRT_TTD_RECORD_ACTION_RESULT(CTX, RESULT)
#define PERFORM_JSRT_TTD_RECORD_ACTION(CTX, ACTION_CODE, ...)
#define PERFORM_JSRT_TTD_RECORD_ACTION_RESULT(CTX, RESULT)

#define PERFORM_JSRT_TTD_RECORD_ACTION_NOT_IMPLEMENTED(CTX)
#define PERFORM_JSRT_TTD_RECORD_ACTION_NOT_IMPLEMENTED(CTX)
#endif
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Parser/rterrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ RT_ERROR_MSG(JSERR_NeedString, 5005, "'%s' is not a string", "String expected",
RT_ERROR_MSG(JSERR_NeedDate, 5006, "'%s' is not a date object", "Date object expected", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_NeedObject, 5007, "'%s' is null or not an object", "Object expected", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_CantAssignTo, 5008, "", "Invalid left-hand side in assignment", kjstReferenceError, 0)
RT_ERROR_MSG(JSERR_UndefVariable, 5009, "'%s' is undefined", "Undefined identifier", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_UndefVariable, 5009, "'%s' is not defined", "Undefined identifier", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_NeedBoolean, 5010, "'%s' is not a boolean", "Boolean expected", kjstTypeError, 0)

// This is the legacy error code for JScript.
Expand Down
2 changes: 2 additions & 0 deletions deps/chakrashim/core/lib/Runtime/Base/ThreadContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,7 @@ ThreadContext::ProbeStackNoDispose(size_t size, Js::ScriptContext *scriptContext
Js::Throw::StackOverflow(scriptContext, returnAddress);
}

#if defined(NTBUILD) || defined(__IOS__) || defined(__ANDROID__)
// Use every Nth stack probe as a QC trigger.
if (AutoSystemInfo::ShouldQCMoreFrequently() && this->HasInterruptPoller() && this->IsScriptActive())
{
Expand All @@ -1722,6 +1723,7 @@ ThreadContext::ProbeStackNoDispose(size_t size, Js::ScriptContext *scriptContext
this->CheckInterruptPoll();
}
}
#endif
}

void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
//-------------------------------------------------------------------------------------------------------
// NOTE: If there is a merge conflict the correct fix is to make a new GUID.

// {FEE3FADC-D028-4221-907F-37E25EABBD96}
// {1a8e3edd-d08b-4a53-92d9-199667c17520}
const GUID byteCodeCacheReleaseFileVersion =
{ 0xFEE3FADC, 0xD028, 0x4221, { 0x90, 0x7F, 0x37, 0xE2, 0x5E, 0xAB, 0xBD, 0x96 } };
{ 0x1a8e3edd, 0xd08b, 0x4a53, { 0x92, 0xd9, 0x19, 0x96, 0x67, 0xc1, 0x75, 0x20 } };
3 changes: 1 addition & 2 deletions deps/chakrashim/core/netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def msbuildTypeMap = [
def machineTypeToOSTagMap = [
'Windows 7': 'Windows 7',
'Windows_NT': 'Windows',
'Ubuntu14.04': 'Ubuntu14.04',
'Ubuntu16.04': 'Ubuntu',
'OSX': 'OSX'
]
Expand Down Expand Up @@ -214,7 +213,7 @@ def CreateStyleCheckTasks = { taskString, taskName, checkName ->
Utilities.addGithubPushTrigger(newJob)
}

Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', 'latest-or-auto')
Utilities.setMachineAffinity(newJob, 'Ubuntu16.04', 'latest-or-auto')
}
}

Expand Down
12 changes: 12 additions & 0 deletions deps/chakrashim/core/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -6232,6 +6232,11 @@ inline WCHAR *PAL_wcsstr(WCHAR *_S, const WCHAR *_P)
}
#endif

#ifndef __has_builtin
#define __has_builtin(x) 0
#endif

#if !__has_builtin(_rotl)
/*++
Function:
_rotl
Expand All @@ -6249,12 +6254,14 @@ unsigned int __cdecl _rotl(unsigned int value, int shift)
retval = (value << shift) | (value >> (sizeof(int) * CHAR_BIT - shift));
return retval;
}
#endif

// On 64 bit unix, make the long an int.
#ifdef BIT64
#define _lrotl _rotl
#endif // BIT64

#if !__has_builtin(_rotl64)
/*++
Function:
_rotl64
Expand All @@ -6272,7 +6279,9 @@ unsigned long long __cdecl _rotl64(unsigned long long value, int shift)
retval = (value << shift) | (value >> (sizeof(unsigned long long) * CHAR_BIT - shift));
return retval;
}
#endif

#if !__has_builtin(_rotr)
/*++
Function:
_rotr
Expand All @@ -6290,7 +6299,9 @@ unsigned int __cdecl _rotr(unsigned int value, int shift)
retval = (value >> shift) | (value << (sizeof(int) * CHAR_BIT - shift));
return retval;
}
#endif

#if !__has_builtin(_rotr64)
/*++
Function:
_rotr64
Expand All @@ -6308,6 +6319,7 @@ unsigned long long __cdecl _rotr64(unsigned long long value, int shift)
retval = (value >> shift) | (value << (sizeof(unsigned long long) * CHAR_BIT - shift));
return retval;
}
#endif

PALIMPORT int __cdecl abs(int);
PALIMPORT double __cdecl fabs(double);
Expand Down
Loading

0 comments on commit ad6108e

Please sign in to comment.