Skip to content

Manual malloc space #572

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

Closed
wants to merge 6 commits into from
Closed

Conversation

qinsoon
Copy link
Member

@qinsoon qinsoon commented Apr 19, 2022

No description provided.

@qinsoon qinsoon added the PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead) label Apr 19, 2022
@qinsoon
Copy link
Member Author

qinsoon commented May 13, 2022

I will redo this pull request. There will be some changes to this draft PR:

  • We will provide malloc/free API, rather than using alloc(..., AllocationSemantic::MALLOC).
  • The malloc API should have the same signature as the library malloc().
  • A binding could call malloc in a non-application thread (which does not have a thread local Mutator).
  • We could forward the malloc call to a third party library, or use our mimalloc implementation. For mimalloc, we need to maintain some thread-local metadata for mimalloc and that is not a part of Mutator.
  • If we forward the malloc call to third party malloc, we should store no metadata for it. We should not have any extra overhead.
  • For our APIs such as is_in_mmtk_spaces(), we may return different results depending on our malloc implementation. For example, when we use thirdparty malloc, the returned address is not in our space. When we use our native malloc, the address is in our space.
  • The malloc API has nothing to do with the (malloc) mark sweep -- no reuse code or anything.
  • We could provide options on 1. whether the malloc'd memory is counted in our heap size, 2. whether we may trigger a GC in malloc (I am not sure if this is a good idea -- we could just count the malloc'd size, and GC in the next normal allocation).

@qinsoon qinsoon closed this May 13, 2022
@qinsoon qinsoon mentioned this pull request Jun 7, 2022
qinsoon added a commit that referenced this pull request Jun 25, 2022
This PR adds a set of malloc related API, and another set of malloc API that will count allocation size into MMTk heap under the feature `malloc_counted_size`. This PR adds things described in #572 (comment).

The changes in this PR:
* tidy up the malloc library import
* provide a set of standard malloc functions (`malloc`, `calloc`, `realloc` and `free`)
* provide a set of malloc functions that will count the malloc size into MMTk heap under the feature `malloc_counted_size`
* provide `gc_poll()` that can be used to check GC when a binding uses counted malloc functions. Small refactoring to allow `poll()` without a space reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant