From ed4258a0c925ce7d3437934c26c164a441c3bdb6 Mon Sep 17 00:00:00 2001 From: ade <93547199+oxade@users.noreply.github.com> Date: Fri, 2 Sep 2022 12:27:43 -0400 Subject: [PATCH] More cost snapshot tests (#4449) * improved cost snapshot tests --- Cargo.lock | 5 +- crates/sui-cost/Cargo.toml | 9 +- crates/sui-cost/src/estimator.rs | 15 +- crates/sui-cost/tests/calibration.rs | 63 + .../tests/empirical_transaction_cost.rs | 34 +- ...ration__bytecode_disassemble_snapshot.snap | 2397 +++++++++++++++++ ...bration__natives_disassemble_snapshot.snap | 470 ++++ ...rical_transaction_cost__good_snapshot.snap | 96 +- 8 files changed, 3007 insertions(+), 82 deletions(-) create mode 100644 crates/sui-cost/tests/calibration.rs create mode 100644 crates/sui-cost/tests/snapshots/calibration__bytecode_disassemble_snapshot.snap create mode 100644 crates/sui-cost/tests/snapshots/calibration__natives_disassemble_snapshot.snap diff --git a/Cargo.lock b/Cargo.lock index f53cb6bf11878..a05369eae06f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7167,14 +7167,17 @@ dependencies = [ "anyhow", "bcs", "insta", + "move-cli", + "move-disassembler", + "move-package", "serde 1.0.144", + "serde_json", "strum", "strum_macros", "sui-config", "sui-types", "test-utils", "tokio", - "toml", "workspace-hack 0.1.0", ] diff --git a/crates/sui-cost/Cargo.toml b/crates/sui-cost/Cargo.toml index 6ae8ec015a5af..adc00747c1c86 100644 --- a/crates/sui-cost/Cargo.toml +++ b/crates/sui-cost/Cargo.toml @@ -14,10 +14,13 @@ tokio = { version = "1.20.1", features = ["full"] } serde = { version = "1.0.144", features = ["derive"] } strum = { version = "0.24", features = ["derive"] } strum_macros = "0.24" -toml = "0.5.9" bcs = "0.1.3" +serde_json = "1.0.83" [dev-dependencies] -insta = { version = "1.17.1", features = ["redactions"] } +insta = { version = "1.17.1", features = ["redactions", "json"] } test-utils = { path = "../test-utils" } -sui-config = {path = "../sui-config"} \ No newline at end of file +sui-config = {path = "../sui-config"} +move-cli = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" } +move-disassembler = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" } +move-package = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" } diff --git a/crates/sui-cost/src/estimator.rs b/crates/sui-cost/src/estimator.rs index b325dd8f29e42..adde740a6606e 100644 --- a/crates/sui-cost/src/estimator.rs +++ b/crates/sui-cost/src/estimator.rs @@ -12,7 +12,7 @@ use sui_types::gas::GasCostSummary; use sui_types::messages::SingleTransactionKind; use sui_types::messages::TransactionKind; -pub const ESTIMATE_FILE: &str = "data/estimate.toml"; +pub const ESTIMATE_FILE: &str = "tests/snapshots/empirical_transaction_cost__good_snapshot.snap"; #[derive( Debug, Eq, PartialEq, Hash, Serialize, Deserialize, Ord, PartialOrd, Clone, Display, EnumString, )] @@ -54,9 +54,18 @@ pub fn estimate_computational_costs_for_transaction( pub fn read_estimate_file( ) -> Result, anyhow::Error> { - let toml_str = fs::read_to_string(&ESTIMATE_FILE).unwrap(); + let json_str = fs::read_to_string(&ESTIMATE_FILE).unwrap(); + + // Remove the metadata: first 4 lines form snapshot tests + let json_str = json_str + .split('\n') + .skip(4) + .map(|q| q.to_string()) + .collect::>() + .join("\n"); + + let cost_map: BTreeMap = serde_json::from_str(&json_str).unwrap(); - let cost_map: BTreeMap = toml::from_str(&toml_str).unwrap(); let cost_map: BTreeMap = cost_map .iter() .map(|(k, v)| (CommonTransactionCosts::from_str(k).unwrap(), v.clone())) diff --git a/crates/sui-cost/tests/calibration.rs b/crates/sui-cost/tests/calibration.rs new file mode 100644 index 0000000000000..39f1e3c2e73ef --- /dev/null +++ b/crates/sui-cost/tests/calibration.rs @@ -0,0 +1,63 @@ +// Copyright (c) 2022, Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +use std::path::PathBuf; + +use insta::assert_snapshot; +use move_cli::base::reroot_path; +use move_disassembler::disassembler::Disassembler; +use move_package::BuildConfig; + +const TEST_MODULE_DATA_DIR: &str = "../sui-framework/tests"; + +// Execute every entry function in Move framework and examples and ensure costs don't change +// To review snapshot changes, and fix snapshot differences, +// 0. Install cargo-insta +// 1. Run `cargo insta test --review` under `./sui-cost`. +// 2. Review, accept or reject changes. + +#[tokio::test] +async fn test_natives_disassemble_snapshot() -> Result<(), anyhow::Error> { + let natives_calib = disassemble_test_module("natives_calibration_tests".to_string())?; + + // Assert that nothing has changed in the disassemby of the code + assert_snapshot!(natives_calib); + Ok(()) +} + +#[tokio::test] +async fn test_bytecode_disassemble_snapshot() -> Result<(), anyhow::Error> { + let bytecode_calib = disassemble_test_module("bytecode_calibration_tests".to_string())?; + + // Assert that nothing has changed in the disassemby of the code + assert_snapshot!(bytecode_calib); + Ok(()) +} + +fn disassemble_test_module(name: String) -> anyhow::Result { + let path = PathBuf::from(TEST_MODULE_DATA_DIR); + let config = BuildConfig { + test_mode: true, + ..Default::default() + }; + let package_name: Option = None; + let module_name = name; + + let rerooted_path = reroot_path(Some(path))?; + + let package = config.compile_package(&rerooted_path, &mut Vec::new())?; + let needle_package = package_name + .as_deref() + .unwrap_or(package.compiled_package_info.package_name.as_str()); + match package + .get_module_by_name(needle_package, &module_name) + .ok() + { + None => anyhow::bail!( + "Unable to find module or script with name '{}' in package '{}'", + module_name, + needle_package, + ), + Some(unit) => Disassembler::from_unit(&unit.unit).disassemble(), + } +} diff --git a/crates/sui-cost/tests/empirical_transaction_cost.rs b/crates/sui-cost/tests/empirical_transaction_cost.rs index 770b5a4f4b21e..633014fd050a4 100644 --- a/crates/sui-cost/tests/empirical_transaction_cost.rs +++ b/crates/sui-cost/tests/empirical_transaction_cost.rs @@ -1,11 +1,9 @@ // Copyright (c) 2022, Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -use insta::assert_yaml_snapshot; -use std::fs; +use insta::assert_json_snapshot; use std::{collections::BTreeMap, path::PathBuf}; use sui_config::ValidatorInfo; -use sui_cost::estimator::ESTIMATE_FILE; use sui_cost::estimator::{ estimate_computational_costs_for_transaction, read_estimate_file, CommonTransactionCosts, }; @@ -43,16 +41,17 @@ const TEST_DATA_DIR: &str = "tests/data/"; #[tokio::test] async fn test_good_snapshot() -> Result<(), anyhow::Error> { - let common_costs = run_common_tx_costs().await?; - assert_yaml_snapshot!(common_costs); + let common_costs: BTreeMap = run_common_tx_costs() + .await? + .iter() + .map(|q| (q.0.to_string(), q.1.clone())) + .collect(); + assert_json_snapshot!(common_costs); Ok(()) } #[tokio::test] async fn check_estimates() { - // Generate the estimates to file - generate_estimates().await.unwrap(); - // Read the estimates let cost_map = read_estimate_file().unwrap(); @@ -96,26 +95,9 @@ async fn check_estimates() { ); } -async fn generate_estimates() -> Result<(), anyhow::Error> { - let common_costs: BTreeMap<_, _> = run_common_tx_costs() - .await? - .iter() - .map(|(k, v)| (format!("{k}"), v.clone())) - .collect(); - - let out_string = toml::to_string(&common_costs).unwrap(); - - fs::write(ESTIMATE_FILE, out_string).expect("Could not write estimator to file!"); - Ok(()) -} - pub async fn run_common_tx_costs( ) -> Result, anyhow::Error> { - Ok(run_counter_costs().await) -} - -pub async fn run_counter_costs() -> BTreeMap { - run_cost_test().await.into_iter().collect() + Ok(run_cost_test().await) } async fn run_cost_test() -> BTreeMap { diff --git a/crates/sui-cost/tests/snapshots/calibration__bytecode_disassemble_snapshot.snap b/crates/sui-cost/tests/snapshots/calibration__bytecode_disassemble_snapshot.snap new file mode 100644 index 0000000000000..aa7be2678d9b7 --- /dev/null +++ b/crates/sui-cost/tests/snapshots/calibration__bytecode_disassemble_snapshot.snap @@ -0,0 +1,2397 @@ +--- +source: crates/sui-cost/tests/calibration.rs +expression: bytecode_calib +--- +// Move bytecode v5 +module 2.bytecode_calibration_tests { +struct ObjectWithU64Field has drop, store { + f0: u64 +} +struct ObjectWithU8Field has drop, store { + f0: u8 +} + +entry public test_calibrate_add() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Add + 12: LdU64(1) + 13: Add + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_add__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Add + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_and() { +L0: flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](flag: bool) + 10: LdFalse + 11: And + 12: LdFalse + 13: And + 14: StLoc[0](flag: bool) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_and__baseline() { +L0: flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](flag: bool) + 10: LdFalse + 11: And + 12: StLoc[0](flag: bool) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_bitand() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: BitAnd + 12: LdU64(1) + 13: BitAnd + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_bitand__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: BitAnd + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_bitor() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: BitOr + 12: LdU64(1) + 13: BitOr + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_bitor__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: BitOr + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_cast_u128() { +L0: trials: u64 +L1: val: u8 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) + 2: LdU8(1) + 3: StLoc[1](val: u8) +B1: + 4: CopyLoc[0](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(21) +B3: + 9: CopyLoc[1](val: u8) + 10: CastU128 + 11: Pop + 12: MoveLoc[1](val: u8) + 13: LdU8(1) + 14: Mul + 15: StLoc[1](val: u8) + 16: MoveLoc[0](trials: u64) + 17: LdU64(1) + 18: Sub + 19: StLoc[0](trials: u64) + 20: Branch(4) +B4: + 21: Ret +} +entry public test_calibrate_cast_u128__baseline() { +L0: trials: u64 +L1: val: u8 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) + 2: LdU8(1) + 3: StLoc[1](val: u8) +B1: + 4: CopyLoc[0](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: CopyLoc[1](val: u8) + 10: Pop + 11: MoveLoc[1](val: u8) + 12: LdU8(1) + 13: Mul + 14: StLoc[1](val: u8) + 15: MoveLoc[0](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[0](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_cast_u64() { +L0: trials: u64 +L1: val: u8 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) + 2: LdU8(1) + 3: StLoc[1](val: u8) +B1: + 4: CopyLoc[0](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(21) +B3: + 9: CopyLoc[1](val: u8) + 10: CastU64 + 11: Pop + 12: MoveLoc[1](val: u8) + 13: LdU8(1) + 14: Mul + 15: StLoc[1](val: u8) + 16: MoveLoc[0](trials: u64) + 17: LdU64(1) + 18: Sub + 19: StLoc[0](trials: u64) + 20: Branch(4) +B4: + 21: Ret +} +entry public test_calibrate_cast_u64__baseline() { +L0: trials: u64 +L1: val: u8 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) + 2: LdU8(1) + 3: StLoc[1](val: u8) +B1: + 4: CopyLoc[0](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: CopyLoc[1](val: u8) + 10: Pop + 11: MoveLoc[1](val: u8) + 12: LdU8(1) + 13: Mul + 14: StLoc[1](val: u8) + 15: MoveLoc[0](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[0](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_cast_u8() { +L0: trials: u64 +L1: val: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) + 2: LdU64(1) + 3: StLoc[1](val: u64) +B1: + 4: CopyLoc[0](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(21) +B3: + 9: CopyLoc[1](val: u64) + 10: CastU8 + 11: Pop + 12: MoveLoc[1](val: u64) + 13: LdU64(1) + 14: Mul + 15: StLoc[1](val: u64) + 16: MoveLoc[0](trials: u64) + 17: LdU64(1) + 18: Sub + 19: StLoc[0](trials: u64) + 20: Branch(4) +B4: + 21: Ret +} +entry public test_calibrate_cast_u8__baseline() { +L0: trials: u64 +L1: val: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) + 2: LdU64(1) + 3: StLoc[1](val: u64) +B1: + 4: CopyLoc[0](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: CopyLoc[1](val: u64) + 10: Pop + 11: MoveLoc[1](val: u64) + 12: LdU64(1) + 13: Mul + 14: StLoc[1](val: u64) + 15: MoveLoc[0](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[0](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_copy_loc() { +L0: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) +B1: + 2: CopyLoc[0](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: CopyLoc[0](trials: u64) + 8: Pop + 9: MoveLoc[0](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[0](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_copy_loc__baseline() { +L0: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) +B1: + 2: CopyLoc[0](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(12) +B3: + 7: MoveLoc[0](trials: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[0](trials: u64) + 11: Branch(2) +B4: + 12: Ret +} +entry public test_calibrate_div() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Div + 12: LdU64(1) + 13: Div + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_div__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Div + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_eq() { +L0: flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](flag: bool) + 10: LdTrue + 11: Eq + 12: LdTrue + 13: Eq + 14: StLoc[0](flag: bool) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_eq__baseline() { +L0: flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](flag: bool) + 10: LdTrue + 11: Eq + 12: StLoc[0](flag: bool) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_ge() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(16) +B3: + 7: CopyLoc[1](trials: u64) + 8: LdU64(1) + 9: Ge + 10: Pop + 11: MoveLoc[1](trials: u64) + 12: LdU64(1) + 13: Sub + 14: StLoc[1](trials: u64) + 15: Branch(2) +B4: + 16: Ret +} +entry public test_calibrate_ge__baseline() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: CopyLoc[1](trials: u64) + 8: Pop + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_gt() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(16) +B3: + 7: CopyLoc[1](trials: u64) + 8: LdU64(1) + 9: Gt + 10: Pop + 11: MoveLoc[1](trials: u64) + 12: LdU64(1) + 13: Sub + 14: StLoc[1](trials: u64) + 15: Branch(2) +B4: + 16: Ret +} +entry public test_calibrate_gt__baseline() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: CopyLoc[1](trials: u64) + 8: Pop + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_imm_borrow_field() { +L0: _r: &u64 +L1: obj: ObjectWithU64Field +L2: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[2](trials: u64) + 2: LdU64(0) + 3: Pack[0](ObjectWithU64Field) + 4: StLoc[1](obj: ObjectWithU64Field) +B1: + 5: CopyLoc[2](trials: u64) + 6: LdU64(0) + 7: Gt + 8: BrTrue(10) +B2: + 9: Branch(18) +B3: + 10: ImmBorrowLoc[1](obj: ObjectWithU64Field) + 11: ImmBorrowField[0](ObjectWithU64Field.f0: u64) + 12: Pop + 13: MoveLoc[2](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[2](trials: u64) + 17: Branch(5) +B4: + 18: Ret +} +entry public test_calibrate_imm_borrow_field__baseline() { +L0: _r: &ObjectWithU64Field +L1: obj: ObjectWithU64Field +L2: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[2](trials: u64) + 2: LdU64(0) + 3: Pack[0](ObjectWithU64Field) + 4: StLoc[1](obj: ObjectWithU64Field) +B1: + 5: CopyLoc[2](trials: u64) + 6: LdU64(0) + 7: Gt + 8: BrTrue(10) +B2: + 9: Branch(17) +B3: + 10: ImmBorrowLoc[1](obj: ObjectWithU64Field) + 11: Pop + 12: MoveLoc[2](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[2](trials: u64) + 16: Branch(5) +B4: + 17: Ret +} +entry public test_calibrate_imm_borrow_loc() { +L0: _r: &u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: ImmBorrowLoc[1](trials: u64) + 8: Pop + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_imm_borrow_loc__baseline() { +L0: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) +B1: + 2: CopyLoc[0](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(12) +B3: + 7: MoveLoc[0](trials: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[0](trials: u64) + 11: Branch(2) +B4: + 12: Ret +} +entry public test_calibrate_ld_const() { +L0: _num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: Pop +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(16) +B3: + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 14: Pop + 15: Branch(4) +B4: + 16: Ret +} +entry public test_calibrate_ld_const__baseline() { +L0: _num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: Pop +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(14) +B3: + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(4) +B4: + 14: Ret +} +entry public test_calibrate_ldu128() { +L0: _num: u128 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU128(0) + 3: Pop +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(16) +B3: + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: LdU128(0) + 14: Pop + 15: Branch(4) +B4: + 16: Ret +} +entry public test_calibrate_ldu128__baseline() { +L0: _num: u128 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU128(0) + 3: Pop +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(14) +B3: + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(4) +B4: + 14: Ret +} +entry public test_calibrate_ldu64() { +L0: _num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: Pop +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(16) +B3: + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: LdU64(0) + 14: Pop + 15: Branch(4) +B4: + 16: Ret +} +entry public test_calibrate_ldu64__baseline() { +L0: _num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: Pop +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(14) +B3: + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(4) +B4: + 14: Ret +} +entry public test_calibrate_ldu8() { +L0: _num: u8 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU8(0) + 3: Pop +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(16) +B3: + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: LdU8(0) + 14: Pop + 15: Branch(4) +B4: + 16: Ret +} +entry public test_calibrate_ldu8__baseline() { +L0: _num: u8 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU8(0) + 3: Pop +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(14) +B3: + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(4) +B4: + 14: Ret +} +entry public test_calibrate_le() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(16) +B3: + 7: CopyLoc[1](trials: u64) + 8: LdU64(1) + 9: Le + 10: Pop + 11: MoveLoc[1](trials: u64) + 12: LdU64(1) + 13: Sub + 14: StLoc[1](trials: u64) + 15: Branch(2) +B4: + 16: Ret +} +entry public test_calibrate_le__baseline() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: CopyLoc[1](trials: u64) + 8: Pop + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_lt() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(16) +B3: + 7: CopyLoc[1](trials: u64) + 8: LdU64(1) + 9: Lt + 10: Pop + 11: MoveLoc[1](trials: u64) + 12: LdU64(1) + 13: Sub + 14: StLoc[1](trials: u64) + 15: Branch(2) +B4: + 16: Ret +} +entry public test_calibrate_lt__baseline() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: CopyLoc[1](trials: u64) + 8: Pop + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_mod() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Mod + 12: LdU64(1) + 13: Mod + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_mod__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Mod + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_mul() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Mul + 12: LdU64(1) + 13: Mul + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_mul__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Mul + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_mut_borrow_field() { +L0: _r: &mut u64 +L1: obj: ObjectWithU64Field +L2: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[2](trials: u64) + 2: LdU64(0) + 3: Pack[0](ObjectWithU64Field) + 4: StLoc[1](obj: ObjectWithU64Field) +B1: + 5: CopyLoc[2](trials: u64) + 6: LdU64(0) + 7: Gt + 8: BrTrue(10) +B2: + 9: Branch(18) +B3: + 10: MutBorrowLoc[1](obj: ObjectWithU64Field) + 11: MutBorrowField[0](ObjectWithU64Field.f0: u64) + 12: Pop + 13: MoveLoc[2](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[2](trials: u64) + 17: Branch(5) +B4: + 18: Ret +} +entry public test_calibrate_mut_borrow_field__baseline() { +L0: _r: &mut ObjectWithU64Field +L1: obj: ObjectWithU64Field +L2: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[2](trials: u64) + 2: LdU64(0) + 3: Pack[0](ObjectWithU64Field) + 4: StLoc[1](obj: ObjectWithU64Field) +B1: + 5: CopyLoc[2](trials: u64) + 6: LdU64(0) + 7: Gt + 8: BrTrue(10) +B2: + 9: Branch(17) +B3: + 10: MutBorrowLoc[1](obj: ObjectWithU64Field) + 11: Pop + 12: MoveLoc[2](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[2](trials: u64) + 16: Branch(5) +B4: + 17: Ret +} +entry public test_calibrate_mut_borrow_loc() { +L0: _r: &mut u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: MutBorrowLoc[1](trials: u64) + 8: Pop + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_mut_borrow_loc__baseline() { +L0: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) +B1: + 2: CopyLoc[0](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(12) +B3: + 7: MoveLoc[0](trials: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[0](trials: u64) + 11: Branch(2) +B4: + 12: Ret +} +entry public test_calibrate_neq() { +L0: flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](flag: bool) + 10: LdTrue + 11: Neq + 12: LdTrue + 13: Neq + 14: StLoc[0](flag: bool) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_neq__baseline() { +L0: flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](flag: bool) + 10: LdTrue + 11: Neq + 12: StLoc[0](flag: bool) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_not() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](_flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](_flag: bool) + 10: Not + 11: Not + 12: StLoc[0](_flag: bool) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_not__baseline() { +L0: _flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](_flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(17) +B3: + 9: MoveLoc[0](_flag: bool) + 10: Not + 11: StLoc[0](_flag: bool) + 12: MoveLoc[1](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[1](trials: u64) + 16: Branch(4) +B4: + 17: Ret +} +entry public test_calibrate_or() { +L0: flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](flag: bool) + 10: LdFalse + 11: Or + 12: LdFalse + 13: Or + 14: StLoc[0](flag: bool) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_or__baseline() { +L0: flag: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdFalse + 3: StLoc[0](flag: bool) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](flag: bool) + 10: LdFalse + 11: Or + 12: StLoc[0](flag: bool) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_pack() { +L0: _num: ObjectWithU8Field +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: MoveLoc[1](trials: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[1](trials: u64) + 11: LdU8(0) + 12: Pack[1](ObjectWithU8Field) + 13: Pop + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_pack__baseline() { +L0: _num: ObjectWithU8Field +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: MoveLoc[1](trials: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[1](trials: u64) + 11: LdU8(0) + 12: Pop + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_read_ref() { +L0: r: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](r: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(17) +B3: + 9: ImmBorrowLoc[0](r: u64) + 10: ReadRef + 11: Pop + 12: MoveLoc[1](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[1](trials: u64) + 16: Branch(4) +B4: + 17: Ret +} +entry public test_calibrate_read_ref__baseline() { +L0: r: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](r: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(16) +B3: + 9: ImmBorrowLoc[0](r: u64) + 10: Pop + 11: MoveLoc[1](trials: u64) + 12: LdU64(1) + 13: Sub + 14: StLoc[1](trials: u64) + 15: Branch(4) +B4: + 16: Ret +} +entry public test_calibrate_shl() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU8(1) + 11: Shl + 12: LdU8(1) + 13: Shl + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_shl__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU8(1) + 11: Shl + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_shr() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU8(1) + 11: Shr + 12: LdU8(1) + 13: Shr + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_shr__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU8(1) + 11: Shr + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_sub() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Sub + 12: LdU64(1) + 13: Sub + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_sub__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_unpack() { +L0: _num: ObjectWithU8Field +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(16) +B3: + 7: MoveLoc[1](trials: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[1](trials: u64) + 11: LdU8(0) + 12: Pack[1](ObjectWithU8Field) + 13: Unpack[1](ObjectWithU8Field) + 14: Pop + 15: Branch(2) +B4: + 16: Ret +} +entry public test_calibrate_unpack__baseline() { +L0: _num: ObjectWithU8Field +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: MoveLoc[1](trials: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[1](trials: u64) + 11: LdU8(0) + 12: Pack[1](ObjectWithU8Field) + 13: Pop + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_vec_imm_borrow() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(18) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: ImmBorrowLoc[0](hash: vector) + 10: LdU64(0) + 11: VecImmBorrow(15) + 12: Pop + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(2) +B4: + 18: Ret +} +entry public test_calibrate_vec_imm_borrow__baseline() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(18) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: ImmBorrowLoc[0](hash: vector) + 10: Pop + 11: LdU64(0) + 12: Pop + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(2) +B4: + 18: Ret +} +entry public test_calibrate_vec_len() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(17) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: ImmBorrowLoc[0](hash: vector) + 10: VecLen(15) + 11: Pop + 12: MoveLoc[1](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[1](trials: u64) + 16: Branch(2) +B4: + 17: Ret +} +entry public test_calibrate_vec_len__baseline() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(16) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: ImmBorrowLoc[0](hash: vector) + 10: Pop + 11: MoveLoc[1](trials: u64) + 12: LdU64(1) + 13: Sub + 14: StLoc[1](trials: u64) + 15: Branch(2) +B4: + 16: Ret +} +entry public test_calibrate_vec_mut_borrow() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(18) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: MutBorrowLoc[0](hash: vector) + 10: LdU64(0) + 11: VecMutBorrow(15) + 12: Pop + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(2) +B4: + 18: Ret +} +entry public test_calibrate_vec_mut_borrow__baseline() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(18) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: MutBorrowLoc[0](hash: vector) + 10: Pop + 11: LdU64(0) + 12: Pop + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(2) +B4: + 18: Ret +} +entry public test_calibrate_vec_pack() { +L0: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) +B1: + 2: CopyLoc[0](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: CopyLoc[0](trials: u64) + 8: VecPack(4, 1) + 9: Pop + 10: MoveLoc[0](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[0](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_vec_pack__baseline() { +L0: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) +B1: + 2: CopyLoc[0](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: CopyLoc[0](trials: u64) + 8: Pop + 9: MoveLoc[0](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[0](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_vec_pop_back() { +L0: hash: vector +L1: hash#1: vector +L2: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[2](trials: u64) +B1: + 2: CopyLoc[2](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(17) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: MutBorrowLoc[0](hash: vector) + 10: LdU8(0) + 11: VecPushBack(15) + 12: MoveLoc[2](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[2](trials: u64) + 16: Branch(2) +B4: + 17: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 18: StLoc[2](trials: u64) +B5: + 19: CopyLoc[2](trials: u64) + 20: LdU64(0) + 21: Gt + 22: BrTrue(24) +B6: + 23: Branch(34) +B7: + 24: LdConst[2](Vector(U8): [2, 1, 52]) + 25: StLoc[1](hash#1: vector) + 26: MutBorrowLoc[1](hash#1: vector) + 27: VecPopBack(15) + 28: Pop + 29: MoveLoc[2](trials: u64) + 30: LdU64(1) + 31: Sub + 32: StLoc[2](trials: u64) + 33: Branch(19) +B8: + 34: Ret +} +entry public test_calibrate_vec_pop_back__baseline() { +L0: hash: vector +L1: hash#1: vector +L2: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[2](trials: u64) +B1: + 2: CopyLoc[2](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(17) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: MutBorrowLoc[0](hash: vector) + 10: LdU8(0) + 11: VecPushBack(15) + 12: MoveLoc[2](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[2](trials: u64) + 16: Branch(2) +B4: + 17: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 18: StLoc[2](trials: u64) +B5: + 19: CopyLoc[2](trials: u64) + 20: LdU64(0) + 21: Gt + 22: BrTrue(24) +B6: + 23: Branch(33) +B7: + 24: LdConst[2](Vector(U8): [2, 1, 52]) + 25: StLoc[1](hash#1: vector) + 26: MutBorrowLoc[1](hash#1: vector) + 27: Pop + 28: MoveLoc[2](trials: u64) + 29: LdU64(1) + 30: Sub + 31: StLoc[2](trials: u64) + 32: Branch(19) +B8: + 33: Ret +} +entry public test_calibrate_vec_push_back() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(17) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: MutBorrowLoc[0](hash: vector) + 10: LdU8(0) + 11: VecPushBack(15) + 12: MoveLoc[1](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[1](trials: u64) + 16: Branch(2) +B4: + 17: Ret +} +entry public test_calibrate_vec_push_back__baseline() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(18) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: MutBorrowLoc[0](hash: vector) + 10: Pop + 11: LdU8(0) + 12: Pop + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(2) +B4: + 18: Ret +} +entry public test_calibrate_vec_swap() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(18) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: MutBorrowLoc[0](hash: vector) + 10: LdU64(0) + 11: LdU64(1) + 12: VecSwap(15) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(2) +B4: + 18: Ret +} +entry public test_calibrate_vec_swap__baseline() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(20) +B3: + 7: LdConst[2](Vector(U8): [2, 1, 52]) + 8: StLoc[0](hash: vector) + 9: MutBorrowLoc[0](hash: vector) + 10: Pop + 11: LdU64(0) + 12: Pop + 13: LdU64(1) + 14: Pop + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(2) +B4: + 20: Ret +} +entry public test_calibrate_vec_unpack() { +L0: hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: LdConst[3](Vector(U8): [0]) + 8: VecUnpack(15, 0) + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_vec_unpack__baseline() { +L0: _hash: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: LdConst[3](Vector(U8): [0]) + 8: Pop + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_write_ref() { +L0: r: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](r: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(17) +B3: + 9: CopyLoc[1](trials: u64) + 10: MutBorrowLoc[0](r: u64) + 11: WriteRef + 12: MoveLoc[1](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[1](trials: u64) + 16: Branch(4) +B4: + 17: Ret +} +entry public test_calibrate_write_ref__baseline() { +L0: r: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdU64(0) + 3: StLoc[0](r: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: CopyLoc[1](trials: u64) + 10: Pop + 11: MutBorrowLoc[0](r: u64) + 12: Pop + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +entry public test_calibrate_xor() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(20) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Xor + 12: LdU64(1) + 13: Xor + 14: StLoc[0](num: u64) + 15: MoveLoc[1](trials: u64) + 16: LdU64(1) + 17: Sub + 18: StLoc[1](trials: u64) + 19: Branch(4) +B4: + 20: Ret +} +entry public test_calibrate_xor__baseline() { +L0: num: u64 +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) + 2: LdConst[1](U64: [255, 255, 255, 255, 255, 255, 255, 255]) + 3: StLoc[0](num: u64) +B1: + 4: CopyLoc[1](trials: u64) + 5: LdU64(0) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(18) +B3: + 9: MoveLoc[0](num: u64) + 10: LdU64(1) + 11: Xor + 12: StLoc[0](num: u64) + 13: MoveLoc[1](trials: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[1](trials: u64) + 17: Branch(4) +B4: + 18: Ret +} +unit_test_poison() { +B0: + 0: LdU64(0) + 1: Call[87](create_signers_for_testing(u64): vector) + 2: Pop + 3: Ret +} +} diff --git a/crates/sui-cost/tests/snapshots/calibration__natives_disassemble_snapshot.snap b/crates/sui-cost/tests/snapshots/calibration__natives_disassemble_snapshot.snap new file mode 100644 index 0000000000000..9c2122bd1e08a --- /dev/null +++ b/crates/sui-cost/tests/snapshots/calibration__natives_disassemble_snapshot.snap @@ -0,0 +1,470 @@ +--- +source: crates/sui-cost/tests/calibration.rs +expression: natives_calib +--- +// Move bytecode v5 +module 2.natives_calibration_tests { +struct ObjectSimple has copy, drop, store, key { + dummy_field: bool +} +struct ObjectWithID has store, key { + id: UID +} + +entry public test_calibrate_event_emit() { +L0: obj1: ObjectSimple +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: LdFalse + 8: Pack[0](ObjectSimple) + 9: Call[0](calibrate_emit(ObjectSimple)) + 10: MoveLoc[1](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[1](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_event_emit__baseline() { +L0: obj1: ObjectSimple +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: LdFalse + 8: Pack[0](ObjectSimple) + 9: Call[1](calibrate_emit_nop(ObjectSimple)) + 10: MoveLoc[1](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[1](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_id_borrow_uid() { +L0: %#1: Scenario +L1: id: UID +L2: obj: ObjectWithID +L3: scenario: &mut Scenario +L4: sender: address +L5: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[5](trials: u64) + 2: LdConst[1](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + 3: StLoc[4](sender: address) + 4: ImmBorrowLoc[4](sender: address) + 5: Call[19](begin(&address): Scenario) + 6: StLoc[0](%#1: Scenario) + 7: MutBorrowLoc[0](%#1: Scenario) + 8: StLoc[3](scenario: &mut Scenario) +B1: + 9: CopyLoc[5](trials: u64) + 10: LdU64(0) + 11: Gt + 12: BrTrue(14) +B2: + 13: Branch(31) +B3: + 14: CopyLoc[3](scenario: &mut Scenario) + 15: Call[20](ctx(&mut Scenario): &mut TxContext) + 16: Call[21](new(&mut TxContext): UID) + 17: Pack[1](ObjectWithID) + 18: StLoc[2](obj: ObjectWithID) + 19: ImmBorrowLoc[2](obj: ObjectWithID) + 20: Call[2](calibrate_borrow_uid(&ObjectWithID)) + 21: MoveLoc[2](obj: ObjectWithID) + 22: Unpack[1](ObjectWithID) + 23: StLoc[1](id: UID) + 24: MoveLoc[1](id: UID) + 25: Call[23](delete(UID)) + 26: MoveLoc[5](trials: u64) + 27: LdU64(1) + 28: Sub + 29: StLoc[5](trials: u64) + 30: Branch(9) +B4: + 31: MoveLoc[3](scenario: &mut Scenario) + 32: Pop + 33: Ret +} +entry public test_calibrate_id_borrow_uid__baseline() { +L0: %#1: Scenario +L1: id: UID +L2: obj: ObjectWithID +L3: scenario: &mut Scenario +L4: sender: address +L5: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[5](trials: u64) + 2: LdConst[1](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + 3: StLoc[4](sender: address) + 4: ImmBorrowLoc[4](sender: address) + 5: Call[19](begin(&address): Scenario) + 6: StLoc[0](%#1: Scenario) + 7: MutBorrowLoc[0](%#1: Scenario) + 8: StLoc[3](scenario: &mut Scenario) +B1: + 9: CopyLoc[5](trials: u64) + 10: LdU64(0) + 11: Gt + 12: BrTrue(14) +B2: + 13: Branch(33) +B3: + 14: CopyLoc[3](scenario: &mut Scenario) + 15: Call[20](ctx(&mut Scenario): &mut TxContext) + 16: Call[21](new(&mut TxContext): UID) + 17: Pack[1](ObjectWithID) + 18: StLoc[2](obj: ObjectWithID) + 19: ImmBorrowLoc[2](obj: ObjectWithID) + 20: Call[2](calibrate_borrow_uid(&ObjectWithID)) + 21: ImmBorrowLoc[2](obj: ObjectWithID) + 22: Pop + 23: MoveLoc[2](obj: ObjectWithID) + 24: Unpack[1](ObjectWithID) + 25: StLoc[1](id: UID) + 26: MoveLoc[1](id: UID) + 27: Call[23](delete(UID)) + 28: MoveLoc[5](trials: u64) + 29: LdU64(1) + 30: Sub + 31: StLoc[5](trials: u64) + 32: Branch(9) +B4: + 33: MoveLoc[3](scenario: &mut Scenario) + 34: Pop + 35: Ret +} +entry public test_calibrate_id_bytes_to_address() { +L0: bytes: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: LdConst[2](Vector(U8): [20, 58, 152, 93, 167, 79, 226, 37, 178, 4, 92, 23, 45, 107, 211, 144, 189, 133, 95, 8, 110]) + 8: Call[24](calibrate_bytes_to_address(vector)) + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_id_bytes_to_address__baseline() { +L0: bytes: vector +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: LdConst[2](Vector(U8): [20, 58, 152, 93, 167, 79, 226, 37, 178, 4, 92, 23, 45, 107, 211, 144, 189, 133, 95, 8, 110]) + 8: Call[25](calibrate_bytes_to_address_nop(vector)) + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_pop() { +L0: _k: bool +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(14) +B3: + 7: LdFalse + 8: Pop + 9: MoveLoc[1](trials: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[1](trials: u64) + 13: Branch(2) +B4: + 14: Ret +} +entry public test_calibrate_pop__baseline() { +L0: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](trials: u64) +B1: + 2: CopyLoc[0](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(12) +B3: + 7: MoveLoc[0](trials: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[0](trials: u64) + 11: Branch(2) +B4: + 12: Ret +} +entry public test_calibrate_transfer_freeze_object() { +L0: obj1: ObjectSimple +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: LdFalse + 8: Pack[0](ObjectSimple) + 9: Call[3](calibrate_freeze_object(ObjectSimple)) + 10: MoveLoc[1](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[1](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_transfer_freeze_object__baseline() { +L0: obj1: ObjectSimple +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: LdFalse + 8: Pack[0](ObjectSimple) + 9: Call[4](calibrate_freeze_object_nop(ObjectSimple)) + 10: MoveLoc[1](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[1](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_transfer_share_object() { +L0: obj1: ObjectSimple +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: LdFalse + 8: Pack[0](ObjectSimple) + 9: Call[5](calibrate_share_object(ObjectSimple)) + 10: MoveLoc[1](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[1](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_transfer_share_object__baseline() { +L0: obj1: ObjectSimple +L1: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: LdFalse + 8: Pack[0](ObjectSimple) + 9: Call[6](calibrate_share_object_nop(ObjectSimple)) + 10: MoveLoc[1](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[1](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_transfer_transfer_internal() { +L0: addr: address +L1: obj1: ObjectSimple +L2: to_object: bool +L3: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[3](trials: u64) +B1: + 2: CopyLoc[3](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(17) +B3: + 7: LdFalse + 8: Pack[0](ObjectSimple) + 9: LdConst[1](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + 10: LdFalse + 11: Call[7](calibrate_transfer_internal(ObjectSimple, address, bool)) + 12: MoveLoc[3](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[3](trials: u64) + 16: Branch(2) +B4: + 17: Ret +} +entry public test_calibrate_transfer_transfer_internal__baseline() { +L0: addr: address +L1: obj1: ObjectSimple +L2: to_object: bool +L3: trials: u64 +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[3](trials: u64) +B1: + 2: CopyLoc[3](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(17) +B3: + 7: LdFalse + 8: Pack[0](ObjectSimple) + 9: LdConst[1](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + 10: LdFalse + 11: Call[8](calibrate_transfer_internal_nop(ObjectSimple, address, bool)) + 12: MoveLoc[3](trials: u64) + 13: LdU64(1) + 14: Sub + 15: StLoc[3](trials: u64) + 16: Branch(2) +B4: + 17: Ret +} +entry public test_calibrate_tx_context_derive_id() { +L0: created_num: u64 +L1: trials: u64 +L2: tx_hash: vector +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: LdConst[3](Vector(U8): [32, 58, 152, 93, 167, 79, 226, 37, 178, 4, 92, 23, 45, 107, 211, 144, 189, 133, 95, 8, 110, 62, 157, 82, 91, 70, 191, 226, 69, 17, 67, 21, 50]) + 8: LdU64(0) + 9: Call[32](calibrate_derive_id(vector, u64)) + 10: MoveLoc[1](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[1](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +entry public test_calibrate_tx_context_derive_id__baseline() { +L0: created_num: u64 +L1: trials: u64 +L2: tx_hash: vector +B0: + 0: LdConst[0](U64: [1, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[1](trials: u64) +B1: + 2: CopyLoc[1](trials: u64) + 3: LdU64(0) + 4: Gt + 5: BrTrue(7) +B2: + 6: Branch(15) +B3: + 7: LdConst[3](Vector(U8): [32, 58, 152, 93, 167, 79, 226, 37, 178, 4, 92, 23, 45, 107, 211, 144, 189, 133, 95, 8, 110, 62, 157, 82, 91, 70, 191, 226, 69, 17, 67, 21, 50]) + 8: LdU64(0) + 9: Call[33](calibrate_derive_id_nop(vector, u64)) + 10: MoveLoc[1](trials: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[1](trials: u64) + 14: Branch(2) +B4: + 15: Ret +} +unit_test_poison() { +B0: + 0: LdU64(0) + 1: Call[34](create_signers_for_testing(u64): vector) + 2: Pop + 3: Ret +} +} diff --git a/crates/sui-cost/tests/snapshots/empirical_transaction_cost__good_snapshot.snap b/crates/sui-cost/tests/snapshots/empirical_transaction_cost__good_snapshot.snap index 0da9548efecbf..0bd2ab1d56846 100644 --- a/crates/sui-cost/tests/snapshots/empirical_transaction_cost__good_snapshot.snap +++ b/crates/sui-cost/tests/snapshots/empirical_transaction_cost__good_snapshot.snap @@ -2,52 +2,50 @@ source: crates/sui-cost/tests/empirical_transaction_cost.rs expression: common_costs --- -Publish: - computation_cost: 521 - storage_cost: 83 - storage_rebate: 0 -MergeCoin: - computation_cost: 463 - storage_cost: 32 - storage_rebate: 0 -? SplitCoin: 0 -: computation_cost: 446 - storage_cost: 32 - storage_rebate: 0 -? SplitCoin: 1 -: computation_cost: 488 - storage_cost: 48 - storage_rebate: 0 -? SplitCoin: 2 -: computation_cost: 531 - storage_cost: 64 - storage_rebate: 0 -? SplitCoin: 3 -: computation_cost: 574 - storage_cost: 80 - storage_rebate: 0 -TransferWholeCoin: - computation_cost: 41 - storage_cost: 32 - storage_rebate: 0 -TransferWholeSuiCoin: - computation_cost: 38 - storage_cost: 32 - storage_rebate: 0 -TransferPortionSuiCoin: - computation_cost: 45 - storage_cost: 48 - storage_rebate: 0 -SharedCounterCreate: - computation_cost: 109 - storage_cost: 31 - storage_rebate: 0 -SharedCounterAssertValue: - computation_cost: 198 - storage_cost: 31 - storage_rebate: 15 -SharedCounterIncrement: - computation_cost: 197 - storage_cost: 31 - storage_rebate: 15 - +{ + "MergeCoin": { + "computation_cost": 463, + "storage_cost": 32, + "storage_rebate": 0 + }, + "Publish": { + "computation_cost": 521, + "storage_cost": 83, + "storage_rebate": 0 + }, + "SharedCounterAssertValue": { + "computation_cost": 198, + "storage_cost": 31, + "storage_rebate": 15 + }, + "SharedCounterCreate": { + "computation_cost": 109, + "storage_cost": 31, + "storage_rebate": 0 + }, + "SharedCounterIncrement": { + "computation_cost": 197, + "storage_cost": 31, + "storage_rebate": 15 + }, + "SplitCoin": { + "computation_cost": 574, + "storage_cost": 80, + "storage_rebate": 0 + }, + "TransferPortionSuiCoin": { + "computation_cost": 45, + "storage_cost": 48, + "storage_rebate": 0 + }, + "TransferWholeCoin": { + "computation_cost": 41, + "storage_cost": 32, + "storage_rebate": 0 + }, + "TransferWholeSuiCoin": { + "computation_cost": 38, + "storage_cost": 32, + "storage_rebate": 0 + } +}