Skip to content

Merge upstream #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 8, 2022
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
5 changes: 3 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ INSTRUBY_ARGS = $(SCRIPT_ARGS) \
INSTALL_PROG_MODE = 0755
INSTALL_DATA_MODE = 0644

BOOTSTRAPRUBY_COMMAND = $(BOOTSTRAPRUBY) $(BOOTSTRAPRUBY_OPT)
TESTSDIR = $(srcdir)/test
TOOL_TESTSDIR = $(tooldir)/test
TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/excludes $(ADDITIONAL_EXCLUDES) --name=!/memory_leak/
Expand Down Expand Up @@ -909,7 +910,7 @@ ENC_HEADERS = $(srcdir)/enc/jis/props.h
$(ENC_MK): $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc/depend \
$(srcdir)/enc/encinit.c.erb $(ENC_HEADERS) $(srcdir)/lib/mkmf.rb $(RBCONFIG) $(HAVE_BASERUBY)-fake
$(ECHO) generating $@
$(Q) $(BOOTSTRAPRUBY) -r./$(arch)-fake $(srcdir)/enc/make_encmake.rb \
$(Q) $(BOOTSTRAPRUBY_COMMAND) $(srcdir)/enc/make_encmake.rb \
--builtin-encs="$(BUILTIN_ENCOBJS)" --builtin-transes="$(BUILTIN_TRANSOBJS)" --module$(ENCSTATIC) $(ENCS) $@

.PRECIOUS: $(MKFILES)
Expand Down Expand Up @@ -1332,7 +1333,7 @@ lldb-ruby: $(PROGRAM) PHONY
DISTPKGS = gzip,zip,all
PKGSDIR = tmp
dist:
$(BASERUBY) $(tooldir)/make-snapshot \
$(BASERUBY) $(V0:1=-v) $(tooldir)/make-snapshot \
-srcdir=$(srcdir) -packages=$(DISTPKGS) \
-unicode-version=$(UNICODE_VERSION) \
$(DISTOPTS) $(PKGSDIR) $(RELNAME)
Expand Down
9 changes: 1 addition & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'p
HAVE_BASERUBY=no
])
AS_IF([test "$HAVE_BASERUBY" = no], [
AS_IF([test "$cross_compiling" = yes], [AC_MSG_ERROR([executable host ruby is required for cross-compiling])])
BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false"
])
AC_SUBST(BASERUBY)
Expand Down Expand Up @@ -3348,8 +3349,6 @@ for var in bindir includedir libdir rubylibprefix; do
done

