Skip to content

Commit a08b42a

Browse files
authored
Merge branch 'master' into patch-1
2 parents 7cafb32 + 2b36a31 commit a08b42a

Some content is hidden

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

56 files changed

+21216
-19685
lines changed

ContributionAgreement.md

+3
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ This agreement has been signed by:
4040
|Yevhen Lukomskyi|ylukomskyi|
4141
|Evgeniy Istomin|MadProbe|
4242
|Wenlu Wang| Kingwl|
43+
|Kevin Cadieux|kevcadieux|
44+
|Aidan Bickford| BickfordA|
45+
|Ryoichi Kaida| camcam-lemon|

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ChakraCore
22

3-
[![Discord Chat](https://img.shields.io/discord/695166668967510077?label=Discord&logo=Discord)](https://discord.gg/3e49Ptz)
3+
[![Discord Chat](https://img.shields.io/discord/695166668967510077?label=Discord&logo=Discord)](https://discord.gg/dgRawPdNuC)
44
[![Licensed under the MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/Microsoft/ChakraCore/blob/master/LICENSE.txt)
55
[![PR's Welcome](https://img.shields.io/badge/PRs%20-welcome-brightgreen.svg)](#contribute)
66

bin/NativeTests/JsRTApiTest.cpp

+64
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#include "stdafx.h"
@@ -2259,7 +2260,70 @@ namespace JsRTApiTest
22592260
TEST_CASE("ApiTest_ModuleSuccessTest", "[ApiTest]")
22602261
{
22612262
JsRTApiTest::WithSetup(JsRuntimeAttributeEnableExperimentalFeatures, ModuleSuccessTest);
2263+
}
2264+
2265+
void JsIsCallableTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
2266+
{
2267+
JsValueRef callables, callable, index, nonCallables, nonCallable;
2268+
bool check;
2269+
2270+
REQUIRE(JsRunScript(_u("[function(){},function*(){},async function(){},async function*(){},_=>_,async _=>_]"),
2271+
JS_SOURCE_CONTEXT_NONE, _u(""), &callables) == JsNoError);
2272+
2273+
for (int i = 0; i < 6; i++)
2274+
{
2275+
REQUIRE(JsIntToNumber(i, &index) == JsNoError);
2276+
REQUIRE(JsGetIndexedProperty(callables, index, &callable) == JsNoError);
2277+
REQUIRE(JsIsCallable(callable, &check) == JsNoError);
2278+
CHECK(check);
2279+
}
2280+
2281+
2282+
REQUIRE(JsRunScript(_u("[class{},Math,Reflect,{}]"), JS_SOURCE_CONTEXT_NONE, _u(""), &nonCallables) == JsNoError);
2283+
2284+
for (int i = 0; i < 4; i++)
2285+
{
2286+
REQUIRE(JsIntToNumber(i, &index) == JsNoError);
2287+
REQUIRE(JsGetIndexedProperty(nonCallables, index, &nonCallable) == JsNoError);
2288+
REQUIRE(JsIsCallable(nonCallable, &check) == JsNoError);
2289+
CHECK(!check);
2290+
}
2291+
}
2292+
2293+
TEST_CASE("ApiTest_JsIsCallableTest", "[ApiTest]") {
2294+
JsRTApiTest::RunWithAttributes(JsIsCallableTest);
2295+
}
2296+
2297+
void JsIsConstructorTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
2298+
{
2299+
JsValueRef constructables, constructable, index, nonConstructables, nonConstructable;
2300+
bool check;
2301+
2302+
REQUIRE(JsRunScript(_u("[class{},function(){}]"), JS_SOURCE_CONTEXT_NONE, _u(""), &constructables) == JsNoError);
2303+
2304+
for (int i = 0; i < 2; i++)
2305+
{
2306+
REQUIRE(JsIntToNumber(i, &index) == JsNoError);
2307+
REQUIRE(JsGetIndexedProperty(constructables, index, &constructable) == JsNoError);
2308+
REQUIRE(JsIsConstructor(constructable, &check) == JsNoError);
2309+
CHECK(check);
2310+
}
2311+
2312+
2313+
REQUIRE(JsRunScript(_u("[Math,Reflect,{},function*(){},async function(){},async function*(){},_=>_,async _=>_]"),
2314+
JS_SOURCE_CONTEXT_NONE, _u(""), &nonConstructables) == JsNoError);
2315+
2316+
for (int i = 0; i < 8; i++)
2317+
{
2318+
REQUIRE(JsIntToNumber(i, &index) == JsNoError);
2319+
REQUIRE(JsGetIndexedProperty(nonConstructables, index, &nonConstructable) == JsNoError);
2320+
REQUIRE(JsIsConstructor(nonConstructable, &check) == JsNoError);
2321+
CHECK(!check);
2322+
}
2323+
}
22622324

2325+
TEST_CASE("ApiTest_JsIsConstructorTest", "[ApiTest]") {
2326+
JsRTApiTest::RunWithAttributes(JsIsConstructorTest);
22632327
}
22642328

22652329
void SetModuleHostInfoTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)

bin/ch/262.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
//-------------------------------------------------------------------------------------------------------
2-
// Copyright (C) Microsoft. All rights reserved.
2+
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56

67
R"====(
78
var $262 = {
8-
createRealm: function () {
9-
return WScript.LoadScript('', 'samethread').$262;
10-
},
11-
global: this,
12-
agent: {
13-
start: function (src) {
14-
WScript.LoadScript(
15-
`
16-
$262 = {
17-
agent:{
18-
receiveBroadcast: function(callback){ WScript.ReceiveBroadcast(callback); },
19-
report: function(value){ WScript.Report(value); },
20-
leaving: function(){ WScript.Leaving(); }
21-
}
22-
};
23-
${src}
24-
`, 'crossthread');
25-
},
26-
broadcast: function (sab) { WScript.Broadcast(sab); },
27-
sleep: function (timeout) { WScript.Sleep(timeout); },
28-
getReport: function () { return WScript.GetReport(); },
29-
},
9+
createRealm: () => WScript.LoadScript('', 'samethread').$262,
10+
global: this,
11+
agent: {
12+
start(src) {
13+
WScript.LoadScript(`
14+
$262 = {
15+
agent: {
16+
receiveBroadcast: WScript.ReceiveBroadcast,
17+
report: WScript.Report,
18+
leaving: WScript.Leaving,
19+
monotonicNow: WScript.monotonicNow
20+
}
21+
};
22+
${ src }
23+
`, 'crossthread');
24+
},
25+
broadcast: WScript.Broadcast,
26+
sleep: WScript.Sleep,
27+
getReport: WScript.GetReport,
28+
monotonicNow: WScript.monotonicNow
29+
}
3030
};
3131
)===="

bin/ch/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
find_package (Python COMPONENTS Interpreter)
12
add_custom_target(dbg_controller_h
2-
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jstoc.py ${CMAKE_CURRENT_SOURCE_DIR}/DbgController.js controllerScript
3+
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/jstoc.py ${CMAKE_CURRENT_SOURCE_DIR}/DbgController.js controllerScript
34
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
45
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/jstoc.py ${CMAKE_CURRENT_SOURCE_DIR}/DbgController.js
56
)

bin/ch/DbgController.js

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var controllerObj = (function () {
6464
[
6565
"#__proto__",
6666
"globalThis",
67+
"AggregateError",
6768
"Array",
6869
"ArrayBuffer",
6970
"Atomics",

bin/ch/WScriptJsrt.cpp

+30-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55
//-------------------------------------------------------------------------------------------------------
66
#include "stdafx.h"
77
#include "PlatformAgnostic/ChakraICU.h"
8+
#if defined(__APPLE__)
9+
#ifdef ctime
10+
#undef ctime
11+
#define CTIME_UNDEFED
12+
#endif
13+
#endif
814
#include <vector>
15+
#include <ctime>
16+
#include <ratio>
17+
#include <chrono>
918

1019
#if defined(_X86_) || defined(_M_IX86)
1120
#define CPU_ARCH_TEXT "x86"
@@ -833,6 +842,26 @@ JsValueRef WScriptJsrt::LoadScript(JsValueRef callee, LPCSTR fileName,
833842
return value;
834843
}
835844

845+
JsValueRef WScriptJsrt::MonotonicNowCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
846+
{
847+
LPCWSTR errorMessage = _u("invalid call to WScript.monotonicNow");
848+
JsErrorCode errorCode = JsNoError;
849+
HRESULT hr = S_OK;
850+
JsValueRef result;
851+
852+
IfJsrtErrorSetGo(ChakraRTInterface::JsDoubleToNumber(static_cast<double>(std::chrono::steady_clock::now().time_since_epoch().count()) / 1e6 /* ns in ms */, &result));
853+
854+
#ifdef CTIME_UNDEFED
855+
#define ctime PAL_ctime
856+
#undef CTIME_UNDEFED
857+
#endif
858+
return result;
859+
860+
Error:
861+
SetExceptionIf(errorCode, errorMessage);
862+
return JS_INVALID_REFERENCE;
863+
}
864+
836865
JsValueRef WScriptJsrt::SetTimeoutCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
837866
{
838867
LPCWSTR errorMessage = _u("invalid call to WScript.SetTimeout");
@@ -1009,12 +1038,6 @@ JsValueRef WScriptJsrt::RequestAsyncBreakCallback(JsValueRef callee, bool isCons
10091038
return JS_INVALID_REFERENCE;
10101039
}
10111040

1012-
JsValueRef WScriptJsrt::EmptyCallback(JsValueRef callee, bool isConstructCall,
1013-
JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
1014-
{
1015-
return JS_INVALID_REFERENCE;
1016-
}
1017-
10181041
bool WScriptJsrt::CreateNamedFunction(const char* nameString, JsNativeFunction callback,
10191042
JsValueRef* functionVar)
10201043
{
@@ -1059,6 +1082,7 @@ bool WScriptJsrt::Initialize()
10591082
JsValueRef wscript;
10601083
IfJsrtErrorFail(ChakraRTInterface::JsCreateObject(&wscript), false);
10611084

1085+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(wscript, "monotonicNow", MonotonicNowCallback));
10621086
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(wscript, "Echo", EchoCallback));
10631087
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(wscript, "Quit", QuitCallback));
10641088
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(wscript, "LoadScriptFile", LoadScriptFileCallback));
@@ -1080,9 +1104,6 @@ bool WScriptJsrt::Initialize()
10801104
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(wscript, "SerializeObject", SerializeObject));
10811105
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(wscript, "Deserialize", Deserialize));
10821106

1083-
// ToDo Remove
1084-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(wscript, "Edit", EmptyCallback));
1085-
10861107
// Platform
10871108
JsValueRef platformObject;
10881109
IfJsrtErrorFail(ChakraRTInterface::JsCreateObject(&platformObject), false);

bin/ch/WScriptJsrt.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -121,14 +122,14 @@ class WScriptJsrt
121122
static JsValueRef CALLBACK LoadScriptCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
122123
static JsValueRef CALLBACK LoadModuleCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
123124
static JsValueRef CALLBACK GetModuleNamespace(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
125+
static JsValueRef CALLBACK MonotonicNowCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
124126
static JsValueRef CALLBACK SetTimeoutCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
125127
static JsValueRef CALLBACK ClearTimeoutCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
126128
static JsValueRef CALLBACK AttachCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
127129
static JsValueRef CALLBACK DetachCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
128130
static JsValueRef CALLBACK DumpFunctionPositionCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
129131
static JsValueRef CALLBACK RequestAsyncBreakCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
130132

131-
static JsValueRef CALLBACK EmptyCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
132133
static JsErrorCode CALLBACK LoadModuleFromString(LPCSTR fileName, LPCSTR fileContent, LPCSTR fullName = nullptr, bool isFile = false);
133134

134135
static JsValueRef CALLBACK LoadBinaryFileCallback(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);

build.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
#-------------------------------------------------------------------------------------------------------
33
# Copyright (C) Microsoft. All rights reserved.
4+
# Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
45
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
56
#-------------------------------------------------------------------------------------------------------
67

@@ -127,7 +128,7 @@ CMAKE_EXPORT_COMPILE_COMMANDS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
127128
LIBS_ONLY_BUILD=
128129
ALWAYS_YES=
129130
CCACHE_NAME=
130-
PYTHON2_BINARY=$(which python2.7 || which python2 || which python 2> /dev/null)
131+
PYTHON_BINARY=$(which python3 || which python || which python2.7 || which python2 || which python 2> /dev/null)
131132

132133
UNAME_S=`uname -s`
133134
if [[ $UNAME_S =~ 'Linux' ]]; then
@@ -538,7 +539,7 @@ export TARGET_PATH
538539

539540
if [[ $HAS_LTTNG == 1 ]]; then
540541
CHAKRACORE_ROOT=`dirname $0`
541-
"$PYTHON2_BINARY" $CHAKRACORE_ROOT/tools/lttng.py --man $CHAKRACORE_ROOT/manifests/Microsoft-Scripting-Chakra-Instrumentation.man --intermediate $TARGET_PATH/intermediate
542+
"$PYTHON_BINARY" $CHAKRACORE_ROOT/tools/lttng.py --man $CHAKRACORE_ROOT/manifests/Microsoft-Scripting-Chakra-Instrumentation.man --intermediate $TARGET_PATH/intermediate
542543
mkdir -p $TARGET_PATH/lttng
543544
(diff -q $TARGET_PATH/intermediate/lttng/jscriptEtw.h $TARGET_PATH/lttng/jscriptEtw.h && echo "jscriptEtw.h up to date; skipping") || cp $TARGET_PATH/intermediate/lttng/* $TARGET_PATH/lttng/
544545
fi
@@ -553,8 +554,8 @@ fi
553554
BUILD_DIRECTORY="${TARGET_PATH}/${BUILD_TYPE_DIR:0}"
554555
echo "Build path: ${BUILD_DIRECTORY}"
555556

556-
BUILD_RELATIVE_DIRECTORY=$("$PYTHON2_BINARY" -c "import os.path;print \
557-
os.path.relpath('${CHAKRACORE_DIR}', '$BUILD_DIRECTORY')")
557+
BUILD_RELATIVE_DIRECTORY=$("$PYTHON_BINARY" -c "from __future__ import print_function; import os.path;\
558+
print(os.path.relpath('${CHAKRACORE_DIR}', '$BUILD_DIRECTORY'))")
558559

559560
################# Write-barrier check/analyze run #################
560561
WB_FLAG=

lib/Backend/Inline.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ Inline::InlineBuiltInFunction(
22032203
if (OpCodeAttr::BailOutRec(inlineCallOpCode))
22042204
{
22052205
StackSym * sym = argInstr->GetSrc1()->GetStackSym();
2206-
if (!sym->m_isSingleDef || !sym->m_instrDef->GetSrc1() || !sym->m_instrDef->GetSrc1()->IsConstOpnd())
2206+
if (sym->HasByteCodeRegSlot() && (!sym->m_isSingleDef || !sym->m_instrDef->GetSrc1() || !sym->m_instrDef->GetSrc1()->IsConstOpnd()))
22072207
{
22082208
if (!sym->IsFromByteCodeConstantTable() && sym->GetByteCodeRegSlot() != callInstrDst->GetStackSym()->GetByteCodeRegSlot())
22092209
{
@@ -3813,6 +3813,10 @@ Inline::SetupInlineInstrForCallDirect(Js::BuiltinFunction builtInId, IR::Instr*
38133813
callInstr->SetSrc1(IR::HelperCallOpnd::New(IR::JnHelperMethod::HelperObject_HasOwnProperty, callInstr->m_func));
38143814
break;
38153815

3816+
case Js::BuiltinFunction::JavascriptObject_HasOwn:
3817+
callInstr->SetSrc1(IR::HelperCallOpnd::New(IR::JnHelperMethod::HelperObject_HasOwn, callInstr->m_func));
3818+
break;
3819+
38163820
case Js::BuiltinFunction::JavascriptArray_IsArray:
38173821
callInstr->SetSrc1(IR::HelperCallOpnd::New(IR::JnHelperMethod::HelperArray_IsArray, callInstr->m_func));
38183822
break;

lib/Backend/InliningDecider.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ bool InliningDecider::GetBuiltInInfoCommon(
540540

541541
case Js::JavascriptBuiltInFunction::JavascriptArray_Includes:
542542
case Js::JavascriptBuiltInFunction::JavascriptObject_HasOwnProperty:
543+
case Js::JavascriptBuiltInFunction::JavascriptObject_HasOwn:
543544
case Js::JavascriptBuiltInFunction::JavascriptArray_IsArray:
544545
*returnType = ValueType::Boolean;
545546
goto CallDirectCommon;

lib/Backend/JnHelperMethodList.h

+1
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ HELPERCALL(String_PadStart, Js::JavascriptString::EntryPadStart, 0)
525525
HELPERCALL(String_PadEnd, Js::JavascriptString::EntryPadEnd, 0)
526526
HELPERCALLCHK(GlobalObject_ParseInt, Js::GlobalObject::EntryParseInt, 0)
527527
HELPERCALLCHK(Object_HasOwnProperty, Js::JavascriptObject::EntryHasOwnProperty, 0)
528+
HELPERCALLCHK(Object_HasOwn, Js::JavascriptObject::EntryHasOwn, 0)
528529

529530
HELPERCALL(RegExp_SplitResultUsed, Js::RegexHelper::RegexSplitResultUsed, 0)
530531
HELPERCALL(RegExp_SplitResultUsedAndMayBeTemp, Js::RegexHelper::RegexSplitResultUsedAndMayBeTemp, 0)

lib/Common/ConfigFlagsList.h

+4
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ PHASE(All)
671671
#define DEFAULT_CONFIG_ESHashbang (true)
672672
#define DEFAULT_CONFIG_ESSymbolDescription (true)
673673
#define DEFAULT_CONFIG_ESArrayFindFromLast (false)
674+
#define DEFAULT_CONFIG_ESPromiseAny (true)
674675
#define DEFAULT_CONFIG_ESNullishCoalescingOperator (true)
675676
#define DEFAULT_CONFIG_ESGlobalThis (true)
676677

@@ -1208,6 +1209,9 @@ FLAGR(Boolean, ESSymbolDescription, "Enable Symbol.prototype.description", DEFAU
12081209

12091210
FLAGR(Boolean, ESArrayFindFromLast, "Enable findLast, findLastIndex for Array.prototype and TypedArray.prorotype", DEFAULT_CONFIG_ESArrayFindFromLast)
12101211

1212+
// ES Promise.any and AggregateError flag
1213+
FLAGR(Boolean, ESPromiseAny, "Enable Promise.any and AggregateError", DEFAULT_CONFIG_ESPromiseAny)
1214+
12111215
// ES import.meta keyword meta-property
12121216
FLAGR(Boolean, ESImportMeta, "Enable import.meta keyword", DEFAULT_CONFIG_ESImportMeta)
12131217

lib/Common/DataStructures/FixedBitVector.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
2-
// Copyright (C) Microsoft. All rights reserved.
2+
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -250,9 +251,10 @@ void BVFixed::SetRange(Container* value, BVIndex start, BVIndex len)
250251
BVUnit::BVUnitTContainer* bits;
251252
static_assert(sizeof(Container) == 1 || sizeof(Container) == sizeof(BVUnit::BVUnitTContainer),
252253
"Container is not suitable to represent the calculated value");
253-
if (sizeof(BVUnit::BVUnitTContainer) == 1)
254+
if (sizeof(Container) == 1)
254255
{
255-
temp = *((BVUnit::BVUnitTContainer*)value);
256+
static_assert(sizeof(byte) == 1, "Size of byte should be 1.");
257+
temp = *(byte*)value;
256258
bits = &temp;
257259
}
258260
else

lib/Jsrt/Core/JsrtCore.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#include "JsrtPch.h"
@@ -1460,7 +1461,7 @@ CHAKRA_API JsIsCallable(_In_ JsValueRef object, _Out_ bool *isCallable)
14601461
VALIDATE_INCOMING_OBJECT(object, scriptContext);
14611462
PARAM_NOT_NULL(isCallable);
14621463

1463-
*isCallable = Js::JavascriptConversion::IsCallable(object);
1464+
*isCallable = Js::JavascriptConversion::IsCallable(object) && !Js::JavascriptOperators::IsClassConstructor(object);
14641465

14651466
return JsNoError;
14661467
});

0 commit comments

Comments
 (0)