Skip to content

Commit 599f4c7

Browse files
authored
Merge branch 'master' into compat/Feature#19036
2 parents 328f508 + bb05e0b commit 599f4c7

File tree

105 files changed

+9601
-5175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+9601
-5175
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ test/mri/tests/cext-c/**/depend
8888
# Diagnostic output directory
8989
dumps/
9090
graal_dumps/
91+
/native-image-build-rubyvm.json
9192

9293
# Profiling
9394
profiles/

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ New features:
55

66
Bug fixes:
77

8+
* Fix `rb_enc_left_char_head()` so it is not always `ArgumentError` (#3267, @eregon).
9+
* Fix `IO.copy_stream` with a `Tempfile` destination (#3280, @eregon).
810

911
Compatibility:
1012

1113
* Add `Exception#detailed_message` method (#3257, @andrykonchin).
14+
* Fix `rb_enc_vsprintf` and force String encoding instead of converting it (@andrykonchin).
15+
* Add `rb_gc_mark_movable` function (@andrykonchin).
1216
* Promoted `File#path` and `File#to_path` to `IO#path` and `IO#to_path` and made IO#new accept an optional `path:` keyword argument (#3275, @moste00)
1317

18+
1419
Performance:
1520

21+
* Optimize calls with `ruby2_keywords` forwarding by deciding it per call site instead of per callee thanks to [my fix in CRuby 3.2](https://bugs.ruby-lang.org/issues/18625) (@eregon).
22+
* Optimize feature loading when require is called with an absolute path to a .rb file (@rwstauner).
1623

1724
Changes:
1825

ci/common.jsonnet

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,50 @@ local common_json = import "../common.json";
88
{
99
# JDK definitions
1010
# ***************
11+
local jdk_base = {
12+
name: error "name not set", # string; The JDK provider, e.g. "jpg-jdk", "labsjdk"
13+
version: error "version not set", # string; Full version string, e.g., "ce-21+35-jvmci-23.1-b15"
14+
jdk_version:: error "jdk_version not set", # int; The major JDK version, e.g., 21
15+
jdk_name:: "jdk%d" % self.jdk_version, # string; The major JDK version with the JDK prefix.
16+
# For the latest (unreleased) this should be overridden with "jdk-latest"
17+
# otherwise the jdk_version with the "jdk" prefix, e.g., "jdk21".
18+
# This should be use for constructing CI job names.
19+
# Optional:
20+
# "build_id": "33",
21+
# "release": true,
22+
# "platformspecific": true,
23+
# "extrabundles": ["static-libs"],
24+
},
25+
# ***************
1126
local variants(name) = [name, name + "Debug", name + "-llvm"],
27+
# gets the JDK major version from a labsjdk version string (e.g., "ce-21+35-jvmci-23.1-b15" -> 21)
28+
local parse_labsjdk_version(version) =
29+
assert std.startsWith(version, "ce-") || std.startsWith(version, "ee-") : "Unsupported labsjdk version: " + version;
30+
local number_prefix(str) =
31+
if std.length(str) == 0 || std.length(std.findSubstr(str[0], "0123456789")) == 0 then
32+
""
33+
else
34+
str[0] + number_prefix(str[1:])
35+
;
36+
std.parseInt(number_prefix(version[3:]))
37+
,
1238
local jdks_data = {
13-
oraclejdk11: common_json.jdks["oraclejdk11"] + { jdk_version:: 11 },
39+
oraclejdk11: jdk_base + common_json.jdks["oraclejdk11"] + { jdk_version:: 11 },
1440
} + {
15-
[name]: common_json.jdks[name] + { jdk_version:: 17 }
41+
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: 17 }
1642
for name in ["oraclejdk17"] + variants("labsjdk-ce-17") + variants("labsjdk-ee-17")
1743
} + {
18-
[name]: common_json.jdks[name] + { jdk_version:: 19 }
44+
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: 19 }
1945
for name in ["oraclejdk19"] + variants("labsjdk-ce-19") + variants("labsjdk-ee-19")
2046
} + {
21-
[name]: common_json.jdks[name] + { jdk_version:: 20 }
47+
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: 20 }
2248
for name in ["oraclejdk20"] + variants("labsjdk-ce-20") + variants("labsjdk-ee-20")
2349
} + {
24-
[name]: common_json.jdks[name] + { jdk_version:: 21 }
50+
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: 21 }
2551
for name in ["oraclejdk21"] + variants("labsjdk-ce-21") + variants("labsjdk-ee-21")
2652
} + {
27-
[name]: common_json.jdks[name] + { jdk_version:: 22 }
28-
for name in ["oraclejdk22"]
53+
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: parse_labsjdk_version(self.version), jdk_name:: "jdk-latest"}
54+
for name in variants("labsjdk-ce-latest") + variants("labsjdk-ee-latest")
2955
},
3056
assert std.assertEqual(std.objectFields(common_json.jdks), std.objectFields(jdks_data)),
3157

