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
58 changes: 33 additions & 25 deletions gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,39 @@
# You may obtain information about the operation of the \GC through GC::Profiler.
module GC

# Initiates garbage collection, even if manually disabled.
#
# The +full_mark+ keyword argument determines whether or not to perform a
# major garbage collection cycle. When set to +true+, a major garbage
# collection cycle is run, meaning all objects are marked. When set to
# +false+, a minor garbage collection cycle is run, meaning only young
# objects are marked.
#
# The +immediate_mark+ keyword argument determines whether or not to perform
# incremental marking. When set to +true+, marking is completed during the
# call to this method. When set to +false+, marking is performed in steps
# that are interleaved with future Ruby code execution, so marking might not
# be completed during this method call. Note that if +full_mark+ is +false+,
# then marking will always be immediate, regardless of the value of
# +immediate_mark+.
#
# The +immediate_sweep+ keyword argument determines whether or not to defer
# sweeping (using lazy sweep). When set to +false+, sweeping is performed in
# steps that are interleaved with future Ruby code execution, so sweeping might
# not be completed during this method call. When set to +true+, sweeping is
# completed during the call to this method.
#
# Note: These keyword arguments are implementation and version-dependent. They
# are not guaranteed to be future-compatible and may be ignored if the
# underlying implementation does not support them.
# Initiates garbage collection, even if explicitly disabled by GC.disable.
#
# Keyword arguments:
#
# - +full_mark+:
# its boolean value determines whether to perform a major garbage collection cycle:
#
# - +true+: initiates a major garbage collection cycle,
# meaning all objects (old and new) are marked.
# - +false+: initiates a minor garbage collection cycle,
# meaning only young objects are marked.
#
# - +immediate_mark+:
# its boolean value determines whether to perform incremental marking:
#
# - +true+: marking is completed before the method returns.
# - +false+: marking is performed by parts,
# interleaved with program execution both before the method returns and afterward;
# therefore marking may not be completed before the return.
# Note that if +full_mark+ is +false+, marking will always be immediate,
# regardless of the value of +immediate_mark+.
#
# - +immediate_sweep+:
# its boolean value determines whether to defer sweeping (using lazy sweep):
#
# - +true+: sweeping is completed before the method returns.
# - +false+: sweeping is performed by parts,
# interleaved with program execution both before the method returns and afterward;
# therefore sweeping may not be completed before the return.
#
# Note that these keword arguments are implementation- and version-dependent,
# are not guaranteed to be future-compatible,
# and may be ignored in some implementations.
def self.start full_mark: true, immediate_mark: true, immediate_sweep: true
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
Expand Down
3 changes: 0 additions & 3 deletions lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ module Gem
VERSION = "3.8.0.dev"
end

# Must be first since it unloads the prelude from 1.9.2
require_relative "rubygems/compatibility"

require_relative "rubygems/defaults"
require_relative "rubygems/deprecate"
require_relative "rubygems/errors"
Expand Down
3 changes: 3 additions & 0 deletions lib/rubygems/basic_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def datadir
File.expand_path(File.join(gems_dir, full_name, "data", name))
end

extend Gem::Deprecate
rubygems_deprecate :datadir, :none, "4.1"

##
# Full path of the target library file.
# If the file is not in this gem, return nil.
Expand Down
41 changes: 0 additions & 41 deletions lib/rubygems/compatibility.rb

This file was deleted.

8 changes: 5 additions & 3 deletions lib/rubygems/deprecate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,18 @@ def deprecate(name, repl, year, month)
# telling the user of +repl+ (unless +repl+ is :none) and the
# Rubygems version that it is planned to go away.

def rubygems_deprecate(name, replacement=:none)
def rubygems_deprecate(name, replacement=:none, version=nil)
class_eval do
old = "_deprecated_#{name}"
alias_method old, name
define_method name do |*args, &block|
klass = is_a? Module
target = klass ? "#{self}." : "#{self.class}#"
version ||= Gem::Deprecate.next_rubygems_major_version
msg = [
"NOTE: #{target}#{name} is deprecated",
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
". It will be removed in Rubygems #{Gem::Deprecate.next_rubygems_major_version}",
". It will be removed in Rubygems #{version}",
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
]
warn "#{msg.join}." unless Gem::Deprecate.skip
Expand All @@ -147,13 +148,14 @@ def rubygems_deprecate(name, replacement=:none)
end

# Deprecation method to deprecate Rubygems commands
def rubygems_deprecate_command(version = Gem::Deprecate.next_rubygems_major_version)
def rubygems_deprecate_command(version = nil)
class_eval do
define_method "deprecated?" do
true
end

