Skip to content

Commit 1113bfe

Browse files
committed
Merge branch 'release/2.0' into exposeExceptionMetadataR20
2 parents 1d71c1b + ebc94d8 commit 1113bfe

File tree

69 files changed

+1141
-1099
lines changed

Some content is hidden

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

69 files changed

+1141
-1099
lines changed

Build/NuGet/.pack-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.3
1+
2.0.0

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ if(CLR_CMAKE_PLATFORM_XPLAT)
288288
-Wno-null-conversion\
289289
-Wno-return-type\
290290
-Wno-switch\
291+
-Wno-implicit-function-declaration\
291292
-Wno-int-to-pointer-cast"
292293
)
293294
# notes..

bin/NativeTests/JsRTApiTest.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,37 @@ namespace JsRTApiTest
102102
JsRTApiTest::RunWithAttributes(JsRTApiTest::ReferenceCountingTest);
103103
}
104104

105+
void WeakReferenceTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
106+
{
107+
JsValueRef valueRef = JS_INVALID_REFERENCE;
108+
REQUIRE(JsCreateString("test", strlen("test"), &valueRef) == JsNoError);
109+
110+
JsWeakRef weakRef = JS_INVALID_REFERENCE;
111+
REQUIRE(JsCreateWeakReference(valueRef, &weakRef) == JsNoError);
112+
113+
// JsGetWeakReferenceValue should return the original value reference.
114+
JsValueRef valueRefFromWeakRef = JS_INVALID_REFERENCE;
115+
CHECK(JsGetWeakReferenceValue(weakRef, &valueRefFromWeakRef) == JsNoError);
116+
CHECK(valueRefFromWeakRef != JS_INVALID_REFERENCE);
117+
CHECK(valueRefFromWeakRef == valueRef);
118+
119+
// Clear the references on the stack, so that the value will be GC'd.
120+
valueRef = JS_INVALID_REFERENCE;
121+
valueRefFromWeakRef = JS_INVALID_REFERENCE;
122+
123+
CHECK(JsCollectGarbage(runtime) == JsNoError);
124+
125+
// JsGetWeakReferenceValue should return an invalid reference after the value was GC'd.
126+
JsValueRef valueRefAfterGC = JS_INVALID_REFERENCE;
127+
CHECK(JsGetWeakReferenceValue(weakRef, &valueRefAfterGC) == JsNoError);
128+
CHECK(valueRefAfterGC == JS_INVALID_REFERENCE);
129+
}
130+
131+
TEST_CASE("ApiTest_WeakReferenceTest", "[ApiTest]")
132+
{
133+
JsRTApiTest::RunWithAttributes(JsRTApiTest::WeakReferenceTest);
134+
}
135+
105136
void ObjectsAndPropertiesTest1(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
106137
{
107138
JsValueRef object = JS_INVALID_REFERENCE;

bin/ch/ChakraRtInterface.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,22 @@ class ChakraRTInterface
196196
HostPrintUsageFuncPtr hostPrintUsage;
197197
char* filename;
198198

199+
ArgInfo() :
200+
argc(0),
201+
argv(nullptr),
202+
hostPrintUsage(nullptr),
203+
filename(nullptr)
204+
{
205+
}
206+
207+
ArgInfo(int argc, LPWSTR* argv, HostPrintUsageFuncPtr hostPrintUsage, char* filename) :
208+
argc(argc),
209+
argv(argv),
210+
hostPrintUsage(hostPrintUsage),
211+
filename(filename)
212+
{
213+
}
214+
199215
~ArgInfo()
200216
{
201217
if (filename != nullptr)

jenkins/check_copyright.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rm -f $ERRFILE
1818
rm -f $ERRFILETEMP
1919

2020
echo "Check Copyright > Begin Checking..."
21-
git diff --name-only `git merge-base origin/master HEAD` HEAD |
21+
git diff --name-only `git merge-base origin/$ghprbTargetBranch HEAD` HEAD |
2222
grep -v -E '\.git.*' |
2323
grep -v -E '\.xml$' |
2424
grep -v -E '\.props$' |

lib/Common/ChakraCoreVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
// * Does not add anything to the file description
5555

5656
// ChakraCore RELEASE and PRERELEASE flags
57-
#define CHAKRA_CORE_VERSION_RELEASE 0
58-
#define CHAKRA_CORE_VERSION_PRERELEASE 0
57+
#define CHAKRA_CORE_VERSION_RELEASE 1
58+
#define CHAKRA_CORE_VERSION_PRERELEASE 1
5959

6060
// Chakra RELEASE flag
6161
// Mostly redundant with CHAKRA_CORE_VERSION_RELEASE,

lib/Common/Common/NumberUtilities.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ namespace Js
125125
{
126126
mov eax, lu1
127127
mul lu2
128-
mov ebx, pluHi
129-
mov DWORD PTR[ebx], edx
128+
mov ebx, pluHi
129+
mov DWORD PTR[ebx], edx
130130
}
131131
#else //!I386_ASM
132132
DWORDLONG llu = UInt32x32To64(lu1, lu2);

lib/Common/CommonPal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,12 @@ extern "C" PVOID _ReturnAddress(VOID);
496496
extern "C" void * _AddressOfReturnAddress(void);
497497
#elif defined(__GNUC__) || defined(__clang__)
498498
#define _ReturnAddress() __builtin_return_address(0)
499+
#if !__has_builtin(_AddressOfReturnAddress)
499500
__forceinline void * _AddressOfReturnAddress()
500501
{
501502
return (void*)((char*) __builtin_frame_address(0) + sizeof(void*));
502503
}
504+
#endif
503505
#else
504506
#error _AddressOfReturnAddress and _ReturnAddress not defined for this platform
505507
#endif

lib/Common/Core/SysInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ AutoSystemInfo::Initialize()
109109
disableDebugScopeCapture = false;
110110
}
111111

112-
this->shouldQCMoreFrequently = false;
113112
this->supportsOnlyMultiThreadedCOM = false;
114113
#if defined(__ANDROID__) || defined(__IOS__)
115114
this->isLowMemoryDevice = true;
115+
this->shouldQCMoreFrequently = true;
116116
#else
117+
this->shouldQCMoreFrequently = false;
117118
this->isLowMemoryDevice = false;
118119
#endif
119120

lib/Common/Memory/Allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,5 +561,5 @@ operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, bool n
561561
char * buffer = (alloc->*AllocFunc)(AllocSizeMath::Add(plusSize, byteSize));
562562

563563
// This seems to generate the most compact code
564-
return buffer + (buffer > 0 ? plusSize : (size_t)buffer);
564+
return buffer + ((uintptr_t)buffer > 0 ? plusSize : (size_t)buffer);
565565
}

lib/Jsrt/ChakraCore.h

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,47 @@ CHAKRA_API
541541
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
542542
/// </returns>
543543
CHAKRA_API
544-
JsCreatePromise(
545-
_Out_ JsValueRef *promise,
546-
_Out_ JsValueRef *resolveFunction,
547-
_Out_ JsValueRef *rejectFunction);
544+
JsCreatePromise(
545+
_Out_ JsValueRef *promise,
546+
_Out_ JsValueRef *resolveFunction,
547+
_Out_ JsValueRef *rejectFunction);
548+
549+
/// <summary>
550+
/// A weak reference to a JavaScript value.
551+
/// </summary>
552+
/// <remarks>
553+
/// A value with only weak references is available for garbage-collection. A strong reference
554+
/// to the value (<c>JsValueRef</c>) may be obtained from a weak reference if the value happens
555+
/// to still be available.
556+
/// </remarks>
557+
typedef JsRef JsWeakRef;
558+
559+
/// <summary>
560+
/// Creates a weak reference to a value.
561+
/// </summary>
562+
/// <param name="value">The value to be referenced.</param>
563+
/// <param name="weakRef">Weak reference to the value.</param>
564+
/// <returns>
565+
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
566+
/// </returns>
567+
CHAKRA_API
568+
JsCreateWeakReference(
569+
_In_ JsValueRef value,
570+
_Out_ JsWeakRef* weakRef);
571+
572+
/// <summary>
573+
/// Gets a strong reference to the value referred to by a weak reference.
574+
/// </summary>
575+
/// <param name="weakRef">A weak reference.</param>
576+
/// <param name="value">Reference to the value, or <c>JS_INVALID_REFERENCE</c> if the value is
577+
/// no longer available.</param>
578+
/// <returns>
579+
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
580+
/// </returns>
581+
CHAKRA_API
582+
JsGetWeakReferenceValue(
583+
_In_ JsWeakRef weakRef,
584+
_Out_ JsValueRef* value);
585+
548586
#endif // CHAKRACOREBUILD_
549587
#endif // _CHAKRACORE_H_

lib/Jsrt/Jsrt.cpp

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ CHAKRA_API JsSetCurrentContext(_In_ JsContextRef newContext)
762762
}
763763
else
764764
{
765-
if(oldScriptContext->IsTTDRecordModeEnabled())
765+
if(oldScriptContext->IsTTDRecordModeEnabled())
766766
{
767767
//already know newScriptContext != oldScriptContext so don't check again
768768
if(oldScriptContext->ShouldPerformRecordAction())
@@ -3908,7 +3908,7 @@ CHAKRA_API JsTTDPreExecuteSnapShotInterval(_In_ JsRuntimeHandle runtimeHandle, _
39083908
return inflateStatus;
39093909
}
39103910

3911-
//If we are in the "active" segment set the continue breakpoint
3911+
//If we are in the "active" segment set the continue breakpoint
39123912
if((moveMode & JsTTDMoveMode::JsTTDMoveScanIntervalForContinueInActiveBreakpointSegment) == JsTTDMoveMode::JsTTDMoveScanIntervalForContinueInActiveBreakpointSegment)
39133913
{
39143914
GlobalAPIWrapper_NoRecord([&]() -> JsErrorCode
@@ -3948,7 +3948,7 @@ CHAKRA_API JsTTDPreExecuteSnapShotInterval(_In_ JsRuntimeHandle runtimeHandle, _
39483948
elog->PopMode(TTD::TTDMode::DebuggerLogBreakpoints);
39493949
elog->PopMode(TTD::TTDMode::DebuggerSuppressBreakpoints);
39503950

3951-
//If we are in the "active" segment un-set the continue breakpoint
3951+
//If we are in the "active" segment un-set the continue breakpoint
39523952
if((moveMode & JsTTDMoveMode::JsTTDMoveScanIntervalForContinueInActiveBreakpointSegment) == JsTTDMoveMode::JsTTDMoveScanIntervalForContinueInActiveBreakpointSegment)
39533953
{
39543954
GlobalAPIWrapper_NoRecord([&]() -> JsErrorCode
@@ -4040,7 +4040,7 @@ CHAKRA_API JsTTDReplayExecution(_Inout_ JsTTDMoveMode* moveMode, _Out_ int64_t*
40404040
return JsNoError;
40414041
});
40424042

4043-
if(bpstatus != JsNoError)
4043+
if(bpstatus != JsNoError)
40444044
{
40454045
return bpstatus;
40464046
}
@@ -4638,4 +4638,49 @@ CHAKRA_API JsGetAndClearExceptionWithMetadata(_Out_ JsValueRef *metadata)
46384638
return JsNoError;
46394639
});
46404640
}
4641+
4642+
CHAKRA_API JsCreateWeakReference(
4643+
_In_ JsValueRef value,
4644+
_Out_ JsWeakRef* weakRef)
4645+
{
4646+
VALIDATE_JSREF(value);
4647+
PARAM_NOT_NULL(weakRef);
4648+
*weakRef = nullptr;
4649+
4650+
return GlobalAPIWrapper_NoRecord([&]() -> JsErrorCode {
4651+
ThreadContext* threadContext = ThreadContext::GetContextForCurrentThread();
4652+
if (threadContext == nullptr)
4653+
{
4654+
return JsErrorNoCurrentContext;
4655+
}
4656+
4657+
Recycler* recycler = threadContext->GetRecycler();
4658+
if (recycler->IsInObjectBeforeCollectCallback())
4659+
{
4660+
return JsErrorInObjectBeforeCollectCallback;
4661+
}
4662+
4663+
recycler->FindOrCreateWeakReferenceHandle<char>(
4664+
reinterpret_cast<char*>(value),
4665+
reinterpret_cast<Memory::RecyclerWeakReference<char>**>(weakRef));
4666+
return JsNoError;
4667+
});
4668+
}
4669+
4670+
CHAKRA_API JsGetWeakReferenceValue(
4671+
_In_ JsWeakRef weakRef,
4672+
_Out_ JsValueRef* value)
4673+
{
4674+
VALIDATE_JSREF(weakRef);
4675+
PARAM_NOT_NULL(value);
4676+
*value = JS_INVALID_REFERENCE;
4677+
4678+
return GlobalAPIWrapper_NoRecord([&]() -> JsErrorCode {
4679+
Memory::RecyclerWeakReference<char>* recyclerWeakReference =
4680+
reinterpret_cast<Memory::RecyclerWeakReference<char>*>(weakRef);
4681+
*value = reinterpret_cast<JsValueRef>(recyclerWeakReference->Get());
4682+
return JsNoError;
4683+
});
4684+
}
4685+
46414686
#endif // CHAKRACOREBUILD_

lib/Jsrt/JsrtCommonExports.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,6 @@
117117
JsCopyPropertyId
118118
JsCreatePromise
119119
JsGetAndClearExceptionWithMetadata
120+
JsCreateWeakReference
121+
JsGetWeakReferenceValue
120122
#endif

lib/Jsrt/JsrtInternal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct {} TTDRecorder;
3434
{ \
3535
return JsErrorWrongRuntime; \
3636
} \
37-
p = Js::CrossSite::MarshalVar(scriptContext, __obj); \
37+
p = Js::CrossSite::MarshalVar(scriptContext, __obj, true); \
3838
}
3939

4040
#define VALIDATE_INCOMING_RUNTIME_HANDLE(p) \
@@ -407,8 +407,8 @@ void HandleScriptCompileError(Js::ScriptContext * scriptContext, CompileScriptEx
407407
#else
408408
#define PERFORM_JSRT_TTD_RECORD_ACTION_CHECK(CTX) false
409409

410-
#define PERFORM_JSRT_TTD_RECORD_ACTION(CTX, ACTION_CODE, ...)
411-
#define PERFORM_JSRT_TTD_RECORD_ACTION_RESULT(CTX, RESULT)
410+
#define PERFORM_JSRT_TTD_RECORD_ACTION(CTX, ACTION_CODE, ...)
411+
#define PERFORM_JSRT_TTD_RECORD_ACTION_RESULT(CTX, RESULT)
412412

413-
#define PERFORM_JSRT_TTD_RECORD_ACTION_NOT_IMPLEMENTED(CTX)
413+
#define PERFORM_JSRT_TTD_RECORD_ACTION_NOT_IMPLEMENTED(CTX)
414414
#endif

lib/Parser/rterrors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ RT_ERROR_MSG(JSERR_NeedString, 5005, "'%s' is not a string", "String expected",
112112
RT_ERROR_MSG(JSERR_NeedDate, 5006, "'%s' is not a date object", "Date object expected", kjstTypeError, 0)
113113
RT_ERROR_MSG(JSERR_NeedObject, 5007, "'%s' is null or not an object", "Object expected", kjstTypeError, 0)
114114
RT_ERROR_MSG(JSERR_CantAssignTo, 5008, "", "Invalid left-hand side in assignment", kjstReferenceError, 0)
115-
RT_ERROR_MSG(JSERR_UndefVariable, 5009, "'%s' is undefined", "Undefined identifier", kjstTypeError, 0)
115+
RT_ERROR_MSG(JSERR_UndefVariable, 5009, "'%s' is not defined", "Undefined identifier", kjstTypeError, 0)
116116
RT_ERROR_MSG(JSERR_NeedBoolean, 5010, "'%s' is not a boolean", "Boolean expected", kjstTypeError, 0)
117117

118118
// This is the legacy error code for JScript.

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,7 @@ ThreadContext::ProbeStackNoDispose(size_t size, Js::ScriptContext *scriptContext
17121712
Js::Throw::StackOverflow(scriptContext, returnAddress);
17131713
}
17141714

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

17271729
void

lib/Runtime/ByteCode/ByteCodeCacheReleaseFileVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
//-------------------------------------------------------------------------------------------------------
55
// NOTE: If there is a merge conflict the correct fix is to make a new GUID.
66

7-
// {FEE3FADC-D028-4221-907F-37E25EABBD96}
7+
// {1a8e3edd-d08b-4a53-92d9-199667c17520}
88
const GUID byteCodeCacheReleaseFileVersion =
9-
{ 0xFEE3FADC, 0xD028, 0x4221, { 0x90, 0x7F, 0x37, 0xE2, 0x5E, 0xAB, 0xBD, 0x96 } };
9+
{ 0x1a8e3edd, 0xd08b, 0x4a53, { 0x92, 0xd9, 0x19, 0x96, 0x67, 0xc1, 0x75, 0x20 } };

netci.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def msbuildTypeMap = [
2020
def machineTypeToOSTagMap = [
2121
'Windows 7': 'Windows 7',
2222
'Windows_NT': 'Windows',
23-
'Ubuntu14.04': 'Ubuntu14.04',
2423
'Ubuntu16.04': 'Ubuntu',
2524
'OSX': 'OSX'
2625
]
@@ -214,7 +213,7 @@ def CreateStyleCheckTasks = { taskString, taskName, checkName ->
214213
Utilities.addGithubPushTrigger(newJob)
215214
}
216215

217-
Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', 'latest-or-auto')
216+
Utilities.setMachineAffinity(newJob, 'Ubuntu16.04', 'latest-or-auto')
218217
}
219218
}
220219

0 commit comments

Comments
 (0)