When profiling the microbenchmark from bug 1420440 comment 0 on nightly and stable, I noticed the following stack close to the top of leaf functions list:
3.3% js::SharedScriptDataHasher::match(js::SharedScriptData *,RefPtr<js::SharedScriptData> const &)
3.2% bool std::equal<mozilla::span_details::span_iterator<mozilla::Span<const unsigned char,18446744073709551615>,0>,...
3.0% bool std::_Equal_unchecked<mozilla::span_details::span_iterator<mozilla::Span<const unsigned char,18446744073709551615>,0>,...
It seems like Clang* isn't able to optimize out the release assertions in Span iterators and produces a heavy loop.
Changing Span's operator== implementation from
std::equal(l.begin(), l.end(), r.begin() to
std::equal(l.data(), l.data() + l.size(), r.data() to avoid the iterators does let the compiler generate a memcmp/bcmp call instead.
Same probably applies for operator< and std::lexicographical_compare.
I'm assuming the release assertions can't be dropped, so I propose at least updating the std::equal, std::lexicographical_compare calls.
*For the record, using GCC (or disabling iterator assertions) seems to generate better code, but still not memcmp.