Two asserts where only 1 is needed?

Tony Printezis tony.printezis at sun.com
Tue Jul 17 14:38:09 UTC 2007


Peter,

No, I can't think of a good reason to check the assertion for every call 
to pop_local_slow(). I would think that checking the condition once in 
the constructor would be enough.

Tony

Peter B. Kessler wrote:

> In hotspot/src/share/vm/utilities/taskqueue.hpptaskqueue.hpp,
> there's
>
>     template<class E>
>     GenericTaskQueue<E>::GenericTaskQueue():TaskQueueSuper() {
>       assert(sizeof(Age) == sizeof(jint), "Depends on this.");
>     }
>
> which seems good and proper (except it doesn't say why it
> depends on the sizes being equal).  But there's also
>
>     template<class E>
>     bool GenericTaskQueue<E>::
>     pop_local_slow(juint localBot, Age oldAge) {
>       ....
>       assert(sizeof(Age) == sizeof(jint) && sizeof(jint) == 
> sizeof(juint),
>              "Assumption about CAS unit.");
>
> which checks an additional condition and has a better failure
> message.
>
> Since Atomic::cmpxchg only deals in jint's, I don't see the reason
> for the check of sizeof(juint).  This is the only place in the VM
> that checks sizeof(jint) == sizeof(juint).
>
> Can anyone think of a reason for the assert at each call of
> pop_local_slow if we've passed already passed the assert in
> the ctor?
>
>             ... peter
>
> P.S. I'll probably fix the weird-line wrapping in the declaration
> of GenericTaskQueue<E>::pop_local_slow while I'm in there.


-- 
----------------------------------------------------------------------
| Tony Printezis, Staff Engineer    | Sun Microsystems Inc.          |
|                                   | MS BUR02-311                   |
| e-mail: tony.printezis at sun.com    | 1 Network Drive                |
| office: +1 781 442 0998 (x20998)  | Burlington, MA01803-0902, USA  |
----------------------------------------------------------------------
e-mail client: Thunderbird (Linux)




More information about the hotspot-gc-dev mailing list