-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* perf: minor optimiazation for assignment * perf: minor optimiazation for image table assignment * perf: optimize memory_table * opt post image table assignment * opt mtable assignment * perf: optimize etable assignment * perf: remove assertion for perf * perf: optimize image table assignment * perf: optimize image table assignment * perf: optimize etable assignment * minor optimization for etable and image table * remove mimalloc * remove config in test_cli script
- Loading branch information
Showing
54 changed files
with
598 additions
and
395 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,44 @@ | ||
use num_bigint::BigUint; | ||
use num_bigint::ToBigUint; | ||
use static_assertions::const_assert; | ||
|
||
use crate::encode::br_table::BR_TABLE_ENCODE_BOUNDARY; | ||
use crate::encode::init_memory_table::INIT_MEMORY_ENCODE_BOUNDARY; | ||
use crate::encode::instruction_table::INSTRUCTION_ENCODE_BOUNDARY; | ||
|
||
use super::FromBn; | ||
|
||
const CLASS_SHIFT: u32 = 224; | ||
|
||
#[derive(Clone, Copy)] | ||
pub enum ImageTableEncoder { | ||
Instruction = 1, | ||
BrTable = 2, | ||
InitMemory = 3, | ||
} | ||
|
||
impl ImageTableEncoder { | ||
pub fn encode<T: FromBn>(&self, data: T) -> T { | ||
const CLASS_SHIFT: u32 = 224; | ||
const_assert!(INSTRUCTION_ENCODE_BOUNDARY <= CLASS_SHIFT); | ||
const_assert!(BR_TABLE_ENCODE_BOUNDARY <= CLASS_SHIFT); | ||
const_assert!(INIT_MEMORY_ENCODE_BOUNDARY <= CLASS_SHIFT); | ||
|
||
assert!(INSTRUCTION_ENCODE_BOUNDARY <= CLASS_SHIFT); | ||
assert!(BR_TABLE_ENCODE_BOUNDARY <= CLASS_SHIFT); | ||
assert!(INIT_MEMORY_ENCODE_BOUNDARY <= CLASS_SHIFT); | ||
lazy_static! { | ||
static ref INSTRUCTION_TAG: BigUint = (ImageTableEncoder::Instruction as u64) | ||
.to_biguint() | ||
.unwrap() | ||
<< CLASS_SHIFT; | ||
static ref BR_TABLE_TAG: BigUint = | ||
(ImageTableEncoder::BrTable as u64).to_biguint().unwrap() << CLASS_SHIFT; | ||
static ref INIT_MEMORY_TAG: BigUint = | ||
(ImageTableEncoder::InitMemory as u64).to_biguint().unwrap() << CLASS_SHIFT; | ||
} | ||
|
||
T::from_bn(&(*self as u64).to_biguint().unwrap()) | ||
* T::from_bn(&(1u64.to_biguint().unwrap() << CLASS_SHIFT)) | ||
+ data | ||
impl ImageTableEncoder { | ||
#[inline(always)] | ||
pub fn encode<T: FromBn>(&self, data: T) -> T { | ||
match self { | ||
ImageTableEncoder::Instruction => T::from_bn(&INSTRUCTION_TAG) + data, | ||
ImageTableEncoder::BrTable => T::from_bn(&BR_TABLE_TAG) + data, | ||
ImageTableEncoder::InitMemory => T::from_bn(&INIT_MEMORY_TAG) + data, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
use num_bigint::ToBigUint; | ||
use num_bigint::BigUint; | ||
use num_traits::One; | ||
use static_assertions::const_assert; | ||
|
||
use super::FromBn; | ||
use crate::encode::COMMON_RANGE_OFFSET; | ||
|
||
pub fn encode_memory_table_entry<T: FromBn>(offset: T, location_type: T, is_i32: T) -> T { | ||
const END_SHIFT: u32 = OFFSET_SHIFT + COMMON_RANGE_OFFSET; | ||
const OFFSET_SHIFT: u32 = LOCATION_TYPE_SHIFT + COMMON_RANGE_OFFSET; | ||
const LOCATION_TYPE_SHIFT: u32 = IS_I32_SHIFT + 1; | ||
const IS_I32_SHIFT: u32 = 0; | ||
const _END_SHIFT: u32 = OFFSET_SHIFT + COMMON_RANGE_OFFSET; | ||
const OFFSET_SHIFT: u32 = LOCATION_TYPE_SHIFT + COMMON_RANGE_OFFSET; | ||
const LOCATION_TYPE_SHIFT: u32 = IS_I32_SHIFT + 1; | ||
const IS_I32_SHIFT: u32 = 0; | ||
|
||
const_assert!(_END_SHIFT < 240); | ||
|
||
assert!(END_SHIFT < 240); | ||
lazy_static! { | ||
pub static ref MEMORY_TABLE_ENTRY_OFFSET: BigUint = BigUint::one() << OFFSET_SHIFT; | ||
pub static ref MEMORY_TABLE_ENTRY_LOCATION_TYPE: BigUint = | ||
BigUint::one() << LOCATION_TYPE_SHIFT; | ||
pub static ref MEMORY_TABLE_ENTRY_IS_I32: BigUint = BigUint::one() << IS_I32_SHIFT; | ||
} | ||
|
||
offset * T::from_bn(&(1u64.to_biguint().unwrap() << OFFSET_SHIFT)) | ||
+ location_type * T::from_bn(&(1u64.to_biguint().unwrap() << LOCATION_TYPE_SHIFT)) | ||
+ is_i32 * T::from_bn(&(1u64.to_biguint().unwrap() << IS_I32_SHIFT)) | ||
pub fn encode_memory_table_entry<T: FromBn>(offset: T, location_type: T, is_i32: T) -> T { | ||
offset * T::from_bn(&MEMORY_TABLE_ENTRY_OFFSET) | ||
+ location_type * T::from_bn(&MEMORY_TABLE_ENTRY_LOCATION_TYPE) | ||
+ is_i32 * T::from_bn(&MEMORY_TABLE_ENTRY_IS_I32) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.