Commit Graph

776 Commits

Author SHA1 Message Date
Jon Coppeard
b89abe6790 Bug 1785804 - Part 2: Remove tracing name context and pass name through the trace methods r=sfink
One point of difference between the DoMarking fast path and other tracers is
handling the edge name. Passing this through to the concrete tracer and
handling it there removes this differemce.

Eventually we should be able to inline some of these these calls at which point
it should get optimsed away for tracers that ignore it.

Depends on D156559

Differential Revision: https://phabricator.services.mozilla.com/D156560
2022-09-07 09:49:58 +00:00
Butkovits Atila
be3e9ca06c Backed out 7 changesets (bug 1785804) for causing reftest crashes at @ mozilla::dom::Promise::MaybeReject(nsresult). CLOSED TREE
Backed out changeset 31ef32f519f2 (bug 1785804)
Backed out changeset 361dc2862d74 (bug 1785804)
Backed out changeset 27771c8d9865 (bug 1785804)
Backed out changeset f9e864cd34a6 (bug 1785804)
Backed out changeset a115e9eaffee (bug 1785804)
Backed out changeset 271975a555d0 (bug 1785804)
Backed out changeset 55855c5ad184 (bug 1785804)
2022-09-07 14:09:56 +03:00
Jon Coppeard
e418b6997d Bug 1785804 - Part 2: Remove tracing name context and pass name through the trace methods r=sfink
One point of difference between the DoMarking fast path and other tracers is
handling the edge name. Passing this through to the concrete tracer and
handling it there removes this differemce.

Eventually we should be able to inline some of these these calls at which point
it should get optimsed away for tracers that ignore it.

Depends on D156559

Differential Revision: https://phabricator.services.mozilla.com/D156560
2022-09-07 09:49:58 +00:00
Edgar Chen
cdad5df9d3 Bug 1776790 - Stop exposing the length of argument list of ChromeOnly constructor to non-chrome context; r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D152467
2022-07-27 19:28:55 +00:00
Andrew McCreight
3fc7fa2c02 Bug 1387334 - Don't call JS_DefineProfilingFunctions in CreateGlobal. r=peterv
In the modern age of the Gecko Profiler, surely nobody is using this.

Differential Revision: https://phabricator.services.mozilla.com/D148438
2022-06-22 15:54:16 +00:00
Kagami Sascha Rosylight
9d5386b0ce Bug 1769290 - Part 2: Apply mozilla-js-handle-rooted-typedef against dom/bindings r=edgar
Changes done by `./mach static-analysis check --checks="-*,mozilla-js-handle-rooted-typedef" --fix --header-filter=dom dom/bindings; ./mach clang-format --outgoing`.

Differential Revision: https://phabricator.services.mozilla.com/D146439
2022-05-18 08:43:09 +00:00
Kagami Sascha Rosylight
5bf1db4f71 Bug 1769290 - Part 1: Apply mozilla-js-handle-rooted-typedef against dom/streams r=smaug
Changes done by `./mach static-analysis check --checks="-*,mozilla-js-handle-rooted-typedef" --fix --header-filter=dom dom/streams; ./mach clang-format --outgoing`.

Differential Revision: https://phabricator.services.mozilla.com/D146329
2022-05-18 08:43:08 +00:00
Emilio Cobos Álvarez
9e02f38a2e Bug 1766909 - Wrap ObservableArray proxy on getter, rather than throwing. r=peterv
This will still prevent them from accessing stuff (.length will be
undefined, etc), but seems better than unexpectedly throwing. This fixes
the issue at hand at least.

With this patch, we reject length accesses here:

  https://searchfox.org/mozilla-central/rev/86c98c486f03b598d0f80356b69163fd400ec8aa/js/xpconnect/wrappers/XrayWrapper.cpp#229-233

Your call on whether this patch is enough as-is, or more work is needed.
Also your call on whether if more work is needed that needs to happen on
this bug or somewhere else.

I'm not sure what we'd need to do to support this more "properly",
presumably we'd need to add special XRay support to
ObservableArrayProxyHandler or so? Pointers (or patches of course ;))
welcome.

Also unsure about the setter situation, I _think_ it's fine not to throw
given the code I read, but please sanity-check.

Differential Revision: https://phabricator.services.mozilla.com/D145045
2022-05-12 07:36:03 +00:00
Edgar Chen
ebd37b74c8 Bug 1683281 - Part 5: Generate binding code for ObservableArray type; r=peterv
The highlevel architecture:
- Each observable array attribute has corresponding ES proxy exotic object stored
  in DOM reflector's reserved slot. It use the ObservableArrayProxyHandler as
  proxy handler which implements the behaviour defined in the spec.
