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/actions/compilers/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export CONFIGURE_TTY='never'
export RUBY_DEBUG='ci rgengc'
export RUBY_TESTOPTS='-q --color=always --tty=no'
export RUBY_DEBUG_COUNTER_DISABLE='1'
export GNUMAKEFLAGS="-j$((1 + $(nproc --all)))"
export GNUMAKEFLAGS="-j$((1 + $(nproc)))"

case "x${INPUT_ENABLE_SHARED}" in
x | xno | xfalse )
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup/directories/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ runs:

- if: runner.os == 'Linux'
shell: bash
run: echo "GNUMAKEFLAGS=-sj$((1 + $(nproc --all)))" >> "$GITHUB_ENV"
run: echo "GNUMAKEFLAGS=-sj$((1 + $(nproc)))" >> "$GITHUB_ENV"

# macOS' GNU make is so old that they doesn't understand `GNUMAKEFLAGS`.
- if: runner.os == 'macOS'
Expand Down
193 changes: 0 additions & 193 deletions .github/workflows/ubuntu-ibm.yml

This file was deleted.

5 changes: 3 additions & 2 deletions doc/string/length.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ Returns the count of characters (not bytes) in +self+:

'foo'.length # => 3
'тест'.length # => 4
'こんにちは'.length # => 5
'こんにちは'.length # => 5

Contrast with String#bytesize:

'foo'.bytesize # => 3
'тест'.bytesize # => 8
'こんにちは'.bytesize # => 15
'こんにちは'.bytesize # => 15

Related: see {Querying}[rdoc-ref:String@Querying].
16 changes: 16 additions & 0 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -5196,6 +5196,22 @@ rb_file_s_extname(VALUE klass, VALUE fname)
* File.path(File::NULL) #=> "/dev/null"
* File.path(Pathname.new("/tmp")) #=> "/tmp"
*
* If +path+ is not a String:
*
* 1. If it has the +to_path+ method, that method will be called to
* coerce to a String.
*
* 2. Otherwise, or if the coerced result is not a String too, the
* standard coersion using +to_str+ method will take place on that
* object. (See also String.try_convert)
*
* The coerced string must satisfy the following conditions:
*
* 1. It must be in an ASCII-compatible encoding; otherwise, an
* Encoding::CompatibilityError is raised.
*
* 2. It must not contain the NUL character (<tt>\0</tt>); otherwise,
* an ArgumentError is raised.
*/

static VALUE
Expand Down
4 changes: 2 additions & 2 deletions imemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ mark_and_move_method_entry(rb_method_entry_t *ment, bool reference_updating)
break;
case VM_METHOD_TYPE_BMETHOD:
rb_gc_mark_and_move(&def->body.bmethod.proc);
if (!reference_updating) {
if (def->body.bmethod.hooks) rb_hook_list_mark(def->body.bmethod.hooks);
if (def->body.bmethod.hooks) {
rb_hook_list_mark_and_move(def->body.bmethod.hooks);
}
break;
case VM_METHOD_TYPE_ALIAS:
Expand Down
2 changes: 1 addition & 1 deletion internal/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ VALUE rb_gccct_clear_table(VALUE);

#if USE_YJIT || USE_ZJIT
/* vm_exec.c */
extern uint64_t rb_vm_insns_count;
extern uint64_t rb_vm_insn_count;
#endif

extern bool rb_free_at_exit;
Expand Down
2 changes: 1 addition & 1 deletion iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
VM_ASSERT(ISEQ_EXECUTABLE_P(iseq));

if (iseq->aux.exec.local_hooks) {
rb_hook_list_mark_and_update(iseq->aux.exec.local_hooks);
rb_hook_list_mark_and_move(iseq->aux.exec.local_hooks);
}
}

Expand Down
12 changes: 9 additions & 3 deletions ractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ ractor_lock(rb_ractor_t *r, const char *file, int line)

ASSERT_ractor_unlocking(r);
rb_native_mutex_lock(&r->sync.lock);
r->malloc_gc_disabled = true;

if (rb_current_execution_context(false)) {
VM_ASSERT(!GET_RACTOR()->malloc_gc_disabled);
GET_RACTOR()->malloc_gc_disabled = true;
}

