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] Insn handling methods for _Jv_InterpMethod


Hi,

The attached patch adds three methods to _Jv_InterpMethod which deal with manipulating the method's insns. These three methods are used by breakpoint management code to install and remove breakpoints.

Questions/comments/concerns?

Keith

ChangeLog
2006-09-25  Keith Seitz  <keiths@redhat.com>

        * include/java-interp.h (_Jv_InterpMethod::install_break):
        Declare.
        (_Jv_InterpMethod::get_insn): Declare.
        (_Jv_InterpMethod::set_insn): Declare.
        * interpret.cc (_Jv_InterpMethod::install_insn): New method.
        (_Jv_InterpMethod::get_insn): New method.
        (_Jv_InterpMethod::set_insn): New method.
Index: include/java-interp.h
===================================================================
--- include/java-interp.h	(revision 117093)
+++ include/java-interp.h	(working copy)
@@ -210,6 +210,17 @@
   void get_line_table (jlong& start, jlong& end, jintArray& line_numbers,
 		       jlongArray& code_indices);
 
+  /* Installs a break instruction at the given code index. Returns
+     the pc_t of the breakpoint or NULL if index is invalid. */
+  pc_t install_break (jlong index);
+
+  // Gets the instruction at the given index
+  pc_t get_insn (jlong index);
+
+  /* Writes the given instruction at the given code index. Returns
+     the insn or NULL if index is invalid. */
+  pc_t set_insn (jlong index, pc_t insn);
+
 #ifdef DIRECT_THREADED
   friend void _Jv_CompileMethod (_Jv_InterpMethod*);
 #endif
Index: interpret.cc
===================================================================
--- interpret.cc	(revision 117093)
+++ interpret.cc	(working copy)
@@ -1381,6 +1381,59 @@
 #endif // !DIRECT_THREADED
 }
 
+pc_t
+_Jv_InterpMethod::install_break (jlong index)
+{
+#ifdef DIRECT_THREADED
+  static insn_slot breakpoint_insn = {0};
+  printf ("_Jv_InterpMethod::install_break at index %ld\n", (long) index);
+  return set_insn (index, &breakpoint_insn);
+#else
+  static pc_t breakpoint_insn = NULL;
+  return set_insn (index, breakpoint_insn);
+#endif
+}
+
+pc_t
+_Jv_InterpMethod::get_insn (jlong index)
+{
+  pc_t code;
+
+#ifdef DIRECT_THREADED
+  if (index >= number_insn_slots || index < 0)
+    return NULL;
+
+  code = reinterpret_cast<pc_t> (prepared);
+#else // !DIRECT_THREADED
+  if (index >= code_length || index < 0)
+    return NULL;
+
+  code = reinterpret_cast<pc_t> (bytecode ());
+#endif // !DIRECT_THREADED
+
+  return &code[index];
+}
+
+pc_t
+_Jv_InterpMethod::set_insn (jlong index, pc_t insn)
+{
+#ifdef DIRECT_THREADED
+  if (index >= number_insn_slots || index < 0)
+    return NULL;
+
+  pc_t code = reinterpret_cast<pc_t> (prepared);
+  code[index].insn = insn->insn;
+#else // !DIRECT_THREADED
+  if (index >= code_length || index < 0)
+    return NULL;
+
+  pc_t code = reinterpret_cast<pc_t> (bytecode ());
+  code[index] = insn;
+#endif // !DIRECT_THREADED
+
+  return &code[index];
+}
+
 void *
 _Jv_JNIMethod::ncode ()
 {

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