WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
98050
Replace ExceptionCode with a structure that stores detail strings.
https://bugs.webkit.org/show_bug.cgi?id=98050
Summary
Replace ExceptionCode with a structure that stores detail strings.
Mike West
Reported
2012-10-01 11:22:47 PDT
See
http://lists.webkit.org/pipermail/webkit-dev/2012-October/022361.html
for context.
Attachments
WIP - Adds ExceptionDetail class.
(11.86 KB, patch)
2012-10-24 04:56 PDT
,
Mike West
no flags
Details
Formatted Diff
Diff
WIP - Bindings & ExceptionBase.
(15.91 KB, patch)
2012-10-24 04:57 PDT
,
Mike West
no flags
Details
Formatted Diff
Diff
WIP - XMLHTTPRequest + ExceptionDetail.
(74.37 KB, patch)
2012-10-24 04:57 PDT
,
Mike West
no flags
Details
Formatted Diff
Diff
Patch
(107.36 KB, patch)
2012-10-24 05:13 PDT
,
Mike West
no flags
Details
Formatted Diff
Diff
Now with less crashing.
(112.00 KB, patch)
2012-10-24 08:30 PDT
,
Mike West
mkwst
: commit-queue-
Details
Formatted Diff
Diff
Perf tests.
(325.57 KB, text/html)
2012-10-25 00:14 PDT
,
Mike West
no flags
Details
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Mike West
Comment 1
2012-10-01 11:30:43 PDT
Experimentally, to see how things might look.
Mike West
Comment 2
2012-10-04 07:33:07 PDT
This turns out to be much more complicated than I expected. Shocking, I know. I'm blocking off some time next week to work through the dependencies.
Mike West
Comment 3
2012-10-10 06:50:08 PDT
A horrible first pass almost compiles. :) Cleaning up a few bits and pieces along the way, tracked in bugs blocking this one.
Ojan Vafai
Comment 4
2012-10-22 11:23:36 PDT
Still working on this? It'd be great to get better error messages!
Mike West
Comment 5
2012-10-22 11:35:54 PDT
I am. I thought I'd have a first pass patch up for review by now, but I got sidetracked. It's still very much on my list.
Mike West
Comment 6
2012-10-24 04:56:33 PDT
Created
attachment 170366
[details]
WIP - Adds ExceptionDetail class.
Mike West
Comment 7
2012-10-24 04:57:16 PDT
Created
attachment 170367
[details]
WIP - Bindings & ExceptionBase.
Mike West
Comment 8
2012-10-24 04:57:51 PDT
Created
attachment 170368
[details]
WIP - XMLHTTPRequest + ExceptionDetail.
Mike West
Comment 9
2012-10-24 05:06:28 PDT
So. I'm not sure how best to put this together for a conceptual review. Nor am I sure how best to position this for eventual landing... I started with a massive, change the world approach, but that was a mess, and the diff was almost 10 meg. Bleh. The three patches I've uploaded are a minimal start in the direction of replacing ExceptionCode. It's still a bit messy (I'd like to drop the ExceptionCodeDescription hop in the middle), but it should be enough to discuss the idea. * The first patch adds the ExceptionDetail class. I haven't tried to optimize anything at all: it blindly creates new strings regardless of whether or not they're used. I'm hoping this worst-case will give perfbot something to evaluate. :) * The second uses that class to add new methods to the JSC and V8 bindings that accept ExceptionDetail instead of ExceptionCode, and routes ExceptionCode-based calls through the new methods by creating ExceptionDetail objects on the fly. * The third patch would be a fix for
bug #97654
in the brave new world these patches are creating. This approach should allow us to slowly convert exceptions to the new hotness without massively unreviewable changes to everything in the world, and, I hope, should make it easy to evaluate the approach I'm suggesting. I'm CCing a few of the folks who chimed in on the webkit-dev thread. Comments are very welcome. :) Thanks!
Mike West
Comment 10
2012-10-24 05:13:38 PDT
Created
attachment 170371
[details]
Patch
Mike West
Comment 11
2012-10-24 05:14:22 PDT
(In reply to
comment #10
)
> Created an attachment (id=170371) [details] > Patch
Uploaded a monolithic patch for perf tests. Let's see what breaks!
Mike West
Comment 12
2012-10-24 08:30:15 PDT
Created
attachment 170404
[details]
Now with less crashing.
WebKit Review Bot
Comment 13
2012-10-24 08:33:56 PDT
Attachment 170404
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/http..." exit_code: 1 LayoutTests/ChangeLog:10: Line contains tab character. [whitespace/tab] [5] LayoutTests/ChangeLog:14: Line contains tab character. [whitespace/tab] [5] Total errors found: 2 in 34 files If any of these errors are false positives, please file a bug against check-webkit-style.
Ryosuke Niwa
Comment 14
2012-10-24 10:33:12 PDT
Comment on
attachment 170404
[details]
Now with less crashing. View in context:
https://bugs.webkit.org/attachment.cgi?id=170404&action=review
> Source/WebCore/dom/ExceptionDetail.h:45 > + void setRedactedDetail(const String& detail) { m_redactedDetail = detail; }
What is redacted detail?
Mike West
Comment 15
2012-10-24 10:43:01 PDT
(In reply to
comment #14
)
> (From update of
attachment 170404
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=170404&action=review
> > > Source/WebCore/dom/ExceptionDetail.h:45 > > + void setRedactedDetail(const String& detail) { m_redactedDetail = detail; } > > What is redacted detail?
Work-in-progress name for the string that can safely be sent to JavaScript. I haven't yet kicked off the discussion on www-dom about that, so I've only stubbed it out here. The names generally need work. Its clearer in ExceptionBase, perhaps that would be better here too.
Mike West
Comment 16
2012-10-25 00:14:28 PDT
Created
attachment 170568
[details]
Perf tests. Hrm. I ran the perf tests twice on the patch just to be sure: I expected this to be slow, but it's quite a bit worse than I thought it would be on some tests. 'Bindings/node-list-access', for instance, regressed about 25%. Other tests have quite a bit of variance between the two runs. 'bindings/gc-tree' was 2% faster on the first, and 20% slower on the second, for example. Weird. Regardless, any optimization is now no longer premature. ;)
Elliott Sprehn
Comment 17
2012-10-25 00:25:34 PDT
Comment on
attachment 170404
[details]
Now with less crashing. View in context:
https://bugs.webkit.org/attachment.cgi?id=170404&action=review
When I had considered this I had thought about instead making ExceptionCode the new class and renaming the existing enum to ExceptionCodeType. Then adding operator overloads for operator=(ExceptionCodeType), and another for int conversion. That would save you from having to change hundreds of files just to get it working.
> Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp:58 > + if (ed.code())
Should add an UnspecifiedBool operator overload instead.
> Source/WebCore/xml/XMLHttpRequest.cpp:1067 > + ed.setCode(INVALID_STATE_ERR);
Can we just use an operator overload so we don't need to change every call site?
Mike West
Comment 18
2012-10-25 00:38:29 PDT
(In reply to
comment #17
)
> (From update of
attachment 170404
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=170404&action=review
> > When I had considered this I had thought about instead making ExceptionCode the new class and renaming the existing enum to ExceptionCodeType. Then adding operator overloads for operator=(ExceptionCodeType), and another for int conversion. That would save you from having to change hundreds of files just to get it working.
That's much cleverer than what I've done. I did think about a similar approach, but ended up leaning towards an explicit setter for clarity. Assignment seemed unclear when dealing with an object with multiple properties. You're right, though, it would make the whole patch simpler. I might need to reevaluate that decision. Thanks!
Joshua Bell
Comment 19
2012-10-26 09:48:17 PDT
(In reply to
comment #18
)
> (In reply to
comment #17
) > > (From update of
attachment 170404
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=170404&action=review
> > > > When I had considered this I had thought about instead making ExceptionCode the new class and renaming the existing enum to ExceptionCodeType. Then adding operator overloads for operator=(ExceptionCodeType), and another for int conversion. That would save you from having to change hundreds of files just to get it working. > > That's much cleverer than what I've done. I did think about a similar approach, but ended up leaning towards an explicit setter for clarity. Assignment seemed unclear when dealing with an object with multiple properties. > > You're right, though, it would make the whole patch simpler. I might need to reevaluate that decision.
Watch out for the Source/WebKit/public/WebExceptionCode.h and chromium dependencies. Most (but not all) of the use cases are from IndexedDB. We're working to eliminate those, though - most of those call sites are already unused with ASSERT(!ec) but the API plumbing hasn't been cleaned up all the way. It would probably be okay to let WebExceptionCode remain int and ExceptionCode become the structure initially (any codes crossing that API boundary lose details - not a change from current behavior) but it may require a little more operator overloading.
Ryosuke Niwa
Comment 20
2012-10-26 09:53:17 PDT
We prefer explicit setter over operator overloading in WebCore.
Joshua Bell
Comment 21
2012-11-08 15:22:41 PST
One more tidbit: in DOM4 exceptions all have code 0 and names. Right now in code like Modules/indexeddb we need to define a IDBDatabaseException that has custom codes for use with ExceptionCode, e.g.: ec = IDBDatabaseException::DATA_ERR ... and somewhere else that maps that to the name property of "DataError" Ideally the ExceptionCode API would allow for easy use of the DOM4-style exceptions, and let you do the equivalent of: ec.setDOMException("DataError", "some message...") ... that results in a DOMException with |code| = 0, |name| = "DataError", and (relevant to this bug) a |message| property. ... While I'm wishing, WebIDL no longer requires that methods be marked with "raises(DOMException)". It would be great to remove that requirement from WebKitIDL as well, especially as it makes binding code generation messy with optional parameters e.g. an IDL foo(optional a, optional b) needs to have an implementation with foo(a, b, ExceptionCode&), foo(a, ExceptionCode&) and foo(ExceptionCode&). So if this were to move to a mechanism where the ExceptionCode object is not passed in to methods it would be a win all around. That's probably something best tackled separately, though.
Mike West
Comment 22
2012-11-16 09:28:24 PST
Brief update, since a few folks have asked. I'm still working on this, but its been on the back burner the last 2-3 weeks due to some other stuff that needed to get done. I put together a version that lazily instantiated the strings (as 'RefPtr<StringImpl>'), which has much better performance than the naive patch up here, but still double-digit perf regressions on a few tests. I need to worm harder at minimizing that impact. I hope to have a decent version of the patch for review next week. Let's see how that goes.
Darin Adler
Comment 23
2013-02-04 08:55:47 PST
Is there a benefit of RefPtr<StringImpl> over String?
Mike West
Comment 24
2013-02-04 08:59:13 PST
(In reply to
comment #23
)
> Is there a benefit of RefPtr<StringImpl> over String?
Not significant. I was still seeing 15% drops on a few DOM tests. That was months ago, however... I'm thinking now about reversing the flow: pass a pointer around, and only creating the exception object if an exception happens, rather than incurring the cost of creating an object on every call.
Andreas Kling
Comment 25
2014-02-05 11:05:22 PST
Comment on
attachment 170404
[details]
Now with less crashing. Clearing review flag on patches from before 2014. If this patch is still relevant, please reset the r? flag.
Darin Adler
Comment 26
2016-11-08 09:07:09 PST
We’ve dome something similar to this with the new Exception class and ExceptionOr. So we won’t purse this specific approach.
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