Closed
Bug 934544
Opened 11 years ago
Closed 11 years ago
Speed up the "copy the string" case for short strings when converting strings to jsval
Categories
(Core :: XPConnect, defect)
Tracking
()
RESOLVED
FIXED
mozilla28
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
(Blocks 2 open bugs)
Details
(Keywords: perf, Whiteboard: [qa-])
Attachments
(1 file, 1 obsolete file)
We changed DOMString to use an nsAutoString in bug 920209, since that traded off one allocation (when creating the JSString) for multiple allocations while appending. But we can avoid the allocation when creating the JSString too, for short strings: the JS engine will use a JSShortString for those as needed, and store the data inline in its GC bits. That will also mean no need for an interesting finalizer for those strings. All we need to do is stop manually creating the JSString and ask the JS engine to do it for us. ;)
Assignee | ||
Comment 1•11 years ago
|
||
Attachment #826846 -
Flags: review?(peterv)
Assignee | ||
Comment 2•11 years ago
|
||
Attachment #826852 -
Flags: review?(peterv)
Assignee | ||
Updated•11 years ago
|
Attachment #826846 -
Attachment is obsolete: true
Attachment #826846 -
Flags: review?(peterv)
Comment 3•11 years ago
|
||
Comment on attachment 826852 [details] [diff] [review] For the case when we have to copy an XPCOM string into a JSString, just ask the JS engine to do that. It'll do a better job of avoiding malloc than we can, since it can sometimes store string data inline in the string. \o/
Attachment #826852 -
Flags: review?(peterv) → review+
Assignee | ||
Updated•11 years ago
|
Assignee | ||
Comment 4•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/9957e9fe5063
Component: XPCOM → XPConnect
Flags: in-testsuite-
Keywords: perf
Whiteboard: [need review]
Target Milestone: --- → mozilla28
Comment 5•11 years ago
|
||
Sorry, just seeing this now because of XPConnect. You seem to ignore a failure and just make that a NullValue? Actually it looks like this method is not prepared for error handling.
Assignee | ||
Comment 6•11 years ago
|
||
The API for this method blows chunks, agreed. If you actually look at the callers, they look like this: 197 jsval str = XPCStringConvert::ReadableToJSVal(cx, *p, &buf); 198 if (JSVAL_IS_NULL(str)) 199 return false; 812 jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer); 813 if (JSVAL_IS_NULL(jsstr)) 814 return false; 836 jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer); 837 if (JSVAL_IS_NULL(jsstr)) 838 return false; 340 jsval jsstr = XPCStringConvert::ReadableToJSVal(ccx, aName, &buf); 341 if (JSVAL_IS_NULL(jsstr)) 342 return NS_ERROR_OUT_OF_MEMORY; Arguably we should change this method to just return a JSString*, with null signaling OOM. I didn't want to mess with that in this bug, though, but happy to do it in a followup.
Flags: needinfo?(evilpies)
Comment 7•11 years ago
|
||
Oh sorry, didn't think we would do something like this. ^^ I can write a patch as well.
Flags: needinfo?(evilpies)
Assignee | ||
Comment 8•11 years ago
|
||
Welcome to XPConnect, and if you write it, I'll review!
https://hg.mozilla.org/mozilla-central/rev/9957e9fe5063
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Updated•10 years ago
|
Whiteboard: [qa-]
You need to log in
before you can comment on or make changes to this bug.
Description
•