Skip to content

Commit

Permalink
Expose an API for heap traversal.
Browse files Browse the repository at this point in the history
Expose the `MMTK::enumerate_object` method for implementing heap
traversal.  That allows the Ruby VM to enable ObjectSpace.each_object
and TracePoint.  The test case whitelist is also updated to not exclude
related test cases so that mmtk-core binding tests will use those test
cases.
  • Loading branch information
wks committed Aug 23, 2024
1 parent 2f453c7 commit 7bdb422
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2021"
# Metadata for the Ruby repository
[package.metadata.ci-repos.ruby]
repo = "mmtk/ruby" # This is used by actions/checkout, so the format is "owner/repo", not URL.
rev = "8c5bd19b7a73c5156c4e2b9ee25cbf89c66816b8"
rev = "fd77eb5b3bd85f1e1ae15a8cfd704e027b25b0a5"

[lib]
name = "mmtk_ruby"
Expand Down
12 changes: 12 additions & 0 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,15 @@ pub extern "C" fn mmtk_object_reference_write_post(
ignored_target,
)
}

/// Enumerate objects. This function will call `callback(object, data)` for each object. It has
/// undefined behavior if allocation or GC happens while this function is running.
#[no_mangle]
pub extern "C" fn mmtk_enumerate_objects(
callback: extern "C" fn(ObjectReference, *mut libc::c_void),
data: *mut libc::c_void,
) {
crate::mmtk().enumerate_objects(|object| {
callback(object, data);
})
}
8 changes: 4 additions & 4 deletions ruby-test-cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test/ruby/test_integer.rb
test/ruby/test_io_buffer.rb
test/ruby/test_io_m17n.rb
# test/ruby/test_io.rb XXXXX leaks?
# test/ruby/test_iseq.rb XXXXX failures
test/ruby/test_iseq.rb
test/ruby/test_iterator.rb
test/ruby/test_key_error.rb
test/ruby/test_keyword.rb
Expand All @@ -75,8 +75,8 @@ test/ruby/test_nomethod_error.rb
test/ruby/test_not.rb
test/ruby/test_numeric.rb
test/ruby/test_object.rb
# test/ruby/test_objectspace.rb XXXX failures
# test/ruby/test_optimization.rb XXXXX hard crash
test/ruby/test_objectspace.rb
test/ruby/test_optimization.rb
test/ruby/test_pack.rb
test/ruby/test_parse.rb
test/ruby/test_path.rb
Expand All @@ -98,7 +98,7 @@ test/ruby/test_require.rb
# test/ruby/test_rubyoptions.rb XXXX failures and crashes
# test/ruby/test_rubyvm_mjit.rb XXXXX query
test/ruby/test_rubyvm.rb
# test/ruby/test_settracefunc.rb XXXX failures
test/ruby/test_settracefunc.rb
test/ruby/test_signal.rb
test/ruby/test_sleep.rb
test/ruby/test_sprintf_comb.rb
Expand Down

0 comments on commit 7bdb422

Please sign in to comment.