On Wed, Oct 04, 2017 at 12:42:22AM -0400, Boris Zbarsky wrote:
On 10/2/17 9:50 PM, Kris Maglione wrote:
For the pretty simple micro-benchmark below, here are the in-document and out-of-document numbers for three runs without the subject principal:

Sorry, I should have been clearer: I meant numbers for "inserted into the document" and "not inserted into the document".

Well, on the upside, if I hadn't misread you, I wouldn't have thought to check the cross-document case (which is pretty relevant to subject principal checks), but would have thought to check inserted vs. non-inserted, so I think it came out for the best :)

I just did a bit of testing with a non-inlined no-op function and it looks like the overhead of NeedsSubjectPrincipal is on the order of maybe 1-2ns. Looks like the actual implementation we end up using mostly consists of reinterpret_cast, which is nice and fast. ;) There's one memory read from the JSContext to get the compartment, and one memory read from the compartment to get the principal; as long a those hit cache all is good.

I'd be pretty surprised if we ever manage to get to that point without both locations being in the cache. We check compartment flags all over the place when JS is running. Maybe just after a block of pure JIT code that touched a huge amount of memory...

So, yeah, it doesn't seem like it should be an issue in practice.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to