Click here to Skip to main content
14,841,092 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: bizarro land coding Pin
honey the codewitch5-Jan-21 0:21
mvahoney the codewitch5-Jan-21 0:21 
GeneralRe: bizarro land coding Pin
Randor 5-Jan-21 0:35
professional Randor 5-Jan-21 0:35 
GeneralRe: bizarro land coding Pin
honey the codewitch5-Jan-21 0:45
mvahoney the codewitch5-Jan-21 0:45 
QuestionRe: bizarro land coding Pin
Randor 5-Jan-21 0:56
professional Randor 5-Jan-21 0:56 
AnswerRe: bizarro land coding Pin
honey the codewitch5-Jan-21 1:06
mvahoney the codewitch5-Jan-21 1:06 
GeneralRe: bizarro land coding Pin
Randor 5-Jan-21 1:24
professional Randor 5-Jan-21 1:24 
GeneralRe: bizarro land coding Pin
honey the codewitch5-Jan-21 1:35
mvahoney the codewitch5-Jan-21 1:35 
GeneralRe: bizarro land coding Pin
Randor 4-Jan-21 19:37
professional Randor 4-Jan-21 19:37 
Stuart,

We are discussing jump tables in the CPU related to branch prediction. There are two address locations in the example you have given that would be added to the jump table. Both the je and jne would result in a jump table entry. It's actually extremely easy to understand:

Branch prediction basically works like this: (note that this is a simplification and each vendor does it differently)
- As your program is executing the CPU tracks each and every time a jump instruction has executed. It keeps a table of the address of these jumps and increments an internal counter each time that jump instruction is executed.
- As executable code is being loaded and cached, the cpu attempts to predict which path will be executed. It uses that internal counter as a 'weight'. In other words previous taken paths have a higher probability of being chosen. If it incorrectly predicts a path... this is known as a branch misprediction. After a misprediction the cpu has to throw away everything it just computed and go back and predict the path again until it gets it right.(This is actually the core problem with the spectre vulnerability[^]) as you can look at the timing and use very small intervals of time to know what is inside the cpu cache.

The likely and unlikely keywords effect the ordering of the jump instructions in such a way so that branch prediction will be more accurate.

Best Wishes,
-David Delaune

modified 5-Jan-21 3:48am.

GeneralRe: bizarro land coding Pin
honey the codewitch4-Jan-21 23:39
mvahoney the codewitch4-Jan-21 23:39 
GeneralRe: bizarro land coding Pin
honey the codewitch4-Jan-21 7:14
mvahoney the codewitch4-Jan-21 7:14 
GeneralRe: bizarro land coding Pin
Rick York3-Jan-21 11:34
mveRick York3-Jan-21 11:34 
GeneralRe: bizarro land coding Pin
honey the codewitch3-Jan-21 11:59
mvahoney the codewitch3-Jan-21 11:59 
GeneralRe: bizarro land coding Pin
Greg Utas3-Jan-21 12:39
mvaGreg Utas3-Jan-21 12:39 
GeneralFace Recognition App Pin
Kevin Marois3-Jan-21 7:59
professionalKevin Marois3-Jan-21 7:59 
GeneralRe: Face Recognition App Pin
Nelek3-Jan-21 10:15
protectorNelek3-Jan-21 10:15 
GeneralLocal Polymorphism Pin
Gerry Schmitz3-Jan-21 4:50
mveGerry Schmitz3-Jan-21 4:50 
GeneralRe: Local Polymorphism Pin
PIEBALDconsult3-Jan-21 5:28
professionalPIEBALDconsult3-Jan-21 5:28 
GeneralRe: Local Polymorphism Pin
Daniel Pfeffer3-Jan-21 6:07
professionalDaniel Pfeffer3-Jan-21 6:07 
GeneralRe: Local Polymorphism Pin
OriginalGriff3-Jan-21 7:38
mveOriginalGriff3-Jan-21 7:38 
GeneralRe: Local Polymorphism Pin
honey the codewitch3-Jan-21 7:53
mvahoney the codewitch3-Jan-21 7:53 
GeneralRe: Local Polymorphism Pin
OriginalGriff3-Jan-21 8:20
mveOriginalGriff3-Jan-21 8:20 
GeneralRe: Local Polymorphism Pin
honey the codewitch3-Jan-21 8:23
mvahoney the codewitch3-Jan-21 8:23 
GeneralRe: Local Polymorphism Pin
OriginalGriff3-Jan-21 8:56
mveOriginalGriff3-Jan-21 8:56 
GeneralRe: Local Polymorphism Pin
honey the codewitch3-Jan-21 9:02
mvahoney the codewitch3-Jan-21 9:02 
GeneralRe: Local Polymorphism Pin
Mike Hankey3-Jan-21 8:18
professionalMike Hankey3-Jan-21 8:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.