Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into Ractor-Local-GC-v…
Browse files Browse the repository at this point in the history
…ersion-2
  • Loading branch information
rm155 committed Apr 19, 2024
2 parents 314a6af + 662ce92 commit 71f0b7b
Show file tree
Hide file tree
Showing 34 changed files with 263 additions and 83 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The following default gems are updated.
* json 2.7.2
* net-http 0.4.1
* optparse 0.5.0
* prism 0.25.0
* prism 0.26.0
* rdoc 6.6.3.1
* reline 0.5.2
* resolv 0.4.0
Expand Down
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ configure-ext: $(EXTS_MK)
build-ext: $(EXTS_MK)
$(Q)$(MAKE) -f $(EXTS_MK) $(mflags) libdir="$(libdir)" LIBRUBY_EXTS=$(LIBRUBY_EXTS) \
EXTENCS="$(ENCOBJS)" BASERUBY="$(BASERUBY)" MINIRUBY="$(MINIRUBY)" \
UPDATE_LIBRARIES=no $(EXTSTATIC)
$(EXTSTATIC)
$(Q)$(MAKE) $(EXTS_NOTE)

exts-note: $(EXTS_MK)
Expand Down
7 changes: 5 additions & 2 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2007,8 +2007,11 @@ iseq_set_use_block(rb_iseq_t *iseq)
body->param.flags.use_block = 1;

rb_vm_t *vm = GET_VM();
st_data_t key = (st_data_t)rb_intern_str(body->location.label); // String -> ID
st_insert(vm->unused_block_warning_table, key, 1);

