chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

1
vendor/zerocopy/.cargo-checksum.json vendored Normal file

File diff suppressed because one or more lines are too long

6
vendor/zerocopy/.cargo_vcs_info.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"git": {
"sha1": "a6a530d0b09bb6218b8b1d7471ad0157096aeaee"
},
"path_in_vcs": ""
}

78
vendor/zerocopy/AGENTS.md vendored Normal file
View File

@@ -0,0 +1,78 @@
<!-- Copyright 2025 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# Instructions for AI Agents
## Agent Persona & Role
You are an expert Rust systems programmer contributing to **zerocopy**, a
library for zero-cost memory manipulation which presents a safe API over what
would otherwise be dangerous operations. Your goal is to write high-quality,
sound, and performant Rust code that adheres to strict safety and soundness
guidelines and works across multiple Rust toolchains and compilation targets.
### Reviewing
You may be authoring changes, or you may be reviewing changes authored by other
agents or humans. When reviewing changes, in addition to reading this document,
you **MUST** also read [agent_docs/reviewing.md](./agent_docs/reviewing.md).
## Critical Rules
- **README Generation:** **DON'T** edit `README.md` directly. It is generated
from `src/lib.rs`. Edit the top-level doc comment in `src/lib.rs` instead.
- **To regenerate:**
`./cargo.sh +stable run --manifest-path tools/generate-readme/Cargo.toml > README.md`
<!-- TODO-check-disable -->
- **TODOs:** **DON'T** use `TODO` comments unless you explicitly intend to block
the PR (CI fails on `TODO`). Use `FIXME` for non-blocking issues.
<!-- TODO-check-enable -->
- **Documentation:** **DO** ensure that changes do not cause documentation to
become out of date (e.g., renaming files referenced here).
## Project Context
### Overview
Zerocopy is a library designed to make zero-copy memory manipulation safe and
easy. It relies heavily on Rust's type system and specific traits to ensure
memory safety.
### Project Structure
- `src/`: Core library source code.
- `zerocopy-derive/`: Source code and tests for the procedural macros.
- `tests/`: UI and integration tests for the main crate.
- `tools/`: Internal tools and scripts.
- `ci/`: CI configuration and scripts.
- `githooks/`: Git hooks for pre-commit/pre-push checks.
- `testdata/`: Data used for testing.
- `testutil/`: Utility code for tests.
## Development Workflow
When developing code changes, you **MUST** read
[agent_docs/development.md](./agent_docs/development.md).
### Before submitting
Once you have made a change, you **MUST** read the relevant documents to ensure
that your change is valid and follows the style guidelines.
- [agent_docs/validation.md](./agent_docs/validation.md) for validating code
changes
- [agent_docs/style.md](./agent_docs/style.md) for style and formatting
guidelines for files and commit messages
#### Pre-submission Checks
Run `./githooks/pre-push` before submitting. This runs a comprehensive suite of
checks, including formatting, toolchain verification, and script validation. It
catches many issues that would otherwise fail in CI.

43
vendor/zerocopy/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,43 @@
<!-- Copyright 2023 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# Changelog
## Releases
We track releases and release notes using [GitHub
Releases](https://github.com/google/zerocopy/releases).
## Yanks and Regressions
### 0.2.2 through 0.2.8, 0.3.0 through 0.3.1, 0.4.0, 0.5.0, 0.6.0 through 0.6.5, 0.7.0 through 0.7.30
*Security advisories for this bug have been published as
[RUSTSEC-2023-0074][rustsec-advisory] and [GHSA-3mv5-343c-w2qg][github-advisory].*
In these versions, the `Ref` methods `into_ref`, `into_mut`, `into_slice`, and
`into_mut_slice` were permitted in combination with the standard library
`cell::Ref` and `cell::RefMut` types for `Ref<B, T>`'s `B` type parameter. These
combinations are unsound, and may permit safe code to exhibit undefined
behavior. Fixes have been published to each affected minor version which do not
permit this code to compile.
See [#716][issue-716] for more details.
[rustsec-advisory]: https://rustsec.org/advisories/RUSTSEC-2023-0074.html
[github-advisory]: https://github.com/google/zerocopy/security/advisories/GHSA-3mv5-343c-w2qg
[issue-716]: https://github.com/google/zerocopy/issues/716
### 0.7.27, 0.7.28
These versions were briefly yanked due to a non-soundness regression reported in
[#672][pull-672]. After reconsidering our yanking policy in [#679][issue-679],
we un-yanked these versions.
[pull-672]: https://github.com/google/zerocopy/pull/672
[issue-679]: https://github.com/google/zerocopy/issues/679

11
vendor/zerocopy/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,11 @@
<!-- Copyright 2022 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# How to Contribute
See our [Contributing Guide](https://github.com/google/zerocopy/discussions/1318).

109
vendor/zerocopy/Cargo.lock generated vendored Normal file
View File

@@ -0,0 +1,109 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "either"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]]
name = "elain"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba39bdf557eef05f2c1c2e986cbab6b85329b922e7606e5b63ee4c5037ba77a"
[[package]]
name = "itertools"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
dependencies = [
"either",
]
[[package]]
name = "proc-macro2"
version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]]
name = "rustversion"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "2.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e2415488199887523e74fd9a5f7be804dfd42d868ae0eca382e3917094d210e"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
[[package]]
name = "zerocopy"
version = "0.8.47"
dependencies = [
"elain",
"itertools",
"rand",
"rustversion",
"static_assertions",
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e8bc7269b54418e7aeeef514aa68f8690b8c0489a06b0136e5f57c4c5ccab89"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

368
vendor/zerocopy/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,368 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
rust-version = "1.56.0"
name = "zerocopy"
version = "0.8.47"
authors = [
"Joshua Liebow-Feeser <joshlf@google.com>",
"Jack Wrenn <jswrenn@amazon.com>",
]
build = "build.rs"
exclude = [".*"]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = """Zerocopy makes zero-cost memory manipulation effortless. We write "unsafe" so you don't have to."""
readme = "README.md"
keywords = [
"cast",
"convert",
"transmute",
"transmutation",
"type-punning",
]
categories = [
"embedded",
"encoding",
"no-std::no-alloc",
"parsing",
"rust-patterns",
]
license = "BSD-2-Clause OR Apache-2.0 OR MIT"
repository = "https://github.com/google/zerocopy"
[package.metadata.build-rs]
no-zerocopy-simd-x86-avx12-1-89-0 = "1.89.0"
no-zerocopy-core-error-1-81-0 = "1.81.0"
no-zerocopy-diagnostic-on-unimplemented-1-78-0 = "1.78.0"
no-zerocopy-generic-bounds-in-const-fn-1-61-0 = "1.61.0"
no-zerocopy-target-has-atomics-1-60-0 = "1.60.0"
no-zerocopy-aarch64-simd-1-59-0 = "1.59.0"
no-zerocopy-panic-in-const-and-vec-try-reserve-1-57-0 = "1.57.0"
[package.metadata.ci]
pinned-stable = "1.93.1"
pinned-nightly = "nightly-2026-01-25"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
"--cfg",
"doc_cfg",
"--generate-link-to-definition",
"--extend-css",
"rustdoc/style.css",
]
[package.metadata.playground]
features = ["__internal_use_only_features_that_work_on_stable"]
[features]
__internal_use_only_features_that_work_on_stable = [
"alloc",
"derive",
"simd",
"std",
]
alloc = []
derive = ["zerocopy-derive"]
float-nightly = []
simd = []
simd-nightly = ["simd"]
std = ["alloc"]
[lib]
name = "zerocopy"
path = "src/lib.rs"
[[test]]
name = "codegen"
path = "tests/codegen.rs"
[[test]]
name = "include"
path = "tests/include.rs"
[[test]]
name = "ui"
path = "tests/ui.rs"
[[bench]]
name = "as_bytes_dynamic_size"
path = "benches/as_bytes_dynamic_size.rs"
[[bench]]
name = "as_bytes_static_size"
path = "benches/as_bytes_static_size.rs"
[[bench]]
name = "read_from_bytes"
path = "benches/read_from_bytes.rs"
[[bench]]
name = "read_from_prefix"
path = "benches/read_from_prefix.rs"
[[bench]]
name = "read_from_suffix"
path = "benches/read_from_suffix.rs"
[[bench]]
name = "ref_from_bytes_dynamic_padding"
path = "benches/ref_from_bytes_dynamic_padding.rs"
[[bench]]
name = "ref_from_bytes_dynamic_size"
path = "benches/ref_from_bytes_dynamic_size.rs"
[[bench]]
name = "ref_from_bytes_static_size"
path = "benches/ref_from_bytes_static_size.rs"
[[bench]]
name = "ref_from_bytes_with_elems_dynamic_padding"
path = "benches/ref_from_bytes_with_elems_dynamic_padding.rs"
[[bench]]
name = "ref_from_bytes_with_elems_dynamic_size"
path = "benches/ref_from_bytes_with_elems_dynamic_size.rs"
[[bench]]
name = "ref_from_prefix_dynamic_padding"
path = "benches/ref_from_prefix_dynamic_padding.rs"
[[bench]]
name = "ref_from_prefix_dynamic_size"
path = "benches/ref_from_prefix_dynamic_size.rs"
[[bench]]
name = "ref_from_prefix_static_size"
path = "benches/ref_from_prefix_static_size.rs"
[[bench]]
name = "ref_from_prefix_with_elems_dynamic_padding"
path = "benches/ref_from_prefix_with_elems_dynamic_padding.rs"
[[bench]]
name = "ref_from_prefix_with_elems_dynamic_size"
path = "benches/ref_from_prefix_with_elems_dynamic_size.rs"
[[bench]]
name = "ref_from_suffix_dynamic_padding"
path = "benches/ref_from_suffix_dynamic_padding.rs"
[[bench]]
name = "ref_from_suffix_dynamic_size"
path = "benches/ref_from_suffix_dynamic_size.rs"
[[bench]]
name = "ref_from_suffix_static_size"
path = "benches/ref_from_suffix_static_size.rs"
[[bench]]
name = "ref_from_suffix_with_elems_dynamic_padding"
path = "benches/ref_from_suffix_with_elems_dynamic_padding.rs"
[[bench]]
name = "ref_from_suffix_with_elems_dynamic_size"
path = "benches/ref_from_suffix_with_elems_dynamic_size.rs"
[[bench]]
name = "split_at_dynamic_padding"
path = "benches/split_at_dynamic_padding.rs"
[[bench]]
name = "split_at_dynamic_size"
path = "benches/split_at_dynamic_size.rs"
[[bench]]
name = "split_at_unchecked_dynamic_padding"
path = "benches/split_at_unchecked_dynamic_padding.rs"
[[bench]]
name = "split_at_unchecked_dynamic_size"
path = "benches/split_at_unchecked_dynamic_size.rs"
[[bench]]
name = "split_via_immutable_dynamic_padding"
path = "benches/split_via_immutable_dynamic_padding.rs"
[[bench]]
name = "split_via_immutable_dynamic_size"
path = "benches/split_via_immutable_dynamic_size.rs"
[[bench]]
name = "split_via_runtime_check_dynamic_padding"
path = "benches/split_via_runtime_check_dynamic_padding.rs"
[[bench]]
name = "split_via_runtime_check_dynamic_size"
path = "benches/split_via_runtime_check_dynamic_size.rs"
[[bench]]
name = "split_via_unchecked_dynamic_padding"
path = "benches/split_via_unchecked_dynamic_padding.rs"
[[bench]]
name = "split_via_unchecked_dynamic_size"
path = "benches/split_via_unchecked_dynamic_size.rs"
[[bench]]
name = "transmute"
path = "benches/transmute.rs"
[[bench]]
name = "transmute_ref_dynamic_size"
path = "benches/transmute_ref_dynamic_size.rs"
[[bench]]
name = "transmute_ref_static_size"
path = "benches/transmute_ref_static_size.rs"
[[bench]]
name = "try_read_from_bytes"
path = "benches/try_read_from_bytes.rs"
[[bench]]
name = "try_read_from_prefix"
path = "benches/try_read_from_prefix.rs"
[[bench]]
name = "try_read_from_suffix"
path = "benches/try_read_from_suffix.rs"
[[bench]]
name = "try_ref_from_bytes_dynamic_padding"
path = "benches/try_ref_from_bytes_dynamic_padding.rs"
[[bench]]
name = "try_ref_from_bytes_dynamic_size"
path = "benches/try_ref_from_bytes_dynamic_size.rs"
[[bench]]
name = "try_ref_from_bytes_static_size"
path = "benches/try_ref_from_bytes_static_size.rs"
[[bench]]
name = "try_ref_from_bytes_with_elems_dynamic_padding"
path = "benches/try_ref_from_bytes_with_elems_dynamic_padding.rs"
[[bench]]
name = "try_ref_from_bytes_with_elems_dynamic_size"
path = "benches/try_ref_from_bytes_with_elems_dynamic_size.rs"
[[bench]]
name = "try_ref_from_prefix_dynamic_padding"
path = "benches/try_ref_from_prefix_dynamic_padding.rs"
[[bench]]
name = "try_ref_from_prefix_dynamic_size"
path = "benches/try_ref_from_prefix_dynamic_size.rs"
[[bench]]
name = "try_ref_from_prefix_static_size"
path = "benches/try_ref_from_prefix_static_size.rs"
[[bench]]
name = "try_ref_from_prefix_with_elems_dynamic_padding"
path = "benches/try_ref_from_prefix_with_elems_dynamic_padding.rs"
[[bench]]
name = "try_ref_from_prefix_with_elems_dynamic_size"
path = "benches/try_ref_from_prefix_with_elems_dynamic_size.rs"
[[bench]]
name = "try_ref_from_suffix_dynamic_padding"
path = "benches/try_ref_from_suffix_dynamic_padding.rs"
[[bench]]
name = "try_ref_from_suffix_dynamic_size"
path = "benches/try_ref_from_suffix_dynamic_size.rs"
[[bench]]
name = "try_ref_from_suffix_static_size"
path = "benches/try_ref_from_suffix_static_size.rs"
[[bench]]
name = "try_ref_from_suffix_with_elems_dynamic_padding"
path = "benches/try_ref_from_suffix_with_elems_dynamic_padding.rs"
[[bench]]
name = "try_ref_from_suffix_with_elems_dynamic_size"
path = "benches/try_ref_from_suffix_with_elems_dynamic_size.rs"
[[bench]]
name = "try_transmute"
path = "benches/try_transmute.rs"
[[bench]]
name = "try_transmute_ref_dynamic_size"
path = "benches/try_transmute_ref_dynamic_size.rs"
[[bench]]
name = "try_transmute_ref_static_size"
path = "benches/try_transmute_ref_static_size.rs"
[[bench]]
name = "write_to_dynamic_size"
path = "benches/write_to_dynamic_size.rs"
[[bench]]
name = "write_to_prefix_dynamic_size"
path = "benches/write_to_prefix_dynamic_size.rs"
[[bench]]
name = "write_to_prefix_static_size"
path = "benches/write_to_prefix_static_size.rs"
[[bench]]
name = "write_to_static_size"
path = "benches/write_to_static_size.rs"
[[bench]]
name = "write_to_suffix_dynamic_size"
path = "benches/write_to_suffix_dynamic_size.rs"
[[bench]]
name = "write_to_suffix_static_size"
path = "benches/write_to_suffix_static_size.rs"
[dependencies.zerocopy-derive]
version = "=0.8.47"
optional = true
[dev-dependencies.elain]
version = "0.3.0"
[dev-dependencies.itertools]
version = "0.11"
[dev-dependencies.rand]
version = "0.8.5"
features = ["small_rng"]
default-features = false
[dev-dependencies.rustversion]
version = "1.0"
[dev-dependencies.static_assertions]
version = "1.1"
[dev-dependencies.zerocopy-derive]
version = "=0.8.47"
[target."cfg(any())".dependencies.zerocopy-derive]
version = "=0.8.47"

58
vendor/zerocopy/Cargo.toml.std vendored Normal file
View File

@@ -0,0 +1,58 @@
[package]
name = "std-deps"
version = "0.0.0"
edition = "2021"
publish = false
# This manifest exists solely to force `cargo vendor` to vendor dependencies
# required by `std` when building with `-Zbuild-std[=core]`. When running
# `cargo vendor`, make sure to include this manifest using `--sync`.
#
# See: https://github.com/rust-lang/wg-cargo-std-aware/issues/23
[workspace]
[dependencies]
# Dependencies from std/Cargo.toml and transitive deps from library/Cargo.lock
addr2line = { version = "=0.25.1", default-features = false }
adler2 = { version = "=2.0.1", default-features = false }
cc = { version = "=1.2.0", default-features = false }
cfg-if = { version = "=1.0.4", default-features = false }
dlmalloc = { version = "=0.2.11", default-features = false }
foldhash = { version = "=0.2.0", default-features = false }
fortanix-sgx-abi = { version = "=0.6.1", default-features = false }
getopts = { version = "=0.2.24", default-features = false }
gimli = { version = "=0.32.3", default-features = false }
hashbrown = { version = "=0.16.1", default-features = false }
hermit-abi = { version = "=0.5.2", default-features = false }
libc = { version = "=0.2.178", default-features = false }
memchr = { version = "=2.7.6", default-features = false }
miniz_oxide = { version = "=0.8.9", default-features = false }
moto-rt = { version = "=0.16.0", default-features = false }
object = { version = "=0.37.3", default-features = false }
r-efi = { version = "=5.3.0", default-features = false }
r-efi-alloc = { version = "=2.1.0", default-features = false }
rand = { version = "=0.9.2", default-features = false }
rand_core = { version = "=0.9.3", default-features = false }
rand_xorshift = { version = "=0.4.0", default-features = false }
rustc-demangle = "=0.1.26"
rustc-literal-escaper = { version = "=0.0.7", default-features = false }
shlex = { version = "=1.3.0", default-features = false }
unwinding = { version = "=0.2.8", default-features = false }
vex-sdk = { version = "=0.27.1", default-features = false }
wasi-snapshot-preview1 = { package = "wasi", version = "=0.11.1+wasi-snapshot-preview1", default-features = false }
wasi-p2 = { package = "wasi", version = "=0.14.4+wasi-0.2.4", default-features = false }
windows-link = { version = "=0.2.1", default-features = false }
windows-sys = { version = "=0.60.2", default-features = false }
windows-targets = { version = "=0.53.5", default-features = false }
wit-bindgen = { version = "=0.45.1", default-features = false }
# Windows targets dependencies (transitive via windows-targets)
windows_aarch64_gnullvm = { version = "=0.53.1", default-features = false }
windows_aarch64_msvc = { version = "=0.53.1", default-features = false }
windows_i686_gnu = { version = "=0.53.1", default-features = false }
windows_i686_gnullvm = { version = "=0.53.1", default-features = false }
windows_i686_msvc = { version = "=0.53.1", default-features = false }
windows_x86_64_gnu = { version = "=0.53.1", default-features = false }
windows_x86_64_gnullvm = { version = "=0.53.1", default-features = false }
windows_x86_64_msvc = { version = "=0.53.1", default-features = false }

202
vendor/zerocopy/LICENSE-APACHE vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2023 The Fuchsia Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

24
vendor/zerocopy/LICENSE-BSD vendored Normal file
View File

@@ -0,0 +1,24 @@
Copyright 2019 The Fuchsia Authors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

26
vendor/zerocopy/LICENSE-MIT vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright 2023 The Fuchsia Authors
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

119
vendor/zerocopy/POLICIES.md vendored Normal file
View File

