Skip to content

Commit 589e743

Browse files
author
Jianchun Xu
committed
swb: fix build failures on Windows
1 parent d7f2c06 commit 589e743

File tree

9 files changed

+43
-29
lines changed

9 files changed

+43
-29
lines changed

lib/Backend/CodeGenNumberAllocator.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class CodeGenNumberThreadAllocator
100100
bool hasNewChunkBlock;
101101
struct BlockRecord
102102
{
103-
BlockRecord(__in_ecount_pagesize char * blockAddress, PageSegment * segment)
104-
: blockAddress(blockAddress), segment(segment)
103+
BlockRecord(__in_ecount_pagesize char * blockAddress, PageSegment * segment)
104+
: blockAddress(blockAddress), segment(segment)
105105
{
106106
}
107107
char * blockAddress;
@@ -114,19 +114,19 @@ class CodeGenNumberThreadAllocator
114114
size_t pendingIntegrationChunkSegmentPageCount;
115115
DListBase<PageSegment> pendingIntegrationNumberSegment;
116116
DListBase<PageSegment> pendingIntegrationChunkSegment;
117-
SListBase<BlockRecord> pendingIntegrationNumberBlock;
118-
SListBase<BlockRecord> pendingIntegrationChunkBlock;
117+
SListBase<BlockRecord, NoThrowHeapAllocator> pendingIntegrationNumberBlock;
118+
SListBase<BlockRecord, NoThrowHeapAllocator> pendingIntegrationChunkBlock;
119119

120120
// These are finished pages during the code gen of the current function
121121
// We can't integrate them until the code gen is done for the function,
122122
// because the references for the number is not set on the entry point yet.
123-
SListBase<BlockRecord> pendingFlushNumberBlock;
124-
SListBase<BlockRecord> pendingFlushChunkBlock;
123+
SListBase<BlockRecord, NoThrowHeapAllocator> pendingFlushNumberBlock;
124+
SListBase<BlockRecord, NoThrowHeapAllocator> pendingFlushChunkBlock;
125125

126126
// Numbers are reference by the chunks, so we need to wait until that is ready
127127
// to be flushed before the number page can be flushed. Otherwise, we might have number
128128
// integrated back to the GC, but the chunk hasn't yet, thus GC won't see the reference.
129-
SListBase<BlockRecord> pendingReferenceNumberBlock;
129+
SListBase<BlockRecord, NoThrowHeapAllocator> pendingReferenceNumberBlock;
130130
};
131131

132132
class CodeGenNumberAllocator

lib/Backend/PageAllocatorPool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ PageAllocator* PageAllocatorPool::GetPageAllocator()
8686
void PageAllocatorPool::ReturnPageAllocator(PageAllocator* pageAllocator)
8787
{
8888
AutoCriticalSection autoCS(&cs);
89-
if (!this->pageAllocators.PrependNoThrow(&HeapAllocator::Instance, pageAllocator))
89+
if (!this->pageAllocators.PrependNoThrow(&NoThrowHeapAllocator::Instance, pageAllocator))
9090
{
9191
HeapDelete(pageAllocator);
9292
}

lib/Common/Memory/HeapAllocator.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,21 @@ class NoThrowHeapAllocator
182182
{
183183
public:
184184
static const bool FakeZeroLengthArray = false;
185+
185186
char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t byteSize);
186187
char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t byteSize);
187188
void Free(void * buffer, size_t byteSize);
189+
190+
char * NoThrowAlloc(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
191+
{
192+
return Alloc(byteSize);
193+
}
194+
195+
char * NoThrowAllocZero(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
196+
{
197+
return AllocZero(byteSize);
198+
}
199+
188200
static NoThrowHeapAllocator Instance;
189201

190202
#ifdef TRACK_ALLOC

lib/Common/Memory/PageAllocator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ SegmentBase<T>::~SegmentBase()
6262
{
6363
RecyclerWriteBarrierManager::ToggleBarrier(this->address, this->segmentPageCount * AutoSystemInfo::PageSize, false);
6464
}
65-
#endif
6665
#endif
6766
RecyclerWriteBarrierManager::OnSegmentFree(this->address, this->segmentPageCount);
67+
#endif
6868
}
6969
}
7070

