mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Gracefully handle errors creating shared memory UA style sheets.
We still panic in a debug build, so that developers can notice when they need to add a new static atom after modifying UA sheets. We also add telemetry to note when this happens, add an app note to a crash report, in case any crash later on occurs, and re-up the existing, expired shared memory sheet telemetry probes so we can look at them again. Differential Revision: https://phabricator.services.mozilla.com/D73188
This commit is contained in:
parent
709c52fefb
commit
6bae0b99ca
10 changed files with 184 additions and 122 deletions
|
@ -27,13 +27,23 @@ pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
|
|||
|
||||
input.generics.where_clause = where_clause;
|
||||
|
||||
let match_body = cg::fmap_match(&input, BindStyle::Ref, |binding| {
|
||||
quote! {
|
||||
::std::mem::ManuallyDrop::into_inner(
|
||||
::to_shmem::ToShmem::to_shmem(#binding, builder)
|
||||
)
|
||||
}
|
||||
});
|
||||
// Do all of the `to_shmem()?` calls before the `ManuallyDrop::into_inner()`
|
||||
// calls, so that we don't drop a value in the shared memory buffer if one
|
||||
// of the `to_shmem`s fails.
|
||||
let match_body = cg::fmap2_match(
|
||||
&input,
|
||||
BindStyle::Ref,
|
||||
|binding| {
|
||||
quote! {
|
||||
::to_shmem::ToShmem::to_shmem(#binding, builder)?
|
||||
}
|
||||
},
|
||||
|binding| {
|
||||
Some(quote! {
|
||||
::std::mem::ManuallyDrop::into_inner(#binding)
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
let name = &input.ident;
|
||||
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
|
||||
|
@ -44,12 +54,12 @@ pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
|
|||
fn to_shmem(
|
||||
&self,
|
||||
builder: &mut ::to_shmem::SharedMemoryBuilder,
|
||||
) -> ::std::mem::ManuallyDrop<Self> {
|
||||
::std::mem::ManuallyDrop::new(
|
||||
) -> ::to_shmem::Result<Self> {
|
||||
Ok(::std::mem::ManuallyDrop::new(
|
||||
match *self {
|
||||
#match_body
|
||||
}
|
||||
)
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue