YJIT 的新 Rust 版本与 C 版本达到了同等水平,因为它通过了所有 CRuby 测试,能够运行所有 YJIT 基准测试,并且执行类似于 C 版本(因为它以相同的方式工作并且大部分生成相同的机器代码)。甚至加入了一些设计改进,例如更细粒度的常量失效机制,预计这将对 Ruby on Rails 应用程序产生重大影响。

内核代码仓库:https://github.com/jamesmunns/pellegrino
fast_fp 项目fast_fp 提供了一组原始类型,支持对许多操作进行快速数学编译器优化。这些优化允许编译器通过放宽 IEEE 754 浮点运算的一些要求来潜在地生成更快的代码。use fast_fp::{FF32, ff32};
// Construct instances of the fast type from std's type using the convenience
// wrapper `ff32` (or `ff64`)
let four = ff32(4.0);
// or using the `From`/`Into` trait
let five: FF32 = 5.0.into();
assert_eq!(four + five, ff32(9.0));
// Most ops are also implemented to work with std's floats too (including PartialEq).
// This makes working with literals easier.
assert_eq!(five + 6.0, 11.0);
assert_eq!(five * 2.0, 10.0);
// Functions can be made generic to accept std or fast types using `num-traits`
use num_traits::real::Real;
fn square<T: Real>(num: T) -> T {
num * num
}
assert_eq!(square(3.0_f32), 9.0);
assert_eq!(square(five), 25.0);
// If the nalgebra feature (with version suffix) is enabled, interop with
// nalgebra is supported
# #[cfg(feature = "nalgebra_v029")]
use nalgebra_v029 as na;
# #[cfg(feature = "nalgebra_v029")]
assert_eq!(na::Matrix3::repeat(four).sum(), 36.0);
From 日报小组 @Jancd
原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。