3 ms·
Ah yeah, I wasn't sure if fusion was going to happen. You're probably right in macro-op terms; sorry about that. The first compare is a bounds check against th
by pcwalton 11y ago
Ah yeah, I wasn't sure if fusion was going to happen. You're probably right in macro-op terms; sorry about that.
The first compare is a bounds check against the array backing the pool, and the second compare is against the type field on the interface, not a null check. Golang interfaces are "fat pointers" with two words: a data pointer and a vtable pointer. So the first cmp is against a register, while the second cmp is against memory, data dependent on the register index. The address of the cmp has to be at least checked to determine if it faults, so I would think at least some part of it would have to be serialized after the first branch, making it slower than the version without the type guard.
- vardump 11y ago> Ah yeah, I wasn't sure if fusion was going to happen. Well, I didn't profile that case. Who knows what will really happen. Modern x86 processors are hard to understand. > ... while the second cmp is against memory, data dependent on the register index Hmm... that sounds like something that would dominate the cost? Memory access and data dependency. Ouch. Also of course in that case, second compare+branch can't be fused, because cmp has a memory operand.