If one specifies a 2 TB heap with G1, the CardIdx_t type (which is int) can not represent all cards in the heap any more.
I.e. 2^31 * 2^9 (card size in bytes) = 2^40 = 1 TB.
There are several calculations in the code (like actually calculating the card # for a given heap word :)) that are in danger of overflow in this case.
Note that there are applications using G1 with 1 TB heaps right now, and a customer intends to test on larger heaps in the near future.
Since the card size is hardcoded as 512 bytes, there is no workaround.
It would probably be best to use a size_t for it. Make sure that all operands calculating CardIdx_t values are also good.