diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..a3cd55a9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +# Ensure that text files that any contributor introduces to the repository +# have their line endings normalized to LF +* text=auto + +# All known text filetypes +*.md text +*.proto text +*.rs text +*.sh text +*.toml text +*.txt text +*.yml text + +# Use Move syntax highlighter for Move IR code +*.mvir linguist-language=Move diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..bc83034e --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +# Rust specific ignores +# Please follow https://help.github.com/en/articles/ignoring-files to create a global +# .gitignore file locally for IDE/Emacs/Vim generated files. +**/target +**/*.rs.bk +.idea/ +**/.vscode + +# Ignore wallet mnemonic files used for deterministic key derivation +*.mnemonic + +# GDB related +**/.gdb_history + +# macOS Specific ignores +# General +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Terraform +.terraform/ + +# Move Build Output +build/ + +# Move coverage and tracing information +.trace +*.mvcov + +# Docker incremental build temporary files and directories +target-out-docker +**/Dockerfile.tmp + +# Doc generation output +*.md.old + +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..0e7edeec --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,491 @@ +[workspace] +resolver = "2" + +members = [ + "extensions/async/move-async-vm", + "extensions/move-table-extension", + "move-binary-format", + "move-binary-format/serializer-tests", + "move-borrow-graph", + "move-bytecode-spec", + "move-bytecode-verifier", + "move-bytecode-verifier/bytecode-verifier-tests", + "move-bytecode-verifier/fuzz", + "move-bytecode-verifier/invalid-mutations", + "move-bytecode-verifier/transactional-tests", + "move-command-line-common", + "move-compiler", + "move-compiler-v2", + "move-compiler-v2/tools/testdiff", + "move-compiler-v2/transactional-tests", + "move-compiler/transactional-tests", + "move-core/types", + "move-examples", + "move-ir-compiler", + "move-ir-compiler/move-bytecode-source-map", + "move-ir-compiler/move-ir-to-bytecode", + "move-ir-compiler/move-ir-to-bytecode/syntax", + "move-ir-compiler/transactional-tests", + "move-ir/types", + "move-model", + "move-model/bytecode", + "move-model/bytecode-test-utils", + "move-model/bytecode/ast-generator-tests", + "move-prover", + "move-prover/boogie-backend", + "move-prover/bytecode-pipeline", + "move-prover/lab", + "move-prover/move-abigen", + "move-prover/move-docgen", + "move-prover/move-errmapgen", + "move-prover/test-utils", + "move-symbol-pool", + "move-vm/integration-tests", + "move-vm/paranoid-tests", + "move-vm/runtime", + "move-vm/test-utils", + "move-vm/transactional-tests", + "move-vm/types", + "testing-infra/module-generation", + "testing-infra/test-generation", + "testing-infra/transactional-test-runner", + "tools/move-bytecode-utils", + "tools/move-bytecode-viewer", + "tools/move-cli", + "tools/move-coverage", + "tools/move-disassembler", + "tools/move-explain", + "tools/move-package", + "tools/move-resource-viewer", + "tools/move-unit-test", +] + +# All workspace members should inherit these keys +# for package declarations. +[workspace.package] +authors = ["Aptos Labs "] +edition = "2021" +homepage = "https://aptoslabs.com" +license = "Apache-2.0" +publish = false +repository = "https://github.com/aptos-labs/aptos-core" +rust-version = "1.78.0" + +# Dependencies that should be kept in sync through the whole workspace +[workspace.dependencies] + +# External crate dependencies. +# Please do not add any test features here: they should be declared by the individual crate. +aes-gcm = "0.10.3" +ahash = "0.8.11" +atty = "0.2.14" +nalgebra = "0.32" +float-cmp = "0.9.0" +again = "0.1.2" +ambassador = "0.4.1" +anyhow = "1.0.71" +anstyle = "1.0.1" +arbitrary = { version = "1.3.2", features = ["derive"] } +arc-swap = "1.6.0" +arr_macro = "0.2.1" +ark-bls12-381 = "0.4.0" +ark-bn254 = "0.4.0" +ark-circom = { git = "https://github.com/aptos-labs/circom-compat", rev = "e3d686641a3dd9d66087a74acdc20dc2a3c24f63" } +ark-crypto-primitives = "0.4.0" +ark-ec = "0.4.0" +ark-ff = "0.4.0" +ark-groth16 = "0.4.0" +ark-relations = "0.4.0" +ark-serialize = "0.4.0" +ark-std = { version = "0.4.0", features = ["getrandom"] } +aptos-moving-average = { git = "https://github.com/aptos-labs/aptos-indexer-processors.git", rev = "4801acae7aea30d7e96bbfbe5ec5b04056dfa4cf" } +assert_approx_eq = "1.1.0" +assert_unordered = "0.3.5" +async-channel = "1.7.1" +async-mutex = "1.4.0" +async-recursion = "1.0.5" +async-stream = "0.3" +async-trait = "0.1.53" +axum = "0.7.5" +base64 = "0.13.0" +base64-url = "2.0.1" +backoff = { version = "0.4.0", features = ["tokio"] } +backtrace = "0.3.58" +bcs = { git = "https://github.com/aptos-labs/bcs.git", rev = "d31fab9d81748e2594be5cd5cdf845786a30562d" } +better_any = "0.1.1" +bellman = { version = "0.13.1", default-features = false } +bigdecimal = { version = "0.4.0", features = ["serde"] } +version-compare = "0.1.1" +bitvec = "1.0.1" +blake2 = "0.10.4" +blake2-rfc = "0.2.18" +blst = "0.3.11" +# The __private_bench feature exposes the Fp12 type which we need to implement a multi-threaded multi-pairing. +blstrs = { version = "0.7.1", features = ["serde", "__private_bench"] } +bollard = "0.15" +bulletproofs = { version = "4.0.0" } +byteorder = "1.4.3" +bytes = { version = "1.4.0", features = ["serde"] } +camino = { version = "1.1.6" } +chrono = { version = "0.4.19", features = ["clock", "serde"] } +cfg_block = "0.1.1" +cfg-if = "1.0.0" +ciborium = "0.2" +claims = "0.7" +clap = { version = "4.3.9", features = [ + "derive", + "env", + "unstable-styles", + "wrap_help", +] } +clap-verbosity-flag = "2.1.1" +clap_complete = "4.4.1" +cloud-storage = { version = "0.11.1", features = [ + "global-client", + "rustls-tls", +], default-features = false } +codespan = "0.11.1" +codespan-reporting = "0.11.1" +colored = "2.0.0" +concurrent-queue = "2.2.0" +console-subscriber = "0.3.0" +const_format = "0.2.26" +core_affinity = "0.8.1" +coset = "0.3" +criterion = "0.3.5" +criterion-cpu-time = "0.1.0" +crossbeam = "0.8.1" +crossbeam-channel = "0.5.4" +crossterm = "0.26.1" +csv = "1.2.1" +curve25519-dalek = "3" +curve25519-dalek-ng = "4" +dashmap = { version = "5.5.3", features = ["inline"] } +datatest-stable = "0.1.1" +debug-ignore = { version = "1.0.3", features = ["serde"] } +derivative = "2.2.0" +derivation-path = "0.2.0" +derive_builder = "0.20.0" +determinator = "0.12.0" +derive_more = "0.99.11" +diesel = "2.1" +# Use the crate version once this feature gets released on crates.io: +# https://github.com/weiznich/diesel_async/commit/e165e8c96a6c540ebde2d6d7c52df5c5620a4bf1 +diesel-async = { git = "https://github.com/weiznich/diesel_async.git", rev = "d02798c67065d763154d7272dd0c09b39757d0f2", features = [ + "async-connection-wrapper", + "postgres", + "bb8", + "tokio", +] } +diesel_migrations = { version = "2.1.0", features = ["postgres"] } +difference = "2.0.0" +digest = "0.9.0" +dir-diff = "0.3.2" +dirs = "5.0.1" +dirs-next = "2.0.0" +dunce = "1.0.4" +ed25519-dalek = { version = "1.0.1", features = ["std", "serde"] } +ed25519-dalek-bip32 = "0.2.0" +either = "1.6.1" +enum_dispatch = "0.3.12" +env_logger = "0.10.0" +erased-serde = "0.3.13" +ethabi = "18.0.0" +ethnum = "1.5.0" +event-listener = "2.5.3" +evm = { version = "0.33.1", features = ["tracing"] } +evm-runtime = { version = "0.33.0", features = ["tracing"] } +fail = "0.5.0" +ff = { version = "0.13", features = ["derive"] } +field_count = "0.1.1" +file_diff = "1.0.0" +firestore = "0.43.0" +fixed = "1.25.1" +flate2 = "1.0.24" +flexi_logger = "0.27.4" +futures = "0.3.29" +futures-channel = "0.3.29" +futures-core = "0.3.29" +futures-util = "0.3.29" +fxhash = "0.2.1" +getrandom = "0.2.2" +gcp-bigquery-client = "0.16.8" +get_if_addrs = "0.5.3" +git2 = "0.16.1" +glob = "0.3.0" +goldenfile = "1.5.2" +google-cloud-storage = "0.13.0" +group = "0.13" +guppy = "0.17.5" +handlebars = "4.2.2" +hashbrown = "0.14.3" +heck = "0.4.1" +hex = { version = "0.4.3", features = ["serde"] } +hex-literal = "0.3.4" +hkdf = "0.10.0" +hmac = "0.12.0" +hostname = "0.3.1" +http = "0.2.9" +httpmock = "0.6.8" +hyper = { version = "0.14.18", features = ["full"] } +hyper-tls = "0.5.0" +image = "0.24.5" +indexmap = "1.9.3" +include_dir = { version = "0.7.2", features = ["glob"] } +indicatif = "0.15.0" +indoc = "1.0.6" +inferno = "0.11.14" +internment = { version = "0.5.0", features = ["arc"] } +ipnet = "2.5.0" +itertools = "0.13" +jemallocator = { version = "0.5.0", features = [ + "profiling", + "unprefixed_malloc_on_supported_platforms", +] } +jemalloc-sys = "0.5.4" +json-patch = "0.2.6" +jsonwebtoken = "8.1" +jwt = "0.16.0" +lazy_static = "1.4.0" +libc = "0.2.147" +libfuzzer-sys = "0.4.6" +libsecp256k1 = "0.7.0" +log = "0.4.17" +lru = "0.7.5" +lz4 = "1.25.0" +maplit = "1.0.2" +merlin = "3" +memory-stats = "1.0.0" +mime = "0.3.16" +mini-moka = { version = "0.10.3", features = ["sync"] } +mirai-annotations = "1.12.0" +mockall = "0.11.4" +more-asserts = "0.3.0" +named-lock = "0.2.0" +native-tls = "0.2.10" +neptune = { version = "13.0.0", default_features = false } +ntest = "0.9.3" +num = "0.4.0" +num-bigint = { version = "0.3.2", features = ["rand"] } +num_cpus = "1.13.1" +num-derive = "0.3.3" +num-integer = "0.1.42" +num-traits = "0.2.15" +once_cell = "1.10.0" +ordered-float = "3.9.1" +ouroboros = "0.15.6" +owo-colors = "3.5.0" +p256 = { version = "0.13.2" } +prettydiff = "0.6.2" +primitive-types = { version = "0.10" } +signature = "2.1.0" +sec1 = "0.7.0" +pairing = "0.23" +parking_lot = "0.12.0" +paste = "1.0.7" +pathsearch = "0.2.0" +passkey-authenticator = { version = "0.2.0", features = ["testable"] } +passkey-client = { version = "0.2.0" } +passkey-types = { version = "0.2.0" } +pbjson = "0.5.1" +percent-encoding = "2.1.0" +petgraph = "0.6.5" +pin-project = "1.0.10" +plotters = { version = "0.3.5", default-features = false } +# We're using git deps until https://github.com/poem-web/poem/pull/829 gets formally released. +poem = { git = "https://github.com/poem-web/poem.git", rev = "809b2816d3504beeba140fef3fdfe9432d654c5b", features = [ + "anyhow", + "rustls", +] } +poem-openapi = { git = "https://github.com/poem-web/poem.git", rev = "809b2816d3504beeba140fef3fdfe9432d654c5b", features = [ + "swagger-ui", + "url", +] } +poem-openapi-derive = { git = "https://github.com/poem-web/poem.git", rev = "809b2816d3504beeba140fef3fdfe9432d654c5b" } +poseidon-ark = { git = "https://github.com/arnaucube/poseidon-ark.git", rev = "6d2487aa1308d9d3860a2b724c485d73095c1c68" } +pprof = { version = "0.11", features = ["flamegraph", "protobuf-codec"] } +pretty = "0.10.0" +pretty_assertions = "1.2.1" +procfs = "0.14.1" +proc-macro2 = "1.0.38" +project-root = "0.2.2" +prometheus = { version = "0.13.3", default-features = false } +prometheus-http-query = "0.5.2" +prometheus-parse = "0.2.4" +proptest = "1.4.0" +proptest-derive = "0.4.0" +prost = { version = "0.12.3", features = ["no-recursion-limit"] } +prost-types = "0.12.3" +quanta = "0.10.1" +quick_cache = "0.5.1" +quote = "1.0.18" +rand = "0.7.3" +rand_core = "0.5.1" +random_word = "0.3.0" +rayon = "1.5.2" +redis = { version = "0.22.3", features = [ + "tokio-comp", + "script", + "connection-manager", +] } +redis-test = { version = "0.1.1", features = ["aio"] } +ref-cast = "1.0.6" +regex = "1.9.3" +reqwest = { version = "0.11.11", features = [ + "blocking", + "cookies", + "json", + "multipart", + "stream", +] } +reqwest-middleware = "0.2.0" +reqwest-retry = "0.2.1" +ring = { version = "0.16.20", features = ["std"] } +ripemd = "0.1.1" +rocksdb = { version = "0.22.0", features = ["lz4"] } +rsa = { version = "0.9.6" } +rstack-self = { version = "0.3.0", features = ["dw"], default_features = false } +rstest = "0.15.0" +rusty-fork = "0.3.0" +rustversion = "1.0.14" +scopeguard = "1.2.0" +sha-1 = "0.10.0" +sha2 = "0.9.3" +sha256 = "1.4.0" +sha2_0_10_6 = { package = "sha2", version = "0.10.6" } +sha3 = "0.9.1" +shell-words = "1.0.0" +siphasher = "0.3.10" +serde = { version = "1.0.193", features = ["derive", "rc"] } +serde-big-array = "0.5.1" +serde_bytes = "0.11.6" +serde_json = { version = "1.0.81", features = [ + "preserve_order", + "arbitrary_precision", +] } # Note: arbitrary_precision is required to parse u256 in JSON +serde_repr = "0.1" +serde_merge = "0.1.3" +serde-name = "0.1.1" +serde-generate = { git = "https://github.com/aptos-labs/serde-reflection", rev = "73b6bbf748334b71ff6d7d09d06a29e3062ca075" } +serde-reflection = { git = "https://github.com/aptos-labs/serde-reflection", rev = "73b6bbf748334b71ff6d7d09d06a29e3062ca075" } +serde_with = "3.4.0" +serde_yaml = "0.8.24" +set_env = "1.3.4" +shadow-rs = "0.16.2" +simplelog = "0.9.0" +smallbitvec = "2.5.1" +smallvec = "1.8.0" +static_assertions = "1.1.0" +stats_alloc = "0.1.8" +status-line = "0.2.0" +strum = "0.24.1" +strum_macros = "0.24.2" +syn = { version = "1.0.92", features = ["derive", "extra-traits"] } +sysinfo = "0.28.4" +tar = "0.4.40" +tempfile = "3.3.0" +tera = "1.16.0" +termcolor = "1.1.2" +test-case = "3.1.0" +textwrap = "0.15.0" +thiserror = "1.0.37" +threadpool = "1.8.1" +thread_local = "1.1.7" +time = { version = "0.3.24", features = ["serde"] } +tiny-bip39 = "0.8.2" +tiny-keccak = { version = "2.0.2", features = ["keccak", "sha3"] } +toml_edit = "0.14.3" +tracing = "0.1.37" +tracing-subscriber = { version = "0.3.17", features = ["json", "env-filter"] } +trybuild = "1.0.80" +tokio = { version = "1.35.1", features = ["full"] } +tokio-io-timeout = "1.2.0" +tokio-metrics = "0.3.1" +tokio-retry = "0.3.0" +tokio-scoped = { version = "0.2.0" } +tokio-stream = { version = "0.1.14", features = ["fs"] } +tokio-test = "0.4.1" +tokio-util = { version = "0.7.2", features = ["compat", "codec"] } +toml = "0.7.4" +tonic = { version = "0.11.0", features = [ + "tls-roots", + "transport", + "prost", + "gzip", + "codegen", + "zstd", +] } +tonic-reflection = "0.11.0" +topological-sort = "0.2.2" +triomphe = "0.1.9" +tui = "0.19.0" +typed-arena = "2.0.2" +typenum = "1.17.0" +uint = "0.9.4" +ureq = { version = "1.5.4", features = [ + "json", + "native-tls", +], default_features = false } +url = { version = "2.4.0", features = ["serde"] } +uuid = { version = "1.0.0", features = ["v4", "serde"] } +variant_count = "1.1.0" +walkdir = "2.3.3" +warp = { version = "0.3.5", features = ["tls"] } +warp-reverse-proxy = "1.0.0" +which = "4.2.5" +whoami = "1.5.0" +x25519-dalek = "1.2.0" +z3tracer = "0.8.0" + +# MOVE DEPENDENCIES +move-abigen = { path = "move-prover/move-abigen" } +move-binary-format = { path = "move-binary-format" } +move-bytecode-spec = { path = "move-bytecode-spec" } +move-bytecode-verifier = { path = "move-bytecode-verifier" } +move-bytecode-utils = { path = "tools/move-bytecode-utils" } +move-cli = { path = "tools/move-cli" } +move-command-line-common = { path = "move-command-line-common" } +move-coverage = { path = "tools/move-coverage" } +move-compiler = { path = "move-compiler" } +move-compiler-v2 = { path = "move-compiler-v2" } +move-core-types = { path = "move-core/types" } +move-docgen = { path = "move-prover/move-docgen" } +move-disassembler = { path = "tools/move-disassembler" } +move-ir-types = { path = "move-ir/types" } +move-ir-compiler = { path = "move-ir-compiler" } +move-bytecode-source-map = { path = "move-ir-compiler/move-bytecode-source-map" } +move-model = { path = "move-model" } +move-package = { path = "tools/move-package" } +move-prover = { path = "move-prover" } +move-prover-boogie-backend = { path = "move-prover/boogie-backend" } +move-prover-bytecode-pipeline = { path = "move-prover/bytecode-pipeline" } +move-stackless-bytecode = { path = "move-model/bytecode" } +move-stackless-bytecode-test-utils = { path = "move-model/bytecode-test-utils" } +aptos-move-stdlib = { path = "aptos-framework/move-stdlib" } +aptos-table-natives = { path = "aptos-framework/table-natives" } +move-prover-test-utils = { path = "move-prover/test-utils" } +move-resource-viewer = { path = "tools/move-resource-viewer" } +move-symbol-pool = { path = "move-symbol-pool" } +move-table-extension = { path = "extensions/move-table-extension" } +move-transactional-test-runner = { path = "testing-infra/transactional-test-runner" } +move-unit-test = { path = "tools/move-unit-test", features = [ + "table-extension", +] } +move-vm-runtime = { path = "move-vm/runtime" } +move-vm-test-utils = { path = "move-vm/test-utils", features = [ + "table-extension", +] } +move-vm-types = { path = "move-vm/types" } + +[profile.bench] +debug = true + +[profile.dev] +debug = true + +# use release settings to reduce memory pressure in the linking step in CI +[profile.ci] +inherits = "test" +debug = 0 # for saving disk space during linking +incremental = false +codegen-units = 16 diff --git a/README.md b/README.md index 0acf524c..699fb87b 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,35 @@ --- id: move-language title: Move Language -custom_edit_url: https://github.com/move-language/move/edit/main/language/README.md +custom_edit_url: https://github.com/initia-labs/move/edit/initia-move/README.md --- -Move is a new programming language developed to provide a safe and programmable foundation for the Diem Blockchain. +This project is forked from [Aptos Move](https://github.com/aptos-labs/aptos-core/tree/main/third_party/move) to avoid multi-standard of move language. -## Overview +## How to fetch latest changes from aptos-core -The Move language directory consists of four main parts: +```shell +# make new subtree branch with latest changes +git subtree split --prefix=third_party/move -b aptos-move -- [virtual machine](move-vm/) (VM) — contains the bytecode format, a bytecode interpreter, and infrastructure for executing a block of transactions. This directory also contains the infrastructure to generate the genesis block. +# merge latest changes into our branch +git switch initia-move +git merge aptos-move +``` -- [bytecode verifier](move-bytecode-verifier/) — contains a static analysis tool for rejecting invalid Move bytecode. The virtual machine runs the bytecode verifier on any new Move code it encounters before executing it. The compiler runs the bytecode verifier on its output and surfaces the errors to the programmer. +## How to validate changes -- [move-compiler](move-compiler/) — contains the Move source language compiler. - -- [standard library](move-stdlib/) — contains the standard library transaction scripts. - -## Exploring the Move language - -- You can find many small Move examples in the [tests](move-compiler/tests/move_check/) directory. The easiest way to experiment with Move is to create a new test in this directory and run it with `cargo test`. +```shell +cargo test \ + --package move-vm-integration-tests \ + --package move-cli \ + --package move-unit-test \ + --package move-compiler \ + --package move-analyzer \ + --package move-stdlib \ + --package move-package \ + --package move-binary-format \ + --package move-bytecode-verifier \ + -- --skip prove +``` diff --git a/move-prover/lab/src/benchmark.rs b/move-prover/lab/src/benchmark.rs index 6e4ba638..37dbb126 100644 --- a/move-prover/lab/src/benchmark.rs +++ b/move-prover/lab/src/benchmark.rs @@ -142,7 +142,7 @@ fn run_benchmark( modules: &[String], dep_dirs: &[String], per_function: bool, - use_aptos_natives: bool, + _use_aptos_natives: bool, ) -> anyhow::Result<()> { let mut options = if let Some(config_file) = config_file_opt { Options::create_from_toml_file(config_file)? @@ -171,20 +171,6 @@ fn run_benchmark( )?; let mut error_writer = StandardStream::stderr(ColorChoice::Auto); - if use_aptos_natives { - options.backend.custom_natives = - Some(move_prover_boogie_backend::options::CustomNativeOptions { - template_bytes: include_bytes!( - "../../../../../aptos-move/framework/src/aptos-natives.bpl" - ) - .to_vec(), - module_instance_names: vec![( - "0x1::object".to_string(), - "object_instances".to_string(), - true, - )], - }); - } // Do not allow any benchmark to run longer than 60s. If this is exceeded it usually // indicates a bug in boogie or the solver, because we already propagate soft timeouts, but // they are ignored. diff --git a/move-prover/src/cli.rs b/move-prover/src/cli.rs index 6cb2af7d..8f6fc251 100644 --- a/move-prover/src/cli.rs +++ b/move-prover/src/cli.rs @@ -20,7 +20,7 @@ use move_model::{ model::VerificationScope, options::ModelBuilderOptions, }; -use move_prover_boogie_backend::options::{BoogieOptions, CustomNativeOptions, VectorTheory}; +use move_prover_boogie_backend::options::{BoogieOptions, VectorTheory}; use move_prover_bytecode_pipeline::options::{AutoTraceLevel, ProverOptions}; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; @@ -802,22 +802,6 @@ impl Options { options.prover.ban_int_2_bv = true; } - if matches.get_flag("aptos") { - options.backend.custom_natives = Some(CustomNativeOptions { - template_bytes: include_bytes!( - "../../../../aptos-move/framework/src/aptos-natives.bpl" - ) - .to_vec(), - module_instance_names: vec![( - "0x1::object".to_string(), - "object_instances".to_string(), - true, - )], - }); - options - .move_named_address_values - .push("Extensions=0x1".to_string()) - } if matches.get_flag("compiler-v2") { options.compiler_v2 = true; } diff --git a/move-vm/runtime/src/session.rs b/move-vm/runtime/src/session.rs index b3ab22d9..59074841 100644 --- a/move-vm/runtime/src/session.rs +++ b/move-vm/runtime/src/session.rs @@ -470,6 +470,28 @@ impl<'r, 'l> Session<'r, 'l> { ) } + pub fn type_to_type_tag( + &self, + ty: &Type, + module_storage: &impl ModuleStorage, + ) -> PartialVMResult { + self.move_vm + .runtime + .loader() + .type_to_type_tag(ty, module_storage) + } + + pub fn get_fully_annotated_type_layout_by_type( + &self, + ty: &Type, + module_storage: &impl ModuleStorage, + ) -> PartialVMResult { + self.move_vm + .runtime + .loader() + .type_to_fully_annotated_layout(ty, &self.module_store, module_storage) + } + /// Gets the underlying native extensions. pub fn get_native_extensions(&mut self) -> &mut NativeContextExtensions<'r> { &mut self.native_extensions diff --git a/move-vm/runtime/src/storage/environment.rs b/move-vm/runtime/src/storage/environment.rs index 11ff86f7..ac7ee496 100644 --- a/move-vm/runtime/src/storage/environment.rs +++ b/move-vm/runtime/src/storage/environment.rs @@ -41,7 +41,7 @@ pub struct RuntimeEnvironment { /// Map from struct names to indices, to save on unnecessary cloning and reduce memory /// consumption. Used by all struct type creations in the VM and in code cache. - struct_name_index_map: StructNameIndexMap, + struct_name_index_map: Arc, /// Type cache for struct layouts, tags and depths, shared across multiple threads. /// @@ -85,7 +85,7 @@ impl RuntimeEnvironment { Self { vm_config, natives, - struct_name_index_map: StructNameIndexMap::empty(), + struct_name_index_map: Arc::new(StructNameIndexMap::empty()), ty_cache: StructInfoCache::empty(), } } @@ -264,11 +264,16 @@ impl RuntimeEnvironment { self.ty_cache.flush(); self.struct_name_index_map.flush(); } + + /// Flushes the struct information cache. + pub fn flush_struct_info_cache(&self) { + self.ty_cache.flush(); + } } impl Clone for RuntimeEnvironment { - /// Returns the cloned environment. Struct re-indexing map and type caches are cloned and no - /// longer shared with the original environment. + /// Returns the cloned environment. Struct name index map is shared, but + /// the type cache is created empty. fn clone(&self) -> Self { Self { vm_config: self.vm_config.clone(),