Use a one-off global object slot for storing generators' [[Prototype]]

RESOLVED FIXED in mozilla9

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Waldo, Assigned: Waldo)

Tracking

Trunk
mozilla9
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

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

The Generator class currently uses the three-slot ctor/proto/property system to store the [[Prototype]] for all generators.  This is unnecessary complexity: you have to make sure to fill in all three slots in just the right way to make sure that you don't have reinitialization problems.  It would be better if it were just a single, one-off slot.  Let's make it happen.
Attachment #559286 - Flags: review?(mrbkap)
There is -- sort of -- a substantive change in this patch.  Currently the Generator prototype object is stored, somewhat, in a "Generator" property of the global object.  I think this was actually a mistake on my part when I converted iterator bootstrapping, because the generator class, as an anonymous class, shouldn't have hit this code to add such a property:

        /*
         * Lacking a constructor, name the prototype (e.g., Math) unless this
         * class (a) is anonymous, i.e. for internal use only; (b) the class
         * of obj (the global object) is has a reserved slot indexed by key;
         * and (c) key is not the null key.
         */
        if (!(clasp->flags & JSCLASS_IS_ANONYMOUS) || !obj->isGlobal() || key == JSProto_Null) {
            uint32 attrs = (clasp->flags & JSCLASS_IS_ANONYMOUS)
                           ? JSPROP_READONLY | JSPROP_PERMANENT
                           : 0;
            if (!DefineStandardSlot(cx, obj, key, atom, ObjectValue(*proto), attrs, named))
                goto bad;
        }

Updated

6 years ago
Attachment #559286 - Flags: review?(mrbkap) → review+
http://hg.mozilla.org/integration/mozilla-inbound/rev/f96612c06d85
Whiteboard: [inbound]
Target Milestone: --- → mozilla9
http://hg.mozilla.org/mozilla-central/rev/f96612c06d85
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Whiteboard: [inbound]
Duplicate of this bug: 677677
You need to log in before you can comment on or make changes to this bug.