Move prototype-creation shared by String/RegExp into one method

RESOLVED FIXED in mozilla8

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Waldo, Assigned: Waldo)

Tracking

unspecified
mozilla8
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Created attachment 545256 [details] [diff] [review]
Patch

Right now String/RegExp duplicate creation of their respective *.prototype objects, and of subsequent frobbing to get their empty shapes (which does not depend on its current ordering with respect to prototype or associated constructor creation).  Implement a helper method to do that, and to serve as a reasonable point for future work involved in initializing prototype objects (thinking particularly of TI here).

This method can't be used by JS_InitClass code path because this changes the parent of the prototype object to be the global object, and sometimes JS_InitClass is called with an object that's not the global object.  This parent dependency (which none of the standard classes has -- I know ctypes does, but I think the corresponding tests are just over-asserting out of an abundance of caution) will eventually die as part of bug 638316 (if not sooner), but for right now it's a mostly-unimportant side show.
Attachment #545256 - Flags: review?(bhackett1024)
Comment on attachment 545256 [details] [diff] [review]
Patch

Review of attachment 545256 [details] [diff] [review]:
-----------------------------------------------------------------
Attachment #545256 - Flags: review?(bhackett1024) → review+
http://hg.mozilla.org/integration/mozilla-inbound/rev/91aad2148739
Status: NEW → ASSIGNED
Whiteboard: [inbound]
Merged:
http://hg.mozilla.org/mozilla-central/rev/91aad2148739
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Whiteboard: [inbound]
I should further note that this method can't be used by JS_InitClass now because it depends on the Array class being initialized with js_ArrayClass, the prototype for it being created with that class, the prototype then converting to js_SlowArrayClass when named properties are added to it, and js_SlowArrayClass then being used for the getEmptyShape call.  (I will be changing this facet of oddity at a future time, distinct from the parent-identity concern noted in comment 0.)
...and more differentiation (can you stand it?): if parent_proto (maybe protoProto, memory hazy about the name) is NULL when provided to JS_InitClass, for a non-standard class, then it becomes relevant that createBlankPrototype uses WithProto::Given while the current code uses WithProto::Class.  That distinction is even wrinklier to get rid of than parent identity, or Array speciality.  But subsequent changing can and does make JS_InitClass's code look somewhat more similar to that in createBlankPrototype, at least.
You need to log in before you can comment on or make changes to this bug.