Commit Graph

55 Commits

Author SHA1 Message Date
Nicholas Nethercote
b9e071e2e8 Bug 1481998 - Make mozilla::Hash{Map,Set}'s entry storage allocation lazy. r=luke,sfink
Entry storage allocation now occurs on the first lookupForAdd()/put()/putNew().
This removes the need for init() and initialized(), and matches how
PLDHashTable/nsTHashtable work. It also removes the need for init() functions
in a lot of types that are built on top of mozilla::Hash{Map,Set}.

Pros:

- No need for init() calls and subsequent checks.

- No memory allocated for empty tables, which are not that uncommon.

Cons:

- An extra branch in lookup() and lookupForAdd(), but not in put()/putNew(),
  because the existing checkOverloaded() can handle it.

Specifics:

- Construction now can take a length parameter.

- init() is removed. Explicit length-setting, when necessary, now occurs in the
  constructors.

- initialized() is removed.

- capacity() now returns zero when the entry storage is absent.

- lookupForAdd() is no longer `const`, because it can instantiate the storage,
  which requires modifications.

- lookupForAdd() can now return an invalid AddPtr in two cases:

  - old: hashing failure (due to OOM in the hasher)

  - new: OOM while instantiating entry storage

  The existing failure handling paths for the old case work for the new case.

- clear(), finish(), and clearAndShrink() are replaced by clear(), compact(),
  and reserve(). The old compactIfUnderloaded() is also removed.

- Capacity computation code is now in its own functions, bestCapacity() and
  hashShift(). setTableSizeLog2() is removed.

- uint32_t is used throughout for capacities, instead of size_t, for
  consistency with other similar values.

- changeTableSize() now takes a capacity instead of a deltaLog2, and it can now
  handle !mTable.

Measurements:

- Total source code size is reduced by over 900 lines. Also, lots of existing
  lines got shorter (i.e. two checks were reduced to one).

- Executable size barely changed, down by 2 KiB on Linux64. The extra branches
  are compensated for by the lack of init() calls.

- Speed changed negligibly. The instruction count for Bench_Cpp_MozHash
  increased from 2.84 billion to 2.89 billion but any execution time change was
  well below noise.
2018-08-10 18:00:29 +10:00
Nicholas Nethercote
f32766d3de Bug 1478879 - Remove Range/Enum use in Bench.cpp. r=froydnj
--HG--
extra : rebase_source : 0fabb074eef422e55ad79b68076d766674476ddc
2018-07-31 10:31:00 +10:00
Nicholas Nethercote
997e790c3f Bug 1477626 - Use mozilla::HashTable instead of js::HashTable in Bench.cpp. r=froydnj
MozReview-Commit-ID: 4P5L9Kdkiuu

--HG--
extra : rebase_source : 3311757797cbc7c699c39b5ee583910c1924cfb1
2018-07-26 20:16:00 +10:00
Nika Layzell
345a0af828 Bug 1471726 - Part 1: Correct codegen for XPIDL arrays of JSVals, r=mccr8 2018-07-31 17:52:58 -04: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
3bb3fd9a2a Bug 1471726 - Part 1: Correct codegen for XPIDL arrays of JSVals, r=mccr8 2018-07-30 11:27:49 -04:00
Nicholas Nethercote
e6f8df84ad Bug 1477622 - Add microbenchmarks measuring hash table performance. r=froydnj
--HG--
extra : rebase_source : 2d76bfcb862b3b690ea8db2b5b007dde2a90f914
2018-07-24 10:38:43 +10:00
Makoto Kato
d7238e0835 Bug 1453551 - Don't use i8 as c_char in xpcom-gtest. r=mystor
c_char isn't i8 on some platforms such as Android/arm, so we should use c_char
instead.

MozReview-Commit-ID: 486BCGvYAE0

