gecko-dev/third_party/rust/cranelift-entity
Benjamin Bouvier e84c6bd970 Bug 1532689: Bump Cranelift to 0.29 in Spidermonkey; r=sunfish
This adds new code to provide the module-relative initial function offset for
each function, and adds checks that the bytecode / code offsets are correct.

Differential Revision: https://phabricator.services.mozilla.com/D22141

--HG--
rename : third_party/rust/cranelift-codegen-meta/src/base/settings.rs => third_party/rust/cranelift-codegen-meta/src/shared/settings.rs
rename : third_party/rust/cranelift-codegen-meta/src/base/types.rs => third_party/rust/cranelift-codegen-meta/src/shared/types.rs
extra : rebase_source : fd70523925d5d0655917bd9068f7ed35836c714a
extra : histedit_source : e64727d7be746dc3f327909db83f091602e259a9%2Cfc2a4335c2adada30a265a50fa76ef75a2b00bad
2019-03-05 18:34:50 +01:00
..
src Bug 1522173: Bump Cranelift to 0.28; r=sunfish 2019-01-24 10:51:17 +01:00
.cargo-checksum.json Bug 1532689: Bump Cranelift to 0.29 in Spidermonkey; r=sunfish 2019-03-05 18:34:50 +01:00
Cargo.toml Bug 1532689: Bump Cranelift to 0.29 in Spidermonkey; r=sunfish 2019-03-05 18:34:50 +01:00
LICENSE Bug 1505777: Run mach-vendor-rust to update Cranelift. rs=bbouvier 2018-11-09 05:16:08 -08:00
README.md Bug 1505777: Run mach-vendor-rust to update Cranelift. rs=bbouvier 2018-11-09 05:16:08 -08:00

This crate contains array-based data structures used by the core Cranelift code generator which use densely numbered entity references as mapping keys.

One major difference between this crate and crates like slotmap, slab, and generational-arena is that this crate currently provides no way to delete entities. This limits its use to situations where deleting isn't important, however this also makes it more efficient, because it doesn't need extra bookkeeping state to reuse the storage for deleted objects, or to ensure that new objects always have unique keys (eg. slotmap's and generational-arena's versioning).

Another major difference is that this crate protects against using a key from one map to access an element in another. Where SlotMap, Slab, and Arena have a value type parameter, PrimaryMap has a key type parameter and a value type parameter. The crate also provides the entity_impl macro which makes it easy to declare new unique types for use as keys. Any attempt to use a key in a map it's not intended for is diagnosed with a type error.

Another is that this crate has two core map types, PrimaryMap and SecondaryMap, which serve complementary purposes. A PrimaryMap creates its own keys when elements are inserted, while an SecondaryMap reuses the keys values of a PrimaryMap, conceptually storing additional data in the same index space. SecondaryMap's values must implement Default and all elements in an SecondaryMap initially have the value of default().

A common way to implement Default is to wrap a type in Option, however this crate also provides the PackedOption utility which can use less memory in some cases.

Additional utilities provided by this crate include:

  • EntityList, for allocating many small arrays (such as instruction operand lists in a compiler code generator).
  • SparseMap: an alternative to SecondaryMap which can use less memory in some situations.
  • EntitySet: a specialized form of SecondaryMap using a bitvector to record which entities are members of the set.