1362: feat(interface-types) Remove allocator index from `string.lower_memory` r=Hywan a=Hywan

This PR updates `string.lower_memory` to remove the allocator index. Indeed, the string pointer is assumed to be present on the stack.
Also, this PR updates `string.size` to pop, and not to peek, the string to compute the length from.

That way, it matches the WIT proposal.

Co-authored-by: Ivan Enderlin <ivan@mnt.io>
This commit is contained in:
bors[bot]
2020-04-09 08:05:50 +00:00
committed by GitHub
8 changed files with 45 additions and 150 deletions

View File

@ -331,10 +331,7 @@ where
Instruction::I64FromU64 => 0x21_u8.to_bytes(writer)?,
Instruction::StringLiftMemory => 0x22_u8.to_bytes(writer)?,
Instruction::StringLowerMemory { allocator_index } => {
0x23_u8.to_bytes(writer)?;
(*allocator_index as u64).to_bytes(writer)?;
}
Instruction::StringLowerMemory => 0x23_u8.to_bytes(writer)?,
Instruction::StringSize => 0x24_u8.to_bytes(writer)?,
Instruction::RecordLift { type_index } => {
@ -688,7 +685,7 @@ mod tests {
Instruction::I64FromU32,
Instruction::I64FromU64,
Instruction::StringLiftMemory,
Instruction::StringLowerMemory { allocator_index: 1 },
Instruction::StringLowerMemory,
Instruction::StringSize,
Instruction::RecordLift { type_index: 1 },
Instruction::RecordLower { type_index: 1 },
@ -730,7 +727,7 @@ mod tests {
0x20, // I64FromU32
0x21, // I64FromU64
0x22, // StringLiftMemory
0x23, 0x01, // StringLowerMemory { allocator_index: 1 }
0x23, // StringLowerMemory
0x24, // StringSize
0x025, 0x01, // RecordLift { type_index: 1 }
0x026, 0x01, // RecordLower { type_index: 1 }