Unlike software developers, g++ doesn't like variable-sized arrays. Have some alloca!
authorshaver@mozilla.org
Thu, 10 Jul 2008 16:48:42 -0400
changeset 17580 c7f76b35889707556b803672374057b11a8fa481
parent 17579 74f3632c456dbf30f71afac1f9ef6fe6a99d72ed
child 17581 9a43f36e5cb1ec415c4ecaa9727b552dc5e9a9a9
push id1452
push usershaver@mozilla.com
push dateFri, 22 Aug 2008 00:08:22 +0000
treeherdermozilla-central@d13bb0868596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
Unlike software developers, g++ doesn't like variable-sized arrays. Have some alloca!
js/src/jstracer.cpp
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -324,17 +324,17 @@ public:
         }                                                                     \
         /* count the number of pending frames */                              \
         unsigned frames = 0;                                                  \
         JSStackFrame* fp = currentFrame;                                      \
         for (;; fp = fp->down) { ++frames; if (fp == entryFrame) break; };    \
         /* stack them up since we want forward order (this should be fast */  \
         /* now, since the previous loop prefetched everything for us and  */  \
         /* the list tends to be short anyway [1-3 frames]).               */  \
-        JSStackFrame* fstack[frames];                                         \
+        JSStackFrame** fstack = (JSStackFrame **)alloca(frames * sizeof (JSStackFrame *)); \
         JSStackFrame** fspstop = &fstack[frames];                             \
         JSStackFrame** fsp = fspstop-1;                                       \
         fp = currentFrame;                                                    \
         for (;; fp = fp->down) { *fsp-- = fp; if (fp == entryFrame) break; }  \
         for (fsp = fstack; fsp < fspstop; ++fsp) {                            \
             JSStackFrame* f = *fsp;                                           \
             jsval* vpstop;                                                    \
             SET_VPNAME("rval");                                               \
@@ -1047,17 +1047,17 @@ js_LoopEdge(JSContext* cx)
             if (hits > HOTLOOP3)
                 f->blacklist();
         }
         return false;
     }
 
     /* execute previously recorded trace */
     VMFragmentInfo* fi = (VMFragmentInfo*)f->vmprivate;
-    double native[fi->maxNativeFrameSlots+1];
+    double* native = (double *)alloca((fi->maxNativeFrameSlots+1) * sizeof(double));
 #ifdef DEBUG
     *(uint64*)&native[fi->maxNativeFrameSlots] = 0xdeadbeefdeadbeefLL;
 #endif
     if (!unbox(cx->fp, cx->fp, fi->typeMap, native)) {
 #ifdef DEBUG
         printf("typemap mismatch, skipping trace.\n");
 #endif
         return false;