change getters to register version (#138)

This commit is contained in:
Cyrill Leutwiler
2024-12-18 17:56:37 +01:00
committed by GitHub
parent 14a598e840
commit d299dd1a19
7 changed files with 409 additions and 413 deletions
Generated
+367 -367
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -68,7 +68,7 @@ git2 = "0.19.0"
# polkadot-sdk and friends
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
scale-info = { version = "2.11.1", default-features = false }
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "6ad748857e0e63c38cb7bb9435831ae73ab708cf" }
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "53f6473c9c8c9d18b5ef0ed02a587757495d1dbf" }
# llvm
[workspace.dependencies.inkwell]
+8 -8
View File
@@ -1,10 +1,10 @@
{
"Baseline": 1115,
"Computation": 2394,
"DivisionArithmetics": 14470,
"ERC20": 22747,
"Events": 1609,
"FibonacciIterative": 1659,
"Flipper": 1994,
"SHA1": 16817
"Baseline": 1099,
"Computation": 2378,
"DivisionArithmetics": 14454,
"ERC20": 22731,
"Events": 1593,
"FibonacciIterative": 1643,
"Flipper": 1978,
"SHA1": 16801
}
@@ -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(())
}
+11 -10
View File
@@ -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
+3 -3
View File
@@ -80,7 +80,7 @@ POLKAVM_IMPORT(uint64_t, call_data_copy, uint32_t, uint32_t, uint32_t)
POLKAVM_IMPORT(uint64_t, call_data_load, uint32_t, uint32_t)
POLKAVM_IMPORT(uint64_t, call_data_size, uint32_t)
POLKAVM_IMPORT(uint64_t, call_data_size)
POLKAVM_IMPORT(uint64_t, delegate_call, uint32_t)
@@ -88,7 +88,7 @@ POLKAVM_IMPORT(void, caller, uint32_t)
POLKAVM_IMPORT(void, chain_id, uint32_t)
POLKAVM_IMPORT(void, code_size, uint32_t, uint32_t)
POLKAVM_IMPORT(uint64_t, code_size, uint32_t)
POLKAVM_IMPORT(void, code_hash, uint32_t, uint32_t)
@@ -112,7 +112,7 @@ POLKAVM_IMPORT(uint64_t, ref_time_left)
POLKAVM_IMPORT(void, return_data_copy, uint32_t, uint32_t, uint32_t)
POLKAVM_IMPORT(void, return_data_size, uint32_t)
POLKAVM_IMPORT(uint64_t, return_data_size)
POLKAVM_IMPORT(void, set_immutable_data, uint32_t, uint32_t);