Skip to content
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

Merged
merged 1 commit into from
May 17, 2017
Merged

Conversation

leirocks
Copy link
Contributor

@leirocks 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.");
Copy link
Contributor

Choose a reason for hiding this comment

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

convert to fatal error?

Copy link
Contributor

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);
Copy link
Contributor

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);
}

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator

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();
Copy link
Contributor

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).

@akroshg
Copy link
Contributor

akroshg commented May 10, 2017

:shipit:

@@ -227,6 +227,7 @@ struct AllocatorInfo
template <typename TAllocator>
struct ForceNonLeafAllocator
{
static const bool FakeZeroLengthArray = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

@@ -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)
Copy link
Contributor

@curtisman curtisman May 12, 2017

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

@leirocks leirocks force-pushed the sab1 branch 3 times, most recently from 7558222 to a4e46c7 Compare May 17, 2017 00:14
- 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
@chakrabot chakrabot merged commit f12ac93 into chakra-core:master May 17, 2017
chakrabot pushed a commit that referenced this pull request May 17, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants