diff --git a/src/docode.c b/src/docode.c
index def6f8be04e635a1de0e9326b1efe9217e567c21..9c91305766dd3c249d57cab0c3aab2b4e33dd12c 100644
--- a/src/docode.c
+++ b/src/docode.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: docode.c,v 1.203 2008/07/14 21:39:20 grubba Exp $
+|| $Id: docode.c,v 1.204 2008/08/28 15:13:19 grubba Exp $
 */
 
 #include "global.h"
@@ -247,6 +247,16 @@ static int ins_label(int lbl)
   return lbl;
 }
 
+void modify_stack_depth(int delta)
+{
+  current_stack_depth += delta;
+#ifdef PIKE_DEBUG
+  if (current_stack_depth < 0) {
+    Pike_fatal("Popped out of virtual stack.\n");
+  }
+#endif
+}
+
 void do_pop(int x)
 {
   struct compilation *c = THIS_COMPILATION;
diff --git a/src/docode.h b/src/docode.h
index c27f3c9febe665c03fc42ba92004515156792d4c..9742ae97baca80bb19240c9ecfc16e6a297ca7f8 100644
--- a/src/docode.h
+++ b/src/docode.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: docode.h,v 1.20 2008/04/14 10:14:38 grubba Exp $
+|| $Id: docode.h,v 1.21 2008/08/28 15:13:19 grubba Exp $
 */
 
 #ifndef DOCODE_H
@@ -29,6 +29,7 @@ void push_explicit(INT32 address);
 INT32 pop_address(void);
 int alloc_label(void);
 int do_jump(int token,INT32 lbl);
+void modify_stack_depth(int delta);
 void do_pop(int x);
 int do_docode(node *n, int flags);
 void do_cond_jump(node *n, int label, int iftrue, int flags);