Closed Bug 1388375 Opened 7 years ago Closed 7 years ago

ValueToId shouldn't unwrap Symbol objects

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(1 file, 1 obsolete file)

Test case:
---
var s = Symbol();
var so = Object(s);

var o = {};
o[s] = 0;
o["Symbol()"] = 1;
o["foo"] = 2;

Object.defineProperty(o, s, {enumerable: false});
Object.defineProperty(o, "Symbol()", {enumerable: false});
Object.defineProperty(o, "foo", {enumerable: true});

print(o.propertyIsEnumerable(so));

Object.defineProperty(Symbol.prototype, Symbol.toPrimitive, {
    value: function() {
        return "foo";
    }
});

print(o.propertyIsEnumerable(so));
---

Expected: Prints "false" and then "true"
Actual: Prints "false" two times
Symbol object unwrapping was added in bug 1083047, but unfortunately that bug doesn't contain any info why the reporter thought unboxing is required by the spec. Maybe it was just an misinterpretation of ES6 draft rev28 which was also published on 2014-10-14, the same date bug 1083047 was reported. (ES6 draft rev28 updated multiple sections to properly handle symbol property keys.)
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Removing IsSymbolOrSymbolWrapper is also beneficial for performance, because IsSymbolOrSymbolWrapper is never inlined (bug 1370210).
Attached patch bug1388375.patch (obsolete) — Splinter Review
Unboxing symbol objects in ValueToId isn't spec-compliant, only symbol values should be directly accepted. Symbol objects should go through the normal slow path for all objects. I've also removed js::IsSymbolOrSymbolWrapper and js::ToSymbolPrimitive because these functions are no longer used.
Attachment #8895348 - Flags: review?(jorendorff)
Comment on attachment 8895348 [details] [diff] [review]
bug1388375.patch

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

Stealing as this might improve perf a bit. Thanks for fixing.
Attachment #8895348 - Flags: review?(jorendorff) → review+
(In reply to Jan de Mooij [:jandem] from comment #4)
> Comment on attachment 8895348 [details] [diff] [review]
> bug1388375.patch
> 
> Review of attachment 8895348 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Stealing as this might improve perf a bit. Thanks for fixing.

Thanks for taking over the review! :-)
Attached patch bug1388375.patchSplinter Review
Update reviewer to :jandem. Otherwise no changes to the patch.
Attachment #8895348 - Attachment is obsolete: true
Attachment #8898790 - Flags: review+
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3c2cc6a87b0b
Don't unbox symbol objects in ValueToId. r=jandem
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/3c2cc6a87b0b
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: