Skip to main content

Should it be lbu???

5 replies [Last post]
jiankercn
Offline
Joined: 2008-04-02

When I reading the ccmallocators_cpu.S in mips/javavm/runtime/jit, I am very confused because of the codes as fallows:
77 #ifndef IAI_NEW_GLUE_CALLING_CONVENTION_IMPROVEMENT
78 /* Get access flags from class */
79 lbu a3, OFFSET_CVMClassBlock_accessFlagsX(CB) # flags
80 /* a3, OFFSET_CVMClassBlock_accessFlagsX(CB) */
81 #endif

But the prototype of accessFlagsX in CVMClassBlock is CVMUint16. I can't understand why load the accessFlagsX by ldu but not ldw?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cjplummer
Offline
Joined: 2006-10-16

I just committed a fix for this in r12749. I fixed all the ports, not just ARM.

Chris

jiankercn
Offline
Joined: 2008-04-02

Thanks very much!
I got it!

My need is lhu but not ldw :)

cjplummer
Offline
Joined: 2006-10-16

This looks like a bug. About a year ago in r6257 the field was changed from a Uint8 to a Uint16. However, the assembly code was never updated. The check is being done only on the FINALIZEABLE bit, which is 0x04. I think that means the check still works for big endian, but not little endian.

I'm not sure what the result of not of not properly detecting finalizeable objects is. We'll end up doing a quick inline allocation rather than deferring to C code. It looks like the C code calls Finalizer.register() on the object, but I'm not sure exactly what this does, and what might go wrong if it is not done.

BTW, you want lhu, not ldw.

Chris

mlam
Offline
Joined: 2006-10-13

The call to Finalizer.register() is needed to track finalizable objects. If I remember correctly, the finalizable object gets added (on instantiation) to a weak reference queue of some sort. When the object gets GC'ed, the weak reference (or was it FinalReference?) causes a notification call to be generated. That notification is where the GC'ed object gets added to a finalizable queue where at a later time, the respective finalizers will be called on the objects. This is how the finalization mechanism works.

Mark

cjplummer
Offline
Joined: 2006-10-16

So it looks like finalizers would not be called. I was wrong about it being a problem for little endian. Actually little endian is fine, but big endian has problems. Here's a simple test:

public class Final {
public static int numFinalize;

public void finalize() {
numFinalize++;
}

public static void main(String[] args) {
int i = 10000;
while (i-- > 0) {
new Final();
}
System.gc();
System.out.println("numFinalize = " + numFinalize);
}
}

And the results on Mac OS X on PowerPC, which is big endian:

% java Final
numFinalize = 10000
% bin/cvm Final
numFinalize = 1295

After 1295 allocations, the method finally got compiled, and then no more finalizers were registered after that point.

Chris