[webkit-dev] JavaScriptCore to C++ JSLock questions

Werner Sharp wsharp at adobe.com
Fri Feb 15 06:54:14 PST 2019


Hi everyone,

I’m working on a project that uses JavaScriptCore in interpreted mode along with a lot of C++ classes referenced from JS based upon the JSClassRef concept.  From doing some profiles, the transition from JSC to C++ (or vice-versa) is quite costly because of JSLockHolder, JSLock::dropAllLocks, etc.  I assume there is no way around this in a single threaded single instance of the VM?  Or no way from C++ to wrap a set of JSObjectGet* type of calls in a block somehow allowing only one lock to happen. For example, I need to query 6 properties of a pure JS object from C++.  That takes 6 round trips into JSC so 6 locks unless I do something like return a string representation of the 6 properties and parse them in my C++ code.

On a related note, one thing I’ve found slow is my own implementation of my C++ class’s hasInstance because of the locking.  I tried to leave the JSClassRef hasInstance NULL assuming that the internal instanceOf would work properly.  But that doesn’t appear to work because the JSCallbackObject always sets the ImplementsHasInstance flag but not the ImplementsDefaultHasInstance flag. I would think that “JSCallbackObject<Parent>::customHasInstance” could be enhanced to call defaultHasInstance if JSObjectHasInstanceCallback hasInstance always returns false?

Or if there is some way that defautHasInstance can be called for a JSCallbackObject I’d appreciate to hear about it.

Thanks for your time.

Werner Sharp


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20190215/46167800/attachment.html>


More information about the webkit-dev mailing list