@@ -39,6 +65,7 @@ local common_json = import "../common.json";
3965
[if std.endsWith(name, "llvm") then "LLVM_JAVA_HOME" else "JAVA_HOME"]: jdks_data[name]
4066
},
4167
jdk_version:: jdks_data[name].jdk_version,
68+
jdk_name:: jdks_data[name].jdk_name,
4269
},
4370
for name in std.objectFields(jdks_data)
4471
} + {
@@ -59,7 +86,7 @@ local common_json = import "../common.json";
5986
"windows-jdk19": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
6087
"windows-jdk20": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
6188
"windows-jdk21": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
62-
"windows-jdk22": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
89+
"windows-jdkLatest": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
6390
"linux-jdk17": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
6491
"linux-jdk19": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
6592
"linux-jdk20": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},

common.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
55
],
66

7-
"mx_version": "6.46.1",
7+
"mx_version": "6.50.2",
88

99
"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
1010
"jdks": {
@@ -35,14 +35,19 @@
3535
"labsjdk-ee-20-llvm": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-sulong", "platformspecific": true },
3636

3737
"oraclejdk21": {"name": "jpg-jdk", "version": "21", "build_id": "33", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
38-
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b14", "platformspecific": true },
39-
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b14-debug", "platformspecific": true },
40-
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b14-sulong", "platformspecific": true },
41-
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b14", "platformspecific": true },
42-
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b14-debug", "platformspecific": true },
43-
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b14-sulong", "platformspecific": true },
44-
45-
"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "11", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
38+
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b15", "platformspecific": true },
39+
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b15-debug", "platformspecific": true },
40+
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b15-sulong", "platformspecific": true },
41+
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15", "platformspecific": true },
42+
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-debug", "platformspecific": true },
43+
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-sulong", "platformspecific": true },
44+
45+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01", "platformspecific": true },
46+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01-debug", "platformspecific": true },
47+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+16-jvmci-b01-sulong", "platformspecific": true },
48+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01", "platformspecific": true },
49+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01-debug", "platformspecific": true },
50+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+16-jvmci-b01-sulong", "platformspecific": true }
4651
},
4752

4853
"eclipse": {

doc/user/polyglot.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ The JVM configuration automatically has access to other languages.
2323
* [Threading and interop](#threading-and-interop)
2424
* [Embedded configuration](#embedded-configuration)
2525

26+
## Installing Other Languages
27+
28+
To use other GraalVM languages, you need the [JVM Standalone](../../README.md#getting-started).
29+
The Native Standalone does not support installing extra languages.
30+
31+
Note that `ruby`, `llvm`, the LLVM toolchain and host Java interop are available without installing anything extra.
32+
33+
Then you can install other languages with `truffleruby-polyglot-get $LANGUAGE`, for instance:
34+
```bash
35+
truffleruby-polyglot-get js
36+
truffleruby-polyglot-get python
37+
truffleruby-polyglot-get wasm
38+
truffleruby-polyglot-get java # for Java on Truffle (aka Espresso)
39+
```
40+
41+
In TruffleRuby versions before 23.1 this was done through installing GraalVM (e.g. via `truffleruby+graalvm`) and using `gu install $LANGUAGE`.
42+
2643
## Running Ruby Code from Another Language
2744

2845
When you `eval` Ruby code from the [Context API](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/Context.html) in another language and mark the `Source` as interactive, the same interactive top-level binding is used each time.
@@ -33,6 +50,8 @@ This is similar to most REPL semantics.
3350

3451
## Loading Code Written in Foreign Languages
3552

53+
Note the ruby command line needs to be passed `--polyglot` to enable access to foreign languages.
54+
3655
`Polyglot.eval(id, string)` executes code in a foreign language identified by its ID.
3756

3857
`Polyglot.eval_file(id, path)` executes code in a foreign language from a file, identified by its language ID.
@@ -249,3 +268,19 @@ Also, the experimental option `--cexts=false` can disable C extensions.
249268

250269
Note: Unlike for example pure JavaScript, Ruby is more than a self-contained expression language.
251270
It has a large core library that includes low-level I/O and system and native-memory routines which may interfere with other embedded contexts or the host system.
271+
272+
## Inner Contexts
273+
274+
TruffleRuby supports creating *inner contexts*, that is multiple isolated execution/evaluation contexts (this is generally supported in GraalVM languages).
275+
Conceptually it is similar to running multiple Ruby interpreters in the same process.
276+
This can also be used with other languages, so for instance the outer/default context might run some Ruby code and some inner contexts run JavaScript code.
277+
This is very useful to interoperate with languages which do not support shared-memory multithreading like JavaScript, as one can then create one or more inner contexts per thread and still have the outer context use multithreaded Ruby.
278+
279+
Objects from an inner context can be passed to other contexts and they are treated as foreign objects:
280+
```ruby
281+
Polyglot::InnerContext.new do |context|
282+
context.eval('ruby', "p Object.new") # prints #<Object:0xd8>
283+
p context.eval('ruby', "Object.new") # prints #<Polyglot::ForeignObject[Ruby] Object:0x131d576b>
284+
end
285+
```
286+
This works by automatically wrapping every object leaving its context in a proxy, which means e.g. if a method is called on a foreign object it is executed in the context to which the object belongs.

lib/cext/ABI_check.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4
1+
6

lib/cext/ABI_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1
1+
3

lib/cext/include/ruby/internal/arithmetic/fixnum.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@
4040
* represent is 4,611,686,018,427,387,904, which is not fixable. The
4141
* seemingly-strange "< FIXNUM_MAX + 1" expression below is due to this.
4242
*/
43-
#ifdef TRUFFLERUBY
44-
#define RB_POSFIXABLE(f) ((f) <= RUBY_FIXNUM_MAX)
45-
#else
4643
#define RB_POSFIXABLE(_) ((_) < RUBY_FIXNUM_MAX + 1)
47-
#endif
4844

4945
/**
5046
* Checks if the passed value is in range of fixnum, assuming it is a negative
@@ -55,15 +51,10 @@
5551
/** Checks if the passed value is in range of fixnum */
5652
#define RB_FIXABLE(_) (RB_POSFIXABLE(_) && RB_NEGFIXABLE(_))
5753

58-
#ifdef TRUFFLERUBY
59-
#define RUBY_FIXNUM_MAX LONG_MAX
60-
#define RUBY_FIXNUM_MIN LONG_MIN
61-
#else
6254
/** Maximum possible value that a fixnum can represent. */
6355
#define RUBY_FIXNUM_MAX (LONG_MAX / 2)
6456

6557
/** Minimum possible value that a fixnum can represent. */
6658
#define RUBY_FIXNUM_MIN (LONG_MIN / 2)
67-
#endif /* TRUFFLERUBY */
6859

6960
#endif /* RBIMPL_ARITHMETIC_FIXNUM_H */

lib/cext/include/ruby/internal/arithmetic/long.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ RBIMPL_ATTR_ARTIFICIAL()
120120
static inline VALUE
121121
RB_INT2FIX(long i)
122122
{
123-
#ifdef TRUFFLERUBY
124-
return rb_tr_longwrap(i);
125-
#else
126123
RBIMPL_ASSERT_OR_ASSUME(RB_FIXABLE(i));
127124

128125
/* :NOTE: VALUE can be wider than long. As j being unsigned, 2j+1 is fully
@@ -135,7 +132,6 @@ RB_INT2FIX(long i)
135132

136133
RBIMPL_ASSERT_OR_ASSUME(RB_FIXNUM_P(n));
137134
return n;
138-
#endif
139135
}
140136

141137
/**

mx.truffleruby/env_files.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ Here is how the various env files relate to each other:
55
* `jvm-ce-libgraal`: + libgraal
66
* `native`: + librubyvm + `Truffle Macro`
77
* `native-host-inlining`: + `TruffleHostInliningPrintExplored`, - native toolchain launchers
8-
* `jvm-ee`: + Oracle GraalVM Compiler + `Truffle enterprise`
8+
* `native-profiling`: + `-H:-DeleteLocalSymbols`
9+
* `jvm-ee`: + Oracle GraalVM Compiler + `Truffle enterprise` + license + `LLVM Runtime Native Enterprise`
910
* `jvm-ee-ntl`: + native toolchain launchers
1011
* `jvm-ee-libgraal`: + libgraal
1112
* `native-ee`: + librubyvm + `Truffle Macro Enterprise` + Native Image G1
13+
* `native-ee-host-inlining`: + `TruffleHostInliningPrintExplored`, - native toolchain launchers
1214
* `native-ee-aux`: + `AuxiliaryEngineCache`, - Native Image G1 (currently incompatible)
13-
* `jvm-gu`: + Graal Updater
1415
* `jvm-js`: + Graal.js
1516
* `jvm-py`: + GraalPython

0 commit comments

Comments
 (0)