#if RACTOR_CHECK_MODE > 0
if (rb_current_execution_context(false) != NULL) {
Expand Down Expand Up @@ -101,9 +105,11 @@ ractor_unlock(rb_ractor_t *r, const char *file, int line)
r->sync.locked_by = Qnil;
#endif

VM_ASSERT(r->malloc_gc_disabled);
if (rb_current_execution_context(false)) {
VM_ASSERT(GET_RACTOR()->malloc_gc_disabled);
GET_RACTOR()->malloc_gc_disabled = false;
}

r->malloc_gc_disabled = false;
rb_native_mutex_unlock(&r->sync.lock);

RUBY_DEBUG_LOG2(file, line, "r:%u%s", r->pub.id, rb_current_ractor_raw(false) == r ? " (self)" : "");
Expand Down
19 changes: 15 additions & 4 deletions test/ruby/test_file_exhaustive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,23 @@ def test_path
[regular_file, utf8_file].each do |file|
assert_equal(file, File.open(file) {|f| f.path})
assert_equal(file, File.path(file))
o = Object.new
class << o; self; end.class_eval do
define_method(:to_path) { file }
end
o = Struct.new(:to_path).new(file)
assert_equal(file, File.path(o))
o = Struct.new(:to_str).new(file)
assert_equal(file, File.path(o))
end

conv_error = ->(method, msg = "converting with #{method}") {
o = Struct.new(method).new(42)
assert_raise(TypeError, msg) {File.path(o)}
o = Struct.new(method).new("abc".encode(Encoding::UTF_32BE))
assert_raise(Encoding::CompatibilityError, msg) {File.path(o)}
o = Struct.new(method).new("\0")
assert_raise(ArgumentError, msg) {File.path(o)}
}

conv_error[:to_path]
conv_error[:to_str]
end

def assert_integer(n)
Expand Down
28 changes: 28 additions & 0 deletions test/ruby/test_nomethod_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,32 @@ def name

assert_match(/undefined method.+this_method_does_not_exist.+for.+Module/, err.to_s)
end

def test_send_forward_raises
t = EnvUtil.labeled_class("Test") do
def foo(...)
forward(...)
end
end
obj = t.new
assert_raise(NoMethodError) do
obj.foo
end
end

# [Bug #21535]
def test_send_forward_raises_when_called_through_vcall
t = EnvUtil.labeled_class("Test") do
def foo(...)
forward(...)
end
def foo_indirect
foo # vcall
end
end
obj = t.new
assert_raise(NoMethodError) do
obj.foo_indirect
end
end
end
4 changes: 2 additions & 2 deletions test/ruby/test_zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1490,8 +1490,8 @@ def test_stats
def test = 1
test
[
RubyVM::ZJIT.stats[:zjit_insns_count] > 0,
RubyVM::ZJIT.stats(:zjit_insns_count) > 0,
RubyVM::ZJIT.stats[:zjit_insn_count] > 0,
RubyVM::ZJIT.stats(:zjit_insn_count) > 0,
]
}, stats: true
end
Expand Down
2 changes: 1 addition & 1 deletion vm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ struct rb_trace_arg_struct {
};

void rb_hook_list_mark(rb_hook_list_t *hooks);
void rb_hook_list_mark_and_update(rb_hook_list_t *hooks);
void rb_hook_list_mark_and_move(rb_hook_list_t *hooks);
void rb_hook_list_free(rb_hook_list_t *hooks);
void rb_hook_list_connect_tracepoint(VALUE target, rb_hook_list_t *list, VALUE tpval, unsigned int target_line);
void rb_hook_list_remove_tracepoint(rb_hook_list_t *list, VALUE tpval);
Expand Down
2 changes: 1 addition & 1 deletion vm_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#if USE_YJIT || USE_ZJIT
// The number of instructions executed on vm_exec_core. --yjit-stats and --zjit-stats use this.
uint64_t rb_vm_insns_count = 0;
uint64_t rb_vm_insn_count = 0;
#endif

#if VM_COLLECT_USAGE_DETAILS
Expand Down
Loading