@@ -343,7 +343,7 @@ PageSegmentBase<T>::AllocPages(uint pageCount)
343343
MemoryOperationLastError::RecordLastError();
344344
if (this->GetAllocator()->processHandle == GetCurrentProcess())
345345
{
346-
Assert(false);
346+
Assert(false);
347347
}
348348
return nullptr;
349349
}

lib/Common/Memory/RecyclerWriteBarrierManager.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#ifdef RECYCLER_WRITE_BARRIER
2323
#if ENABLE_DEBUG_CONFIG_OPTIONS
24-
namespace Memory
24+
namespace Memory
2525
{
2626
FN_VerifyIsNotBarrierAddress* g_verifyIsNotBarrierAddress = nullptr;
2727
}
@@ -377,11 +377,11 @@ RecyclerWriteBarrierManager::IsBarrierAddress(void * address)
377377
bool
378378
RecyclerWriteBarrierManager::IsBarrierAddress(uintptr_t index)
379379
{
380-
return cardTable[index] & WRITE_BARRIER_PAGE_BIT;
380+
return (cardTable[index] & WRITE_BARRIER_PAGE_BIT) == WRITE_BARRIER_PAGE_BIT;
381381
}
382382

383-
// TODO: SWB, looks we didn't initialize card table for heap allocation.
384-
// we didn't hit such issue because we are not allocating write barrier
383+
// TODO: SWB, looks we didn't initialize card table for heap allocation.
384+
// we didn't hit such issue because we are not allocating write barrier
385385
// annotated struct with heap today.
386386
// after SWB is widely enabled and if an annotated structure can be allocated
387387
// with both Heap and Recycler/Arena we'll capture the issue
@@ -406,10 +406,10 @@ RecyclerWriteBarrierManager::VerifyIsBarrierAddress(void * address, size_t bytes
406406
uintptr_t startIndex = GetCardTableIndex(address);
407407
char * endAddress = (char *)Math::Align<INT_PTR>((INT_PTR)((char *)address + bytes), s_WriteBarrierPageSize);
408408
uintptr_t endIndex = GetCardTableIndex(endAddress);
409-
do
409+
do
410410
{
411411
// no need to check if cardTable is commited or not, if it's not commited it'll AV instead of assertion
412-
if (!IsBarrierAddress(startIndex))
412+
if (!IsBarrierAddress(startIndex))
413413
{
414414
Js::Throw::FatalInternalError();
415415
}
@@ -425,11 +425,11 @@ RecyclerWriteBarrierManager::VerifyIsNotBarrierAddress(void * address, size_t by
425425
uintptr_t startIndex = GetCardTableIndex(address);
426426
char * endAddress = (char *)Math::Align<INT_PTR>((INT_PTR)((char *)address + bytes), s_WriteBarrierPageSize);
427427
uintptr_t endIndex = GetCardTableIndex(endAddress);
428-
do
428+
do
429429
{
430430
if(IsCardTableCommited(startIndex))
431431
{
432-
if (IsBarrierAddress(startIndex))
432+
if (IsBarrierAddress(startIndex))
433433
{
434434
Js::Throw::FatalInternalError();
435435
}
@@ -439,13 +439,13 @@ RecyclerWriteBarrierManager::VerifyIsNotBarrierAddress(void * address, size_t by
439439
}
440440
}
441441

442-
bool
442+
bool
443443
RecyclerWriteBarrierManager::Initialize()
444444
{
445445
g_verifyIsNotBarrierAddress = RecyclerWriteBarrierManager::VerifyIsNotBarrierAddress;
446446
return true;
447447
}
448-
#endif
448+
#endif
449449

450450
uintptr_t
451451
RecyclerWriteBarrierManager::GetCardTableIndex(void *address)

lib/JITServer/JITServer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ServerContextManager
1212
static void CleanUpForProcess(HANDLE hProcess);
1313

1414
static void RegisterScriptContext(ServerScriptContext* scriptContext);
15-
static void UnRegisterScriptContext(ServerScriptContext* scriptContext);
15+
static void UnRegisterScriptContext(ServerScriptContext* scriptContext);
1616

1717
static bool CheckLivenessAndAddref(ServerScriptContext* context);
1818
static bool CheckLivenessAndAddref(ServerThreadContext* context);
@@ -44,19 +44,19 @@ class ServerContextManager
4444
T* context;
4545
union {
4646
DWORD runtimeProcId;
47-
ServerThreadContext* threadCtx;
47+
ServerThreadContext* threadCtx;
4848
};
4949
StackBackTrace* stack;
5050
};
5151

5252
static void RecordCloseContext(ServerThreadContext* context)
5353
{
5454
auto record = HeapNewNoThrow(ClosedContextEntry<ServerThreadContext>, context);
55-
if (record)
55+
if (record)
5656
{
5757
record->runtimeProcId = context->GetRuntimePid();
5858
}
59-
ClosedThreadContextList.PrependNoThrow(&HeapAllocator::Instance, record);
59+
ClosedThreadContextList.PrependNoThrow(&NoThrowHeapAllocator::Instance, record);
6060
}
6161
static void RecordCloseContext(ServerScriptContext* context)
6262
{
@@ -65,7 +65,7 @@ class ServerContextManager
6565
{
6666
record->threadCtx = context->GetThreadContext();
6767
}
68-
ClosedScriptContextList.PrependNoThrow(&HeapAllocator::Instance, record);
68+
ClosedScriptContextList.PrependNoThrow(&NoThrowHeapAllocator::Instance, record);
6969
}
7070

7171
static SList<ClosedContextEntry<ServerThreadContext>*, NoThrowHeapAllocator> ClosedThreadContextList;

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4130,7 +4130,7 @@ void ThreadContext::RemoveExternalWeakReferenceCache(ExternalWeakReferenceCache
41304130

41314131
void ThreadContext::MarkExternalWeakReferencedObjects(bool inPartialCollect)
41324132
{
4133-
SListBase<ExternalWeakReferenceCache *>::Iterator iteratorWeakRefCache(&this->externalWeakReferenceCacheList);
4133+
SListBase<ExternalWeakReferenceCache *, HeapAllocator>::Iterator iteratorWeakRefCache(&this->externalWeakReferenceCacheList);
41344134
while (iteratorWeakRefCache.Next())
41354135
{
41364136
iteratorWeakRefCache.Data()->MarkNow(recycler, inPartialCollect);
@@ -4139,7 +4139,7 @@ void ThreadContext::MarkExternalWeakReferencedObjects(bool inPartialCollect)
41394139

41404140
void ThreadContext::ResolveExternalWeakReferencedObjects()
41414141
{
4142-
SListBase<ExternalWeakReferenceCache *>::Iterator iteratorWeakRefCache(&this->externalWeakReferenceCacheList);
4142+
SListBase<ExternalWeakReferenceCache *, HeapAllocator>::Iterator iteratorWeakRefCache(&this->externalWeakReferenceCacheList);
41434143
while (iteratorWeakRefCache.Next())
41444144
{
41454145
iteratorWeakRefCache.Data()->ResolveNow(recycler);

lib/Runtime/Base/ThreadContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ class ThreadContext sealed :
654654
uint32 polymorphicCacheState;
655655

656656
#ifdef ENABLE_PROJECTION
657-
SListBase<ExternalWeakReferenceCache *> externalWeakReferenceCacheList;
657+
SListBase<ExternalWeakReferenceCache *, HeapAllocator> externalWeakReferenceCacheList;
658658
#if DBG_DUMP
659659
IProjectionContextMemoryInfo *projectionMemoryInformation;
660660
#endif

lib/Runtime/Library/ForInObjectEnumerator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ namespace Js
1313
struct ShadowData
1414
{
1515
ShadowData(RecyclableObject * initObject, RecyclableObject * firstPrototype, Recycler * recycler);
16+
1617
Field(RecyclableObject *) currentObject;
1718
Field(RecyclableObject *) firstPrototype;
1819
Field(BVSparse<Recycler>) propertyIds;
19-
Field(SListBase<Js::PropertyRecord const *, Recycler>) newPropertyStrings;
20+
typedef SListBase<Js::PropertyRecord const *, Recycler> _PropertyStringsListType;
21+
Field(_PropertyStringsListType) newPropertyStrings;
2022
} *shadowData;
2123

2224
// States

0 commit comments

Comments
 (0)