--HG--
extra : rebase_source : 0ee9d510de5cd8ab20daa1709c7425ca95dc8793
2018-04-12 15:28:08 +09:00
arthur.iakab
bbca7c7700 Merge mozilla-central to inbound 2018-04-11 01:17:20 +03:00
Nika Layzell
944ff7f16d Bug 1444151 - Part 2: Make Rust's RefPtr::forget safe, r=froydnj 2018-04-10 17:49:49 -04:00
Nika Layzell
06d6bb6d34 Bug 1429816 - Part 1: Bump syn and quote in xpcom. r=froydnj,mystor
--HG--
extra : rebase_source : 46d9431193b07658534bd5489477aadce7398e1a
2018-04-10 01:48:33 +02:00
Matt Brubeck
61e9479fbb Bug 1449034 - Update Rust crates to use lazy_static 1.0. r=ted
MozReview-Commit-ID: 4u4OQFBaURV

--HG--
extra : rebase_source : f7a4f89d275777a036ca08dad42b0a17e9c7eb8e
2018-03-26 15:12:56 -07:00
L. David Baron
1da1c4f2be Bug 1448138 - Rename string DataFlags::SHARED to REFCOUNTED to make it clearer to those reading the code. r=erahm
MozReview-Commit-ID: 1mJuwY5dQkj

--HG--
extra : transplant_source : %B8%97%C2%AAa%A6%3D%E3%AC%9C%C1%15%99%FE%94%1A%E2K%81%F1
2018-03-23 17:31:37 -07:00
Nika Layzell
80fab95acc Bug 1433015 - Part 2: Change the xpcom test to use the observer service, r=froydnj
MozReview-Commit-ID: JSnMIvu97aT
2018-01-30 15:45:21 -05:00
Nika Layzell
d3046cbdb8 Bug 1433015 - Part 1: Fix a typo in xpcom_macros, r=froydnj
MozReview-Commit-ID: 3f1wsWgQfpG
2018-01-30 15:45:21 -05:00
Nika Layzell
281f61ed94 Bug 1293362 - Part 8: Add some tests for using xpcom interfaces from rust code, r=froydnj
MozReview-Commit-ID: 1b6tfHtyDWf
2018-01-23 17:27:33 -05:00
Nika Layzell
98ea82060d Bug 1293362 - Part 7: Expose the nsComponentManager static interfaces to rust code, r=froydnj
MozReview-Commit-ID: D4kvNFgmIpH
2018-01-23 17:27:32 -05:00
Nika Layzell
3db03efd58 Bug 1293362 - Part 6: Expose the cached XPCOM service getters to rust code, r=froydnj
MozReview-Commit-ID: 5oy4wVaaVeP
2018-01-23 17:27:30 -05:00
Nika Layzell
a8351a819f Bug 1293362 - Part 5: Allow implementing xpcom interfaces from rust code with a custom derive, r=froydnj
MozReview-Commit-ID: 90Yv3H40jZW
2018-01-23 17:27:28 -05:00
Nika Layzell
c33284aec0 Bug 1293362 - Part 4: Generate runtime bindings for calling xpcom methods from rust, r=froydnj
MozReview-Commit-ID: K37KyHkKsSl
2018-01-23 17:27:26 -05:00
Nika Layzell
94e3d3cb1b Bug 1293362 - Part 2: Add skeleton crates for xpcom bindings, r=froydnj
MozReview-Commit-ID: H5nxsk4cg2E
2018-01-23 17:27:23 -05:00
Nika Layzell
1b1ba4879a Bug 1403213 - Move nsstring into servo/support/gecko/nsstring, r=froydnj
MozReview-Commit-ID: 8ucStGkxmj7

--HG--
rename : xpcom/rust/nsstring/gtest/Test.cpp => xpcom/rust/gtest/nsstring/Test.cpp
rename : xpcom/rust/nsstring/gtest/test.rs => xpcom/rust/gtest/nsstring/test.rs
extra : rebase_source : 509a2ab1aa569e8f3ef0955dcdfa36b53ce5e234
2017-10-23 15:37:25 -04:00
Sebastian Hengst
5d671ee296 Backed out changeset 74c58b336d30 (bug 1403213) for referencing non-existing xpcom/rust/gtest/moz.build in xpcom/moz.build. r=backout on a CLOSED TREE
--HG--
extra : amend_source : 7c25d872785312b81c4a94ef32de025b38642f54
2017-10-20 21:30:36 +02:00
Nika Layzell
a4927e2417 Bug 1403213 - Move nsstring into servo/support/gecko/nsstring, r=froydnj
MozReview-Commit-ID: FmKtJxSCdYc
2017-10-20 12:04:30 -07:00
Nika Layzell
4146e6b110 Bug 1377351 - Part 3: Expose nsA[C]String::Assign(nsA[C]String&&) overload as take_from to rust, r=froydnj
MozReview-Commit-ID: 4YNPi3iRo78
2017-10-18 13:00:15 -04:00
Nicholas Nethercote
9e0714dd26 Bug 1403506 - Remove nsTFixedString<T>. r=erahm.
(patch is actually r=erahm,mystor)

