Skip to content

Commit e64badc

Browse files
committed
[GR-20446] [GR-13666] [GR-18163] Backports for 20.1.
PullRequest: truffleruby/1558
2 parents 7c588c7 + 79a9c69 commit e64badc

File tree

14 files changed

+67
-31
lines changed

14 files changed

+67
-31
lines changed

CHANGELOG.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,12 @@ New features:
44

55
* Nightly builds of TruffleRuby are now available, see the README for details (#1483).
66
* `||=` will not compile the right-hand-side if it's only executed once, to match the idiomatic lazy-initialisation use-case (#1887, @kipply).
7-
* The implicit interface for allowing Ruby objects to behave as polyglot arrays with `#size`, `#[]` methods has been removed and replaced with an explicit interface where each method starts with `polyglot_*`.
8-
* Hash keys are no longer reported as polyglot members.
9-
* All remaining implicit polyglot behaviour for `#[]` method was replaced with `polyglot_*` methods.
10-
* Rename dynamic API to match InteropLibrary. All the methods keep the name as it is in InteropLibrary with following changes: use snake_case, add `polyglot_` prefix, drop `get` and `is` prefix, append `?` on all predicates.
11-
* Many nodes that manipulate arrays have been converted to use `ArrayStoreLibrary`.
12-
* Split `Truffle::Interop.write` into `.write_array_element` and `.write_member` methods.
13-
* Rename `Truffle::Interop.size` to `.array_size`.
14-
* Rename `Truffle::Interop.is_boolean?` to `.boolean?`.
15-
* Split `Truffle::Interop.read` into `.read_member` and `.read_array_element`.
16-
* Drop `is_` prefix in `Truffle::Interop.is_array_element_*` predicates.
17-
* The old array strategy code has been removed and all remaining nodes converted to the new `ArrayStoreLibrary`.
18-
* `Truffle::Interop.hash_keys_as_members` has been added to treat a Ruby Hash as a polyglot object with the Hash keys as members.
197
* Added `--metrics-profile-require` option to profile searching, parsing, translating and loading files.
208
* Added support for captured variables for the Truffle instruments (e.g. Chrome debugger).
219

2210
Bug fixes:
2311

24-
* Fixed `Exception#dup` to copy exception backtrace string array.
12+
* Fixed `Exception#dup` to copy the `Exception#backtrace` string array.
2513
* Fixed `rb_warn` and `rb_warning` when used as statements (#1886, @chrisseaton).
2614
* Fixed `NameError.new` and `NoMethodError.new` `:receiver` argument.
2715
* Correctly handle large numbers of arguments to `rb_funcall` (#1882).
@@ -30,7 +18,7 @@ Bug fixes:
3018
* Fixed `SystemCallError.new` parameter conversion.
3119
* Fixed `File#{chmod, umask}` argument conversion check.
3220
* Added warning in `Hash.[]` for non-array elements.
33-
* Fixed `File.lchmod` raises `NotImplementedError` when not available.
21+
* Fixed `File.lchmod` to raise `NotImplementedError` when not available.
3422
* `RSTRING_PTR()` now always returns a native pointer, resolving two bugs `memcpy`ing to (#1822) and from (#1772) Ruby Strings.
3523
* Fixed issue with duping during splat (#1883).
3624
* Fixed `Dir#children` implementation.
@@ -50,12 +38,12 @@ Bug fixes:
5038
* Updated `Kernel.Float()` to return given string in error message (#1945).
5139
* Parameters and arity of methods derived from `method_missing` should now match MRI (#1921).
5240
* Fixed compile error in `RB_FLOAT_TYPE_P` macro (#1928).
53-
* Fixed `Symbol#match` to call block with match data (#1933).
41+
* Fixed `Symbol#match` to call the block with the `MatchData` (#1933).
5442
* Fixed `Digest::SHA2.hexdigest` error with long messages (#1922).
5543
* Fixed `Date.parse` to dup the coerced string to not modify original (#1946).
5644
* Update `Comparable` error messages for special constant values (#1941).
5745
* Fixed `File.ftype` parameter conversion (#1961).
58-
* Fixed `Digest::Instance#file` to not modify string literal (#1964).
46+
* Fixed `Digest::Instance#file` to not modify string literals (#1964).
5947
* Make sure that string interpolation returns a `String`, and not a subclass (#1950).
6048
* `alias_method` and `instance_methods` should now work correctly inside a refinement (#1942).
6149
* Fixed `Regexp.union` parameter conversion (#1963).
@@ -64,7 +52,7 @@ Bug fixes:
6452
* `rb_encoding->name` can now be read even if the `rb_encoding` is stored in native memory.
6553
* Detect and cut off recursion when inspecting a foreign object, substituting an ellipsis instead.
6654
* Fixed feature lookup order on load path.
67-
* Fixed feature lookup order to check every `$LOAD_PATH` path entry for `.rb`, then every entry for native extension when require called with no extension.
55+
* Fixed feature lookup order to check every `$LOAD_PATH` path entry for `.rb`, then every entry for native extension when `require` is called with no extension.
6856
* Define the `_DARWIN_C_SOURCE` macro in extension makefiles (#1592).
6957
* Change handling of var args in `rb_rescue2` to handle usage in C extensions (#1823).
7058
* Fixed incorrect `Encoding::CompatibilityError` raised for some interpolated Regexps (#1967).
@@ -76,7 +64,6 @@ Bug fixes:
7664
* Fix issue where interpolated string matched `#` within string as being a variable (#1495).
7765
* Fix `File.join` to raise error on strings with null bytes.
7866
* Fix initialization of Ruby Thread for foreign thread created in Java.
79-
* Fix circular require in `bundler/index` patch.
8067

8168
Compatibility:
8269

@@ -127,16 +114,25 @@ Compatibility:
127114
* Implemented `rb_tracepoint_new`, `rb_tracepoint_disable`, `rb_tracepoint_enable`, and `rb_tracepoint_enabled_p` (#1450).
128115
* Implemented `RbConfig::CONFIG['AR']` and `RbConfig::CONFIG['STRIP']` (#1973).
129116
* Not yet implemented C API functions are now correctly detected as missing via `mkmf`'s `have_func` (#1980).
130-
* Do not define unsupported C-API TracePoint events to let C extensions detect it (#1983).
117+
* Accept `RUBY_INTERNAL_EVENT_{NEWOBJ,FREEOBJ}` events but warn they are not triggered (#1978, #1983).
131118
* `IO.copy_stream(in, STDOUT)` now writes to `STDOUT` without buffering like MRI.
132119
* Implemented `RbConfig['vendordir']`.
120+
* Implemented `Enumerator::ArithmeticSequence`.
133121

134122
Changes:
135123

136124
* `TRUFFLERUBY_RESILIENT_GEM_HOME` has been removed. Unset `GEM_HOME` and `GEM_PATH` instead if you need to.
137-
* Implemented `Enumerator::ArithmeticSequence`.
138-
* `Truffle::System.full_memory_barrier`, `Truffle::Primitive.logical_processors`, and `Truffle::AtomicReference` have been removed.
139-
* Updated `nil` to be a global immutable singleton (#1835).
125+
* The deprecated `Truffle::System.full_memory_barrier`, `Truffle::Primitive.logical_processors`, and `Truffle::AtomicReference` have been removed.
126+
* The implicit interface for allowing Ruby objects to behave as polyglot arrays with `#size`, `#[]` methods has been removed and replaced with an explicit interface where each method starts with `polyglot_*`.
127+
* Hash keys are no longer reported as polyglot members.
128+
* All remaining implicit polyglot behaviour for `#[]` method was replaced with `polyglot_*` methods.
129+
* Rename dynamic API to match InteropLibrary. All the methods keep the name as it is in InteropLibrary with the following changes: use snake_case, add `polyglot_` prefix, drop `get` and `is` prefix, append `?` on all predicates.
130+
* Split `Truffle::Interop.write` into `.write_array_element` and `.write_member` methods.
131+
* Rename `Truffle::Interop.size` to `.array_size`.
132+
* Rename `Truffle::Interop.is_boolean?` to `.boolean?`.
133+
* Split `Truffle::Interop.read` into `.read_member` and `.read_array_element`.
134+
* Drop `is_` prefix in `Truffle::Interop.is_array_element_*` predicates.
135+
* `Truffle::Interop.hash_keys_as_members` has been added to treat a Ruby Hash as a polyglot object with the Hash keys as members.
140136

141137
Performance:
142138

@@ -146,6 +142,8 @@ Performance:
146142
* Ruby objects passed to C extensions are now converted less often to native handles.
147143
* Calling blocking system calls and running C code with unblocking actions has been refactored to remove some optimisation boundaries.
148144
* `return` expressions are now rewritten as implicit return expressions where control flow allows this to be safely done as a tail optimisation. This can improve interpreter performance by up to 50% in some benchmarks, and can be applied to approximately 80% of return nodes seen in Rails and its dependencies (#1977).
145+
* The old array strategy code has been removed and all remaining nodes converted to the new `ArrayStoreLibrary`.
146+
* Updated `nil` to be a global immutable singleton (#1835).
149147

150148
# 20.0.0
151149

lib/cext/include/ruby/ruby.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,10 +2456,8 @@ int ruby_native_thread_p(void);
24562456
#define RUBY_INTERNAL_EVENT_SWITCH 0x040000
24572457
#define RUBY_EVENT_SWITCH 0x040000 /* obsolete name. this macro is for compatibility */
24582458
/* 0x080000 */
2459-
#ifndef TRUFFLERUBY
24602459
#define RUBY_INTERNAL_EVENT_NEWOBJ 0x100000
24612460
#define RUBY_INTERNAL_EVENT_FREEOBJ 0x200000
2462-
#endif
24632461
#define RUBY_INTERNAL_EVENT_GC_START 0x400000
24642462
#define RUBY_INTERNAL_EVENT_GC_END_MARK 0x800000
24652463
#define RUBY_INTERNAL_EVENT_GC_END_SWEEP 0x1000000

lib/patches/bundler/index.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ def search_by_dependency(dependency, base = nil)
1515
if base # allow all platforms when searching from a lockfile
1616
dependency.matches_spec?(spec)
1717
else
18-
dependency.matches_spec?(spec) && Gem::Platform.match_spec?(spec)
18+
if Gem::Platform.respond_to? :match_spec?
19+
dependency.matches_spec?(spec) && Gem::Platform.match_spec?(spec)
20+
else
21+
dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform)
22+
end
1923
end
2024
end
2125

lib/truffle/truffle/cext.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,14 +928,26 @@ def rb_tracepoint_new(events, func, data)
928928

929929
def events_to_events_array(events)
930930
events_ary = []
931-
if events & 0x0001 != 0
931+
if events.anybits? 0x0001
932932
events ^= 0x0001
933933
events_ary << :line
934934
end
935-
if events & 0x0002 != 0
935+
if events.anybits? 0x0002
936936
events ^= 0x0002
937937
events_ary << :class
938938
end
939+
940+
if events.anybits? 0x100000
941+
events ^= 0x100000
942+
warn 'warning: rb_tracepoint_new(RUBY_INTERNAL_EVENT_NEWOBJ) is not yet implemented' if $VERBOSE
943+
events_ary << :never
944+
end
945+
if events.anybits? 0x200000
946+
events ^= 0x200000
947+
warn 'warning: rb_tracepoint_new(RUBY_INTERNAL_EVENT_FREEOBJ) is not yet implemented' if $VERBOSE
948+
events_ary << :never
949+
end
950+
939951
raise ArgumentError, "unknown event #{'%#x' % events}" unless events == 0
940952
events_ary
941953
end

spec/ruby/core/kernel/require_relative_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@
9090
ScratchPad.recorded.should == []
9191
end
9292

93+
it "raises a LoadError that includes the missing path" do
94+
missing_path = "#{@dir}/nonexistent.rb"
95+
expanded_missing_path = File.expand_path(missing_path, File.dirname(__FILE__))
96+
-> { require_relative(missing_path) }.should raise_error(LoadError) { |e|
97+
e.message.should include(expanded_missing_path)
98+
e.path.should == expanded_missing_path
99+
}
100+
ScratchPad.recorded.should == []
101+
end
102+
93103
it "raises a LoadError if basepath does not exist" do
94104
-> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
95105
end

src/main/c/cext/ruby.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3410,9 +3410,12 @@ int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optiona
34103410
return extracted;
34113411
}
34123412

3413+
FILE *rb_io_stdio_file(rb_io_t *fptr) {
3414+
rb_tr_error("rb_io_stdio_file not yet implemented");
3415+
}
3416+
34133417
#ifndef HAVE_GNU_QSORT_R
34143418
typedef int (cmpfunc_t)(const void*, const void*, void*);
3415-
34163419
#endif
34173420

34183421
#undef rb_intern

src/main/java/org/truffleruby/RubyLanguage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
TraceManager.CallTag.class,
5959
TraceManager.ClassTag.class,
6060
TraceManager.LineTag.class,
61+
TraceManager.NeverTag.class,
6162
StandardTags.RootTag.class,
6263
StandardTags.StatementTag.class,
6364
StandardTags.CallTag.class

src/main/java/org/truffleruby/core/kernel/TraceManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public static class CallTag extends Tag {
4646
public static class ClassTag extends Tag {
4747
}
4848

49+
/** A tag which applies to no Node, but is useful to handle not-yet-implemented TracePoint events. */
50+
public static class NeverTag extends Tag {
51+
}
52+
4953
private final RubyContext context;
5054
private final Instrumenter instrumenter;
5155
private final CyclicAssumption unusedAssumption;

src/main/java/org/truffleruby/core/string/CoreStrings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class CoreStrings {
4545
public final CoreString MULTIPLY;
4646
public final CoreString NEGATIVE_ARRAY_SIZE;
4747
public final CoreString NEGATIVE_STRING_SIZE;
48+
public final CoreString NEVER;
4849
public final CoreString NIL;
4950
public final CoreString ONE_HASH_REQUIRED;
5051
public final CoreString PIPE;
@@ -102,6 +103,7 @@ public CoreStrings(RubyContext context) {
102103
MULTIPLY = new CoreString(context, "*");
103104
NEGATIVE_ARRAY_SIZE = new CoreString(context, "negative array size");
104105
NEGATIVE_STRING_SIZE = new CoreString(context, "negative string size (or size too big)");
106+
NEVER = new CoreString(context, "never");
105107
NIL = new CoreString(context, "nil");
106108
ONE_HASH_REQUIRED = new CoreString(context, "one hash required");
107109
PIPE = new CoreString(context, "|");

src/main/java/org/truffleruby/core/tracepoint/TracePointNodes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ private TracePointEvent createEvents(DynamicObject eventSymbol) {
7474
return new TracePointEvent(TraceManager.LineTag.class, eventSymbol);
7575
} else if (eventSymbol == coreStrings().CLASS.getSymbol()) {
7676
return new TracePointEvent(TraceManager.ClassTag.class, eventSymbol);
77+
} else if (eventSymbol == coreStrings().NEVER.getSymbol()) {
78+
return new TracePointEvent(TraceManager.NeverTag.class, eventSymbol);
7779
} else {
7880
throw new UnsupportedOperationException(Layouts.SYMBOL.getString(eventSymbol));
7981
}

0 commit comments

Comments
 (0)