diff --git a/collector/benchmarks/ctfe-stress-cast/Cargo.lock b/collector/benchmarks/ctfe-stress-cast/Cargo.lock new file mode 100644 index 000000000..3f3213ba3 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-cast/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "ctfe-stress" +version = "0.1.0" + diff --git a/collector/benchmarks/ctfe-stress-cast/Cargo.toml b/collector/benchmarks/ctfe-stress-cast/Cargo.toml new file mode 100644 index 000000000..e3b83556a --- /dev/null +++ b/collector/benchmarks/ctfe-stress-cast/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "ctfe-stress" +version = "0.1.0" +authors = ["Ralf Jung "] diff --git a/collector/benchmarks/ctfe-stress-cast/src/lib.rs b/collector/benchmarks/ctfe-stress-cast/src/lib.rs new file mode 100644 index 000000000..4258f9d76 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-cast/src/lib.rs @@ -0,0 +1,42 @@ +#![feature(const_fn, const_let)] +#![allow(unused_must_use)] + +// Try to make CTFE actually do a lot of computation, without producing a big result. +// And without support for loops. + +macro_rules! const_repeat { + // Base case: Use 16 at the end to avoid function calls at the leaves as much as possibele. + ([16] $e: expr, $T: ty) => {{ + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e + }}; + ([1] $e: expr, $T: ty) => {{ + $e + }}; + // Recursive case: Take a 16 + ([16 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e() + }}; + // Recursive case: Take a 4 + ([4 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e() + }}; + // Recursive case: Take a 2 + ([2 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e() + }}; +} +macro_rules! expensive_static { + ($name: ident : $T: ty = $e : expr) => + (pub static $name : $T = const_repeat!([2 16 16 16 16 16] $e, $T);) +} + +expensive_static!(CHAIN: usize = 42i32 as u8 as u64 as i8 as isize as usize); diff --git a/collector/benchmarks/ctfe-stress-const-fn/Cargo.lock b/collector/benchmarks/ctfe-stress-const-fn/Cargo.lock new file mode 100644 index 000000000..3f3213ba3 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-const-fn/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "ctfe-stress" +version = "0.1.0" + diff --git a/collector/benchmarks/ctfe-stress-const-fn/Cargo.toml b/collector/benchmarks/ctfe-stress-const-fn/Cargo.toml new file mode 100644 index 000000000..e3b83556a --- /dev/null +++ b/collector/benchmarks/ctfe-stress-const-fn/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "ctfe-stress" +version = "0.1.0" +authors = ["Ralf Jung "] diff --git a/collector/benchmarks/ctfe-stress-const-fn/src/lib.rs b/collector/benchmarks/ctfe-stress-const-fn/src/lib.rs new file mode 100644 index 000000000..d65658850 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-const-fn/src/lib.rs @@ -0,0 +1,44 @@ +#![feature(const_fn, const_let)] +#![allow(unused_must_use)] + +// Try to make CTFE actually do a lot of computation, without producing a big result. +// And without support for loops. + +macro_rules! const_repeat { + // Base case: Use 16 at the end to avoid function calls at the leaves as much as possibele. + ([16] $e: expr, $T: ty) => {{ + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e + }}; + ([1] $e: expr, $T: ty) => {{ + $e + }}; + // Recursive case: Take a 16 + ([16 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e() + }}; + // Recursive case: Take a 4 + ([4 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e() + }}; + // Recursive case: Take a 2 + ([2 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e() + }}; +} +macro_rules! expensive_static { + ($name: ident : $T: ty = $e : expr) => + (pub static $name : $T = const_repeat!([2 16 16 16 16 16] $e, $T);) +} + +const fn inc(i: i32) -> i32 { i + 1 } + +expensive_static!(CONST_FN_SIMPLE: i32 = inc(42)); diff --git a/collector/benchmarks/ctfe-stress-force-alloc/Cargo.lock b/collector/benchmarks/ctfe-stress-force-alloc/Cargo.lock new file mode 100644 index 000000000..3f3213ba3 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-force-alloc/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "ctfe-stress" +version = "0.1.0" + diff --git a/collector/benchmarks/ctfe-stress-force-alloc/Cargo.toml b/collector/benchmarks/ctfe-stress-force-alloc/Cargo.toml new file mode 100644 index 000000000..e3b83556a --- /dev/null +++ b/collector/benchmarks/ctfe-stress-force-alloc/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "ctfe-stress" +version = "0.1.0" +authors = ["Ralf Jung "] diff --git a/collector/benchmarks/ctfe-stress-force-alloc/src/lib.rs b/collector/benchmarks/ctfe-stress-force-alloc/src/lib.rs new file mode 100644 index 000000000..29760c48e --- /dev/null +++ b/collector/benchmarks/ctfe-stress-force-alloc/src/lib.rs @@ -0,0 +1,42 @@ +#![feature(const_fn, const_let)] +#![allow(unused_must_use)] + +// Try to make CTFE actually do a lot of computation, without producing a big result. +// And without support for loops. + +macro_rules! const_repeat { + // Base case: Use 16 at the end to avoid function calls at the leaves as much as possibele. + ([16] $e: expr, $T: ty) => {{ + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e + }}; + ([1] $e: expr, $T: ty) => {{ + $e + }}; + // Recursive case: Take a 16 + ([16 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e() + }}; + // Recursive case: Take a 4 + ([4 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e() + }}; + // Recursive case: Take a 2 + ([2 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e() + }}; +} +macro_rules! expensive_static { + ($name: ident : $T: ty = $e : expr) => + (pub static $name : $T = const_repeat!([2 16 16 16 16 16] $e, $T);) +} + +expensive_static!(FORCE_ALLOC: i32 = *****(&&&&&5)); diff --git a/collector/benchmarks/ctfe-stress-index-check/Cargo.lock b/collector/benchmarks/ctfe-stress-index-check/Cargo.lock new file mode 100644 index 000000000..3f3213ba3 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-index-check/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "ctfe-stress" +version = "0.1.0" + diff --git a/collector/benchmarks/ctfe-stress-index-check/Cargo.toml b/collector/benchmarks/ctfe-stress-index-check/Cargo.toml new file mode 100644 index 000000000..e3b83556a --- /dev/null +++ b/collector/benchmarks/ctfe-stress-index-check/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "ctfe-stress" +version = "0.1.0" +authors = ["Ralf Jung "] diff --git a/collector/benchmarks/ctfe-stress-index-check/src/lib.rs b/collector/benchmarks/ctfe-stress-index-check/src/lib.rs new file mode 100644 index 000000000..d3d9b410d --- /dev/null +++ b/collector/benchmarks/ctfe-stress-index-check/src/lib.rs @@ -0,0 +1,42 @@ +#![feature(const_fn, const_let)] +#![allow(unused_must_use)] + +// Try to make CTFE actually do a lot of computation, without producing a big result. +// And without support for loops. + +macro_rules! const_repeat { + // Base case: Use 16 at the end to avoid function calls at the leaves as much as possibele. + ([16] $e: expr, $T: ty) => {{ + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e + }}; + ([1] $e: expr, $T: ty) => {{ + $e + }}; + // Recursive case: Take a 16 + ([16 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e() + }}; + // Recursive case: Take a 4 + ([4 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e() + }}; + // Recursive case: Take a 2 + ([2 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e() + }}; +} +macro_rules! expensive_static { + ($name: ident : $T: ty = $e : expr) => + (pub static $name : $T = const_repeat!([2 16 16 16 16 16] $e, $T);) +} + +expensive_static!(CHECKED_INDEX: u8 = b"foomp"[3]); diff --git a/collector/benchmarks/ctfe-stress-ops/Cargo.lock b/collector/benchmarks/ctfe-stress-ops/Cargo.lock new file mode 100644 index 000000000..3f3213ba3 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-ops/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "ctfe-stress" +version = "0.1.0" + diff --git a/collector/benchmarks/ctfe-stress-ops/Cargo.toml b/collector/benchmarks/ctfe-stress-ops/Cargo.toml new file mode 100644 index 000000000..e3b83556a --- /dev/null +++ b/collector/benchmarks/ctfe-stress-ops/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "ctfe-stress" +version = "0.1.0" +authors = ["Ralf Jung "] diff --git a/collector/benchmarks/ctfe-stress-ops/src/lib.rs b/collector/benchmarks/ctfe-stress-ops/src/lib.rs new file mode 100644 index 000000000..2872abf3e --- /dev/null +++ b/collector/benchmarks/ctfe-stress-ops/src/lib.rs @@ -0,0 +1,42 @@ +#![feature(const_fn, const_let)] +#![allow(unused_must_use)] + +// Try to make CTFE actually do a lot of computation, without producing a big result. +// And without support for loops. + +macro_rules! const_repeat { + // Base case: Use 16 at the end to avoid function calls at the leaves as much as possibele. + ([16] $e: expr, $T: ty) => {{ + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e + }}; + ([1] $e: expr, $T: ty) => {{ + $e + }}; + // Recursive case: Take a 16 + ([16 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e() + }}; + // Recursive case: Take a 4 + ([4 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e() + }}; + // Recursive case: Take a 2 + ([2 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e() + }}; +} +macro_rules! expensive_static { + ($name: ident : $T: ty = $e : expr) => + (pub static $name : $T = const_repeat!([16 16 16 16 16] $e, $T);) +} + +expensive_static!(OPS: i32 = ((((10 >> 1) + 3) * 7) / 2 - 12) << 4); diff --git a/collector/benchmarks/ctfe-stress-reloc/Cargo.lock b/collector/benchmarks/ctfe-stress-reloc/Cargo.lock new file mode 100644 index 000000000..3f3213ba3 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-reloc/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "ctfe-stress" +version = "0.1.0" + diff --git a/collector/benchmarks/ctfe-stress-reloc/Cargo.toml b/collector/benchmarks/ctfe-stress-reloc/Cargo.toml new file mode 100644 index 000000000..e3b83556a --- /dev/null +++ b/collector/benchmarks/ctfe-stress-reloc/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "ctfe-stress" +version = "0.1.0" +authors = ["Ralf Jung "] diff --git a/collector/benchmarks/ctfe-stress-reloc/src/lib.rs b/collector/benchmarks/ctfe-stress-reloc/src/lib.rs new file mode 100644 index 000000000..46a03375f --- /dev/null +++ b/collector/benchmarks/ctfe-stress-reloc/src/lib.rs @@ -0,0 +1,42 @@ +#![feature(const_fn, const_let)] +#![allow(unused_must_use)] + +// Try to make CTFE actually do a lot of computation, without producing a big result. +// And without support for loops. + +macro_rules! const_repeat { + // Base case: Use 16 at the end to avoid function calls at the leaves as much as possibele. + ([16] $e: expr, $T: ty) => {{ + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e + }}; + ([1] $e: expr, $T: ty) => {{ + $e + }}; + // Recursive case: Take a 16 + ([16 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e() + }}; + // Recursive case: Take a 4 + ([4 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e() + }}; + // Recursive case: Take a 2 + ([2 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e() + }}; +} +macro_rules! expensive_static { + ($name: ident : $T: ty = $e : expr) => + (pub static $name : $T = const_repeat!([2 16 16 16 16 16 16] $e, $T);) +} + +expensive_static!(RELOCATIONS : &'static str = "hello"); diff --git a/collector/benchmarks/ctfe-stress-unsize-slice/Cargo.lock b/collector/benchmarks/ctfe-stress-unsize-slice/Cargo.lock new file mode 100644 index 000000000..3f3213ba3 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-unsize-slice/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "ctfe-stress" +version = "0.1.0" + diff --git a/collector/benchmarks/ctfe-stress-unsize-slice/Cargo.toml b/collector/benchmarks/ctfe-stress-unsize-slice/Cargo.toml new file mode 100644 index 000000000..e3b83556a --- /dev/null +++ b/collector/benchmarks/ctfe-stress-unsize-slice/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "ctfe-stress" +version = "0.1.0" +authors = ["Ralf Jung "] diff --git a/collector/benchmarks/ctfe-stress-unsize-slice/src/lib.rs b/collector/benchmarks/ctfe-stress-unsize-slice/src/lib.rs new file mode 100644 index 000000000..3a8890b95 --- /dev/null +++ b/collector/benchmarks/ctfe-stress-unsize-slice/src/lib.rs @@ -0,0 +1,48 @@ +#![feature(const_fn, const_let)] +#![allow(unused_must_use)] + +// Try to make CTFE actually do a lot of computation, without producing a big result. +// And without support for loops. + +macro_rules! const_repeat { + // Base case: Use 16 at the end to avoid function calls at the leaves as much as possibele. + ([16] $e: expr, $T: ty) => {{ + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e; + $e; $e; $e; $e + }}; + ([1] $e: expr, $T: ty) => {{ + $e + }}; + // Recursive case: Take a 16 + ([16 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e(); + e(); e(); e(); e() + }}; + // Recursive case: Take a 8 + ([8 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e(); + e(); e(); e(); e() + }}; + // Recursive case: Take a 4 + ([4 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e(); e(); e() + }}; + // Recursive case: Take a 2 + ([2 $($n: tt)*] $e: expr, $T: ty) => {{ + const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } + e(); e() + }}; +} +macro_rules! expensive_static { + ($name: ident : $T: ty = $e : expr) => + (pub static $name : $T = const_repeat!([16 16 16 16 16 16] $e, $T);) +} + +expensive_static!(UNSIZING: &'static [u8] = b"foo");