JavaScript debugging

In order to simplify JavaScript debugging, it's useful to have the following code in the [Visualizer] section of Common7\Packages\Debugger\autoexp.dat:

;------------------------------------------------------------------------------
;  JSString
;------------------------------------------------------------------------------
JSString{
 preview ( [$e.mChars,su] )
 stringview ( [$e.mChars,sub] )
 children
 (
  #if(!($e.mLength & JSString::DEPENDENT))
  (
   #(
    [actual members]: [$e,!] ,
    #array
    (
     expr: $e.mChars[$i],
     size: $e.mLength & JSString::LENGTH_MASK
    )
   )
  )
  #else
  (
   ; Dependent strings aren't done yet
   #(
    [actual members]: [$e,!],
    #array
    (
     expr: $e.mChars[$i],
     size: $e.mLength & JSString::LENGTH_MASK
    )
   )
  )
 )
}
;------------------------------------------------------------------------------
;  JSObject
;------------------------------------------------------------------------------
JSObject{
 preview (
  #(
   (void *)&$e,
   " [object ",
   [((JSClass *)($e.classword & ~3))->name,s],
   "]"
  )
 )
 children (
  #(
   #(#(#(
   [actual members]: [$e,!],
   #if ($e.fslots[0])
   (
    #(prototype : (JSObject *)($e.fslots[0] & ~7))
   )),
   #if ($e.fslots[1])
   (
    #(parent : (JSObject *)($e.fslots[1] & ~7))
   )),
   #if (((JSClass *)($e.classword & ~3))->flags & 1)
   (
    #(private : (void *)($e.fslots[2]))
   )),
   #(class : (JSClass *)($e.classword & ~3))
  )
 )
}

Profiling SpiderMonkey in gecko-1.9.2

I've had a few problems trying to build a profiling version of SpiderMonkey from gecko-1.9.2 on OS X.

First, in order to build SpiderMonkey at all on OS X 10.6, it's necessary to pick GCC 4.0 because the standard GCC 4.2.1 can't build it.

$ CC=gcc-4.0 CXX=g++-4.0 ../configure --enable-optimize --disable-debug

Then, in order to turn on the profiling support, the -pg flag must be passed to the compiler and linker:

$ CC=gcc-4.0 CXX=g++-4.0 ../configure --enable-optimize="-O3 -fstrict-aliasing -pg" --disable-debug

Finally, to stop the resulting JS shell from instantly crashing, __attribute((fastcall)) needs to be turned off in jstypes.h, jsdhash.h and nanojit/avmplus.h.