Skip to content

Commit 1544822

Browse files
committed
surface oop jit on windows builds of chakracore
1 parent f55c747 commit 1544822

File tree

12 files changed

+79
-53
lines changed

12 files changed

+79
-53
lines changed

bin/ChakraCore/TestHooks.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,6 @@ HRESULT __stdcall SetEnableCheckMemoryLeakOutput(bool flag)
6868
return S_OK;
6969
}
7070

71-
#if ENABLE_NATIVE_CODEGEN
72-
#ifdef _WIN32
73-
void __stdcall ConnectJITServer(HANDLE processHandle, void* serverSecurityDescriptor, UUID connectionId)
74-
{
75-
JITManager::GetJITManager()->EnableOOPJIT();
76-
ThreadContext::SetJITConnectionInfo(processHandle, serverSecurityDescriptor, connectionId);
77-
}
78-
#endif
79-
#endif
80-
8171
void __stdcall NotifyUnhandledException(PEXCEPTION_POINTERS exceptionInfo)
8272
{
8373
#ifdef GENERATE_DUMP
@@ -203,9 +193,6 @@ HRESULT OnChakraCoreLoaded(OnChakraCoreLoadedPtr pfChakraCoreLoaded)
203193
#undef FLAG_NumberPairSet
204194
#undef FLAG_NumberTrioSet
205195
#undef FLAG_NumberRange
206-
#if ENABLE_NATIVE_CODEGEN && _WIN32
207-
ConnectJITServer,
208-
#endif
209196
NotifyUnhandledException
210197
};
211198
return pfChakraCoreLoaded(testHooks);

bin/ChakraCore/TestHooks.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ struct TestHooks
6969
#undef FLAG_NumberTrioSet
7070
#undef FLAG_NumberRange
7171

72-
#if ENABLE_NATIVE_CODEGEN
73-
#ifdef _WIN32
74-
typedef void(TESTHOOK_CALL * ConnectJITServer)(HANDLE processHandle, void* serverSecurityDescriptor, UUID connectionId);
75-
ConnectJITServer pfnConnectJITServer;
76-
#endif
77-
#endif
78-
7972
NotifyUnhandledExceptionPtr pfnNotifyUnhandledException;
8073
};
8174

bin/ch/ChakraRtInterface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
178178
m_jsApiHooks.pfJsrtTTDGetSnapTimeTopLevelEventMove = (JsAPIHooks::JsrtTTDGetSnapTimeTopLevelEventMovePtr)GetChakraCoreSymbol(library, "JsTTDGetSnapTimeTopLevelEventMove");
179179
m_jsApiHooks.pfJsrtTTDMoveToTopLevelEvent = (JsAPIHooks::JsrtTTDMoveToTopLevelEventPtr)GetChakraCoreSymbol(library, "JsTTDMoveToTopLevelEvent");
180180
m_jsApiHooks.pfJsrtTTDReplayExecution = (JsAPIHooks::JsrtTTDReplayExecutionPtr)GetChakraCoreSymbol(library, "JsTTDReplayExecution");
181+
#ifdef _WIN32
182+
m_jsApiHooks.pfJsrtConnectJITProcess = (JsAPIHooks::JsrtConnectJITProcess)GetChakraCoreSymbol(library, "JsConnectJITProcess");
183+
#endif
181184
#endif
182185

183186
return true;

bin/ch/ChakraRtInterface.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ struct JsAPIHooks
112112
typedef JsErrorCode(WINAPI *JsrtTTDMoveToTopLevelEventPtr)(JsRuntimeHandle runtimeHandle, JsTTDMoveMode moveMode, int64_t snapshotStartTime, int64_t eventTime);
113113
typedef JsErrorCode(WINAPI *JsrtTTDReplayExecutionPtr)(JsTTDMoveMode* moveMode, int64_t* rootEventTime);
114114

115+
#ifdef _WIN32
116+
typedef JsErrorCode(WINAPI *JsrtConnectJITProcess)(HANDLE processHandle, void* serverSecurityDescriptor, UUID connectionId);
117+
#endif
118+
115119
JsrtCreateRuntimePtr pfJsrtCreateRuntime;
116120
JsrtCreateContextPtr pfJsrtCreateContext;
117121
JsrtSetObjectBeforeCollectCallbackPtr pfJsrtSetObjectBeforeCollectCallback;
@@ -217,6 +221,10 @@ struct JsAPIHooks
217221
JsrtTTDGetSnapTimeTopLevelEventMovePtr pfJsrtTTDGetSnapTimeTopLevelEventMove;
218222
JsrtTTDMoveToTopLevelEventPtr pfJsrtTTDMoveToTopLevelEvent;
219223
JsrtTTDReplayExecutionPtr pfJsrtTTDReplayExecution;
224+
225+
#ifdef _WIN32
226+
JsrtConnectJITProcess pfJsrtConnectJITProcess;
227+
#endif
220228
};
221229

