Skip to content

Commit 8b3c0d3

Browse files
authored
Merge pull request rust-lang#148 from TheDan64/dependabot/cargo/static-alloc-0.2
Update static-alloc requirement from 0.1 to 0.2
2 parents b27eee9 + dc679a8 commit 8b3c0d3

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ llvm-sys = "80.1"
6767
once_cell = "1.2"
6868
parking_lot = "0.10"
6969
regex = "1"
70-
static-alloc = { version = "0.1", optional = true }
70+
static-alloc = { version = "0.2", optional = true }
7171

7272
[badges]
7373
travis-ci = { repository = "TheDan64/inkwell" }

src/types/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use llvm_sys::core::LLVMDumpType;
3737
use llvm_sys::core::{LLVMAlignOf, LLVMGetTypeContext, LLVMFunctionType, LLVMArrayType, LLVMGetUndef, LLVMPointerType, LLVMPrintTypeToString, LLVMTypeIsSized, LLVMSizeOf, LLVMVectorType, LLVMGetElementType, LLVMConstNull};
3838
use llvm_sys::prelude::{LLVMTypeRef, LLVMValueRef};
3939
#[cfg(feature = "experimental")]
40-
use static_alloc::Slab;
40+
use static_alloc::Bump;
4141

4242
use std::fmt;
4343
use std::marker::PhantomData;
@@ -115,15 +115,19 @@ impl<'ctx> Type<'ctx> {
115115

116116
#[cfg(feature = "experimental")]
117117
fn fn_type(&self, param_types: &[BasicTypeEnum<'ctx>], is_var_args: bool) -> FunctionType<'ctx> {
118-
let pool: Slab<[usize; 16]> = Slab::uninit();
119-
let mut fixed_vec = pool.fixed_vec(param_types.len()).expect("Found more than 16 params");
118+
let pool: Bump<[usize; 16]> = Bump::uninit();
119+
let mut pool_start = None;
120120

121-
for param_type in param_types {
122-
fixed_vec.push(param_type.as_type_ref()).expect("Unexpected error");
121+
for (i, param_type) in param_types.iter().enumerate() {
122+
let addr = pool.leak(param_type.as_type_ref()).expect("Found more than 16 params");
123+
124+
if i == 0 {
125+
pool_start = Some(addr as *mut _);
126+
}
123127
}
124128

125129
let fn_type = unsafe {
126-
LLVMFunctionType(self.ty, fixed_vec.as_mut_ptr(), fixed_vec.len() as u32, is_var_args as i32)
130+
LLVMFunctionType(self.ty, pool_start.unwrap_or(std::ptr::null_mut()), param_types.len() as u32, is_var_args as i32)
127131
};
128132

129133
FunctionType::new(fn_type)

0 commit comments

Comments
 (0)