diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2022-06-29 15:21:11 +0200 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2022-07-04 20:04:59 +0200 |
commit | 890df5f81271e031ae86775b8b8b8e4e4d4640d8 (patch) | |
tree | 3e33ab2b8fafbf05e5117973140e4557770b552e /test | |
parent | b92fb7869624cb58475516361505f65f4f8a24d0 (diff) | |
download | ruby-890df5f81271e031ae86775b8b8b8e4e4d4640d8.tar.gz |
ObjectSpace.dump: Include string coderange
I suspect that some shared pages are invalidated because
some static string don't have their coderange set eagerly.
So the first time they are scanned, the entire memory page is
invalidated.
Being able to see the coderange in `ObjectSpace` would help debug
this.
And in addition `dump` currently call `is_broken_string()` and `is_ascii_string()`
which both end up scanning the string and assigning coderange. I think it's
undesirable as `dump` should be read only.
Diffstat (limited to 'test')
-rw-r--r-- | test/objspace/test_objspace.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index ed9c998597..1392447e4f 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -486,6 +486,16 @@ class TestObjSpace < Test::Unit::TestCase end end + def test_dump_string_coderange + assert_includes ObjectSpace.dump("TEST STRING"), '"coderange":"7bit"' + unknown = "TEST STRING".dup.force_encoding(Encoding::BINARY) + 2.times do # ensure that dumping the string doesn't mutate it + assert_includes ObjectSpace.dump(unknown), '"coderange":"unknown"' + end + assert_includes ObjectSpace.dump("Fée"), '"coderange":"valid"' + assert_includes ObjectSpace.dump("\xFF"), '"coderange":"broken"' + end + def test_dump_escapes_method_name method_name = "foo\"bar" klass = Class.new do |