Bug 1385003 - Autogenerated changes to go with webrender update. r=jrmuizel

This regenerates the cargo lockfiles and FFI bindings header. It also revendors
the third_party/rust libraries.

MozReview-Commit-ID: ID0YhoIH6cz

--HG--
extra : rebase_source : 7c22828a831eafcf527f2c3baf8d4d012db8f9a4
This commit is contained in:
Kartikaya Gupta 2017-08-09 08:46:25 -04:00
Родитель 162dcae649
Коммит bdee759275
22 изменённых файлов: 1965 добавлений и 1022 удалений

Просмотреть файл

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Generated with cbindgen:0.1.19 */
/* Generated with cbindgen:0.1.20 */
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
* To generate this file:
@ -144,9 +144,9 @@ enum class YuvColorSpace : uint32_t {
struct Arc_VecU8;
struct LayerPixel;
struct DocumentHandle;
struct RenderApi;
struct LayerPixel;
struct Renderer;
@ -255,8 +255,10 @@ struct Epoch {
typedef Epoch WrEpoch;
typedef uint32_t PipelineSourceId;
struct PipelineId {
uint32_t mNamespace;
PipelineSourceId mNamespace;
uint32_t mHandle;
bool operator==(const PipelineId& aOther) const {
@ -285,11 +287,13 @@ struct BuiltDisplayListDescriptor {
uint64_t builder_start_time;
uint64_t builder_finish_time;
uint64_t send_start_time;
size_t glyph_offset;
bool operator==(const BuiltDisplayListDescriptor& aOther) const {
return builder_start_time == aOther.builder_start_time &&
builder_finish_time == aOther.builder_finish_time &&
send_start_time == aOther.send_start_time;
send_start_time == aOther.send_start_time &&
glyph_offset == aOther.glyph_offset;
}
};
@ -454,20 +458,6 @@ struct GradientStop {
}
};
struct SideOffsets2D_f32 {
float top;
float right;
float bottom;
float left;
bool operator==(const SideOffsets2D_f32& aOther) const {
return top == aOther.top &&
right == aOther.right &&
bottom == aOther.bottom &&
left == aOther.left;
}
};
struct SideOffsets2D_u32 {
uint32_t top;
uint32_t right;
@ -482,6 +472,20 @@ struct SideOffsets2D_u32 {
}
};
struct SideOffsets2D_f32 {
float top;
float right;
float bottom;
float left;
bool operator==(const SideOffsets2D_f32& aOther) const {
return top == aOther.top &&
right == aOther.right &&
bottom == aOther.bottom &&
left == aOther.left;
}
};
struct NinePatchDescriptor {
uint32_t width;
uint32_t height;
@ -540,8 +544,10 @@ struct WrFilterOp {
}
};
typedef uint32_t GlyphIndex;
struct GlyphInstance {
uint32_t index;
GlyphIndex index;
LayoutPoint point;
bool operator==(const GlyphInstance& aOther) const {
@ -626,14 +632,14 @@ const VecU8 *wr_add_ref_arc(const ArcVecU8 *aArc)
WR_FUNC;
WR_INLINE
void wr_api_add_blob_image(RenderApi *aApi,
void wr_api_add_blob_image(DocumentHandle *aDh,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
ByteSlice aBytes)
WR_FUNC;
WR_INLINE
void wr_api_add_external_image(RenderApi *aApi,
void wr_api_add_external_image(DocumentHandle *aDh,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrExternalImageId aExternalImageId,
@ -642,14 +648,14 @@ void wr_api_add_external_image(RenderApi *aApi,
WR_FUNC;
WR_INLINE
void wr_api_add_image(RenderApi *aApi,
void wr_api_add_image(DocumentHandle *aDh,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
ByteSlice aBytes)
WR_FUNC;
WR_INLINE
void wr_api_add_raw_font(RenderApi *aApi,
void wr_api_add_raw_font(DocumentHandle *aDh,
WrFontKey aKey,
uint8_t *aFontBuffer,
size_t aBufferSize,
@ -657,22 +663,27 @@ void wr_api_add_raw_font(RenderApi *aApi,
WR_FUNC;
WR_INLINE
void wr_api_clear_root_display_list(RenderApi *aApi,
void wr_api_clear_root_display_list(DocumentHandle *aDh,
WrEpoch aEpoch,
WrPipelineId aPipelineId)
WR_FUNC;
WR_INLINE
void wr_api_delete(RenderApi *aApi)
void wr_api_clone(DocumentHandle *aDh,
DocumentHandle **aOutHandle)
WR_FUNC;
WR_INLINE
void wr_api_delete(DocumentHandle *aDh)
WR_DESTRUCTOR_SAFE_FUNC;
WR_INLINE
void wr_api_delete_font(RenderApi *aApi,
void wr_api_delete_font(DocumentHandle *aDh,
WrFontKey aKey)
WR_FUNC;
WR_INLINE
void wr_api_delete_image(RenderApi *aApi,
void wr_api_delete_image(DocumentHandle *aDh,
WrImageKey aKey)
WR_FUNC;
@ -684,11 +695,11 @@ void wr_api_finalize_builder(WrState *aState,
WR_FUNC;
WR_INLINE
void wr_api_generate_frame(RenderApi *aApi)
void wr_api_generate_frame(DocumentHandle *aDh)
WR_FUNC;
WR_INLINE
void wr_api_generate_frame_with_properties(RenderApi *aApi,
void wr_api_generate_frame_with_properties(DocumentHandle *aDh,
const WrOpacityProperty *aOpacityArray,
size_t aOpacityCount,
const WrTransformProperty *aTransformArray,
@ -696,16 +707,16 @@ void wr_api_generate_frame_with_properties(RenderApi *aApi,
WR_FUNC;
WR_INLINE
WrIdNamespace wr_api_get_namespace(RenderApi *aApi)
WrIdNamespace wr_api_get_namespace(DocumentHandle *aDh)
WR_FUNC;
WR_INLINE
void wr_api_send_external_event(RenderApi *aApi,
void wr_api_send_external_event(DocumentHandle *aDh,
size_t aEvt)
WR_DESTRUCTOR_SAFE_FUNC;
WR_INLINE
void wr_api_set_root_display_list(RenderApi *aApi,
void wr_api_set_root_display_list(DocumentHandle *aDh,
ColorF aColor,
WrEpoch aEpoch,
float aViewportWidth,
@ -718,25 +729,25 @@ void wr_api_set_root_display_list(RenderApi *aApi,
WR_FUNC;
WR_INLINE
void wr_api_set_root_pipeline(RenderApi *aApi,
void wr_api_set_root_pipeline(DocumentHandle *aDh,
WrPipelineId aPipelineId)
WR_FUNC;
WR_INLINE
void wr_api_set_window_parameters(RenderApi *aApi,
void wr_api_set_window_parameters(DocumentHandle *aDh,
int32_t aWidth,
int32_t aHeight)
WR_FUNC;
WR_INLINE
void wr_api_update_blob_image(RenderApi *aApi,
void wr_api_update_blob_image(DocumentHandle *aDh,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
ByteSlice aBytes)
WR_FUNC;
WR_INLINE
void wr_api_update_external_image(RenderApi *aApi,
void wr_api_update_external_image(DocumentHandle *aDh,
WrImageKey aKey,
const WrImageDescriptor *aDescriptor,
WrExternalImageId aExternalImageId,
@ -745,7 +756,7 @@ void wr_api_update_external_image(RenderApi *aApi,
WR_FUNC;
WR_INLINE
void wr_api_update_image(RenderApi *aApi,
void wr_api_update_image(DocumentHandle *aDh,
WrImageKey aKey,
const WrImageDescriptor *aDescriptor,
ByteSlice aBytes)
@ -1026,7 +1037,7 @@ void wr_renderer_update(Renderer *aRenderer)
WR_FUNC;
WR_INLINE
void wr_scroll_layer_with_id(RenderApi *aApi,
void wr_scroll_layer_with_id(DocumentHandle *aDh,
WrPipelineId aPipelineId,
uint64_t aScrollId,
LayoutPoint aNewScrollOrigin)
@ -1060,7 +1071,7 @@ bool wr_window_new(WrWindowId aWindowId,
void *aGlContext,
WrThreadPool *aThreadPool,
bool aEnableProfiler,
RenderApi **aOutApi,
DocumentHandle **aOutHandle,
Renderer **aOutRenderer)
WR_FUNC;

Просмотреть файл

@ -1 +1 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"b66e958a27e280a79ae1742be91e02cbaf7392851d430f19b13f3619861860e2","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"7d09decba6c94743746eb13ebd51735356ec6a1125d33da708d3e141148c81c3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","Makefile.in":"7348b5f8a577048279b3f98e2c2b5705f506cf5b4b1e6bb542cc0b1e62468411","README.md":"755e885eb12f7b0b459c8b579f20cd941e55f0197b947591131daf048c5d7bc6","configure":"e0e6ba778e5f5784fa87abf235aa4f3da750d922bfb26a34803d9674577d56ec","etc/bindgen.sh":"116938e8c7a4500e056f719c66bdc896739c8b0a34a16e6a29a9e335f7458648","etc/bindings.h":"f6110c7a692e24f9c6d1c4a78ba8a7750952b397b86a5ac466353c7c57cfb7bb","src/freetype.rs":"0e27e13cca4f79569718fa4c247b8f7020388d8a84ad5f971c376a0658073cfa","src/lib.rs":"812e79af46e33a93420c8301ad95392f5e8a57266b3e43c47085c6dd0c63653f","src/tt_os2.rs":"9517c53fc4e575ceb615d554dc72812dcbb532bf94883d51202b24caae1a1418"},"package":"fde23272c687e4570aefec06cb71174ec0f5284b725deac4e77ba2665d635faf"}
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"b66e958a27e280a79ae1742be91e02cbaf7392851d430f19b13f3619861860e2","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"ec1a0a3ceb37de795193e244fb3781cf87d25ea610f150976958468881da76a7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","Makefile.in":"7348b5f8a577048279b3f98e2c2b5705f506cf5b4b1e6bb542cc0b1e62468411","README.md":"755e885eb12f7b0b459c8b579f20cd941e55f0197b947591131daf048c5d7bc6","configure":"e0e6ba778e5f5784fa87abf235aa4f3da750d922bfb26a34803d9674577d56ec","etc/bindgen.sh":"39c1d5298f6e46380f0616d6080bd2c3ead5f04149bcf5b7345c56dae2000e79","etc/bindings.h":"b531980f5739536dfc1484236d436efd18f448b4ea15001d1dfbbaf381ad054f","src/freetype.rs":"445a3d48974dcf22961b612ef6cdef48c2dedc1ccc6e73a88eee53fa601859d8","src/lib.rs":"812e79af46e33a93420c8301ad95392f5e8a57266b3e43c47085c6dd0c63653f","src/tt_os2.rs":"9517c53fc4e575ceb615d554dc72812dcbb532bf94883d51202b24caae1a1418"},"package":"398b8a11884898184d55aca9806f002b3cf68f0e860e0cbb4586f834ee39b0e7"}

40
third_party/rust/freetype/Cargo.toml поставляемый
Просмотреть файл

@ -1,19 +1,33 @@
[package]
description = "Bindings for Freetype used by Servo"
license = "Apache-2.0 / MIT"
name = "freetype"
version = "0.2.0"
authors = ["The Servo Project Developers"]
documentation = "http://doc.servo.org/freetype/"
repository = "https://github.com/servo/rust-freetype"
# 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 believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[features]
default = ["servo-freetype-sys"]
[package]
name = "freetype"
version = "0.3.0"
authors = ["The Servo Project Developers"]
description = "Bindings for Freetype used by Servo"
documentation = "http://doc.servo.org/freetype/"
license = "Apache-2.0 / MIT"
repository = "https://github.com/servo/rust-freetype"
[lib]
name = "freetype"
crate-type = ["rlib"]
[dependencies.servo-freetype-sys]
version = "4.0.2"
optional = true
[dependencies]
servo-freetype-sys = { version = "4.0.2", optional = true }
libc = "0.2"
[dependencies.libc]
version = "0.2"
[features]
default = ["servo-freetype-sys"]

1
third_party/rust/freetype/etc/bindgen.sh поставляемый
Просмотреть файл

@ -7,7 +7,6 @@ cd "$(dirname $0)"
# We blacklist FT_Error and import our own in order to have convenience methods
# on it instead of being a plain integer.
"${BINDGEN}" bindings.h -o ../src/freetype.rs \
--no-unstable-rust \
--blacklist-type "FT_(Int16|UInt16|Int32|UInt32|Int16|Int64|UInt64)" \
--raw-line "pub type FT_Int16 = i16;" \
--raw-line "pub type FT_UInt16 = u16;" \

1
third_party/rust/freetype/etc/bindings.h поставляемый
Просмотреть файл

@ -3,3 +3,4 @@
#include <freetype2/freetype/ftlcdfil.h>
#include <freetype2/freetype/tttables.h>
#include <freetype2/freetype/ftmodapi.h>
#include <freetype2/freetype/ftoutln.h>

1698
third_party/rust/freetype/src/freetype.rs поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1
third_party/rust/fxhash/.cargo-checksum.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"83bb4c3e7fbfb7380c175923ba7dfe150e4e09bd4ebfb45e65e5f8a494d36ab9","README.md":"7b9227f966b312e221bd372fef79438b2446a21241eb7542520eac29bfbc10d0","bench.rs":"b4dc3ef9eeb043ffb470b37a0c2a36306a024af808eac8517924359298d3e183","lib.rs":"885b72a1c977dc1c3ff4e0652719e62b6d8c3e713403e571afd581283f72df7b"},"package":"c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"}

Просмотреть файл

38
third_party/rust/fxhash/Cargo.toml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,38 @@
# 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 believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
name = "fxhash"
version = "0.2.1"
authors = ["cbreeden <github@u.breeden.cc>"]
description = "A fast, non-secure, hashing algorithm derived from an internal hasher used in FireFox and Rustc."
documentation = "https://docs.rs/fxhash"
readme = "README.md"
keywords = ["hash"]
categories = ["algorithms"]
license = "Apache-2.0/MIT"
repository = "https://github.com/cbreeden/fxhash"
[lib]
name = "fxhash"
path = "lib.rs"
[[bench]]
name = "fxhash"
path = "bench.rs"
[dependencies.byteorder]
version = "1.0.0"
[dev-dependencies.seahash]
version = "3.0.5"
[dev-dependencies.fnv]
version = "1.0.5"

62
third_party/rust/fxhash/README.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,62 @@
# Fx Hash
This hashing algorithm was extracted from the Rustc compiler. This is the same hashing algoirthm used for some internal operations in FireFox. The strength of this algorithm is in hashing 8 bytes at a time on 64-bit platforms, where the FNV algorithm works on one byte at a time.
## Disclaimer
It is **not a cryptographically secure** hash, so it is strongly recommended that you do not use this hash for cryptographic purproses. Furthermore, this hashing algorithm was not designed to prevent any attacks for determining collisions which could be used to potentially cause quadratic behavior in `HashMap`s. So it is not recommended to expose this hash in places where collissions or DDOS attacks may be a concern.
## Examples
Building an Fx backed hashmap.
```rust
extern crate fxhash;
use fxhash::FxHashMap;
let mut hashmap = FxHashMap::new();
hashmap.insert("black", 0);
hashmap.insert("white", 255);
```
Building an Fx backed hashset.
```rust
extern crate fxhash;
use fxhash::FxHashSet;
let mut hashmap = FxHashSet::new();
hashmap.insert("black");
hashmap.insert("white");
```
## Benchmarks
Generally `fxhash` is than `fnv` on `u32`, `u64`, or any byte sequence with length >= 5. However, keep in mind that hashing speed is not the only characteristic worth considering. That being said, Rustc had an observable increase in speed when switching from `fnv` backed hashmaps to `fx` based hashmaps.
bench_fnv_003 ... bench: 3 ns/iter (+/- 0)
bench_fnv_004 ... bench: 2 ns/iter (+/- 0)
bench_fnv_011 ... bench: 6 ns/iter (+/- 1)
bench_fnv_012 ... bench: 5 ns/iter (+/- 1)
bench_fnv_023 ... bench: 14 ns/iter (+/- 3)
bench_fnv_024 ... bench: 14 ns/iter (+/- 4)
bench_fnv_068 ... bench: 57 ns/iter (+/- 11)
bench_fnv_132 ... bench: 145 ns/iter (+/- 30)
bench_fx_003 ... bench: 4 ns/iter (+/- 0)
bench_fx_004 ... bench: 3 ns/iter (+/- 1)
bench_fx_011 ... bench: 5 ns/iter (+/- 2)
bench_fx_012 ... bench: 4 ns/iter (+/- 1)
bench_fx_023 ... bench: 7 ns/iter (+/- 3)
bench_fx_024 ... bench: 4 ns/iter (+/- 1)
bench_fx_068 ... bench: 10 ns/iter (+/- 3)
bench_fx_132 ... bench: 19 ns/iter (+/- 5)
bench_seahash_003 ... bench: 30 ns/iter (+/- 12)
bench_seahash_004 ... bench: 32 ns/iter (+/- 22)
bench_seahash_011 ... bench: 30 ns/iter (+/- 4)
bench_seahash_012 ... bench: 31 ns/iter (+/- 1)
bench_seahash_023 ... bench: 32 ns/iter (+/- 6)
bench_seahash_024 ... bench: 31 ns/iter (+/- 5)
bench_seahash_068 ... bench: 40 ns/iter (+/- 9)
bench_seahash_132 ... bench: 50 ns/iter (+/- 12)

78
third_party/rust/fxhash/bench.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,78 @@
#![feature(test)]
extern crate test;
extern crate fnv;
extern crate fxhash;
extern crate seahash;
use std::hash::{Hash, Hasher};
use test::{Bencher, black_box};
fn fnvhash<H: Hash>(b: H) -> u64 {
let mut hasher = fnv::FnvHasher::default();
b.hash(&mut hasher);
hasher.finish()
}
fn seahash<H: Hash>(b: H) -> u64 {
let mut hasher = seahash::SeaHasher::default();
b.hash(&mut hasher);
hasher.finish()
}
macro_rules! generate_benches {
($($fx:ident, $fx32:ident, $fx64:ident, $fnv:ident, $sea:ident, $s:expr),* $(,)*) => (
$(
#[bench]
fn $fx(b: &mut Bencher) {
let s = black_box($s);
b.iter(|| {
fxhash::hash(&s)
})
}
#[bench]
fn $fx32(b: &mut Bencher) {
let s = black_box($s);
b.iter(|| {
fxhash::hash32(&s)
})
}
#[bench]
fn $fx64(b: &mut Bencher) {
let s = black_box($s);
b.iter(|| {
fxhash::hash64(&s)
})
}
#[bench]
fn $fnv(b: &mut Bencher) {
let s = black_box($s);
b.iter(|| {
fnvhash(&s)
})
}
#[bench]
fn $sea(b: &mut Bencher) {
let s = black_box($s);
b.iter(|| {
seahash(&s)
})
}
)*
)
}
generate_benches!(
bench_fx_003, bench_fx32_003, bench_fx64_003, bench_fnv_003, bench_seahash_003, "123",
bench_fx_004, bench_fx32_004, bench_fx64_004, bench_fnv_004, bench_seahash_004, "1234",
bench_fx_011, bench_fx32_011, bench_fx64_011, bench_fnv_011, bench_seahash_011, "12345678901",
bench_fx_012, bench_fx32_012, bench_fx64_012, bench_fnv_012, bench_seahash_012, "123456789012",
bench_fx_023, bench_fx32_023, bench_fx64_023, bench_fnv_023, bench_seahash_023, "12345678901234567890123",
bench_fx_024, bench_fx32_024, bench_fx64_024, bench_fnv_024, bench_seahash_024, "123456789012345678901234",
bench_fx_068, bench_fx32_068, bench_fx64_068, bench_fnv_068, bench_seahash_068, "11234567890123456789012345678901234567890123456789012345678901234567",
bench_fx_132, bench_fx32_132, bench_fx64_132, bench_fnv_132, bench_seahash_132, "112345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901",
);

324
third_party/rust/fxhash/lib.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,324 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(missing_docs)]
//! # Fx Hash
//!
//! This hashing algorithm was extracted from the Rustc compiler. This is the same hashing
//! algoirthm used for some internal operations in FireFox. The strength of this algorithm
//! is in hashing 8 bytes at a time on 64-bit platforms, where the FNV algorithm works on one
//! byte at a time.
//!
//! ## Disclaimer
//!
//! It is **not a cryptographically secure** hash, so it is strongly recommended that you do
//! not use this hash for cryptographic purproses. Furthermore, this hashing algorithm was
//! not designed to prevent any attacks for determining collisions which could be used to
//! potentially cause quadratic behavior in `HashMap`s. So it is not recommended to expose
//! this hash in places where collissions or DDOS attacks may be a concern.
use std::collections::{HashMap, HashSet};
use std::default::Default;
use std::hash::{Hasher, Hash, BuildHasherDefault};
use std::ops::BitXor;
extern crate byteorder;
use byteorder::{ByteOrder, NativeEndian};
/// A builder for default Fx hashers.
pub type FxBuildHasher = BuildHasherDefault<FxHasher>;
/// A `HashMap` using a default Fx hasher.
pub type FxHashMap<K, V> = HashMap<K, V, FxBuildHasher>;
/// A `HashSet` using a default Fx hasher.
pub type FxHashSet<V> = HashSet<V, FxBuildHasher>;
const ROTATE: u32 = 5;
const SEED64: u64 = 0x517cc1b727220a95;
const SEED32: u32 = (SEED64 & 0xFFFF_FFFF) as u32;
#[cfg(target_pointer_width = "32")]
const SEED: usize = SEED32 as usize;
#[cfg(target_pointer_width = "64")]
const SEED: usize = SEED64 as usize;
trait HashWord {
fn hash_word(&mut self, Self);
}
macro_rules! impl_hash_word {
($($ty:ty = $key:ident),* $(,)*) => (
$(
impl HashWord for $ty {
#[inline]
fn hash_word(&mut self, word: Self) {
*self = self.rotate_left(ROTATE).bitxor(word).wrapping_mul($key);
}
}
)*
)
}
impl_hash_word!(usize = SEED, u32 = SEED32, u64 = SEED64);
#[inline]
fn write32(mut hash: u32, mut bytes: &[u8]) -> u32 {
while bytes.len() >= 4 {
let n = NativeEndian::read_u32(bytes);
hash.hash_word(n);
bytes = bytes.split_at(4).1;
}
for byte in bytes {
hash.hash_word(*byte as u32);
}
hash
}
#[inline]
fn write64(mut hash: u64, mut bytes: &[u8]) -> u64 {
while bytes.len() >= 8 {
let n = NativeEndian::read_u64(bytes);
hash.hash_word(n);
bytes = bytes.split_at(8).1;
}
if bytes.len() >= 4 {
let n = NativeEndian::read_u32(bytes);
hash.hash_word(n as u64);
bytes = bytes.split_at(4).1;
}
for byte in bytes {
hash.hash_word(*byte as u64);
}
hash
}
#[inline]
#[cfg(target_pointer_width = "32")]
fn write(hash: usize, bytes: &[u8]) -> usize {
write32(hash as u32, bytes) as usize
}
#[inline]
#[cfg(target_pointer_width = "64")]
fn write(hash: usize, bytes: &[u8]) -> usize {
write64(hash as u64, bytes) as usize
}
/// This hashing algorithm was extracted from the Rustc compiler.
/// This is the same hashing algoirthm used for some internal operations in FireFox.
/// The strength of this algorithm is in hashing 8 bytes at a time on 64-bit platforms,
/// where the FNV algorithm works on one byte at a time.
///
/// This hashing algorithm should not be used for cryptographic, or in scenarios where
/// DOS attacks are a concern.
#[derive(Debug, Clone)]
pub struct FxHasher {
hash: usize,
}
impl Default for FxHasher {
#[inline]
fn default() -> FxHasher {
FxHasher { hash: 0 }
}
}
impl Hasher for FxHasher {
#[inline]
fn write(&mut self, bytes: &[u8]) {
self.hash = write(self.hash, bytes);
}
#[inline]
fn write_u8(&mut self, i: u8) {
self.hash.hash_word(i as usize);
}
#[inline]
fn write_u16(&mut self, i: u16) {
self.hash.hash_word(i as usize);
}
#[inline]
fn write_u32(&mut self, i: u32) {
self.hash.hash_word(i as usize);
}
#[inline]
#[cfg(target_pointer_width = "32")]
fn write_u64(&mut self, i: u64) {
self.hash.hash_word(i as usize);
self.hash.hash_word((i >> 32) as usize);
}
#[inline]
#[cfg(target_pointer_width = "64")]
fn write_u64(&mut self, i: u64) {
self.hash.hash_word(i as usize);
}
#[inline]
fn write_usize(&mut self, i: usize) {
self.hash.hash_word(i);
}
#[inline]
fn finish(&self) -> u64 {
self.hash as u64
}
}
/// This hashing algorithm was extracted from the Rustc compiler.
/// This is the same hashing algoirthm used for some internal operations in FireFox.
/// The strength of this algorithm is in hashing 8 bytes at a time on any platform,
/// where the FNV algorithm works on one byte at a time.
///
/// This hashing algorithm should not be used for cryptographic, or in scenarios where
/// DOS attacks are a concern.
#[derive(Debug, Clone)]
pub struct FxHasher64 {
hash: u64,
}
impl Default for FxHasher64 {
#[inline]
fn default() -> FxHasher64 {
FxHasher64 { hash: 0 }
}
}
impl Hasher for FxHasher64 {
#[inline]
fn write(&mut self, bytes: &[u8]) {
self.hash = write64(self.hash, bytes);
}
#[inline]
fn write_u8(&mut self, i: u8) {
self.hash.hash_word(i as u64);
}
#[inline]
fn write_u16(&mut self, i: u16) {
self.hash.hash_word(i as u64);
}
#[inline]
fn write_u32(&mut self, i: u32) {
self.hash.hash_word(i as u64);
}
fn write_u64(&mut self, i: u64) {
self.hash.hash_word(i);
}
#[inline]
fn write_usize(&mut self, i: usize) {
self.hash.hash_word(i as u64);
}
#[inline]
fn finish(&self) -> u64 {
self.hash
}
}
/// This hashing algorithm was extracted from the Rustc compiler.
/// This is the same hashing algoirthm used for some internal operations in FireFox.
/// The strength of this algorithm is in hashing 4 bytes at a time on any platform,
/// where the FNV algorithm works on one byte at a time.
///
/// This hashing algorithm should not be used for cryptographic, or in scenarios where
/// DOS attacks are a concern.
#[derive(Debug, Clone)]
pub struct FxHasher32 {
hash: u32,
}
impl Default for FxHasher32 {
#[inline]
fn default() -> FxHasher32 {
FxHasher32 { hash: 0 }
}
}
impl Hasher for FxHasher32 {
#[inline]
fn write(&mut self, bytes: &[u8]) {
self.hash = write32(self.hash, bytes);
}
#[inline]
fn write_u8(&mut self, i: u8) {
self.hash.hash_word(i as u32);
}
#[inline]
fn write_u16(&mut self, i: u16) {
self.hash.hash_word(i as u32);
}
#[inline]
fn write_u32(&mut self, i: u32) {
self.hash.hash_word(i);
}
#[inline]
fn write_u64(&mut self, i: u64) {
self.hash.hash_word(i as u32);
self.hash.hash_word((i >> 32) as u32);
}
#[inline]
#[cfg(target_pointer_width = "32")]
fn write_usize(&mut self, i: usize) {
self.write_u32(i as u32);
}
#[inline]
#[cfg(target_pointer_width = "64")]
fn write_usize(&mut self, i: usize) {
self.write_u64(i as u64);
}
#[inline]
fn finish(&self) -> u64 {
self.hash as u64
}
}
/// A convenience function for when you need a quick 64-bit hash.
#[inline]
pub fn hash64<T: Hash + ?Sized>(v: &T) -> u64 {
let mut state = FxHasher64::default();
v.hash(&mut state);
state.finish()
}
/// A convenience function for when you need a quick 32-bit hash.
#[inline]
pub fn hash32<T: Hash + ?Sized>(v: &T) -> u32 {
let mut state = FxHasher32::default();
v.hash(&mut state);
state.finish() as u32
}
/// A convenience function for when you need a quick usize hash.
#[inline]
pub fn hash<T: Hash + ?Sized>(v: &T) -> usize {
let mut state = FxHasher::default();
v.hash(&mut state);
state.finish() as usize
}

Просмотреть файл

@ -1 +0,0 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"1108708721703f4562646e1e7c6f6c924fa997835714bcc6a3ff8a58382134f1","Cargo.toml":"723e5918946fdb518ed1ad3e03ae9104b980cbe85bbee1989dc4197570ba6d73","README.md":"9a38b16bccde5db28c34d79134f02d2cdcbbab224b9a68ace93c5b85b5ef38f2","appveyor.yml":"130e820ab60abf8d08f3a91d4b0158e6a581c180385e12850113adb362eb158c","build.rs":"e13e88ed285a829256d3c6987563a663c37e335457d090125a3e19b1a97fec8e","src/lib.rs":"ab4e0a2e6d0ac700df5dbb7a2c83542cb82c94d4e46c632a4114fec93d6aba0a","tests/tests.rs":"f642da7b54b6cde55cf25fe84b2e6b27356d26b351d42a38e944b93e0c1fa24f"},"package":"5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88"}

19
third_party/rust/heapsize-0.3.8/.travis.yml поставляемый
Просмотреть файл

@ -1,19 +0,0 @@
language: rust
rust:
- 1.8.0
- nightly
- beta
- stable
os:
- linux
- osx
notifications:
webhooks: http://build.servo.org:54856/travis
script:
- cargo test
- "[ $TRAVIS_RUST_VERSION != nightly ] || cargo test --features unstable"
- "[ $TRAVIS_RUST_VERSION != nightly ] || cargo test --manifest-path derive/Cargo.toml"

14
third_party/rust/heapsize-0.3.8/Cargo.toml поставляемый
Просмотреть файл

@ -1,14 +0,0 @@
[package]
name = "heapsize"
version = "0.3.8"
authors = [ "The Servo Project Developers" ]
description = "Infrastructure for measuring the total runtime size of an object on the heap"
license = "MPL-2.0"
repository = "https://github.com/servo/heapsize"
build = "build.rs"
[target.'cfg(windows)'.dependencies]
kernel32-sys = "0.2.1"
[features]
unstable = []

5
third_party/rust/heapsize-0.3.8/README.md поставляемый
Просмотреть файл

@ -1,5 +0,0 @@
# heapsize
In support of measuring heap allocations in Rust programs.
[API Documentation](https://doc.servo.org/heapsize/)

23
third_party/rust/heapsize-0.3.8/appveyor.yml поставляемый
Просмотреть файл

@ -1,23 +0,0 @@
environment:
matrix:
- FEATURES: ""
- FEATURES: "unstable"
platform:
- i686-pc-windows-gnu
- i686-pc-windows-msvc
- x86_64-pc-windows-gnu
- x86_64-pc-windows-msvc
install:
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:PLATFORM}.exe"
- rust-nightly-%PLATFORM%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
- rustc -V
- cargo -V
build_script:
- cargo build --verbose --features "%FEATURES%"
test_script:
- cargo test --verbose --features "%FEATURES%"

37
third_party/rust/heapsize-0.3.8/build.rs поставляемый
Просмотреть файл

@ -1,37 +0,0 @@
use std::env::var;
use std::process::Command;
use std::str;
fn main() {
let verbose = Command::new(var("RUSTC").unwrap_or("rustc".into()))
.arg("--version")
.arg("--verbose")
.output()
.unwrap()
.stdout;
let verbose = str::from_utf8(&verbose).unwrap();
let mut commit_date = None;
let mut release = None;
for line in verbose.lines() {
let mut parts = line.split(':');
match parts.next().unwrap().trim() {
"commit-date" => commit_date = Some(parts.next().unwrap().trim()),
"release" => release = Some(parts.next().unwrap().trim()),
_ => {}
}
}
let version = release.unwrap().split('-').next().unwrap();;
let mut version_components = version.split('.').map(|s| s.parse::<u32>().unwrap());
let version = (
version_components.next().unwrap(),
version_components.next().unwrap(),
version_components.next().unwrap(),
// "unknown" sorts after "2016-02-14", which is what we want to defaut to unprefixed
// https://github.com/servo/heapsize/pull/44#issuecomment-187935883
commit_date.unwrap()
);
assert_eq!(version_components.next(), None);
if version < (1, 8, 0, "2016-02-14") {
println!("cargo:rustc-cfg=prefixed_jemalloc");
}
}

323
third_party/rust/heapsize-0.3.8/src/lib.rs поставляемый
Просмотреть файл

@ -1,323 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Data structure measurement.
#[cfg(target_os = "windows")]
extern crate kernel32;
#[cfg(target_os = "windows")]
use kernel32::{GetProcessHeap, HeapSize, HeapValidate};
use std::borrow::Cow;
use std::cell::{Cell, RefCell};
use std::collections::{BTreeMap, HashSet, HashMap, LinkedList, VecDeque};
use std::hash::BuildHasher;
use std::hash::Hash;
use std::marker::PhantomData;
use std::mem::size_of;
use std::net::{Ipv4Addr, Ipv6Addr};
use std::os::raw::c_void;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize};
use std::rc::Rc;
/// Get the size of a heap block.
///
/// Ideally Rust would expose a function like this in std::rt::heap.
///
/// `unsafe` because the caller must ensure that the pointer is from jemalloc.
/// FIXME: This probably interacts badly with custom allocators:
/// https://doc.rust-lang.org/book/custom-allocators.html
pub unsafe fn heap_size_of(ptr: *const c_void) -> usize {
if ptr == 0x01 as *const c_void {
0
} else {
heap_size_of_impl(ptr)
}
}
#[cfg(not(target_os = "windows"))]
unsafe fn heap_size_of_impl(ptr: *const c_void) -> usize {
// The C prototype is `je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr)`. On some
// platforms `JEMALLOC_USABLE_SIZE_CONST` is `const` and on some it is empty. But in practice
// this function doesn't modify the contents of the block that `ptr` points to, so we use
// `*const c_void` here.
extern "C" {
#[cfg_attr(any(prefixed_jemalloc, target_os = "macos", target_os = "android"), link_name = "je_malloc_usable_size")]
fn malloc_usable_size(ptr: *const c_void) -> usize;
}
malloc_usable_size(ptr)
}
#[cfg(target_os = "windows")]
pub unsafe fn heap_size_of_impl(mut ptr: *const c_void) -> usize {
let heap = GetProcessHeap();
if HeapValidate(heap, 0, ptr) == 0 {
ptr = *(ptr as *const *const c_void).offset(-1);
}
HeapSize(heap, 0, ptr) as usize
}
// The simplest trait for measuring the size of heap data structures. More complex traits that
// return multiple measurements -- e.g. measure text separately from images -- are also possible,
// and should be used when appropriate.
//
pub trait HeapSizeOf {
/// Measure the size of any heap-allocated structures that hang off this value, but not the
/// space taken up by the value itself (i.e. what size_of::<T> measures, more or less); that
/// space is handled by the implementation of HeapSizeOf for Box<T> below.
fn heap_size_of_children(&self) -> usize;
}
// There are two possible ways to measure the size of `self` when it's on the heap: compute it
// (with `::std::rt::heap::usable_size(::std::mem::size_of::<T>(), 0)`) or measure it directly
// using the heap allocator (with `heap_size_of`). We do the latter, for the following reasons.
//
// * The heap allocator is the true authority for the sizes of heap blocks; its measurement is
// guaranteed to be correct. In comparison, size computations are error-prone. (For example, the
// `rt::heap::usable_size` function used in some of Rust's non-default allocator implementations
// underestimate the true usable size of heap blocks, which is safe in general but would cause
// under-measurement here.)
//
// * If we measure something that isn't a heap block, we'll get a crash. This keeps us honest,
// which is important because unsafe code is involved and this can be gotten wrong.
//
// However, in the best case, the two approaches should give the same results.
//
impl<T: HeapSizeOf + ?Sized> HeapSizeOf for Box<T> {
fn heap_size_of_children(&self) -> usize {
// Measure size of `self`.
unsafe {
heap_size_of(&**self as *const T as *const c_void) + (**self).heap_size_of_children()
}
}
}
impl<T: HeapSizeOf> HeapSizeOf for [T] {
fn heap_size_of_children(&self) -> usize {
self.iter().fold(0, |size, item| size + item.heap_size_of_children())
}
}
impl HeapSizeOf for String {
fn heap_size_of_children(&self) -> usize {
unsafe {
heap_size_of(self.as_ptr() as *const c_void)
}
}
}
impl<'a, T: ?Sized> HeapSizeOf for &'a T {
fn heap_size_of_children(&self) -> usize {
0
}
}
impl<T: HeapSizeOf> HeapSizeOf for Option<T> {
fn heap_size_of_children(&self) -> usize {
match *self {
None => 0,
Some(ref x) => x.heap_size_of_children()
}
}
}
impl<T: HeapSizeOf, E: HeapSizeOf> HeapSizeOf for Result<T, E> {
fn heap_size_of_children(&self) -> usize {
match *self {
Ok(ref x) => x.heap_size_of_children(),
Err(ref e) => e.heap_size_of_children(),
}
}
}
impl<'a, B: ?Sized + ToOwned> HeapSizeOf for Cow<'a, B> where B::Owned: HeapSizeOf {
fn heap_size_of_children(&self) -> usize {
match *self {
Cow::Borrowed(_) => 0,
Cow::Owned(ref b) => b.heap_size_of_children(),
}
}
}
impl HeapSizeOf for () {
fn heap_size_of_children(&self) -> usize {
0
}
}
impl<T1, T2> HeapSizeOf for (T1, T2)
where T1: HeapSizeOf, T2 :HeapSizeOf
{
fn heap_size_of_children(&self) -> usize {
self.0.heap_size_of_children() +
self.1.heap_size_of_children()
}
}
impl<T1, T2, T3> HeapSizeOf for (T1, T2, T3)
where T1: HeapSizeOf, T2 :HeapSizeOf, T3: HeapSizeOf
{
fn heap_size_of_children(&self) -> usize {
self.0.heap_size_of_children() +
self.1.heap_size_of_children() +
self.2.heap_size_of_children()
}
}
impl<T1, T2, T3, T4> HeapSizeOf for (T1, T2, T3, T4)
where T1: HeapSizeOf, T2 :HeapSizeOf, T3: HeapSizeOf, T4: HeapSizeOf
{
fn heap_size_of_children(&self) -> usize {
self.0.heap_size_of_children() +
self.1.heap_size_of_children() +
self.2.heap_size_of_children() +
self.3.heap_size_of_children()
}
}
impl<T1, T2, T3, T4, T5> HeapSizeOf for (T1, T2, T3, T4, T5)
where T1: HeapSizeOf, T2 :HeapSizeOf, T3: HeapSizeOf, T4: HeapSizeOf, T5: HeapSizeOf
{
fn heap_size_of_children(&self) -> usize {
self.0.heap_size_of_children() +
self.1.heap_size_of_children() +
self.2.heap_size_of_children() +
self.3.heap_size_of_children() +
self.4.heap_size_of_children()
}
}
impl<T: HeapSizeOf> HeapSizeOf for Arc<T> {
fn heap_size_of_children(&self) -> usize {
(**self).heap_size_of_children()
}
}
impl<T: HeapSizeOf> HeapSizeOf for RefCell<T> {
fn heap_size_of_children(&self) -> usize {
self.borrow().heap_size_of_children()
}
}
impl<T: HeapSizeOf + Copy> HeapSizeOf for Cell<T> {
fn heap_size_of_children(&self) -> usize {
self.get().heap_size_of_children()
}
}
impl<T: HeapSizeOf> HeapSizeOf for Vec<T> {
fn heap_size_of_children(&self) -> usize {
self.iter().fold(
unsafe { heap_size_of(self.as_ptr() as *const c_void) },
|n, elem| n + elem.heap_size_of_children())
}
}
impl<T: HeapSizeOf> HeapSizeOf for VecDeque<T> {
fn heap_size_of_children(&self) -> usize {
self.iter().fold(
// FIXME: get the buffer pointer for heap_size_of(), capacity() is a lower bound:
self.capacity() * size_of::<T>(),
|n, elem| n + elem.heap_size_of_children())
}
}
impl<T> HeapSizeOf for Vec<Rc<T>> {
fn heap_size_of_children(&self) -> usize {
// The fate of measuring Rc<T> is still undecided, but we still want to measure
// the space used for storing them.
unsafe {
heap_size_of(self.as_ptr() as *const c_void)
}
}
}
impl<T: HeapSizeOf, S> HeapSizeOf for HashSet<T, S>
where T: Eq + Hash, S: BuildHasher {
fn heap_size_of_children(&self) -> usize {
//TODO(#6908) measure actual bucket memory usage instead of approximating
let size = self.capacity() * (size_of::<T>() + size_of::<usize>());
self.iter().fold(size, |n, value| {
n + value.heap_size_of_children()
})
}
}
impl<K: HeapSizeOf, V: HeapSizeOf, S> HeapSizeOf for HashMap<K, V, S>
where K: Eq + Hash, S: BuildHasher {
fn heap_size_of_children(&self) -> usize {
//TODO(#6908) measure actual bucket memory usage instead of approximating
let size = self.capacity() * (size_of::<V>() + size_of::<K>() + size_of::<usize>());
self.iter().fold(size, |n, (key, value)| {
n + key.heap_size_of_children() + value.heap_size_of_children()
})
}
}
// PhantomData is always 0.
impl<T> HeapSizeOf for PhantomData<T> {
fn heap_size_of_children(&self) -> usize {
0
}
}
// A linked list has an overhead of two words per item.
impl<T: HeapSizeOf> HeapSizeOf for LinkedList<T> {
fn heap_size_of_children(&self) -> usize {
let mut size = 0;
for item in self {
size += 2 * size_of::<usize>() + size_of::<T>() + item.heap_size_of_children();
}
size
}
}
// FIXME: Overhead for the BTreeMap nodes is not accounted for.
impl<K: HeapSizeOf, V: HeapSizeOf> HeapSizeOf for BTreeMap<K, V> {
fn heap_size_of_children(&self) -> usize {
let mut size = 0;
for (key, value) in self.iter() {
size += size_of::<(K, V)>() +
key.heap_size_of_children() +
value.heap_size_of_children();
}
size
}
}
/// For use on types defined in external crates
/// with known heap sizes.
#[macro_export]
macro_rules! known_heap_size(
($size:expr, $($ty:ty),+) => (
$(
impl $crate::HeapSizeOf for $ty {
#[inline(always)]
fn heap_size_of_children(&self) -> usize {
$size
}
}
)+
);
($size: expr, $($ty:ident<$($gen:ident),+>),+) => (
$(
impl<$($gen: $crate::HeapSizeOf),+> $crate::HeapSizeOf for $ty<$($gen),+> {
#[inline(always)]
fn heap_size_of_children(&self) -> usize {
$size
}
}
)+
);
);
known_heap_size!(0, char, str);
known_heap_size!(0, u8, u16, u32, u64, usize);
known_heap_size!(0, i8, i16, i32, i64, isize);
known_heap_size!(0, bool, f32, f64);
known_heap_size!(0, AtomicBool, AtomicIsize, AtomicUsize);
known_heap_size!(0, Ipv4Addr, Ipv6Addr);

171
third_party/rust/heapsize-0.3.8/tests/tests.rs поставляемый
Просмотреть файл

@ -1,171 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![cfg_attr(feature= "unstable", feature(alloc, heap_api, repr_simd))]
extern crate heapsize;
use heapsize::{HeapSizeOf, heap_size_of};
use std::os::raw::c_void;
pub const EMPTY: *mut () = 0x1 as *mut ();
#[cfg(feature = "unstable")]
mod unstable {
extern crate alloc;
use heapsize::{HeapSizeOf, heap_size_of};
use std::os::raw::c_void;
#[repr(C, simd)]
struct OverAligned(u64, u64, u64, u64);
#[test]
fn check_empty() {
assert_eq!(::EMPTY, alloc::heap::EMPTY);
}
#[cfg(not(target_os = "windows"))]
#[test]
fn test_alloc() {
unsafe {
// A 64 byte request is allocated exactly.
let x = alloc::heap::allocate(64, 0);
assert_eq!(heap_size_of(x as *const c_void), 64);
alloc::heap::deallocate(x, 64, 0);
// A 255 byte request is rounded up to 256 bytes.
let x = alloc::heap::allocate(255, 0);
assert_eq!(heap_size_of(x as *const c_void), 256);
alloc::heap::deallocate(x, 255, 0);
// A 1MiB request is allocated exactly.
let x = alloc::heap::allocate(1024 * 1024, 0);
assert_eq!(heap_size_of(x as *const c_void), 1024 * 1024);
alloc::heap::deallocate(x, 1024 * 1024, 0);
// An overaligned 1MiB request is allocated exactly.
let x = alloc::heap::allocate(1024 * 1024, 32);
assert_eq!(heap_size_of(x as *const c_void), 1024 * 1024);
alloc::heap::deallocate(x, 1024 * 1024, 32);
}
}
#[cfg(target_os = "windows")]
#[test]
fn test_alloc() {
unsafe {
// A 64 byte request is allocated exactly.
let x = alloc::heap::allocate(64, 0);
assert_eq!(heap_size_of(x as *const c_void), 64);
alloc::heap::deallocate(x, 64, 0);
// A 255 byte request is allocated exactly.
let x = alloc::heap::allocate(255, 0);
assert_eq!(heap_size_of(x as *const c_void), 255);
alloc::heap::deallocate(x, 255, 0);
// A 1MiB request is allocated exactly.
let x = alloc::heap::allocate(1024 * 1024, 0);
assert_eq!(heap_size_of(x as *const c_void), 1024 * 1024);
alloc::heap::deallocate(x, 1024 * 1024, 0);
// An overaligned 1MiB request is over-allocated.
let x = alloc::heap::allocate(1024 * 1024, 32);
assert_eq!(heap_size_of(x as *const c_void), 1024 * 1024 + 32);
alloc::heap::deallocate(x, 1024 * 1024, 32);
}
}
#[cfg(not(target_os = "windows"))]
#[test]
fn test_simd() {
let x = Box::new(OverAligned(0, 0, 0, 0));
assert_eq!(unsafe { heap_size_of(&*x as *const _ as *const c_void) }, 32);
}
#[cfg(target_os = "windows")]
#[test]
fn test_simd() {
let x = Box::new(OverAligned(0, 0, 0, 0));
assert_eq!(unsafe { heap_size_of(&*x as *const _ as *const c_void) }, 32 + 32);
}
#[test]
fn test_boxed_str() {
let x = "raclette".to_owned().into_boxed_str();
assert_eq!(x.heap_size_of_children(), 8);
}
}
#[test]
fn test_heap_size() {
// Note: jemalloc often rounds up request sizes. However, it does not round up for request
// sizes of 8 and higher that are powers of two. We take advantage of knowledge here to make
// the sizes of various heap-allocated blocks predictable.
//-----------------------------------------------------------------------
// Start with basic heap block measurement.
unsafe {
// EMPTY is the special non-null address used to represent zero-size allocations.
assert_eq!(heap_size_of(EMPTY as *const c_void), 0);
}
//-----------------------------------------------------------------------
// Test HeapSizeOf implementations for various built-in types.
// Not on the heap; 0 bytes.
let x = 0i64;
assert_eq!(x.heap_size_of_children(), 0);
// An i64 is 8 bytes.
let x = Box::new(0i64);
assert_eq!(x.heap_size_of_children(), 8);
// An ascii string with 16 chars is 16 bytes in UTF-8.
let string = String::from("0123456789abcdef");
assert_eq!(string.heap_size_of_children(), 16);
let string_ref: (&String, ()) = (&string, ());
assert_eq!(string_ref.heap_size_of_children(), 0);
let slice: &str = &*string;
assert_eq!(slice.heap_size_of_children(), 0);
// Not on the heap.
let x: Option<i32> = None;
assert_eq!(x.heap_size_of_children(), 0);
// Not on the heap.
let x = Some(0i64);
assert_eq!(x.heap_size_of_children(), 0);
// The `Some` is not on the heap, but the Box is.
let x = Some(Box::new(0i64));
assert_eq!(x.heap_size_of_children(), 8);
// Not on the heap.
let x = ::std::sync::Arc::new(0i64);
assert_eq!(x.heap_size_of_children(), 0);
// The `Arc` is not on the heap, but the Box is.
let x = ::std::sync::Arc::new(Box::new(0i64));
assert_eq!(x.heap_size_of_children(), 8);
// Zero elements, no heap storage.
let x: Vec<i64> = vec![];
assert_eq!(x.heap_size_of_children(), 0);
// Four elements, 8 bytes per element.
let x = vec![0i64, 1i64, 2i64, 3i64];
assert_eq!(x.heap_size_of_children(), 32);
}
#[test]
fn test_boxed_slice() {
let x = vec![1i64, 2i64].into_boxed_slice();
assert_eq!(x.heap_size_of_children(), 16)
}

29
toolkit/library/gtest/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -343,7 +343,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "freetype"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
@ -354,6 +354,14 @@ name = "futures"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fxhash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gamma-lut"
version = "0.2.0"
@ -427,14 +435,6 @@ name = "glob"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "heapsize"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "heapsize"
version = "0.4.0"
@ -1208,8 +1208,8 @@ dependencies = [
"core-text 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1233,8 +1233,9 @@ dependencies = [
"core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1307,14 +1308,14 @@ dependencies = [
"checksum env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ed39959122ea027670b704fb70539f4286ddf4a49eefede23bf0b4b2a069ec03"
"checksum euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7be9fcb1ce77782eb620253eb02bc1f000545f3c360841a26cda572f10fad4ff"
"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344"
"checksum freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fde23272c687e4570aefec06cb71174ec0f5284b725deac4e77ba2665d635faf"
"checksum freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "398b8a11884898184d55aca9806f002b3cf68f0e860e0cbb4586f834ee39b0e7"
"checksum futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "55f0008e13fc853f79ea8fc86e931486860d4c4c156cdffb59fa5f7fa833660a"
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
"checksum gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f72af1e933f296b827361eb9e70d0267abf8ad0de9ec7fa667bbe67177b297"
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
"checksum gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0940975a4ca12b088d32b5d5134826c47d2e73de4b0b459b05244c01503eccbb"
"checksum gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "917ee404f414ed77756c12cb44fdcc7cd02f207bf91e1dc91a3ce7da794ec361"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88"
"checksum heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7593b1522161003928c959c20a2ca421c68e940d63d75573316a009e48a6d4"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"

29
toolkit/library/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -341,7 +341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "freetype"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
@ -352,6 +352,14 @@ name = "futures"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fxhash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gamma-lut"
version = "0.2.0"
@ -425,14 +433,6 @@ name = "glob"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "heapsize"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "heapsize"
version = "0.4.0"
@ -1195,8 +1195,8 @@ dependencies = [
"core-text 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1220,8 +1220,9 @@ dependencies = [
"core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1294,14 +1295,14 @@ dependencies = [
"checksum env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ed39959122ea027670b704fb70539f4286ddf4a49eefede23bf0b4b2a069ec03"
"checksum euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7be9fcb1ce77782eb620253eb02bc1f000545f3c360841a26cda572f10fad4ff"
"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344"
"checksum freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fde23272c687e4570aefec06cb71174ec0f5284b725deac4e77ba2665d635faf"
"checksum freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "398b8a11884898184d55aca9806f002b3cf68f0e860e0cbb4586f834ee39b0e7"
"checksum futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "55f0008e13fc853f79ea8fc86e931486860d4c4c156cdffb59fa5f7fa833660a"
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
"checksum gamma-lut 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f72af1e933f296b827361eb9e70d0267abf8ad0de9ec7fa667bbe67177b297"
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
"checksum gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0940975a4ca12b088d32b5d5134826c47d2e73de4b0b459b05244c01503eccbb"
"checksum gleam 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "917ee404f414ed77756c12cb44fdcc7cd02f207bf91e1dc91a3ce7da794ec361"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88"
"checksum heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7593b1522161003928c959c20a2ca421c68e940d63d75573316a009e48a6d4"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"