Add a number of #[inline] annotation through crates

Adding `#[inline]` will typically improve codegen for optimized builds
without LTO (so far the majority in practice) by allowing functions that
otherwise couldn't be inlined across codegen units to get inlined
across codegen units.

Right now `wasm-bindgen` has a lot of functions that are very small and
delegate to other functions, but aren't otherwise candidates for
inlining because they're concrete.

I was poking around in release-mode wasm recently and noticed an
alarming number of functions for tiny pieces of functionality, which
motivates this patch!
This commit is contained in:
Alex Crichton
2018-10-01 15:27:34 -07:00
parent 9c085dc0f5
commit 332beecabe
4 changed files with 70 additions and 7 deletions

View File

@ -77,6 +77,7 @@ macro_rules! type_wasm_native {
impl IntoWasmAbi for Option<$t> {
type Abi = $r;
#[inline]
fn into_abi(self, _extra: &mut Stack) -> $r {
match self {
None => $r {
@ -94,6 +95,7 @@ macro_rules! type_wasm_native {
impl FromWasmAbi for Option<$t> {
type Abi = $r;
#[inline]
unsafe fn from_abi(js: $r, _extra: &mut Stack) -> Self {
if js.present == 0 {
None
@ -170,6 +172,7 @@ macro_rules! type_64 {
impl IntoWasmAbi for Option<$t> {
type Abi = WasmOptional64;
#[inline]
fn into_abi(self, _extra: &mut Stack) -> WasmOptional64 {
match self {
None => WasmOptional64 {
@ -191,6 +194,7 @@ macro_rules! type_64 {
impl FromWasmAbi for Option<$t> {
type Abi = WasmOptional64;
#[inline]
unsafe fn from_abi(js: WasmOptional64, _extra: &mut Stack) -> Self {
if js.present == 0 {
None
@ -257,6 +261,7 @@ impl FromWasmAbi for char {
impl IntoWasmAbi for Option<char> {
type Abi = WasmOptionalU32;
#[inline]
fn into_abi(self, _extra: &mut Stack) -> WasmOptionalU32 {
match self {
None => WasmOptionalU32 {
@ -274,6 +279,7 @@ impl IntoWasmAbi for Option<char> {
impl FromWasmAbi for Option<char> {
type Abi = WasmOptionalU32;
#[inline]
unsafe fn from_abi(js: WasmOptionalU32, _extra: &mut Stack) -> Self {
if js.present == 0 {
None