Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwco
Report allocation errors as panics OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`. This should be review one commit at a time: - The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics. - The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API. ACP: https://github.com/rust-lang/libs-team/issues/192 Closes #51540 Closes #51245
This commit is contained in:
commit
39cf520299
58 changed files with 138 additions and 878 deletions
|
@ -219,7 +219,7 @@ fn exported_symbols_provider_local(
|
|||
for symbol_name in ALLOCATOR_METHODS
|
||||
.iter()
|
||||
.map(|method| format!("__rust_{}", method.name))
|
||||
.chain(["__rust_alloc_error_handler".to_string(), OomStrategy::SYMBOL.to_string()])
|
||||
.chain([OomStrategy::SYMBOL.to_string()])
|
||||
{
|
||||
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));
|
||||
|
||||
|
|
|
@ -635,16 +635,9 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
if let Some(kind) = allocator_kind_for_codegen(tcx) {
|
||||
let llmod_id =
|
||||
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
|
||||
let module_llvm = tcx.sess.time("write_allocator_module", || {
|
||||
backend.codegen_allocator(
|
||||
tcx,
|
||||
&llmod_id,
|
||||
kind,
|
||||
// If allocator_kind is Some then alloc_error_handler_kind must
|
||||
// also be Some.
|
||||
tcx.alloc_error_handler_kind(()).unwrap(),
|
||||
)
|
||||
});
|
||||
let module_llvm = tcx
|
||||
.sess
|
||||
.time("write_allocator_module", || backend.codegen_allocator(tcx, &llmod_id, kind));
|
||||
|
||||
ongoing_codegen.submit_pre_codegened_module_to_llvm(
|
||||
tcx,
|
||||
|
|
|
@ -123,7 +123,6 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
|
|||
tcx: TyCtxt<'tcx>,
|
||||
module_name: &str,
|
||||
kind: AllocatorKind,
|
||||
alloc_error_handler_kind: AllocatorKind,
|
||||
) -> Self::Module;
|
||||
/// This generates the codegen unit and returns it along with
|
||||
/// a `u64` giving an estimate of the unit's processing cost.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue