Closed Bug 1848325 Opened 1 year ago Closed 1 year ago

Rename special CommonPropertyNames

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
118 Branch
Tracking Status
firefox118 --- fixed

People

(Reporter: arai, Assigned: arai)

References

(Blocks 1 open bug)

Details

Attachments

(17 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

CommonPropertyNames contains some entries where the id and the content different.
before exposing it to public API, we should rename them to clarify the id is different than the content.

https://searchfox.org/mozilla-central/rev/77dd6aa3810610949a5ff925e24de2f8c11377fd/js/src/vm/CommonPropertyNames.h#533

MACRO1(star, star, "*")                                                      \

https://searchfox.org/mozilla-central/rev/77dd6aa3810610949a5ff925e24de2f8c11377fd/js/src/vm/CommonPropertyNames.h#166

MACRO0(empty, empty, "")                                                     \

https://searchfox.org/mozilla-central/rev/77dd6aa3810610949a5ff925e24de2f8c11377fd/js/src/vm/CommonPropertyNames.h#140

MACRO_(defineGetter, defineGetter, "__defineGetter__")                       \

Also, if we're to use JS::WellKnownAtomId with gecko atoms, we might be better aligning the underline position, for simplicity:

https://searchfox.org/mozilla-central/rev/77dd6aa3810610949a5ff925e24de2f8c11377fd/js/src/vm/CommonPropertyNames.h#209

MACRO_(for, for_, "for")                                                   \

https://searchfox.org/mozilla-central/source/__GENERATED__/xpcom/ds/nsGkAtomList.h#438

GK_ATOM(_for, "for", 0xb87ea068, true, nsStaticAtom, Atom)

We should try to avoid _ followed by an upper-case character, because all identifiers which start with _[A-Z] are reserved by implementations. Same goes for identifiers which include two consecutive _ characters.

From https://en.cppreference.com/w/cpp/language/identifiers:

Identifiers that appear as appearing as a token or preprocessing token (i.e., not in user-defined-string-literal like operator ""id) (since C++11) of one of the following forms are reserved:

  • identifiers with a double underscore anywhere;
  • identifiers that begin with an underscore followed by an uppercase letter;
  • in the global namespace, identifiers that begin with an underscore.

thank you for pointing that out :)

so, if double underscore cannot be used, we cannot use leading or trailing underscore unless we stop using js_*_str format identifier.

given the js_*_str is used in very limited places, we could switch to something else, or maybe directly use js::wellKnownAtomInfos[n].content, without declaring js_*_str variables.
(bug 1847677 will remove most of the consumers anyway)

https://searchfox.org/mozilla-central/rev/77dd6aa3810610949a5ff925e24de2f8c11377fd/js/src/vm/WellKnownAtom.cpp#9,21-23

#define DECLARE_CONST_CHAR_STR(IDPART, _, TEXT) char js_##IDPART##_str[] = TEXT;
...
js::WellKnownAtomInfo js::wellKnownAtomInfos[] = {
#define ENUM_ENTRY_(IDPART, _, _2)                                \
  {uint32_t(sizeof(js_##IDPART##_str) - 1),                       \

"underscore + uppercase" matches the following. maybe using trailing underscore is safer? or perhaps we should look into some other way to clarify the text content is different than the id.

  MACRO_(_Array_Iterator, _Array_Iterator, "Array Iterator")                 \
  MACRO_(_Async_from_Sync_Iterator, _Async_from_Sync_Iterator,               \
  MACRO_(_Invalid_Date, _Invalid_Date, "Invalid Date")                       \
  MACRO_(_Iterator_Helper, _Iterator_Helper, "Iterator Helper")              \
  MACRO_(_Map_Iterator, _Map_Iterator, "Map Iterator")                       \
  MACRO_(_NegativeInfinity, _NegativeInfinity, "-Infinity")                  \
  MACRO_(_RegExp_String_Iterator, _RegExp_String_Iterator,                   \
  MACRO_(_Set_Iterator, _Set_Iterator, "Set Iterator")                       \
  MACRO_(_String_Iterator, _String_Iterator, "String Iterator")              \

actually, I was wrong. the underscore isn't used in js_*_str in current set because the IDPART is used instead, but that's still misleading.
I'll add class static in order to use the same identifier between the enum class and the strings.

Depends on: 1848473
Attachment #9349119 - Attachment description: WIP: Bug 1848325 - Part 1: Rename CommonPropertyNames empty to empty_. r?jandem! → Bug 1848325 - Part 1: Rename CommonPropertyNames empty to empty_. r?jandem!

defineGetter etc are currently unused, but will be used again in bug 1847677.

Depends on D186302

Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/10b649b5c9fd Part 1: Rename CommonPropertyNames empty to empty_. r=jandem https://hg.mozilla.org/integration/autoland/rev/26b92aa12caf Part 2: Rename CommonPropertyNames with $-prefix. r=jandem https://hg.mozilla.org/integration/autoland/rev/8f78f353f710 Part 3: Rename CommonPropertyNames with dot-prefix. r=jandem https://hg.mozilla.org/integration/autoland/rev/ab946ba7672e Part 4: Rename CommonPropertyNames with [object *] content. r=jandem https://hg.mozilla.org/integration/autoland/rev/945782fb21a5 Part 5: Rename CommonPropertyNames with *-prefix. r=jandem https://hg.mozilla.org/integration/autoland/rev/c95fdd620848 Part 6: Rename CommonPropertyNames with " Iterator" suffix. r=jandem https://hg.mozilla.org/integration/autoland/rev/91993e04a2f1 Part 7: Rename CommonPropertyNames with __-prefix. r=jandem https://hg.mozilla.org/integration/autoland/rev/a302a27df9f8 Part 8: Rename CommonPropertyNames comma to comma_. r=jandem https://hg.mozilla.org/integration/autoland/rev/04e9a9e2a084 Part 9: Rename CommonPropertyNames for futex. r=jandem https://hg.mozilla.org/integration/autoland/rev/11997cbcead7 Part 10: Rename CommonPropertyNames for use-prefix. r=jandem https://hg.mozilla.org/integration/autoland/rev/67d32f150e98 Part 11: Rename CommonPropertyNames with #-prefix. r=jandem https://hg.mozilla.org/integration/autoland/rev/e44e553c9fd9 Part 12: Rename CommonPropertyNames for self-hosted. r=jandem https://hg.mozilla.org/integration/autoland/rev/6b4381c2af09 Part 13: Rename CommonPropertyNames with spaces. r=jandem https://hg.mozilla.org/integration/autoland/rev/8b9e0d861cc5 Part 14: Rename remaining special CommonPropertyNames. r=jandem https://hg.mozilla.org/integration/autoland/rev/fc61e359ad38 Part 15: Rename defineDataPropertyIntrinsic to DefineDataProperty. r=jandem https://hg.mozilla.org/integration/autoland/rev/ce9f337c7f60 Part 16: Rename more CommonPropertyNames with __-prefix. r=jandem https://hg.mozilla.org/integration/autoland/rev/d86693cc6243 Part 17: Remove unused CommonPropertyNames entries. r=jandem
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: