Skip to content

Commit

Permalink
Import third party collections and use internal Allocator API (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog authored Sep 24, 2023
1 parent e98eaca commit 481fd86
Show file tree
Hide file tree
Showing 195 changed files with 43,838 additions and 2,987 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo build --workspace

miri:
miri_rune:
runs-on: ubuntu-latest
needs: basics
steps:
Expand All @@ -71,7 +71,18 @@ jobs:
with:
components: miri
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly miri test -p rune --all-features -- runtime hir::arena
- run: cargo miri test -p rune --all-features -- runtime hir::arena

miri_rune_alloc:
runs-on: ubuntu-latest
needs: basics
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri
- uses: Swatinem/rust-cache@v2
- run: cargo miri test -p rune-alloc --all-features

no_default_features:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -108,7 +119,7 @@ jobs:

test:
runs-on: ubuntu-latest
needs: [no_default_features, build_feature, docs, msrv, miri, wasm]
needs: [no_default_features, build_feature, docs, msrv, miri_rune, miri_rune_alloc, wasm]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
Expand Down
9 changes: 7 additions & 2 deletions benches/benches/benchmarks/aoc_2020_19b.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use criterion::Criterion;

use rune::alloc::TryClone;

criterion::criterion_group!(benches, aoc_2020_19b);

const INPUT: &str = include_str!("data/aoc_2020_19b.txt");
Expand All @@ -8,7 +10,7 @@ fn aoc_2020_19b(b: &mut Criterion) {
let mut data = rune::runtime::Vec::new();

for line in INPUT.split('\n').filter(|s| !s.is_empty()) {
data.push(line.to_owned().into());
data.push(rune::to_value(line.to_owned()).unwrap()).unwrap();
}

let mut vm = rune_vm! {
Expand Down Expand Up @@ -234,6 +236,9 @@ fn aoc_2020_19b(b: &mut Criterion) {
let entry = rune::Hash::type_hash(["main"]);

b.bench_function("aoc_2020_19b", |b| {
b.iter(|| vm.call(entry, (data.clone(),)).expect("failed call"));
b.iter(|| {
vm.call(entry, (data.try_clone().unwrap(),))
.expect("failed call")
});
});
}
6 changes: 5 additions & 1 deletion benches/benches/benchmarks/aoc_2020_1a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use anyhow::Context;
use criterion::Criterion;
use rune::alloc::TryClone;

criterion::criterion_group!(benches, aoc_2020_1a);

Expand Down Expand Up @@ -86,6 +87,9 @@ fn aoc_2020_1a(b: &mut Criterion) {
let entry = rune::Hash::type_hash(["main"]);

b.bench_function("aoc_2020_1a", |b| {
b.iter(|| vm.call(entry, (data.clone(),)).expect("failed call"));
b.iter(|| {
vm.call(entry, (data.try_clone().unwrap(),))
.expect("failed call")
});
});
}
7 changes: 6 additions & 1 deletion benches/benches/benchmarks/aoc_2020_1b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use criterion::Criterion;

use rune::alloc::TryClone;

criterion::criterion_group!(benches, aoc_2020_1b);

const INPUT: &str = include_str!("data/aoc_2020_1.txt");
Expand Down Expand Up @@ -60,6 +62,9 @@ fn aoc_2020_1b(b: &mut Criterion) {
let entry = rune::Hash::type_hash(["main"]);

b.bench_function("aoc_2020_1b", |b| {
b.iter(|| vm.call(entry, (data.clone(),)).expect("failed call"));
b.iter(|| {
vm.call(entry, (data.try_clone().unwrap(),))
.expect("failed call")
});
});
}
1 change: 1 addition & 0 deletions crates/rune-alloc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/patches/
26 changes: 26 additions & 0 deletions crates/rune-alloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "rune-alloc"
version = "0.12.3"
authors = ["John-John Tedro <[email protected]>"]
edition = "2021"
rust-version = "1.70"
description = "The Rune Language, an embeddable dynamic programming language for Rust."
documentation = "https://docs.rs/rune"
readme = "README.md"
homepage = "https://github.com/rune-rs/rune"
repository = "https://github.com/rune-rs/rune"
license = "MIT OR Apache-2.0"
keywords = ["language", "scripting", "scripting-language"]
categories = ["parser-implementations"]

[features]
default = ["std", "serde"]
std = ["alloc", "ahash/std"]
alloc = []

[dependencies]
serde = { version = "1.0", optional = true }
ahash = { version = "0.8.3", default-features = false }

[dev-dependencies]
rand = { version = "0.8.5", features = ["small_rng"] }
Loading

0 comments on commit 481fd86

Please sign in to comment.