Closed Bug 1107496 Opened 5 years ago Closed 5 years ago

Add PlainObject subclass

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: bhackett, Assigned: bhackett)

References

Details

Attachments

(1 file)

Attached patch patchSplinter Review
There are a lot of subclasses of JSObject and NativeObject for the various kinds of objects that can be created, but there isn't one for the ordinary objects created using '{}' object literals, 'new Foo()', 'Object.create()', etc.  The clasp for these objects is stored on JSObject itself, which leads to lots of weird code like 'obj->is<JSObject>()', makes it hard to create these objects in an elegant way, is error prone (a class_ left out on a subclass will cause references to resolve to JSObject::class_, which is never what we want to happen), and leads to the code being underspecified (we have to use JSObject or NativeObject to refer to these objects).

The attached patch adds a PlainObject subclass to NativeObject to refer to these objects.  I don't know if there's a better name to use here, but PlainObject seemed nice to easily distinguish these from the JSObject/NativeObject superclasses.  This patch also cleans up some object creation APIs and replaces a lot of uses of NativeObject or JSObject with specific subclasses, and fixes a TypedObject bug where a couple functions ended up being named 'Object' due to the class resolving thing above.
Attachment #8532030 - Flags: review?(luke)
Comment on attachment 8532030 [details] [diff] [review]
patch

Review of attachment 8532030 [details] [diff] [review]:
-----------------------------------------------------------------

Nice
Attachment #8532030 - Flags: review?(luke) → review+
Hmm, the try run I did (acf43bc57a51) never even ran SM(ggc).

https://hg.mozilla.org/integration/mozilla-inbound/rev/516d97ff2d4d
https://hg.mozilla.org/mozilla-central/rev/516d97ff2d4d
Assignee: nobody → bhackett1024
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.