Skip to content

Commit f46b1c3

Browse files
Merge branch 'main' into update-to-rust-1.90.0
2 parents fcdc977 + a71f07f commit f46b1c3

File tree

8 files changed

+73
-65
lines changed

8 files changed

+73
-65
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
# we specify bash to get pipefail; it guards against the `curl` command
6767
# failing. otherwise `sh` won't catch that `curl` returned non-0
6868
shell: bash
69-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.29.0/cargo-dist-installer.sh | sh"
69+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.0/cargo-dist-installer.sh | sh"
7070
- name: Cache dist
7171
uses: actions/upload-artifact@v4
7272
with:

Cargo.lock

Lines changed: 38 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ byteorder = "1.5.0"
4141
byte-unit = "5.1.6"
4242
clap = "4.5.48"
4343
console = "0.16.1"
44-
cranelift = "0.123.2"
44+
cranelift = "0.124.1"
4545
criterion = { version = "0.7.0", default-features = false }
4646
dashmap = "6.1.0"
4747
dirs = "6.0.0"

dist-workspace.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cargo-auditable = false
88
# Whether to use cargo-cyclonedx to generate an SBOM
99
cargo-cyclonedx = true
1010
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
11-
cargo-dist-version = "0.29.0"
11+
cargo-dist-version = "0.30.0"
1212
# CI backends to support
1313
ci = "github"
1414
# Whether dist should create a Github Release or use an existing draft

