Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ fn instrument_function_attr<'ll>(
}

fn nojumptables_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> Option<&'ll Attribute> {
if !sess.opts.unstable_opts.no_jump_tables {
if sess.opts.cg.jump_tables {
return None;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ fn test_codegen_options_tracking_hash() {
tracked!(force_frame_pointers, FramePointer::Always);
tracked!(force_unwind_tables, Some(true));
tracked!(instrument_coverage, InstrumentCoverage::Yes);
tracked!(jump_tables, false);
tracked!(link_dead_code, Some(true));
tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
Expand Down Expand Up @@ -831,7 +832,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(mutable_noalias, false);
tracked!(next_solver, NextSolverConfig { coherence: true, globally: true });
tracked!(no_generate_arange_section, true);
tracked!(no_jump_tables, true);
tracked!(no_link, true);
tracked!(no_profiler_runtime, true);
tracked!(no_trait_vptr, true);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,8 @@ options! {
"instrument the generated code to support LLVM source-based code coverage reports \
(note, the compiler build config must include `profiler = true`); \
implies `-C symbol-mangling-version=v0`"),
jump_tables: bool = (true, parse_bool, [TRACKED],
"allow jump table and lookup table generation from switch case lowering (default: yes)"),
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
"a single extra argument to append to the linker invocation (can be used several times)"),
link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
Expand Down Expand Up @@ -2475,8 +2477,6 @@ options! {
"omit DWARF address ranges that give faster lookups"),
no_implied_bounds_compat: bool = (false, parse_bool, [TRACKED],
"disable the compatibility version of the `implied_bounds_ty` query"),
no_jump_tables: bool = (false, parse_no_value, [TRACKED],
"disable the jump tables and lookup tables that can be generated from a switch case lowering"),
no_leak_check: bool = (false, parse_no_value, [UNTRACKED],
"disable the 'leak check' for subtyping; unsound, but useful for tests"),
no_link: bool = (false, parse_no_value, [TRACKED],
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_target/src/spec/base/helenos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::spec::{PanicStrategy, RelroLevel, StackProbeType, TargetOptions};

pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "helenos".into(),

dynamic_linking: true,
// we need the linker to keep libgcc and friends
no_default_libraries: false,
has_rpath: true,
relro_level: RelroLevel::Full,
panic_strategy: PanicStrategy::Abort,
stack_probes: StackProbeType::Inline,

..Default::default()
}
}
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub(crate) mod dragonfly;
pub(crate) mod freebsd;
pub(crate) mod fuchsia;
pub(crate) mod haiku;
pub(crate) mod helenos;
pub(crate) mod hermit;
pub(crate) mod hurd;
pub(crate) mod hurd_gnu;
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,12 @@ supported_targets! {
("i686-unknown-haiku", i686_unknown_haiku),
("x86_64-unknown-haiku", x86_64_unknown_haiku),

("aarch64-unknown-helenos", aarch64_unknown_helenos),
("i686-unknown-helenos", i686_unknown_helenos),
("powerpc-unknown-helenos", powerpc_unknown_helenos),
("sparc64-unknown-helenos", sparc64_unknown_helenos),
("x86_64-unknown-helenos", x86_64_unknown_helenos),

("i686-unknown-hurd-gnu", i686_unknown_hurd_gnu),
("x86_64-unknown-hurd-gnu", x86_64_unknown_hurd_gnu),

Expand Down
22 changes: 22 additions & 0 deletions compiler/rustc_target/src/spec/targets/aarch64_unknown_helenos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::spec::{Target, base};

pub(crate) fn target() -> Target {
let mut base = base::helenos::opts();
base.max_atomic_width = Some(128);
base.features = "+v8a".into();
base.linker = Some("aarch64-helenos-gcc".into());

Target {
llvm_target: "aarch64-unknown-helenos".into(),
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 HelenOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: "aarch64".into(),
options: base,
}
}
26 changes: 26 additions & 0 deletions compiler/rustc_target/src/spec/targets/i686_unknown_helenos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, Target, base};

pub(crate) fn target() -> Target {
let mut base = base::helenos::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
base.linker = Some("i686-helenos-gcc".into());
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.rustc_abi = Some(RustcAbi::X86Sse2);

Target {
llvm_target: "i686-unknown-helenos".into(),
metadata: crate::spec::TargetMetadata {
description: Some("IA-32 (i686) HelenOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
i128:128-f64:32:64-f80:32-n8:16:32-S128"
.into(),
arch: "x86".into(),
options: base,
}
}
24 changes: 24 additions & 0 deletions compiler/rustc_target/src/spec/targets/powerpc_unknown_helenos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use rustc_abi::Endian;

use crate::spec::{Target, TargetMetadata, base};

pub(crate) fn target() -> Target {
let mut base = base::helenos::opts();
base.endian = Endian::Big;
base.max_atomic_width = Some(32);
base.linker = Some("ppc-helenos-gcc".into());

Target {
llvm_target: "powerpc-unknown-helenos".into(),
metadata: TargetMetadata {
description: Some("PowerPC HelenOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: base,
}
}
26 changes: 26 additions & 0 deletions compiler/rustc_target/src/spec/targets/sparc64_unknown_helenos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use rustc_abi::Endian;

use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, base};

pub(crate) fn target() -> Target {
let mut base = base::helenos::opts();
base.endian = Endian::Big;
base.cpu = "v9".into();
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
base.linker = Some("sparc64-helenos-gcc".into());

Target {
llvm_target: "sparc64-unknown-helenos".into(),
metadata: TargetMetadata {
description: Some("SPARC HelenOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
arch: "sparc64".into(),
options: base,
}
}
25 changes: 25 additions & 0 deletions compiler/rustc_target/src/spec/targets/x86_64_unknown_helenos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::spec::{Cc, LinkerFlavor, Lld, Target, base};

pub(crate) fn target() -> Target {
let mut base = base::helenos::opts();
base.cpu = "x86-64".into();
base.plt_by_default = false;
base.max_atomic_width = Some(64);
base.linker = Some("amd64-helenos-gcc".into());
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);

Target {
llvm_target: "x86_64-unknown-helenos".into(),
metadata: crate::spec::TargetMetadata {
description: Some("64-bit HelenOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
data_layout:
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
arch: "x86_64".into(),
options: base,
}
}
80 changes: 80 additions & 0 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,15 @@ use core::fmt;
use core::future::Future;
use core::hash::{Hash, Hasher};
use core::marker::{Tuple, Unsize};
#[cfg(not(no_global_oom_handling))]
use core::mem::MaybeUninit;
use core::mem::{self, SizedTypeProperties};
use core::ops::{
AsyncFn, AsyncFnMut, AsyncFnOnce, CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut,
DerefPure, DispatchFromDyn, LegacyReceiver,
};
#[cfg(not(no_global_oom_handling))]
use core::ops::{Residual, Try};
use core::pin::{Pin, PinCoerceUnsized};
use core::ptr::{self, NonNull, Unique};
use core::task::{Context, Poll};
Expand Down Expand Up @@ -386,6 +390,82 @@ impl<T> Box<T> {
pub fn try_new_zeroed() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
Box::try_new_zeroed_in(Global)
}

/// Maps the value in a box, reusing the allocation if possible.
///
/// `f` is called on the value in the box, and the result is returned, also boxed.
///
/// Note: this is an associated function, which means that you have
/// to call it as `Box::map(b, f)` instead of `b.map(f)`. This
/// is so that there is no conflict with a method on the inner type.
///
/// # Examples
///
/// ```
/// #![feature(smart_pointer_try_map)]
///
/// let b = Box::new(7);
/// let new = Box::map(b, |i| i + 7);
/// assert_eq!(*new, 14);
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "smart_pointer_try_map", issue = "144419")]
pub fn map<U>(this: Self, f: impl FnOnce(T) -> U) -> Box<U> {
if size_of::<T>() == size_of::<U>() && align_of::<T>() == align_of::<U>() {
let (value, allocation) = Box::take(this);
Box::write(
unsafe { mem::transmute::<Box<MaybeUninit<T>>, Box<MaybeUninit<U>>>(allocation) },
f(value),
)
} else {
Box::new(f(*this))
}
}

/// Attempts to map the value in a box, reusing the allocation if possible.
///
/// `f` is called on the value in the box, and if the operation succeeds, the result is
/// returned, also boxed.
///
/// Note: this is an associated function, which means that you have
/// to call it as `Box::try_map(b, f)` instead of `b.try_map(f)`. This
/// is so that there is no conflict with a method on the inner type.
///
/// # Examples
///
/// ```
/// #![feature(smart_pointer_try_map)]
///
/// let b = Box::new(7);
/// let new = Box::try_map(b, u32::try_from).unwrap();
/// assert_eq!(*new, 7);
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "smart_pointer_try_map", issue = "144419")]
pub fn try_map<R>(
this: Self,
f: impl FnOnce(T) -> R,
) -> <R::Residual as Residual<Box<R::Output>>>::TryType
where
R: Try,
R::Residual: Residual<Box<R::Output>>,
{
if size_of::<T>() == size_of::<R::Output>() && align_of::<T>() == align_of::<R::Output>() {
let (value, allocation) = Box::take(this);
try {
Box::write(
unsafe {
mem::transmute::<Box<MaybeUninit<T>>, Box<MaybeUninit<R::Output>>>(
allocation,
)
},
f(value)?,
)
}
} else {
try { Box::new(f(*this)?) }
}
}
}

impl<T, A: Allocator> Box<T, A> {
Expand Down
Loading
Loading