222230
#ifdef _WIN32
@@ -307,18 +315,6 @@ class ChakraRTInterface
307315
#endif
308316
}
309317

310-
#ifdef _WIN32
311-
#if ENABLE_NATIVE_CODEGEN
312-
static void ConnectJITServer(HANDLE processHandle, void* serverSecurityDescriptor, UUID connectionId)
313-
{
314-
if (m_testHooksSetup && m_testHooks.pfnConnectJITServer != NULL)
315-
{
316-
m_testHooks.pfnConnectJITServer(processHandle, serverSecurityDescriptor, connectionId);
317-
}
318-
}
319-
#endif
320-
#endif
321-
322318
static void NotifyUnhandledException(PEXCEPTION_POINTERS exceptionInfo)
323319
{
324320
if (m_testHooksSetup && m_testHooks.pfnNotifyUnhandledException != NULL)
@@ -442,6 +438,9 @@ class ChakraRTInterface
442438
static JsErrorCode WINAPI JsQueueBackgroundParse_Experimental(JsScriptContents* contents, DWORD* dwBgParseCookie) { return HOOK_JS_API(QueueBackgroundParse_Experimental)(contents, dwBgParseCookie); }
443439
static JsErrorCode WINAPI JsDiscardBackgroundParse_Experimental(DWORD dwBgParseCookie, void* buffer, bool* callerOwnsBuffer) { return HOOK_JS_API(DiscardBackgroundParse_Experimental(dwBgParseCookie, buffer, callerOwnsBuffer)); }
444440
static JsErrorCode WINAPI JsExecuteBackgroundParse_Experimental(DWORD dwBgParseCookie, JsValueRef script, JsSourceContext sourceContext, WCHAR *url, JsParseScriptAttributes parseAttributes, JsValueRef parserState, JsValueRef *result) { return HOOK_JS_API(ExecuteBackgroundParse_Experimental(dwBgParseCookie, script, sourceContext, url, parseAttributes, parserState, result)); }
441+
#ifdef _WIN32
442+
static JsErrorCode WINAPI JsConnectJITProcess(HANDLE processHandle, void* serverSecurityDescriptor, UUID connectionId) { return HOOK_JS_API(ConnectJITProcess(processHandle, serverSecurityDescriptor, connectionId)); }
443+
#endif
445444
};
446445

447446
class AutoRestoreContext

bin/ch/ch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ int _cdecl wmain(int argc, __in_ecount(argc) LPWSTR argv[])
12981298
{
12991299
// TODO: Error checking
13001300
JITProcessManager::StartRpcServer(argc, argv);
1301-
ChakraRTInterface::ConnectJITServer(JITProcessManager::GetRpcProccessHandle(), nullptr, JITProcessManager::GetRpcConnectionId());
1301+
ChakraRTInterface::JsConnectJITProcess(JITProcessManager::GetRpcProccessHandle(), nullptr, JITProcessManager::GetRpcConnectionId());
13021302
}
13031303
#endif
13041304
HANDLE threadHandle;