nsTFixedString<T> is only used as a base class for nsTAutoStringN<T, N>, so
this patch merges the former into the latter, cutting some code and simplifying
the string class hierarchy.

Because the "Fixed" name is now gone, the patch also renames
StringDataFlags::FIXED as INLINE and ClassDataFlags::FIXED as INLINE.

The patch also removes nsFixed[C]String and ns_auto_[c]string! from Rust code
because nsAutoString can't be implemented directly in Rust due to its move
semantics. There were only two uses of ns_auto_string! outside of tests so this
seems like a minor loss.

MozReview-Commit-ID: 8ntximghiut

--HG--
extra : rebase_source : f36edbae0553adcfee356fb8b311097ff7424786
2017-09-27 20:19:33 +10:00
Michael Layzell
8b222e2445 Bug 1403545 - Stop allocating in fmt::Write for nsA[C]String, r=froydnj
MozReview-Commit-ID: 6EOJ8QBrwXK
2017-09-27 12:19:29 -07:00
Michael Layzell
8e9f0c50e6 Bug 1383411 - Introduce a distinction between nsCStr<'a> and nsCString, r=froydnj 2017-09-25 18:14:43 -04:00
L. David Baron
eb59a21402 Bug 1381080 patch 1 - Add ClassFlags::NULL_TERMINATED to strings that require null-termination. r=erahm
This is needed for patch 4.

MozReview-Commit-ID: 5ikQFIL9O0i

--HG--
extra : transplant_source : %88%80%E3%04%11%7E%7F%A4%7E%15%1B%1A%84%E2%13%3E%F6%E8%2A%1C
2017-07-20 15:46:58 -07:00
L. David Baron
715cb90c8e Bug 1343715 - Split nsTSubstring::mFlags into separate variables for class and data flags (rust bindings changes). r=mystor
Thanks to Manish for help in reflecting this idiomatically in rust.

MozReview-Commit-ID: 8tB7vsc5yxc

--HG--
extra : transplant_source : F%87%16%82.P%BD%F3%B1%A4%19%BA%F0%3DQ%F6%ED%BD%95%60
2017-07-10 12:23:11 -07:00
Ralph Giles
f56cb16c14 Bug 1336153 - Remove MOZ_RUST. r=ted
We now have code that unconditionally requires the rust
compiler and are committed to adding more. Remove this
last vestige of conditional support.

MozReview-Commit-ID: EK6FBnAbR

--HG--
extra : rebase_source : 6efda10a74f9ca0482304c2b1ffe6941e42138f8
2017-05-09 11:36:13 -07:00
Henri Sivonen
778981d9cc Bug 1359353 - Make the backing buffers of XPCOM strings available as mutable slices. r=mystor.
MozReview-Commit-ID: KeJ2Qb3R5ET