- Each observable array exotic objects has 2 reserved slots:
  * one is to store the raw pointer of the interface, it is cleaned up when the
    DOM reflector is finalized. It is used to run the SetAlgorithm and
    DeleteAlgorithm defined in the spec.
  * one is to store the backing list used to store the indexed value. The additional
    properties are stored in the proxy target instead.

Depends on D112279

Differential Revision: https://phabricator.services.mozilla.com/D112280
2022-03-10 22:44:28 +00:00
Edgar Chen
f56fbb0c77 Bug 1683281 - Part 4: Add helper method to get ObservableArray backing object; r=peterv
Depends on D112278

Differential Revision: https://phabricator.services.mozilla.com/D112279
2022-03-10 22:44:28 +00:00
Jon Coppeard
d40ccf2be0 Bug 1757956 - Part 3: Rename JSFreeOp to JS::GCContext in the JS engine r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D140525
2022-03-10 08:40:03 +00:00
Jan de Mooij
dec8bffeb2 Bug 1754405 part 7 - Remove SYMBOL_TO_JSID. r=evilpie
Differential Revision: https://phabricator.services.mozilla.com/D138278
2022-02-13 12:01:46 +00:00
Jon Coppeard
6488ea1184 Bug 1744059 - Rename UnsafeTraceRoot to TraceRoot as it is not unsafe to use r=sfink,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D132969
2021-12-07 09:02:36 +00:00
Jon Coppeard
d89836b479 Bug 1693775 - Change CallbackTracer::onChild to pass GCCellPtr by value r=sfink,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D131142
2021-11-16 09:09:37 +00:00
Peter Van der Beken
41f13509b9 Bug 1726595 - WebIDL code generation for Promise returning callbacks doesn't handle abrupt completions correctly. r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D125531
2021-09-28 15:20:58 +00:00
André Bargull
d2bbf86876 Bug 1726123 - Part 5: Add missing "js/" includes outside of SM. r=arai
In preparation for the next part, add missing includes to "js/" public headers.

Differential Revision: https://phabricator.services.mozilla.com/D122843
2021-08-17 15:45:39 +00:00
Tom Schuster
67961ba46a Bug 1717279 - Remove JSID_IS_SYMBOL and JSID_TO_SYMBOL. r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D118287
2021-06-21 20:56:10 +00:00
Andi-Bogdan Postelnicu
1cf28e7475 Bug 1519636 - Reformat recent changes to the Google coding style. r=emilio
Updated with clang-format version 12.0.0 (taskcluster-KEgO7qdgQ8uaewA6NkRnRA)

Differential Revision: https://phabricator.services.mozilla.com/D115804
2021-05-24 15:08:47 +00:00
Peter Van der Beken
2ffa0654be Bug 1709695 - Only init PropertyInfos and sort IDs for resolving Xray properties once needed. r=nika
Most of the time, a lot of the WebIDL interfaces are never used with Xray wrappers.
We still always initialise the necessary PropertyInfo arrays whenever they're used
normally (not through Xray wrappers). I think we should postpone that initialisation
until we're actually going to use them with Xray wrappers.

Differential Revision: https://phabricator.services.mozilla.com/D114402
2021-05-07 13:57:24 +00:00
Tom Schuster
a2dce1438e Bug 1708698 - Use Maybe<PropertyDescriptor> for Xray resolveOwnProperty and a lot of related code. r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D113976
2021-05-07 12:29:05 +00:00
Dorel Luca
753e2506cf Backed out changeset d1070cff14c6 (bug 1709695) for Mochitest failures in dom/tests/mochitest/chrome/test_sandbox_bindings.xhtml. CLOSED TREE 2021-05-07 10:47:54 +03:00
Peter Van der Beken
ba1380d84b Bug 1709695 - Only init PropertyInfos and sort IDs for resolving Xray properties once needed. r=nika
Most of the time, a lot of the WebIDL interfaces are never used with Xray wrappers.
We still always initialise the necessary PropertyInfo arrays whenever they're used
normally (not through Xray wrappers). I think we should postpone that initialisation
until we're actually going to use them with Xray wrappers.

