<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 3, 2023 at 8:12 AM Ioi Lam <<a href="mailto:ioi.lam@oracle.com">ioi.lam@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 2/1/2023 10:37 PM, David Holmes wrote:<br>
> <trimming><br>
><br>
> On 2/02/2023 3:25 pm, Thomas Stüfe wrote:<br>
>> On Thu, Feb 2, 2023 at 5:30 AM David Holmes <<a href="mailto:david.holmes@oracle.com" target="_blank">david.holmes@oracle.com</a> <br>
>> <mailto:<a href="mailto:david.holmes@oracle.com" target="_blank">david.holmes@oracle.com</a>>> wrote:<br>
>><br>
>>     That would have to be determined case-by-case. For each ergo flag we<br>
>>     would have to decide what value it is calculating and based on what,<br>
>>     and<br>
>>     determine whether an out-of-range value is an error or something <br>
>> to be<br>
>>     wary of.<br>
>><br>
>> Sure, what I meant was how to control it? Two sets of FLAT_SET_... <br>
>> macros, one that asserts on constraint violation, one that caps?<br>
><br>
> No I expect to just see the places where FLAG_SET_ERGO is called do <br>
> the right thing by checking the return value and proceeding accordingly.<br>
<br>
David, are you proposing this?<br>
<br>
    int value = calculate_ergo();<br>
    if (FLAG_SET_ERGO (TheFlag, value) == error) {<br>
      value = do_it_again()<br>
      if (FLAG_SET_ERGO (TheFlag, value) == error) {<br>
         huh?<br>
      }<br>
    }<br>
<br>
In the above code, all FLAG_SET_ERGO does is to check the range for you. <br>
It doesn't tell you why the range check fails. So the caller would have <br>
to redo the calculation (with no more information, other than that the <br>
last value was no good). What if the new value is also no good?<br>
<br>
With this style, you almost have to wrap every FLAG_SET_ERGO  in a loop, <br>
keep trying (in the dark) until you succeed.<br>
<br>
==================<br>
I think it's better to just assert inside FLAG_SET_ERGO if the value is <br>
out of range. The caller should make sure it has calculated a correct value.<br>
<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Maybe we can add a new FLAG_SET_ERGO_CAPPED() that would cap the value, <br>
but that should be an opt-in. FLAG_SET_ERGO() should not automatically <br>
cap the value.<br>
<br></blockquote><div><br></div><div>That sounds like a pragmatic solution. The CAPPED version may not even be needed. I expects the asserts mostly to fire for "special" values, as in the cited case of NonNMethodCodeHeapSize, and point to problems in the constraint function itself, which should accept special values.</div><div><br></div><div>Cheers, Thomas</div></div></div>