Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ d4e24021d39e1f80f0055b55d91f8d5f22e15084
e90282be7ba1bc8e3119f6e1a2c80356ceb3f80a
26a9e0b4e31f7b5a9cbd755e0a15823a8fa51bae
2f53985da9ee593fe524d408256835667938c7d7

# Win32: EOL code of batch files
23f9a0d655c4d405bb2397a147a1523436205486
b839989fd22fef85e2af19de1bc83aa72a5b22bd
31 changes: 20 additions & 11 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1278,15 +1278,6 @@ rb_gc_obj_needs_cleanup_p(VALUE obj)
}

case T_DATA:
if (flags & RUBY_TYPED_FL_IS_TYPED_DATA) {
uintptr_t type = (uintptr_t)RTYPEDDATA(obj)->type;
if (type & TYPED_DATA_EMBEDDED) {
RUBY_DATA_FUNC dfree = ((const rb_data_type_t *)(type & TYPED_DATA_PTR_MASK))->function.dfree;
return (dfree == RUBY_NEVER_FREE || dfree == RUBY_TYPED_DEFAULT_FREE);
}
}
return true;

case T_OBJECT:
case T_STRING:
case T_ARRAY:
Expand All @@ -1298,7 +1289,13 @@ rb_gc_obj_needs_cleanup_p(VALUE obj)
case T_COMPLEX:
break;

default:
case T_FILE:
case T_SYMBOL:
case T_CLASS:
case T_ICLASS:
case T_MODULE:
case T_REGEXP:
case T_MATCH:
return true;
}

Expand All @@ -1310,6 +1307,18 @@ rb_gc_obj_needs_cleanup_p(VALUE obj)
if (flags & ROBJECT_HEAP) return true;
return false;

case T_DATA:
if (flags & RUBY_TYPED_FL_IS_TYPED_DATA) {
uintptr_t type = (uintptr_t)RTYPEDDATA(obj)->type;
if (type & TYPED_DATA_EMBEDDED) {
RUBY_DATA_FUNC dfree = ((const rb_data_type_t *)(type & TYPED_DATA_PTR_MASK))->function.dfree;
if (dfree == RUBY_NEVER_FREE || dfree == RUBY_TYPED_DEFAULT_FREE) {
return false;
}
}
}
return true;

case T_STRING:
if (flags & (RSTRING_NOEMBED | RSTRING_FSTR)) return true;
return rb_shape_has_fields(shape_id);
Expand All @@ -1324,7 +1333,7 @@ rb_gc_obj_needs_cleanup_p(VALUE obj)

case T_BIGNUM:
if (!(flags & BIGNUM_EMBED_FLAG)) return true;
return false;
return rb_shape_has_fields(shape_id);

case T_STRUCT:
if (!(flags & RSTRUCT_EMBED_LEN_MASK)) return true;
Expand Down
11 changes: 0 additions & 11 deletions lib/prism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module Prism
autoload :DSL, "prism/dsl"
autoload :InspectVisitor, "prism/inspect_visitor"
autoload :LexCompat, "prism/lex_compat"
autoload :LexRipper, "prism/lex_ripper"
autoload :MutationCompiler, "prism/mutation_compiler"
autoload :Pack, "prism/pack"
autoload :Pattern, "prism/pattern"
Expand All @@ -35,7 +34,6 @@ module Prism
# private here.

private_constant :LexCompat
private_constant :LexRipper

# Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
class CurrentVersionError < ArgumentError
Expand Down Expand Up @@ -68,15 +66,6 @@ def self.lex_compat(source, **options)
LexCompat.new(source, **options).result # steep:ignore
end

# :call-seq:
# Prism::lex_ripper(source) -> Array
#
# This wraps the result of Ripper.lex. It produces almost exactly the
# same tokens. Raises SyntaxError if the syntax in source is invalid.
def self.lex_ripper(source)
LexRipper.new(source).result # steep:ignore
end

# :call-seq:
# Prism::load(source, serialized, freeze) -> ParseResult
#
Expand Down
55 changes: 0 additions & 55 deletions lib/prism/lex_ripper.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/prism/prism.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ Gem::Specification.new do |spec|
"lib/prism/ffi.rb",
"lib/prism/inspect_visitor.rb",
"lib/prism/lex_compat.rb",
"lib/prism/lex_ripper.rb",
"lib/prism/mutation_compiler.rb",
"lib/prism/node_ext.rb",
"lib/prism/node.rb",
Expand Down
3 changes: 2 additions & 1 deletion test/prism/bom_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
return if RUBY_ENGINE != "ruby"

require_relative "test_helper"
require "ripper"

module Prism
class BOMTest < TestCase
Expand Down Expand Up @@ -53,7 +54,7 @@ def test_string

def assert_bom(source)
bommed = "\xEF\xBB\xBF#{source}"
assert_equal Prism.lex_ripper(bommed), Prism.lex_compat(bommed).value
assert_equal Ripper.lex(bommed), Prism.lex_compat(bommed).value
end
end
end
3 changes: 2 additions & 1 deletion test/prism/lex_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return if !(RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.2.0")

require_relative "test_helper"
require "ripper"

module Prism
class LexTest < TestCase
Expand Down Expand Up @@ -49,7 +50,7 @@ def test_parse_lex_file
if RUBY_VERSION >= "3.3"
def test_lex_compare
prism = Prism.lex_compat(File.read(__FILE__), version: "current").value
ripper = Prism.lex_ripper(File.read(__FILE__))
ripper = Ripper.lex(File.read(__FILE__))
assert_equal(ripper, prism)
end
end
Expand Down
12 changes: 7 additions & 5 deletions test/ruby/test_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1667,22 +1667,24 @@ def test_mn_threads_sub_millisecond_sleep

# [Bug #21840]
def test_mutex_owner_doesnt_starve_waiters
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
require "tempfile"
temp = Tempfile.new("temp")
m = Mutex.new

fib = lambda { |n|
def fib(n)
return n if n <= 1
fib(n - 1) + fib(n - 2)
}
end

t1_running = false
t1 = Thread.new do
Thread.new do
t1_running = true
loop do
fib(20)
m.synchronize do
File.open(__FILE__) { } # reset timeslice due to blocking operation
File.open(temp.path) { } # reset timeslice due to blocking operation
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion thread_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th, rb_serial_t ec_serial)
struct sync_waiter *cur = 0, *next;


if (mutex->wait_waking) {
if (mutex->wait_waking && ec_serial) {
uint32_t saved = mutex->saved_running_time_us;
if (th->running_time_us < saved) {
th->running_time_us = saved;
Expand Down