Skip to content

Commit 34fa597

Browse files
MikeHolmanpleath
authored andcommitted
1 parent 7e1b6ad commit 34fa597

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

lib/Backend/EmitBuffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ bool EmitBufferManager<TAlloc, TPreReservedAlloc, SyncObject>::ProtectBufferWith
414414
template <typename TAlloc, typename TPreReservedAlloc, class SyncObject>
415415
bool EmitBufferManager<TAlloc, TPreReservedAlloc, SyncObject>::CommitBufferForInterpreter(TEmitBufferAllocation* allocation, _In_reads_bytes_(bufferSize) BYTE* pBuffer, _In_ size_t bufferSize)
416416
{
417-
Assert(this->criticalSection.IsLocked());
417+
AutoRealOrFakeCriticalSection<SyncObject> autoCs(&this->criticalSection);
418418

419419
Assert(allocation != nullptr);
420420
allocation->bytesUsed += bufferSize;

lib/Backend/ServerScriptContext.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ ServerScriptContext::IsClosed() const
312312
void
313313
ServerScriptContext::AddToDOMFastPathHelperMap(intptr_t funcInfoAddr, IR::JnHelperMethod helper)
314314
{
315+
AutoCriticalSection cs(&m_cs);
315316
m_domFastPathHelperMap->Add(funcInfoAddr, helper);
316317
}
317318

@@ -327,7 +328,7 @@ ServerScriptContext::DecommitEmitBufferManager(bool asmJsManager)
327328
GetEmitBufferManager(asmJsManager)->Decommit();
328329
}
329330

