209 Commits

Author SHA1 Message Date
Andrew McCreight
3d1c6d4ceb Bug 1792920, part 3 - Make Rust use a new MozExternalRefCountType instead of XPIDL's nsrefcnt. r=nika
The remaining uses of XPIDL's definition of nsrefcnt in Rust are all
now related to the return type of nsISupport's AddRef and Release
methods. The C++ name of the return types is MozExternalRefCountType,
not nsrefcnt (which is something else entirely), so use a more accurate
name.

I can't use the C++ definition, because it is in C++, and I eventually
want to remove the XPIDL definition, because it isn't accurate for C++,
so in this patch I'll make a specific one for Rust, so the code is a
little easier to read.

Differential Revision: https://phabricator.services.mozilla.com/D159322
2022-10-17 16:09:21 +00:00
Andrew McCreight
f5c69690d6 Bug 1792920, part 2 - Fix the type of the refcount argument for NS_LogAddRef and NS_LogRelease in Rust. r=xpcom-reviewers,nika
The type of the refcount argument to these functions is the C++ type
nsrefcnt, which is actually uintptr_t. This is different from the
definition of nsrefcnt in XPIDL which is currently being used. These
functions are not actually defined in XPIDL, and also uintptr_t
can't be expressed in XPIDL, so let's just change it to the type it
really is in Rust, usize. The goal of the patch is to eliminate
some uses of nsrefcnt from Rust.

Differential Revision: https://phabricator.services.mozilla.com/D159321
2022-10-17 16:09:20 +00:00
Andrew McCreight
cdd79677c6 Bug 1794645 - Use usize for refcounting non-atomic Rust XPCOM objects. r=nika
This matches the implementation of refcounting in C++ XPCOM objects.
We'll end up crashing if the refcount being returned is too large.

Change inc() and dec() to use try_into instead of as. This will change
the behavior because we'll crash if the value is too large instead of
silently truncating the return value, which might be worse because few
callers actually use the return value, but is unlikely to matter.

Also, use a more precise return type for the get() methods. It is only
used by Rust code, so there's no need to be compatible with
nsISupports. I made that change here to avoid needing to add a coercion
from usize to nsrefcnt.

Part of my goal with this patch is to eliminate an unnecessary use of
nsrefcnt from Rust.

Differential Revision: https://phabricator.services.mozilla.com/D159124
2022-10-13 14:53:08 +00:00
Nika Layzell
3202b3d09e Bug 1789902 - Part 3: Stop generating rust bindings for Services.py, r=xpcom-reviewers,barret
Differential Revision: https://phabricator.services.mozilla.com/D156892
2022-09-13 13:47:14 +00:00
Nika Layzell
3d9a6d0374 Bug 1789902 - Part 2: Use XPCOM static components instead of Services in Rust, r=xpcom-reviewers,necko-reviewers,barret,valentin
Differential Revision: https://phabricator.services.mozilla.com/D156891
2022-09-13 13:47:13 +00:00
Nika Layzell
2d7346701a Bug 1789902 - Part 1: Support accessing XPCOM static components from Rust, r=xpcom-reviewers,barret
This will allow us to replace some of the uses of Services.py with the
non-deprecated static components getters.

Differential Revision: https://phabricator.services.mozilla.com/D156890
2022-09-13 13:47:13 +00:00
Mike Hommey
e3d1d71728 Bug 1789509 - Use drop(Box::from_raw). r=xpcom-reviewers,nika
As of rustc 1.64, Box::from_raw is #[must_use].

Differential Revision: https://phabricator.services.mozilla.com/D156599
2022-09-07 20:50:15 +00:00
Nika Layzell
4011409c5d Bug 1783282 - Use a custom attribute instead of derive for implementing xpcom interfaces in rust, r=xpcom-reviewers,necko-reviewers,dragana,barret
Differential Revision: https://phabricator.services.mozilla.com/D153801
2022-08-18 13:57:35 +00:00
Nika Layzell
706cf2f2fa Bug 1782765 - Fix nullability of arrays of interfaces in Rust, r=xpcom-reviewers,necko-reviewers,mccr8,valentin
When generating code for arrays of interfaces from the rust-xpidl
compiler, the type was declared incorrectly as ThinVec<RefPtr<T>>
instead of ThinVec<Option<RefPtr<T>>> meaning that null values in the
array would be handled incorrectly.

