On Oct 5, 2014, at 3:08 PM, Boris Zbarsky <bzbar...@mit.edu> wrote: > On 10/5/14, 2:27 PM, Cameron Zwarich wrote: >> I am opposed to anything that requires string copies between the DOM and JS > > The only way to do that with SpiderMonkey in its current state is to use > JSString for your string type. You cannot safely grab the chars from a > SpiderMonkey string and hold that pointer across a GC operation, because the > GC might move the string data in memory. > > Gecko used to not copy the string on calls from JS to C++, and we had to give > up on that and just copy.
Are there any plans to eliminate the copies in Gecko? If I understand things correctly from reading Blink mailing list posts, pre-Oilpan Blink shares string buffers between V8 and Blink code, despite V8 having a precise moving GC. It looks like they did this by having GC integration for external Blink strings that would trigger a deref of the Blink string buffer when a V8 handle went away. V8 strings that come from Blink strings are in this wrapped representation from the point of their creation. V8-created strings are converted to the external Blink representation on demand. > Now for return values from C++ to JS we do still avoid the copy. But we also > have the one-slot cache which is a big win; you should definitely do that no > matter what else you do with return values... How do you avoid the copy on return values from C++ to JS in Gecko? Thanks, Cameron _______________________________________________ dev-servo mailing list dev-servo@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-servo