Граф коммитов

1343 Коммитов

Автор SHA1 Сообщение Дата
Ted Campbell a75a26eb42 Bug 1508180 - Use uppercase high-order macro names in xptinfo. r=nika
This makes clang-format stop mangling the macros.

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

--HG--
extra : moz-landing-system : lando
2018-11-19 17:31:14 +00:00
Kyle Machulis 911d1c3784 Bug 1498059 - Allow 8-bit unsigned consts in XPIDL; , r=nika,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D8593

--HG--
extra : moz-landing-system : lando
2018-11-06 00:05:35 +00:00
Adrian Wielgosik d4785563da Bug 1480245, part 4 - Remove always-true nsXPTInterfaceInfo::IsScriptable(). r=nika
Differential Revision: https://phabricator.services.mozilla.com/D9646

--HG--
extra : moz-landing-system : lando
2018-10-25 09:55:05 +00:00
Adrian Wielgosik 3aae9fcc99 Bug 1480245, part 3 - Remove always-true nsXPTInterfaceInfo::EnsureResolved(). r=nika
Differential Revision: https://phabricator.services.mozilla.com/D9645

--HG--
extra : moz-landing-system : lando
2018-10-24 17:39:47 +00:00
Adrian Wielgosik e6326985f3 Bug 1480245, part 1 - Remove compatibility methods from nsXPTInterfaceInfo. r=nika
I left GetMethodInfo, GetConstant as they are still useful as separate methods.

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

--HG--
extra : moz-landing-system : lando
2018-10-25 09:56:26 +00:00
Nika Layzell 5b24f801f7 Bug 1500927 - Add copy-free jsstring support to perfecthash.py, r=bzbarsky
This is needed for bug 1500926. It takes the approach of taking a JSFlatString
and using AutoAssertCannotGC to read the memory directly from the JS heap.
This lets us avoid re-encoding strings when performing lookups, which can be
advantageous.

Only ASCII strings are supported by this handler, and wide strings are hashed
as though they contain only values under 0x7f. This is OK as invalid keys to
perfecthash may return any hashtable entry.

Differential Revision: https://phabricator.services.mozilla.com/D9405
2018-10-24 20:11:01 -04:00
A. Wilcox 041115caa2 Bug 1498938 - Support [implicit_jscontext] XPIDL calls on Linux/PPC64.; r=froydnj 2018-10-17 23:12:51 +00:00
Nicholas Nethercote 0979695a1a Bug 1489047 - Remove C++ support for, and testing of, the XPIDL DOMString type. r=nika
--HG--
extra : rebase_source : 21df3192cfff8f9d9254306a5be4f8ad84397eb7
2018-09-06 18:03:18 +10:00
Nathan Froyd 3445a4da75 Bug 1494511 - export aarch64 windows xptcstubs from their source file; r=dmajor
DONTBUILD because NPTOB.
2018-09-27 11:17:21 -04:00
Tom Ritter 50da904b0c Bug 1490568 Quote the _PrepareAndDispatch symbol to fix the mingw-clang x86 build r=dmajor
Differential Revision: https://phabricator.services.mozilla.com/D6045

--HG--
extra : moz-landing-system : lando
2018-09-17 15:30:14 +00:00
Tom Ritter b5f6d986cc Bug 1491856 Change .scl 3 -> .scl 2 in the reflect assembly r=dmajor
As in Bug 1390583 and Bug 1470993, this will correct them to be external symbols

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

--HG--
extra : moz-landing-system : lando
2018-09-17 15:27:24 +00:00
Nathan Froyd 7624eea8a4 Bug 1480549 - add aarch64 windows support to xptcall; r=dmajor
Since the ABI on this platform just uses the ARM procedure call
standard, which is the same standard Unix uses, we can just
copy-and-paste everything, with some adjustments to the assembly code to
compile properly.
2018-08-29 15:49:57 -04:00
Kris Maglione 83db11134f Bug 1484496: Part 1 - Add support for symbol properties to XPIDL. r=nika
This patch allows us to define methods or getters/setters for any of the
current set of well-known symbols. Those are defined by adding the [symbol]
attribute to a method:

  [symbol]
  Iterator iterator();

which causes the method to define a property with the well-known symbol which
matches its method name (Symbol.iterator, in this case).

Due to the implementation details of the XPIDL parser, this currently does not
support defining a non-symbol function with the same name as a symbol
function:

  [symbol]
  Iterator iterator();

  [binaryname(OtherIterator)]
  Thing iterator(in nsIDRef aIID);