This patch fixes this code generation mistake and updates crates using
the interface to handle null values correctly.

Differential Revision: https://phabricator.services.mozilla.com/D153485
2022-08-11 17:53:48 +00:00
Nika Layzell
c1e984d0c6 Bug 1779326 - Handle a few more native types in rust-xpidl, r=xpcom-reviewers,kmag
This makes the logic for the rust type line up a bit more with the C++
logic for existing types, and adds support for 'char' and 'char16_t'
native types (for 'charPtr').

This specifically enables `nsIInputStream::Read` to be used from Rust.

Differential Revision: https://phabricator.services.mozilla.com/D152715
2022-07-27 14:09:52 +00:00
Butkovits Atila
99f074b50f Backed out changeset d4dae48f386a (bug 1779326) for causing build bustages. CLOSED TREE 2022-07-27 02:28:37 +03:00
Nika Layzell
155b049ad5 Bug 1779326 - Handle a few more native types in rust-xpidl, r=xpcom-reviewers,kmag
This makes the logic for the rust type line up a bit more with the C++
logic for existing types, and adds support for 'char' and 'char16_t'
native types (for 'charPtr').

This specifically enables `nsIInputStream::Read` to be used from Rust.

Differential Revision: https://phabricator.services.mozilla.com/D152715
2022-07-26 23:12:58 +00:00
Mike Hommey
df77ed0752 Bug 1774501 - Update to env_logger 0.9 in various in-tree crates. r=nbp,keeler,xpcom-reviewers,rhunt,nika
Differential Revision: https://phabricator.services.mozilla.com/D149453
2022-06-16 20:44:03 +00:00
Mike Hommey
7ce663eb08 Bug 1772048 - Update rustc_version and semver crates. r=emilio,webdriver-reviewers,kinetik,whimboo
semver 1.0 doesn't and won't support Clone on semver::Error[1], so we
convert the mozversion error type to store the string version of the
error, which is an incompatible change requiring a version bump on the
crate.

1. https://github.com/dtolnay/semver/pull/280

Differential Revision: https://phabricator.services.mozilla.com/D147825
2022-06-07 10:01:32 +00:00
Andrew McCreight
2b23a6e593 Bug 1767291, part 1 - Remove aggregate arguments to nsComponentManager's create instance methods. r=xpcom-reviewers,nika
I also took the opportunity to mark nsIComponentManager as builtinclass,
and I marked the two methods I changed as noscript because clearly they
aren't being called by JS, so it seems like it should be avoided.

I also fixed some clang-tidy issues.

Based on a patch by froydnj.

Differential Revision: https://phabricator.services.mozilla.com/D145250
2022-05-02 21:00:46 +00:00
Garrett Bourg
df70195396 Bug 1747544 - Fix lint warning on string comparison in bench.rs. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D141517
2022-03-31 17:40:29 +00:00
Randell Jesup
fcaf70841e Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 18:47:08 +00:00
Noemi Erli
2390d257e6 Backed out changeset 12a59e5a50bf (bug 1207753) for causing build bustage CLOSED TREE 2022-03-16 18:32:51 +02:00
Randell Jesup
4b033a5256 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 16:16:14 +00:00
Butkovits Atila
927ad62c6a Backed out changeset a68ee4b09f92 (bug 1207753) for causing Hazard bustages. CLOSED TREE 2022-03-16 14:38:14 +02:00
Randell Jesup
7d4b5fae04 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 12:01:14 +00:00
Nika Layzell
e5ccabd06f Bug 1746533 - Part 2: Use the fallible Poll implementation in moz_task, r=emilio
This should avoid crash issues caused by background task queues being destroyed
and dropping their Runnables.

