RFR: 8184765: Dynamically resize SystemDictionary

Gerard Ziemski gerard.ziemski at oracle.com
Mon Oct 30 15:52:22 UTC 2017


> On Oct 30, 2017, at 10:36 AM, coleen.phillimore at oracle.com wrote:
> 
> 
> 
> On 10/30/17 11:24 AM, Gerard Ziemski wrote:
>> hi Coleen,
>> 
>> 
>>> On Oct 30, 2017, at 10:12 AM, coleen.phillimore at oracle.com wrote:
>>> 
>>> 
>>> Hi Gerard,
>>> 
>>> This looks great.  One small question:
>>> + // straight forward brute force
>>> + inline static int _next_prime(int n) {
>>> +   int p = n;
>>> +   for (int i = n; i < (n * n); i++) {
>>> +     if ((i % 2) != 0) {
>>> +       p = i;
>>> +       break;
>>> +     }
>>> +   }
>>> +   return p;
>>> + }
>>> 
>>> Is this how you calculate next prime?  Wouldn't you check if it can mod by 3 and 5 as well?
>> As long as it’s not even i.e. mod 2 (and strictly speaking larger than 1). 3 and 5 are prime, so no need to check them.
> 
> If you passed in 214 (2*107), 215 would look prime but it's not.   I think the prime table would be better and limit resizing occurrences.

Right, need something a bit more clever here. A precomputed prime table might be good enough, but let me see how complex (a correct) function has to be.


cheers


More information about the hotspot-runtime-dev mailing list