Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/Backend/NativeCodeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ NativeCodeData::Allocator::Alloc(size_t requestSize)
return data;
}

char *
NativeCodeData::Allocator::AllocLeaf(size_t requestSize)
{
return Alloc(requestSize);
}

char *
NativeCodeData::Allocator::AllocZero(size_t requestSize)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Backend/NativeCodeData.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class NativeCodeData

char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes);
char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes);
char * AllocLeaf(__declspec(guard(overflow)) size_t requestedBytes);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digitalinfinity Strange, why CI did not complain on this? Should use DECLSPEC_GUARD_OVERFLOW

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp- I don't know? @dilijev any ideas? @jainchun, i'll make the change- sorry, had ported the change from Threshold and didn't notice the macro conversion 😞

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JIT is still disabled on Linux so this whole block is probably compiled out on Linux


NativeCodeData * Finalize();
void Free(void * buffer, size_t byteSize);

Expand Down
4 changes: 2 additions & 2 deletions lib/Common/DataStructures/FixedBitVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ template <typename TAllocator>
BVFixed * BVFixed::New(TAllocator * alloc, BVFixed * initBv)
{
BVIndex length = initBv->Length();
BVFixed *result = AllocatorNewPlus(TAllocator, alloc, sizeof(BVUnit) * BVFixed::WordCount(length), BVFixed, initBv);
BVFixed *result = AllocatorNewPlusLeaf(TAllocator, alloc, sizeof(BVUnit) * BVFixed::WordCount(length), BVFixed, initBv);
return result;
}

template <typename TAllocator>
BVFixed * BVFixed::New(DECLSPEC_GUARD_OVERFLOW BVIndex length, TAllocator * alloc, bool initialSet)
{
BVFixed *result = AllocatorNewPlus(TAllocator, alloc, sizeof(BVUnit) * BVFixed::WordCount(length), BVFixed, length, initialSet);
BVFixed *result = AllocatorNewPlusLeaf(TAllocator, alloc, sizeof(BVUnit) * BVFixed::WordCount(length), BVFixed, length, initialSet);
return result;
}

Expand Down
25 changes: 25 additions & 0 deletions lib/Runtime/Base/TempArenaAllocatorObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,31 @@ namespace Js
Assert(allocator.AllocatedSize() == 0);
}

template <bool isGuestArena>
void TempArenaAllocatorWrapper<isGuestArena>::AdviseInUse()
{
if (isGuestArena)
{
if (externalGuestArenaRef == nullptr)
Copy link
Contributor

@curtisman curtisman Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we assert that externalGuestArenaRef != nullptr in

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we assert that externalGuestArenaRef != nullptr in AdviseNotInUse, should this be an assert externalGuestArenaRef == nullptr too?

{
externalGuestArenaRef = this->recycler->RegisterExternalGuestArena(this->GetAllocator());
}
}
}

template <bool isGuestArena>
void TempArenaAllocatorWrapper<isGuestArena>::AdviseNotInUse()
{
this->allocator.Reset();

if (isGuestArena)
{
Assert(externalGuestArenaRef != nullptr);
this->recycler->UnregisterExternalGuestArena(externalGuestArenaRef);
externalGuestArenaRef = nullptr;
}
}

// Explicit instantiation
template class TempArenaAllocatorWrapper<true>;
template class TempArenaAllocatorWrapper<false>;
Expand Down
2 changes: 2 additions & 0 deletions lib/Runtime/Base/TempArenaAllocatorObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Js

public:

void AdviseInUse();
void AdviseNotInUse();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were the implementations of these already present?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No? Newly added

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp; I didn't see them above


static TempArenaAllocatorWrapper* Create(ThreadContext * threadContext);

Expand Down
3 changes: 2 additions & 1 deletion lib/Runtime/Base/ThreadContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,7 @@ ThreadContext::GetTemporaryGuestAllocator(LPCWSTR name)
{
temporaryGuestArenaAllocatorCount--;
Js::TempGuestArenaAllocatorObject * allocator = recyclableData->temporaryGuestArenaAllocators[temporaryGuestArenaAllocatorCount];
allocator->AdviseInUse();
recyclableData->temporaryGuestArenaAllocators[temporaryGuestArenaAllocatorCount] = nullptr;
return allocator;
}
Expand All @@ -2154,7 +2155,7 @@ ThreadContext::ReleaseTemporaryGuestAllocator(Js::TempGuestArenaAllocatorObject
{
if (temporaryGuestArenaAllocatorCount < MaxTemporaryArenaAllocators)
{
tempGuestAllocator->GetAllocator()->Reset();
tempGuestAllocator->AdviseNotInUse();
recyclableData->temporaryGuestArenaAllocators[temporaryGuestArenaAllocatorCount] = tempGuestAllocator;
temporaryGuestArenaAllocatorCount++;
return;
Expand Down