Differential Revision: https://phabricator.services.mozilla.com/D135410
2022-01-26 15:36:14 +00:00
Mike Hommey
8fd03d2f80 Bug 1751331 - Use the mozbuild crate in nserror. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D136567
2022-01-25 21:29:53 +00:00
Mike Hommey
e467585271 Bug 1751331 - Use the mozbuild crate in xpcom. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D136565
2022-01-25 21:29:52 +00:00
criss
592389ca2d Backed out 10 changesets (bug 1751331) for causing bustages. CLOSED TREE
Backed out changeset 5ce212465a26 (bug 1751331)
Backed out changeset 14d62b8ffa5a (bug 1751331)
Backed out changeset 76f46bd9afa1 (bug 1751331)
Backed out changeset 147faaad046f (bug 1751331)
Backed out changeset f85b049d12f9 (bug 1751331)
Backed out changeset 16d8d3f8378b (bug 1751331)
Backed out changeset 1cd9386a3927 (bug 1751331)
Backed out changeset 20faacba6db6 (bug 1751331)
Backed out changeset 7d17f75bcb38 (bug 1751331)
Backed out changeset 28b9aab1f174 (bug 1751331)
2022-01-25 13:00:25 +02:00
Mike Hommey
209e7cc15f Bug 1751331 - Use the mozbuild crate in nserror. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D136567
2022-01-25 09:03:05 +00:00
Mike Hommey
5fa0297527 Bug 1751331 - Use the mozbuild crate in xpcom. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D136565
2022-01-25 09:03:04 +00:00
Nika Layzell
e8f83d2043 Bug 1748718 - Part 3: Remove now-unnecessary xpidl constant casts, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D135166
2022-01-07 20:35:15 +00:00
Nika Layzell
3e323b7d7a Bug 1739727 - Part 2: Improve rust async support in moz_task, r=emilio
This patch contains changes to moz_task to improve it's support for
async execution on multiple threads. Unlike the previous executor
implementation, this new implementation reduces the amount of unsafe
code substantially by depending on the async-task crate
(https://crates.io/crates/async-task) for the core task implementation.
This adds a few additional features:

 * Both local (no Send bound) and non-local (with Send bound) execution support,
 * Support for spawning on arbitrary nsIEventTargets or the background task pool,
 * Returned Task objects from runnables which may be .await-ed on or detach()-ed,
 * Support for spawning with the NS_DISPATCH_EVENT_MAY_BLOCK flag set,
 * Automatic use of NS_DISPATCH_AT_END when required,
 * Support for specifying the runnable priority for runnables.

There are also some correctness improvements, and exposed a better API
for dispatching normal runnable functions to background threads.

After these changes the TaskRunnable API should no longer be necessary.
It is re-implemented on top of the executor and kept in-place to avoid
rewriting all consumers.

Differential Revision: https://phabricator.services.mozilla.com/D130705
2021-12-07 20:01:41 +00:00
Nika Layzell
19317ab22a Bug 1739727 - Part 1: Vendor the async-task library, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D130704
2021-12-07 20:01:41 +00:00
Nika Layzell
2dad541514 Bug 1741734 - Fix rust xpcom_macros future-compat warning, r=xpcom-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D131444
2021-11-18 00:48:53 +00:00
Niklas Goegge
21b2b112f4 Bug 1724152: Replace GkRustUtils::GenerateUUID with nsID::GenerateUUID. r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D129633
2021-11-04 08:55:46 +00:00
Norisz Fay
51e8153e60 Backed out 5 changesets (bug 1736459) for causing Windows crashes (bug 1738034) a=backout
Backed out changeset c934eeb21692 (bug 1736459)
Backed out changeset 0b2da7db414c (bug 1736459)
Backed out changeset 798893f69a02 (bug 1736459)
Backed out changeset 2a8f412c4d08 (bug 1736459)
Backed out changeset 59eeaeafdf67 (bug 1736459)
2021-10-27 16:02:24 +03:00
Mike Hommey
9f1048850f Bug 1736459 - Don't initialize env_logger when stdout/stderr don't exist on Windows. r=xpcom-reviewers,nika
This works around a regression in rust 1.56's libstd.

Differential Revision: https://phabricator.services.mozilla.com/D129571
2021-10-26 23:11:39 +00:00
Mike Hommey
ae874d3dfc Bug 1733308 - Forbid sources files with the same base name. r=firefox-build-system-reviewers,andi
While the build system could be improved to actually support those
cases, because of all the legacy things involved, it would be a lot more
work for a low reward.

Instead, we forbid them, which allows to remove the non-unified builds
exception in xpcom/rust/gtest.

Differential Revision: https://phabricator.services.mozilla.com/D127035
2021-10-01 01:49:16 +00:00
Andi-Bogdan Postelnicu
2fc4f70e9b Bug 1725145 - Preparation for the hybrid build env. r=necko-reviewers,firefox-build-system-reviewers,valentin,glandium
Automatically generated path that adds flag `REQUIRES_UNIFIED_BUILD = True` to `moz.build`
when the module governed by the build config file is not buildable outside on the unified environment.

This needs to be done in order to have a hybrid build system that adds the possibility of combing
unified build components with ones that are built outside of the unified eco system.

Differential Revision: https://phabricator.services.mozilla.com/D122345
2021-08-25 10:46:17 +00:00
Zibi Braniecki
750e9a5da5 Bug 1613705 - [localization] part11: Fix XPCOM future_task polling assert. r=nika
Depends on D105586

Differential Revision: https://phabricator.services.mozilla.com/D114508
2021-08-03 16:25:14 +00:00
Butkovits Atila
949da905e7 Backed out 19 changesets (bug 1613705) for causing build bustages complaining about Document.cpp. CLOSED TREE
Backed out changeset 2ee1091dd20d (bug 1613705)
Backed out changeset d377afc0b09f (bug 1613705)
Backed out changeset de9d4378f0ac (bug 1613705)
Backed out changeset 9843372abb6e (bug 1613705)
Backed out changeset 5fc5918e5905 (bug 1613705)
Backed out changeset a7aeae7afd49 (bug 1613705)
Backed out changeset 5d61617a5402 (bug 1613705)
Backed out changeset 85bf98573899 (bug 1613705)
Backed out changeset 175af8a1b8c2 (bug 1613705)
Backed out changeset 93fcb23d7898 (bug 1613705)
Backed out changeset 595529cd906f (bug 1613705)
Backed out changeset 9f3e2963d925 (bug 1613705)
Backed out changeset 442289058933 (bug 1613705)
Backed out changeset fc3b9acb0e81 (bug 1613705)
Backed out changeset 408983c64f7f (bug 1613705)
Backed out changeset 08b637fc3fcd (bug 1613705)
Backed out changeset 6ef0aafd2db0 (bug 1613705)
Backed out changeset d88b294e0a5e (bug 1613705)
Backed out changeset e6bebff87544 (bug 1613705)
2021-08-03 12:36:01 +03:00
Zibi Braniecki
e4f37c5029 Bug 1613705 - [localization] part11: Fix XPCOM future_task polling assert. r=nika
Depends on D105586

Differential Revision: https://phabricator.services.mozilla.com/D114508
2021-08-03 05:52:04 +00:00
Cosmin Sabou
3564c330b3 Backed out 11 changesets (bug 1613705) for several test failures. CLOSED TREE
Backed out changeset 4e690882b6af (bug 1613705)
Backed out changeset 302e7a75affc (bug 1613705)
Backed out changeset 626b40e3aad1 (bug 1613705)
Backed out changeset 1cbab987bb7d (bug 1613705)
Backed out changeset 2213917abb30 (bug 1613705)
Backed out changeset c89aa0375690 (bug 1613705)
Backed out changeset 6466027c5767 (bug 1613705)
Backed out changeset 6c188c4b38bf (bug 1613705)
Backed out changeset 8d0c087b9896 (bug 1613705)
Backed out changeset 3404fd6725f1 (bug 1613705)
Backed out changeset c9cfbba15d90 (bug 1613705)
2021-08-02 14:04:29 +03:00
Zibi Braniecki
9bfbca88d8 Bug 1613705 - [localization] part11: Fix XPCOM future_task polling assert. r=nika
Depends on D105586

Differential Revision: https://phabricator.services.mozilla.com/D114508
2021-08-02 09:54:11 +00:00
Nika Layzell
40a0ecc65f Bug 1709935 - Support XPCOM refcount logging with rust-xpcom, r=xpcom-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D115086
2021-05-19 17:29:23 +00:00
Nika Layzell
3a56bcbaeb Bug 1709227 - Include offset information in rust-xpcom vtables, r=mccr8
In the Itanium C++ ABI VTables contain extra fields before the virtual function
pointer list for RTTI information, and these fields are not eliminated even
when RTTI is disabled using -fno-rtti. The two relevant fields for rust-xpcom's
vtables are the "offset to top" field, which contains the displacement to the
top of the object from the corresponding vtable pointer as a `ptrdiff_t`
(`isize`), and the "typeinfo pointer" field which points to the typeinfo object
and is null when building with -fno-rtti. The VTable pointer points after these
fields to the beginning of the virtual function pointer list.

While these extra fields would generally not be accessed in -fno-rtti
situations, gcc and clang still support `dynamic_cast<void*>` even when
-fno-rtti is passed, meaning that the "offset to top" field should be present.

Although I was unable to find documentation for the C++ ABI used on Darwin, it
appears to behave the same as the Itanium C++ ABI when it comes to VTable
layout.

In order to include these fields in the manual vtables built by the rust-xpcom
macros, a `&'static VTableExtra<VTableType>` is used instead of directly using
the vtable type, and the vtable reference stored in the struct is offset into
the allocation.

As the only platform I know of to not include these extra fields is Windows,
they are generated on all non-Windows platforms.

Differential Revision: https://phabricator.services.mozilla.com/D115085
2021-05-18 20:56:40 +00:00
Jens Stutte
05581ddca4 Bug 1678330: Ensure nested SpinEventLoopUntil(OrShutdown) calls are traceable to the originating source in case of crash. r=nika,extension-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D106839
2021-03-02 22:11:58 +00:00
Cosmin Sabou
b2eb620ed0 Backed out changeset 03cae7800b41 (bug 1678330) for mochitest plain failures on test_window_open_discarded_bc.html. CLOSED TREE 2021-03-02 20:18:21 +02:00
Jens Stutte
a0af9ea0a4 Bug 1678330: Ensure nested SpinEventLoopUntil(OrShutdown) calls are traceable to the originating source in case of crash. r=nika,extension-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D106839
2021-03-02 15:15:20 +00:00
Dan Glastonbury
d22631c4d7 Bug 1679094 - Resolve dom::Promise from Rust. r=nika
A very limited interface to allow resolving dom::Promises from Rust code by
marshaling values via nsIVariant.

Differential Revision: https://phabricator.services.mozilla.com/D97905
2020-12-12 02:55:49 +00:00
Csoregi Natalia
3b68bf27c8 Backed out changeset cccdff68c790 (bug 1679094) for causing build bustage. CLOSED TREE 2020-12-12 03:18:44 +02:00
Dan Glastonbury
27752e15a3 Bug 1679094 - Resolve dom::Promise from Rust. r=nika
A very limited interface to allow resolving dom::Promises from Rust code by
marshaling values via nsIVariant.

Differential Revision: https://phabricator.services.mozilla.com/D97905
2020-12-12 00:47:23 +00:00
Dan Glastonbury
6c151a3362 Bug 1679095 - Extend nsstring to support creating void strings. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D97904
2020-12-12 00:43:30 +00:00