define_method "deprecation_warning" do
version ||= Gem::Deprecate.next_rubygems_major_version
msg = [
"#{command} command is deprecated",
". It will be removed in Rubygems #{version}.\n",
Expand Down
7 changes: 0 additions & 7 deletions test/rubygems/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
require "shellwords"

class TestGemConfig < Gem::TestCase
def test_datadir
util_make_gems
spec = Gem::Specification.find_by_name("a")
spec.activate
assert_equal "#{spec.full_gem_path}/data/a", spec.datadir
end

def test_good_rake_path_is_escaped
path = Gem::TestCase.class_variable_get(:@@good_rake)
ruby, rake = path.shellsplit
Expand Down
29 changes: 0 additions & 29 deletions test/rubygems/test_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -527,35 +527,6 @@ def test_self_configuration
assert_equal expected, Gem.configuration
end

def test_self_datadir
foo = nil

Dir.chdir @tempdir do
FileUtils.mkdir_p "data"
File.open File.join("data", "foo.txt"), "w" do |fp|
fp.puts "blah"
end

foo = util_spec "foo" do |s|
s.files = %w[data/foo.txt]
end

install_gem foo
end

gem "foo"

expected = File.join @gemhome, "gems", foo.full_name, "data", "foo"

assert_equal expected, Gem::Specification.find_by_name("foo").datadir
end

def test_self_datadir_nonexistent_package
assert_raise(Gem::MissingSpecError) do
Gem::Specification.find_by_name("xyzzy").datadir
end
end

def test_self_default_exec_format
ruby_install_name "ruby" do
assert_equal "%s", Gem.default_exec_format
Expand Down
11 changes: 11 additions & 0 deletions zjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,17 @@ rb_zjit_shape_obj_too_complex_p(VALUE obj)
return rb_shape_obj_too_complex_p(obj);
}

enum {
RB_SPECIAL_CONST_SHAPE_ID = SPECIAL_CONST_SHAPE_ID,
RB_INVALID_SHAPE_ID = INVALID_SHAPE_ID,
};

bool
rb_zjit_singleton_class_p(VALUE klass)
{
return RCLASS_SINGLETON_P(klass);
}

// Primitives used by zjit.rb. Don't put other functions below, which wouldn't use them.
VALUE rb_zjit_assert_compiles(rb_execution_context_t *ec, VALUE self);
VALUE rb_zjit_stats(rb_execution_context_t *ec, VALUE self);
Expand Down
3 changes: 3 additions & 0 deletions zjit/bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,11 @@ fn main() {
.allowlist_function("rb_optimized_call")
.allowlist_function("rb_zjit_icache_invalidate")
.allowlist_function("rb_zjit_print_exception")
.allowlist_function("rb_zjit_singleton_class_p")
.allowlist_type("robject_offsets")
.allowlist_type("rstring_offsets")
.allowlist_var("RB_SPECIAL_CONST_SHAPE_ID")
.allowlist_var("RB_INVALID_SHAPE_ID")

// From jit.c
.allowlist_function("rb_assert_holding_vm_lock")
Expand Down
10 changes: 8 additions & 2 deletions zjit/src/cruby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ pub struct ID(pub ::std::os::raw::c_ulong);
/// Pointer to an ISEQ
pub type IseqPtr = *const rb_iseq_t;

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct ShapeId(pub u32);

pub const SPECIAL_CONST_SHAPE_ID: ShapeId = ShapeId(RB_SPECIAL_CONST_SHAPE_ID);
pub const INVALID_SHAPE_ID: ShapeId = ShapeId(RB_INVALID_SHAPE_ID);

// Given an ISEQ pointer, convert PC to insn_idx
pub fn iseq_pc_to_insn_idx(iseq: IseqPtr, pc: *mut VALUE) -> Option<u16> {
let pc_zero = unsafe { rb_iseq_pc_at_idx(iseq, 0) };
Expand Down Expand Up @@ -487,8 +493,8 @@ impl VALUE {
unsafe { rb_zjit_shape_obj_too_complex_p(self) }
}

pub fn shape_id_of(self) -> u32 {
unsafe { rb_obj_shape_id(self) }
pub fn shape_id_of(self) -> ShapeId {
ShapeId(unsafe { rb_obj_shape_id(self) })
}

pub fn embedded_p(self) -> bool {
Expand Down
4 changes: 4 additions & 0 deletions zjit/src/cruby_bindings.inc.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading