Skip to content

Commit 3cfff2c

Browse files
committed
[MERGE #5923 @MikeHolman] JSRT changes to support shim improvements
Merge pull request #5923 from MikeHolman:mergeshim This change adds a laundry list of new (still very experimental) JSRT APIs, to support improvements in chakra shim functionality and performance.
2 parents f23227e + 282f7a2 commit 3cfff2c

File tree

95 files changed

+8439
-758
lines changed

Some content is hidden

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

95 files changed

+8439
-758
lines changed

BUILD.gn

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
6+
action("ChakraCoreBuild") {
7+
script = "tools/run_msbuild.py"
8+
9+
chakracore_solution = rebase_path("Build\Chakra.Core.sln")
10+
11+
# NOSORT
12+
sources = [
13+
chakracore_solution
14+
]
15+
16+
outputs = [
17+
"$target_gen_dir/ChakraCore.lib",
18+
"$target_gen_dir/../../../ChakraCore.pdb",
19+
"$target_gen_dir/../../../ChakraCore.dll"
20+
]
21+
22+
# The path should be like: "Build/VcBuild/bin/x64_debug""
23+
outdir = "Build/VcBuild/bin/" + current_cpu
24+
25+
if (is_debug) {
26+
config = "Debug"
27+
outdir = outdir + "_debug"
28+
}
29+
else {
30+
config = "Release"
31+
outdir = outdir + "_release"
32+
}
33+
34+
outdir = rebase_path(outdir)
35+
36+
# On Windows, run msbuild.exe on sln and copy lib, dll, pdb files to appropriate locations,
37+
# def main(sln, outdir, target_gen_dir, *flags):
38+
39+
args = [
40+
chakracore_solution,
41+
outdir,
42+
rebase_path(target_gen_dir),
43+
"/m",
44+
"/t:Build",
45+
"/p:Configuration=$config",
46+
"/p:platform=$current_cpu"
47+
]
48+
}

Build/Chakra.Core.sln

Lines changed: 451 additions & 1 deletion
Large diffs are not rendered by default.

bin/ChakraCore/ChakraCore.vcxproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@
164164
<ProjectReference Include="..\..\lib\Runtime\Math\Chakra.Runtime.Math.vcxproj">
165165
<Project>{abc904ad-9415-46f8-aa23-e33193f81f7c}</Project>
166166
</ProjectReference>
167+
<ProjectReference Include="..\..\lib\SCACore\Chakra.SCACore.vcxproj">
168+
<Project>{4da3a367-6ed2-4ee8-9698-5bcd0b8af7f5}</Project>
169+
</ProjectReference>
167170
<ProjectReference Include="..\..\lib\WasmReader\Chakra.WasmReader.vcxproj">
168171
<Project>{53D52B0B-86D9-4D31-AD09-0D6B3C063ADD}</Project>
169172
</ProjectReference>
@@ -194,4 +197,4 @@
194197
</ItemGroup>
195198
<Import Project="$(BuildConfigPropsPath)Chakra.Build.targets" Condition="exists('$(BuildConfigPropsPath)Chakra.Build.targets')" />
196199
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
197-
</Project>
200+
</Project>

bin/ChakraCore/TestHooks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#pragma once
66

77
#ifdef ENABLE_TEST_HOOKS
8-
8+
#include <oaidl.h>
99
interface ICustomConfigFlags;
1010

1111
#if defined(_WIN32) || defined(_MSC_VER)

bin/NativeTests/JsRTApiTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ namespace JsRTApiTest
257257
CHECK(data == (void *)0xdeadbeef);
258258
}
259259

