Last Comment Bug 685688 - Use a one-off global object slot for storing generators' [[Prototype]]
: Use a one-off global object slot for storing generators' [[Prototype]]
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: All All
-- normal (vote)
: mozilla9
Assigned To: Jeff Walden [:Waldo] (remove +bmo to email)
: Jason Orendorff [:jorendorff]
: 677677 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2011-09-08 14:17 PDT by Jeff Walden [:Waldo] (remove +bmo to email)
Modified: 2011-09-20 09:01 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch (9.37 KB, patch)
2011-09-08 14:17 PDT, Jeff Walden [:Waldo] (remove +bmo to email)
mrbkap: review+
Details | Diff | Splinter Review

Description User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-09-08 14:17:47 PDT
Created attachment 559286 [details] [diff] [review]

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.
Comment 1 User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-09-08 14:22:45 PDT
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;
Comment 2 User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-09-08 14:56:10 PDT
Comment 4 User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-09-20 09:01:23 PDT
*** Bug 677677 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.