throws for a duplicate method name, even though there is no actual conflict.

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

--HG--
extra : rebase_source : 1385e2da93113306730f7c087fe7385dbe668e91
extra : histedit_source : 3afd9fe38e7cbddc5576c2bd1673496dd623e489
2018-08-21 14:08:35 -07:00
Nika Layzell f1902ff595 Bug 1480624 - Part 1: Add XPT_FOR_EACH_*_TYPE macros to xptinfo.h, r=mccr8
Summary:
This macro simplifies code which allows performing an operation on or
extracting information from a particular nsXPTType's native representation.

It is also used in part 2 to implement xpc::DestructValue.

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1480624

Differential Revision: https://phabricator.services.mozilla.com/D2689
2018-08-03 15:55:13 -04:00
Nika Layzell 3869445efd Bug 1474739 - Part 3: Linting fixes on a CLOSED TREE, a=bustage 2018-08-01 18:23:21 -04:00
Nika Layzell 540b4e5eb7 Bug 1474739 - Part 2: Remove all code for XPT shims, r=bzbarsky
Summary: Depends On D2624

Reviewers: bzbarsky!

Tags: #secure-revision

Bug #: 1474739

Differential Revision: https://phabricator.services.mozilla.com/D2625
2018-08-01 18:07:44 -04:00
Nika Layzell b465c677b3 Bug 1479484 - Part 5: Remove old perfecthash.py, r=froydnj
Summary: Depends On D2618

Reviewers: froydnj!

Tags: #secure-revision

Bug #: 1479484

Differential Revision: https://phabricator.services.mozilla.com/D2619
2018-08-01 17:54:43 -04:00
Nika Layzell 082166e008 Bug 1479484 - Part 4: Move xptcodegen over to new perfecthash.py, r=froydnj
Summary:
This patch ports xptcodegen.py over to the new perfecthash.py system, removing
some special-case code generators, and taking advantage of the easier-to-use
interface.

In addition, the code was changed to take advantage of the endianness
information from Part 2, allowing us to avoid having to perform endianness swaps
at runtime when hashing nsIDs.

Depends On D2616

Reviewers: froydnj!

Tags: #secure-revision

Bug #: 1479484

Differential Revision: https://phabricator.services.mozilla.com/D2618
2018-08-01 17:54:42 -04:00
Nika Layzell 7fa88ded1b Bug 1474369 - Part 8: Rename from Sequence to Array in xpidl, r=mccr8
Summary:
This more closely matches the C++ names, and reflects the fact that the
reflected type is not WebIDL's mozilla::dom::Sequence. The reasoning behind this
type difference is for ergonomics, due to xpidl only being exposed to internal
JS code.

Depends On D2335

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2337
2018-07-31 17:53:03 -04:00
Nika Layzell cb71d3b003 Bug 1474369 - Part 7: Rename [array] to LegacyArray within xpt and xpidl, r=mccr8
Summary:
This is done so we can use Array as the name for the new nsTArray-based
type, rather than having to come up with a new name.

LegacyArray was chosen as the [array] attribute is now effectively deprecated,
and we'd like to remove it ASAP.

Depends On D2334

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2335
2018-07-31 17:53:03 -04:00
Nika Layzell 5b6ca0e475 Bug 1475409 - Part 3: Make the different categories of types in xptinfo more explicit, r=mccr8
Summary:
This should make it more clear which types have which behaviours, and should
make it easier to add new types without forgetting to handle a special case
somewhere.

Depends On D2114

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1475409

Differential Revision: https://phabricator.services.mozilla.com/D2115
2018-07-31 17:53:02 -04:00
Nika Layzell 985488cb0f Bug 1475409 - Part 2: Be more explicit about the type of nsXPTType::Tag(), r=mccr8
This will get us both more clarity as to what types are, but also will improve switch exhaustiveness checks.

Summary: Depends On D2113

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1475409

Differential Revision: https://phabricator.services.mozilla.com/D2114
2018-07-31 17:53:02 -04:00
Nika Layzell 2cb67382dc Bug 1475409 - Part 1: Remove nsXPTType::TagPart(), r=mccr8
Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1475409

