mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 14:01:02 +00:00
@@ -11,9 +11,8 @@ where
|
||||
{
|
||||
let offset = context.builder().build_int_add(
|
||||
offset,
|
||||
context.field_const(
|
||||
(revive_common::BYTE_LENGTH_X32 + revive_common::BYTE_LENGTH_FIELD) as u64,
|
||||
),
|
||||
context
|
||||
.word_const((revive_common::BYTE_LENGTH_X32 + revive_common::BYTE_LENGTH_WORD) as u64),
|
||||
"datacopy_contract_hash_offset",
|
||||
)?;
|
||||
|
||||
@@ -33,8 +32,8 @@ where
|
||||
{
|
||||
revive_llvm_context::polkavm_evm_memory::store_byte(
|
||||
context,
|
||||
context.field_const(offset),
|
||||
context.field_const(value),
|
||||
context.word_const(offset),
|
||||
context.word_const(value),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
@@ -53,21 +52,21 @@ where
|
||||
for (index, chunk) in source
|
||||
.chars()
|
||||
.collect::<Vec<char>>()
|
||||
.chunks(revive_common::BYTE_LENGTH_FIELD * 2)
|
||||
.chunks(revive_common::BYTE_LENGTH_WORD * 2)
|
||||
.enumerate()
|
||||
{
|
||||
let mut value_string = chunk.iter().collect::<String>();
|
||||
value_string.push_str(
|
||||
"0".repeat((revive_common::BYTE_LENGTH_FIELD * 2) - chunk.len())
|
||||
"0".repeat((revive_common::BYTE_LENGTH_WORD * 2) - chunk.len())
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
let datacopy_destination = context.builder().build_int_add(
|
||||
destination,
|
||||
context.field_const(offset as u64),
|
||||
context.word_const(offset as u64),
|
||||
format!("datacopy_destination_index_{index}").as_str(),
|
||||
)?;
|
||||
let datacopy_value = context.field_const_str_hex(value_string.as_str());
|
||||
let datacopy_value = context.word_const_str_hex(value_string.as_str());
|
||||
revive_llvm_context::polkavm_evm_memory::store(
|
||||
context,
|
||||
datacopy_destination,
|
||||
|
||||
@@ -49,7 +49,7 @@ where
|
||||
let condition = context.builder().build_int_compare(
|
||||
inkwell::IntPredicate::NE,
|
||||
condition.into_int_value(),
|
||||
context.field_const(0),
|
||||
context.word_const(0),
|
||||
format!("conditional_{block_key}_condition_compared").as_str(),
|
||||
)?;
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ impl Instruction {
|
||||
..
|
||||
} => {
|
||||
let mut key_extended =
|
||||
"0".repeat(revive_common::BYTE_LENGTH_FIELD * 2 - value.len());
|
||||
"0".repeat(revive_common::BYTE_LENGTH_WORD * 2 - value.len());
|
||||
key_extended.push_str(value.as_str());
|
||||
|
||||
*value = mapping.get(key_extended.as_str()).cloned().ok_or_else(|| {
|
||||
|
||||
@@ -11,7 +11,7 @@ where
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let result = context
|
||||
.field_type()
|
||||
.word_type()
|
||||
.const_int_from_string(
|
||||
value.to_ascii_uppercase().as_str(),
|
||||
inkwell::types::StringRadix::Hexadecimal,
|
||||
@@ -30,7 +30,7 @@ where
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let result = context
|
||||
.field_type()
|
||||
.word_type()
|
||||
.const_int_from_string(value.as_str(), inkwell::types::StringRadix::Decimal)
|
||||
.expect("Always valid");
|
||||
Ok(result.as_basic_value_enum())
|
||||
|
||||
@@ -88,7 +88,7 @@ impl Assembly {
|
||||
hash_data_mapping: &BTreeMap<String, String>,
|
||||
) -> anyhow::Result<BTreeMap<String, String>> {
|
||||
let mut index_path_mapping = BTreeMap::new();
|
||||
let index = "0".repeat(revive_common::BYTE_LENGTH_FIELD * 2);
|
||||
let index = "0".repeat(revive_common::BYTE_LENGTH_WORD * 2);
|
||||
index_path_mapping.insert(index, full_path.to_owned());
|
||||
|
||||
let dependencies = match self.data.as_mut() {
|
||||
@@ -100,7 +100,7 @@ impl Assembly {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut index_extended = "0".repeat(revive_common::BYTE_LENGTH_FIELD * 2 - index.len());
|
||||
let mut index_extended = "0".repeat(revive_common::BYTE_LENGTH_WORD * 2 - index.len());
|
||||
index_extended.push_str(index.as_str());
|
||||
|
||||
*data = match data {
|
||||
@@ -136,7 +136,7 @@ impl Assembly {
|
||||
hash_data_mapping: &BTreeMap<String, String>,
|
||||
) -> anyhow::Result<BTreeMap<String, String>> {
|
||||
let mut index_path_mapping = BTreeMap::new();
|
||||
let index = "0".repeat(revive_common::BYTE_LENGTH_FIELD * 2);
|
||||
let index = "0".repeat(revive_common::BYTE_LENGTH_WORD * 2);
|
||||
index_path_mapping.insert(index, full_path.to_owned());
|
||||
|
||||
let dependencies = match self
|
||||
@@ -150,7 +150,7 @@ impl Assembly {
|
||||
None => return Ok(index_path_mapping),
|
||||
};
|
||||
for (index, data) in dependencies.iter_mut() {
|
||||
let mut index_extended = "0".repeat(revive_common::BYTE_LENGTH_FIELD * 2 - index.len());
|
||||
let mut index_extended = "0".repeat(revive_common::BYTE_LENGTH_WORD * 2 - index.len());
|
||||
index_extended.push_str(index.as_str());
|
||||
|
||||
*data = match data {
|
||||
|
||||
@@ -162,8 +162,8 @@ where
|
||||
.value
|
||||
.ok_or_else(|| anyhow::anyhow!("Instruction value missing"))?;
|
||||
|
||||
if value.len() > revive_common::BYTE_LENGTH_FIELD * 2 {
|
||||
Ok(Some(context.field_const(0).as_basic_value_enum()))
|
||||
if value.len() > revive_common::BYTE_LENGTH_WORD * 2 {
|
||||
Ok(Some(context.word_const(0).as_basic_value_enum()))
|
||||
} else {
|
||||
crate::evmla::assembly::instruction::stack::push(context, value).map(Some)
|
||||
}
|
||||
@@ -522,7 +522,7 @@ where
|
||||
revive_llvm_context::polkavm_evm_comparison::compare(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
context.field_const(0),
|
||||
context.word_const(0),
|
||||
inkwell::IntPredicate::EQ,
|
||||
)
|
||||
.map(Some)
|
||||
@@ -571,7 +571,7 @@ where
|
||||
revive_llvm_context::polkavm_evm_bitwise::xor(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
context.field_type().const_all_ones(),
|
||||
context.word_type().const_all_ones(),
|
||||
)
|
||||
.map(Some)
|
||||
}
|
||||
@@ -758,7 +758,7 @@ where
|
||||
.solidity_mut()
|
||||
.get_or_allocate_immutable(key.as_str());
|
||||
|
||||
let index = context.field_const(offset as u64);
|
||||
let index = context.word_const(offset as u64);
|
||||
revive_llvm_context::polkavm_evm_immutable::load(context, index).map(Some)
|
||||
}
|
||||
InstructionName::ASSIGNIMMUTABLE => {
|
||||
@@ -771,7 +771,7 @@ where
|
||||
|
||||
let offset = context.solidity_mut().allocate_immutable(key.as_str());
|
||||
|
||||
let index = context.field_const(offset as u64);
|
||||
let index = context.word_const(offset as u64);
|
||||
let value = arguments.pop().expect("Always exists").into_int_value();
|
||||
revive_llvm_context::polkavm_evm_immutable::store(context, index, value)
|
||||
.map(|_| None)
|
||||
@@ -783,7 +783,7 @@ where
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
|
||||
{
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy => {
|
||||
Ok(Some(context.field_const(0).as_basic_value_enum()))
|
||||
Ok(Some(context.word_const(0).as_basic_value_enum()))
|
||||
}
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
@@ -801,7 +801,7 @@ where
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
|
||||
{
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy => {
|
||||
Ok(Some(context.field_const(0).as_basic_value_enum()))
|
||||
Ok(Some(context.word_const(0).as_basic_value_enum()))
|
||||
}
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime => {
|
||||
revive_llvm_context::polkavm_evm_calldata::size(context).map(Some)
|
||||
@@ -902,7 +902,7 @@ where
|
||||
}
|
||||
.map(|_| None)
|
||||
}
|
||||
InstructionName::PUSHSIZE => Ok(Some(context.field_const(0).as_basic_value_enum())),
|
||||
InstructionName::PUSHSIZE => Ok(Some(context.word_const(0).as_basic_value_enum())),
|
||||
InstructionName::RETURNDATASIZE => {
|
||||
revive_llvm_context::polkavm_evm_return_data::size(context).map(Some)
|
||||
}
|
||||
@@ -1259,7 +1259,7 @@ where
|
||||
)
|
||||
.expect("Always exists");
|
||||
let pointer = revive_llvm_context::PolkaVMPointer::new(
|
||||
context.field_type(),
|
||||
context.word_type(),
|
||||
revive_llvm_context::PolkaVMAddressSpace::Stack,
|
||||
context.evmla().stack
|
||||
[self.stack.elements.len() - output_size + index]
|
||||
@@ -1299,11 +1299,11 @@ where
|
||||
let element_pointer = context.build_gep(
|
||||
pointer,
|
||||
&[
|
||||
context.field_const(0),
|
||||
context.word_const(0),
|
||||
context
|
||||
.integer_const(revive_common::BIT_LENGTH_X32, index as u64),
|
||||
],
|
||||
context.field_type(),
|
||||
context.word_type(),
|
||||
format!("return_value_pointer_element_{}", index).as_str(),
|
||||
);
|
||||
context.build_store(element_pointer, argument)?;
|
||||
|
||||
@@ -766,7 +766,7 @@ impl Function {
|
||||
|
||||
let result = match (&operands[0], &operands[1]) {
|
||||
(Element::Tag(tag), Element::Constant(offset)) => {
|
||||
let offset = offset % revive_common::BIT_LENGTH_FIELD;
|
||||
let offset = offset % revive_common::BIT_LENGTH_WORD;
|
||||
let offset = offset.to_u64().expect("Always valid");
|
||||
let result = tag << offset;
|
||||
if Self::is_tag_value_valid(blocks, &result) {
|
||||
@@ -776,7 +776,7 @@ impl Function {
|
||||
}
|
||||
}
|
||||
(Element::Constant(constant), Element::Constant(offset)) => {
|
||||
let offset = offset % revive_common::BIT_LENGTH_FIELD;
|
||||
let offset = offset % revive_common::BIT_LENGTH_WORD;
|
||||
let offset = offset.to_u64().expect("Always valid");
|
||||
Element::Constant(constant << offset)
|
||||
}
|
||||
@@ -793,7 +793,7 @@ impl Function {
|
||||
|
||||
let result = match (&operands[0], &operands[1]) {
|
||||
(Element::Tag(tag), Element::Constant(offset)) => {
|
||||
let offset = offset % revive_common::BIT_LENGTH_FIELD;
|
||||
let offset = offset % revive_common::BIT_LENGTH_WORD;
|
||||
let offset = offset.to_u64().expect("Always valid");
|
||||
let result = tag >> offset;
|
||||
if Self::is_tag_value_valid(blocks, &result) {
|
||||
@@ -803,7 +803,7 @@ impl Function {
|
||||
}
|
||||
}
|
||||
(Element::Constant(constant), Element::Constant(offset)) => {
|
||||
let offset = offset % revive_common::BIT_LENGTH_FIELD;
|
||||
let offset = offset % revive_common::BIT_LENGTH_WORD;
|
||||
let offset = offset.to_u64().expect("Always valid");
|
||||
Element::Constant(constant >> offset)
|
||||
}
|
||||
@@ -1151,7 +1151,7 @@ where
|
||||
let r#type = context.function_type(
|
||||
vec![
|
||||
context
|
||||
.integer_type(revive_common::BIT_LENGTH_FIELD)
|
||||
.integer_type(revive_common::BIT_LENGTH_WORD)
|
||||
.as_basic_type_enum();
|
||||
input_size
|
||||
],
|
||||
@@ -1200,7 +1200,7 @@ where
|
||||
let mut stack_variables = Vec::with_capacity(self.stack_size);
|
||||
for stack_index in 0..self.stack_size {
|
||||
let pointer = context.build_alloca(
|
||||
context.field_type(),
|
||||
context.word_type(),
|
||||
format!("stack_var_{stack_index:03}").as_str(),
|
||||
);
|
||||
let value = match self.r#type {
|
||||
@@ -1215,7 +1215,7 @@ where
|
||||
.get_nth_param((stack_index - 1) as u32)
|
||||
.expect("Always valid")
|
||||
}
|
||||
_ => context.field_const(0).as_basic_value_enum(),
|
||||
_ => context.word_const(0).as_basic_value_enum(),
|
||||
};
|
||||
context.build_store(pointer, value)?;
|
||||
stack_variables.push(revive_llvm_context::PolkaVMArgument::new(
|
||||
|
||||
Reference in New Issue
Block a user