260+
void CALLBACK ExternalObjectTraceCallback(void *data)
261+
{
262+
CHECK(data == (void *)0xdeadbeef);
263+
}
264+
260265
void CrossContextSetPropertyTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
261266
{
262267
bool hasExternalData;
@@ -292,6 +297,11 @@ namespace JsRTApiTest
292297
REQUIRE(JsSetPrototype(jsrtExternalObjectRef, mainObjectRef) == JsNoError);
293298
REQUIRE(JsHasExternalData(jsrtExternalObjectRef, &hasExternalData) == JsNoError);
294299
REQUIRE(hasExternalData);
300+
301+
JsValueRef object3 = JS_INVALID_REFERENCE;
302+
JsGetterSetterInterceptor * interceptor3 = nullptr;
303+
JsValueRef prototype2 = JS_INVALID_REFERENCE;
304+
REQUIRE(JsCreateCustomExternalObject((void *)0xdeadbeef, 0, ExternalObjectTraceCallback, ExternalObjectFinalizeCallback, &interceptor3, prototype2, &object3) == JsNoError);
295305
}
296306

297307
TEST_CASE("ApiTest_CrossContextSetPropertyTest", "[ApiTest]")

bin/ch/ChakraRtInterface.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,20 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
7878
m_jsApiHooks.pfJsrtCreateRuntime = (JsAPIHooks::JsrtCreateRuntimePtr)GetChakraCoreSymbol(library, "JsCreateRuntime");
7979
m_jsApiHooks.pfJsrtCreateContext = (JsAPIHooks::JsrtCreateContextPtr)GetChakraCoreSymbol(library, "JsCreateContext");
8080
m_jsApiHooks.pfJsrtSetObjectBeforeCollectCallback = (JsAPIHooks::JsrtSetObjectBeforeCollectCallbackPtr)GetChakraCoreSymbol(library, "JsSetObjectBeforeCollectCallback");
81+
m_jsApiHooks.pfJsrtSetRuntimeDomWrapperTracingCallbacks = (JsAPIHooks::JsrtSetRuntimeDomWrapperTracingCallbacksPtr)GetChakraCoreSymbol(library, "JsSetRuntimeDomWrapperTracingCallbacks");
8182
m_jsApiHooks.pfJsrtSetRuntimeMemoryLimit = (JsAPIHooks::JsrtSetRuntimeMemoryLimitPtr)GetChakraCoreSymbol(library, "JsSetRuntimeMemoryLimit");
8283
m_jsApiHooks.pfJsrtSetCurrentContext = (JsAPIHooks::JsrtSetCurrentContextPtr)GetChakraCoreSymbol(library, "JsSetCurrentContext");
8384
m_jsApiHooks.pfJsrtGetCurrentContext = (JsAPIHooks::JsrtGetCurrentContextPtr)GetChakraCoreSymbol(library, "JsGetCurrentContext");
8485
m_jsApiHooks.pfJsrtDisposeRuntime = (JsAPIHooks::JsrtDisposeRuntimePtr)GetChakraCoreSymbol(library, "JsDisposeRuntime");
8586
m_jsApiHooks.pfJsrtCreateObject = (JsAPIHooks::JsrtCreateObjectPtr)GetChakraCoreSymbol(library, "JsCreateObject");
8687
m_jsApiHooks.pfJsrtCreateExternalObject = (JsAPIHooks::JsrtCreateExternalObjectPtr)GetChakraCoreSymbol(library, "JsCreateExternalObject");
88+
m_jsApiHooks.pfJsrtGetArrayForEachFunction = (JsAPIHooks::JsrtGetArrayForEachFunctionPtr)GetChakraCoreSymbol(library, "JsGetArrayForEachFunction");;
89+
m_jsApiHooks.pfJsrtGetArrayKeysFunction = (JsAPIHooks::JsrtGetArrayKeysFunctionPtr)GetChakraCoreSymbol(library, "JsGetArrayKeysFunction");;
90+
m_jsApiHooks.pfJsrtGetArrayValuesFunction = (JsAPIHooks::JsrtGetArrayValuesFunctionPtr)GetChakraCoreSymbol(library, "JsGetArrayValuesFunction");;
91+
m_jsApiHooks.pfJsrtGetArrayEntriesFunction = (JsAPIHooks::JsrtGetArrayEntriesFunctionPtr)GetChakraCoreSymbol(library, "JsGetArrayEntriesFunction");;
92+
m_jsApiHooks.pfJsrtGetPropertyIdSymbolIterator = (JsAPIHooks::JsrtGetPropertyIdSymbolIteratorPtr)GetChakraCoreSymbol(library, "JsGetPropertyIdSymbolIterator");;
93+
m_jsApiHooks.pfJsrtGetErrorPrototype = (JsAPIHooks::JsrtGetErrorPrototypePtr)GetChakraCoreSymbol(library, "JsGetErrorPrototype");;
94+
m_jsApiHooks.pfJsrtGetIteratorPrototype = (JsAPIHooks::JsrtGetIteratorPrototypePtr)GetChakraCoreSymbol(library, "JsGetIteratorPrototype");;
8795
m_jsApiHooks.pfJsrtCreateFunction = (JsAPIHooks::JsrtCreateFunctionPtr)GetChakraCoreSymbol(library, "JsCreateFunction");
8896
m_jsApiHooks.pfJsrtCreateNamedFunction = (JsAPIHooks::JsCreateNamedFunctionPtr)GetChakraCoreSymbol(library, "JsCreateNamedFunction");
8997
m_jsApiHooks.pfJsrtSetProperty = (JsAPIHooks::JsrtSetPropertyPtr)GetChakraCoreSymbol(library, "JsSetProperty");
@@ -105,6 +113,7 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
105113
m_jsApiHooks.pfJsrtDoubleToNumber = (JsAPIHooks::JsrtDoubleToNumberPtr)GetChakraCoreSymbol(library, "JsDoubleToNumber");
106114
m_jsApiHooks.pfJsrtGetExternalData = (JsAPIHooks::JsrtGetExternalDataPtr)GetChakraCoreSymbol(library, "JsGetExternalData");
107115
m_jsApiHooks.pfJsrtSetExternalData = (JsAPIHooks::JsrtSetExternalDataPtr)GetChakraCoreSymbol(library, "JsSetExternalData");
116+
m_jsApiHooks.pfJsrtCloneObject = (JsAPIHooks::JsrtCloneObjectPtr)GetChakraCoreSymbol(library, "JsCloneObject");
108117
m_jsApiHooks.pfJsrtCreateArray = (JsAPIHooks::JsrtCreateArrayPtr)GetChakraCoreSymbol(library, "JsCreateArray");
109118
m_jsApiHooks.pfJsrtCreateArrayBuffer = (JsAPIHooks::JsrtCreateArrayBufferPtr)GetChakraCoreSymbol(library, "JsCreateArrayBuffer");
110119
m_jsApiHooks.pfJsrtCreateSharedArrayBufferWithSharedContent = (JsAPIHooks::JsrtCreateSharedArrayBufferWithSharedContentPtr)GetChakraCoreSymbol(library, "JsCreateSharedArrayBufferWithSharedContent");
@@ -119,6 +128,7 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
119128
m_jsApiHooks.pfJsrtRelease = (JsAPIHooks::JsrtReleasePtr)GetChakraCoreSymbol(library, "JsRelease");
120129
m_jsApiHooks.pfJsrtAddRef = (JsAPIHooks::JsrtAddRefPtr)GetChakraCoreSymbol(library, "JsAddRef");
121130
m_jsApiHooks.pfJsrtGetValueType = (JsAPIHooks::JsrtGetValueType)GetChakraCoreSymbol(library, "JsGetValueType");
131+
m_jsApiHooks.pfJsrtGetIndexedProperty = (JsAPIHooks::JsrtGetIndexedPropertyPtr)GetChakraCoreSymbol(library, "JsGetIndexedProperty");
122132
m_jsApiHooks.pfJsrtSetIndexedProperty = (JsAPIHooks::JsrtSetIndexedPropertyPtr)GetChakraCoreSymbol(library, "JsSetIndexedProperty");
123133
m_jsApiHooks.pfJsrtSetPromiseContinuationCallback = (JsAPIHooks::JsrtSetPromiseContinuationCallbackPtr)GetChakraCoreSymbol(library, "JsSetPromiseContinuationCallback");
124134
m_jsApiHooks.pfJsrtSetHostPromiseRejectionTracker = (JsAPIHooks::JsrtSetHostPromiseRejectionTrackerPtr)GetChakraCoreSymbol(library, "JsSetHostPromiseRejectionTracker");
@@ -178,6 +188,18 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
178188
m_jsApiHooks.pfJsrtTTDGetSnapTimeTopLevelEventMove = (JsAPIHooks::JsrtTTDGetSnapTimeTopLevelEventMovePtr)GetChakraCoreSymbol(library, "JsTTDGetSnapTimeTopLevelEventMove");
179189
m_jsApiHooks.pfJsrtTTDMoveToTopLevelEvent = (JsAPIHooks::JsrtTTDMoveToTopLevelEventPtr)GetChakraCoreSymbol(library, "JsTTDMoveToTopLevelEvent");
180190
m_jsApiHooks.pfJsrtTTDReplayExecution = (JsAPIHooks::JsrtTTDReplayExecutionPtr)GetChakraCoreSymbol(library, "JsTTDReplayExecution");
191+
m_jsApiHooks.pfJsrtVarSerializer = (JsAPIHooks::JsrtVarSerializerPtr)GetChakraCoreSymbol(library, "JsVarSerializer");
192+
m_jsApiHooks.pfJsrtVarSerializerSetTransferableVars = (JsAPIHooks::JsrtVarSerializerSetTransferableVarsPtr)GetChakraCoreSymbol(library, "JsVarSerializerSetTransferableVars");
193+
m_jsApiHooks.pfJsrtVarSerializerWriteValue = (JsAPIHooks::JsrtVarSerializerWriteValuePtr)GetChakraCoreSymbol(library, "JsVarSerializerWriteValue");
194+
m_jsApiHooks.pfJsrtVarSerializerReleaseData = (JsAPIHooks::JsrtVarSerializerReleaseDataPtr)GetChakraCoreSymbol(library, "JsVarSerializerReleaseData");
195+
m_jsApiHooks.pfJsrtVarSerializerFree = (JsAPIHooks::JsrtVarSerializerFreePtr)GetChakraCoreSymbol(library, "JsVarSerializerFree");
196+
m_jsApiHooks.pfJsrtVarDeserializer = (JsAPIHooks::JsrtVarDeserializerPtr)GetChakraCoreSymbol(library, "JsVarDeserializer");
197+
m_jsApiHooks.pfJsrtVarDeserializerSetTransferableVars = (JsAPIHooks::JsrtVarDeserializerSetTransferableVarsPtr)GetChakraCoreSymbol(library, "JsVarDeserializerSetTransferableVars");
198+
m_jsApiHooks.pfJsrtVarDeserializerReadValue = (JsAPIHooks::JsrtVarDeserializerReadValuePtr)GetChakraCoreSymbol(library, "JsVarDeserializerReadValue");
199+
m_jsApiHooks.pfJsrtVarDeserializerFree = (JsAPIHooks::JsrtVarDeserializerFreePtr)GetChakraCoreSymbol(library, "JsVarDeserializerFree");
200+
201+
m_jsApiHooks.pfJsrtDetachArrayBuffer = (JsAPIHooks::JsrtDetachArrayBufferPtr)GetChakraCoreSymbol(library, "JsDetachArrayBuffer");
202+
181203
#ifdef _WIN32
182204
m_jsApiHooks.pfJsrtConnectJITProcess = (JsAPIHooks::JsrtConnectJITProcess)GetChakraCoreSymbol(library, "JsConnectJITProcess");
183205
#endif

0 commit comments

Comments
 (0)