if (!vm->unused_block_warning_strict) {
st_data_t key = (st_data_t)rb_intern_str(body->location.label); // String -> ID
st_insert(vm->unused_block_warning_table, key, 1);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion defs/gmake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,12 @@ ifneq ($(POSTLINK),)
endif
$(Q) $(RMALL) $@.*

rubyspec-capiext: $(patsubst %.c,$(RUBYSPEC_CAPIEXT)/%.$(DLEXT),$(notdir $(wildcard $(srcdir)/$(RUBYSPEC_CAPIEXT)/*.c)))
RUBYSPEC_CAPIEXT_SO := $(patsubst %.c,$(RUBYSPEC_CAPIEXT)/%.$(DLEXT),$(notdir $(wildcard $(srcdir)/$(RUBYSPEC_CAPIEXT)/*.c)))
rubyspec-capiext: $(RUBYSPEC_CAPIEXT_SO)
@ $(NULLCMD)

ifeq ($(ENABLE_SHARED),yes)
ruby: $(if $(LIBRUBY_SO_UPDATE),$(RUBYSPEC_CAPIEXT_SO))
exts: rubyspec-capiext
endif

Expand Down
3 changes: 3 additions & 0 deletions enc/encinit.c.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* Automatically generated from <%= erb.filename %>
* Do not edit<%# directly%>.
*/
/* Copyright 2012 Google Inc. Some Rights Reserved.
* Author: yugui@google.com (Yugui Sonoda)
*/
Expand Down
8 changes: 2 additions & 6 deletions enc/make_encmake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ def target_transcoders
Dir.mkdir 'enc'
rescue Errno::EEXIST
end
File.open("enc/encinit.c", "w") {|f|
f.puts "/* Automatically generated from enc/encinit.c.erb"
f.puts " * Do not edit."
f.puts " */"
f.puts tmp
}
require 'tool/lib/output'
Output.new(path: "enc/encinit.c", ifchange: true).write(tmp)
end
1 change: 0 additions & 1 deletion ext/extmk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,6 @@ def mf.macro(name, values, max = 70)
end
submakeopts << 'EXTLDFLAGS="$(EXTLDFLAGS)"'
submakeopts << 'EXTINITS="$(EXTINITS)"'
submakeopts << 'UPDATE_LIBRARIES="$(UPDATE_LIBRARIES)"'
submakeopts << 'SHOWFLAGS='
mf.macro "SUBMAKEOPTS", submakeopts
mf.macro "NOTE_MESG", %w[$(RUBY) $(top_srcdir)/tool/lib/colorize.rb skip]
Expand Down
3 changes: 0 additions & 3 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13076,9 +13076,6 @@ update_cc_tbl_i(VALUE ccs_ptr, void *data)
}

for (int i=0; i<RUBY_ATOMIC_LOAD(ccs->len); i++) {
if (gc_object_moved_p(objspace, (VALUE)ccs->entries[i].ci)) {
ccs->entries[i].ci = (struct rb_callinfo *)rb_gc_location((VALUE)ccs->entries[i].ci);
}
if (gc_object_moved_p(objspace, (VALUE)ccs->entries[i].cc)) {
ccs->entries[i].cc = (struct rb_callcache *)rb_gc_location((VALUE)ccs->entries[i].cc);
}
Expand Down
1 change: 0 additions & 1 deletion imemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ cc_table_mark_i(ID id, VALUE ccs_ptr, void *data)
for (int i=0; i<RUBY_ATOMIC_LOAD(ccs->len); i++) {
VM_ASSERT((VALUE)data == ccs->entries[i].cc->klass);

rb_gc_mark_movable((VALUE)ccs->entries[i].ci);
rb_gc_mark_movable((VALUE)ccs->entries[i].cc);
}
return ID_TABLE_CONTINUE;
Expand Down
1 change: 1 addition & 0 deletions include/ruby/internal/encoding/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/attr/returns_nonnull.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/encoding/coderange.h"
#include "ruby/internal/value.h"
#include "ruby/internal/core/rbasic.h"
#include "ruby/internal/fl_type.h"
Expand Down
8 changes: 2 additions & 6 deletions include/ruby/io/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@ enum rb_io_buffer_endian {
RB_IO_BUFFER_LITTLE_ENDIAN = 4,
RB_IO_BUFFER_BIG_ENDIAN = 8,

#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_LITTLE_ENDIAN,
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#if defined(WORDS_BIGENDIAN)
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_BIG_ENDIAN,
#elif defined(REG_DWORD) && REG_DWORD == REG_DWORD_LITTLE_ENDIAN
#else
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_LITTLE_ENDIAN,
#elif defined(REG_DWORD) && REG_DWORD == REG_DWORD_BIG_ENDIAN
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_BIG_ENDIAN,
#endif

RB_IO_BUFFER_NETWORK_ENDIAN = RB_IO_BUFFER_BIG_ENDIAN
Expand Down
4 changes: 4 additions & 0 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ static bool
cc_is_active(const struct rb_callcache *cc, bool reference_updating)
{
if (cc) {
if (cc == rb_vm_empty_cc() || rb_vm_empty_cc_for_super()) {
return false;
}

if (reference_updating) {
cc = (const struct rb_callcache *)rb_gc_location((VALUE)cc);
}
Expand Down
18 changes: 18 additions & 0 deletions lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def setup(*groups)
# Bundler.require(:test) # requires second_gem
#
def require(*groups)
load_plugins
setup(*groups).require(*groups)
end

Expand Down Expand Up @@ -560,6 +561,23 @@ def feature_flag
@feature_flag ||= FeatureFlag.new(VERSION)
end

def load_plugins(definition = Bundler.definition)
return if defined?(@load_plugins_ran)

Bundler.rubygems.load_plugins

requested_path_gems = definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
path_plugin_files = requested_path_gems.map do |spec|
Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
end.flatten
Bundler.rubygems.load_plugin_files(path_plugin_files)
Bundler.rubygems.load_env_plugins
@load_plugins_ran = true
end

def reset!
reset_paths!
Plugin.reset!
Expand Down
16 changes: 1 addition & 15 deletions lib/bundler/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def run(options)

if resolve_if_needed(options)
ensure_specs_are_compatible!
load_plugins
Bundler.load_plugins(@definition)
options.delete(:jobs)
else
options[:jobs] = 1 # to avoid the overhead of Bundler::Worker
Expand Down Expand Up @@ -213,20 +213,6 @@ def installation_parallelization(options)
Bundler.settings.processor_count
end

def load_plugins
Gem.load_plugins

requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
path_plugin_files = requested_path_gems.map do |spec|
Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
end.flatten
Gem.load_plugin_files(path_plugin_files)
Gem.load_env_plugins
end

def ensure_specs_are_compatible!
@definition.specs.each do |spec|
unless spec.matches_current_ruby?
Expand Down
24 changes: 24 additions & 0 deletions lib/bundler/plugin/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,30 @@ def self.defined_event?(event)
# Includes an Array of Bundler::Dependency objects
# GEM_AFTER_INSTALL_ALL = "after-install-all"
define :GEM_AFTER_INSTALL_ALL, "after-install-all"

# @!parse
# A hook called before each individual gem is required
# Includes a Bundler::Dependency.
# GEM_BEFORE_REQUIRE = "before-require"
define :GEM_BEFORE_REQUIRE, "before-require"

# @!parse
# A hook called after each individual gem is required
# Includes a Bundler::Dependency.
# GEM_AFTER_REQUIRE = "after-require"
define :GEM_AFTER_REQUIRE, "after-require"

# @!parse
# A hook called before any gems require
# Includes an Array of Bundler::Dependency objects.
# GEM_BEFORE_REQUIRE_ALL = "before-require-all"
define :GEM_BEFORE_REQUIRE_ALL, "before-require-all"

# @!parse
# A hook called after all gems required
# Includes an Array of Bundler::Dependency objects.
# GEM_AFTER_REQUIRE_ALL = "after-require-all"
define :GEM_AFTER_REQUIRE_ALL, "after-require-all"
end
end
end
12 changes: 12 additions & 0 deletions lib/bundler/rubygems_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ def loaded_gem_paths
loaded_gem_paths.flatten
end

def load_plugins
Gem.load_plugins
end

def load_plugin_files(plugin_files)
Gem.load_plugin_files(plugin_files)
end

def load_env_plugins
Gem.load_env_plugins
end

def ui=(obj)
Gem::DefaultUserInteraction.ui = obj
end
Expand Down
19 changes: 15 additions & 4 deletions lib/bundler/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ def require(*groups)
groups.map!(&:to_sym)
groups = [:default] if groups.empty?

@definition.dependencies.each do |dep|
# Skip the dependency if it is not in any of the requested groups, or
# not for the current platform, or doesn't match the gem constraints.
next unless (dep.groups & groups).any? && dep.should_include?
dependencies = @definition.dependencies.select do |dep|
# Select the dependency if it is in any of the requested groups, and
# for the current platform, and matches the gem constraints.
(dep.groups & groups).any? && dep.should_include?
end

Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE_ALL, dependencies)

dependencies.each do |dep|
required_file = nil
Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE, dep)

begin
# Loop through all the specified autorequires for the
Expand Down Expand Up @@ -76,7 +81,13 @@ def require(*groups)
end
end
end

Plugin.hook(Plugin::Events::GEM_AFTER_REQUIRE, dep)
end

Plugin.hook(Plugin::Events::GEM_AFTER_REQUIRE_ALL, dependencies)

dependencies
end

def self.definition_method(meth)
Expand Down
2 changes: 1 addition & 1 deletion lib/prism/prism.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |spec|
spec.name = "prism"
spec.version = "0.25.0"
spec.version = "0.26.0"
spec.authors = ["Shopify"]
spec.email = ["ruby@shopify.com"]

Expand Down
30 changes: 20 additions & 10 deletions lib/prism/translation/parser/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1535,19 +1535,29 @@ def visit_string_node(node)
elsif node.opening == "?"
builder.character([node.unescaped, srange(node.location)])
else
parts = if node.content.lines.count <= 1 || node.unescaped.lines.count <= 1
[builder.string_internal([node.unescaped, srange(node.content_loc)])]
else
start_offset = node.content_loc.start_offset
content_lines = node.content.lines
unescaped_lines = node.unescaped.lines

[node.content.lines, node.unescaped.lines].transpose.map do |content_line, unescaped_line|
end_offset = start_offset + content_line.length
offsets = srange_offsets(start_offset, end_offset)
start_offset = end_offset
parts =
if content_lines.length <= 1 || unescaped_lines.length <= 1
[builder.string_internal([node.unescaped, srange(node.content_loc)])]
elsif content_lines.length != unescaped_lines.length
# This occurs when we have line continuations in the string. We
# need to come back and fix this, but for now this stops the
# code from breaking when we encounter it because of trying to
# transpose arrays of different lengths.
[builder.string_internal([node.unescaped, srange(node.content_loc)])]
else
start_offset = node.content_loc.start_offset

[content_lines, unescaped_lines].transpose.map do |content_line, unescaped_line|
end_offset = start_offset + content_line.length
offsets = srange_offsets(start_offset, end_offset)
start_offset = end_offset

builder.string_internal([unescaped_line, offsets])
builder.string_internal([unescaped_line, offsets])
end
end
end

builder.string_compose(
token(node.opening_loc),
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_suggest/clean_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def join_groups(groups)
groups.each do |lines|
line = lines.first

# Handle the case of multiple groups in a a row
# Handle the case of multiple groups in a row
# if one is already replaced, move on
next if @document[line.index].empty?

Expand Down
2 changes: 1 addition & 1 deletion prism/extension.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PRISM_EXT_NODE_H
#define PRISM_EXT_NODE_H

#define EXPECTED_PRISM_VERSION "0.25.0"
#define EXPECTED_PRISM_VERSION "0.26.0"

#include <ruby.h>
#include <ruby/encoding.h>
Expand Down
2 changes: 1 addition & 1 deletion prism/templates/lib/prism/serialize.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Prism

# The minor version of prism that we are expecting to find in the serialized
# strings.
MINOR_VERSION = 25
MINOR_VERSION = 26

# The patch version of prism that we are expecting to find in the serialized
# strings.
Expand Down
4 changes: 2 additions & 2 deletions prism/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* The minor version of the Prism library as an int.
*/
#define PRISM_VERSION_MINOR 25
#define PRISM_VERSION_MINOR 26

/**
* The patch version of the Prism library as an int.
Expand All @@ -24,6 +24,6 @@
/**
* The version of the Prism library as a constant string.
*/
#define PRISM_VERSION "0.25.0"
#define PRISM_VERSION "0.26.0"

#endif
Loading

0 comments on commit 71f0b7b

Please sign in to comment.