Differential Revision: https://phabricator.services.mozilla.com/D114402
2021-05-07 06:59:07 +00:00
Peter Van der Beken
d3d8dcf5f6 Bug 1688198 - Symbol.toStringTag is incorrectly defined on the global object, rather than on its prototype. r=edgar.
For [Global] WebIDL interfaces, properties from the property array are installed
on the object itself, instead of on the prototype. To fix the bug I changed how
we install the @@toStringTag property, instead of adding it in the property
array of every interface we'll now instead install the property directly in
CreateInterfacePrototypeObject, which is also a codesize win. This does mean
that we need to look up the value dynamically in XrayResolveOwnProperty (we
can't resolve it from the property array anymore), but luckily we can use
NamesOfInterfacesWithProtos for that.

Differential Revision: https://phabricator.services.mozilla.com/D113664
2021-05-07 06:58:31 +00:00
Peter Van der Beken
9b5b32ef7e Bug 1708497 - Stop generating identical ResolveOwnProperty/EnumerateOwnProperties implementations. r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D113827
2021-05-05 13:43:59 +00:00
Edgar Chen
70f3dbe892 Bug 1707721 - Fix the comment for BindingJSObjectCreator; r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D113414
2021-04-27 09:34:12 +00:00
Kagami Sascha Rosylight
20a3a7aaff Bug 1631581 - Part 4: Rename Unforgeable to LegacyUnforgeable r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D111212
2021-04-11 03:13:32 +00:00
Kagami Sascha Rosylight
76d2e42ae7 Bug 1631581 - Part 2: Rename NamedConstructor to LegacyFactoryFunction r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D111210
2021-04-11 03:13:31 +00:00
Sean Feng
daffde1ac2 Bug 1700391 - Remove the unused UnprivilegedJunkScopeOrWorkerGlobal() method r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D109514
2021-03-24 12:56:45 +00:00
Simon Giesecke
c153cfe233 Bug 1674080 - Add some required includes to the bindings generator. r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D95147
2021-03-11 13:38:31 +00:00
Jan de Mooij
32014a5271 Bug 1696860 - Remove prototype splicing code for the global object. r=iain
After the ObjectGroup removal changes, prototype splicing and SetPrototype are
equivalent in that both (only) trigger a shape change for the new proto.

Differential Revision: https://phabricator.services.mozilla.com/D107459
2021-03-10 14:06:28 +00:00
Chris Peterson
2d4ca059e8 Bug 1691889 - Replace MOZ_MUST_USE with [[nodiscard]] in dom/. r=peterv
The MOZ_MUST_USE macro is defined as clang's and gcc's nonstandard __attribute__((warn_unused_result)). Now that we compile as C++17 by default (bug 1560664), we can replace MOZ_MUST_USE with C++17's standard [[nodiscard]] attribute.

The [[nodiscard]] attribute must precede a function declaration's declaration specifiers (like static, extern, inline, or virtual). The __attribute__((warn_unused_result)) attribute does not have this order restriction.

Differential Revision: https://phabricator.services.mozilla.com/D107355
2021-03-10 08:19:25 +00:00
Ted Campbell
bf2062a7c7 Bug 1694040 - Use JSObject::is<ProxyObject> in more places. r=jandem
Also replace JSClass::isProxy with isProxyObject and clarify that the flag
indicates primarily that the JSObject is of type js::ProxyObject.

In DOM binding code, prefer checks for NativeObject rather than !ProxyObject
where that is what we really meant.

Differential Revision: https://phabricator.services.mozilla.com/D105884
2021-02-22 13:12:29 +00:00
Kagami Sascha Rosylight
9d5beaf069 Bug 1688335 - Remove .length and .name from namespaces r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D102830
2021-01-25 21:47:12 +00:00
Simon Giesecke
a61cef41e1 Bug 1673931 - Avoid including ScriptSettings.h from BindingUtils.h. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D96560

Depends on D96557
2020-11-23 16:10:52 +00:00
Simon Giesecke
6fac745ea4 Bug 1673931 - Remove dependency of BindingUtils.h on Document.h.
Differential Revision: https://phabricator.services.mozilla.com/D95048

Depends on D95047
2020-11-23 16:08:03 +00:00
Simon Giesecke
971b645fe3 Bug 1660470 - Add missing include directives/forward declarations. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D87865
2020-11-23 16:21:38 +00:00
Jon Coppeard
6550bf91b1 Bug 1668825 - Remove unused onChild return value r=sfink
This isn't used anywhere so we can make onChild void.

Differential Revision: https://phabricator.services.mozilla.com/D92257
2020-10-05 07:55:13 +00:00
Jon Coppeard
070d9db800 Bug 1668825 - Combine TracerKindTag and TracerKind r=sfink
Currently we have two different enums that determine the tracer kind. Combine
this into a single enum and move it to the JS namespace.

Differential Revision: https://phabricator.services.mozilla.com/D92253
2020-10-05 07:53:38 +00:00
Jeff Walden
6d5beafab1 Bug 1663365 - Move various Object-related functions to a new js/public/Object.h header. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D89333
2020-09-08 22:55:38 +00:00
Jeff Walden
49d77af36e Bug 1663365 - Move |JSJitInfo| out of jsfriendapi.h to its own experimental header. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D89332
2020-09-08 22:52:34 +00:00
Jeff Walden
b5ec4c7eba Bug 1663365 - Create a new js/public/String.h header seeded with the inline string functions previously found in jsfriendapi.h. (More functions ought be added/moved here, but these make a good start.) r=jandem,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D89330
2020-09-08 22:50:52 +00:00
Jeff Walden
c9ab0ce005 Bug 1656411 - Move WindowProxy-related functions out of jsfriendapi.h to their own header. r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D85521
2020-07-31 16:11:36 +00:00
Nathan Froyd
e3ebda1914 Bug 1223932 - delete guard object uses from the tree; r=jwalden
CLOSED TREE

We don't need these macros anymore, for two reasons:

1. We have static analysis to provide the same sort of checks via `MOZ_RAII`
   and friends.
2. clang now warns for the "temporary that should have been a declaration" case.

The extra requirements on class construction also show up during debug tests
as performance problems.

This change was automated by using the following sed script:

```
# Remove declarations in classes.
/MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER/d
/MOZ_GUARD_OBJECT_NOTIFIER_INIT/d

# Remove individual macros, carefully.
{
  # We don't have to worry about substrings here because the closing
  # parenthesis "anchors" the match.
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)/)/g;

  # Remove the longer identifier first.
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT//g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM//g;
}

# Remove the actual include.
\@# *include "mozilla/GuardObjects.h"@d
```

and running:

```
find . -name \*.cpp -o -name \*.h | grep -v 'GuardObjects.h' |xargs sed -i -f script 2>/dev/null
mach clang-format
```

Differential Revision: https://phabricator.services.mozilla.com/D85168
2020-07-30 14:22:38 +00:00
Mihai Alexandru Michis
a911a108d0 Backed out changeset ac9c811bc427 (bug 1223932) for causing spidermonkey rust failures.
CLOSED TREE
2020-07-30 18:23:21 +03:00
Nathan Froyd
bec9f9b93a Bug 1223932 - delete guard object uses from the tree; r=jwalden
We don't need these macros anymore, for two reasons:

1. We have static analysis to provide the same sort of checks via `MOZ_RAII`
   and friends.
2. clang now warns for the "temporary that should have been a declaration" case.

The extra requirements on class construction also show up during debug tests
as performance problems.

This change was automated by using the following sed script:

```
# Remove declarations in classes.
/MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER/d
/MOZ_GUARD_OBJECT_NOTIFIER_INIT/d

# Remove individual macros, carefully.
{
  # We don't have to worry about substrings here because the closing
  # parenthesis "anchors" the match.
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)/)/g;

  # Remove the longer identifier first.
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT//g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM//g;
}

# Remove the actual include.
\@# *include "mozilla/GuardObjects.h"@d
```

and running:

```
find . -name \*.cpp -o -name \*.h | grep -v 'GuardObjects.h' |xargs sed -i -f script 2>/dev/null
mach clang-format
```

Differential Revision: https://phabricator.services.mozilla.com/D85168
2020-07-30 14:22:38 +00:00
Simon Giesecke
b4b3fdfc78 Bug 1653228 - Move PinnedStringId to a separate header. r=peterv
AtomList uses only PinnedStringId from BindingUtils, and there are no other
dependencies between BindingUtils and PinnedStringId, and BindingUtils is
complex to parse. Moving PinnedStringId to a separate header therefore seems
beneficial.

Differential Revision: https://phabricator.services.mozilla.com/D83769
2020-07-22 15:13:21 +00:00
Simon Giesecke
1cd5c68592 Bug 1652002 - Remove some unnecessary includes from BindingUtils.h. r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D83098
2020-07-15 15:34:49 +00:00
Kris Maglione
f6b7b4f451 Bug 1645510: Part 1 - Make unprivileged junk scope creation lazy, weak, and fallible. r=mccr8,bholley
Differential Revision: https://phabricator.services.mozilla.com/D79719
2020-06-27 03:06:26 +00:00
Jon Coppeard
c53e11c2b2 Bug 1642974 - Don't expose WeakRef targets which are DOM wrappers whose target has been collected r=smaug,sfink
WeakRef targets that are wrappers to DOM objects are preserved when the WeakRef is created.  This checks whether the wrapper is still preserved in deref() and if it is found to have been released, the target is cleared.

The patch adds a new DOMJSClass hook to deal with getting the wrapper cache for non-nsISupports objects.

Differential Revision: https://phabricator.services.mozilla.com/D78061
2020-06-06 06:58:42 +00:00
Tom Schuster
f77a3af47a Bug 1277799 - Define @@toStringTag on all DOM interface prototype objects. r=peterv
Instead of manually defining toStringTag we now add the toStringTag symbol to the list of properties.
This is also how we usually define toStringTag in the JS engine.
Even though this changes more code I like this approach better. Everything is centralized in the generated bindings file.

Differential Revision: https://phabricator.services.mozilla.com/D72179
2020-05-05 17:54:51 +00:00