Reputation: 13
Now I try to dispatch codes dynamically, for example, SSE, AVX and so on. In a binary file, all codes which will be dispatched at the time of execution are bundled.
I worry that undefined CPU instructions in a code path which will not be executed in the CPU cause unintended behavior via speculative execution or others.
Then, I have two questions.
Upvotes: 1
Views: 99
Reputation: 27974
You are worrying too much. Speculative execution is called speculative because a CPU executes some code only if it thinks it's worth doing so, but can't assume the code won't cause any CPU exceptions. Machine code execution has a strict sequential, instruction-by-instruction, semantics, so the CPU cannot legitimately report issues from the (speculative) future in respect to the (logically) current instruction pointer.
Upvotes: 1