Closed
Bug 501230
Opened 15 years ago
Closed 15 years ago
TM: fast path for String.toString
Categories
(Core :: JavaScript Engine, defect, P2)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla1.9.2a1
People
(Reporter: gal, Assigned: brendan)
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file, 2 obsolete files)
4.00 KB,
patch
|
gal
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Reporter | ||
Comment 1•15 years ago
|
||
This does GetMethod twice potentially, but only if the object is of StringClass, which should be safe.
Assignee: general → gal
Reporter | ||
Comment 2•15 years ago
|
||
This path is hit heavily in dromaeo JS tests >> string tests >> charAt test.
Reporter | ||
Comment 3•15 years ago
|
||
100x that Dromeo test without the patch: 643 with the patch: 414 (smaller is better)
Reporter | ||
Comment 4•15 years ago
|
||
The 643 is with Bug 501254 applied. Without that we get 1488, which is slower than interpretation (1202).
Reporter | ||
Updated•15 years ago
|
Attachment #385875 -
Flags: review?(brendan)
Reporter | ||
Comment 5•15 years ago
|
||
"100x that dromeo test" => running that test 100 times (it runs too short originally to properly measure it)
Assignee | ||
Comment 6•15 years ago
|
||
You can't argue about getMethod called twice being "safe" in the presence of user-defined getters. By the book, toString should be got only once. Suggest pushing the optimization down into js_DefaultValue. /be
Reporter | ||
Comment 7•15 years ago
|
||
I thought its safe because of the js_StringClass check. Could you briefly explain why thats not the case? (I believe you its not, I just don't understand why not ;) I will push this further down and eliminate the redundant getMethod.
Assignee | ||
Comment 8•15 years ago
|
||
js> save = String.prototype.toString function toString() { [native code] } js> String.prototype.__defineGetter__('toString', function(){++effectCount; return save.apply(this, arguments)}) js> effectCount=1 1 js> s = new String('hi') hi js> s hi js> effectCount 2 You don't know what the getter might do. It could have arbitrary effects. The spec says toString is tried once. The example above shows this. With your patch if I'm not mistaken the effectCount would be 4 at the end. /be
Reporter | ||
Updated•15 years ago
|
Attachment #385875 -
Flags: review?(brendan)
Assignee | ||
Comment 9•15 years ago
|
||
Attachment #385875 -
Attachment is obsolete: true
Attachment #388833 -
Flags: review?(gal)
Assignee | ||
Comment 10•15 years ago
|
||
Someone could set String.prototype.__proto__ = null or s = new String("hi"); s.__proto__ = null -- that would be just mean, but it's allowed. /be
Attachment #388833 -
Attachment is obsolete: true
Attachment #388835 -
Flags: review?(gal)
Attachment #388833 -
Flags: review?(gal)
Reporter | ||
Updated•15 years ago
|
Attachment #388835 -
Flags: review?(gal) → review+
Assignee | ||
Updated•15 years ago
|
Assignee: gal → brendan
Status: NEW → ASSIGNED
OS: Mac OS X → All
Priority: -- → P2
Hardware: x86 → All
Target Milestone: --- → mozilla1.9.2a1
Assignee | ||
Comment 11•15 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/9a626a99c67c /be
Whiteboard: fixed-in-tracemonkey
Nice, what's the win like? (Wouldn't we rather just emit a tiny bit of LIR here? Guard on shape, deref a couple of pointers, Bob's your screaming CPU pipeline?)
Assignee | ||
Comment 13•15 years ago
|
||
(In reply to comment #12) > Nice, what's the win like? > > (Wouldn't we rather just emit a tiny bit of LIR here? Guard on shape, deref a > couple of pointers, Bob's your screaming CPU pipeline?) There are lotsa ways to reach OBJ_DEFAULT_VALUE that won't go through an imacro being recorded for JITting. String objects are rare birds outside of Dromaeo, so any JIT-only optimizations should go in a later bug, if we feel the need. Why is Dromaeo creating String wrappers? Dunno. Anyone? /be
Assignee | ||
Comment 14•15 years ago
|
||
(In reply to comment #12) > Nice, what's the win like? Andreas said strictly better than the win measured in comment 3 but I didn't hear actual numbers. /be
Assignee | ||
Comment 15•15 years ago
|
||
John, see comment 13 para 2. Thanks, /be
Comment 16•15 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/9a626a99c67c
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•