+#if KJS_MAX_STACK > 0
+ static int depth = 0; // sum of all extant function calls
+
+#if JAVASCRIPT_CALL_TRACING
+ static bool tracing = false;
+ if (traceJavaScript() && !tracing) {
+ tracing = true;
+ for (int i = 0; i < depth; i++)
+ putchar (' ');
+ printf ("*** calling: %s\n", toString(exec).ascii());
+ for (int j = 0; j < args.size(); j++) {
+ for (int i = 0; i < depth; i++)
+ putchar (' ');
+ printf ("*** arg[%d] = %s\n", j, args[j]->toString(exec).ascii());
+ }
+ tracing = false;
+ }
+#endif
+
+ if (++depth > KJS_MAX_STACK) {
+ --depth;
+ return throwError(exec, RangeError, "Maximum call stack size exceeded.");
+ }
+#endif
+