The default placement operator new is defined to always require that its
result be null-checked. A sufficiently smart compiler can remove this
check, but not all compilers are sufficiently smart. Better to have a
custom placement operator new that will remove null checks in a way
defined by the standard.
In JS StructuredClone BufferList<SystemAllocPolicy> is typedef'd to
JSStructuredCloneData and use everywhere in gecko that stores structured
clone data.
This patch changed some raw pointers to UniquePtr<JSStructuredCloneData>
and some to stack allocated JSStructuredCloneData for better life time
management. Some parameters or methods are deleted because of changing
to the new data structure.
MessagePortMessage now has the exactly same structure with
ClonedMessageData. Maybe in the future they can be consolidated.
MozReview-Commit-ID: 1IY9p5eKLgv
--HG--
extra : rebase_source : 59a1f04de0d09709e9dc71a68c33025a6c13731c
It works like a move constructor but it's fallible. It can also move
data to different but compatible AllocPolicy.
MozReview-Commit-ID: LAbPWCwnrr6
--HG--
extra : rebase_source : 799551bc38934a38374dab0e8e0e93247a0ae547
These methods allow us to move some buffers out of a pickle with minimum
copying. It's useful when the IPC deserialized type uses BufferList to
store data and we want to take the buffers from IPC directly.
Borrowing is not suitable to use for IPC to hand out data because we
often want to store the data somewhere for processing after IPC has
released the underlying buffers.
MozReview-Commit-ID: F1K2ZMkACqq
--HG--
extra : rebase_source : eb67256e78f16189a62f441300e0dd06fe6ed687
mozilla::SignalTrampoline is designed to work around a bug in older ARM
kernels; it constructs a trampoline function with a NOP slide and then
calls a specified function. This feat is accomplished using inline
assembly and naked functions, which is a GCC extension where you get to
write the entire body of your function using GCC inline assembly.
Unfortunately, the particular implementation that it uses requires the
specified function's address to be loaded into a register. GCC permits
this and we use input arguments to the assembly statement to ensure that
GCC knows it shouldn't clobber the incoming argument registers when
trying to load the function's address.
clang, however, complains about the use of input parameters in naked
functions. So we need to find something that will work on both GCC and
clang.
The trick is to realize that we're a) tail-calling the specified
function and b) we don't have to worry about calling a fully-general
function. We just have to worry about calling a function inside libxul,
and we can therefore "assume" that the offset between the branch and the
called function fits into the immediate field of a Thumb (or ARM) branch
instruction. (This assumption is not strictly true; the branch range is
+/-16MB or so and libxul is actually quite a bit bigger than that. But
it works in practice, and the linker will insert branch stubs if
necessary to make things work out OK.)
The upshot is that we can use a "b" instruction instead of a "bx"
instruction, and this makes clang much happier. As a small bonus, the
stub gets ever-so-much-more efficient, which is probably the
least-significant micro-optimization ever.
This removes the unnecessary setting of c-basic-offset from all
python-mode files.
This was automatically generated using
perl -pi -e 's/; *c-basic-offset: *[0-9]+//'
... on the affected files.
The bulk of these files are moz.build files but there a few others as
well.
MozReview-Commit-ID: 2pPf3DEiZqx
--HG--
extra : rebase_source : 0a7dcac80b924174a2c429b093791148ea6ac204
These new constructor accepts two RangedPtr<T> arguments.
MozReview-Commit-ID: 8a3bYserLMr
--HG--
extra : rebase_source : 216de17b7a51783fe48d604b432d4dc7df6ad6eb
This means we can return already_AddRefed<T> for any RefPtr<T>s
being held as instance variables easier.
MozReview-Commit-ID: HFHdkF8EUsK
--HG--
extra : rebase_source : df650d39c010386afcb8cb2dd48292c26fbc6501
This patch implements mozilla::NotNull, which is similar but not identicial to
gsl::not_null.
The current draft(?) implementation of gsl::not_null is at
https://github.com/Microsoft/GSL/blob/master/include/gsl.h.
The main difference is that not_null allows implicit conversion from T to
not_null<T>. In contrast, NotNull only allows explicit conversion from T to
NotNull<T> via WrapNotNull().
The rationale for this is that when converting from a less-constrained type to
a more constrained type, implicit conversion is undesirable. For example, if I
changed a function f from this:
f(int* aPtr);
to this:
f(gsl::not_null<int*> aPtr);
no call sites would have to be modified. But if I changed it to this:
f(mozilla::NotNull<int*> aPtr);
call sites *would* need to be modified. This is a good thing! It forces the
author to audit the call sites for non-nullness, and encourages them to
back-propagate NotNull throughout the code.
The other difference between not_null and NotNull is that not_null disables
pointer arithmetic, which means it cannot be used with array pointers. I have
not implemented this restriction for NotNull because it seems arbitrary and
unnecessary.