Auto merge of #98638 - bjorn3:less_string_interning, r=tmiasko
Use less string interning This removes string interning in a couple of places where doing so won't result in perf improvements. I also switched one place to use pre-interned symbols.
This commit is contained in:
commit
4587677300
@ -12,7 +12,6 @@
|
||||
use rustc_middle::ty::ScalarInt;
|
||||
use rustc_middle::ty::layout::{TyAndLayout, LayoutOf};
|
||||
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
|
||||
use rustc_span::Symbol;
|
||||
use rustc_target::abi::{self, HasDataLayout, Pointer, Size};
|
||||
|
||||
use crate::consts::const_alloc_to_gcc;
|
||||
@ -125,12 +124,15 @@ fn const_real(&self, typ: Type<'gcc>, val: f64) -> RValue<'gcc> {
|
||||
self.context.new_rvalue_from_double(typ, val)
|
||||
}
|
||||
|
||||
fn const_str(&self, s: Symbol) -> (RValue<'gcc>, RValue<'gcc>) {
|
||||
let s_str = s.as_str();
|
||||
let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| {
|
||||
self.global_string(s_str)
|
||||
});
|
||||
let len = s_str.len();
|
||||
fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) {
|
||||
let str_global = *self
|
||||
.const_str_cache
|
||||
.borrow_mut()
|
||||
.raw_entry_mut()
|
||||
.from_key(s)
|
||||
.or_insert_with(|| (s.to_owned(), self.global_string(s)))
|
||||
.1;
|
||||
let len = s.len();
|
||||
let cs = self.const_ptrcast(str_global.get_address(None),
|
||||
self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self, true)),
|
||||
);
|
||||
|
@ -13,7 +13,7 @@
|
||||
use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
|
||||
use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, TyAndLayout, LayoutOfHelpers};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
|
||||
|
||||
@ -101,7 +101,7 @@ pub struct CodegenCx<'gcc, 'tcx> {
|
||||
pub global_lvalues: RefCell<FxHashMap<RValue<'gcc>, LValue<'gcc>>>,
|
||||
|
||||
/// Cache of constant strings,
|
||||
pub const_str_cache: RefCell<FxHashMap<Symbol, LValue<'gcc>>>,
|
||||
pub const_str_cache: RefCell<FxHashMap<String, LValue<'gcc>>>,
|
||||
|
||||
/// Cache of globals.
|
||||
pub globals: RefCell<FxHashMap<String, RValue<'gcc>>>,
|
||||
|
@ -6,7 +6,14 @@
|
||||
* TODO(antoyo): remove the patches.
|
||||
*/
|
||||
|
||||
#![feature(rustc_private, decl_macro, associated_type_bounds, never_type, trusted_len)]
|
||||
#![feature(
|
||||
rustc_private,
|
||||
decl_macro,
|
||||
associated_type_bounds,
|
||||
never_type,
|
||||
trusted_len,
|
||||
hash_raw_entry
|
||||
)]
|
||||
#![allow(broken_intra_doc_links)]
|
||||
#![recursion_limit="256"]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
Loading…
Reference in New Issue
Block a user