[MLton-devel] experimental release of source-level profiling

Stephen Weeks MLton@mlton.org
Mon, 20 Jan 2003 13:31:41 -0800

> GCStateVolatile was supposed to ensure that it was written to it's memory
> location every time it was modified.  Do you have a small example that
> exhibits the bug?  Or any outstanding changes that affect it?

I checked in the change to make gcState.currentSource volatile.
Running a MLton with that change, compiling any example with
	-profile time -profile-stack true -profile-basis true
should show the problem.  I'm testing it on wc-scanStream.  Here is
the problematic Machine code and the assembly produced by the native
codegen.  Note that the assembly stores $0x13E into %edi, but does not
write it to memory.  So, the call to GC_profileEnter sees the wrong

L_792: {kind = CReturn {dst = Some glob {index = 46, isRoot = true, ty = pt_22},
			frameInfo = Some {frameLayoutsIndex = 0},
			func = {bytesNeeded = None,
				ensuresBytesFree = true,
				mayGC = true,
				maySwitchThreads = false,
				modifiesFrontier = true,
				modifiesStackTop = true,
				name = GC_arrayAllocate,
				needsCurrentSource = true,
				returnTy = Some pointer}},
	live = (),
	raises = None,
	returns = None}
    ProfileLabel MLtonProfile2617
    CurrentSource  = 0xFFFFFFFF
    CurrentSource  = 0x13E
    CCall {args = (<GCState>),
	   frameInfo = None,
	   func = {bytesNeeded = None,
		   ensuresBytesFree = false,
		   mayGC = false,
		   maySwitchThreads = false,
		   modifiesFrontier = false,
		   modifiesStackTop = false,
		   name = GC_profileEnter,
		   needsCurrentSource = false,
		   returnTy = None},
	   return = Some L_793}

.global MLtonProfile2617
	addl $-4,%ebp
	movl %ebp,((gcState+8)+(0*4))
	movl %eax,%esi
	movl $0xFFFFFFFF,%edi
	movl $0x13E,%edi
	movl (c_stackP+(0*4)),%edx
	xchgl %edx,%esp
	pushl $gcState
	movl %edx,%ebx
	xchgl %eax,%esi
	movl %eax,(globalpointer+(46*4))
	call GC_profileEnter
	addl $4,%esp

This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
MLton-devel mailing list