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]

Patch: fix and speed-up object marking


The boehm.cc object/array marking code had many opportunities for
improvement.  In many cases simply reversing the direction of a loop
frees up a register and removes two memory loads per iteration. 

Other improvements were found by loading pointers to arrays from memory
into local variables before indexing into them.  This saves a load
inside the loop because the compiler doesn't know that the array pointer
in memory doesn't change.   I haven't finished changing these -- but
it's a good start.

This patch also includes my one-line fix for marking
Class::protectionDomain.

Tested by running Eclipse with gij.  Ok for branch and trunk?

AG


2002-12-22  Anthony Green  <green@redhat.com>

	* boehm.cc (_Jv_MarkObj): Mark the protectionDomain of a class.
	Speed up marking.
	(_Jv_MarkArray): Speed up marking.

Index: boehm.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/boehm.cc,v
retrieving revision 1.35
diff -c -r1.35 boehm.cc
*** boehm.cc	6 Dec 2002 23:41:36 -0000	1.35
--- boehm.cc	23 Dec 2002 06:45:38 -0000
***************
*** 108,114 ****
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c3label);
        p = (ptr_t) c->superclass;
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c4label);
!       for (int i = 0; i < c->constants.size; ++i)
  	{
  	  /* FIXME: We could make this more precise by using the tags -KKT */
  	  p = (ptr_t) c->constants.data[i].p;
--- 108,114 ----
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c3label);
        p = (ptr_t) c->superclass;
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c4label);
!       for (int i = c->constants.size - 1; i >= 0; i--)
  	{
  	  /* FIXME: We could make this more precise by using the tags -KKT */
  	  p = (ptr_t) c->constants.data[i].p;
***************
*** 144,150 ****
  	{
  	  // Scan each method in the cases where `methods' really
  	  // points to a methods structure.
! 	  for (int i = 0; i < c->method_count; ++i)
  	    {
  	      p = (ptr_t) c->methods[i].name;
  	      MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c,
--- 144,150 ----
  	{
  	  // Scan each method in the cases where `methods' really
  	  // points to a methods structure.
! 	  for (int i = c->method_count - 1; i >= 0; i--)
  	    {
  	      p = (ptr_t) c->methods[i].name;
  	      MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c,
***************
*** 158,164 ****
        // Mark all the fields.
        p = (ptr_t) c->fields;
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8label);
!       for (int i = 0; i < c->field_count; ++i)
  	{
  	  _Jv_Field* field = &c->fields[i];
  
--- 158,164 ----
        // Mark all the fields.
        p = (ptr_t) c->fields;
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8label);
!       for (int i = c->field_count - 1; i >= 0; i--)
  	{
  	  _Jv_Field* field = &c->fields[i];
  
***************
*** 194,200 ****
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c9label);
        p = (ptr_t) c->interfaces;
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cAlabel);
!       for (int i = 0; i < c->interface_count; ++i)
  	{
  	  p = (ptr_t) c->interfaces[i];
  	  MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cClabel);
--- 194,200 ----
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c9label);
        p = (ptr_t) c->interfaces;
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cAlabel);
!       for (int i = c->interface_count - 1; i > 0; i--)
  	{
  	  p = (ptr_t) c->interfaces[i];
  	  MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cClabel);
***************
*** 203,208 ****
--- 203,210 ----
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cBlabel);
        p = (ptr_t) c->arrayclass;
        MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cDlabel);
+       p = (ptr_t) c->protectionDomain;
+       MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cPlabel);
  
  #ifdef INTERPRETER
        if (_Jv_IsInterpretedClass (c))
***************
*** 212,243 ****
  	  p = (ptr_t) ic->interpreted_methods;
  	  MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, cElabel);
  
! 	  for (int i = 0; i < c->method_count; i++)
! 	    {
! 	      p = (ptr_t) ic->interpreted_methods[i];
! 	      MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, \
! 			  cFlabel);
! 
! 	      // Mark the direct-threaded code.
! 	      if ((c->methods[i].accflags
! 		   & java::lang::reflect::Modifier::NATIVE) == 0)
! 		{
! 		  _Jv_InterpMethod *im
! 		    = (_Jv_InterpMethod *) ic->interpreted_methods[i];
! 		  if (im)
! 		    {
! 		      p = (ptr_t) im->prepared;
! 		      MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, \
! 				  cFlabel);
! 		    }
! 		}
! 
! 	      // The interpreter installs a heap-allocated trampoline
! 	      // here, so we'll mark it.
! 	      p = (ptr_t) c->methods[i].ncode;
! 	      MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c,
! 			  cm3label);
! 	    }
  
  	  p = (ptr_t) ic->field_initializers;
  	  MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, cGlabel);
--- 214,251 ----
  	  p = (ptr_t) ic->interpreted_methods;
  	  MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, cElabel);
  
! 	  {
! 	    const ptr_t *p_ic_interpreted_methods = (ptr_t *) ic->interpreted_methods;
! 	    const _Jv_Method *p_c_methods = c->methods;
! 	    for (int i = c->method_count - 1; i >= 0; i--)
! 	      {
! 		p = p_ic_interpreted_methods[i];
! 		
! 		MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, \
! 			    cFlabel);
! 
! 		const _Jv_Method *m = &p_c_methods[i];
! 
! 		// Mark the direct-threaded code.
! 		if ((m->accflags
! 		     & java::lang::reflect::Modifier::NATIVE) == 0)
! 		  {
! 		    const _Jv_InterpMethod *im = (_Jv_InterpMethod *) p;
! 		    if (im)
! 		      {
! 			p = (ptr_t) im->prepared;
! 			MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, \
! 				    cFlabel);
! 		      }
! 		  }
! 		
! 		// The interpreter installs a heap-allocated trampoline
! 		// here, so we'll mark it.
! 		p = (ptr_t) m->ncode;
! 		MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c,
! 			    cm3label);
! 	      }
! 	  }
  
  	  p = (ptr_t) ic->field_initializers;
  	  MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, cGlabel);
***************
*** 261,267 ****
  	  jfieldID field = JvGetFirstInstanceField (klass);
  	  jint max = JvNumInstanceFields (klass);
  
! 	  for (int i = 0; i < max; ++i)
  	    {
  	      if (JvFieldIsRef (field))
  		{
--- 269,275 ----
  	  jfieldID field = JvGetFirstInstanceField (klass);
  	  jint max = JvNumInstanceFields (klass);
  
! 	  for (int i = max - 1; i >= 0; i--)
  	    {
  	      if (JvFieldIsRef (field))
  		{
***************
*** 307,318 ****
    p = (ptr_t) klass;
    MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, &(dt -> clas), o2label);
  
!   for (int i = 0; i < JvGetArrayLength (array); ++i)
!     {
!       jobject obj = elements (array)[i];
!       p = (ptr_t) obj;
!       MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, array, e2label);
!     }
  
    return mark_stack_ptr;
  }
--- 315,328 ----
    p = (ptr_t) klass;
    MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, &(dt -> clas), o2label);
  
!   {
!     ptr_t *pp = (ptr_t *) elements (array);
!     for (int i = JvGetArrayLength (array) - 1; i >= 0; i--)
!       {
! 	p = pp[i];
! 	MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, array, e2label);
!       }
!   }
  
    return mark_stack_ptr;
  }




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