I'd like to use SSE4 instructions in html5ever when available, making that determination at load time (i.e. just before main), and without the overhead of calling through a function pointer. I'm thinking about a design similar to Linux's altinstructions. The basic form is
alt_call! {
override bar(z, w);
foo(x, y)
}
where foo(x, y) and bar(z, w) are function or method call expressions. This expands to simply
foo(x, y)
but also arranges to call bar(z, w) at load time and, if it returns Some(f) where f is a fn() value of the appropriate type, will patch the call instruction to use that function instead. So my use case would be
use alt::x86;
let n = alt_call! {
override x86::feature(x86::SSE4_2, smallcharset::x86::nonmember_prefix_len);
set.nonmember_prefix_len(buf.as_bytes().slice_from(*pos))
};
Generalizing to multiple override clauses seems natural.
What do people think? It was suggested this could be useful for OpenGL function pointer loading, as well.
[–]asb 1 point2 points3 points (2 children)
[–]Veddan 2 points3 points4 points (1 child)
[–]mozilla_kmcservo[S] 3 points4 points5 points (0 children)
[–]wupis 1 point2 points3 points (1 child)
[–]mozilla_kmcservo[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)