mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Replace all uses of the heapsize
crate with malloc_size_of
.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`. `malloc_size_of` is better -- it handles various cases that `heapsize` does not -- so this patch changes Servo to use `malloc_size_of`. This patch makes the following changes to the `malloc_size_of` crate. - Adds `MallocSizeOf` trait implementations for numerous types, some built-in (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`). - Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't support that operation. - For `HashSet`/`HashMap`, falls back to a computed estimate when `enclosing_size_of_op` isn't available. - Adds an extern "C" `malloc_size_of` function that does the actual heap measurement; this is based on the same functions from the `heapsize` crate. This patch makes the following changes elsewhere. - Converts all the uses of `heapsize` to instead use `malloc_size_of`. - Disables the "heapsize"/"heap_size" feature for the external crates that provide it. - Removes the `HeapSizeOf` implementation from `hashglobe`. - Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of` doesn't derive those types, unlike `heapsize`.
This commit is contained in:
parent
421baa854e
commit
4506f0d30c
269 changed files with 1418 additions and 1521 deletions
|
@ -10,7 +10,7 @@ use servo_url::{ImmutableOrigin, ServoUrl};
|
|||
use std::default::Default;
|
||||
|
||||
/// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator)
|
||||
#[derive(Clone, Copy, HeapSizeOf, PartialEq)]
|
||||
#[derive(Clone, Copy, MallocSizeOf, PartialEq)]
|
||||
pub enum Initiator {
|
||||
None,
|
||||
Download,
|
||||
|
@ -20,7 +20,7 @@ pub enum Initiator {
|
|||
}
|
||||
|
||||
/// A request [type](https://fetch.spec.whatwg.org/#concept-request-type)
|
||||
#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum Type {
|
||||
None,
|
||||
Audio,
|
||||
|
@ -33,7 +33,7 @@ pub enum Type {
|
|||
}
|
||||
|
||||
/// A request [destination](https://fetch.spec.whatwg.org/#concept-request-destination)
|
||||
#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum Destination {
|
||||
None,
|
||||
Document,
|
||||
|
@ -53,14 +53,14 @@ pub enum Destination {
|
|||
}
|
||||
|
||||
/// A request [origin](https://fetch.spec.whatwg.org/#concept-request-origin)
|
||||
#[derive(Clone, Debug, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum Origin {
|
||||
Client,
|
||||
Origin(ImmutableOrigin),
|
||||
}
|
||||
|
||||
/// A [referer](https://fetch.spec.whatwg.org/#concept-request-referrer)
|
||||
#[derive(Clone, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum Referrer {
|
||||
NoReferrer,
|
||||
/// Default referrer if nothing is specified
|
||||
|
@ -69,7 +69,7 @@ pub enum Referrer {
|
|||
}
|
||||
|
||||
/// A [request mode](https://fetch.spec.whatwg.org/#concept-request-mode)
|
||||
#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum RequestMode {
|
||||
Navigate,
|
||||
SameOrigin,
|
||||
|
@ -79,7 +79,7 @@ pub enum RequestMode {
|
|||
}
|
||||
|
||||
/// Request [credentials mode](https://fetch.spec.whatwg.org/#concept-request-credentials-mode)
|
||||
#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum CredentialsMode {
|
||||
Omit,
|
||||
CredentialsSameOrigin,
|
||||
|
@ -87,7 +87,7 @@ pub enum CredentialsMode {
|
|||
}
|
||||
|
||||
/// [Cache mode](https://fetch.spec.whatwg.org/#concept-request-cache-mode)
|
||||
#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum CacheMode {
|
||||
Default,
|
||||
NoStore,
|
||||
|
@ -98,7 +98,7 @@ pub enum CacheMode {
|
|||
}
|
||||
|
||||
/// [Service-workers mode](https://fetch.spec.whatwg.org/#request-service-workers-mode)
|
||||
#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum ServiceWorkersMode {
|
||||
All,
|
||||
Foreign,
|
||||
|
@ -106,7 +106,7 @@ pub enum ServiceWorkersMode {
|
|||
}
|
||||
|
||||
/// [Redirect mode](https://fetch.spec.whatwg.org/#concept-request-redirect-mode)
|
||||
#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)]
|
||||
#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum RedirectMode {
|
||||
Follow,
|
||||
Error,
|
||||
|
@ -114,7 +114,7 @@ pub enum RedirectMode {
|
|||
}
|
||||
|
||||
/// [Response tainting](https://fetch.spec.whatwg.org/#concept-request-response-tainting)
|
||||
#[derive(Clone, Copy, HeapSizeOf, PartialEq)]
|
||||
#[derive(Clone, Copy, MallocSizeOf, PartialEq)]
|
||||
pub enum ResponseTainting {
|
||||
Basic,
|
||||
CorsTainting,
|
||||
|
@ -122,7 +122,7 @@ pub enum ResponseTainting {
|
|||
}
|
||||
|
||||
/// [Window](https://fetch.spec.whatwg.org/#concept-request-window)
|
||||
#[derive(Clone, Copy, HeapSizeOf, PartialEq)]
|
||||
#[derive(Clone, Copy, MallocSizeOf, PartialEq)]
|
||||
pub enum Window {
|
||||
NoWindow,
|
||||
Client, // TODO: Environmental settings object
|
||||
|
@ -135,16 +135,16 @@ pub enum CorsSettings {
|
|||
UseCredentials,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, HeapSizeOf, Serialize)]
|
||||
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
||||
pub struct RequestInit {
|
||||
#[serde(deserialize_with = "::hyper_serde::deserialize",
|
||||
serialize_with = "::hyper_serde::serialize")]
|
||||
#[ignore_heap_size_of = "Defined in hyper"]
|
||||
#[ignore_malloc_size_of = "Defined in hyper"]
|
||||
pub method: Method,
|
||||
pub url: ServoUrl,
|
||||
#[serde(deserialize_with = "::hyper_serde::deserialize",
|
||||
serialize_with = "::hyper_serde::serialize")]
|
||||
#[ignore_heap_size_of = "Defined in hyper"]
|
||||
#[ignore_malloc_size_of = "Defined in hyper"]
|
||||
pub headers: Headers,
|
||||
pub unsafe_request: bool,
|
||||
pub body: Option<Vec<u8>>,
|
||||
|
@ -199,17 +199,17 @@ impl Default for RequestInit {
|
|||
|
||||
/// A [Request](https://fetch.spec.whatwg.org/#concept-request) as defined by
|
||||
/// the Fetch spec.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, MallocSizeOf)]
|
||||
pub struct Request {
|
||||
/// <https://fetch.spec.whatwg.org/#concept-request-method>
|
||||
#[ignore_heap_size_of = "Defined in hyper"]
|
||||
#[ignore_malloc_size_of = "Defined in hyper"]
|
||||
pub method: Method,
|
||||
/// <https://fetch.spec.whatwg.org/#local-urls-only-flag>
|
||||
pub local_urls_only: bool,
|
||||
/// <https://fetch.spec.whatwg.org/#sandboxed-storage-area-urls-flag>
|
||||
pub sandboxed_storage_area_urls: bool,
|
||||
/// <https://fetch.spec.whatwg.org/#concept-request-header-list>
|
||||
#[ignore_heap_size_of = "Defined in hyper"]
|
||||
#[ignore_malloc_size_of = "Defined in hyper"]
|
||||
pub headers: Headers,
|
||||
/// <https://fetch.spec.whatwg.org/#unsafe-request-flag>
|
||||
pub unsafe_request: bool,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue