WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 84781
objectProtoFuncToString creates new string every invocation
https://bugs.webkit.org/show_bug.cgi?id=84781
Summary
objectProtoFuncToString creates new string every invocation
Michael Saboff
Reported
2012-04-24 14:33:29 PDT
objectProtoFuncToString creates and returns a JSString with the contents of "[object <object_type]" (e.g. "[object Number]"). This creates a new string each time possibly increasing memory and using CPU. This value should be created once and cached for each object.
Attachments
Patch
(4.09 KB, patch)
2012-04-24 14:49 PDT
,
Michael Saboff
ggaren
: review-
Details
Formatted Diff
Diff
Updated Patch with Suggested Fixes
(3.91 KB, patch)
2012-04-24 15:35 PDT
,
Michael Saboff
ggaren
: review+
webkit-ews
: commit-queue-
Details
Formatted Diff
Diff
Updated patch with speculative Qt fix
(3.92 KB, patch)
2012-04-24 16:44 PDT
,
Michael Saboff
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Michael Saboff
Comment 1
2012-04-24 14:49:16 PDT
Created
attachment 138653
[details]
Patch This fails the style checker due to using a PassRefPtr as a local, but reused pattern from JSStringBuilder.h.
WebKit Review Bot
Comment 2
2012-04-24 14:51:01 PDT
Attachment 138653
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1 Source/JavaScriptCore/runtime/ObjectPrototype.cpp:260: Local variables should never be PassRefPtr (see
http://webkit.org/coding/RefPtr.html
). [readability/pass_ptr] [5] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Geoffrey Garen
Comment 3
2012-04-24 15:15:46 PDT
Comment on
attachment 138653
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=138653&action=review
Patch looks good, but some minor changes needed here before committing.
> Source/JavaScriptCore/runtime/ObjectPrototype.cpp:259 > + if (!thisObject->structure()->hasObjectToStringValue()) {
Our typical style here is just to call objectToStringValue(): RefPtr<> toStringValue = thisObject->structure()->objectToStringValue(); if (!toStringValue) { ... toStringValue = ... } ...
> Source/JavaScriptCore/runtime/ObjectPrototype.cpp:264 > + thisObject->structure()->setObjectToStringValue(exec->globalData(), thisObject, jsNontrivialString(exec, result));
The appropriate pattern is to make the local a RefPtr, to avoid accidentally dereferencing NULL, and then use .release() when passing it to setObjectToStringValue here.
> Source/JavaScriptCore/runtime/Structure.cpp:797 > +#if 1
Please remove the #if.
Michael Saboff
Comment 4
2012-04-24 15:35:21 PDT
Created
attachment 138669
[details]
Updated Patch with Suggested Fixes
Geoffrey Garen
Comment 5
2012-04-24 15:37:54 PDT
Comment on
attachment 138669
[details]
Updated Patch with Suggested Fixes r=me
Early Warning System Bot
Comment 6
2012-04-24 16:15:49 PDT
Comment on
attachment 138669
[details]
Updated Patch with Suggested Fixes
Attachment 138669
[details]
did not pass qt-wk2-ews (qt): Output:
http://queues.webkit.org/results/12525366
Michael Saboff
Comment 7
2012-04-24 16:44:12 PDT
Created
attachment 138686
[details]
Updated patch with speculative Qt fix
Michael Saboff
Comment 8
2012-04-24 17:57:32 PDT
Committed
r115151
: <
http://trac.webkit.org/changeset/115151
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug