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
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
iwr -useb get.scoop.sh | iex
Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH
scoop install vcpkg uutils-coreutils cmake@3.31.6
scoop install vcpkg uutils-coreutils
shell: pwsh

- name: Restore vcpkg artifact
Expand Down
2 changes: 1 addition & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ rb_gc_vm_barrier(void)
rb_vm_barrier();
}

#if USE_MODULAR_GC
void *
rb_gc_get_ractor_newobj_cache(void)
{
return GET_RACTOR()->newobj_cache;
}

#if USE_MODULAR_GC
void
rb_gc_initialize_vm_context(struct rb_gc_vm_context *context)
{
Expand Down
35 changes: 22 additions & 13 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,17 @@ rb_gc_impl_size_allocatable_p(size_t size)
}

static const size_t ALLOCATED_COUNT_STEP = 1024;
static void
ractor_cache_flush_count(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache)
{
for (int heap_idx = 0; heap_idx < HEAP_COUNT; heap_idx++) {
rb_ractor_newobj_heap_cache_t *heap_cache = &cache->heap_caches[heap_idx];

rb_heap_t *heap = &heaps[heap_idx];
RUBY_ATOMIC_SIZE_ADD(heap->total_allocated_objects, heap_cache->allocated_objects_count);
heap_cache->allocated_objects_count = 0;
}
}

