-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
some changes for SharedArrayBuffer #2939
Conversation
leirocks
commented
May 8, 2017
- Due to spec change, SharedArrayBuffer is not transferrable, remove related code
- Hardening the allocation path for OOM case
- Fix a possible race issue in waiter list
default: | ||
} | ||
else | ||
{ | ||
AssertMsg(false, "We should explicitly have a case statement for each object which has detached state."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert to fatal error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can do AssertOrFailFastMsg(state->GetTypeId() != TypeIds_ArrayBuffer, "blah blah"); This will be lot cleaner.
In reply to: 115386419 [](ancestors = 115386419)
} | ||
uint SharedContents::Release() | ||
{ | ||
return InterlockedDecrement(&refCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert of failfast of refCount should be 0 to begin with?
Recycler* recycler = GetType()->GetLibrary()->GetRecycler(); | ||
recycler->ReportExternalMemoryFree(sharedContents->bufferLength); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this fails on Linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't look into the detail but I guess somehow in Linux the finalGC is not called in linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jianchun maybe I remember wrong but.. do you think this has anything to do with exit time cleanup we were dealing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't look into the detail but I guess somehow in Linux the finalGC is not called in linux.
If that's the case, shall we make it non _WIN32 only and add TODO investigate?
long ret = InterlockedDecrement(&refCount); | ||
if (ret < 0) | ||
{ | ||
Js::Throw::FatalInternalError(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can do AssertOrFailFastMsg (ret >= 0).
@@ -227,6 +227,7 @@ struct AllocatorInfo | |||
template <typename TAllocator> | |||
struct ForceNonLeafAllocator | |||
{ | |||
static const bool FakeZeroLengthArray = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see 5224e05
while Heap allocation zero length array, we allocated the track data, but we didn't delete the track data in DeleteArray, causes memory leak in chk build.
with changing DeleteArray to use the FakeZeroLengthArray, every allocator need to provide such definition.
class RecyclerLeafAllocator | ||
{ | ||
public: | ||
static const bool FakeZeroLengthArray = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
lib/Common/Memory/Allocator.h
Outdated
@@ -382,16 +384,19 @@ void DestructArray(size_t count, T* obj) | |||
template <typename TAllocator, typename T> | |||
void DeleteArray(typename AllocatorInfo<TAllocator, T>::AllocatorType * allocator, size_t count, T * obj) | |||
{ | |||
if (count == 0) | |||
if (count == 0 && TAllocator::FakeZeroLengthArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be AllocatorInfo<TAllocator, T>::AllocatorType::FakeZeroLengthArray instead?
But why do we care?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, could be, then I can remove the FakeZeroLengthArray on RecyclerLeafAllocator I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AllocatorInfo<TAllocator, T>::AllocatorType is just same as TAllocator...
we care because for Heap allocated zero length array, we still allocate memory for the tracking data. and for Heap allocator the tracking data is in front of the user address, need to call into the free function to clear the tracking data and reset the memory leaking status
7558222
to
a4e46c7
Compare
- Due to spec change, SharedArrayBuffer is not transferrable, remove related code - Hardening the allocation path for OOM case - Fix a possible race issue in waiter list - Enable by default
Merge pull request #2939 from leirocks:sab1 - Due to spec change, SharedArrayBuffer is not transferrable, remove related code - Hardening the allocation path for OOM case - Fix a possible race issue in waiter list - Turn on by default