lib/JITClient/JITManager.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,22 @@ JITManager::CreateBinding(
6767
RPC_BINDING_HANDLE_TEMPLATE_V1 bindingTemplate;
6868
RPC_BINDING_HANDLE_SECURITY_V1_W bindingSecurity;
6969

70-
#ifndef NTBUILD
71-
RPC_SECURITY_QOS_V4 securityQOS;
72-
ZeroMemory(&securityQOS, sizeof(RPC_SECURITY_QOS_V4));
73-
securityQOS.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT;
74-
securityQOS.IdentityTracking = RPC_C_QOS_IDENTITY_DYNAMIC;
75-
securityQOS.ImpersonationType = RPC_C_IMP_LEVEL_IDENTIFY;
76-
securityQOS.Version = 4;
77-
#else
70+
#if (NTDDI_VERSION >= NTDDI_WIN8)
7871
RPC_SECURITY_QOS_V5 securityQOS;
7972
ZeroMemory(&securityQOS, sizeof(RPC_SECURITY_QOS_V5));
8073
securityQOS.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT;
8174
securityQOS.IdentityTracking = RPC_C_QOS_IDENTITY_DYNAMIC;
8275
securityQOS.ImpersonationType = RPC_C_IMP_LEVEL_IDENTIFY;
8376
securityQOS.Version = 5;
8477
securityQOS.ServerSecurityDescriptor = serverSecurityDescriptor;
85-
#endif // NTBUILD
78+
#else
79+
RPC_SECURITY_QOS_V4 securityQOS;
80+
ZeroMemory(&securityQOS, sizeof(RPC_SECURITY_QOS_V4));
81+
securityQOS.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT;
82+
securityQOS.IdentityTracking = RPC_C_QOS_IDENTITY_DYNAMIC;
83+
securityQOS.ImpersonationType = RPC_C_IMP_LEVEL_IDENTIFY;
84+
securityQOS.Version = 4;
85+
#endif
8686

8787
ZeroMemory(&bindingTemplate, sizeof(bindingTemplate));
8888
bindingTemplate.Version = 1;

lib/JITServer/JITServer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ HRESULT JsInitializeJITServer(
2727
return status;
2828
}
2929

30-
#ifndef NTBUILD
31-
status = RpcServerRegisterIf2(
30+
#if (NTDDI_VERSION >= NTDDI_WIN8)
31+
status = RpcServerRegisterIf3(
3232
ServerIChakraJIT_v0_0_s_ifspec,
3333
NULL,
3434
NULL,
3535
RPC_IF_AUTOLISTEN,
3636
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
3737
(ULONG)-1,
38-
NULL);
38+
NULL,
39+
securityDescriptor);
3940
#else
40-
status = RpcServerRegisterIf3(
41+
status = RpcServerRegisterIf2(
4142
ServerIChakraJIT_v0_0_s_ifspec,
4243
NULL,
4344
NULL,
4445
RPC_IF_AUTOLISTEN,
4546
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
4647
(ULONG)-1,
47-
NULL,
48-
securityDescriptor);
48+
NULL);
4949
#endif
5050
if (status != RPC_S_OK)
5151
{

lib/Jsrt/Chakra.Jsrt.vcxproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Condition="'$(ChakraBuildPathImported)'!='true'" Project="$(SolutionDir)Chakra.Build.Paths.props" />
44
<Import Project="$(BuildConfigPropsPath)Chakra.Build.ProjectConfiguration.props" />
@@ -61,6 +61,7 @@
6161
<ClInclude Include="ChakraCommon.h" />
6262
<ClInclude Include="ChakraCommonWindows.h" />
6363
<ClInclude Include="ChakraCore.h" />
64+
<ClInclude Include="ChakraCoreWindows.h" />
6465
<ClInclude Include="ChakraDebug.h" />
6566
<ClInclude Include="JsrtContext.h" />
6667
<ClInclude Include="JsrtDebugManager.h" />
@@ -89,4 +90,4 @@
8990
</ItemGroup>
9091
<Import Project="$(BuildConfigPropsPath)Chakra.Build.targets" Condition="exists('$(BuildConfigPropsPath)Chakra.Build.targets')" />
9192
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
92-
</Project>
93+
</Project>

lib/Jsrt/ChakraCore.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,5 +1271,10 @@ CHAKRA_API
12711271
_In_ JsValueRef parserState,
12721272
_Out_ JsValueRef * result);
12731273

1274+
1275+
#ifdef _WIN32
1276+
#include "ChakraCoreWindows.h"
1277+
#endif // _WIN32
1278+
12741279
#endif // _CHAKRACOREBUILD
12751280
#endif // _CHAKRACORE_H_

lib/Jsrt/ChakraCoreWindows.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
#ifdef _MSC_VER
7+
#pragma once
8+
#endif // _MSC_VER
9+
10+
#ifndef _CHAKRACOREWINDOWS_H_
11+
#define _CHAKRACOREWINDOWS_H_
12+
13+
/// <summary>
14+
/// Enables out-of-process JIT by connecting to a Chakra JIT process that was initialized by calling JsInitializeJITServer
15+
/// </summary>
16+
/// <remarks>
17+
/// Should be called before JS code is executed.
18+
/// </remarks>
19+
/// <param name="processHandle">Handle to the JIT process</param>
20+
/// <param name="serverSecurityDescriptor">Optional pointer to an RPC SECURITY_DESCRIPTOR structure</param>
21+
/// <param name="connectionId">Same UUID that was passed to JsInitializeJITServer</param>
22+
/// <returns>
23+
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
24+
/// </returns>
25+
CHAKRA_API
26+
JsConnectJITProcess(_In_ HANDLE processHandle, _In_opt_ void* serverSecurityDescriptor, _In_ UUID connectionId);
27+
28+
#endif // _CHAKRACOREWINDOWS_H_

0 commit comments

Comments
 (0)