Differential Revision: https://phabricator.services.mozilla.com/D2113
2018-07-31 17:53:02 -04:00
Nika Layzell d4c9b9edf4 Bug 1474369 - Part 4: Add support for Sequence<T> types to xpidl and XPConnect, r=mccr8
Summary:
This patch adds support for the `Sequence<T>` type. This is largely a
straightforward type propagation patch, but there are a few notable things:

 1. We allow `[iid_is(x)] Sequence<nsQIResult>`, so Sequence can be Dependent.

 2. `Sequence<T>` is reflected into C++ as a `nsTArray<T>`, which is different
    than WebIDL's `mozilla::dom::Sequence<T>` type. This decision was made for
    general ergonomics reasons, as `nsTArray<T>` is more prevailent throughout
    the codebase, and lengths in this case cannot be controlled by content, as
    XPConnect is only exposed to Chrome JS.

 3. Owned pointers in `Sequence<T>` are not reflected as their owned
    counterparts. For example, `Sequence<nsISupports>` is reflected as
    `nsTArray<nsISupports*>` rather than `nsTArray<RefPtr<nsISupports>>`. This
    was done to avoid depending on `RefPtr<T>` and `T*` having the same
    in-memory representation, however if that is considered an acceptable
    dependency, it would be nice to support that.

 4. We also don't reflect singly-owned pointers as their owned counterparts. For
    example, `nsTArray<nsIIDPtr>` would be reflected as `nsTArray<nsIID*>`
    rather than `nsTArray<mozilla::UniquePtr<nsIID>>`. If we are willing to
    depend on `mozilla::UniquePtr<T>`'s in-memory representation, we could also
    do this, however.

 5. There are no restrictions on what types can appear inside of a `Sequence<T>`
    or what can appear inside an `[array] T`. We may want to add restrictions
    either at the xpidl level or in XPConnect.

Depends On D2109

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2110
2018-07-31 17:53:01 -04:00
Nika Layzell 5ee2c61291 Bug 1474369 - Part 1: Clean up value initialization codepaths in XPConnect, r=mccr8
Summary:
A goal of the Sequence<T> work is to allow using more complex types within lists
in XPConnect. For example, we ideally want to support `Sequence<AString>`,
rather than requiring people to use the unergonomic 'wstring' type.

These types require initialization before they can be read into. Currently this
initialization for parameters is directly handled by XPCWrappedNative's
CallMethodHelper object.

This patch introduces a new function to the `xpc` namespace to initialize a
specific value from an uninitialized state to a safe state.

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2105
2018-07-31 17:53:00 -04:00
qiaopengcheng ffa75bd086 Bug 1478560 - Fix the compiling error of the struct nsXPTCVariant. r=glandium 2018-07-31 09:39:31 +09:00
Cosmin Sabou e748fd8968 Backed out 15 changesets (bug 1475409, bug 1461450, bug 1474369, bug 1471726) for causing rooting hazards and browser chrome failures. CLOSED TREE
Backed out changeset 7ce27aa3ce68 (bug 1474369)
Backed out changeset a8a4e2414daa (bug 1474369)
Backed out changeset 13c9626970e2 (bug 1474369)
Backed out changeset 9817819b7765 (bug 1475409)
Backed out changeset 39fcebfe6529 (bug 1475409)
Backed out changeset c19ca740d3d1 (bug 1475409)
Backed out changeset b26c90518fca (bug 1474369)
Backed out changeset cbdde0474521 (bug 1474369)
Backed out changeset ccea3049fe0f (bug 1474369)
Backed out changeset e9f6d2544a82 (bug 1474369)
Backed out changeset 99c4d07d4b88 (bug 1474369)
Backed out changeset c721ada8a6d6 (bug 1461450)
Backed out changeset 961379be0f5e (bug 1461450)
Backed out changeset cf2448b2635f (bug 1471726)
Backed out changeset 408961783c95 (bug 1471726)
2018-07-30 20:31:24 +03:00
Nika Layzell 72ed07e711 Bug 1474369 - Part 8: Rename from Sequence to Array in xpidl, r=mccr8
Summary:
This more closely matches the C++ names, and reflects the fact that the
reflected type is not WebIDL's mozilla::dom::Sequence. The reasoning behind this
type difference is for ergonomics, due to xpidl only being exposed to internal
JS code.

Depends On D2335

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2337
2018-07-30 11:31:41 -04:00
Nika Layzell 28fd912fa1 Bug 1474369 - Part 7: Rename [array] to LegacyArray within xpt and xpidl, r=mccr8
Summary:
This is done so we can use Array as the name for the new nsTArray-based
type, rather than having to come up with a new name.

LegacyArray was chosen as the [array] attribute is now effectively deprecated,
and we'd like to remove it ASAP.

