T) + 1;
Comparison of J:\JAE1_2T\src\share\javavm\runtime\UTF8POOL.C and
J:\PC\SHARE\javavm\runtime\UTF8POOL.C
Version 1.13
----------------------------------------------------- Power of 2
L55 /* The alignement unit for entries: must be a power of 2 */
L56 #define UTF8PoolAlignment 4
R55 /* The alignement unit for entries */
R56 #define UTF8PoolAlignment 6
----------------------------------------------------- Power of 2
L193 (length + UTF8PoolAlignment - 1) &~ (UTF8PoolAlignment - 1);
R193 ((length + UTF8PoolAlignment - 1) / UTF8PoolAlignment) *
UTF8PoolAlignment;
----------------------------------------------------- Power of 2
L634 (length + UTF8PoolAlignment - 1) &~ (UTF8PoolAlignment - 1);
R634 ((length + UTF8PoolAlignment - 1) / UTF8PoolAlignment) *
UTF8PoolAlignment;
Comparison of J:\JAE1_2T\src\solaris\javavm\green_threads\include\SPARC_MD.H and
J:\PC\NX\javavm\green_threads\include\SPARC_MD.H
Version 1.6
----------------------------------------------------- Power of 2
L53 #define STACK_ALIGN 8
L54 #define SA(X) (((X)+(STACK_ALIGN-1)) & ~(STACK_ALIGN-1))
R53 #define STACK_ALIGN (sizeof (LONG DOUBLE))
R54 #define SA(X) ((((X)+(STACK_ALIGN-1)) / STACK_ALIGN) * STACK_ALIGN)
Comparison of J:\JAE1_2T\src\solaris\javavm\include\GC_MD.H and
J:\PC\NX\javavm\include\GC_MD.H
Version 1.6
----------------------------------------------------- Power of 2
L89 #define PAGE_ALIGNMENT (64 * 1024) /* page size is the same. */
R89 #define PAGE_ALIGNMENT (((64 * 1024 + sizeof(long double) - 1) /
sizeof (long double)) * sizeof (long double)) /* srb */ /* page size is the
same. */
----------------------------------------------------- Power of 2
L93 #define PTR_2_PAGE_SHIFT (16)
R93 /* #define PTR_2_PAGE_SHIFT (16) - use "/" instead - srb */
Comparison of J:\JAE1_2T\src\solaris\javavm\include\OOBJ_MD.H and
J:\PC\NX\javavm\include\OOBJ_MD.H
Version 1.11
----------------------------------------------------- Power of 2
L26 #define OBJECT_SIZE_SHIFT 2 /* log2(sizeof(OBJECT)) */
R26 #define OBJECT_SIZE_FACTOR sizeof(OBJECT) /* srb */
Comparison of J:\JAE1_2T\src\solaris\javavm\runtime\MEMORY_MD.C and
J:\PC\NX\javavm\runtime\MEMORY_MD.C
Version 1.16
----------------------------------------------------- Power of 2
L67 return (value + memGrainSize - 1) & ~(memGrainSize - 1);
R67 /* srb - do not require memGrainSize to be power of 2 */
R68 return ((value + memGrainSize - 1) / memGrainSize) * memGrainSize;
----------------------------------------------------- Power of 2
L73 return value & ~(memGrainSize - 1);
R74 /* srb - do not require memGrainSize to be power of 2 */
R75 return (value / memGrainSize) * memGrainSize;
----------------------------------------------------- Power of 2
L80 extern unsigned int memGrainSize;
Licensee made a minimal effort to produce source that is more portable.
In several cases, however, the effort to do so was too large and the change will
only work on licensee platform. In other cases, licensee kept the code in the
shared directory instead of moving it into the platform specific directory.
Obviously these changes will need much more work before they can be released.
In the following patch listing, "L" refers to the left path which is original
file from JavaSoft and "R" refers to the right path which is our modified file.
At the end of each "---------" line is Power of 2, see below for explanation.
Portability, "Power of 2" explanation:
Places in the shared directory assume that the platform's native word size is a
power of 2. That is, sizeof(int) is 4 or 8. On the ClearPath HMP NX (A Series)
platform, the native word size is 6 bytes. A double word is 12 bytes. So
sizeof(int) is 6 and sizeof(long double) is 12. Note that our pointers are
always offsets in terms of bytes (the ClearPath HMP IX or 2200 Series has
pointers that are word offsets or byte offsets). This means that :
1) constant values like 4 and 8 need to be sizeof(<type>) instead.
2) pointers to double-word align objects in the heap may not have their low
three bits be 0. To ensure that the low three bits in the pointer are zero, the
object has to be aligned to a multiple of 24 bytes (an obvious waste of space).
Ideally, the location of the bits should be defined by macros in the platform
headers. We have spare bits elsewhere in the word that could be used, allow
objects to be word aligned only.
3) Adding 3 and then ANDing (&) a mask with the low two bits off does not align
to the next word boundary Ditto for adding 7 and ANDing a mask with the low
three bits off for double word alignment.. In fact, ANDing is not usable for
alignment on our platform and a div (/) or mod (%) has to be used.
4) Shifting a pointer left 3 bits does not reduce it to a OBJECTGRAIN offset. A
division is required. Ditto for computhing which page an address is in.
5) The size of a scalar type can still be represented in a two bit field
(T_SIZEFIELD), but that representation is not log2 of the size. For our
platform, the sizes are:
char 1
short 6
int 6
double 12
6) Hardware page sizes are not a power of 2. In fact, no sizes are a power of
2.
Specific examples/code fixes to follow:
Comparison of J:\JAE1_2T\src\share\javavm\include\GC.H and
J:\PC\SHARE\javavm\include\GC.H
Version 1.16
----------------------------------------------------- Power of 2
L38 #define OBJECTGRAIN 8
L39 #define HANDLEGRAIN 8
R38 #define OBJECTGRAIN (sizeof (long double) * 2) /* srb */
R39 #define HANDLEGRAIN (sizeof (long double) * 2) /* srb */
----------------------------------------------------- Power of 2
L72 #define h_len(h) ((h) & (~(OBJECTGRAIN-1)^SWAPPED))
R72 #define h_len(h) ((((h) & ~SWAPPED) / OBJECTGRAIN) * OBJECTGRAIN)/*srb*/
R73 #define h_slen(h) (((h) / OBJECTGRAIN) * OBJECTGRAIN) /* srb */
----------------------------------------------------- Power of 2
L76 #define obj_len(p) (obj_geth(p)&(~(OBJECTGRAIN-1)^SWAPPED))
R77 #define obj_len(p) (((obj_geth(p) & ~SWAPPED) / OBJECTGRAIN) *
OBJECTGRAIN) /* srb */
----------------------------------------------------- Power of 2
L91 #define MarkPtr(p) _MarkPtr(((unsigned int) (p) & ~(OBJECTGRAIN - 1)))
L92 #define ClearMarkPtr(p) _ClearMarkPtr(((unsigned
int)(p)&~(OBJECTGRAIN-1)))
L93 #define IsMarked(p) _IsMarked((unsigned int) (p) & ~(OBJECTGRAIN - 1))
R92 #define MarkPtr(p) _MarkPtr(h_slen((unsigned int) (p))) /* srb */
R93 #define ClearMarkPtr(p) _ClearMarkPtr(h_slen((unsigned int)(p))) /*srb*/
R94 #define IsMarked(p) _IsMarked(h_slen((unsigned int) (p))) /* srb */
----------------------------------------------------- Power of 2
L98 #define ValidObject(p) ((((int)(p)) & (OBJECTGRAIN-1)) == 0 &&
(unsigned char *)(p) >= opmin &&
(unsigned char *)(p) < opmax)
L99 #define ValidHandle(p) (((int) (p) & (sizeof(JHandle)-1)) == 0 &&
(unsigned char *)(p) >= hpmin &&
(unsigned char *)(p) <= hpmax)
----------------------------------------------------- Power of 2
R99 #define ValidObject(p) ((((int)(p)) % OBJECTGRAIN) == 0 &&
(unsigned char *)(p) >= opmin &&
(unsigned char *)(p) < opmax)
R100 #define ValidHandle(p) (((int) (p) % sizeof(JHandle)) == 0 &&
(unsigned char *)(p) >= hpmin &&
(unsigned char *)(p) <= hpmax)
----------------------------------------------------- Power of 2
L101 #define ValidHorO(p) (((int) (p) & (OBJECTGRAIN-1)) == 0 &&
(unsigned char *)(p) >= hpmin &&
(unsigned char *)(p) <= opmax)
R102 #define ValidHorO(p) (((int) (p) % OBJECTGRAIN) == 0 &&
(unsigned char *)(p) >= hpmin &&
(unsigned char *)(p) <= opmax)
----------------------------------------------------- Power of 2
L109 #define MARKINDEX(p) (((unsigned char *)(p) - hpmin) >> 8)
L110 #define BITOFFSET(p) ((((unsigned char *)(p) - hpmin) >> 3) & 0x1f)
R110 #define MARKINDEX(p) (((unsigned char *)(p) - hpmin) /
(OBJECTGRAIN*32)) /* srb */
R111 #define BITOFFSET(p) ((((unsigned char *)(p) - hpmin) / OBJECTGRAIN) &
0x1f) /* srb */
Comparison of J:\JAE1_2T\src\share\javavm\include\OOBJ.H and
J:\PC\SHARE\javavm\include\OOBJ.H
Version 1.93
----------------------------------------------------- Power of 2
L59 #define ALIGN(n) (((n)+3)&~3)
R59 #define ALIGN(n) ((((n)+sizeof(int)-1)/sizeof(int))*sizeof(int)) /*srb*/
Comparison of J:\JAE1_2T\src\share\javavm\include\TYPECODES.H and
J:\PC\SHARE\javavm\include\TYPECODES.H
Version 1.10
----------------------------------------------------- Power of 2
R115 extern int srb_size_factors [4];
----------------------------------------------------- Power of 2
L120 #define T_ELEMENT_SIZE(t) (1<<T_SIZEFIELD(t)) /* only for some!! */
R121 #define T_ELEMENT_SIZE(t) (srb_size_factors [T_SIZEFIELD(t)]) /* srb -
only for some!! */
Comparison of J:\JAE1_2T\src\share\javavm\runtime\CLASSRESOLVER.C and
J:\PC\SHARE\javavm\runtime\CLASSRESOLVER.C
Version 1.123
----------------------------------------------------- Power of 2
L1061 ptr = sysMalloc(sizeof(struct methodtable)
L1062 + (mslot - 1)* sizeof(struct methodblock *)
L1063 + FLAG_MASK);
R1061 /* srb - should be Least Common Multiple of sizeof(int) [6 for
R1062 E-mode and FLAG_MASK+1 */
R1063 #define METHODALIGNMENT ((FLAG_MASK+1) * 3)
R1064 ptr = sysMalloc(sizeof(struct methodtable)
R1065 + (mslot - 1)* sizeof(struct methodblock *)
R1066 + METHODALIGNMENT - 1);
----------------------------------------------------- Power of 2
L1069 new_table = (struct methodtable *)((((long)ptr) + FLAG_MASK) &
LENGTH_MASK);
R1072 new_table = (struct methodtable *)
R1073 (((((long)ptr) + METHODALIGNMENT - 1) / METHODALIGNMENT)
R1074 * METHODALIGNMENT);
Comparison of J:\JAE1_2T\src\share\javavm\runtime\GC.C and
J:\PC\SHARE\javavm\runtime\GC.C
Version 1.206
----------------------------------------------------- Power of 2
L743 sysAssert((size & (OBJECTGRAIN-1)) == 0);
R743 sysAssert((size % OBJECTGRAIN) == 0); /* srb */
----------------------------------------------------- Power of 2
L770 sysAssert((old_obj & (OBJECTGRAIN-1)) == 0);
R770 sysAssert((old_obj % OBJECTGRAIN) == 0); /* srb */
---------------------------------------------------- Power of 2
L775 sysAssert((new_obj & (OBJECTGRAIN-1)) == 0);
R775 sysAssert((new_obj % OBJECTGRAIN) == 0); /* srb */
----------------------------------------------------- Power of 2
L944 sysAssert((((long) p + sizeof(hdr)) & (OBJECTGRAIN - 1))
== 0);
R944 sysAssert((((long) p + sizeof(hdr)) % /* srb */
R945 OBJECTGRAIN) == 0);
----------------------------------------------------- Power of 2
L982 size_t alignedHeaderSize = (sizeof(ChunkBlk) + inner_alignment -
1)
L983 & ~(inner_alignment - 1);
R983 size_t alignedHeaderSize =
R984 ((sizeof(ChunkBlk) + inner_alignment - 1) / inner_alignment) *
R985 inner_alignment; /* srb */
----------------------------------------------------- Power of 2
L995 /* save another (at least) 8 bytes for overwrite detection: */
L996 reqSize -= (inner_alignment > 8) ? inner_alignment : 8;
R997 /* save another (at least) 2 words for overwrite detection: */
R998 reqSize -= (inner_alignment > 2*sizeof(int)) ? inner_alignment :
R999 2*sizeof(int);
----------------------------------------------------- Power of 2
L999 *((int32_t *)(chunk->physEndPtr - 8)) = ALMOST_WORD;
L1000 *((int32_t *)(chunk->physEndPtr - 4)) = ULTIMATE_WORD;
R1002 ((int *)(chunk->physEndPtr))[-2] = ALMOST_WORD; /* srb */
R1003 ((int *)(chunk->physEndPtr))[-1] = ULTIMATE_WORD; /* srb */
----------------------------------------------------- Power of 2
L1052 n = (n0 + sizeof(hdr) + (OBJECTGRAIN - 1)) & ~(OBJECTGRAIN - 1);
R1055 n = ((n0 + sizeof(hdr) + (OBJECTGRAIN - 1)) / OBJECTGRAIN) *
R1056 OBJECTGRAIN; /* srb */
----------------------------------------------------- Power of 2
L1205 n = (n0 + sizeof(hdr) + (OBJECTGRAIN - 1)) & ~(OBJECTGRAIN - 1);
R1209 n = ((n0 + sizeof(hdr) + (OBJECTGRAIN - 1)) / OBJECTGRAIN) *
R1210 OBJECTGRAIN; /* srb */
----------------------------------------------------- Power of 2
R1414
R1415 int srb_size_factors [4] = { /* srb - support non-power of 2 sizes */
R1416 sizeof (char),
R1417 sizeof (short),
R1418 sizeof (int),
R1419 sizeof (long double) };
R1420
----------------------------------------------------- Power of 2
L1416 return l << ((t == T_CLASS) ? OBJECT_SIZE_SHIFT : T_SIZEFIELD(t));
R1428 return l * ((t == T_CLASS) ? OBJECT_SIZE_FACTOR /* srb */
R1429 : T_ELEMENT_SIZE(t)); /* srb */
----------------------------------------------------- Power of 2
L1443 int eltshift;
----------------------------------------------------- Power of 2
L1448 eltshift = (t == T_CLASS ? OBJECT_SIZE_SHIFT : T_SIZEFIELD(t));
L1449
----------------------------------------------------- Power of 2
L1451 if (l < 0 || ((l + 1) >> (sizeof(int) * 8 - 1 - eltshift)))
R1461 if (l < 0) /* srb -- work still in progress!!! */
----------------------------------------------------- Power of 2
L1454 size = l << eltshift;
R1464 size = sizearray (t, l); /* srb */
----------------------------------------------------- Power of 2
L1521 mem_top = (void *)(((int)blkP->endPtr + PAGE_ALIGNMENT - 1)
L1522 & ~(PAGE_ALIGNMENT - 1));
R1531 mem_top = (void *)((((int)blkP->endPtr + PAGE_ALIGNMENT - 1)
R1532 / PAGE_ALIGNMENT) * PAGE_ALIGNMENT); /* SRB */
----------------------------------------------------- Power of 2
L1549 mem_top = (void *)(((int)blkP->endPtr + PAGE_ALIGNMENT - 1)
L1550 & ~(PAGE_ALIGNMENT - 1));
R1559 mem_top = (void *)((((int)blkP->endPtr + PAGE_ALIGNMENT - 1)
R1560 / PAGE_ALIGNMENT) *
PAGE_ALIGNMENT);/*SRB*/
----------------------------------------------------- Power of 2
L1677 int numPages = (blkP->allocSize >> PTR_2_PAGE_SHIFT) + 1;
R1687 int numPages = (blkP->allocSize / PAGE_ALIGNMENT) + 1;
----------------------------------------------------- Power of 2
L1687 firstMapIndex = ((int)blkP - (int)mem_base) >> PTR_2_PAGE_SHIFT;
R1697 firstMapIndex = ((int)blkP - (int)mem_base) / PAGE_ALIGNMENT;
----------------------------------------------------- Power of 2
L1916 needPages = (sz >> PTR_2_PAGE_SHIFT) + 2;
R1926 needPages = (sz / PAGE_ALIGNMENT) + 2;
----------------------------------------------------- Power of 2
L2093 incr = (incr + HANDLEGRAIN - 1) & ~(HANDLEGRAIN - 1);
R2103 incr = ((incr + HANDLEGRAIN - 1) / HANDLEGRAIN)*HANDLEGRAIN; /*SRB*/
----------------------------------------------------- Power of 2
L2111 (((int) hpool + HANDLEGRAIN-1) & ~(HANDLEGRAIN-1));
R2121 ((((int) hpool + HANDLEGRAIN-1)/HANDLEGRAIN)*HANDLEGRAIN);/*SRB*/
----------------------------------------------------- Power of 2
L2184 incr = (incr + OBJECTGRAIN - 1) & ~(OBJECTGRAIN - 1);
R2194 incr = ((incr + OBJECTGRAIN - 1) / OBJECTGRAIN)*OBJECTGRAIN; /*srb*/
----------------------------------------------------- Power of 2
L3814 if (!((lowest_len - plen) & (OBJECTGRAIN - 1)) == 0)
{
R3824 if (!((lowest_len - plen) % OBJECTGRAIN) == 0) {
/*srb*/
----------------------------------------------------- Power of 2
L3817 & (OBJECTGRAIN - 1)) == 0);
R3827 % OBJECTGRAIN) == 0); /* srb */
----------------------------------------------------- Power of 2
L4712 if (! expandHandleSpace((((int)(min_request * 0.20)) >>
L4713 PTR_2_PAGE_SHIFT) + 1)) {
R4722 if (! expandHandleSpace((((int)(min_request * 0.20)) /
R4723 PAGE_ALIGNMENT) + 1)) {
----------------------------------------------------- Power of 2
L4804 ((int) ((hpoollimit - hpool) * 0.20) & ~(HANDLEGRAIN - 1));
R4815 ((((int) ((hpoollimit - hpool) * 0.20)) / /* SRB */
R4816 HANDLEGRAIN) * HANDLEGRAIN);
----------------------------------------------------- Power of 2
L4810 while (((int) opool + sizeof(hdr)) & (OBJECTGRAIN - 1)) {
R4822 while (((int) opool + sizeof(hdr)) % OBJECTGRAIN) { /* srb */
----------------------------------------------------- Power of 2
L4875 FreeMemoryLowWaterMark = (long) (0.2 * FreeObjectCtr) &
~(OBJECTGRAIN - 1);
R4888 FreeMemoryLowWaterMark = ((long) ((0.2 * FreeObjectCtr) /
R4889 OBJECTGRAIN) * OBJECTGRAIN);
----------------------------------------------------- Power of 2
L5370 handlePagesByList += (blkP->allocSize >> PTR_2_PAGE_SHIFT) +
1;
R5384 handlePagesByList += (blkP->allocSize / PAGE_ALIGNMENT) + 1;
----------------------------------------------------- Power of 2
L5379 objectPagesByList += (blkP->allocSize >> PTR_2_PAGE_SHIFT) +
1;
R5393 objectPagesByList += (blkP->allocSize / PAGE_ALIGNMEN
Comparison of J:\JAE1_2T\src\share\javavm\runtime\UTF8POOL.C and
J:\PC\SHARE\javavm\runtime\UTF8POOL.C
Version 1.13
----------------------------------------------------- Power of 2
L55 /* The alignement unit for entries: must be a power of 2 */
L56 #define UTF8PoolAlignment 4
R55 /* The alignement unit for entries */
R56 #define UTF8PoolAlignment 6
----------------------------------------------------- Power of 2
L193 (length + UTF8PoolAlignment - 1) &~ (UTF8PoolAlignment - 1);
R193 ((length + UTF8PoolAlignment - 1) / UTF8PoolAlignment) *
UTF8PoolAlignment;
----------------------------------------------------- Power of 2
L634 (length + UTF8PoolAlignment - 1) &~ (UTF8PoolAlignment - 1);
R634 ((length + UTF8PoolAlignment - 1) / UTF8PoolAlignment) *
UTF8PoolAlignment;
Comparison of J:\JAE1_2T\src\solaris\javavm\green_threads\include\SPARC_MD.H and
J:\PC\NX\javavm\green_threads\include\SPARC_MD.H
Version 1.6
----------------------------------------------------- Power of 2
L53 #define STACK_ALIGN 8
L54 #define SA(X) (((X)+(STACK_ALIGN-1)) & ~(STACK_ALIGN-1))
R53 #define STACK_ALIGN (sizeof (LONG DOUBLE))
R54 #define SA(X) ((((X)+(STACK_ALIGN-1)) / STACK_ALIGN) * STACK_ALIGN)
Comparison of J:\JAE1_2T\src\solaris\javavm\include\GC_MD.H and
J:\PC\NX\javavm\include\GC_MD.H
Version 1.6
----------------------------------------------------- Power of 2
L89 #define PAGE_ALIGNMENT (64 * 1024) /* page size is the same. */
R89 #define PAGE_ALIGNMENT (((64 * 1024 + sizeof(long double) - 1) /
sizeof (long double)) * sizeof (long double)) /* srb */ /* page size is the
same. */
----------------------------------------------------- Power of 2
L93 #define PTR_2_PAGE_SHIFT (16)
R93 /* #define PTR_2_PAGE_SHIFT (16) - use "/" instead - srb */
Comparison of J:\JAE1_2T\src\solaris\javavm\include\OOBJ_MD.H and
J:\PC\NX\javavm\include\OOBJ_MD.H
Version 1.11
----------------------------------------------------- Power of 2
L26 #define OBJECT_SIZE_SHIFT 2 /* log2(sizeof(OBJECT)) */
R26 #define OBJECT_SIZE_FACTOR sizeof(OBJECT) /* srb */
Comparison of J:\JAE1_2T\src\solaris\javavm\runtime\MEMORY_MD.C and
J:\PC\NX\javavm\runtime\MEMORY_MD.C
Version 1.16
----------------------------------------------------- Power of 2
L67 return (value + memGrainSize - 1) & ~(memGrainSize - 1);
R67 /* srb - do not require memGrainSize to be power of 2 */
R68 return ((value + memGrainSize - 1) / memGrainSize) * memGrainSize;
----------------------------------------------------- Power of 2
L73 return value & ~(memGrainSize - 1);
R74 /* srb - do not require memGrainSize to be power of 2 */
R75 return (value / memGrainSize) * memGrainSize;
----------------------------------------------------- Power of 2
L80 extern unsigned int memGrainSize;
Licensee made a minimal effort to produce source that is more portable.
In several cases, however, the effort to do so was too large and the change will
only work on licensee platform. In other cases, licensee kept the code in the
shared directory instead of moving it into the platform specific directory.
Obviously these changes will need much more work before they can be released.
In the following patch listing, "L" refers to the left path which is original
file from JavaSoft and "R" refers to the right path which is our modified file.
At the end of each "---------" line is Power of 2, see below for explanation.
Portability, "Power of 2" explanation:
Places in the shared directory assume that the platform's native word size is a
power of 2. That is, sizeof(int) is 4 or 8. On the ClearPath HMP NX (A Series)
platform, the native word size is 6 bytes. A double word is 12 bytes. So
sizeof(int) is 6 and sizeof(long double) is 12. Note that our pointers are
always offsets in terms of bytes (the ClearPath HMP IX or 2200 Series has
pointers that are word offsets or byte offsets). This means that :
1) constant values like 4 and 8 need to be sizeof(<type>) instead.
2) pointers to double-word align objects in the heap may not have their low
three bits be 0. To ensure that the low three bits in the pointer are zero, the
object has to be aligned to a multiple of 24 bytes (an obvious waste of space).
Ideally, the location of the bits should be defined by macros in the platform
headers. We have spare bits elsewhere in the word that could be used, allow
objects to be word aligned only.
3) Adding 3 and then ANDing (&) a mask with the low two bits off does not align
to the next word boundary Ditto for adding 7 and ANDing a mask with the low
three bits off for double word alignment.. In fact, ANDing is not usable for
alignment on our platform and a div (/) or mod (%) has to be used.
4) Shifting a pointer left 3 bits does not reduce it to a OBJECTGRAIN offset. A
division is required. Ditto for computhing which page an address is in.
5) The size of a scalar type can still be represented in a two bit field
(T_SIZEFIELD), but that representation is not log2 of the size. For our
platform, the sizes are:
char 1
short 6
int 6
double 12
6) Hardware page sizes are not a power of 2. In fact, no sizes are a power of
2.
Specific examples/code fixes to follow:
Comparison of J:\JAE1_2T\src\share\javavm\include\GC.H and
J:\PC\SHARE\javavm\include\GC.H
Version 1.16
----------------------------------------------------- Power of 2
L38 #define OBJECTGRAIN 8
L39 #define HANDLEGRAIN 8
R38 #define OBJECTGRAIN (sizeof (long double) * 2) /* srb */
R39 #define HANDLEGRAIN (sizeof (long double) * 2) /* srb */
----------------------------------------------------- Power of 2
L72 #define h_len(h) ((h) & (~(OBJECTGRAIN-1)^SWAPPED))
R72 #define h_len(h) ((((h) & ~SWAPPED) / OBJECTGRAIN) * OBJECTGRAIN)/*srb*/
R73 #define h_slen(h) (((h) / OBJECTGRAIN) * OBJECTGRAIN) /* srb */
----------------------------------------------------- Power of 2
L76 #define obj_len(p) (obj_geth(p)&(~(OBJECTGRAIN-1)^SWAPPED))
R77 #define obj_len(p) (((obj_geth(p) & ~SWAPPED) / OBJECTGRAIN) *
OBJECTGRAIN) /* srb */
----------------------------------------------------- Power of 2
L91 #define MarkPtr(p) _MarkPtr(((unsigned int) (p) & ~(OBJECTGRAIN - 1)))
L92 #define ClearMarkPtr(p) _ClearMarkPtr(((unsigned
int)(p)&~(OBJECTGRAIN-1)))
L93 #define IsMarked(p) _IsMarked((unsigned int) (p) & ~(OBJECTGRAIN - 1))
R92 #define MarkPtr(p) _MarkPtr(h_slen((unsigned int) (p))) /* srb */
R93 #define ClearMarkPtr(p) _ClearMarkPtr(h_slen((unsigned int)(p))) /*srb*/
R94 #define IsMarked(p) _IsMarked(h_slen((unsigned int) (p))) /* srb */
----------------------------------------------------- Power of 2
L98 #define ValidObject(p) ((((int)(p)) & (OBJECTGRAIN-1)) == 0 &&
(unsigned char *)(p) >= opmin &&
(unsigned char *)(p) < opmax)
L99 #define ValidHandle(p) (((int) (p) & (sizeof(JHandle)-1)) == 0 &&
(unsigned char *)(p) >= hpmin &&
(unsigned char *)(p) <= hpmax)
----------------------------------------------------- Power of 2
R99 #define ValidObject(p) ((((int)(p)) % OBJECTGRAIN) == 0 &&
(unsigned char *)(p) >= opmin &&
(unsigned char *)(p) < opmax)
R100 #define ValidHandle(p) (((int) (p) % sizeof(JHandle)) == 0 &&
(unsigned char *)(p) >= hpmin &&
(unsigned char *)(p) <= hpmax)
----------------------------------------------------- Power of 2
L101 #define ValidHorO(p) (((int) (p) & (OBJECTGRAIN-1)) == 0 &&
(unsigned char *)(p) >= hpmin &&
(unsigned char *)(p) <= opmax)
R102 #define ValidHorO(p) (((int) (p) % OBJECTGRAIN) == 0 &&
(unsigned char *)(p) >= hpmin &&
(unsigned char *)(p) <= opmax)
----------------------------------------------------- Power of 2
L109 #define MARKINDEX(p) (((unsigned char *)(p) - hpmin) >> 8)
L110 #define BITOFFSET(p) ((((unsigned char *)(p) - hpmin) >> 3) & 0x1f)
R110 #define MARKINDEX(p) (((unsigned char *)(p) - hpmin) /
(OBJECTGRAIN*32)) /* srb */
R111 #define BITOFFSET(p) ((((unsigned char *)(p) - hpmin) / OBJECTGRAIN) &
0x1f) /* srb */
Comparison of J:\JAE1_2T\src\share\javavm\include\OOBJ.H and
J:\PC\SHARE\javavm\include\OOBJ.H
Version 1.93
----------------------------------------------------- Power of 2
L59 #define ALIGN(n) (((n)+3)&~3)
R59 #define ALIGN(n) ((((n)+sizeof(int)-1)/sizeof(int))*sizeof(int)) /*srb*/
Comparison of J:\JAE1_2T\src\share\javavm\include\TYPECODES.H and
J:\PC\SHARE\javavm\include\TYPECODES.H
Version 1.10
----------------------------------------------------- Power of 2
R115 extern int srb_size_factors [4];
----------------------------------------------------- Power of 2
L120 #define T_ELEMENT_SIZE(t) (1<<T_SIZEFIELD(t)) /* only for some!! */
R121 #define T_ELEMENT_SIZE(t) (srb_size_factors [T_SIZEFIELD(t)]) /* srb -
only for some!! */
Comparison of J:\JAE1_2T\src\share\javavm\runtime\CLASSRESOLVER.C and
J:\PC\SHARE\javavm\runtime\CLASSRESOLVER.C
Version 1.123
----------------------------------------------------- Power of 2
L1061 ptr = sysMalloc(sizeof(struct methodtable)
L1062 + (mslot - 1)* sizeof(struct methodblock *)
L1063 + FLAG_MASK);
R1061 /* srb - should be Least Common Multiple of sizeof(int) [6 for
R1062 E-mode and FLAG_MASK+1 */
R1063 #define METHODALIGNMENT ((FLAG_MASK+1) * 3)
R1064 ptr = sysMalloc(sizeof(struct methodtable)
R1065 + (mslot - 1)* sizeof(struct methodblock *)
R1066 + METHODALIGNMENT - 1);
----------------------------------------------------- Power of 2
L1069 new_table = (struct methodtable *)((((long)ptr) + FLAG_MASK) &
LENGTH_MASK);
R1072 new_table = (struct methodtable *)
R1073 (((((long)ptr) + METHODALIGNMENT - 1) / METHODALIGNMENT)
R1074 * METHODALIGNMENT);
Comparison of J:\JAE1_2T\src\share\javavm\runtime\GC.C and
J:\PC\SHARE\javavm\runtime\GC.C
Version 1.206
----------------------------------------------------- Power of 2
L743 sysAssert((size & (OBJECTGRAIN-1)) == 0);
R743 sysAssert((size % OBJECTGRAIN) == 0); /* srb */
----------------------------------------------------- Power of 2
L770 sysAssert((old_obj & (OBJECTGRAIN-1)) == 0);
R770 sysAssert((old_obj % OBJECTGRAIN) == 0); /* srb */
---------------------------------------------------- Power of 2
L775 sysAssert((new_obj & (OBJECTGRAIN-1)) == 0);
R775 sysAssert((new_obj % OBJECTGRAIN) == 0); /* srb */
----------------------------------------------------- Power of 2
L944 sysAssert((((long) p + sizeof(hdr)) & (OBJECTGRAIN - 1))
== 0);
R944 sysAssert((((long) p + sizeof(hdr)) % /* srb */
R945 OBJECTGRAIN) == 0);
----------------------------------------------------- Power of 2
L982 size_t alignedHeaderSize = (sizeof(ChunkBlk) + inner_alignment -
1)
L983 & ~(inner_alignment - 1);
R983 size_t alignedHeaderSize =
R984 ((sizeof(ChunkBlk) + inner_alignment - 1) / inner_alignment) *
R985 inner_alignment; /* srb */
----------------------------------------------------- Power of 2
L995 /* save another (at least) 8 bytes for overwrite detection: */
L996 reqSize -= (inner_alignment > 8) ? inner_alignment : 8;
R997 /* save another (at least) 2 words for overwrite detection: */
R998 reqSize -= (inner_alignment > 2*sizeof(int)) ? inner_alignment :
R999 2*sizeof(int);
----------------------------------------------------- Power of 2
L999 *((int32_t *)(chunk->physEndPtr - 8)) = ALMOST_WORD;
L1000 *((int32_t *)(chunk->physEndPtr - 4)) = ULTIMATE_WORD;
R1002 ((int *)(chunk->physEndPtr))[-2] = ALMOST_WORD; /* srb */
R1003 ((int *)(chunk->physEndPtr))[-1] = ULTIMATE_WORD; /* srb */
----------------------------------------------------- Power of 2
L1052 n = (n0 + sizeof(hdr) + (OBJECTGRAIN - 1)) & ~(OBJECTGRAIN - 1);
R1055 n = ((n0 + sizeof(hdr) + (OBJECTGRAIN - 1)) / OBJECTGRAIN) *
R1056 OBJECTGRAIN; /* srb */
----------------------------------------------------- Power of 2
L1205 n = (n0 + sizeof(hdr) + (OBJECTGRAIN - 1)) & ~(OBJECTGRAIN - 1);
R1209 n = ((n0 + sizeof(hdr) + (OBJECTGRAIN - 1)) / OBJECTGRAIN) *
R1210 OBJECTGRAIN; /* srb */
----------------------------------------------------- Power of 2
R1414
R1415 int srb_size_factors [4] = { /* srb - support non-power of 2 sizes */
R1416 sizeof (char),
R1417 sizeof (short),
R1418 sizeof (int),
R1419 sizeof (long double) };
R1420
----------------------------------------------------- Power of 2
L1416 return l << ((t == T_CLASS) ? OBJECT_SIZE_SHIFT : T_SIZEFIELD(t));
R1428 return l * ((t == T_CLASS) ? OBJECT_SIZE_FACTOR /* srb */
R1429 : T_ELEMENT_SIZE(t)); /* srb */
----------------------------------------------------- Power of 2
L1443 int eltshift;
----------------------------------------------------- Power of 2
L1448 eltshift = (t == T_CLASS ? OBJECT_SIZE_SHIFT : T_SIZEFIELD(t));
L1449
----------------------------------------------------- Power of 2
L1451 if (l < 0 || ((l + 1) >> (sizeof(int) * 8 - 1 - eltshift)))
R1461 if (l < 0) /* srb -- work still in progress!!! */
----------------------------------------------------- Power of 2
L1454 size = l << eltshift;
R1464 size = sizearray (t, l); /* srb */
----------------------------------------------------- Power of 2
L1521 mem_top = (void *)(((int)blkP->endPtr + PAGE_ALIGNMENT - 1)
L1522 & ~(PAGE_ALIGNMENT - 1));
R1531 mem_top = (void *)((((int)blkP->endPtr + PAGE_ALIGNMENT - 1)
R1532 / PAGE_ALIGNMENT) * PAGE_ALIGNMENT); /* SRB */
----------------------------------------------------- Power of 2
L1549 mem_top = (void *)(((int)blkP->endPtr + PAGE_ALIGNMENT - 1)
L1550 & ~(PAGE_ALIGNMENT - 1));
R1559 mem_top = (void *)((((int)blkP->endPtr + PAGE_ALIGNMENT - 1)
R1560 / PAGE_ALIGNMENT) *
PAGE_ALIGNMENT);/*SRB*/
----------------------------------------------------- Power of 2
L1677 int numPages = (blkP->allocSize >> PTR_2_PAGE_SHIFT) + 1;
R1687 int numPages = (blkP->allocSize / PAGE_ALIGNMENT) + 1;
----------------------------------------------------- Power of 2
L1687 firstMapIndex = ((int)blkP - (int)mem_base) >> PTR_2_PAGE_SHIFT;
R1697 firstMapIndex = ((int)blkP - (int)mem_base) / PAGE_ALIGNMENT;
----------------------------------------------------- Power of 2
L1916 needPages = (sz >> PTR_2_PAGE_SHIFT) + 2;
R1926 needPages = (sz / PAGE_ALIGNMENT) + 2;
----------------------------------------------------- Power of 2
L2093 incr = (incr + HANDLEGRAIN - 1) & ~(HANDLEGRAIN - 1);
R2103 incr = ((incr + HANDLEGRAIN - 1) / HANDLEGRAIN)*HANDLEGRAIN; /*SRB*/
----------------------------------------------------- Power of 2
L2111 (((int) hpool + HANDLEGRAIN-1) & ~(HANDLEGRAIN-1));
R2121 ((((int) hpool + HANDLEGRAIN-1)/HANDLEGRAIN)*HANDLEGRAIN);/*SRB*/
----------------------------------------------------- Power of 2
L2184 incr = (incr + OBJECTGRAIN - 1) & ~(OBJECTGRAIN - 1);
R2194 incr = ((incr + OBJECTGRAIN - 1) / OBJECTGRAIN)*OBJECTGRAIN; /*srb*/
----------------------------------------------------- Power of 2
L3814 if (!((lowest_len - plen) & (OBJECTGRAIN - 1)) == 0)
{
R3824 if (!((lowest_len - plen) % OBJECTGRAIN) == 0) {
/*srb*/
----------------------------------------------------- Power of 2
L3817 & (OBJECTGRAIN - 1)) == 0);
R3827 % OBJECTGRAIN) == 0); /* srb */
----------------------------------------------------- Power of 2
L4712 if (! expandHandleSpace((((int)(min_request * 0.20)) >>
L4713 PTR_2_PAGE_SHIFT) + 1)) {
R4722 if (! expandHandleSpace((((int)(min_request * 0.20)) /
R4723 PAGE_ALIGNMENT) + 1)) {
----------------------------------------------------- Power of 2
L4804 ((int) ((hpoollimit - hpool) * 0.20) & ~(HANDLEGRAIN - 1));
R4815 ((((int) ((hpoollimit - hpool) * 0.20)) / /* SRB */
R4816 HANDLEGRAIN) * HANDLEGRAIN);
----------------------------------------------------- Power of 2
L4810 while (((int) opool + sizeof(hdr)) & (OBJECTGRAIN - 1)) {
R4822 while (((int) opool + sizeof(hdr)) % OBJECTGRAIN) { /* srb */
----------------------------------------------------- Power of 2
L4875 FreeMemoryLowWaterMark = (long) (0.2 * FreeObjectCtr) &
~(OBJECTGRAIN - 1);
R4888 FreeMemoryLowWaterMark = ((long) ((0.2 * FreeObjectCtr) /
R4889 OBJECTGRAIN) * OBJECTGRAIN);
----------------------------------------------------- Power of 2
L5370 handlePagesByList += (blkP->allocSize >> PTR_2_PAGE_SHIFT) +
1;
R5384 handlePagesByList += (blkP->allocSize / PAGE_ALIGNMENT) + 1;
----------------------------------------------------- Power of 2
L5379 objectPagesByList += (blkP->allocSize >> PTR_2_PAGE_SHIFT) +
1;
R5393 objectPagesByList += (blkP->allocSize / PAGE_ALIGNMEN
- relates to
-
JDK-4183945 (porting) sizearray() - portability improvements to make VM easier to port
- Closed
-
JDK-4112810 (porting) suggested improvements to make VM easier to port (powers of two)
- Closed