Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all #[inline.*]s #1666

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
4 changes: 0 additions & 4 deletions crates/allocator/src/bump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ static mut INNER: InnerAlloc = InnerAlloc::new();
pub struct BumpAllocator;

unsafe impl GlobalAlloc for BumpAllocator {
#[inline]
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
match INNER.alloc(layout) {
Some(start) => start as *mut u8,
None => core::ptr::null_mut(),
}
}

#[inline]
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
// A new page in Wasm is guaranteed to already be zero initialized, so we can just use our
// regular `alloc` call here and save a bit of work.
Expand All @@ -52,7 +50,6 @@ unsafe impl GlobalAlloc for BumpAllocator {
self.alloc(layout)
}

#[inline]
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
}

Expand Down Expand Up @@ -142,7 +139,6 @@ impl InnerAlloc {
/// This function rounds up to the next page. For example, if we have an allocation of
/// `size = PAGE_SIZE / 2` this function will indicate that one page is required to satisfy
/// the allocation.
#[inline]
fn required_pages(size: usize) -> Option<usize> {
size.checked_add(PAGE_SIZE - 1)
.and_then(|num| num.checked_div(PAGE_SIZE))
Expand Down
1 change: 0 additions & 1 deletion crates/engine/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ macro_rules! define_error_codes {
}

impl From<ReturnCode> for Result {
#[inline]
fn from(return_code: ReturnCode) -> Self {
match return_code.0 {
0 => Ok(()),
Expand Down
9 changes: 0 additions & 9 deletions crates/env/src/call/call_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ where
E: Environment,
{
/// Returns the call flags.
#[inline]
pub fn call_flags(&self) -> &CallFlags {
&self.call_flags
}

/// Returns the execution input.
#[inline]
pub fn exec_input(&self) -> &ExecutionInput<Args> {
&self.exec_input
}
Expand All @@ -70,19 +68,16 @@ where
E: Environment,
{
/// Returns the account ID of the called contract instance.
#[inline]
pub fn callee(&self) -> &E::AccountId {
&self.call_type.callee
}

/// Returns the chosen gas limit for the called contract execution.
#[inline]
pub fn gas_limit(&self) -> Gas {
self.call_type.gas_limit
}

/// Returns the transferred value for the called contract.
#[inline]
pub fn transferred_value(&self) -> &E::Balance {
&self.call_type.transferred_value
}
Expand All @@ -93,7 +88,6 @@ where
E: Environment,
{
/// Returns the code hash which we use to perform a delegate call.
#[inline]
pub fn code_hash(&self) -> &E::Hash {
&self.call_type.code_hash
}
Expand Down Expand Up @@ -409,7 +403,6 @@ where
E: Environment,
{
/// The type of the call.
#[inline]
#[must_use]
pub fn call_type<NewCallType>(
self,
Expand All @@ -430,7 +423,6 @@ where
E: Environment,
{
/// The flags used to change the behavior of the contract call.
#[inline]
#[must_use]
pub fn call_flags(
self,
Expand All @@ -456,7 +448,6 @@ where
///
/// Either use `.returns::<()>` to signal that the call does not return a value
/// or use `.returns::<T>` to signal that the call returns a value of type `T`.
#[inline]
pub fn returns<R>(self) -> CallBuilder<E, CallType, Args, Set<ReturnType<R>>> {
CallBuilder {
call_type: self.call_type,
Expand Down
7 changes: 0 additions & 7 deletions crates/env/src/call/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use core::marker::PhantomData;
pub struct ReturnType<T>(PhantomData<fn() -> T>);

impl<T> Clone for ReturnType<T> {
#[inline]
fn clone(&self) -> Self {
Self(Default::default())
}
Expand All @@ -32,7 +31,6 @@ impl<T> Clone for ReturnType<T> {
impl<T> Copy for ReturnType<T> {}

impl<T> Default for ReturnType<T> {
#[inline]
fn default() -> Self {
Self(Default::default())
}
Expand All @@ -44,7 +42,6 @@ pub struct Set<T>(pub T);

impl<T> Set<T> {
/// Returns the set value.
#[inline]
pub fn value(self) -> T {
self.0
}
Expand All @@ -55,7 +52,6 @@ impl<T> Set<T> {
pub struct Unset<T>(PhantomData<fn() -> T>);

impl<T> Clone for Unset<T> {
#[inline]
fn clone(&self) -> Self {
Self(Default::default())
}
Expand All @@ -64,7 +60,6 @@ impl<T> Clone for Unset<T> {
impl<T> Copy for Unset<T> {}

impl<T> Default for Unset<T> {
#[inline]
fn default() -> Self {
Self(Default::default())
}
Expand All @@ -87,7 +82,6 @@ pub trait Unwrap {
impl<T> Unwrap for Unset<T> {
type Output = T;

#[inline]
fn unwrap_or_else<F>(self, f: F) -> Self::Output
where
F: FnOnce() -> Self::Output,
Expand All @@ -99,7 +93,6 @@ impl<T> Unwrap for Unset<T> {
impl<T> Unwrap for Set<T> {
type Output = T;

#[inline]
fn unwrap_or_else<F>(self, _: F) -> Self::Output
where
F: FnOnce() -> Self::Output,
Expand Down
16 changes: 0 additions & 16 deletions crates/env/src/call/create_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,25 +190,21 @@ where
E: Environment,
{
/// The code hash of the contract.
#[inline]
pub fn code_hash(&self) -> &E::Hash {
&self.code_hash
}

/// The gas limit for the contract instantiation.
#[inline]
pub fn gas_limit(&self) -> u64 {
self.gas_limit
}

/// The endowment for the instantiated contract.
#[inline]
pub fn endowment(&self) -> &E::Balance {
&self.endowment
}

/// The raw encoded input data.
#[inline]
pub fn exec_input(&self) -> &ExecutionInput<Args> {
&self.exec_input
}
Expand All @@ -228,7 +224,6 @@ where
Salt: AsRef<[u8]>,
{
/// The salt for determining the hash for the contract account ID.
#[inline]
pub fn salt_bytes(&self) -> &Salt {
&self.salt_bytes
}
Expand All @@ -249,7 +244,6 @@ where
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`] or an
/// [`ink::primitives::LangError`][`ink_primitives::LangError`]. If you want to handle those
/// use the [`try_instantiate`][`CreateParams::try_instantiate`] method instead.
#[inline]
pub fn instantiate(&self) -> <R as ConstructorReturnType<ContractRef>>::Output {
crate::instantiate_contract(self)
.unwrap_or_else(|env_error| {
Expand All @@ -267,7 +261,6 @@ where
/// On failure this returns an outer [`ink::env::Error`][`crate::Error`] or inner
/// [`ink::primitives::LangError`][`ink_primitives::LangError`], both of which can be handled
/// by the caller.
#[inline]
pub fn try_instantiate(
&self,
) -> Result<
Expand Down Expand Up @@ -446,7 +439,6 @@ where
E: Environment,
{
/// Sets the used code hash for the contract instantiation.
#[inline]
pub fn code_hash(
self,
code_hash: E::Hash,
Expand Down Expand Up @@ -478,7 +470,6 @@ where
E: Environment,
{
/// Sets the maximum allowed gas costs for the contract instantiation.
#[inline]
pub fn gas_limit(
self,
gas_limit: u64,
Expand Down Expand Up @@ -511,7 +502,6 @@ where
E: Environment,
{
/// Sets the value transferred upon the execution of the call.
#[inline]
pub fn endowment(
self,
endowment: E::Balance,
Expand Down Expand Up @@ -552,7 +542,6 @@ where
E: Environment,
{
/// Sets the value transferred upon the execution of the call.
#[inline]
pub fn exec_input<Args>(
self,
exec_input: ExecutionInput<Args>,
Expand Down Expand Up @@ -593,7 +582,6 @@ where
E: Environment,
{
/// Sets the value transferred upon the execution of the call.
#[inline]
pub fn salt_bytes<Salt>(
self,
salt: Salt,
Expand Down Expand Up @@ -645,7 +633,6 @@ where
///
/// Therefore this must always be a reference (i.e `ContractRef`) to the contract you're trying
/// to instantiate.
#[inline]
pub fn returns<R>(
self,
) -> CreateBuilder<
Expand Down Expand Up @@ -690,7 +677,6 @@ where
GasLimit: Unwrap<Output = u64>,
{
/// Finalizes the create builder, allowing it to instantiate a contract.
#[inline]
pub fn params(self) -> CreateParams<E, ContractRef, Args, Salt, RetType> {
CreateParams {
code_hash: self.code_hash.value(),
Expand Down Expand Up @@ -730,7 +716,6 @@ where
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`] or an
/// [`ink::primitives::LangError`][`ink_primitives::LangError`]. If you want to handle those
/// use the [`try_instantiate`][`CreateBuilder::try_instantiate`] method instead.
#[inline]
pub fn instantiate(self) -> <RetType as ConstructorReturnType<ContractRef>>::Output {
self.params().instantiate()
}
Expand All @@ -742,7 +727,6 @@ where
/// On failure this returns an outer [`ink::env::Error`][`crate::Error`] or inner
/// [`ink::primitives::LangError`][`ink_primitives::LangError`], both of which can be handled
/// by the caller.
#[inline]
pub fn try_instantiate(
self,
) -> Result<
Expand Down
15 changes: 0 additions & 15 deletions crates/env/src/call/execution_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub struct ExecutionInput<Args> {

impl ExecutionInput<EmptyArgumentList> {
/// Creates a new execution input with the given selector.
#[inline]
pub fn new(selector: Selector) -> Self {
Self {
selector,
Expand All @@ -34,7 +33,6 @@ impl ExecutionInput<EmptyArgumentList> {
}

/// Pushes an argument to the execution input.
#[inline]
pub fn push_arg<T>(
self,
arg: T,
Expand All @@ -51,7 +49,6 @@ impl ExecutionInput<EmptyArgumentList> {

impl<Head, Rest> ExecutionInput<ArgumentList<Argument<Head>, Rest>> {
/// Pushes an argument to the execution input.
#[inline]
pub fn push_arg<T>(self, arg: T) -> ExecutionInput<ArgsList<T, ArgsList<Head, Rest>>>
where
T: scale::Encode,
Expand Down Expand Up @@ -102,7 +99,6 @@ pub struct Argument<T> {

impl<T> Argument<T> {
/// Creates a new argument.
#[inline]
fn new(arg: T) -> Self {
Self { arg }
}
Expand All @@ -117,7 +113,6 @@ pub type EmptyArgumentList = ArgumentList<ArgumentListEnd, ArgumentListEnd>;

impl EmptyArgumentList {
/// Creates a new empty argument list.
#[inline]
pub fn empty() -> EmptyArgumentList {
ArgumentList {
head: ArgumentListEnd,
Expand All @@ -126,7 +121,6 @@ impl EmptyArgumentList {
}

/// Pushes the first argument to the empty argument list.
#[inline]
pub fn push_arg<T>(self, arg: T) -> ArgumentList<Argument<T>, Self>
where
T: scale::Encode,
Expand All @@ -140,7 +134,6 @@ impl EmptyArgumentList {

impl<Head, Rest> ArgumentList<Argument<Head>, Rest> {
/// Pushes another argument to the argument list.
#[inline]
pub fn push_arg<T>(self, arg: T) -> ArgumentList<Argument<T>, Self>
where
T: scale::Encode,
Expand All @@ -156,24 +149,20 @@ impl<T> scale::Encode for Argument<T>
where
T: scale::Encode,
{
#[inline]
fn size_hint(&self) -> usize {
<T as scale::Encode>::size_hint(&self.arg)
}

#[inline]
fn encode_to<O: scale::Output + ?Sized>(&self, output: &mut O) {
<T as scale::Encode>::encode_to(&self.arg, output)
}
}

impl scale::Encode for EmptyArgumentList {
#[inline]
fn size_hint(&self) -> usize {
0
}

#[inline]
fn encode_to<O: scale::Output + ?Sized>(&self, _output: &mut O) {}
}

Expand All @@ -182,12 +171,10 @@ where
Head: scale::Encode,
Rest: scale::Encode,
{
#[inline]
fn size_hint(&self) -> usize {
scale::Encode::size_hint(&self.head) + scale::Encode::size_hint(&self.rest)
}

#[inline]
fn encode_to<O: scale::Output + ?Sized>(&self, output: &mut O) {
// We reverse the order of encoding because we build up the list of
// arguments in reverse order, too. This way we encode the arguments
Expand All @@ -202,12 +189,10 @@ impl<Args> scale::Encode for ExecutionInput<Args>
where
Args: scale::Encode,
{
#[inline]
fn size_hint(&self) -> usize {
scale::Encode::size_hint(&self.selector) + scale::Encode::size_hint(&self.args)
}

#[inline]
fn encode_to<O: scale::Output + ?Sized>(&self, output: &mut O) {
scale::Encode::encode_to(&self.selector, output);
scale::Encode::encode_to(&self.args, output);
Expand Down
Loading