Depends On D2334

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2335
2018-07-30 11:31:29 -04:00
Nika Layzell f6490fc64d Bug 1475409 - Part 3: Make the different categories of types in xptinfo more explicit, r=mccr8
Summary:
This should make it more clear which types have which behaviours, and should
make it easier to add new types without forgetting to handle a special case
somewhere.

Depends On D2114

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1475409

Differential Revision: https://phabricator.services.mozilla.com/D2115
2018-07-30 11:28:19 -04:00
Nika Layzell e1f1115f9a Bug 1475409 - Part 2: Be more explicit about the type of nsXPTType::Tag(), r=mccr8
This will get us both more clarity as to what types are, but also will improve switch exhaustiveness checks.

Summary: Depends On D2113

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1475409

Differential Revision: https://phabricator.services.mozilla.com/D2114
2018-07-30 11:28:17 -04:00
Nika Layzell 366cd88a89 Bug 1475409 - Part 1: Remove nsXPTType::TagPart(), r=mccr8
Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1475409

Differential Revision: https://phabricator.services.mozilla.com/D2113
2018-07-30 11:28:14 -04:00
Nika Layzell 0f6863aece Bug 1474369 - Part 4: Add support for Sequence<T> types to xpidl and XPConnect, r=mccr8
Summary:
This patch adds support for the `Sequence<T>` type. This is largely a
straightforward type propagation patch, but there are a few notable things:

 1. We allow `[iid_is(x)] Sequence<nsQIResult>`, so Sequence can be Dependent.

 2. `Sequence<T>` is reflected into C++ as a `nsTArray<T>`, which is different
    than WebIDL's `mozilla::dom::Sequence<T>` type. This decision was made for
    general ergonomics reasons, as `nsTArray<T>` is more prevailent throughout
    the codebase, and lengths in this case cannot be controlled by content, as
    XPConnect is only exposed to Chrome JS.

 3. Owned pointers in `Sequence<T>` are not reflected as their owned
    counterparts. For example, `Sequence<nsISupports>` is reflected as
    `nsTArray<nsISupports*>` rather than `nsTArray<RefPtr<nsISupports>>`. This
    was done to avoid depending on `RefPtr<T>` and `T*` having the same
    in-memory representation, however if that is considered an acceptable
    dependency, it would be nice to support that.

 4. We also don't reflect singly-owned pointers as their owned counterparts. For
    example, `nsTArray<nsIIDPtr>` would be reflected as `nsTArray<nsIID*>`
    rather than `nsTArray<mozilla::UniquePtr<nsIID>>`. If we are willing to
    depend on `mozilla::UniquePtr<T>`'s in-memory representation, we could also
    do this, however.

 5. There are no restrictions on what types can appear inside of a `Sequence<T>`
    or what can appear inside an `[array] T`. We may want to add restrictions
    either at the xpidl level or in XPConnect.

Depends On D2109

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2110
2018-07-30 11:28:08 -04:00
Nika Layzell 6391732616 Bug 1474369 - Part 1: Clean up value initialization codepaths in XPConnect, r=mccr8
Summary:
A goal of the Sequence<T> work is to allow using more complex types within lists
in XPConnect. For example, we ideally want to support `Sequence<AString>`,
rather than requiring people to use the unergonomic 'wstring' type.

These types require initialization before they can be read into. Currently this
initialization for parameters is directly handled by XPCWrappedNative's
CallMethodHelper object.

This patch introduces a new function to the `xpc` namespace to initialize a
specific value from an uninitialized state to a safe state.

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2105
2018-07-30 11:28:00 -04:00
Nathan Froyd 695cb9d23b Bug 1477081 - remove TARGET_CPU use from moz.build files; r=ted.mielczarek
TARGET_CPU is not canonicalized, whereas CPU_ARCH is, so we should be
using CPU_ARCH to get consistent values everywhere.
2018-07-24 16:08:55 -04:00
Nathan Froyd 309ddc0be2 Bug 1477048 - part 2 - remove non-ipc/chromium moz.build uses of OS_TEST; r=gps
The deletions in xptcall are when we don't even have support for the CPU
in moz.configure, so I assume that people haven't been compiling on
those architectures for quite some time.
2018-07-24 16:08:56 -04:00
Nathan Froyd 5158597854 Bug 1477048 - part 1 - remove `'86' in CONFIG['OS_TEST']` stanzas from moz.build files; r=gps
The current code is somewhat non-obvious to a first-time reader, and
OS_TEST is a bizarre thing anyway, since it's actually the name of the
CPU we're running on.  We'd do well to minimize the use of OS_TEST.