examples/embedded_jvm/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async fn common_main() -> Result<()> {
2222
let cargo_manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
2323
let class_path = ClassPath::from(&[cargo_manifest_dir]);
2424
let configuration = ConfigurationBuilder::new()
25-
.class_path(class_path.clone())
25+
.class_path(class_path)
2626
.main_class("HelloWorld")
2727
.build()?;
2828
let vm = VM::new(configuration).await?;

ristretto_vm/src/intrinsic_methods/jdk/internal/util/systemprops_raw.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pub(crate) async fn platform_properties(
3232
push_property(system_properties, &mut properties, "user.language")?;
3333
push_property(system_properties, &mut properties, "user.script")?;
3434
push_property(system_properties, &mut properties, "user.variant")?;
35-
push_property(system_properties, &mut properties, "native.encoding")?;
35+
if java_version < JAVA_25.java() {
36+
push_property(system_properties, &mut properties, "native.encoding")?;
37+
}
3638
push_property(system_properties, &mut properties, "file.separator")?;
3739
push_property(system_properties, &mut properties, "format.country")?;
3840
push_property(system_properties, &mut properties, "format.language")?;
@@ -48,6 +50,9 @@ pub(crate) async fn platform_properties(
4850
push_property(system_properties, &mut properties, "https.proxyPort")?;
4951
push_property(system_properties, &mut properties, "java.io.tmpdir")?;
5052
push_property(system_properties, &mut properties, "line.separator")?;
53+
if java_version >= JAVA_25.java() {
54+
push_property(system_properties, &mut properties, "native.encoding")?;
55+
}
5156
push_property(system_properties, &mut properties, "os.arch")?;
5257
push_property(system_properties, &mut properties, "os.name")?;
5358
push_property(system_properties, &mut properties, "os.version")?;

ristretto_vm/src/startup_trace.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[cfg(feature = "startup-trace")]
2-
use std::sync::{LazyLock, Mutex};
2+
use std::sync::{LazyLock, Mutex, OnceLock};
33
#[cfg(feature = "startup-trace")]
44
use std::time::{Duration, Instant};
55

@@ -13,7 +13,7 @@ pub static ENABLED: LazyLock<bool> = LazyLock::new(|| {
1313

1414
// First-call timestamp (set exactly on the first trace call)
1515
#[cfg(feature = "startup-trace")]
16-
static START: LazyLock<Mutex<Option<Instant>>> = LazyLock::new(|| Mutex::new(None));
16+
static START: OnceLock<Instant> = OnceLock::new();
1717

1818
// Previous-call timestamp
1919
#[cfg(feature = "startup-trace")]
@@ -28,40 +28,32 @@ pub fn startup_trace_log(message: &str) {
2828
}
2929

3030
let now = Instant::now();
31-
let mut start_guard = START.lock().expect("failed to lock START");
3231
let mut last_guard = LAST.lock().expect("failed to lock LAST");
32+
let start = START.get_or_init(|| {
33+
*last_guard = Some(now);
34+
now
35+
});
3336

34-
if start_guard.is_none() {
35-
*start_guard = Some(now);
37+
if let Some(last) = *last_guard {
38+
let delta_elapsed = now.checked_duration_since(last).unwrap_or(Duration::ZERO);
39+
let start_elapsed = now.checked_duration_since(*start).unwrap_or(Duration::ZERO);
40+
*last_guard = Some(now);
41+
println!("[startup]{message}: +{delta_elapsed:.3?} (Σ {start_elapsed:.3?})");
42+
} else {
3643
*last_guard = Some(now);
3744
println!(
3845
"[startup]{message}: +{:.3?} (Σ {:.3?})",
3946
Duration::ZERO,
4047
Duration::ZERO
4148
);
42-
return;
4349
}
44-
45-
let start = start_guard.expect("START should be initialized");
46-
let last = last_guard.expect("LAST should be initialized");
47-
let delta_elapsed = now.checked_duration_since(last).unwrap_or(Duration::ZERO);
48-
let start_elapsed = now.checked_duration_since(start).unwrap_or(Duration::ZERO);
49-
50-
*last_guard = Some(now);
51-
52-
println!("[startup]{message}: +{delta_elapsed:.3?} (Σ {start_elapsed:.3?})");
5350
}
5451

55-
/// No-op version when the feature is disabled; zero code generation.
56-
#[doc(hidden)]
57-
#[cfg(not(feature = "startup-trace"))]
58-
#[inline(always)]
59-
pub fn startup_trace_log(_message: &str) {}
60-
6152
/// Log a startup phase message and the time elapsed since the last `startup_trace!()` call.
6253
#[macro_export]
6354
macro_rules! startup_trace {
6455
($msg:expr) => {{
56+
#[cfg(feature = "startup-trace")]
6557
$crate::startup_trace::startup_trace_log($msg);
6658
}};
6759
}

ristretto_vm/tests/hello_world.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use ristretto_vm::{ClassPath, ConfigurationBuilder, Result, VM};
2+
use std::io::Cursor;
23
use std::path::PathBuf;
4+
use std::sync::Arc;
5+
use tokio::sync::Mutex;
36

47
async fn test_helloworld(java_verison: &str) -> Result<()> {
58
let cargo_manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@@ -8,15 +11,23 @@ async fn test_helloworld(java_verison: &str) -> Result<()> {
811
.join("classes")
912
.join("classes.jar");
1013
let class_path = ClassPath::from(&[classes_jar_path]);
14+
let stdout_buffer = Arc::new(Mutex::new(Cursor::new(Vec::<u8>::new())));
15+
1116
let configuration = ConfigurationBuilder::new()
1217
.class_path(class_path.clone())
1318
.main_class("HelloWorld")
1419
.java_version(java_verison)
20+
.stdout(stdout_buffer.clone())
1521
.build()?;
1622
let vm = VM::new(configuration).await?;
17-
let parameters: Vec<&str> = Vec::new();
23+
let parameters = vec!["world!"];
24+
1825
let result = vm.invoke_main(&parameters).await?;
1926
assert!(result.is_none());
27+
let output = stdout_buffer.lock().await;
28+
let output_bytes = output.get_ref();
29+
let output_str = String::from_utf8(output_bytes.clone()).expect("Invalid UTF-8 output");
30+
assert_eq!(output_str.trim(), "Hello world!");
2031
Ok(())
2132
}
2233

0 commit comments

Comments
 (0)