Bug 1877258 - Add use counter for optimize get iterator fuse being popped r=iain

Differential Revision: https://phabricator.services.mozilla.com/D229217
This commit is contained in:
Matthew Gaudet 2024-11-18 16:38:09 +00:00
parent ea81b48f42
commit 105ce8bbaf
6 changed files with 53 additions and 4 deletions

View File

@ -71,6 +71,8 @@ custom JS_asmjs uses asm.js
custom JS_wasm uses WebAssembly
custom JS_wasm_legacy_exceptions uses WebAssembly legacy exception-handling
custom JS_isHTMLDDA_fuse has used the document.all getter (popping the EmulatesUndefined Fuse)
custom JS_OptimizeGetIterator_fuse has modified any builtins such that the GetIterator fuse is popped
// Console API
method console.assert

View File

@ -107,8 +107,8 @@ use.counter:
send_in_pings:
- use-counters
# Total of 2329 use counter metrics (excludes denominators).
# Total of 355 'page' use counters.
# Total of 2331 use counter metrics (excludes denominators).
# Total of 356 'page' use counters.
use.counter.page:
svgsvgelement_getelementbyid:
type: counter
@ -552,6 +552,23 @@ use.counter.page:
send_in_pings:
- use-counters
js__optimize_get_iterator_fuse:
type: counter
description: >
Whether a page has modified any builtins such that the GetIterator fuse is popped.
Compare against `use.counter.top_level_content_documents_destroyed`
to calculate the rate.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
notification_emails:
- dom-core@mozilla.com
- emilio@mozilla.com
expires: never
send_in_pings:
- use-counters
console_assert:
type: counter
description: >
@ -6145,7 +6162,7 @@ use.counter.page:
send_in_pings:
- use-counters
# Total of 355 'document' use counters.
# Total of 356 'document' use counters.
use.counter.doc:
svgsvgelement_getelementbyid:
type: counter
@ -6589,6 +6606,23 @@ use.counter.doc:
send_in_pings:
- use-counters
js__optimize_get_iterator_fuse:
type: counter
description: >
Whether a document has modified any builtins such that the GetIterator fuse is popped.
Compare against `use.counter.content_documents_destroyed`
to calculate the rate.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
notification_emails:
- dom-core@mozilla.com
- emilio@mozilla.com
expires: never
send_in_pings:
- use-counters
console_assert:
type: counter
description: >

View File

@ -99,7 +99,8 @@ extern JS_PUBLIC_API void JS_SetAccumulateTelemetryCallback(
_(ASMJS, AsmJS) \
_(WASM, Wasm) \
_(WASM_LEGACY_EXCEPTIONS, WasmLegacyExceptions) \
_(ISHTMLDDA_FUSE, IsHTMLDDAFuse)
_(ISHTMLDDA_FUSE, IsHTMLDDAFuse) \
_(OPTIMIZE_GET_ITERATOR_FUSE, OptimizeGetIteratorFuse)
/*
* Use counter names passed to the accumulate use counter callback.

View File

@ -76,6 +76,14 @@ const char* js::RealmFuses::getFuseName(RealmFuses::FuseIndex index) {
return fuseNames[rawIndex];
}
void js::OptimizeGetIteratorFuse::popFuse(JSContext* cx,
RealmFuses& realmFuses) {
InvalidatingRealmFuse::popFuse(cx, realmFuses);
MOZ_ASSERT(cx->global());
cx->runtime()->setUseCounter(cx->global(),
JSUseCounter::OPTIMIZE_GET_ITERATOR_FUSE);
}
bool js::OptimizeGetIteratorFuse::checkInvariant(JSContext* cx) {
// Simple invariant: this fuse merely reflects the conjunction of a group of
// fuses, so if this fuse is intact, then the invariant it asserts is that

View File

@ -44,6 +44,7 @@ class InvalidatingRealmFuse : public InvalidatingFuse {
struct OptimizeGetIteratorFuse final : public InvalidatingRealmFuse {
virtual const char* name() override { return "OptimizeGetIteratorFuse"; }
virtual bool checkInvariant(JSContext* cx) override;
virtual void popFuse(JSContext* cx, RealmFuses& realmFuses) override;
};
struct PopsOptimizedGetIteratorFuse : public RealmFuse {

View File

@ -2647,6 +2647,9 @@ static void SetUseCounterCallback(JSObject* obj, JSUseCounter counter) {
case JSUseCounter::ISHTMLDDA_FUSE:
SetUseCounter(obj, eUseCounter_custom_JS_isHTMLDDA_fuse);
return;
case JSUseCounter::OPTIMIZE_GET_ITERATOR_FUSE:
SetUseCounter(obj, eUseCounter_custom_JS_OptimizeGetIterator_fuse);
return;
case JSUseCounter::COUNT:
break;
}