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 doc/yjit/yjit.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This project is open source and falls under the same license as CRuby.

<p align="center"><b>
If you're using YJIT in production, please
<a href="mailto:maxime.chevalierboisvert@shopify.com">share your success stories with us!</a>
<a href="mailto:ruby@shopify.com">share your success stories with us!</a>
</b></p>

If you wish to learn more about the approach taken, here are some conference talks and publications:
Expand Down
8 changes: 8 additions & 0 deletions doc/zjit.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ A file called `zjit_exits_{pid}.dump` will be created in the same directory as `
stackprof path/to/zjit_exits_{pid}.dump
```

### Viewing HIR in Iongraph

Using `--zjit-dump-hir-iongraph` will dump all compiled functions into a directory named `/tmp/zjit-iongraph-{PROCESS_PID}`. Each file will be named `func_{ZJIT_FUNC_NAME}.json`. In order to use them in the Iongraph viewer, you'll need to use `jq` to collate them to a single file. An example invocation of `jq` is shown below for reference.

`jq --slurp --null-input '.functions=inputs | .version=2' /tmp/zjit-iongraph-{PROCESS_PID}/func*.json > ~/Downloads/ion.json`

From there, you can use https://mozilla-spidermonkey.github.io/iongraph/ to view your trace.

### Printing ZJIT Errors

`--zjit-debug` prints ZJIT compilation errors and other diagnostics:
Expand Down
9 changes: 9 additions & 0 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -7592,6 +7592,9 @@ rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)