static inline VALUE
ractor_cache_allocate_slot(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache,
Expand All @@ -2240,19 +2251,11 @@ ractor_cache_allocate_slot(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *ca
rb_asan_unpoison_object(obj, true);
heap_cache->freelist = p->next;

if (rb_gc_multi_ractor_p()) {
heap_cache->allocated_objects_count++;
rb_heap_t *heap = &heaps[heap_idx];
if (heap_cache->allocated_objects_count >= ALLOCATED_COUNT_STEP) {
RUBY_ATOMIC_SIZE_ADD(heap->total_allocated_objects, heap_cache->allocated_objects_count);
heap_cache->allocated_objects_count = 0;
}
}
else {
rb_heap_t *heap = &heaps[heap_idx];
heap->total_allocated_objects++;
GC_ASSERT(heap->total_slots >=
(heap->total_allocated_objects - heap->total_freed_objects - heap->final_slots_count));
heap_cache->allocated_objects_count++;
rb_heap_t *heap = &heaps[heap_idx];
if (heap_cache->allocated_objects_count >= ALLOCATED_COUNT_STEP) {
RUBY_ATOMIC_SIZE_ADD(heap->total_allocated_objects, heap_cache->allocated_objects_count);
heap_cache->allocated_objects_count = 0;
}

#if RGENGC_CHECK_MODE
Expand Down Expand Up @@ -5172,6 +5175,8 @@ gc_verify_internal_consistency_(rb_objspace_t *objspace)

/* check counters */

ractor_cache_flush_count(objspace, rb_gc_get_ractor_newobj_cache());

if (!is_lazy_sweeping(objspace) &&
!finalizing &&
!rb_gc_multi_ractor_p()) {
Expand Down Expand Up @@ -7510,6 +7515,8 @@ rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)

setup_gc_stat_symbols();

ractor_cache_flush_count(objspace, rb_gc_get_ractor_newobj_cache());

if (RB_TYPE_P(hash_or_sym, T_HASH)) {
hash = hash_or_sym;
}
Expand Down Expand Up @@ -7662,6 +7669,8 @@ rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym)
{
rb_objspace_t *objspace = objspace_ptr;

ractor_cache_flush_count(objspace, rb_gc_get_ractor_newobj_cache());

setup_gc_stat_heap_symbols();

if (NIL_P(heap_name)) {
Expand Down
6 changes: 5 additions & 1 deletion lib/bundler/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ def prune_gem_cache(resolve, cache_path)

cached.each do |path|
Bundler.ui.info " * #{File.basename(path)}"
File.delete(path)

begin
File.delete(path)
rescue Errno::ENOENT
end
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions lib/bundler/templates/newgem/Rakefile.tt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ Rake::ExtensionTask.new("<%= config[:underscored_name] %>", GEMSPEC) do |ext|
end
<% end -%>

<% if config[:ext] == "go" -%>
require "go_gem/rake_task"

GoGem::RakeTask.new("<%= config[:underscored_name] %>")
<% end -%>
<% end -%>
<% if default_task_names.size == 1 -%>
task default: <%= default_task_names.first.inspect %>
Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def self.activate_and_load_bin_path(name, exec_name = nil, *requirements)
# RubyGems now uses this new `Gem.activate_and_load_bin_path` helper in
# binstubs, which is of course not overridden in Bundler since it didn't
# exist at the time. So, include the override here to workaround that.
load ENV["BUNDLE_BIN_PATH"] if ENV["BUNDLE_BIN_PATH"] && spec.version <= "2.5.22"
load ENV["BUNDLE_BIN_PATH"] if ENV["BUNDLE_BIN_PATH"] && spec.version <= Gem::Version.create("2.5.22")

# Make sure there's no version of Bundler in `$LOAD_PATH` that's different
# from the version we just activated. If that was the case (it happens
Expand Down Expand Up @@ -666,7 +666,7 @@ def self.load_safe_marshal
# warnings in platform constants

def self.load_bundler_extensions(version)
return unless version <= "2.6.9"
return unless version <= Gem::Version.create("2.6.9")

previous_platforms = {}

Expand Down
31 changes: 31 additions & 0 deletions lib/rubygems/bundler_version_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module Gem::BundlerVersionFinder
def self.bundler_version
return if bundle_config_version == "system"

v = ENV["BUNDLER_VERSION"]
v = nil if v&.empty?

Expand Down Expand Up @@ -78,4 +80,33 @@ def self.lockfile_contents
File.read(lockfile)
end
private_class_method :lockfile_contents

def self.bundle_config_version
config_file = bundler_config_file
return unless config_file && File.file?(config_file)

contents = File.read(config_file)
contents =~ /^BUNDLE_VERSION:\s*["']?([^"'\s]+)["']?\s*$/

$1
end
private_class_method :bundle_config_version

def self.bundler_config_file
# see Bundler::Settings#global_config_file and local_config_file
# global
if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
ENV["BUNDLE_CONFIG"]
elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty?
ENV["BUNDLE_USER_CONFIG"]
elsif ENV["BUNDLE_USER_HOME"] && !ENV["BUNDLE_USER_HOME"].empty?
ENV["BUNDLE_USER_HOME"] + "config"
elsif Gem.user_home && !Gem.user_home.empty?
Gem.user_home + ".bundle/config"
else
# local
"config"
end
end
private_class_method :bundler_config_file
end
12 changes: 9 additions & 3 deletions lib/rubygems/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,17 @@ def approximate_recommendation
##
# Compares this version with +other+ returning -1, 0, or 1 if the
# other version is larger, the same, or smaller than this
# one. Attempts to compare to something that's not a
# <tt>Gem::Version</tt> or a valid version String return +nil+.
# one. +other+ must be an instance of Gem::Version, comparing with
# other types may raise an exception.

def <=>(other)
return self <=> self.class.new(other) if (String === other) && self.class.correct?(other)
if String === other
unless Gem::Deprecate.skip
warn "comparing version objects with strings is deprecated and will be removed"
end
return unless self.class.correct?(other)
return self <=> self.class.new(other)
end

return unless Gem::Version === other
return 0 if @version == other.version || canonical_segments == other.canonical_segments
Expand Down
8 changes: 8 additions & 0 deletions spec/bundler/commands/newgem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,14 @@ def create_temporary_dir(dir)
expect(bundled_app("#{gem_name}/ext/#{gem_name}/go.mod").read).to include("module github.com/bundleuser/#{gem_name}")
end

it "includes go_gem extension in Rakefile" do
expect(bundled_app("#{gem_name}/Rakefile").read).to include(<<~RUBY)
require "go_gem/rake_task"

GoGem::RakeTask.new("#{gem_name}")
RUBY
end

context "with --no-ci" do
let(:flags) { "--ext=go --no-ci" }

Expand Down
3 changes: 3 additions & 0 deletions test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ def setup
ENV["XDG_STATE_HOME"] = nil
ENV["SOURCE_DATE_EPOCH"] = nil
ENV["BUNDLER_VERSION"] = nil
ENV["BUNDLE_CONFIG"] = nil
ENV["BUNDLE_USER_CONFIG"] = nil
ENV["BUNDLE_USER_HOME"] = nil
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "true"

@current_dir = Dir.pwd
Expand Down
70 changes: 70 additions & 0 deletions test/rubygems/test_gem_bundler_version_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require_relative "helper"
require "rubygems/bundler_version_finder"
require "tempfile"

class TestGemBundlerVersionFinder < Gem::TestCase
def setup
Expand Down Expand Up @@ -56,6 +57,75 @@ def test_bundler_version_with_bundle_update_bundler
assert_nil bvf.bundler_version
end

def test_bundler_version_with_bundle_config
config_content = <<~CONFIG
BUNDLE_VERSION: "system"
CONFIG

Tempfile.create("bundle_config") do |f|
f.write(config_content)
f.flush

bvf.stub(:bundler_config_file, f.path) do
assert_nil bvf.bundler_version
end
end
end

def test_bundler_version_with_bundle_config_single_quoted
config_with_single_quoted_version = <<~CONFIG
BUNDLE_VERSION: 'system'
CONFIG

Tempfile.create("bundle_config") do |f|
f.write(config_with_single_quoted_version)
f.flush

bvf.stub(:bundler_config_file, f.path) do
assert_nil bvf.bundler_version
end
end
end

def test_bundler_version_with_bundle_config_version
ENV["BUNDLER_VERSION"] = "1.1.1.1"

config_content = <<~CONFIG
BUNDLE_VERSION: "1.2.3"
CONFIG

Tempfile.create("bundle_config") do |f|
f.write(config_content)
f.flush

bvf.stub(:bundler_config_file, f.path) do
assert_equal v("1.1.1.1"), bvf.bundler_version
end
end
end

def test_bundler_version_with_bundle_config_non_existent_file
bvf.stub(:bundler_config_file, "/non/existent/path") do
assert_nil bvf.bundler_version
end
end

def test_bundler_version_with_bundle_config_without_version
config_without_version = <<~CONFIG
BUNDLE_JOBS: "8"
BUNDLE_GEM__TEST: "minitest"
CONFIG

Tempfile.create("bundle_config") do |f|
f.write(config_without_version)
f.flush

bvf.stub(:bundler_config_file, f.path) do
assert_nil bvf.bundler_version
end
end
end

def test_bundler_version_with_lockfile
bvf.stub(:lockfile_contents, "") do
assert_nil bvf.bundler_version
Expand Down
19 changes: 14 additions & 5 deletions test/rubygems/test_gem_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,20 @@ def test_spaceship
assert_equal(-1, v("5.a") <=> v("5.0.0.rc2"))
assert_equal(1, v("5.x") <=> v("5.0.0.rc2"))

assert_equal(0, v("1.9.3") <=> "1.9.3")
assert_equal(1, v("1.9.3") <=> "1.9.2.99")
assert_equal(-1, v("1.9.3") <=> "1.9.3.1")

assert_nil v("1.0") <=> "whatever"
[
[0, "1.9.3"],
[1, "1.9.2.99"],
[-1, "1.9.3.1"],
[nil, "whatever"],
].each do |cmp, string_ver|
expected = "comparing version objects with strings is deprecated and will be removed\n"

actual_stdout, actual_stderr = capture_output do
assert_equal(cmp, v("1.9.3") <=> string_ver)
end
assert_empty actual_stdout
assert_equal expected, actual_stderr
end
end

def test_approximate_recommendation
Expand Down
2 changes: 1 addition & 1 deletion vm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ struct rb_iseq_constant_body {
* size = M+N+O+(*1)+K+(&1)+(**1) // parameter size.
*/

struct {
struct rb_iseq_parameters {
struct {
unsigned int has_lead : 1;
unsigned int has_opt : 1;
Expand Down
8 changes: 5 additions & 3 deletions yjit/src/cruby_bindings.inc.rs

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

8 changes: 6 additions & 2 deletions zjit/bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,12 @@ fn main() {
.blocklist_type("VALUE")
.blocklist_type("ID")

.opaque_type("rb_iseq_t")
.blocklist_type("rb_iseq_t")
// Avoid binding to stuff we don't use
.blocklist_item("rb_thread_struct.*")
.opaque_type("rb_thread_struct.*")
.blocklist_item("iseq_inline_storage_entry_.*")
.opaque_type("iseq_inline_storage_entry")
.opaque_type("iseq_compile_data")

// Finish the builder and generate the bindings.
.generate()
Expand Down
Loading