This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] "Rewrite" GetFrameCount


Hi,

The attach patch adds the new function _Jv_Frame::depth(), which returns the depth of the stack at this frame. It's a little hoaky, but it should be sufficient, since we end up getting the top of the stack from the thread anyway. No need to add more storage to save this info off.

It also contains changes to _Jv_JVMTI_GetFrame to use this function. This patch should effectively be a nop in functionality, except that I can now call _Jv_Frame::depth without having to call a JVMTI function, which I'm going to need when I submit patches related to single stepping.

Ok?

Keith

ChangeLog
2007-02-07  Keith Seitz  <keiths@redhat.com>

        * include/java-interp.h (_Jv_Frame::depth):
        New function.
        * jvmti.cc (_Jv_JVMTI_GetFrameCount): Use _Jv_Frame::depth.
Index: include/java-interp.h
===================================================================
--- include/java-interp.h	(revision 121607)
+++ include/java-interp.h	(working copy)
@@ -1,6 +1,6 @@
 // java-interp.h - Header file for the bytecode interpreter.  -*- c++ -*-
 
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006  Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -352,6 +352,16 @@
   {
     thread->frame = (gnu::gcj::RawData *) next;
   }
+
+  int depth ()
+  {
+    int depth = 0;
+    struct _Jv_Frame *f;
+    for (f = this; f != NULL; f = f->next)
+      ++depth;
+
+    return depth;
+  }
 };
 
 // An interpreted frame in the call stack
Index: jvmti.cc
===================================================================
--- jvmti.cc	(revision 121616)
+++ jvmti.cc	(working copy)
@@ -259,14 +259,7 @@
   THREAD_CHECK_IS_ALIVE (thr);
    
   _Jv_Frame *frame = reinterpret_cast<_Jv_Frame *> (thr->frame);
-  (*frame_count) = 0;
-  
-  while (frame != NULL)
-    {
-      (*frame_count)++;
-      frame = frame->next;
-    }
-  
+  (*frame_count) = frame->depth ();
   return JVMTI_ERROR_NONE;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]