WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
165795
Use JSValue::toWTFString instead of calling toString(exec) and value(exec)
https://bugs.webkit.org/show_bug.cgi?id=165795
Summary
Use JSValue::toWTFString instead of calling toString(exec) and value(exec)
Yusuke Suzuki
Reported
2016-12-13 01:45:33 PST
Use JSValue::toWTFString instead of calling toString(exec) and value(exec)
Attachments
Patch
(67.33 KB, patch)
2016-12-13 01:48 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(67.30 KB, patch)
2016-12-13 01:49 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(67.41 KB, patch)
2016-12-13 02:00 PST
,
Yusuke Suzuki
saam
: review+
Details
Formatted Diff
Diff
Patch
(64.18 KB, patch)
2016-12-13 23:52 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2016-12-13 01:48:03 PST
Created
attachment 296996
[details]
Patch
Yusuke Suzuki
Comment 2
2016-12-13 01:49:03 PST
Created
attachment 296997
[details]
Patch
Yusuke Suzuki
Comment 3
2016-12-13 02:00:27 PST
Created
attachment 296999
[details]
Patch
Saam Barati
Comment 4
2016-12-13 19:27:47 PST
Comment on
attachment 296999
[details]
Patch Looks like you have some build issues but r=me if it builds.
Yusuke Suzuki
Comment 5
2016-12-13 23:03:25 PST
Committed
r209792
: <
http://trac.webkit.org/changeset/209792
>
WebKit Commit Bot
Comment 6
2016-12-13 23:17:59 PST
Re-opened since this is blocked by
bug 165841
Yusuke Suzuki
Comment 7
2016-12-13 23:52:04 PST
Created
attachment 297070
[details]
Patch Patch for landing
Yusuke Suzuki
Comment 8
2016-12-14 08:05:10 PST
Committed
r209801
: <
http://trac.webkit.org/changeset/209801
>
Darin Adler
Comment 9
2016-12-14 09:04:16 PST
So glad you did this Yusuke! Now I can delete my local git branch named "ToWTFString", or maybe I will merge it to see if I had any changes there on something you missed?
Yusuke Suzuki
Comment 10
2016-12-14 09:47:01 PST
(In reply to
comment #9
)
> So glad you did this Yusuke! Now I can delete my local git branch named > "ToWTFString", or maybe I will merge it to see if I had any changes there on > something you missed?
Nice! Can you check whether I missed something in your branch? If your branch find a missed one, that's super awesome!
Darin Adler
Comment 11
2016-12-15 00:15:57 PST
Turns out my patch still has valuable changes, but it's hard to merge so I am not sure what I am going to do. Maybe just do the work below again. I found quite a few call sites that were calling JSValue::isString first, then calling JSValue::toString or JSValue::toWTFString. Those could call JSValue::getString instead, which should be a bit more efficient. That has an additional benefit because we know those call sites cannot generate exceptions, so we can remove unneeded RETURN_IF_EXCEPTION or any other branching based on the exception. In a couple other places, I did something similar except that I changed code to use the asString function rather than JSValue::getString. At call sites that were calling Identifier::toString on the result, I changed them to call JSString::toIdentifier instead of JSString::value or JSValue::toWTFString, hoping to save on allocating a string that already exists in the atomic string table. Another thing the patch had was that I had changed toWTFString to return a null string any time there is an exception, so the caller could check the string for null instead of checking the ExecState for an exception. That was possibly a valuable optimization back when I originally wrote this before we started using ThrowScope, but presumably is not needed now. One other thing the patch had is that I also noticed that WebCore::Dictionary::getWithUndefinedOrNullCheck will return true when it encounters an exception in toWTFString, and I am not sure that is what we want, so I made it return false in that case in the patch.
Darin Adler
Comment 12
2016-12-15 01:15:43 PST
(In reply to
comment #11
)
> I found quite a few call sites that were calling JSValue::isString first
Patch in
bug 165895
now.
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