Merge branch 'optimizations' of github.com:fluencelabs/interface-types into optimizations

This commit is contained in:
vms 2021-04-23 23:57:46 +03:00
commit 6116c5c252
11 changed files with 1 additions and 26 deletions

View File

@ -38,7 +38,6 @@ pub fn ser_type_size(ty: &IType) -> usize {
// Vec-like types are passed by pointer and size
IType::String | IType::ByteArray | IType::Array(_) => 2 * WASM_POINTER_SIZE,
IType::S64 | IType::U64 | IType::I64 | IType::F64 => 8,
IType::U128 => 16,
}
}
@ -49,7 +48,6 @@ pub fn ser_value_size(value: &IValue) -> u32 {
IValue::S16(_) | IValue::U16(_) => 2,
IValue::S32(_) | IValue::U32(_) | IValue::F32(_) | IValue::I32(_) => 4,
IValue::S64(_) | IValue::U64(_) | IValue::F64(_) | IValue::I64(_) => 8,
IValue::U128(_) => 16,
IValue::String(_) | IValue::ByteArray(_) | IValue::Array(_) => 2 * 4,
IValue::Record(_) => 4,
}
@ -73,7 +71,6 @@ pub fn type_tag_form_itype(itype: &IType) -> u32 {
IType::U16 => 2, // u16
IType::U32 => 3, // u32
IType::U64 => 4, // u64
IType::U128 => 5, // u128
IType::S8 => 6, // i8
IType::S16 => 7, // i16
IType::S32 | IType::I32 => 8, // i32
@ -93,7 +90,6 @@ pub fn type_tag_form_ivalue(itype: &IValue) -> u32 {
IValue::U16(_) => 2, // u16
IValue::U32(_) => 3, // u32
IValue::U64(_) => 4, // u64
IValue::U128(_) => 5, // u128
IValue::S8(_) => 6, // i8
IValue::S16(_) => 7, // i16
IValue::S32(_) | IValue::I32(_) => 8, // i32

View File

@ -103,7 +103,6 @@ impl<'m> MemoryReader<'m> {
read_array_ty!(read_s64_array, i64, S64);
read_array_ty!(read_i64_array, i64, I64);
read_array_ty!(read_f64_array, f64, F64);
read_array_ty!(read_u128_array, u128, U128);
}
impl<'r, 'm> SequentialReader<'r, 'm> {
@ -130,5 +129,4 @@ impl<'r, 'm> SequentialReader<'r, 'm> {
read_ty!(read_u64, u64, 8);
read_ty!(read_i64, i64, 8);
read_ty!(read_f64, f64, 8);
read_ty!(read_u128, u128, 16);
}

View File

@ -29,7 +29,6 @@ where
IType::U64 => 0x07_u8.to_bytes(writer),
IType::F32 => 0x08_u8.to_bytes(writer),
IType::F64 => 0x09_u8.to_bytes(writer),
IType::U128 => 0x46_u8.to_bytes(writer),
IType::String => 0x0a_u8.to_bytes(writer),
IType::ByteArray => 0x3C_u8.to_bytes(writer),
IType::Array(ty) => {
@ -88,7 +87,6 @@ mod keyword {
custom_keyword!(u16);
custom_keyword!(u32);
custom_keyword!(u64);
custom_keyword!(u128);
custom_keyword!(string);
custom_keyword!(array);
}
@ -140,10 +138,6 @@ impl Parse<'_> for IType {
parser.parse::<keyword::f64>()?;
Ok(IType::F64)
} else if lookahead.peek::<keyword::u128>() {
parser.parse::<keyword::u128>()?;
Ok(IType::U128)
} else if lookahead.peek::<keyword::string>() {
parser.parse::<keyword::string>()?;

View File

@ -48,7 +48,6 @@ native!(u32, U32);
native!(u64, U64);
native!(f32, F32);
native!(f64, F64);
native!(u128, U128);
native!(String, String);
impl NativeType for Vec<u8> {

View File

@ -41,9 +41,6 @@ pub enum IType {
/// A 64-bits float.
F64,
/// A 128-bit unsigned integer.
U128,
/// A string.
String,
@ -115,7 +112,6 @@ impl ToString for &IType {
IType::U64 => "u64".to_string(),
IType::F32 => "f32".to_string(),
IType::F64 => "f64".to_string(),
IType::U128 => "u128".to_string(),
IType::String => "string".to_string(),
IType::ByteArray => "array (u8)".to_string(),
IType::Array(ty) => format!("array ({})", ty.as_ref().to_string()),

View File

@ -37,10 +37,7 @@ pub enum IValue {
/// A 64-bits float.
F64(f64),
/// A 128-bits integer.
U128(u128),
/// A string.
String(String),

View File

@ -30,7 +30,6 @@ pub(crate) fn array_lift_memory_impl(
IType::U16 => reader.read_u16_array(offset, elements_count)?,
IType::U32 => reader.read_u32_array(offset, elements_count)?,
IType::U64 => reader.read_u64_array(offset, elements_count)?,
IType::U128 => reader.read_u128_array(offset, elements_count)?,
IType::F32 => reader.read_f32_array(offset, elements_count)?,
IType::F64 => reader.read_f64_array(offset, elements_count)?,
IType::String => read_string_array(li_helper, offset, elements_count)?,

View File

@ -31,7 +31,6 @@ pub(crate) fn array_lower_memory_impl<T: Heapable>(
IValue::U16(value) => seq_writer.write_array(writer, value.to_le_bytes()),
IValue::U32(value) => seq_writer.write_array(writer, value.to_le_bytes()),
IValue::U64(value) => seq_writer.write_array(writer, value.to_le_bytes()),
IValue::U128(value) => seq_writer.write_array(writer, value.to_le_bytes()),
IValue::I32(value) => seq_writer.write_array(writer, value.to_le_bytes()),
IValue::I64(value) => seq_writer.write_array(writer, value.to_le_bytes()),
IValue::F32(value) => seq_writer.write_array(writer, value.to_le_bytes()),

View File

@ -33,7 +33,6 @@ pub(crate) fn record_lift_memory_impl(
IType::U16 => values.push(IValue::U16(seq_reader.read_u16())),
IType::U32 => values.push(IValue::U32(seq_reader.read_u32())),
IType::U64 => values.push(IValue::U64(seq_reader.read_u64())),
IType::U128 => values.push(IValue::U128(seq_reader.read_u128())),
IType::F32 => values.push(IValue::F32(seq_reader.read_f32())),
IType::F64 => values.push(IValue::F64(seq_reader.read_f64())),
IType::String => values.push(IValue::String(read_string(reader, &seq_reader)?)),

View File

@ -22,7 +22,6 @@ pub(crate) fn record_lower_memory_impl<T: Heapable>(
IValue::U16(value) => result.extend_from_slice(&value.to_le_bytes()),
IValue::U32(value) => result.extend_from_slice(&value.to_le_bytes()),
IValue::U64(value) => result.extend_from_slice(&value.to_le_bytes()),
IValue::U128(value) => result.extend_from_slice(&value.to_le_bytes()),
IValue::I32(value) => result.extend_from_slice(&value.to_le_bytes()),
IValue::I64(value) => result.extend_from_slice(&value.to_le_bytes()),
IValue::F32(value) => result.extend_from_slice(&value.to_le_bytes()),

View File

@ -215,7 +215,6 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
Some(IValue::U16(_)) => self.deserialize_u16(visitor),
Some(IValue::U32(_)) => self.deserialize_u32(visitor),
Some(IValue::U64(_)) => self.deserialize_u64(visitor),
Some(IValue::U128(_)) => self.deserialize_u64(visitor),
Some(IValue::F32(_)) => self.deserialize_f32(visitor),
Some(IValue::F64(_)) => self.deserialize_f64(visitor),
Some(IValue::String(_)) => self.deserialize_string(visitor),