enum gc_stat_heap_sym {
gc_stat_heap_sym_slot_size,
gc_stat_heap_sym_heap_live_slots,
gc_stat_heap_sym_heap_free_slots,
gc_stat_heap_sym_heap_final_slots,
gc_stat_heap_sym_heap_eden_pages,
gc_stat_heap_sym_heap_eden_slots,
gc_stat_heap_sym_total_allocated_pages,
Expand All @@ -7610,6 +7613,9 @@ setup_gc_stat_heap_symbols(void)
if (gc_stat_heap_symbols[0] == 0) {
#define S(s) gc_stat_heap_symbols[gc_stat_heap_sym_##s] = ID2SYM(rb_intern_const(#s))
S(slot_size);
S(heap_live_slots);
S(heap_free_slots);
S(heap_final_slots);
S(heap_eden_pages);
S(heap_eden_slots);
S(total_allocated_pages);
Expand All @@ -7631,6 +7637,9 @@ stat_one_heap(rb_heap_t *heap, VALUE hash, VALUE key)
rb_hash_aset(hash, gc_stat_heap_symbols[gc_stat_heap_sym_##name], SIZET2NUM(attr));

SET(slot_size, heap->slot_size);
SET(heap_live_slots, heap->total_allocated_objects - heap->total_freed_objects - heap->final_slots_count);
SET(heap_free_slots, heap->total_slots - (heap->total_allocated_objects - heap->total_freed_objects));
SET(heap_final_slots, heap->final_slots_count);
SET(heap_eden_pages, heap->total_pages);
SET(heap_eden_slots, heap->total_slots);
SET(total_allocated_pages, heap->total_allocated_pages);
Expand Down
2 changes: 1 addition & 1 deletion lib/error_highlight/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def prism_spot_constant_path_operator_write
# ^^^
def prism_spot_def_for_name
location = @node.name_loc
location = location.join(@node.operator_loc) if @node.operator_loc
location = @node.operator_loc.join(location) if @node.operator_loc
prism_location(location)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/command_line/dash_0_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ruby_exe("puts $/, $-0", options: "-072").should == ":\n:\n"
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "sets $/ and $-0 as a frozen string" do
ruby_exe("puts $/.frozen?, $-0.frozen?", options: "-072").should == "true\ntrue\n"
end
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/enumerable/to_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[1, 2, 3].to_set { |x| x * x }.should == Set[1, 4, 9]
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "instantiates an object of provided as the first argument set class" do
set = nil
proc{set = [1, 2, 3].to_set(EnumerableSpecs::SetSubclass)}.should complain(/Enumerable#to_set/)
Expand All @@ -20,7 +20,7 @@
end
end

ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do
it "instantiates an object of provided as the first argument set class" do
set = [1, 2, 3].to_set(EnumerableSpecs::SetSubclass)
set.should be_kind_of(EnumerableSpecs::SetSubclass)
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/file/stat/birthtime_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../../../spec_helper'

platform_is(:windows, :darwin, :freebsd, :netbsd,
*ruby_version_is("3.5") { :linux },
*ruby_version_is("4.0") { :linux },
) do
not_implemented_messages = [
"birthtime() function is unimplemented", # unsupported OS/version
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/kernel/caller_locations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
end
end

ruby_version_is "3.4"..."3.5" do
ruby_version_is "3.4"..."4.0" do
it "includes core library methods defined in Ruby" do
file, line = Kernel.instance_method(:tap).source_location
file.should.start_with?('<internal:')
Expand All @@ -95,7 +95,7 @@
end
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "does not include core library methods defined in Ruby" do
file, line = Kernel.instance_method(:tap).source_location
file.should.start_with?('<internal:')
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/kernel/caller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
end

guard -> { Kernel.instance_method(:tap).source_location } do
ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do
it "includes core library methods defined in Ruby" do
file, line = Kernel.instance_method(:tap).source_location
file.should.start_with?('<internal:')
Expand All @@ -95,7 +95,7 @@
end
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "includes core library methods defined in Ruby" do
file, line = Kernel.instance_method(:tap).source_location
file.should.start_with?('<internal:')
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/kernel/inspect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class << obj
obj.inspect.should be_kind_of(String)
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "calls #instance_variables_to_inspect private method to know which variables to display" do
obj = Object.new
obj.instance_eval do
Expand Down
11 changes: 6 additions & 5 deletions spec/ruby/core/kernel/require_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
end

provided = %w[complex enumerator fiber rational thread ruby2_keywords]
ruby_version_is "3.5" do
ruby_version_is "4.0" do
provided << "set"
provided << "pathname"
end
Expand All @@ -32,13 +32,14 @@

features.sort.should == provided.sort

ruby_version_is "3.5" do
provided.map! { |f| f == "pathname" ? "pathname.so" : f }
requires = provided
ruby_version_is "4.0" do
requires = requires.map { |f| f == "pathname" ? "pathname.so" : f }
end

code = provided.map { |f| "puts require #{f.inspect}\n" }.join
code = requires.map { |f| "puts require #{f.inspect}\n" }.join
required = ruby_exe(code, options: '--disable-gems')
required.should == "false\n" * provided.size
required.should == "false\n" * requires.size
end

it_behaves_like :kernel_require_basic, :require, CodeLoadingSpecs::Method.new
Expand Down
6 changes: 3 additions & 3 deletions spec/ruby/core/marshal/dump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _dump(level)
Marshal.dump(MarshalSpec::ClassWithOverriddenName).should == "\x04\bc)MarshalSpec::ClassWithOverriddenName"
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "dumps a class with multibyte characters in name" do
source_object = eval("MarshalSpec::MultibyteぁあぃいClass".dup.force_encoding(Encoding::UTF_8))
Marshal.dump(source_object).should == "\x04\bIc,MarshalSpec::Multibyte\xE3\x81\x81\xE3\x81\x82\xE3\x81\x83\xE3\x81\x84Class\x06:\x06ET"
Expand Down Expand Up @@ -261,7 +261,7 @@ def _dump(level)
Marshal.dump(MarshalSpec::ModuleWithOverriddenName).should == "\x04\bc*MarshalSpec::ModuleWithOverriddenName"
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "dumps a module with multibyte characters in name" do
source_object = eval("MarshalSpec::MultibyteけげこごModule".dup.force_encoding(Encoding::UTF_8))
Marshal.dump(source_object).should == "\x04\bIm-MarshalSpec::Multibyte\xE3\x81\x91\xE3\x81\x92\xE3\x81\x93\xE3\x81\x94Module\x06:\x06ET"
Expand Down Expand Up @@ -880,7 +880,7 @@ def finalizer.noop(_)
Marshal.dump(obj).should include("MarshalSpec::TimeWithOverriddenName")
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "dumps a Time subclass with multibyte characters in name" do
source_object = eval("MarshalSpec::MultibyteぁあぃいTime".dup.force_encoding(Encoding::UTF_8))
Marshal.dump(source_object).should == "\x04\bIc+MarshalSpec::Multibyte\xE3\x81\x81\xE3\x81\x82\xE3\x81\x83\xE3\x81\x84Time\x06:\x06ET"
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/method/source_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def f
eval('def self.m; end', nil, "foo", 100)
end
location = c.method(:m).source_location
ruby_version_is(""..."3.5") do
ruby_version_is(""..."4.0") do
location.should == ["foo", 100]
end
ruby_version_is("3.5") do
ruby_version_is("4.0") do
location.should == ["foo", 100, 0, 100, 15]
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/module/ruby2_keywords_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def obj.foo(*a, **b) end
}.should complain(/Skipping set of ruby2_keywords flag for/)
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "prints warning when a method accepts post arguments" do
obj = Object.new
def obj.foo(*a, b) end
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/module/set_temporary_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module m::N; end
m.name.should == "fake_name_2"
end

ruby_bug "#21094", ""..."3.5" do
ruby_bug "#21094", ""..."4.0" do
it "also updates a name of a nested module" do
m = Module.new
m::N = Module.new
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/objectspace/_id2ref_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../../spec_helper'

ruby_version_is "3.5" do
ruby_version_is "4.0" do
describe "ObjectSpace._id2ref" do
it "is deprecated" do
id = nil.object_id
Expand All @@ -11,7 +11,7 @@
end
end

ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do
describe "ObjectSpace._id2ref" do
it "converts an object id to a reference to the object" do
s = "I am a string"
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/proc/ruby2_keywords_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}.should complain(/Skipping set of ruby2_keywords flag for/)
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "prints warning when a proc accepts post arguments" do
f = -> *a, b { }

Expand Down
8 changes: 4 additions & 4 deletions spec/ruby/core/proc/source_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
end

it "works even if the proc was created on the same line" do
ruby_version_is(""..."3.5") do
ruby_version_is(""..."4.0") do
proc { true }.source_location.should == [__FILE__, __LINE__]
Proc.new { true }.source_location.should == [__FILE__, __LINE__]
-> { true }.source_location.should == [__FILE__, __LINE__]
end
ruby_version_is("3.5") do
ruby_version_is("4.0") do
proc { true }.source_location.should == [__FILE__, __LINE__, 11, __LINE__, 19]
Proc.new { true }.source_location.should == [__FILE__, __LINE__, 15, __LINE__, 23]
-> { true }.source_location.should == [__FILE__, __LINE__, 8, __LINE__, 17]
Expand Down Expand Up @@ -94,10 +94,10 @@
it "works for eval with a given line" do
proc = eval('-> {}', nil, "foo", 100)
location = proc.source_location
ruby_version_is(""..."3.5") do
ruby_version_is(""..."4.0") do
location.should == ["foo", 100]
end
ruby_version_is("3.5") do
ruby_version_is("4.0") do
location.should == ["foo", 100, 2, 100, 5]
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/process/status/bit_and_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../../../spec_helper'

ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do

describe "Process::Status#&" do
it "returns a bitwise and of the integer status of an exited child" do
Expand All @@ -17,7 +17,7 @@
end
end

ruby_version_is "3.3"..."3.5" do
ruby_version_is "3.3"..."4.0" do
it "raises an ArgumentError if mask is negative" do
suppress_warning do
ruby_exe("exit(0)")
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/process/status/right_shift_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../../../spec_helper'

ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do

describe "Process::Status#>>" do
it "returns a right shift of the integer status of an exited child" do
Expand All @@ -16,7 +16,7 @@
end
end

ruby_version_is "3.3"..."3.5" do
ruby_version_is "3.3"..."4.0" do
it "raises an ArgumentError if shift value is negative" do
suppress_warning do
ruby_exe("exit(0)")
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/range/max_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
(..1.0).max.should == 1.0
end

ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do
it "raises for an exclusive beginless Integer range" do
-> {
(...1).max
}.should raise_error(TypeError, 'cannot exclude end value with non Integer begin value')
end
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "returns the end point for exclusive beginless Integer ranges" do
(...1).max.should == 0
end
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/range/reverse_each_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
(1..3).reverse_each.size.should == 3
end

ruby_bug "#20936", "3.4"..."3.5" do
ruby_bug "#20936", "3.4"..."4.0" do
it "returns Infinity when Range size is infinite" do
(..3).reverse_each.size.should == Float::INFINITY
end
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/set/compare_by_identity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def o.hash; 123; end
set.to_a.sort.should == [a1, a2].sort
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "raises a FrozenError on frozen sets" do
set = Set.new.freeze
-> {
Expand All @@ -99,7 +99,7 @@ def o.hash; 123; end
end
end

ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do
it "raises a FrozenError on frozen sets" do
set = Set.new.freeze
-> {
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/set/divide_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
set.map{ |x| x.to_a.sort }.sort.should == [[1], [3, 4], [6], [9, 10, 11]]
end

ruby_version_is "3.5" do
ruby_version_is "4.0" do
it "yields each two Object to the block" do
ret = []
Set[1, 2].divide { |x, y| ret << [x, y] }
ret.sort.should == [[1, 2], [2, 1]]
end
end

ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do
it "yields each two Object to the block" do
ret = []
Set[1, 2].divide { |x, y| ret << [x, y] }
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/set/equal_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
set1.should == set2
end

ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do
context "when comparing to a Set-like object" do
it "returns true when a Set and a Set-like object contain the same elements" do
Set[1, 2, 3].should == SetSpecs::SetLike.new([1, 2, 3])
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/set/flatten_merge_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../../spec_helper'

describe "Set#flatten_merge" do
ruby_version_is ""..."3.5" do
ruby_version_is ""..."4.0" do
it "is protected" do
Set.should have_protected_instance_method("flatten_merge")
end
Expand Down
Loading