Closed Bug 728411 Opened 13 years ago Closed 9 years ago

Move object implementation details out of JSObject into ObjectImpl, Elements, and Properties classes

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Waldo, Assigned: Waldo)

Details

(Whiteboard: [Leave open after merge])

Attachments

(12 files, 2 obsolete files)

17.11 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
15.68 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
4.84 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
2.44 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
9.29 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
4.87 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
2.58 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
23.11 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
9.13 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
7.81 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
3.15 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
4.94 KB, patch
bhackett1024
: review+
Details | Diff | Splinter Review
jsobj.h and JSObject are kind of a mess of complexity, with some public methods, some private methods, and not a whole lot of distinction between the two. It's a very fat interface. I'd find it helpful for the property split if JSObject were just a veneer that acted upon a lower-level interface, an ObjectImpl superclass if you will. That class would act upon the type, shape, slots, and elements directly. The complexity of those structures should also be moved into separate headers. It's also possible this might make it easier to have a compile-time switch to allow gradual implementation of a new property-storage mechanism, with the final switchover controlled by #ifdef. This might or might not be feasible. But anything that makes it easier to make a controlled step, that doesn't require landing and enabling everything all at once, seems highly desirable. So I think this is worth doing for that reason as well.
There's a lot of stuff that relies on other members being directly in that class, so things will have to move from JSObject to ObjectImpl incrementally. The alternative is moving everything at once, which seems a bit harder to review.
Attachment #598380 - Flags: review?(bhackett1024)
Attachment #598380 - Flags: review?(bhackett1024) → review+
Comment on attachment 598378 [details] [diff] [review] Move ObjectElements and a little bit of implementation related to it into a separate header Review of attachment 598378 [details] [diff] [review]: ----------------------------------------------------------------- I think that ObjectElements should be in the same header and files as ObjectImpl. ObjectElements is a very thin structure which only makes sense in the context of the object that owns it, and the comments and code for all of these should be in the same place. The model here is Stack.h, which has a lot of separate structures which are all interrelated, and would be much harder to understand if those structures were in separate headers.
Attachment #598378 - Flags: review?(bhackett1024)
Attachment #598378 - Attachment is obsolete: true
Attachment #598380 - Attachment is obsolete: true
Attachment #599354 - Flags: review?(bhackett1024)
Attachment #599357 - Flags: review?(bhackett1024)
Turns out this method doesn't even use |this|, not sure why it existed on JSObject in the first place, probably historical reasons...
Attachment #599362 - Flags: review?(bhackett1024)
Attachment #599363 - Flags: review?(bhackett1024)
Attached patch Barrier bitsSplinter Review
Attachment #599364 - Flags: review?(bhackett1024)
Somewhere in this stream of patches I start to copy over is* methods without copying over the corresponding set* methods. This could possibly be avoided, but it'd be a lot of work. The problem is the set* methods depend on setFlag, which is non-trivially intertwined with a bunch of JSObject stuff as I remember. It'll move over at some point, just it's a bit of trouble to do it now, exactly.
Attachment #599366 - Flags: review?(bhackett1024)
Comment on attachment 599354 [details] [diff] [review] New files, take two Review of attachment 599354 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/vm/ObjectImpl.cpp @@ +21,5 @@ > + * Portions created by the Initial Developer are Copyright (C) 2012 > + * the Initial Developer. All Rights Reserved. > + * > + * Contributor(s): > + * Jeff Walden <jwalden+code@mit.edu> (original author) This is kind of petty, but can you leave the contributors section blank, like it is in jsobj*? Seeing contributor lists in the source that are woefully incomplete has bugged me for a while, and it would be nice if they either (a) reflected everyone who has made significant contributions to the code in the file, or (b) are left blank. The 'Spidermonkey elements' bit above is wrong, too. Ditto for the other new files.
Attachment #599354 - Flags: review?(bhackett1024) → review+
Shouldn't you be using the new MPL2 license block anyway? http://www.mozilla.org/MPL/headers/
Um. That page might say so. I guess I'm going to have to vigorously protest it, or at least request that bug 717196 get prioritized. That's the reason I haven't been using it -- that I very much don't want to lose MXR functionality just for a new header.
Comment on attachment 599355 [details] [diff] [review] Start moving methods over, a bunch of simple methods at first Review of attachment 599355 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jsobj.h @@ -503,4 @@ > inline bool isSystem() const; > inline bool setSystem(JSContext *cx); > > - inline bool hasSpecialEquality() const; I think this should stay in JSObject. My understanding of the ObjectImpl vs. JSObject split is that the former contains the minimum of methods to interact with the object's layout, and the latter has convenience methods that wrap the former and are not related to the object implementation. hasSpecialEquality seems to fit the latter better. (Aside, just did some grepping. Is hasSpecialEquality used at all anymore?)
Attachment #599355 - Flags: review?(bhackett1024) → review+
Attachment #599357 - Flags: review?(bhackett1024) → review+
Attachment #599362 - Flags: review?(bhackett1024) → review+
Attachment #599363 - Flags: review?(bhackett1024) → review+
Attachment #599364 - Flags: review?(bhackett1024) → review+
Attachment #599366 - Flags: review?(bhackett1024) → review+
Regarding comments: I used the MPL2 header, and I added grist to the bug 717196 mill to hopefully get that issue resolved sooner. hasSpecialEquality is I think more of an implementation detail than something we will ultimately want to expose in JSObject. Generally users shouldn't be asking the question, and the only things that need to know such intimate details are JITs, which of course are going to be ObjectImpl-aware. But I could be wrong about how this split should play out, so I left it where it was for now.
Either this or one of the other bugs in the same push caused: Regression :( Trace Malloc MaxHeap increase 2.11% on CentOS release 5 (Final) Mozilla-Inbound --------------------------------------------------------------------------------------------- Previous: avg 26103806.667 stddev 15352.186 of 30 runs up to revision ede36f262612 New : avg 26653960.000 stddev 3571.834 of 5 runs since revision b150d708bb98 Change : +550153.333 (2.11% / z=35.836) Graph : http://mzl.la/zcFtKt and Regression :( Trace Malloc MaxHeap increase 2.32% on WINNT 5.2 Mozilla-Inbound ------------------------------------------------------------------------------ Previous: avg 24745420.000 stddev 30508.545 of 30 runs up to revision ede36f262612 New : avg 25318560.000 stddev 43905.159 of 5 runs since revision b150d708bb98 Change : +573140.000 (2.32% / z=18.786) Graph : http://mzl.la/xMpaaj https://groups.google.com/d/msg/mozilla.dev.tree-management/O57mK7haIQk/nAHeyQWXancJ
There shouldn't have been any heap-usage change from the patches in this particular bug -- all it did was insert a class in a class hierarchy (one without vtables, too) and move some methods and fields among the classes in it. I suppose it's not impossible it's one of the other patches there, but I'm still a bit surprised about this...
I just picked one of the bugs in the push at random to post the above in, I didn't have a chance to look at the diffs. The regression is quite noticeable on the graphs - can I leave you to narrow down which of your changesets in that push caused it? :-)
Attachment #606761 - Flags: review?(bhackett1024)
Attachment #606762 - Flags: review?(bhackett1024)
Attachment #606763 - Flags: review?(bhackett1024)
Attachment #606765 - Flags: review?(bhackett1024)
Comment on attachment 606761 [details] [diff] [review] Move more slot range details into ObjectImpl Review of attachment 606761 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jsobj.h @@ +1133,2 @@ > inline bool isDate() const; > + using js::ObjectImpl::isDenseArray; What does this code for? (C++....) isArray etc. are public members of ObjectImpl and this code should be a no-op, so can you just update the comment to point readers at the ObjectImpl section instead? I'm also hoping that once the elements stuff is fixed that ObjectImpl will be totally class agnostic and won't need any isClass methods. @@ +1147,4 @@ > inline bool isRegExpStatics() const; > inline bool isScope() const; > inline bool isScript() const; > + using js::ObjectImpl::isSlowArray; Ditto.
Attachment #606761 - Flags: review?(bhackett1024) → review+
Attachment #606762 - Flags: review?(bhackett1024) → review+
Attachment #606763 - Flags: review?(bhackett1024) → review+
Attachment #606765 - Flags: review?(bhackett1024) → review+
(In reply to Brian Hackett (:bhackett) from comment #25) > Comment on attachment 606761 [details] [diff] [review] > What does this code for? Not much, I guess. I think maybe those methods were only protected, so the using was necessary, then I made them public at some point and they became unnecessary. > I'm also hoping that once the elements stuff is fixed that ObjectImpl will be > totally class agnostic and won't need any isClass methods. Yeah, I think that's an end goal here.
I found I needed this for ArrayBuffer, which currently stores its delegate object (that holds the array buffer's actual properties) as a private. I'm pretty sure that'll change so that ArrayBuffer can just be a regular old object, but it seems best to leave that to later after more of the new representation gets fleshed out.
Attachment #608146 - Flags: review?(bhackett1024)
Attachment #608146 - Flags: review?(bhackett1024) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/2be844125c05 for comment 29's move-private-stuff-to-ObjectImpl. Still keeping open...
I'm guessing we can close this now.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: