Skip to content

Commit

Permalink
Prevent FPE in scaleSizeBasedOnBlockFrequency() float to int32 cast
Browse files Browse the repository at this point in the history
Prevent a FPE when casting a float that is larger then 0x7fffffff
to an int32.

Signed-off-by: Kevin Langman <langman@ca.ibm.com>
  • Loading branch information
klangman committed Dec 2, 2021
1 parent 376e221 commit eec1c59
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runtime/compiler/optimizer/InlinerTempForJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4144,7 +4144,8 @@ int32_t TR_MultipleCallTargetInliner::scaleSizeBasedOnBlockFrequency(int32_t byt
int adjFrequency = frequency ? frequency : 1;

float factor = (float)adjFrequency / (float)maxFrequency;
bytecodeSize = (int32_t)((float)bytecodeSize / (factor*factor));
float weight = (float)bytecodeSize / (factor*factor);
bytecodeSize = (weight > 0x7fffffff) ? 0x7fffffff : ((int32_t)weight);

heuristicTrace(tracer(),"exceedsSizeThreshold: Scaled up size for call from %d to %d", oldSize, bytecodeSize);
}
Expand Down

0 comments on commit eec1c59

Please sign in to comment.