--HG--
extra : rebase_source : 175a6dcac973d72a167a4e0e8d6d7e3c695203c8
2017-04-25 13:17:48 +03:00
Michael Layzell
a6f6b4a390 Bug 1320179 - Part 4: MOZ_OBJDIR->MOZ_TOPOBJDIR and update m-c-changes.patch for protobuf changes, r=fitzgen
MozReview-Commit-ID: EPhkF350sGY
2017-04-06 18:37:31 -04:00
Michael Layzell
981693a30f Bug 1320179 - Part 2: Add the nserror rust crate and generate NS_ERROR codes, r=froydnj
MozReview-Commit-ID: FFU6WfEqev
2017-04-06 18:37:25 -04:00
Wes Kocher
1f91b9d155 Backed out 4 changesets (bug 1320179) for causing merge conflicts a=backout
Backed out changeset b8aa677f7452 (bug 1320179)
Backed out changeset 9e2f77570128 (bug 1320179)
Backed out changeset 470d8143b350 (bug 1320179)
Backed out changeset ea4f1b3cc7b1 (bug 1320179)
2017-04-06 15:29:24 -07:00
Michael Layzell
c33097aeaa Bug 1320179 - Part 4: MOZ_OBJDIR->MOZ_TOPOBJDIR and update m-c-changes.patch for protobuf changes, r=fitzgen
MozReview-Commit-ID: EPhkF350sGY
2017-04-06 17:37:13 -04:00
Michael Layzell
df411f4313 Bug 1320179 - Part 2: Add the nserror rust crate and generate NS_ERROR codes, r=froydnj
MozReview-Commit-ID: FFU6WfEqev
2017-04-06 17:22:08 -04:00
emilio+bugs@crisal.io
92f1a57200 Bug 1348398: Keep deriving debug in StringRepr. 2017-03-24 15:14:30 -04:00
Michael Layzell
2be5900b6b Bug 1347224 - Part 1: Expose fallible methods on the rust ns[C]String bindings, r=froydnj
This patch adds a series of fallible methods for the rust ns[C]String
bindings, as well as the `set_length` method, which is the same as the
`SetLength` method in C++. `set_length` is marked as unsafe.

The decision was made to make the fallible methods seperate from the
infallible methods, and to use seperate Rust->C++ bindings for each of
them, rather than only binding the fallible bindings, and unwrapping
them in rust-land. This is to try to match the C++ API as closely as
possible, and to ensure that the behavior matches.

MozReview-Commit-ID: FkSomkFUFGD
2017-03-20 14:40:45 -04:00
Emilio Cobos Álvarez
30bd5679fd Bug 1344209: Handle empty strings gracefully in rust nsString bindings. r=mystor
MozReview-Commit-ID: 5lI8LXwZIML
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-03-03 17:49:37 +01:00
Michael Layzell
59bb3b9927 Bug 1339218 - Comment wording fixup, r=me
MozReview-Commit-ID: 8T0ibqe17Ru
2017-02-15 12:10:46 -05:00
Michael Layzell
58cab3c905 Bug 1339218 - Re-introduce the ns[C]StringRepr type for use in bindings with custom destructor logic, r=froydnj
MozReview-Commit-ID: 3VUWFA5tX1L
2017-02-15 12:02:54 -05:00
Michael Layzell
c3093f17b8 Bug 1316696 - Eliminate ns{Fixed,}{C,}StringRepr from the rust bindings, r=froydnj
MozReview-Commit-ID: AMwAUq82vMo
2017-02-08 14:17:42 -05:00
Emilio Cobos Álvarez
c7cae408eb Bug 1334579: Integrate nsstring bindings with leak logging. r=mystor
MozReview-Commit-ID: 368DwwuaMqr

--HG--
extra : rebase_source : e8e2149ca7169556df668615d654423ae9080097
2017-01-27 21:12:22 +01:00
Hiroyuki Ikezoe
a4cf573971 Bug 1330824 - Add truncate for nsAString and nsACString. r=mystor
MozReview-Commit-ID: 2ND5ra3buxI
2017-01-14 15:02:14 +09:00
Michael Layzell
92086b33cd Backout of Bug 1316696 as we don't want to require rustc 1.13 yet, a=froydnj 2016-11-28 14:19:12 -05:00
Michael Layzell
a2ede4255a Bug 1316696 - Eliminate ns{Fixed,}{C,}StringRepr from the rust bindings, r=froydnj
MozReview-Commit-ID: AMwAUq82vMo
2016-11-24 13:48:38 -05:00
Michael Layzell
29905acb08 Bug 1319083 - Relax the Sized constraint on nsA[C]String::assign/append, r=froydnj
MozReview-Commit-ID: Js5GOrnqtsg
2016-11-21 10:41:48 -05:00
Michael Layzell
fb03faf0e0 Bug 1316964 - Make the append and assign methods on the rust nsstring types more generic, r=froydnj
MozReview-Commit-ID: 5y30BnUDKsT
2016-11-15 17:01:36 -05:00
Kyle Machulis
05c2031bce Bug 1313160 - Add From<&'a String> and From<&'a Vec<u8>> conversions for rust nsstring lib; r=mystor
MozReview-Commit-ID: EBHFA8sjnM6
2016-10-27 13:07:50 -07:00