BTESTRUBY='$(MINIRUBY)'
BOOTSTRAPRUBY='$(BASERUBY)'
BOOTSTRAPRUBY_COMMAND='$(BOOTSTRAPRUBY)'
AS_IF([test x"$cross_compiling" = xyes], [
test x"$MINIRUBY" = x && MINIRUBY="${RUBY-$BASERUBY} -I`$CHDIR .; pwd` "-r'$(arch)-fake'
XRUBY_LIBDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["libdir"]']`
Expand All @@ -3362,7 +3361,6 @@ AS_IF([test x"$cross_compiling" = xyes], [
RUNRUBY_COMMAND='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
RUNRUBY='$(RUNRUBY_COMMAND)'
XRUBY='$(MINIRUBY)'
BOOTSTRAPRUBY_COMMAND='$(BOOTSTRAPRUBY) -r./$(arch)-fake'
TEST_RUNNABLE=no
CROSS_COMPILING=yes
AC_DEFINE(CROSS_COMPILING, 1)
Expand All @@ -3373,9 +3371,6 @@ AS_IF([test x"$cross_compiling" = xyes], [
RUNRUBY_COMMAND='$(MINIRUBY) $(tooldir)/runruby.rb --extout=$(EXTOUT) $(RUNRUBYOPT)'
RUNRUBY='$(RUNRUBY_COMMAND) --'
XRUBY='$(RUNRUBY)'
AS_CASE(["$HAVE_BASERUBY"],
[yes], [BOOTSTRAPRUBY_COMMAND='$(BOOTSTRAPRUBY) -r./$(arch)-fake'],
[BOOTSTRAPRUBY='$(MINIRUBY)'])
TEST_RUNNABLE=yes
CROSS_COMPILING=no
])
Expand All @@ -3387,8 +3382,6 @@ AC_SUBST(PREP)
AC_SUBST(RUNRUBY_COMMAND)
AC_SUBST(RUNRUBY)
AC_SUBST(XRUBY)
AC_SUBST(BOOTSTRAPRUBY)
AC_SUBST(BOOTSTRAPRUBY_COMMAND)
AC_SUBST(EXTOUT, [${EXTOUT=.ext}])

FIRSTMAKEFILE=""
Expand Down
2 changes: 1 addition & 1 deletion ext/psych/lib/psych/scalar_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def tokenize string
elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
require 'date'
begin
class_loader.date.strptime(string, '%Y-%m-%d')
class_loader.date.strptime(string, '%F', Date::GREGORIAN)
rescue ArgumentError
string
end
Expand Down
2 changes: 1 addition & 1 deletion ext/psych/lib/psych/versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module Psych
VERSION = '5.0.0.dev'

if RUBY_ENGINE == 'jruby'
DEFAULT_SNAKEYAML_VERSION = '1.28'.freeze
DEFAULT_SNAKEYAML_VERSION = '1.31'.freeze
end
end
4 changes: 3 additions & 1 deletion ext/psych/lib/psych/visitors/to_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def deserialize o
when "!ruby/object:DateTime"
class_loader.date_time
require 'date' unless defined? DateTime
@ss.parse_time(o.value).to_datetime
t = @ss.parse_time(o.value)
DateTime.civil(*t.to_a[0, 6].reverse, Rational(t.utc_offset, 86400)) +
(t.subsec/86400)
when '!ruby/encoding'
::Encoding.find o.value
when "!ruby/object:Complex"
Expand Down
16 changes: 8 additions & 8 deletions ext/psych/lib/psych/visitors/yaml_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ def visit_Regexp o
register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY)
end

def visit_Date o
register o, visit_Integer(o.gregorian)
end

def visit_DateTime o
formatted = if o.offset.zero?
o.strftime("%Y-%m-%d %H:%M:%S.%9N Z".freeze)
else
o.strftime("%Y-%m-%d %H:%M:%S.%9N %:z".freeze)
end
t = o.italy
formatted = format_time t, t.offset.zero?
tag = '!ruby/object:DateTime'
register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY)
end
Expand Down Expand Up @@ -235,7 +236,6 @@ def visit_Integer o
end
alias :visit_TrueClass :visit_Integer
alias :visit_FalseClass :visit_Integer
alias :visit_Date :visit_Integer

def visit_Float o
if o.nan?
Expand Down Expand Up @@ -482,8 +482,8 @@ def dump_exception o, msg
@emitter.end_mapping
end

def format_time time
if time.utc?
def format_time time, utc = time.utc?
if utc
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
else
time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems/query_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ def show_remote_gems(name)
fetcher.detect(specs_type) { true }
else
fetcher.detect(specs_type) do |name_tuple|
name === name_tuple.name
name === name_tuple.name && options[:version].satisfied_by?(name_tuple.version)
end
end

output_query_results(spec_tuples)
end

def specs_type
if options[:all]
if options[:all] || options[:version].specific?
if options[:prerelease]
:complete
else
Expand Down
8 changes: 5 additions & 3 deletions mjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,7 @@ static void mjit_wait(struct rb_iseq_constant_body *body);
static void
check_unit_queue(void)
{
if (mjit_opts.custom) return;
if (worker_stopped) return;
if (current_cc_pid != 0) return; // still compiling

Expand Down Expand Up @@ -1431,7 +1432,7 @@ mjit_hook_custom_compile(const rb_iseq_t *iseq)
static void
mjit_add_iseq_to_process(const rb_iseq_t *iseq, const struct rb_mjit_compile_info *compile_info, bool recompile_p)
{
if (!mjit_enabled || pch_status == PCH_FAILED || !rb_ractor_main_p()) // TODO: Support non-main Ractors
if (!mjit_enabled || pch_status != PCH_SUCCESS || !rb_ractor_main_p()) // TODO: Support non-main Ractors
return;
if (mjit_opts.custom) {
mjit_hook_custom_compile(iseq);
Expand Down Expand Up @@ -1957,9 +1958,10 @@ mjit_resume(void)

// Lazily prepare PCH when --mjit=pause is given
if (pch_status == PCH_NOT_READY) {
if (rb_respond_to(rb_mMJITCompiler, rb_intern("compile"))) {
if (rb_respond_to(rb_mMJIT, rb_intern("compile"))) {
// [experimental] defining RubyVM::MJIT.compile allows you to replace JIT
mjit_opts.custom = true;
pch_status = PCH_SUCCESS;
}
else {
// Lazy MJIT boot
Expand Down Expand Up @@ -2040,7 +2042,7 @@ mjit_finish(bool close_handle_p)
mjit_dump_total_calls();
#endif

if (!mjit_opts.save_temps && getpid() == pch_owner_pid && pch_status != PCH_NOT_READY)
if (!mjit_opts.save_temps && getpid() == pch_owner_pid && pch_status == PCH_SUCCESS && !mjit_opts.custom)
remove_file(pch_file);

xfree(header_file); header_file = NULL;
Expand Down
17 changes: 10 additions & 7 deletions mjit_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,16 @@ def mjit_capture_is_entries(body, is_entries)
}
end

# Convert encoded VM pointers to insn BINs.
def rb_vm_insn_decode(encoded)
Primitive.cexpr! 'INT2NUM(rb_vm_insn_decode(NUM2PTR(encoded)))'
end

# Convert insn BINs to encoded VM pointers. This one is not used by the compiler, but useful for debugging.
def rb_vm_insn_encode(bin)
Primitive.cexpr! 'PTR2NUM((VALUE)rb_vm_get_insns_address_table()[NUM2INT(bin)])'
end

def insn_may_depend_on_sp_or_pc(insn, opes)
_opes_addr = opes.to_i
Primitive.cexpr! 'RBOOL(insn_may_depend_on_sp_or_pc(NUM2INT(insn), (VALUE *)NUM2PTR(_opes_addr)))'
Expand All @@ -104,13 +110,10 @@ def to_ruby(value)
Primitive.cexpr! '(VALUE)NUM2PTR(value)'
end

def debug(status)
_cc_entries_addr = status.compiled_iseq.jit_unit.cc_entries.instance_variable_get(:@addr)
Primitive.cstmt! %{
const struct rb_callcache **cc_entries = (const struct rb_callcache **)NUM2PTR(_cc_entries_addr);
fprintf(stderr, "debug: %p\n", cc_entries[0]);
return Qnil;
}
# Convert RubyVM::InstructionSequence to C.rb_iseq_t. Not used by the compiler, but useful for debugging.
def rb_iseqw_to_iseq(iseqw)
iseq_addr = Primitive.cexpr! 'PTR2NUM((VALUE)rb_iseqw_to_iseq(iseqw))'
rb_iseq_t.new(iseq_addr)
end

# TODO: remove this after migration
Expand Down
7 changes: 5 additions & 2 deletions template/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
XRUBY_LIBDIR = @XRUBY_LIBDIR@
XRUBY_RUBYLIBDIR = @XRUBY_RUBYLIBDIR@
XRUBY_RUBYHDRDIR = @XRUBY_RUBYHDRDIR@
BOOTSTRAPRUBY = @BOOTSTRAPRUBY@
BOOTSTRAPRUBY_COMMAND = @BOOTSTRAPRUBY_COMMAND@

yes_baseruby = $(HAVE_BASERUBY:no=)
no_baseruby = $(HAVE_BASERUBY:yes=)
BOOTSTRAPRUBY = $(yes_baseruby:yes=$(BASERUBY)) $(no_baseruby:no=$(MINIRUBY))
BOOTSTRAPRUBY_OPT = $(yes_baseruby:yes=-r./$(arch)-fake)

COROUTINE_H = @X_COROUTINE_H@
COROUTINE_OBJ = $(COROUTINE_H:.h=.$(OBJEXT))
Expand Down
4 changes: 0 additions & 4 deletions test/excludes/Psych/TestDateTime.rb

This file was deleted.

20 changes: 20 additions & 0 deletions test/psych/test_date_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ def test_datetime_timezone_offset
assert_match(/12:00:00-05:00/, cycled.last.to_s)
end

def test_julian_date
d = Date.new(1582, 10, 4, Date::GREGORIAN)
assert_cycle d
end

def test_proleptic_gregorian_date
d = Date.new(1582, 10, 14, Date::GREGORIAN)
assert_cycle d
end

def test_julian_datetime
dt = DateTime.new(1582, 10, 4, 23, 58, 59, 0, Date::GREGORIAN)
assert_cycle dt
end

def test_proleptic_gregorian_datetime
dt = DateTime.new(1582, 10, 14, 23, 58, 59, 0, Date::GREGORIAN)
assert_cycle dt
end

def test_invalid_date
assert_cycle "2013-10-31T10:40:07-000000000000033"
end
Expand Down
26 changes: 26 additions & 0 deletions test/rubygems/test_gem_commands_info_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,30 @@ def test_execute
assert_match %r{#{@gem.summary}\n}, @ui.output
assert_match "", @ui.error
end

def test_execute_with_version_flag
spec_fetcher do |fetcher|
fetcher.spec "coolgem", "1.0"
fetcher.spec "coolgem", "2.0"
end

@cmd.handle_options %w[coolgem --remote --version 1.0]

use_ui @ui do
@cmd.execute
end

expected = <<-EOF

*** REMOTE GEMS ***

coolgem (1.0)
Author: A User
Homepage: http://example.com

this is a summary
EOF

assert_equal expected, @ui.output
end
end
4 changes: 1 addition & 3 deletions test/socket/test_socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,6 @@ def test_bintime
end

def test_closed_read
omit if RUBY_PLATFORM.include?("freebsd")

require 'timeout'
require 'socket'
bug4390 = '[ruby-core:35203]'
Expand All @@ -585,7 +583,7 @@ def test_closed_read
ensure
serv_thread.value.close
server.close
end
end unless RUBY_PLATFORM.include?("freebsd")

def test_connect_timeout
host = "127.0.0.1"
Expand Down
4 changes: 4 additions & 0 deletions thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
#include "mmtk.h"
#endif

#if USE_MJIT && defined(HAVE_SYS_WAIT_H)
#include <sys/wait.h>
#endif

#ifndef USE_NATIVE_THREAD_PRIORITY
#define USE_NATIVE_THREAD_PRIORITY 0
#define RUBY_THREAD_PRIORITY_MAX 3
Expand Down
5 changes: 3 additions & 2 deletions tool/make-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $keep_temp ||= nil
$patch_file ||= nil
$packages ||= nil
$digests ||= nil
$no7z ||= nil
$tooldir = File.expand_path("..", __FILE__)
$unicode_version = nil if ($unicode_version ||= nil) == ""
$colorize = Colorize.new
Expand Down Expand Up @@ -146,7 +147,7 @@ unless destdir = ARGV.shift
end
revisions = ARGV.empty? ? [nil] : ARGV

if $exported
if defined?($exported)
abort "#{File.basename $0}: -exported option is deprecated; use -srcdir instead"
end

Expand Down Expand Up @@ -416,7 +417,7 @@ def package(vcs, rev, destdir, tmp = nil)
f.puts "Object.__send__(:remove_const, :RUBY_VERSION)"
f.puts "RUBY_VERSION='#{version}'"
end
warn "cross.rb:", File.read("cross.rb").gsub(/^/, "> "), ""
puts "cross.rb:", File.read("cross.rb").gsub(/^/, "> "), "" if $VERBOSE
unless File.exist?("configure")
print "creating configure..."
unless system([ENV["AUTOCONF"]]*2)
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define RUBY_RELEASE_YEAR 2022
#define RUBY_RELEASE_MONTH 9
#define RUBY_RELEASE_DAY 6
#define RUBY_RELEASE_DAY 7

#include "ruby/version.h"
#include "ruby/internal/abi.h"
Expand Down
Loading