On Sun, Oct 7, 2012 at 5:44 PM, Timothy Baldridge <tbaldri...@gmail.com>wrote:
> While digging through the CLJS sources I've seen that protocols use some > sort of odd bitmask optimization. Is this documented anywhere? > > Or as a more general question, is the way protocols are implemented in > CLJS documented at all? > > Thanks, > > Timothy > Nothing beyond the source. The bitmask optimization was because V8 was penalizing us for adding too many non-function properties onto the prototypes like so: cljs.core.Vector.prototype.cljs$core$ISeq = true; This was done to support satisfies?. We can now know that vectors satisfy ISeq. But as I said above, it turned out as we began implementing the persistent data structures and implementing many protocols - V8 would deoptimize when using this approach. So we needed a different way to encode this information. Every deftype/record instance now has a 1 or 2 integer fields which represents a bit mask of all the core protocols that a particular type implements. V8 stopped penalizing us and this approach has the added benefit of satisfies? now being nearly as fast as native instanceof. David -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en