Merge commit '97e5045493
' into sync_cg_clif-2021-12-20
This commit is contained in:
commit
3426a730ff
36 changed files with 1017 additions and 532 deletions
|
@ -4,6 +4,7 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
|
||||
use rustc_codegen_ssa::back::metadata::create_compressed_metadata_file;
|
||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
|
@ -123,6 +124,7 @@ fn module_codegen(
|
|||
backend_config.clone(),
|
||||
module.isa(),
|
||||
tcx.sess.opts.debuginfo != DebugInfo::None,
|
||||
cgu_name,
|
||||
);
|
||||
super::predefine_mono_items(tcx, &mut module, &mono_items);
|
||||
for (mono_item, _) in mono_items {
|
||||
|
@ -277,7 +279,8 @@ pub(crate) fn run_aot(
|
|||
let tmp_file =
|
||||
tcx.output_filenames(()).temp_path(OutputType::Metadata, Some(&metadata_cgu_name));
|
||||
|
||||
let obj = crate::metadata::new_metadata_object(tcx, &metadata_cgu_name, &metadata);
|
||||
let symbol_name = rustc_middle::middle::exported_symbols::metadata_symbol_name(tcx);
|
||||
let obj = create_compressed_metadata_file(tcx.sess, &metadata, &symbol_name);
|
||||
|
||||
if let Err(err) = std::fs::write(&tmp_file, obj) {
|
||||
tcx.sess.fatal(&format!("error writing metadata object file: {}", err));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::CString;
|
||||
use std::lazy::{Lazy, SyncOnceCell};
|
||||
use std::lazy::SyncOnceCell;
|
||||
use std::os::raw::{c_char, c_int};
|
||||
use std::sync::{mpsc, Mutex};
|
||||
|
||||
|
@ -11,6 +11,7 @@ use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink};
|
|||
use rustc_codegen_ssa::CrateInfo;
|
||||
use rustc_middle::mir::mono::MonoItem;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Symbol;
|
||||
|
||||
use cranelift_jit::{JITBuilder, JITModule};
|
||||
|
||||
|
@ -23,7 +24,7 @@ struct JitState {
|
|||
}
|
||||
|
||||
thread_local! {
|
||||
static LAZY_JIT_STATE: RefCell<Option<JitState>> = RefCell::new(None);
|
||||
static LAZY_JIT_STATE: RefCell<Option<JitState>> = const { RefCell::new(None) };
|
||||
}
|
||||
|
||||
/// The Sender owned by the rustc thread
|
||||
|
@ -50,12 +51,11 @@ impl UnsafeMessage {
|
|||
fn send(self) -> Result<(), mpsc::SendError<UnsafeMessage>> {
|
||||
thread_local! {
|
||||
/// The Sender owned by the local thread
|
||||
static LOCAL_MESSAGE_SENDER: Lazy<mpsc::Sender<UnsafeMessage>> = Lazy::new(||
|
||||
static LOCAL_MESSAGE_SENDER: mpsc::Sender<UnsafeMessage> =
|
||||
GLOBAL_MESSAGE_SENDER
|
||||
.get().unwrap()
|
||||
.lock().unwrap()
|
||||
.clone()
|
||||
);
|
||||
.clone();
|
||||
}
|
||||
LOCAL_MESSAGE_SENDER.with(|sender| sender.send(self))
|
||||
}
|
||||
|
@ -76,7 +76,13 @@ fn create_jit_module<'tcx>(
|
|||
jit_builder.symbols(imported_symbols);
|
||||
let mut jit_module = JITModule::new(jit_builder);
|
||||
|
||||
let mut cx = crate::CodegenCx::new(tcx, backend_config.clone(), jit_module.isa(), false);
|
||||
let mut cx = crate::CodegenCx::new(
|
||||
tcx,
|
||||
backend_config.clone(),
|
||||
jit_module.isa(),
|
||||
false,
|
||||
Symbol::intern("dummy_cgu_name"),
|
||||
);
|
||||
|
||||
crate::allocator::codegen(tcx, &mut jit_module, &mut cx.unwind_context);
|
||||
crate::main_shim::maybe_create_entry_wrapper(
|
||||
|
@ -246,7 +252,13 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) ->
|
|||
|
||||
jit_module.prepare_for_function_redefine(func_id).unwrap();
|
||||
|
||||
let mut cx = crate::CodegenCx::new(tcx, backend_config, jit_module.isa(), false);
|
||||
let mut cx = crate::CodegenCx::new(
|
||||
tcx,
|
||||
backend_config,
|
||||
jit_module.isa(),
|
||||
false,
|
||||
Symbol::intern("dummy_cgu_name"),
|
||||
);
|
||||
tcx.sess.time("codegen fn", || crate::base::codegen_fn(&mut cx, jit_module, instance));
|
||||
|
||||
assert!(cx.global_asm.is_empty());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue