cvsuser     04/03/26 04:10:50

  Modified:    classes  delegate.pmc parrotobject.pmc
               include/parrot objects.h
               ops      object.ops
               src      objects.c
  Log:
  faster object accessors
  * class and attribute count of objects with less indirection
  * speeds up especially oo4 bench
  
  Revision  Changes    Path
  1.23      +2 -4      parrot/classes/delegate.pmc
  
  Index: delegate.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/delegate.pmc,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -w -r1.22 -r1.23
  --- delegate.pmc      21 Mar 2004 11:07:09 -0000      1.22
  +++ delegate.pmc      26 Mar 2004 12:10:29 -0000      1.23
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2003 The Perl Foundation.  All Rights Reserved.
  -$Id: delegate.pmc,v 1.22 2004/03/21 11:07:09 leo Exp $
  +$Id: delegate.pmc,v 1.23 2004/03/26 12:10:29 leo Exp $
   
   =head1 NAME
   
  @@ -143,8 +143,6 @@
   */
   
   
  -#define get_attrib_num(x, y) *((PMC **)PObj_bufstart(x)+y)
  -
   PARROT_INLINE static PMC *
   find_meth(Parrot_Interp interpreter, PMC *pmc, const char *name) {
       STRING *meth = const_string(interpreter, name);
  @@ -156,7 +154,7 @@
           print_pbc_location(interpreter);
       }
       if (PObj_is_object_TEST(pmc)) {
  -        class = get_attrib_num((Buffer *)PMC_data(pmc), POD_CLASS);
  +        class = GET_CLASS((Buffer *)PMC_data(pmc), pmc);
       }
       REG_STR(2) = meth;
       return Parrot_find_method_with_cache(interpreter, class, meth);
  
  
  
  1.25      +2 -4      parrot/classes/parrotobject.pmc
  
  Index: parrotobject.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/parrotobject.pmc,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -w -r1.24 -r1.25
  --- parrotobject.pmc  26 Mar 2004 10:09:27 -0000      1.24
  +++ parrotobject.pmc  26 Mar 2004 12:10:30 -0000      1.25
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: parrotobject.pmc,v 1.24 2004/03/26 10:09:27 leo Exp $
  +$Id: parrotobject.pmc,v 1.25 2004/03/26 12:10:30 leo Exp $
   
   =head1 NAME
   
  @@ -45,8 +45,6 @@
   
   #include "parrot/parrot.h"
   
  -#define get_attrib_num(x, y) *((PMC **)PObj_bufstart(x)+y)
  -
   pmclass ParrotObject extends ParrotClass need_ext {
   
   /*
  @@ -132,7 +130,7 @@
   */
   
       PMC* find_method(STRING* name) {
  -        PMC *class = get_attrib_num((PMC *)PMC_data(SELF), POD_CLASS);
  +        PMC *class = GET_CLASS((PMC *)PMC_data(SELF), pmc);
           return Parrot_find_method_with_cache(INTERP, class, name);
       }
   
  
  
  
  1.22      +23 -1     parrot/include/parrot/objects.h
  
  Index: objects.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/objects.h,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -w -r1.21 -r1.22
  --- objects.h 16 Mar 2004 21:29:01 -0000      1.21
  +++ objects.h 26 Mar 2004 12:10:37 -0000      1.22
  @@ -1,7 +1,7 @@
   /* objects.h
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: objects.h,v 1.21 2004/03/16 21:29:01 dan Exp $
  + *     $Id: objects.h,v 1.22 2004/03/26 12:10:37 leo Exp $
    *  Overview:
    *     Parrot class and object header stuff
    *  Data Structure and Algorithms:
  @@ -83,6 +83,28 @@
   #define resize_attrib_array(x, y) Parrot_reallocate(interpreter, x, (sizeof(PMC 
*)*(y)))
   #define SLOTTYPE Buffer
   #endif
  +#endif
  +
  +#if 0
  +/*
  + * class = 1st element in object array
  + */
  +
  +#  define ATTRIB_COUNT(obj) PMC_int_val(obj)
  +#  define SET_CLASS(arr, obj, class) \
  +       set_attrib_num(obj, POD_CLASS, class)
  +#  define GET_CLASS(arr, obj) \
  +       get_attrib_num(obj, POD_CLASS)
  +#else
  +
  +/*
  + * class is in the PMC
  + */
  +
  +#  define SET_CLASS(arr, obj, class) PObj_bufstart(obj) = class
  +#  define GET_CLASS(arr, obj) PObj_bufstart(obj)
  +#  define ATTRIB_COUNT(obj) PObj_buflen(obj)
  +
   #endif
   
   /*
  
  
  
  1.37      +1 -1      parrot/ops/object.ops
  
  Index: object.ops
  ===================================================================
  RCS file: /cvs/public/parrot/ops/object.ops,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -w -r1.36 -r1.37
  --- object.ops        23 Mar 2004 07:27:51 -0000      1.36
  +++ object.ops        26 Mar 2004 12:10:41 -0000      1.37
  @@ -256,7 +256,7 @@
   
   inline op class(out PMC, in PMC) :object_classes {
       if (PObj_is_object_TEST($2))
  -     $1 = get_attrib_num((Buffer *)PMC_data($2), POD_CLASS);
  +     $1 = GET_CLASS((Buffer *)PMC_data($2), $2);
       else
        $1 = $2;
       goto NEXT();
  
  
  
  1.67      +7 -8      parrot/src/objects.c
  
  Index: objects.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/objects.c,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -w -r1.66 -r1.67
  --- objects.c 26 Mar 2004 10:09:32 -0000      1.66
  +++ objects.c 26 Mar 2004 12:10:50 -0000      1.67
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: objects.c,v 1.66 2004/03/26 10:09:32 leo Exp $
  +$Id: objects.c,v 1.67 2004/03/26 12:10:50 leo Exp $
   
   =head1 NAME
   
  @@ -518,11 +518,11 @@
       set_attrib_array_size(new_object_array,
                             attrib_count + POD_FIRST_ATTRIB);
       /* 0 - class PMC, 1 - class name */
  -    set_attrib_num(new_object_array, POD_CLASS, class);
  +    SET_CLASS(new_object_array, object, class);
       set_attrib_num(new_object_array, POD_CLASS_NAME, class_name);
   
       /* Note the number of used slots */
  -    object->cache.int_val = POD_FIRST_ATTRIB + attrib_count;
  +    ATTRIB_COUNT(object) = POD_FIRST_ATTRIB + attrib_count;
   
       /* We are an object now */
       PObj_is_object_SET(object);
  @@ -705,7 +705,7 @@
       }
       else {
           /* else get the objects class and the data array */
  -        t = get_attrib_num(object_array, POD_CLASS);
  +        t = GET_CLASS(object_array, pmc);
           object_array = PMC_data(t);
       }
       if (t == cl)
  @@ -1059,7 +1059,7 @@
       if (PObj_is_object_TEST(object)) {
           INTVAL attrib_count;
           attrib_array = PMC_data(object);
  -        attrib_count = get_attrib_count(attrib_array);
  +        attrib_count = ATTRIB_COUNT(object);
           if (attrib >= attrib_count || attrib < POD_FIRST_ATTRIB) {
               internal_exception(OUT_OF_BOUNDS, "No such attribute");
           }
  @@ -1077,7 +1077,7 @@
       if (PObj_is_object_TEST(object)) {
           INTVAL attrib_count;
           attrib_array = PMC_data(object);
  -        attrib_count = get_attrib_count(attrib_array);
  +        attrib_count = ATTRIB_COUNT(object);
           if (attrib >= attrib_count || attrib < POD_FIRST_ATTRIB) {
               internal_exception(OUT_OF_BOUNDS, "No such attribute");
           }
  @@ -1095,8 +1095,7 @@
       INTVAL offset;
       HashBucket *b;
   
  -    class_pmc = get_attrib_num((SLOTTYPE *)PMC_data(object),
  -                               POD_CLASS);
  +    class_pmc = GET_CLASS((SLOTTYPE *)PMC_data(object), object);
       offset_hash = get_attrib_num((SLOTTYPE *)PMC_data(class_pmc),
                                    PCD_ATTRIB_OFFS);
   #if 0
  
  
  

Reply via email to