@@ -0,0 +1,119 @@
<!-- Copyright 2023 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# Zerocopy's Policies
## Soundness
Zerocopy is expressly designed for use in security-critical contexts. It is used
in hardware security firmware, cryptographic implementations, hypervisors, and
more. We understand that software in these contexts has a very high bar for
correctness, and we take our responsibility to meet that bar very seriously.
This section describes policies which are designed to ensure the correctness and
soundness of our code and prevent regressions.
### Forwards-compatibility
Rust does not currently have a formal memory model. As such, while Rust provides
guarantees about the semantics of some operations, the semantics of many
operations is up in the air and subject to change.
Zerocopy strives to ensure that our code - and code emitted by our custom
derives - is sound under any version of Rust as early as our MSRV, and will
continue to be sound under any future version of Rust. The policies in this
section are designed to help ensure that we live up to this goal.
### Safety comments
Each non-test `unsafe` block must be annotated with a "safety comment" which
provides a rationale for its soundness. In order to ensure that our soundness is
forwards-compatible, safety comments must satisfy the following criteria:
- Safety comments must constitute a (possibly informal) proof that all of Rust's
soundness rules are upheld.
- Safety comments must only rely for their correctness on statements which
appear in the stable versions of the [Rust Reference] or standard library
documentation (ie, the docs for [core], [alloc], and [std]); arguments which
rely on text from the beta or nightly versions of these documents are not
considered complete.
- All statements from the Reference or standard library documentation which are
relied upon for soundness must be quoted in the safety comment. This ensures
that there is no ambiguity as to what aspect of the text is being cited. This
is especially important in cases where the text of these documents changes in
the future. Such changes are of course required to be backwards-compatible,
but may change the manner in which a particular guarantee is explained.
We use the [`clippy::undocumented_unsafe_blocks`] lint to ensure that `unsafe`
blocks cannot be added without a safety comment. Note that there are a few
outstanding uncommented `unsafe` blocks which are tracked in [#429]. Our goal is
to reach 100% safety comment coverage and not regress once we've reached it.
[Rust Reference]: https://doc.rust-lang.org/reference/
[core]: https://doc.rust-lang.org/stable/core/
[alloc]: https://doc.rust-lang.org/stable/alloc/
[std]: https://doc.rust-lang.org/stable/std/
[`clippy::undocumented_unsafe_blocks`]: https://rust-lang.github.io/rust-clippy/master/index.html#/undocumented_unsafe_blocks
[#429]: https://github.com/google/zerocopy/issues/429
#### Exceptions to our safety comment policy
In rare circumstances, the soundness of an `unsafe` block may depend upon
semantics which are widely agreed upon but not formally guaranteed. In order to
avoid slowing down zerocopy's development to an unreasonable degree, a safety
comment may violate our safety comment policy so long as all of the following
hold:
- The safety comment's correctness may rely on semantics which are not
guaranteed in official Rust documentation *so long as* a member of the Rust
team has articulated in an official communication (e.g. a comment on a Rust
GitHub repo) that Rust intends to guarantee particular semantics.
- There exists an active effort to formalize the guarantee in Rust's official
documentation.
### Target architecture support
Zerocopy bases its soundness on guarantees made about the semantics of Rust
which appear in the Rust Reference or standard library documentation; zerocopy
is sound so long as these guarantees hold. There are known cases in which these
guarantees do not hold on certain target architectures (see
[rust-lang/unsafe-code-guidelines#461]); on such target architectures, zerocopy
may be unsound. We consider it outside of zerocopy's scope to reason about these
cases. Zerocopy makes no effort maintain soundness in cases where Rust's
documented guarantees do not hold.
[rust-lang/unsafe-code-guidelines#461]: https://github.com/rust-lang/unsafe-code-guidelines/issues/461
## MSRV
<!-- Our policy used to be simply that MSRV was a breaking change in all
circumstances. This implicitly relied on syn having the same MSRV policy, which
it does not. See #1085 and #1088. -->
Without the `derive` feature enabled, zerocopy's minimum supported Rust version
(MSRV) is encoded the `package.rust-version` field in its `Cargo.toml` file. For
zerocopy, we consider an increase in MSRV to be a semver-breaking change, and
will only increase our MSRV during semver-breaking version changes (e.g., 0.1 ->
0.2, 1.0 -> 2.0, etc).
For zerocopy with the `derive` feature enabled, and for the zerocopy-derive
crate, we inherit the maximum MSRV any of our dependencies. As of this writing
(2024-10-03), at least one dependency (syn) does *not* consider MSRV increases
to be semver-breaking changes. Thus, using the `derive` feature may result in
the effective MSRV increasing within a semver version train.
## Yanking
Whenever a bug or regression is identified, we will yank any affected versions
which are part of the current version train. For example, if the most recent
version is 0.10.20 and a bug is uncovered, we will release a fix in 0.10.21 and
yank all 0.10.X versions which are affected. We *may* also yank versions in
previous version trains on a case-by-case basis, but we don't guarantee it.
For information about a particular yanked or un-yanked version, see our [yank
log][yank-log].
[yank-log]: https://github.com/google/zerocopy/blob/main/CHANGELOG.md#yanks-and-regressions

213
vendor/zerocopy/README.md vendored Normal file
View File

@@ -0,0 +1,213 @@
<!-- Copyright 2024 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms.
WARNING: DO NOT EDIT THIS FILE. It is generated automatically. Edits should be
made in the doc comment on `src/lib.rs` or in `tools/generate-readme`.
-->
# zerocopy
***<span style="font-size: 140%">Fast, safe, <span
style="color:red;">compile error</span>. Pick two.</span>***
Zerocopy makes zero-cost memory manipulation effortless. We write `unsafe`
so you don't have to.
*For an overview of what's changed from zerocopy 0.7, check out our [release
notes][release-notes], which include a step-by-step upgrading guide.*
*Have questions? Need more out of zerocopy? Submit a [customer request
issue][customer-request-issue] or ask the maintainers on
[GitHub][github-q-a] or [Discord][discord]!*
[customer-request-issue]: https://github.com/google/zerocopy/issues/new/choose
[release-notes]: https://github.com/google/zerocopy/discussions/1680
[github-q-a]: https://github.com/google/zerocopy/discussions/categories/q-a
[discord]: https://discord.gg/MAvWH2R6zk
## Overview
###### Conversion Traits
Zerocopy provides four derivable traits for zero-cost conversions:
- `TryFromBytes` indicates that a type may safely be converted from
certain byte sequences (conditional on runtime checks)
- `FromZeros` indicates that a sequence of zero bytes represents a valid
instance of a type
- `FromBytes` indicates that a type may safely be converted from an
arbitrary byte sequence
- `IntoBytes` indicates that a type may safely be converted *to* a byte
sequence
These traits support sized types, slices, and [slice DSTs][slice-dsts].
[slice-dsts]: KnownLayout#dynamically-sized-types
###### Marker Traits
Zerocopy provides three derivable marker traits that do not provide any
functionality themselves, but are required to call certain methods provided
by the conversion traits:
- `KnownLayout` indicates that zerocopy can reason about certain layout
qualities of a type
- `Immutable` indicates that a type is free from interior mutability,
except by ownership or an exclusive (`&mut`) borrow
- `Unaligned` indicates that a type's alignment requirement is 1
You should generally derive these marker traits whenever possible.
###### Conversion Macros
Zerocopy provides six macros for safe casting between types:
- (`try_`[try_transmute])`transmute` (conditionally) converts a value of
one type to a value of another type of the same size
- (`try_`[try_transmute_mut])`transmute_mut` (conditionally) converts a
mutable reference of one type to a mutable reference of another type of
the same size
- (`try_`[try_transmute_ref])`transmute_ref` (conditionally) converts a
mutable or immutable reference of one type to an immutable reference of
another type of the same size
These macros perform *compile-time* size and alignment checks, meaning that
unconditional casts have zero cost at runtime. Conditional casts do not need
to validate size or alignment runtime, but do need to validate contents.
These macros cannot be used in generic contexts. For generic conversions,
use the methods defined by the [conversion traits](#conversion-traits).
###### Byteorder-Aware Numerics
Zerocopy provides byte-order aware integer types that support these
conversions; see the `byteorder` module. These types are especially useful
for network parsing.
## Cargo Features
- **`alloc`**
By default, `zerocopy` is `no_std`. When the `alloc` feature is enabled,
the `alloc` crate is added as a dependency, and some allocation-related
functionality is added.
- **`std`**
By default, `zerocopy` is `no_std`. When the `std` feature is enabled, the
`std` crate is added as a dependency (ie, `no_std` is disabled), and
support for some `std` types is added. `std` implies `alloc`.
- **`derive`**
Provides derives for the core marker traits via the `zerocopy-derive`
crate. These derives are re-exported from `zerocopy`, so it is not
necessary to depend on `zerocopy-derive` directly.
However, you may experience better compile times if you instead directly
depend on both `zerocopy` and `zerocopy-derive` in your `Cargo.toml`,
since doing so will allow Rust to compile these crates in parallel. To do
so, do *not* enable the `derive` feature, and list both dependencies in
your `Cargo.toml` with the same leading non-zero version number; e.g:
```toml
[dependencies]
zerocopy = "0.X"
zerocopy-derive = "0.X"
```
To avoid the risk of [duplicate import errors][duplicate-import-errors] if
one of your dependencies enables zerocopy's `derive` feature, import
derives as `use zerocopy_derive::*` rather than by name (e.g., `use
zerocopy_derive::FromBytes`).
- **`simd`**
When the `simd` feature is enabled, `FromZeros`, `FromBytes`, and
`IntoBytes` impls are emitted for all stable SIMD types which exist on the
target platform. Note that the layout of SIMD types is not yet stabilized,
so these impls may be removed in the future if layout changes make them
invalid. For more information, see the Unsafe Code Guidelines Reference
page on the [layout of packed SIMD vectors][simd-layout].
- **`simd-nightly`**
Enables the `simd` feature and adds support for SIMD types which are only
available on nightly. Since these types are unstable, support for any type
may be removed at any point in the future.
- **`float-nightly`**
Adds support for the unstable `f16` and `f128` types. These types are
not yet fully implemented and may not be supported on all platforms.
[duplicate-import-errors]: https://github.com/google/zerocopy/issues/1587
[simd-layout]: https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
## Security Ethos
Zerocopy is expressly designed for use in security-critical contexts. We
strive to ensure that that zerocopy code is sound under Rust's current
memory model, and *any future memory model*. We ensure this by:
- **...not 'guessing' about Rust's semantics.**
We annotate `unsafe` code with a precise rationale for its soundness that
cites a relevant section of Rust's official documentation. When Rust's
documented semantics are unclear, we work with the Rust Operational
Semantics Team to clarify Rust's documentation.
- **...rigorously testing our implementation.**
We run tests using [Miri], ensuring that zerocopy is sound across a wide
array of supported target platforms of varying endianness and pointer
width, and across both current and experimental memory models of Rust.
- **...formally proving the correctness of our implementation.**
We apply formal verification tools like [Kani][kani] to prove zerocopy's
correctness.
For more information, see our full [soundness policy].
[Miri]: https://github.com/rust-lang/miri
[Kani]: https://github.com/model-checking/kani
[soundness policy]: https://github.com/google/zerocopy/blob/main/POLICIES.md#soundness
## Relationship to Project Safe Transmute
[Project Safe Transmute] is an official initiative of the Rust Project to
develop language-level support for safer transmutation. The Project consults
with crates like zerocopy to identify aspects of safer transmutation that
would benefit from compiler support, and has developed an [experimental,
compiler-supported analysis][mcp-transmutability] which determines whether,
for a given type, any value of that type may be soundly transmuted into
another type. Once this functionality is sufficiently mature, zerocopy
intends to replace its internal transmutability analysis (implemented by our
custom derives) with the compiler-supported one. This change will likely be
an implementation detail that is invisible to zerocopy's users.
Project Safe Transmute will not replace the need for most of zerocopy's
higher-level abstractions. The experimental compiler analysis is a tool for
checking the soundness of `unsafe` code, not a tool to avoid writing
`unsafe` code altogether. For the foreseeable future, crates like zerocopy
will still be required in order to provide higher-level abstractions on top
of the building block provided by Project Safe Transmute.
[Project Safe Transmute]: https://rust-lang.github.io/rfcs/2835-project-safe-transmute.html
[mcp-transmutability]: https://github.com/rust-lang/compiler-team/issues/411
## MSRV
See our [MSRV policy].
[MSRV policy]: https://github.com/google/zerocopy/blob/main/POLICIES.md#msrv
## Changelog
Zerocopy uses [GitHub Releases].
[GitHub Releases]: https://github.com/google/zerocopy/releases
## Thanks
Zerocopy is maintained by engineers at Google with help from [many wonderful
contributors][contributors]. Thank you to everyone who has lent a hand in
making Rust a little more secure!
[contributors]: https://github.com/google/zerocopy/graphs/contributors
## Disclaimer
Disclaimer: Zerocopy is not an officially supported Google product.

View File

@@ -0,0 +1,97 @@
<!-- Copyright 2025 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# Development Guidelines
This document covers guidelines for developing code changes.
## Build and Test
This repository uses a wrapper script (`cargo.sh`) to ensure consistent
toolchain usage and configuration.
> [!IMPORTANT]
> **NEVER** run `cargo` directly.
> **ALWAYS** use `./cargo.sh` for all cargo sub-commands.
>
> **Why?** `cargo.sh` ensures that the toolchains used in development match
> those in CI, which is important because some features are only available on
> specific toolchains, and because UI tests rely on the text of compiler errors,
> which changes between toolchain versions.
### Syntax
`./cargo.sh +<toolchain> <command> [args]`
This is equivalent to:
`cargo +1.2.3 <command> [args]`
...where `1.2.3` is the toolchain version named by `<toolchain>` (e.g., `msrv` ->
`1.56.0`).
### Toolchains
The `<toolchain>` argument is mandatory:
- `msrv`: Minimum Supported Rust Version.
- `stable`: Stable toolchain.
- `nightly`: Nightly toolchain.
- `all`: Runs on `msrv`, `stable`, and `nightly` sequentially.
- Version-gated: e.g., `no-zerocopy-core-error-1-81-0` (see `Cargo.toml`).
## MSRV (Minimum Supported Rust Version)
The MSRV is **1.56.0**.
- **Do NOT** use features stabilized after 1.56.0 unless version-gated.
- **Requirement:** Ask for user approval before introducing new version-gated
behavior.
- **Verify**: Ensure code compiles on 1.56.0 (`./cargo.sh +msrv ...`).
### Version Gating Convention
We use `[package.metadata.build-rs]` in `Cargo.toml` to gate features by Rust version.
1. **Define**: Add `no-zerocopy-<feature>-<version> = "<version>"` to `Cargo.toml`.
2. **Use**: Use `#[cfg(not(no_zerocopy_<feature>_<version>))]` (note underscores).
3. **Document**: For public items, use `#[cfg_attr(doc_cfg, doc(cfg(rust = "<version>")))]`.
**Important:** The toolchains listed in `.github/workflows/ci.yml` and
`Cargo.toml` (under `[package.metadata.build-rs]`) must be kept in sync. If you
add a new version-gated feature, ensure it is reflected in both places.
## UI Tests
For advice on how to add, modify, or remove UI tests (in `tests/ui-*` or
`zerocopy-derive/tests/ui-*`), refer to [agent_docs/ui_tests.md](./ui_tests.md).
## Macro Development
- **Shared Logic:** Put shared macro logic in `src/util/macro_util.rs` to avoid
code duplication in generated code.
- **Lints:** Generated code often triggers lints. Use `#[allow(...)]` liberally
in generated code to suppress them.
```rust
// GOOD: Suppress lints that might be triggered by generated names.
// Example: Using a variant name (PascalCase) as a field name (snake_case).
// Input: `enum MyEnum { VariantA }`
// Generated: `union Variants { __field_VariantA: ... }`
quote! {
#[allow(non_snake_case)]
union ___ZerocopyVariants {
#(#fields)*
}
}
```
## Unsafe Code
`unsafe` code is extremely dangerous and should be avoided unless absolutely
necessary. For guidelines on writing unsafe code, including pointer casts and
safety comments, refer to [agent_docs/unsafe_code.md](./unsafe_code.md).

109
vendor/zerocopy/agent_docs/reviewing.md vendored Normal file
View File

@@ -0,0 +1,109 @@
<!-- Copyright 2025 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# Reviewing
This document outlines the protocols and standards for AI agents performing code
reviews in the `zerocopy` repository.
## 1. The "Analyze-First" Mandate
Prevent hallucination by grounding your review in reality.
* **Rule:** Before commenting on *any* line of code, you **MUST** read the
file using `view_file` (or an equivalent tool in your protocol) to confirm
the context.
* **Why:** Diffs often miss surrounding context (e.g., `cfg` gates, trait
bounds, imports) that changes the validity of the code.
* **Protocol:**
1. Review is requested (manually by a user or automatically via CI/PR).
2. **YOU** call `view_file` (or equivalent) on the relevant files.
3. **YOU** analyze the code in strict steps (Safety -> Logic -> Style).
4. **YOU** generate the review.
## 2. Reviewer Personas
You are not just a "helper"; you are a multi-disciplinary expert. Switch between
these personas as you review:
### A. The Security Auditor (Critical)
* **Focus:** Undefined Behavior (UB), `unsafe` blocks, safety invariants.
* **Reference:** You **MUST** verify compliance with
[`unsafe_code.md`](unsafe_code.md).
* **Checklist:**
* [ ] Does every `unsafe` block have a `// SAFETY:` comment?
* [ ] Does every `unsafe` function, `unsafe` trait, and macro with safety
preconditions have `/// # Safety` documentation?
* [ ] Do safety comments comply with each rule in
[`unsafe_code.md`](unsafe_code.md)?
### B. The Logic Detective
* **Focus:** Correctness, edge cases, off-by-one errors, interior mutability.
* **Checklist:**
* [ ] Does the code panic on valid input?
* [ ] Are unwrap/expect calls justified?
* [ ] Does the logic handle ZSTs (Zero-Sized Types) correctly?
* [ ] Are generics properly bounded?
### C. The Style Cop
* **Focus:** Readability, idiomatic Rust, project standards.
* **Reference:** [`style.md`](style.md)
* **Checklist:**
* [ ] Are each of the style guidelines in [`style.md`](style.md) followed?
* [ ] Is there unnecessary complexity?
### D. The Simplicity Advocate
* **Focus:** Maintainability and code reuse
* **Checklist:**
* [ ] Can this be done with an existing utility? (Search the codebase for
similar patterns.)
* [ ] Is the implementation surprisingly complex for what it does?
* [ ] Are there "clever" one-liners that should be expanded for
readability?
* [ ] Does it re-implement a standard library function manually, or
functionality which is provided by a popular crate on crates.io?
## 3. Operational Protocols
### Chain-of-Thought (CoT) Requirement
You **MUST** output your reasoning before your final verdict.
* **Bad:** "This looks good."
* **Good:** "I checked the `unsafe` block on line 42. It casts `*mut T` to
`*mut u8`. The safety comment argues that `T` is `IntoBytes`, but `T` is a
generic without bounds. This is unsound. **Finding:** Unsound `unsafe`
block."
### Actionable Feedback
Every critique **MUST** be actionable.
* **Severity:** Clearly state if an issue is `BLOCKING` (must fix before
merge) or `NIT` (optional/style).
* **Fix:** Provide the exact code snippet to fix the issue.
<!-- TODO-check-disable -->
### Handling TODO comments
`TODO` comments are used to prevent a PR from being merged until they are
resolved. When you encounter a `TODO` comment:
1. **Evaluate** the surrounding code *under the assumption that the `TODO` will
be resolved*.
2. **Critique** only if the `TODO` is insufficient (i.e., the code would still
be problematic *even if* the `TODO` were resolved).
3. **Safety Placeholders:** A `// SAFETY: TODO` comment is a valid placeholder
for a safety comment, and a `/// TODO` comment in a `/// # Safety` doc
section is a valid placeholder for safety documentation. **DO NOT** flag
the first as a missing safety justification or a critical issue, and **DO
NOT** flag the second as missing safety documentation. You must assume the
author will write a sound justification or accurate safety documentation
before merging.
<!-- TODO-check-enable -->
## 4. Anti-Patterns (NEVER Do This)
* **NEVER** approve a PR with missing `// SAFETY:` comments.
* **NEVER** assume a function works as named; check its definition.
* **NEVER** suggest adding a dependency without checking if it's already in
`Cargo.toml`.

45
vendor/zerocopy/agent_docs/style.md vendored Normal file
View File

@@ -0,0 +1,45 @@
<!-- Copyright 2025 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# Style Guidelines
This document covers code style and formatting guidelines for the project, as
well as commit message requirements.
## File Headers
Each file must contain a copyright header (see `src/lib.rs` for example) which is
based on that file's creation year.
## Formatting
Refer to `ci/check_fmt.sh`.
## Comments
- Wrap all comments (`//`, `///`, `//!`) at **80 columns** from the left margin,
taking into account any preceding code or comments.
- **Exceptions:** Markdown tables, ASCII diagrams, long URLs, code blocks, or
other cases where wrapping would impair readability.
## Markdown Files
- Wrap paragraphs and bulleted lists at **80 columns** from the left margin,
taking into account any preceding code or comments. For example, a markdown
block inside of a `/// Lorem ipsum...` comment should have lines no more than
76 columns wide.
- In bulleted lists, indent subsequent lines by 2 spaces.
- Do not wrap links if it breaks them.
- Always put a blank line between a section header and the beginning of the section.
## Pull Requests and Commit Messages
Use GitHub issue syntax in commit messages:
- Resolves issue: `Closes #123`
- Progress on issue: `Makes progress on #123`

48
vendor/zerocopy/agent_docs/ui_tests.md vendored Normal file
View File

@@ -0,0 +1,48 @@
<!-- Copyright 2025 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# UI & Output Tests
When updating UI test files (`tests/ui-*` or `zerocopy-derive/tests/ui-*`) or
functionality which could affect compiler error output or derive output, run:
`./tools/update-expected-test-output.sh`.
**Note:** We maintain separate UI tests for different toolchains (`ui-msrv`,
`ui-stable`, `ui-nightly`) because compiler output varies. The script handles
this automatically.
### Symlink Pattern
To share test code across toolchains while allowing for different error output,
we use a symlink pattern:
1. **Canonical Source:** The `ui-nightly` directory holds the actual source
files (`.rs`).
2. **Symlinks:** The `ui-stable` and `ui-msrv` directories contain *symlinks*
to the `.rs` files in `ui-nightly`.
- **Example:** `tests/ui-stable/foo.rs` -> `../ui-nightly/foo.rs`
3. **Unique Output:** Each directory contains its own `.stderr` files.
### Workflow Rules
- **Adding a Test:**
1. Create the `.rs` file in `ui-nightly`.
2. Create relative symlinks in `ui-stable` and `ui-msrv` pointing to the
new file in `ui-nightly`.
3. Run `./tools/update-expected-test-output.sh` to generate the `.stderr` files.
- **Modifying a Test:**
1. Edit the `.rs` file in `ui-nightly`.
2. Run `./tools/update-expected-test-output.sh` to update the `.stderr` files.
- **Removing a Test:**
1. Delete the `.rs` file from `ui-nightly`.
2. Delete the symlinks from `ui-stable` and `ui-msrv`.
3. Delete the corresponding `.stderr` files from all three directories.
**NEVER** edit `.stderr` files directly. Only update them via the script or the
commands it runs. If a `.stderr` file is causing a test failure and updating it
via tooling does not fix the failure, that indicates a bug.

View File

@@ -0,0 +1,84 @@
<!-- Copyright 2025 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# Unsafe Code Guidelines
`unsafe` code is extremely dangerous and should be avoided unless absolutely
necessary. When it is absolutely necessary to write `unsafe` code, it should be
done extremely carefully.
This document covers guidelines for writing unsafe code, including pointer casts
and safety comments.
## Pointer Casts
- **Avoid `&slice[0] as *const T`**: Use `slice.as_ptr()`. Accessing subsequent
elements via pointer arithmetic on a single-element pointer is UB.
```rust
let slice = &[1, 2];
// BAD: Derived from reference to single element.
let ptr = &slice[0] as *const i32;
// SAFETY: UB! `ptr` has provenance only for the first element.
// Accessing `ptr.add(1)` is out of bounds for this provenance.
let val = unsafe { *ptr.add(1) };
// GOOD: Derived from the slice itself.
let ptr = slice.as_ptr();
// SAFETY: Safe because `ptr` has provenance for the entire slice.
let val = unsafe { *ptr.add(1) };
```
- **Avoid converting `&mut T` to `*const T`**: This reborrows as a shared
reference, restricting permissions. Cast `&mut T` to `*mut T` first.
```rust
let mut val = 42;
let r = &mut val;
// BAD: `r as *const i32` creates a shared reborrow.
// The resulting pointer loses write provenance.
let ptr = r as *const i32 as *mut i32;
// SAFETY: UB! Writing to a pointer derived from a shared reborrow.
unsafe { *ptr = 0 };
// GOOD: `r as *mut i32` preserves write provenance.
let ptr = r as *mut i32;
// SAFETY: Safe because `ptr` retains mutable provenance.
unsafe { *ptr = 0 };
```
## Safety Comments
Every `unsafe` block must be documented with a `// SAFETY:` comment.
- **Requirement:** The comment must prove soundness using *only* text from the
stable [Rust Reference](https://doc.rust-lang.org/reference/) or [standard
library documentation](https://doc.rust-lang.org/std/).
- **Citation:** You must cite and quote the relevant text from the
documentation. Citations must cite a specific version of the documentation
(e.g. https://doc.rust-lang.org/1.91.0/reference/ or
https://doc.rust-lang.org/1.91.0/std/).
- **Prohibition:** Do not rely on "common sense" or behavior not guaranteed by
the docs.
```rust
// BAD: Missing justification for "obvious" properties.
// SAFETY: `ptr` and `field` are from the same object.
let offset = unsafe { field.cast::<u8>().offset_from(ptr.cast::<u8>()) };
// GOOD: Explicitly justifies every requirement, even trivial ones.
// SAFETY:
// - `ptr` and `field` are derived from the same allocated object [1].
// - The distance between them is trivially a multiple of `u8`'s size (1) [2],
// satisfying `offset_from`'s alignment requirement [1].
//
// [1] Per https://doc.rust-lang.org/1.91.0/std/primitive.pointer.html#method.offset_from:
//
// Both pointers must be derived from the same allocated object, and the
// distance between them must be a multiple of the element size.
//
// [2] https://doc.rust-lang.org/1.91.0/reference/type-layout.html#primitive-data-layout
let offset = unsafe { field.cast::<u8>().offset_from(ptr.cast::<u8>()) };
```

View File

@@ -0,0 +1,84 @@
<!-- Copyright 2025 The Fuchsia Authors
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
This file may not be copied, modified, or distributed except according to
those terms. -->
# Validating Changes
This document covers the procedures and requirements for validating changes to
the project, including linting, testing, and pre-submission checks.
## Linting
Clippy should **always** be run on the `nightly` toolchain.
```bash
./cargo.sh +nightly clippy
./cargo.sh +nightly clippy --tests
```
### Strict Linting
- We deny warnings in CI. Even warnings not explicitly listed in `lib.rs` will
cause CI to fail.
- **Why:** We maintain a zero-warning policy so that new warnings (which often
indicate bugs) are immediately obvious and not obscured by existing ones.
- Do not introduce new warnings.
- Respect the strict `deny` list in `src/lib.rs`.
## Validating Changes
Ensure the library builds on all supported toolchains and that Clippy passes.
```bash
./cargo.sh +msrv check --tests --features __internal_use_only_features_that_work_on_stable
./cargo.sh +stable check --tests --features __internal_use_only_features_that_work_on_stable
./cargo.sh +nightly check --tests --all-features
./cargo.sh +nightly clippy --tests --all-features --workspace
```
**Note:** Tests are rarely toolchain-sensitive. Running tests on `nightly` is
usually sufficient.
## Testing Strategy
- **Unit Tests:** Place unit tests in a `mod tests` module within the source
file they test.
- **UI/Compile-Fail Tests:**
- **`zerocopy`:** Place in `tests/ui-*` (top-level). The top-level `tests`
directory contains *only* UI tests.
- **`zerocopy-derive`:** Place in `zerocopy-derive/tests/ui-*`.
- **Derive Integration Tests:** Place integration tests for derive macros in
`zerocopy-derive/tests`.
- **Derive Output Tests:** Place unit tests that verify the *generated code*
(token streams) in `zerocopy-derive/src/output_tests.rs`.
- **Formal Verification (Kani):** Place Kani proofs in a `mod proofs` module
within the source file they test.
- **Purpose:** Use the
[Kani Rust Verifier](https://model-checking.github.io/kani/) to prove the
soundness of `unsafe` code or code relied upon by `unsafe` blocks. Unlike
testing, which checks specific inputs, Kani proves properties for *all*
possible inputs.
- **How to Write Proofs:**
- **Harnesses:** Mark proof functions with `#[kani::proof]`.
- **Inputs:** Use `kani::any()` to generate arbitrary inputs.
- **Assumptions:** Use `kani::assume(condition)` to constrain inputs to
valid states (e.g., `align.is_power_of_two()`).
- **Assertions:** Use `assert!(condition)` to verify the properties you
want to prove.
- **CI:** Kani runs in CI using the `model-checking/kani-github-action` with
specific feature flags to ensure compatibility.
<!-- FIXME: Describe how to ensure that a Kani proof is "total" (esp wrt function inputs). -->
## Feature Gates
When editing code gated by a feature, compile **with and without** that feature.
```bash
./cargo.sh +stable check --tests
./cargo.sh +stable check --tests --feature foo
```

View File

@@ -0,0 +1,9 @@
use zerocopy::*;
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_as_bytes_dynamic_size(source: &format::CocoPacket) -> &[u8] {
source.as_bytes()
}

View File

@@ -0,0 +1,5 @@
bench_as_bytes_dynamic_size:
mov rax, rdi
lea rdx, [2*rsi + 5]
and rdx, -2
ret

View File

@@ -0,0 +1,47 @@
Iterations: 100
Instructions: 400
Total Cycles: 137
Total uOps: 400
Dispatch Width: 4
uOps Per Cycle: 2.92
IPC: 2.92
Block RThroughput: 1.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 1 0.50 lea rdx, [2*rsi + 5]
1 1 0.33 and rdx, -2
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 1.33 1.33 - 1.34 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - - 0.66 - 0.34 - - mov rax, rdi
- - 0.33 0.67 - - - - lea rdx, [2*rsi + 5]
- - 1.00 - - - - - and rdx, -2
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,9 @@
use zerocopy::*;
#[path = "formats/coco_static_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_as_bytes_static_size(source: &format::CocoPacket) -> &[u8] {
source.as_bytes()
}

View File

@@ -0,0 +1,4 @@
bench_as_bytes_static_size:
mov rax, rdi
mov edx, 6
ret

View File

@@ -0,0 +1,45 @@
Iterations: 100
Instructions: 300
Total Cycles: 104
Total uOps: 300
Dispatch Width: 4
uOps Per Cycle: 2.88
IPC: 2.88
Block RThroughput: 1.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 1 0.33 mov edx, 6
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 0.99 1.00 - 1.01 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.99 - - 0.01 - - mov rax, rdi
- - - 1.00 - - - - mov edx, 6
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,24 @@
use zerocopy_derive::*;
// The only valid value of this type are the bytes `0xC0C0`.
#[derive(TryFromBytes, KnownLayout, Immutable)]
#[repr(u16)]
pub enum C0C0 {
_XC0C0 = 0xC0C0,
}
#[derive(FromBytes, KnownLayout, Immutable, SplitAt)]
#[repr(C, align(4))]
pub struct Packet<Magic> {
magic_number: Magic,
milk: u8,
mug_size: u8,
temperature: [u8; 5],
marshmallows: [[u8; 3]],
}
/// A packet begining with the magic number `0xC0C0`.
pub type CocoPacket = Packet<C0C0>;
/// A packet beginning with any two initialized bytes.
pub type LocoPacket = Packet<[u8; 2]>;

View File

@@ -0,0 +1,27 @@
use zerocopy_derive::*;
// The only valid value of this type are the bytes `0xC0C0`.
#[derive(TryFromBytes, KnownLayout, Immutable, IntoBytes)]
#[repr(u16)]
pub enum C0C0 {
_XC0C0 = 0xC0C0,
}
macro_rules! define_packet {
($name: ident, $trait: ident, $leading_field: ty) => {
#[derive($trait, KnownLayout, Immutable, IntoBytes, SplitAt)]
#[repr(C, align(2))]
pub struct $name {
magic_number: $leading_field,
mug_size: u8,
temperature: u8,
marshmallows: [[u8; 2]],
}
};
}
/// Packet begins with bytes 0xC0C0.
define_packet!(CocoPacket, TryFromBytes, C0C0);
/// Packet begins with any two bytes.
define_packet!(LocoPacket, FromBytes, [u8; 2]);

View File

@@ -0,0 +1,27 @@
use zerocopy_derive::*;
// The only valid value of this type are the bytes `0xC0C0`.
#[derive(TryFromBytes, KnownLayout, Immutable, IntoBytes)]
#[repr(u16)]
pub enum C0C0 {
_XC0C0 = 0xC0C0,
}
macro_rules! define_packet {
($name: ident, $trait: ident, $leading_field: ty) => {
#[derive($trait, KnownLayout, Immutable, IntoBytes)]
#[repr(C, align(2))]
pub struct $name {
magic_number: $leading_field,
mug_size: u8,
temperature: u8,
marshmallows: [u8; 2],
}
};
}
/// Packet begins with bytes 0xC0C0.
define_packet!(CocoPacket, TryFromBytes, C0C0);
/// Packet begins with any two bytes.
define_packet!(LocoPacket, FromBytes, [u8; 2]);

View File

@@ -0,0 +1,7 @@
#[path = "formats/coco_static_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_read_from_bytes_static_size(source: &[u8]) -> Option<format::LocoPacket> {
zerocopy::FromBytes::read_from_bytes(source).ok()
}

View File

@@ -0,0 +1,15 @@
bench_read_from_bytes_static_size:
mov rcx, rsi
cmp rsi, 6
jne .LBB5_2
mov eax, dword ptr [rdi]
movzx ecx, word ptr [rdi + 4]
shl rcx, 32
or rcx, rax
.LBB5_2:
shl rcx, 16
inc rcx
xor eax, eax
cmp rsi, 6
cmove rax, rcx
ret

View File

@@ -0,0 +1,65 @@
Iterations: 100
Instructions: 1300
Total Cycles: 377
Total uOps: 1400
Dispatch Width: 4
uOps Per Cycle: 3.71
IPC: 3.45
Block RThroughput: 3.5
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rcx, rsi
1 1 0.33 cmp rsi, 6
1 1 1.00 jne .LBB5_2
1 5 0.50 * mov eax, dword ptr [rdi]
1 5 0.50 * movzx ecx, word ptr [rdi + 4]
1 1 0.50 shl rcx, 32
1 1 0.33 or rcx, rax
1 1 0.50 shl rcx, 16
1 1 0.33 inc rcx
1 0 0.25 xor eax, eax
1 1 0.33 cmp rsi, 6
2 2 0.67 cmove rax, rcx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 3.66 3.67 - 3.67 1.00 1.00
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.63 0.36 - 0.01 - - mov rcx, rsi
- - 0.05 0.05 - 0.90 - - cmp rsi, 6
- - - - - 1.00 - - jne .LBB5_2
- - - - - - - 1.00 mov eax, dword ptr [rdi]
- - - - - - 1.00 - movzx ecx, word ptr [rdi + 4]
- - 0.97 - - 0.03 - - shl rcx, 32
- - 0.02 0.35 - 0.63 - - or rcx, rax
- - 0.98 - - 0.02 - - shl rcx, 16
- - - 0.98 - 0.02 - - inc rcx
- - - - - - - - xor eax, eax
- - 0.03 0.93 - 0.04 - - cmp rsi, 6
- - 0.98 1.00 - 0.02 - - cmove rax, rcx
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_static_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_read_from_prefix_static_size(source: &[u8]) -> Option<format::LocoPacket> {
match zerocopy::FromBytes::read_from_prefix(source) {
Ok((packet, _rest)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,14 @@
bench_read_from_prefix_static_size:
cmp rsi, 5
jbe .LBB5_2
mov eax, dword ptr [rdi]
movzx edi, word ptr [rdi + 4]
shl rdi, 32
or rdi, rax
.LBB5_2:
shl rdi, 16
inc rdi
xor eax, eax
cmp rsi, 6
cmovae rax, rdi
ret

View File

@@ -0,0 +1,63 @@
Iterations: 100
Instructions: 1200
Total Cycles: 905
Total uOps: 1300
Dispatch Width: 4
uOps Per Cycle: 1.44
IPC: 1.33
Block RThroughput: 3.3
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 cmp rsi, 5
1 1 1.00 jbe .LBB5_2
1 5 0.50 * mov eax, dword ptr [rdi]
1 5 0.50 * movzx edi, word ptr [rdi + 4]
1 1 0.50 shl rdi, 32
1 1 0.33 or rdi, rax
1 1 0.50 shl rdi, 16
1 1 0.33 inc rdi
1 0 0.25 xor eax, eax
1 1 0.33 cmp rsi, 6
2 2 0.67 cmovae rax, rdi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 3.32 3.32 - 3.36 1.00 1.00
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.05 0.94 - 0.01 - - cmp rsi, 5
- - - - - 1.00 - - jbe .LBB5_2
- - - - - - - 1.00 mov eax, dword ptr [rdi]
- - - - - - 1.00 - movzx edi, word ptr [rdi + 4]
- - 0.71 - - 0.29 - - shl rdi, 32
- - - 0.64 - 0.36 - - or rdi, rax
- - 1.00 - - - - - shl rdi, 16
- - 0.31 0.40 - 0.29 - - inc rdi
- - - - - - - - xor eax, eax
- - 0.34 0.35 - 0.31 - - cmp rsi, 6
- - 0.91 0.99 - 0.10 - - cmovae rax, rdi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_static_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_read_from_suffix_static_size(source: &[u8]) -> Option<format::LocoPacket> {
match zerocopy::FromBytes::read_from_suffix(source) {
Ok((_rest, packet)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,15 @@
bench_read_from_suffix_static_size:
mov rcx, rsi
cmp rsi, 6
jb .LBB5_2
mov eax, dword ptr [rdi + rsi - 6]
movzx ecx, word ptr [rdi + rsi - 2]
shl rcx, 32
or rcx, rax
.LBB5_2:
shl rcx, 16
inc rcx
xor eax, eax
cmp rsi, 6
cmovae rax, rcx
ret

View File

@@ -0,0 +1,65 @@
Iterations: 100
Instructions: 1300
Total Cycles: 377
Total uOps: 1400
Dispatch Width: 4
uOps Per Cycle: 3.71
IPC: 3.45
Block RThroughput: 3.5
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rcx, rsi
1 1 0.33 cmp rsi, 6
1 1 1.00 jb .LBB5_2
1 5 0.50 * mov eax, dword ptr [rdi + rsi - 6]
1 5 0.50 * movzx ecx, word ptr [rdi + rsi - 2]
1 1 0.50 shl rcx, 32
1 1 0.33 or rcx, rax
1 1 0.50 shl rcx, 16
1 1 0.33 inc rcx
1 0 0.25 xor eax, eax
1 1 0.33 cmp rsi, 6
2 2 0.67 cmovae rax, rcx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 3.66 3.67 - 3.67 1.00 1.00
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.63 0.36 - 0.01 - - mov rcx, rsi
- - 0.05 0.05 - 0.90 - - cmp rsi, 6
- - - - - 1.00 - - jb .LBB5_2
- - - - - - - 1.00 mov eax, dword ptr [rdi + rsi - 6]
- - - - - - 1.00 - movzx ecx, word ptr [rdi + rsi - 2]
- - 0.97 - - 0.03 - - shl rcx, 32
- - 0.02 0.35 - 0.63 - - or rcx, rax
- - 0.98 - - 0.02 - - shl rcx, 16
- - - 0.98 - 0.02 - - inc rcx
- - - - - - - - xor eax, eax
- - 0.03 0.93 - 0.04 - - cmp rsi, 6
- - 0.98 1.00 - 0.02 - - cmovae rax, rcx
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,7 @@
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_bytes_dynamic_padding(source: &[u8]) -> Option<&format::LocoPacket> {
zerocopy::FromBytes::ref_from_bytes(source).ok()
}

View File

@@ -0,0 +1,28 @@
bench_ref_from_bytes_dynamic_padding:
test dil, 3
je .LBB5_2
xor eax, eax
mov rdx, rsi
ret
.LBB5_2:
movabs rax, 9223372036854775804
and rax, rsi
cmp rax, 9
jae .LBB5_4
xor eax, eax
mov rdx, rsi
ret
.LBB5_4:
add rax, -9
movabs rcx, -6148914691236517205
mul rcx
shr rdx
lea rcx, [rdx + 2*rdx]
or rcx, 3
add rcx, 9
xor eax, eax
cmp rsi, rcx
cmove rsi, rdx
cmove rax, rdi
mov rdx, rsi
ret

View File

@@ -0,0 +1,89 @@
Iterations: 100
Instructions: 2500
Total Cycles: 849
Total uOps: 2800
Dispatch Width: 4
uOps Per Cycle: 3.30
IPC: 2.94
Block RThroughput: 7.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 test dil, 3
1 1 1.00 je .LBB5_2
1 0 0.25 xor eax, eax
1 1 0.33 mov rdx, rsi
1 1 1.00 U ret
1 1 0.33 movabs rax, 9223372036854775804
1 1 0.33 and rax, rsi
1 1 0.33 cmp rax, 9
1 1 1.00 jae .LBB5_4
1 0 0.25 xor eax, eax
1 1 0.33 mov rdx, rsi
1 1 1.00 U ret
1 1 0.33 add rax, -9
1 1 0.33 movabs rcx, -6148914691236517205
2 4 1.00 mul rcx
1 1 0.50 shr rdx
1 1 0.50 lea rcx, [rdx + 2*rdx]
1 1 0.33 or rcx, 3
1 1 0.33 add rcx, 9
1 0 0.25 xor eax, eax
1 1 0.33 cmp rsi, rcx
2 2 0.67 cmove rsi, rdx
2 2 0.67 cmove rax, rdi
1 1 0.33 mov rdx, rsi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 8.33 8.32 - 8.35 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.35 0.33 - 0.32 - - test dil, 3
- - - - - 1.00 - - je .LBB5_2
- - - - - - - - xor eax, eax
- - 0.92 0.04 - 0.04 - - mov rdx, rsi
- - - - - 1.00 - - ret
- - 0.32 0.15 - 0.53 - - movabs rax, 9223372036854775804
- - 0.03 0.06 - 0.91 - - and rax, rsi
- - 0.05 0.93 - 0.02 - - cmp rax, 9
- - - - - 1.00 - - jae .LBB5_4
- - - - - - - - xor eax, eax
- - 0.93 0.04 - 0.03 - - mov rdx, rsi
- - - - - 1.00 - - ret
- - 0.37 0.33 - 0.30 - - add rax, -9
- - 0.61 0.09 - 0.30 - - movabs rcx, -6148914691236517205
- - 1.00 1.00 - - - - mul rcx
- - 0.67 - - 0.33 - - shr rdx
- - 0.33 0.67 - - - - lea rcx, [rdx + 2*rdx]
- - 0.34 0.61 - 0.05 - - or rcx, 3
- - 0.36 0.61 - 0.03 - - add rcx, 9
- - - - - - - - xor eax, eax
- - 0.04 0.63 - 0.33 - - cmp rsi, rcx
- - 0.98 0.97 - 0.05 - - cmove rsi, rdx
- - 0.98 0.94 - 0.08 - - cmove rax, rdi
- - 0.05 0.92 - 0.03 - - mov rdx, rsi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,7 @@
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_bytes_dynamic_size(source: &[u8]) -> Option<&format::LocoPacket> {
zerocopy::FromBytes::ref_from_bytes(source).ok()
}

View File

@@ -0,0 +1,20 @@
bench_ref_from_bytes_dynamic_size:
mov rdx, rsi
cmp rsi, 4
setb al
or al, dil
test al, 1
je .LBB5_2
xor eax, eax
ret
.LBB5_2:
lea rcx, [rdx - 4]
mov rsi, rcx
shr rsi
and rcx, -2
add rcx, 4
xor eax, eax
cmp rdx, rcx
cmove rdx, rsi
cmove rax, rdi
ret

View File

@@ -0,0 +1,75 @@
Iterations: 100
Instructions: 1800
Total Cycles: 606
Total uOps: 2000
Dispatch Width: 4
uOps Per Cycle: 3.30
IPC: 2.97
Block RThroughput: 5.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rdx, rsi
1 1 0.33 cmp rsi, 4
1 1 0.50 setb al
1 1 0.33 or al, dil
1 1 0.33 test al, 1
1 1 1.00 je .LBB5_2
1 0 0.25 xor eax, eax
1 1 1.00 U ret
1 1 0.50 lea rcx, [rdx - 4]
1 1 0.33 mov rsi, rcx
1 1 0.50 shr rsi
1 1 0.33 and rcx, -2
1 1 0.33 add rcx, 4
1 0 0.25 xor eax, eax
1 1 0.33 cmp rdx, rcx
2 2 0.67 cmove rdx, rsi
2 2 0.67 cmove rax, rdi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 6.00 6.00 - 6.00 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - - 0.99 - 0.01 - - mov rdx, rsi
- - 0.99 0.01 - - - - cmp rsi, 4
- - 1.00 - - - - - setb al
- - 0.99 0.01 - - - - or al, dil
- - - 0.99 - 0.01 - - test al, 1
- - - - - 1.00 - - je .LBB5_2
- - - - - - - - xor eax, eax
- - - - - 1.00 - - ret
- - 1.00 - - - - - lea rcx, [rdx - 4]
- - - 1.00 - - - - mov rsi, rcx
- - 1.00 - - - - - shr rsi
- - 1.00 - - - - - and rcx, -2
- - - 1.00 - - - - add rcx, 4
- - - - - - - - xor eax, eax
- - - - - 1.00 - - cmp rdx, rcx
- - 0.01 1.00 - 0.99 - - cmove rdx, rsi
- - 0.01 1.00 - 0.99 - - cmove rax, rdi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,7 @@
#[path = "formats/coco_static_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_bytes_static_size(source: &[u8]) -> Option<&format::LocoPacket> {
zerocopy::FromBytes::ref_from_bytes(source).ok()
}

View File

@@ -0,0 +1,8 @@
bench_ref_from_bytes_static_size:
mov ecx, edi
and ecx, 1
xor rsi, 6
xor eax, eax
or rsi, rcx
cmove rax, rdi
ret

View File

@@ -0,0 +1,53 @@
Iterations: 100
Instructions: 700
Total Cycles: 240
Total uOps: 800
Dispatch Width: 4
uOps Per Cycle: 3.33
IPC: 2.92
Block RThroughput: 2.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov ecx, edi
1 1 0.33 and ecx, 1
1 1 0.33 xor rsi, 6
1 0 0.25 xor eax, eax
1 1 0.33 or rsi, rcx
2 2 0.67 cmove rax, rdi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 2.33 2.33 - 2.34 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.01 0.98 - 0.01 - - mov ecx, edi
- - 0.02 0.66 - 0.32 - - and ecx, 1
- - 0.33 0.66 - 0.01 - - xor rsi, 6
- - - - - - - - xor eax, eax
- - 0.98 0.02 - - - - or rsi, rcx
- - 0.99 0.01 - 1.00 - - cmove rax, rdi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_bytes_with_elems_dynamic_padding(
source: &[u8],
count: usize,
) -> Option<&format::LocoPacket> {
zerocopy::FromBytes::ref_from_bytes_with_elems(source, count).ok()
}

View File

@@ -0,0 +1,30 @@
bench_ref_from_bytes_with_elems_dynamic_padding:
mov rcx, rdx
mov edx, 3
mov rax, rcx
mul rdx
jo .LBB5_5
cmp rax, -10
ja .LBB5_5
mov edx, eax
not edx
and edx, 3
add rdx, rax
add rdx, 9
cmp rsi, rdx
jne .LBB5_5
mov r8d, edi
and r8d, 3
jne .LBB5_5
add rax, 9
cmp rdx, rax
jb .LBB5_5
mov rax, rdi
mov rdx, rcx
ret
.LBB5_5:
xor edi, edi
mov rcx, rsi
mov rax, rdi
mov rdx, rcx
ret

View File

@@ -0,0 +1,95 @@
Iterations: 100
Instructions: 2800
Total Cycles: 944
Total uOps: 2900
Dispatch Width: 4
uOps Per Cycle: 3.07
IPC: 2.97
Block RThroughput: 7.3
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rcx, rdx
1 1 0.33 mov edx, 3
1 1 0.33 mov rax, rcx
2 4 1.00 mul rdx
1 1 1.00 jo .LBB5_5
1 1 0.33 cmp rax, -10
1 1 1.00 ja .LBB5_5
1 1 0.33 mov edx, eax
1 1 0.33 not edx
1 1 0.33 and edx, 3
1 1 0.33 add rdx, rax
1 1 0.33 add rdx, 9
1 1 0.33 cmp rsi, rdx
1 1 1.00 jne .LBB5_5
1 1 0.33 mov r8d, edi
1 1 0.33 and r8d, 3
1 1 1.00 jne .LBB5_5
1 1 0.33 add rax, 9
1 1 0.33 cmp rdx, rax
1 1 1.00 jb .LBB5_5
1 1 0.33 mov rax, rdi
1 1 0.33 mov rdx, rcx
1 1 1.00 U ret
1 0 0.25 xor edi, edi
1 1 0.33 mov rcx, rsi
1 1 0.33 mov rax, rdi
1 1 0.33 mov rdx, rcx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 9.32 9.32 - 9.36 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.64 0.18 - 0.18 - - mov rcx, rdx
- - 0.17 0.83 - - - - mov edx, 3
- - 0.50 0.49 - 0.01 - - mov rax, rcx
- - 1.00 1.00 - - - - mul rdx
- - - - - 1.00 - - jo .LBB5_5
- - 0.82 0.18 - - - - cmp rax, -10
- - - - - 1.00 - - ja .LBB5_5
- - 0.02 0.98 - - - - mov edx, eax
- - 0.82 0.02 - 0.16 - - not edx
- - 0.82 0.17 - 0.01 - - and edx, 3
- - 0.99 - - 0.01 - - add rdx, rax
- - 0.98 0.01 - 0.01 - - add rdx, 9
- - 1.00 - - - - - cmp rsi, rdx
- - - - - 1.00 - - jne .LBB5_5
- - 0.16 0.83 - 0.01 - - mov r8d, edi
- - 0.17 0.17 - 0.66 - - and r8d, 3
- - - - - 1.00 - - jne .LBB5_5
- - 0.02 0.98 - - - - add rax, 9
- - - 0.17 - 0.83 - - cmp rdx, rax
- - - - - 1.00 - - jb .LBB5_5
- - 0.01 0.67 - 0.32 - - mov rax, rdi
- - 0.02 0.98 - - - - mov rdx, rcx
- - - - - 1.00 - - ret
- - - - - - - - xor edi, edi
- - 0.34 0.66 - - - - mov rcx, rsi
- - 0.34 0.50 - 0.16 - - mov rax, rdi
- - 0.50 0.50 - - - - mov rdx, rcx
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_bytes_with_elems_dynamic_size(
source: &[u8],
count: usize,
) -> Option<&format::LocoPacket> {
zerocopy::FromBytes::ref_from_bytes_with_elems(source, count).ok()
}

View File

@@ -0,0 +1,16 @@
bench_ref_from_bytes_with_elems_dynamic_size:
movabs rax, 9223372036854775805
cmp rdx, rax
seta cl
mov rax, rdi
or dil, cl
test dil, 1
jne .LBB5_2
lea rcx, [2*rdx + 4]
cmp rsi, rcx
je .LBB5_3
.LBB5_2:
xor eax, eax
mov rdx, rsi
.LBB5_3:
ret

View File

@@ -0,0 +1,65 @@
Iterations: 100
Instructions: 1300
Total Cycles: 439
Total uOps: 1400
Dispatch Width: 4
uOps Per Cycle: 3.19
IPC: 2.96
Block RThroughput: 3.5
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 movabs rax, 9223372036854775805
1 1 0.33 cmp rdx, rax
2 2 1.00 seta cl
1 1 0.33 mov rax, rdi
1 1 0.33 or dil, cl
1 1 0.33 test dil, 1
1 1 1.00 jne .LBB5_2
1 1 0.50 lea rcx, [2*rdx + 4]
1 1 0.33 cmp rsi, rcx
1 1 1.00 je .LBB5_3
1 0 0.25 xor eax, eax
1 1 0.33 mov rdx, rsi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 4.32 4.33 - 4.35 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - - 0.99 - 0.01 - - movabs rax, 9223372036854775805
- - 0.33 0.67 - - - - cmp rdx, rax
- - 1.98 - - 0.02 - - seta cl
- - 0.01 0.99 - - - - mov rax, rdi
- - 1.00 - - - - - or dil, cl
- - 0.99 0.01 - - - - test dil, 1
- - - - - 1.00 - - jne .LBB5_2
- - - 1.00 - - - - lea rcx, [2*rdx + 4]
- - 0.01 - - 0.99 - - cmp rsi, rcx
- - - - - 1.00 - - je .LBB5_3
- - - - - - - - xor eax, eax
- - - 0.67 - 0.33 - - mov rdx, rsi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_prefix_dynamic_padding(source: &[u8]) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_prefix(source) {
Ok((packet, _rest)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,22 @@
bench_ref_from_prefix_dynamic_padding:
xor edx, edx
mov eax, 0
test dil, 3
je .LBB5_1
ret
.LBB5_1:
movabs rax, 9223372036854775804
and rsi, rax
cmp rsi, 9
jae .LBB5_3
mov edx, 1
xor eax, eax
ret
.LBB5_3:
add rsi, -9
movabs rcx, -6148914691236517205
mov rax, rsi
mul rcx
shr rdx
mov rax, rdi
ret

View File

@@ -0,0 +1,77 @@
Iterations: 100
Instructions: 1900
Total Cycles: 608
Total uOps: 2000
Dispatch Width: 4
uOps Per Cycle: 3.29
IPC: 3.13
Block RThroughput: 5.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 0 0.25 xor edx, edx
1 1 0.33 mov eax, 0
1 1 0.33 test dil, 3
1 1 1.00 je .LBB5_1
1 1 1.00 U ret
1 1 0.33 movabs rax, 9223372036854775804
1 1 0.33 and rsi, rax
1 1 0.33 cmp rsi, 9
1 1 1.00 jae .LBB5_3
1 1 0.33 mov edx, 1
1 0 0.25 xor eax, eax
1 1 1.00 U ret
1 1 0.33 add rsi, -9
1 1 0.33 movabs rcx, -6148914691236517205
1 1 0.33 mov rax, rsi
2 4 1.00 mul rcx
1 1 0.50 shr rdx
1 1 0.33 mov rax, rdi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 6.00 6.00 - 6.00 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - - - - - - - xor edx, edx
- - 0.01 0.98 - 0.01 - - mov eax, 0
- - 0.98 0.01 - 0.01 - - test dil, 3
- - - - - 1.00 - - je .LBB5_1
- - - - - 1.00 - - ret
- - 0.01 0.99 - - - - movabs rax, 9223372036854775804
- - - 1.00 - - - - and rsi, rax
- - - 1.00 - - - - cmp rsi, 9
- - - - - 1.00 - - jae .LBB5_3
- - 1.00 - - - - - mov edx, 1
- - - - - - - - xor eax, eax
- - - - - 1.00 - - ret
- - 0.02 0.02 - 0.96 - - add rsi, -9
- - 0.99 0.01 - - - - movabs rcx, -6148914691236517205
- - 0.01 0.99 - - - - mov rax, rsi
- - 1.00 1.00 - - - - mul rcx
- - 1.00 - - - - - shr rdx
- - 0.98 - - 0.02 - - mov rax, rdi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_prefix_dynamic_size(source: &[u8]) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_prefix(source) {
Ok((packet, _rest)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,17 @@
bench_ref_from_prefix_dynamic_size:
xor edx, edx
mov eax, 0
test dil, 1
jne .LBB5_4
cmp rsi, 4
jae .LBB5_3
mov edx, 1
xor eax, eax
ret
.LBB5_3:
add rsi, -4
shr rsi
mov rdx, rsi
mov rax, rdi
.LBB5_4:
ret

View File

@@ -0,0 +1,67 @@
Iterations: 100
Instructions: 1400
Total Cycles: 405
Total uOps: 1400
Dispatch Width: 4
uOps Per Cycle: 3.46
IPC: 3.46
Block RThroughput: 4.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 0 0.25 xor edx, edx
1 1 0.33 mov eax, 0
1 1 0.33 test dil, 1
1 1 1.00 jne .LBB5_4
1 1 0.33 cmp rsi, 4
1 1 1.00 jae .LBB5_3
1 1 0.33 mov edx, 1
1 0 0.25 xor eax, eax
1 1 1.00 U ret
1 1 0.33 add rsi, -4
1 1 0.50 shr rsi
1 1 0.33 mov rdx, rsi
1 1 0.33 mov rax, rdi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 3.99 3.99 - 4.02 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - - - - - - - xor edx, edx
- - 0.01 0.98 - 0.01 - - mov eax, 0
- - 0.98 0.02 - - - - test dil, 1
- - - - - 1.00 - - jne .LBB5_4
- - 0.02 0.98 - - - - cmp rsi, 4
- - - - - 1.00 - - jae .LBB5_3
- - 0.98 0.01 - 0.01 - - mov edx, 1
- - - - - - - - xor eax, eax
- - - - - 1.00 - - ret
- - 0.01 0.99 - - - - add rsi, -4
- - 1.00 - - - - - shr rsi
- - - 1.00 - - - - mov rdx, rsi
- - 0.99 0.01 - - - - mov rax, rdi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_static_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_prefix_static_size(source: &[u8]) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_prefix(source) {
Ok((packet, _rest)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,8 @@
bench_ref_from_prefix_static_size:
xor eax, eax
cmp rsi, 6
mov rcx, rdi
cmovb rcx, rax
test dil, 1
cmove rax, rcx
ret

View File

@@ -0,0 +1,53 @@
Iterations: 100
Instructions: 700
Total Cycles: 274
Total uOps: 900
Dispatch Width: 4
uOps Per Cycle: 3.28
IPC: 2.55
Block RThroughput: 2.3
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 0 0.25 xor eax, eax
1 1 0.33 cmp rsi, 6
1 1 0.33 mov rcx, rdi
2 2 0.67 cmovb rcx, rax
1 1 0.33 test dil, 1
2 2 0.67 cmove rax, rcx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 2.66 2.67 - 2.67 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - - - - - - - xor eax, eax
- - - 0.01 - 0.99 - - cmp rsi, 6
- - 0.01 0.67 - 0.32 - - mov rcx, rdi
- - 1.00 0.99 - 0.01 - - cmovb rcx, rax
- - 0.66 0.01 - 0.33 - - test dil, 1
- - 0.99 0.99 - 0.02 - - cmove rax, rcx
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,13 @@
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_prefix_with_elems_dynamic_padding(
source: &[u8],
count: usize,
) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_prefix_with_elems(source, count) {
Ok((packet, _rest)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,35 @@
bench_ref_from_prefix_with_elems_dynamic_padding:
mov rcx, rdx
mov edx, 3
mov rax, rcx
mul rdx
mov edx, 1
jo .LBB5_5
cmp rax, -10
ja .LBB5_5
lea r8, [rax + 9]
not eax
and eax, 3
add rax, r8
jae .LBB5_3
.LBB5_5:
xor r8d, r8d
mov rax, r8
ret
.LBB5_3:
xor edx, edx
mov r8d, 0
test dil, 3
je .LBB5_4
mov rax, r8
ret
.LBB5_4:
xor edx, edx
cmp rax, rsi
mov eax, 1
cmova rcx, rax
cmova rdi, rdx
mov rdx, rcx
mov r8, rdi
mov rax, r8
ret

View File

@@ -0,0 +1,101 @@
Iterations: 100
Instructions: 3100
Total Cycles: 1110
Total uOps: 3600
Dispatch Width: 4
uOps Per Cycle: 3.24
IPC: 2.79
Block RThroughput: 9.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rcx, rdx
1 1 0.33 mov edx, 3
1 1 0.33 mov rax, rcx
2 4 1.00 mul rdx
1 1 0.33 mov edx, 1
1 1 1.00 jo .LBB5_5
1 1 0.33 cmp rax, -10
1 1 1.00 ja .LBB5_5
1 1 0.50 lea r8, [rax + 9]
1 1 0.33 not eax
1 1 0.33 and eax, 3
1 1 0.33 add rax, r8
1 1 1.00 jae .LBB5_3
1 0 0.25 xor r8d, r8d
1 1 0.33 mov rax, r8
1 1 1.00 U ret
1 0 0.25 xor edx, edx
1 1 0.33 mov r8d, 0
1 1 0.33 test dil, 3
1 1 1.00 je .LBB5_4
1 1 0.33 mov rax, r8
1 1 1.00 U ret
1 0 0.25 xor edx, edx
1 1 0.33 cmp rax, rsi
1 1 0.33 mov eax, 1
3 3 1.00 cmova rcx, rax
3 3 1.00 cmova rdi, rdx
1 1 0.33 mov rdx, rcx
1 1 0.33 mov r8, rdi
1 1 0.33 mov rax, r8
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 11.01 10.98 - 11.01 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.48 0.50 - 0.02 - - mov rcx, rdx
- - 0.02 0.98 - - - - mov edx, 3
- - 0.51 0.48 - 0.01 - - mov rax, rcx
- - 1.00 1.00 - - - - mul rdx
- - 0.49 0.50 - 0.01 - - mov edx, 1
- - - - - 1.00 - - jo .LBB5_5
- - 0.98 0.02 - - - - cmp rax, -10
- - - - - 1.00 - - ja .LBB5_5
- - 0.02 0.98 - - - - lea r8, [rax + 9]
- - 0.98 0.02 - - - - not eax
- - 0.99 0.01 - - - - and eax, 3
- - 0.98 0.01 - 0.01 - - add rax, r8
- - - - - 1.00 - - jae .LBB5_3
- - - - - - - - xor r8d, r8d
- - 0.01 0.98 - 0.01 - - mov rax, r8
- - - - - 1.00 - - ret
- - - - - - - - xor edx, edx
- - 0.48 0.52 - - - - mov r8d, 0
- - 0.02 0.97 - 0.01 - - test dil, 3
- - - - - 1.00 - - je .LBB5_4
- - 0.49 0.50 - 0.01 - - mov rax, r8
- - - - - 1.00 - - ret
- - - - - - - - xor edx, edx
- - 0.51 0.49 - - - - cmp rax, rsi
- - - 1.00 - - - - mov eax, 1
- - 1.04 0.97 - 0.99 - - cmova rcx, rax
- - 0.98 0.53 - 1.49 - - cmova rdi, rdx
- - 0.50 0.50 - - - - mov rdx, rcx
- - 0.51 0.01 - 0.48 - - mov r8, rdi
- - 0.02 0.01 - 0.97 - - mov rax, r8
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,13 @@
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_prefix_with_elems_dynamic_size(
source: &[u8],
count: usize,
) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_prefix_with_elems(source, count) {
Ok((packet, _rest)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,22 @@
bench_ref_from_prefix_with_elems_dynamic_size:
movabs rax, 9223372036854775805
cmp rdx, rax
ja .LBB5_1
mov rcx, rdx
xor edx, edx
mov eax, 0
test dil, 1
jne .LBB5_4
lea rax, [2*rcx + 4]
xor r8d, r8d
cmp rax, rsi
mov edx, 1
cmovbe rdx, rcx
cmova rdi, r8
mov rax, rdi
.LBB5_4:
ret
.LBB5_1:
mov edx, 1
xor eax, eax
ret

View File

@@ -0,0 +1,77 @@
Iterations: 100
Instructions: 1900
Total Cycles: 672
Total uOps: 2300
Dispatch Width: 4
uOps Per Cycle: 3.42
IPC: 2.83
Block RThroughput: 5.8
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 movabs rax, 9223372036854775805
1 1 0.33 cmp rdx, rax
1 1 1.00 ja .LBB5_1
1 1 0.33 mov rcx, rdx
1 0 0.25 xor edx, edx
1 1 0.33 mov eax, 0
1 1 0.33 test dil, 1
1 1 1.00 jne .LBB5_4
1 1 0.50 lea rax, [2*rcx + 4]
1 0 0.25 xor r8d, r8d
1 1 0.33 cmp rax, rsi
1 1 0.33 mov edx, 1
3 3 1.00 cmovbe rdx, rcx
3 3 1.00 cmova rdi, r8
1 1 0.33 mov rax, rdi
1 1 1.00 U ret
1 1 0.33 mov edx, 1
1 0 0.25 xor eax, eax
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 6.66 6.66 - 6.68 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - - 0.99 - 0.01 - - movabs rax, 9223372036854775805
- - 0.37 0.63 - - - - cmp rdx, rax
- - - - - 1.00 - - ja .LBB5_1
- - 0.63 0.37 - - - - mov rcx, rdx
- - - - - - - - xor edx, edx
- - 0.01 0.98 - 0.01 - - mov eax, 0
- - 0.98 0.02 - - - - test dil, 1
- - - - - 1.00 - - jne .LBB5_4
- - 0.01 0.99 - - - - lea rax, [2*rcx + 4]
- - - - - - - - xor r8d, r8d
- - 1.00 - - - - - cmp rax, rsi
- - - 0.67 - 0.33 - - mov edx, 1
- - 0.73 0.98 - 1.29 - - cmovbe rdx, rcx
- - 1.60 0.36 - 1.04 - - cmova rdi, r8
- - 0.99 0.01 - - - - mov rax, rdi
- - - - - 1.00 - - ret
- - 0.34 0.66 - - - - mov edx, 1
- - - - - - - - xor eax, eax
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_suffix_dynamic_padding(source: &[u8]) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_suffix(source) {
Ok((_rest, packet)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,23 @@
bench_ref_from_suffix_dynamic_padding:
lea eax, [rsi + rdi]
test al, 3
jne .LBB5_1
movabs rax, 9223372036854775804
and rax, rsi
cmp rax, 9
jae .LBB5_3
.LBB5_1:
xor eax, eax
ret
.LBB5_3:
add rax, -9
movabs rcx, -6148914691236517205
mul rcx
shr rdx
lea rax, [rdx + 2*rdx]
sub rsi, rax
or rax, -4
add rsi, rdi
add rax, rsi
add rax, -8
ret

View File

@@ -0,0 +1,79 @@
Iterations: 100
Instructions: 2000
Total Cycles: 682
Total uOps: 2100
Dispatch Width: 4
uOps Per Cycle: 3.08
IPC: 2.93
Block RThroughput: 5.3
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.50 lea eax, [rsi + rdi]
1 1 0.33 test al, 3
1 1 1.00 jne .LBB5_1
1 1 0.33 movabs rax, 9223372036854775804
1 1 0.33 and rax, rsi
1 1 0.33 cmp rax, 9
1 1 1.00 jae .LBB5_3
1 0 0.25 xor eax, eax
1 1 1.00 U ret
1 1 0.33 add rax, -9
1 1 0.33 movabs rcx, -6148914691236517205
2 4 1.00 mul rcx
1 1 0.50 shr rdx
1 1 0.50 lea rax, [rdx + 2*rdx]
1 1 0.33 sub rsi, rax
1 1 0.33 or rax, -4
1 1 0.33 add rsi, rdi
1 1 0.33 add rax, rsi
1 1 0.33 add rax, -8
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 6.65 6.67 - 6.68 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.90 0.10 - - - - lea eax, [rsi + rdi]
- - 0.93 - - 0.07 - - test al, 3
- - - - - 1.00 - - jne .LBB5_1
- - 0.51 0.47 - 0.02 - - movabs rax, 9223372036854775804
- - - - - 1.00 - - and rax, rsi
- - - 0.09 - 0.91 - - cmp rax, 9
- - - - - 1.00 - - jae .LBB5_3
- - - - - - - - xor eax, eax
- - - - - 1.00 - - ret
- - 0.43 0.47 - 0.10 - - add rax, -9
- - 0.42 0.39 - 0.19 - - movabs rcx, -6148914691236517205
- - 1.00 1.00 - - - - mul rcx
- - 0.69 - - 0.31 - - shr rdx
- - 0.54 0.46 - - - - lea rax, [rdx + 2*rdx]
- - 0.07 0.91 - 0.02 - - sub rsi, rax
- - 0.91 0.05 - 0.04 - - or rax, -4
- - 0.08 0.90 - 0.02 - - add rsi, rdi
- - 0.09 0.91 - - - - add rax, rsi
- - 0.08 0.92 - - - - add rax, -8
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_suffix_dynamic_size(source: &[u8]) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_suffix(source) {
Ok((_rest, packet)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,13 @@
bench_ref_from_suffix_dynamic_size:
mov rdx, rsi
lea ecx, [rsi + rdi]
mov eax, edx
and eax, 1
add rax, rdi
xor esi, esi
sub rdx, 4
cmovb rax, rsi
shr rdx
test cl, 1
cmovne rax, rsi
ret

View File

@@ -0,0 +1,63 @@
Iterations: 100
Instructions: 1200
Total Cycles: 439
Total uOps: 1400
Dispatch Width: 4
uOps Per Cycle: 3.19
IPC: 2.73
Block RThroughput: 3.5
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rdx, rsi
1 1 0.50 lea ecx, [rsi + rdi]
1 1 0.33 mov eax, edx
1 1 0.33 and eax, 1
1 1 0.33 add rax, rdi
1 0 0.25 xor esi, esi
1 1 0.33 sub rdx, 4
2 2 0.67 cmovb rax, rsi
1 1 0.50 shr rdx
1 1 0.33 test cl, 1
2 2 0.67 cmovne rax, rsi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 4.33 4.33 - 4.34 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.02 0.32 - 0.66 - - mov rdx, rsi
- - 0.32 0.68 - - - - lea ecx, [rsi + rdi]
- - 0.66 - - 0.34 - - mov eax, edx
- - 0.02 0.33 - 0.65 - - and eax, 1
- - - 0.99 - 0.01 - - add rax, rdi
- - - - - - - - xor esi, esi
- - 0.65 - - 0.35 - - sub rdx, 4
- - 1.00 1.00 - - - - cmovb rax, rsi
- - 0.66 - - 0.34 - - shr rdx
- - - 0.01 - 0.99 - - test cl, 1
- - 1.00 1.00 - - - - cmovne rax, rsi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,10 @@
#[path = "formats/coco_static_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_suffix_static_size(source: &[u8]) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_suffix(source) {
Ok((_rest, packet)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,13 @@
bench_ref_from_suffix_static_size:
lea eax, [rsi + rdi]
cmp rsi, 6
setb cl
or cl, al
test cl, 1
je .LBB5_2
xor eax, eax
ret
.LBB5_2:
lea rax, [rdi + rsi]
add rax, -6
ret

View File

@@ -0,0 +1,61 @@
Iterations: 100
Instructions: 1100
Total Cycles: 338
Total uOps: 1100
Dispatch Width: 4
uOps Per Cycle: 3.25
IPC: 3.25
Block RThroughput: 3.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.50 lea eax, [rsi + rdi]
1 1 0.33 cmp rsi, 6
1 1 0.50 setb cl
1 1 0.33 or cl, al
1 1 0.33 test cl, 1
1 1 1.00 je .LBB5_2
1 0 0.25 xor eax, eax
1 1 1.00 U ret
1 1 0.50 lea rax, [rdi + rsi]
1 1 0.33 add rax, -6
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 3.32 3.33 - 3.35 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.97 0.03 - - - - lea eax, [rsi + rdi]
- - 0.33 0.32 - 0.35 - - cmp rsi, 6
- - 1.00 - - - - - setb cl
- - - 1.00 - - - - or cl, al
- - - 1.00 - - - - test cl, 1
- - - - - 1.00 - - je .LBB5_2
- - - - - - - - xor eax, eax
- - - - - 1.00 - - ret
- - 0.34 0.66 - - - - lea rax, [rdi + rsi]
- - 0.68 0.32 - - - - add rax, -6
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,13 @@
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_suffix_with_elems_dynamic_padding(
source: &[u8],
count: usize,
) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_suffix_with_elems(source, count) {
Ok((_rest, packet)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,34 @@
bench_ref_from_suffix_with_elems_dynamic_padding:
mov rcx, rdx
mov edx, 3
mov rax, rcx
mul rdx
jo .LBB5_1
cmp rax, -10
ja .LBB5_1
lea rdx, [rax + 9]
not eax
and eax, 3
add rax, rdx
jae .LBB5_4
.LBB5_1:
xor r8d, r8d
mov edx, 1
mov rax, r8
ret
.LBB5_4:
lea r9d, [rsi + rdi]
xor edx, edx
mov r8d, 0
test r9b, 3
je .LBB5_5
mov rax, r8
ret
.LBB5_5:
sub rsi, rax
jb .LBB5_1
add rdi, rsi
mov rdx, rcx
mov r8, rdi
mov rax, r8
ret

View File

@@ -0,0 +1,99 @@
Iterations: 100
Instructions: 3000
Total Cycles: 973
Total uOps: 3100
Dispatch Width: 4
uOps Per Cycle: 3.19
IPC: 3.08
Block RThroughput: 8.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rcx, rdx
1 1 0.33 mov edx, 3
1 1 0.33 mov rax, rcx
2 4 1.00 mul rdx
1 1 1.00 jo .LBB5_1
1 1 0.33 cmp rax, -10
1 1 1.00 ja .LBB5_1
1 1 0.50 lea rdx, [rax + 9]
1 1 0.33 not eax
1 1 0.33 and eax, 3
1 1 0.33 add rax, rdx
1 1 1.00 jae .LBB5_4
1 0 0.25 xor r8d, r8d
1 1 0.33 mov edx, 1
1 1 0.33 mov rax, r8
1 1 1.00 U ret
1 1 0.50 lea r9d, [rsi + rdi]
1 0 0.25 xor edx, edx
1 1 0.33 mov r8d, 0
1 1 0.33 test r9b, 3
1 1 1.00 je .LBB5_5
1 1 0.33 mov rax, r8
1 1 1.00 U ret
1 1 0.33 sub rsi, rax
1 1 1.00 jb .LBB5_1
1 1 0.33 add rdi, rsi
1 1 0.33 mov rdx, rcx
1 1 0.33 mov r8, rdi
1 1 0.33 mov rax, r8
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 9.66 9.66 - 9.68 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - - 0.99 - 0.01 - - mov rcx, rdx
- - 0.66 0.34 - - - - mov edx, 3
- - 0.34 0.66 - - - - mov rax, rcx
- - 1.00 1.00 - - - - mul rdx
- - - - - 1.00 - - jo .LBB5_1
- - 1.00 - - - - - cmp rax, -10
- - - - - 1.00 - - ja .LBB5_1
- - - 1.00 - - - - lea rdx, [rax + 9]
- - 1.00 - - - - - not eax
- - 1.00 - - - - - and eax, 3
- - 1.00 - - - - - add rax, rdx
- - - - - 1.00 - - jae .LBB5_4
- - - - - - - - xor r8d, r8d
- - 0.33 0.33 - 0.34 - - mov edx, 1
- - 0.33 - - 0.67 - - mov rax, r8
- - - - - 1.00 - - ret
- - 0.33 0.67 - - - - lea r9d, [rsi + rdi]
- - - - - - - - xor edx, edx
- - 0.67 0.33 - - - - mov r8d, 0
- - 0.33 0.34 - 0.33 - - test r9b, 3
- - - - - 1.00 - - je .LBB5_5
- - 0.66 0.01 - 0.33 - - mov rax, r8
- - - - - 1.00 - - ret
- - 0.33 0.67 - - - - sub rsi, rax
- - - - - 1.00 - - jb .LBB5_1
- - - 1.00 - - - - add rdi, rsi
- - 0.01 0.99 - - - - mov rdx, rcx
- - - 1.00 - - - - mov r8, rdi
- - 0.67 0.33 - - - - mov rax, r8
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,13 @@
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_ref_from_suffix_with_elems_dynamic_size(
source: &[u8],
count: usize,
) -> Option<&format::LocoPacket> {
match zerocopy::FromBytes::ref_from_suffix_with_elems(source, count) {
Ok((_rest, packet)) => Some(packet),
_ => None,
}
}

View File

@@ -0,0 +1,23 @@
bench_ref_from_suffix_with_elems_dynamic_size:
movabs rax, 9223372036854775805
cmp rdx, rax
ja .LBB5_1
lea r8d, [rsi + rdi]
xor ecx, ecx
mov eax, 0
test r8b, 1
jne .LBB5_5
lea rax, [2*rdx + 4]
sub rsi, rax
jae .LBB5_4
.LBB5_1:
xor eax, eax
mov edx, 1
ret
.LBB5_4:
add rdi, rsi
mov rcx, rdx
mov rax, rdi
.LBB5_5:
mov rdx, rcx
ret

View File

@@ -0,0 +1,77 @@
Iterations: 100
Instructions: 1900
Total Cycles: 571
Total uOps: 1900
Dispatch Width: 4
uOps Per Cycle: 3.33
IPC: 3.33
Block RThroughput: 5.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 movabs rax, 9223372036854775805
1 1 0.33 cmp rdx, rax
1 1 1.00 ja .LBB5_1
1 1 0.50 lea r8d, [rsi + rdi]
1 0 0.25 xor ecx, ecx
1 1 0.33 mov eax, 0
1 1 0.33 test r8b, 1
1 1 1.00 jne .LBB5_5
1 1 0.50 lea rax, [2*rdx + 4]
1 1 0.33 sub rsi, rax
1 1 1.00 jae .LBB5_4
1 0 0.25 xor eax, eax
1 1 0.33 mov edx, 1
1 1 1.00 U ret
1 1 0.33 add rdi, rsi
1 1 0.33 mov rcx, rdx
1 1 0.33 mov rax, rdi
1 1 0.33 mov rdx, rcx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 5.66 5.66 - 5.68 - -
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.66 0.33 - 0.01 - - movabs rax, 9223372036854775805
- - 0.01 0.99 - - - - cmp rdx, rax
- - - - - 1.00 - - ja .LBB5_1
- - 0.99 0.01 - - - - lea r8d, [rsi + rdi]
- - - - - - - - xor ecx, ecx
- - 0.33 0.33 - 0.34 - - mov eax, 0
- - 0.33 0.34 - 0.33 - - test r8b, 1
- - - - - 1.00 - - jne .LBB5_5
- - 0.34 0.66 - - - - lea rax, [2*rdx + 4]
- - - 1.00 - - - - sub rsi, rax
- - - - - 1.00 - - jae .LBB5_4
- - - - - - - - xor eax, eax
- - 1.00 - - - - - mov edx, 1
- - - - - 1.00 - - ret
- - - 1.00 - - - - add rdi, rsi
- - 1.00 - - - - - mov rcx, rdx
- - 0.32 0.68 - - - - mov rax, rdi
- - 0.68 0.32 - - - - mov rdx, rcx
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,12 @@
use zerocopy::*;
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_split_at_dynamic_padding(
source: &format::CocoPacket,
len: usize,
) -> Option<Split<&format::CocoPacket>> {
source.split_at(len)
}

View File

@@ -0,0 +1,12 @@
bench_split_at_dynamic_padding:
mov rax, rdi
cmp rcx, rdx
jbe .LBB5_2
xor esi, esi
mov qword ptr [rax], rsi
ret
.LBB5_2:
mov qword ptr [rax + 8], rdx
mov qword ptr [rax + 16], rcx
mov qword ptr [rax], rsi
ret

View File

@@ -0,0 +1,59 @@
Iterations: 100
Instructions: 1000
Total Cycles: 404
Total uOps: 1000
Dispatch Width: 4
uOps Per Cycle: 2.48
IPC: 2.48
Block RThroughput: 4.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 1 0.33 cmp rcx, rdx
1 1 1.00 jbe .LBB5_2
1 0 0.25 xor esi, esi
1 1 1.00 * mov qword ptr [rax], rsi
1 1 1.00 U ret
1 1 1.00 * mov qword ptr [rax + 8], rdx
1 1 1.00 * mov qword ptr [rax + 16], rcx
1 1 1.00 * mov qword ptr [rax], rsi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 0.99 1.00 4.00 3.01 2.00 2.00
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.99 - - 0.01 - - mov rax, rdi
- - - 1.00 - - - - cmp rcx, rdx
- - - - - 1.00 - - jbe .LBB5_2
- - - - - - - - xor esi, esi
- - - - 1.00 - - 1.00 mov qword ptr [rax], rsi
- - - - - 1.00 - - ret
- - - - 1.00 - 1.00 - mov qword ptr [rax + 8], rdx
- - - - 1.00 - - 1.00 mov qword ptr [rax + 16], rcx
- - - - 1.00 - 1.00 - mov qword ptr [rax], rsi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,12 @@
use zerocopy::*;
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_split_at_dynamic_size(
source: &format::CocoPacket,
len: usize,
) -> Option<Split<&format::CocoPacket>> {
source.split_at(len)
}

View File

@@ -0,0 +1,12 @@
bench_split_at_dynamic_size:
mov rax, rdi
cmp rcx, rdx
jbe .LBB5_2
xor esi, esi
mov qword ptr [rax], rsi
ret
.LBB5_2:
mov qword ptr [rax + 8], rdx
mov qword ptr [rax + 16], rcx
mov qword ptr [rax], rsi
ret

View File

@@ -0,0 +1,59 @@
Iterations: 100
Instructions: 1000
Total Cycles: 404
Total uOps: 1000
Dispatch Width: 4
uOps Per Cycle: 2.48
IPC: 2.48
Block RThroughput: 4.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 1 0.33 cmp rcx, rdx
1 1 1.00 jbe .LBB5_2
1 0 0.25 xor esi, esi
1 1 1.00 * mov qword ptr [rax], rsi
1 1 1.00 U ret
1 1 1.00 * mov qword ptr [rax + 8], rdx
1 1 1.00 * mov qword ptr [rax + 16], rcx
1 1 1.00 * mov qword ptr [rax], rsi
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 0.99 1.00 4.00 3.01 2.00 2.00
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.99 - - 0.01 - - mov rax, rdi
- - - 1.00 - - - - cmp rcx, rdx
- - - - - 1.00 - - jbe .LBB5_2
- - - - - - - - xor esi, esi
- - - - 1.00 - - 1.00 mov qword ptr [rax], rsi
- - - - - 1.00 - - ret
- - - - 1.00 - 1.00 - mov qword ptr [rax + 8], rdx
- - - - 1.00 - - 1.00 mov qword ptr [rax + 16], rcx
- - - - 1.00 - 1.00 - mov qword ptr [rax], rsi
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,12 @@
use zerocopy::*;
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
unsafe fn bench_split_at_unchecked_dynamic_padding(
source: &format::CocoPacket,
len: usize,
) -> Split<&format::CocoPacket> {
unsafe { source.split_at_unchecked(len) }
}

View File

@@ -0,0 +1,6 @@
bench_split_at_unchecked_dynamic_padding:
mov rax, rdi
mov qword ptr [rdi], rsi
mov qword ptr [rdi + 8], rdx
mov qword ptr [rdi + 16], rcx
ret

View File

@@ -0,0 +1,49 @@
Iterations: 100
Instructions: 500
Total Cycles: 303
Total uOps: 500
Dispatch Width: 4
uOps Per Cycle: 1.65
IPC: 1.65
Block RThroughput: 3.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 1 1.00 * mov qword ptr [rdi], rsi
1 1 1.00 * mov qword ptr [rdi + 8], rdx
1 1 1.00 * mov qword ptr [rdi + 16], rcx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 0.49 0.50 3.00 1.01 1.50 1.50
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.49 0.50 - 0.01 - - mov rax, rdi
- - - - 1.00 - 0.50 0.50 mov qword ptr [rdi], rsi
- - - - 1.00 - 0.50 0.50 mov qword ptr [rdi + 8], rdx
- - - - 1.00 - 0.50 0.50 mov qword ptr [rdi + 16], rcx
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,12 @@
use zerocopy::*;
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
unsafe fn bench_split_at_unchecked_dynamic_size(
source: &format::CocoPacket,
len: usize,
) -> Split<&format::CocoPacket> {
unsafe { source.split_at_unchecked(len) }
}

View File

@@ -0,0 +1,6 @@
bench_split_at_unchecked_dynamic_size:
mov rax, rdi
mov qword ptr [rdi], rsi
mov qword ptr [rdi + 8], rdx
mov qword ptr [rdi + 16], rcx
ret

View File

@@ -0,0 +1,49 @@
Iterations: 100
Instructions: 500
Total Cycles: 303
Total uOps: 500
Dispatch Width: 4
uOps Per Cycle: 1.65
IPC: 1.65
Block RThroughput: 3.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 1 1.00 * mov qword ptr [rdi], rsi
1 1 1.00 * mov qword ptr [rdi + 8], rdx
1 1 1.00 * mov qword ptr [rdi + 16], rcx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 0.49 0.50 3.00 1.01 1.50 1.50
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.49 0.50 - 0.01 - - mov rax, rdi
- - - - 1.00 - 0.50 0.50 mov qword ptr [rdi], rsi
- - - - 1.00 - 0.50 0.50 mov qword ptr [rdi + 8], rdx
- - - - 1.00 - 0.50 0.50 mov qword ptr [rdi + 16], rcx
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,11 @@
use zerocopy::*;
#[path = "formats/coco_dynamic_padding.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_split_via_immutable_dynamic_padding(
split: Split<&format::CocoPacket>,
) -> (&format::CocoPacket, &[[u8; 3]]) {
split.via_immutable()
}

View File

@@ -0,0 +1,14 @@
bench_split_via_immutable_dynamic_padding:
mov rax, rdi
mov rcx, qword ptr [rsi]
mov rdx, qword ptr [rsi + 8]
mov rsi, qword ptr [rsi + 16]
lea rdi, [rsi + 2*rsi]
add rdi, rcx
add rdi, 9
sub rdx, rsi
mov qword ptr [rax], rcx
mov qword ptr [rax + 8], rsi
mov qword ptr [rax + 16], rdi
mov qword ptr [rax + 24], rdx
ret

View File

@@ -0,0 +1,65 @@
Iterations: 100
Instructions: 1300
Total Cycles: 510
Total uOps: 1300
Dispatch Width: 4
uOps Per Cycle: 2.55
IPC: 2.55
Block RThroughput: 4.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 5 0.50 * mov rcx, qword ptr [rsi]
1 5 0.50 * mov rdx, qword ptr [rsi + 8]
1 5 0.50 * mov rsi, qword ptr [rsi + 16]
1 1 0.50 lea rdi, [rsi + 2*rsi]
1 1 0.33 add rdi, rcx
1 1 0.33 add rdi, 9
1 1 0.33 sub rdx, rsi
1 1 1.00 * mov qword ptr [rax], rcx
1 1 1.00 * mov qword ptr [rax + 8], rsi
1 1 1.00 * mov qword ptr [rax + 16], rdi
1 1 1.00 * mov qword ptr [rax + 24], rdx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 2.00 2.00 4.00 2.00 3.50 3.50
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.03 0.93 - 0.04 - - mov rax, rdi
- - - - - - 0.49 0.51 mov rcx, qword ptr [rsi]
- - - - - - 1.00 - mov rdx, qword ptr [rsi + 8]
- - - - - - 0.01 0.99 mov rsi, qword ptr [rsi + 16]
- - 0.93 0.07 - - - - lea rdi, [rsi + 2*rsi]
- - 0.05 0.02 - 0.93 - - add rdi, rcx
- - 0.49 0.49 - 0.02 - - add rdi, 9
- - 0.50 0.49 - 0.01 - - sub rdx, rsi
- - - - 1.00 - 0.50 0.50 mov qword ptr [rax], rcx
- - - - 1.00 - 0.50 0.50 mov qword ptr [rax + 8], rsi
- - - - 1.00 - 0.49 0.51 mov qword ptr [rax + 16], rdi
- - - - 1.00 - 0.51 0.49 mov qword ptr [rax + 24], rdx
- - - - - 1.00 - - ret

View File

@@ -0,0 +1,11 @@
use zerocopy::*;
#[path = "formats/coco_dynamic_size.rs"]
mod format;
#[unsafe(no_mangle)]
fn bench_split_via_immutable_dynamic_size(
split: Split<&format::CocoPacket>,
) -> (&format::CocoPacket, &[[u8; 2]]) {
split.via_immutable()
}

View File

@@ -0,0 +1,13 @@
bench_split_via_immutable_dynamic_size:
mov rax, rdi
mov rcx, qword ptr [rsi]
mov rdx, qword ptr [rsi + 8]
mov rsi, qword ptr [rsi + 16]
lea rdi, [rcx + 2*rsi]
add rdi, 4
sub rdx, rsi
mov qword ptr [rax], rcx
mov qword ptr [rax + 8], rsi
mov qword ptr [rax + 16], rdi
mov qword ptr [rax + 24], rdx
ret

View File

@@ -0,0 +1,63 @@
Iterations: 100
Instructions: 1200
Total Cycles: 509
Total uOps: 1200
Dispatch Width: 4
uOps Per Cycle: 2.36
IPC: 2.36
Block RThroughput: 4.0
Instruction Info:
[1]: #uOps
[2]: Latency
[3]: RThroughput
[4]: MayLoad
[5]: MayStore
[6]: HasSideEffects (U)
[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 5 0.50 * mov rcx, qword ptr [rsi]
1 5 0.50 * mov rdx, qword ptr [rsi + 8]
1 5 0.50 * mov rsi, qword ptr [rsi + 16]
1 1 0.50 lea rdi, [rcx + 2*rsi]
1 1 0.33 add rdi, 4
1 1 0.33 sub rdx, rsi
1 1 1.00 * mov qword ptr [rax], rcx
1 1 1.00 * mov qword ptr [rax + 8], rsi
1 1 1.00 * mov qword ptr [rax + 16], rdi
1 1 1.00 * mov qword ptr [rax + 24], rdx
1 1 1.00 U ret
Resources:
[0] - SBDivider
[1] - SBFPDivider
[2] - SBPort0
[3] - SBPort1
[4] - SBPort4
[5] - SBPort5
[6.0] - SBPort23
[6.1] - SBPort23
Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 1.66 1.66 4.00 1.68 3.50 3.50
Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.34 0.33 - 0.33 - - mov rax, rdi
- - - - - - 0.49 0.51 mov rcx, qword ptr [rsi]
- - - - - - 0.51 0.49 mov rdx, qword ptr [rsi + 8]
- - - - - - 0.01 0.99 mov rsi, qword ptr [rsi + 16]
- - 0.33 0.67 - - - - lea rdi, [rcx + 2*rsi]
- - 0.63 0.34 - 0.03 - - add rdi, 4
- - 0.36 0.32 - 0.32 - - sub rdx, rsi
- - - - 1.00 - 0.50 0.50 mov qword ptr [rax], rcx
- - - - 1.00 - 0.50 0.50 mov qword ptr [rax + 8], rsi
- - - - 1.00 - 0.98 0.02 mov qword ptr [rax + 16], rdi
- - - - 1.00 - 0.51 0.49 mov qword ptr [rax + 24], rdx
- - - - - 1.00 - - ret

Some files were not shown because too many files have changed in this diff Show More