mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 23:08:01 +00:00
change getters to register version (#138)
This commit is contained in:
@@ -66,21 +66,14 @@ impl Entry {
|
||||
.get_global(crate::polkavm::GLOBAL_CALLDATA_SIZE)?
|
||||
.value
|
||||
.as_pointer_value();
|
||||
let call_data_size_pointer_arg =
|
||||
context.build_alloca_at_entry(context.word_type(), "call_data_size_pointer_arg");
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::CALL_DATA_SIZE,
|
||||
&[call_data_size_pointer_arg.to_int(context).into()],
|
||||
);
|
||||
let value = context.build_load(call_data_size_pointer_arg, "call_data_size_load")?;
|
||||
let value_truncated = context.builder().build_int_truncate(
|
||||
value.into_int_value(),
|
||||
context.xlen_type(),
|
||||
"call_data_size_truncated",
|
||||
)?;
|
||||
let call_data_size_value = context
|
||||
.build_runtime_call(revive_runtime_api::polkavm_imports::CALL_DATA_SIZE, &[])
|
||||
.expect("the call_data_size syscall method should return a value")
|
||||
.into_int_value();
|
||||
context
|
||||
.builder()
|
||||
.build_store(call_data_size_pointer, value_truncated)?;
|
||||
.build_store(call_data_size_pointer, call_data_size_value)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -16,19 +16,20 @@ where
|
||||
Some(address) => address,
|
||||
None => super::context::address(context)?.into_int_value(),
|
||||
};
|
||||
|
||||
let address_pointer = context.build_address_argument_store(address)?;
|
||||
let output_pointer = context.build_alloca_at_entry(context.word_type(), "output_pointer");
|
||||
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::CODE_SIZE,
|
||||
&[
|
||||
address_pointer.to_int(context).into(),
|
||||
output_pointer.to_int(context).into(),
|
||||
],
|
||||
);
|
||||
let code_size_value = context
|
||||
.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::CODE_SIZE,
|
||||
&[address_pointer.to_int(context).into()],
|
||||
)
|
||||
.expect("the code_size syscall method should return a value")
|
||||
.into_int_value();
|
||||
|
||||
context.build_load(output_pointer, "code_size")
|
||||
Ok(context
|
||||
.builder()
|
||||
.build_int_z_extend(code_size_value, context.word_type(), "code_size")?
|
||||
.into())
|
||||
}
|
||||
|
||||
/// Translates the `extcodehash` instruction.
|
||||
|
||||
@@ -10,17 +10,19 @@ pub fn size<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let output_pointer = context.build_alloca_at_entry(context.word_type(), "return_data_size");
|
||||
let output_pointer_parameter = context.builder().build_ptr_to_int(
|
||||
output_pointer.value,
|
||||
context.xlen_type(),
|
||||
"return_data_copy_output_pointer",
|
||||
)?;
|
||||
context.build_runtime_call(
|
||||
revive_runtime_api::polkavm_imports::RETURNDATASIZE,
|
||||
&[output_pointer_parameter.into()],
|
||||
);
|
||||
context.build_load(output_pointer, "return_data_size_load")
|
||||
let return_data_size_value = context
|
||||
.build_runtime_call(revive_runtime_api::polkavm_imports::RETURNDATASIZE, &[])
|
||||
.expect("the return_data_size syscall method should return a value")
|
||||
.into_int_value();
|
||||
|
||||
Ok(context
|
||||
.builder()
|
||||
.build_int_z_extend(
|
||||
return_data_size_value,
|
||||
context.word_type(),
|
||||
"return_data_size",
|
||||
)?
|
||||
.into())
|
||||
}
|
||||
|
||||
/// Translates the return data copy, trapping if
|
||||
|
||||
Reference in New Issue
Block a user