330-
OOPEmitBufferManager *
331+
OOPEmitBufferManagerWithLock *
331332
ServerScriptContext::GetEmitBufferManager(bool asmJsManager)
332333
{
333334
if (asmJsManager)
@@ -343,11 +344,11 @@ ServerScriptContext::GetEmitBufferManager(bool asmJsManager)
343344
IR::JnHelperMethod
344345
ServerScriptContext::GetDOMFastPathHelper(intptr_t funcInfoAddr)
345346
{
347+
AutoCriticalSection cs(&m_cs);
348+
346349
IR::JnHelperMethod helper = IR::HelperInvalid;
347350

348-
m_domFastPathHelperMap->LockResize();
349351
m_domFastPathHelperMap->TryGetValue(funcInfoAddr, &helper);
350-
m_domFastPathHelperMap->UnlockResize();
351352

352353
return helper;
353354
}
@@ -392,6 +393,7 @@ ServerScriptContext::GetCodeGenAllocators()
392393
Field(Js::Var)*
393394
ServerScriptContext::GetModuleExportSlotArrayAddress(uint moduleIndex, uint slotIndex)
394395
{
396+
AutoCriticalSection cs(&m_cs);
395397
AssertOrFailFast(m_moduleRecords.ContainsKey(moduleIndex));
396398
auto record = m_moduleRecords.Item(moduleIndex);
397399
return record->localExportSlotsAddr;
@@ -406,6 +408,7 @@ ServerScriptContext::SetIsPRNGSeeded(bool value)
406408
void
407409
ServerScriptContext::AddModuleRecordInfo(unsigned int moduleId, __int64 localExportSlotsAddr)
408410
{
411+
AutoCriticalSection cs(&m_cs);
409412
Js::ServerSourceTextModuleRecord* record = HeapNewStructZ(Js::ServerSourceTextModuleRecord);
410413
record->moduleId = moduleId;
411414
record->localExportSlotsAddr = (Field(Js::Var)*)localExportSlotsAddr;

lib/Backend/ServerScriptContext.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ServerScriptContext : public ScriptContextInfo
8080
void SetIsPRNGSeeded(bool value);
8181
void AddModuleRecordInfo(unsigned int moduleId, __int64 localExportSlotsAddr);
8282
void UpdateGlobalObjectThisAddr(intptr_t globalThis);
83-
OOPEmitBufferManager * GetEmitBufferManager(bool asmJsManager);
83+
OOPEmitBufferManagerWithLock * GetEmitBufferManager(bool asmJsManager);
8484
void DecommitEmitBufferManager(bool asmJsManager);
8585
#ifdef PROFILE_EXEC
8686
Js::ScriptContextProfiler* GetCodeGenProfiler(_In_ PageAllocator* pageAllocator);
@@ -100,10 +100,11 @@ class ServerScriptContext : public ScriptContextInfo
100100
Js::ScriptContextProfiler * codeGenProfiler;
101101
CriticalSection profilerCS;
102102
#endif
103+
CriticalSection m_cs;
103104
ArenaAllocator m_sourceCodeArena;
104105

105-
OOPEmitBufferManager m_interpreterThunkBufferManager;
106-
OOPEmitBufferManager m_asmJsInterpreterThunkBufferManager;
106+
OOPEmitBufferManagerWithLock m_interpreterThunkBufferManager;
107+
OOPEmitBufferManagerWithLock m_asmJsInterpreterThunkBufferManager;
107108

108109
ScriptContextDataIDL m_contextData;
109110
intptr_t m_globalThisAddr;

lib/JITIDL/ChakraJIT.acf

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55

6-
typedef [context_handle_noserialize] PTHREADCONTEXT_HANDLE;
7-
typedef [context_handle_noserialize] PSCRIPTCONTEXT_HANDLE;
8-
96
[
107
type_strict_context_handle
118
]
129
interface IChakraJIT
1310
{
11+
UpdatePropertyRecordMap([context_handle_noserialize] threadContextInfoAddress);
12+
AddDOMFastPathHelper([context_handle_noserialize] scriptContextInfoAddress);
13+
AddModuleRecordInfo([context_handle_noserialize] scriptContextInfoAddress);
14+
SetWellKnownHostTypeId([context_handle_noserialize] threadContextInfoAddress);
15+
CloseScriptContext([context_handle_noserialize] scriptContextInfoAddress);
16+
FreeAllocation([context_handle_noserialize] scriptContextInfoAddress);
17+
NewInterpreterThunkBlock([context_handle_noserialize] scriptContextInfoAddress);
18+
DecommitInterpreterBufferManager([context_handle_noserialize] scriptContextInfoAddress);
19+
IsNativeAddr([context_handle_noserialize] threadContextInfoAddress);
20+
SetIsPRNGSeeded([context_handle_noserialize] scriptContextInfoAddress);
21+
RemoteCodeGen([context_handle_noserialize] scriptContextInfoAddress);
22+
23+
#if DBG
24+
IsInterpreterThunkAddr([context_handle_noserialize] scriptContextInfoAddress);
25+
#endif
26+
1427
typedef [encode, decode] pCodeGenWorkItemIDL;
1528
}

lib/JITServer/JITServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ ServerNewInterpreterThunkBlock(
502502
ServerThreadContext * threadContext;
503503
} localAlloc(threadContext);
504504

505-
OOPEmitBufferManager * emitBufferManager = scriptContext->GetEmitBufferManager(thunkInput->asmJsThunk != FALSE);
505+
OOPEmitBufferManagerWithLock * emitBufferManager = scriptContext->GetEmitBufferManager(thunkInput->asmJsThunk != FALSE);
506506

507507
BYTE* runtimeAddress;
508508
EmitBufferAllocation<SectionAllocWrapper, PreReservedSectionAllocWrapper> * alloc = emitBufferManager->AllocateBuffer(InterpreterThunkEmitter::BlockSize, &runtimeAddress);
@@ -573,7 +573,7 @@ ServerIsInterpreterThunkAddr(
573573
*result = false;
574574
return RPC_S_INVALID_ARG;
575575
}
576-
OOPEmitBufferManager * manager = context->GetEmitBufferManager(asmjsThunk != FALSE);
576+
OOPEmitBufferManagerWithLock * manager = context->GetEmitBufferManager(asmjsThunk != FALSE);
577577
if (manager == nullptr)
578578
{
579579
*result = false;

0 commit comments

Comments
 (0)