Note that the complete nuking of the xptcall/md/unix/moz.build lines are
because we don't support OS X/x86 anymore.
2018-07-24 16:08:56 -04:00
Robert Bartlensky 06d2e947d6 Bug 1476313: Fix DEAD_STORE errors in xpcom/reflect/xptcall/md/unix/*. r=mccr8
MozReview-Commit-ID: 29GpsKzXQhq

--HG--
extra : rebase_source : 25e5028f0aadb3cbf8f3e50e3b3af1cf8dc827f2
2018-07-19 11:36:42 +01:00
Bobby Holley 4d4dfa4633 Bug 1476987 - Eliminate nsXPTCVariant::ptr. r=nika
MozReview-Commit-ID: JCazltUuMBf

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

--HG--
extra : moz-landing-system : lando
2018-07-21 01:25:37 +00:00
Jan de Mooij ef23676856 Bug 1475699 - Support invoking JS-implemented XPIDL methods/attributes marked as [implicit_jscontext]. r=mccr8 2018-07-17 18:11:03 +02:00
Jeff Gilbert 15f1932c0f Bug 1470325 - Update Codegen.py to emit Foo_Binding instead of FooBinding. - r=bz,qdot
MozReview-Commit-ID: CFIQpIRsXIU
2018-06-26 17:05:01 -07:00
Jacek Caban 16173fb976 Bug 1470993 - Fix reflect mingw clang compilation r=dmajor
MozReview-Commit-ID: 4al9Yid9prK

--HG--
extra : rebase_source : 97d59d43270bd2ee23380d0b3cade2dbf9c517d0
2018-06-25 21:51:39 +02:00
David Major a22b21c63c Bug 1470488 - don't instrument win32's xptcall SharedStub; r=froydnj
Compiler-inserted instrumentation is going to do terrible things to this
function, so don't let the compiler do that.
2018-06-22 13:51:13 -04:00
Sylvestre Ledru 6d84fa8c1b Bug 1464869 - Fix flake8/pep8 issue by hand in xpcom/ r=Nika
MozReview-Commit-ID: KOzQnlWwVuR

--HG--
extra : rebase_source : e14c57fe3bf7f238399f8860b6a05184b4d65163
2018-05-25 22:17:28 -07:00
Sylvestre Ledru 34a5216fe7 Bug 1464869 - Run autopep8 on xpcom/ r=Nika
MozReview-Commit-ID: JDdoIvkmOIx

--HG--
extra : rebase_source : c23ee8d3da399dd837eccf6a63a50cd50f5e81c6
2018-05-25 21:29:52 -07:00
Nika Layzell 3043db4105 Bug 1457972 - Part 10: Make sure to allocate ExtendedVal inline, r=froydnj 2018-05-14 17:55:57 -04:00
Nika Layzell ca0a0c7f42 Bug 1457972 - Part 6: Ensure the extended types list has some basic types with known indexes, r=mccr8
Currently XPCVariant has some code for working with arrays of a series of basic
types. I want to unify and simplify code which works with nsXPTTypes to always
take the topmost level type (rather than passing in an array element type when
working with an array).

This is pretty easy for most of XPConnect, but XPCVariant occasionally needs to
perform calls on made-up array types, which isn't compatible with the current
implementation. Fortunately, it only needs a very small set of array types. This
patch adds a set of simple types (mostly the arithmetic types and
TD_INTERFACE_IS_TYPE for interfaces) to the extra types array unconditionally
with a known index, for XPCVariant.

An other option I was considering was to consider the value `0xff` in the data
byte on nsXPTType to be a flag which indicates that the array element type is
actually the type immediately following the current nsXPTType object in memory,
but that was incompatible with many of the existing nsXPTType consumers which
copy the nsXPTType objects around (e.g. onto the stack), rather than always
using them by reference, so I decided it was not a good approach to take.
2018-05-14 17:55:56 -04:00
Nika Layzell e2240ec5a2 Bug 1457972 - Part 4: Remove dipper types, r=mccr8
In XPConnect, native values are passed around within nsXPTCMiniVariant objects.
an [nsXPTCMiniVariant] contains 64-bits of data in a union type.

nsXPTCMiniVariant values are created by the platform-specific glue code and
passed into XPConnect proper when calling from C++ into JS.

When calling from JS into C++, we instead create nsXPTCVariant objects and pass
them into the glue code. These objects have extra information in addition to the
nsXPTCMiniVariant: namely they also have a `type` field with the type stored in
the variant, space for flags, and a `ptr` field which is passed over IPC instead
of the inner nsXPTCMiniVariant when a flag (`PTR_IS_DATA`) is set.

The JSValue type in XPConnect is always passed as a pointer to a JSValue object,
both for in parameters and out parameters. This is handled by making the JSValue
type be unconditionally flagged as [`IsIndirect()`] This flag is also used for
all types of outparameters.

When the `IsIndirect()` flag is set, it means that the actual data is stored in
the nsXPTCVariant's val field, and it sets the flag to tell the glue code to
instead pass the `ptr` field (which is always pointing to the `val` field for
[legacy reasons]) into the C++ code.

In contrast "dipper" is a different and super weird flag. Currently only the
string class types (nsACString & nsAString) are marked as "dipper". A "dipper"
type is always passed as an "in" type (and thus always passed "directly"), even
when it's actually an out parameter.

XPConnect treats these types as though they are pointer types (nsAString*). This
means that there is no space in the nsXPTCVariant to store the actual nsAString
types when passing from JS into C++, so these values have to be allocated by a
different mechanism (in the current code, there is a size 2 buffer for each
string type in the context and once that buffer is exceeded, we heap allocate
the nsString values).

In effect, the current state looks something like this:
+------------+---------------------+---------------------+
| type       | out (xpt/native)    | in (xpt/native)     |
+------------+---------------------+---------------------+
| TD_INT32   | indirect (int32_t*) | direct (int32_t)    |
+------------+---------------------+---------------------+
| TD_JSVAL   | indirect (JSValue*) | indirect (JSValue*) |
+------------+---------------------+---------------------+
| TD_ASTRING | direct (nsAString*) | direct (nsAString*) |
+------------+---------------------+---------------------+

This patch ensures there is enough space in the nsXPTCVariant to fit the
nsString value, and switches string class types to being unconditionally
indirect instead of using the dipper system. This allows us to delete a ton of
dipper-specific code, and unify the indirect and string class codepaths.

This only affects the size of nsXPTCVariant objects, and does not affect
nsXPTCMiniVariant objects. nsXPTCVariant objects are never allocated by the
platform-specific binding code, rather, they are allocated in an AutoTArray on
the stack as part of the CallMethodHelper object.

The size increase is a total of 1 word, so 4 bytes in 32-bit builds, and 8 bytes
in 64-bit builds, which is ignorable for stack allocated objects.

[nsXPTCMiniVariant]: https://searchfox.org/mozilla-central/rev/eb6c5214a63e20a3fff455e92c876287a8d2e188/xpcom/reflect/xptcall/xptcall.h#20-47
[`IsIndirect()`]: https://searchfox.org/mozilla-central/rev/c0d81882c7941c4ff13a50603e37095cdab0d1ea/xpcom/reflect/xptinfo/xptinfo.h#371
[legacy reasons]: https://searchfox.org/mozilla-central/rev/eb6c5214a63e20a3fff455e92c876287a8d2e188/xpcom/reflect/xptcall/xptcall.h#66-79
2018-05-14 17:55:55 -04:00
Nika Layzell f20e777cdb Bug 1457972 - Part 2: Remove unused code paths in xpconnect, r=mccr8
Thanks to the changes in the previous patch, we had some unused code which we
can get rid of. This patch just cleans stuff up a bit.
2018-05-14 17:55:54 -04:00
Nika Layzell 73efb8abf3 Bug 1457972 - Part 1: Unify xpconnect cleanup codepaths, r=mccr8
It used to be that in XPConnect there were many different pieces of code for
each place where we may need to clean up some untyped values based on their
nsXPTType information. This was a mess, and meant that every time you needed to
add a new data type you'd have to find every one of these places and add support
for your new type to them.

In fact, this was bad enough that it appears that I missed some places when
adding my webidl support! Which means that in some edge cases we may clean up
one of these values incorrectly D:!

This patch adds a new unified method which performs the cleanup by looking at a
nsXPTType object. The idea is that this function takes a void* which is actually
a T* where T is a value of the nsXPTType parmaeter. It clears the value behind
the pointer to a valid state such that free-ing the memory would not cause any
leaks. e.g. it free(...)s owned pointers and sets the pointer to `nullptr`, and
truncates nsA[C]String values such that they reference the static empty string.

I also modify every one of these custom cleanup codepaths to instead call into
this unified cleanup method.

This also involved some simplification of helper methods in order to make the
implementation cleaner.
2018-05-14 17:55:54 -04:00