[webkit-changes] cvs commit: JavaScriptCore/kjs internal.cpp internal.h

Darin darin at opensource.apple.com
Sun Aug 14 09:41:48 PDT 2005


darin       05/08/14 09:41:48

  Modified:    .        ChangeLog
               kjs      internal.cpp internal.h
  Log:
          Reviewed by Maciej.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4421
            speed up JavaScript by inlining some label stack functions
  
          * kjs/internal.h: Removed the copy constructor and assignment operator for LabelStack.
          They were unused, and the implementations had bugs; I removed them rather than fixing them.
          Also removed the clear function, since that was only needed to help the assignment operator
          share code with the destructor, and was not efficient enough for the destructor.
          (KJS::LabelStack::~LabelStack): Made this inline. Also used an efficient implementation
          that's nice and fast when the stack is empty, better than the old clear() function which
          used to keep updating and refetching "tos" each time through the loop.
          (KJS::LabelStack::pop): Made this inline.
  
          * kjs/internal.cpp: Deleted the now-inline functions and the obsolete functions. Also
          deleted a commented-out line of code.
  
  Revision  Changes    Path
  1.796     +19 -0     JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.795
  retrieving revision 1.796
  diff -u -r1.795 -r1.796
  --- ChangeLog	14 Aug 2005 16:34:01 -0000	1.795
  +++ ChangeLog	14 Aug 2005 16:41:47 -0000	1.796
  @@ -2,6 +2,25 @@
   
           Reviewed by Maciej.
   
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4421
  +          speed up JavaScript by inlining some label stack functions
  +
  +        * kjs/internal.h: Removed the copy constructor and assignment operator for LabelStack.
  +        They were unused, and the implementations had bugs; I removed them rather than fixing them.
  +        Also removed the clear function, since that was only needed to help the assignment operator
  +        share code with the destructor, and was not efficient enough for the destructor.
  +        (KJS::LabelStack::~LabelStack): Made this inline. Also used an efficient implementation
  +        that's nice and fast when the stack is empty, better than the old clear() function which
  +        used to keep updating and refetching "tos" each time through the loop.
  +        (KJS::LabelStack::pop): Made this inline.
  +
  +        * kjs/internal.cpp: Deleted the now-inline functions and the obsolete functions. Also
  +        deleted a commented-out line of code.
  +
  +2005-08-14  Darin Adler  <darin at apple.com>
  +
  +        Reviewed by Maciej.
  +
           - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4419
             speed up JavaScript by improving KJS::List
   
  
  
  
  1.63      +0 -52     JavaScriptCore/kjs/internal.cpp
  
  Index: internal.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/internal.cpp,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- internal.cpp	14 Aug 2005 16:04:19 -0000	1.62
  +++ internal.cpp	14 Aug 2005 16:41:47 -0000	1.63
  @@ -260,32 +260,6 @@
   
   // ------------------------------ LabelStack -----------------------------------
   
  -LabelStack::LabelStack(const LabelStack &other)
  -{
  -  tos = 0;
  -  *this = other;
  -}
  -
  -LabelStack &LabelStack::operator=(const LabelStack &other)
  -{
  -  clear();
  -  tos = 0;
  -  StackElem *cur = 0;
  -  StackElem *se = other.tos;
  -  while (se) {
  -    StackElem *newPrev = new StackElem;
  -    newPrev->prev = 0;
  -    newPrev->id = se->id;
  -    if (cur)
  -      cur->prev = newPrev;
  -    else
  -      tos = newPrev;
  -    cur = newPrev;
  -    se = se->prev;
  -  }
  -  return *this;
  -}
  -
   bool LabelStack::push(const Identifier &id)
   {
     if (contains(id))
  @@ -310,31 +284,6 @@
     return false;
   }
   
  -void LabelStack::pop()
  -{
  -  if (tos) {
  -    StackElem *prev = tos->prev;
  -    delete tos;
  -    tos = prev;
  -  }
  -}
  -
  -LabelStack::~LabelStack()
  -{
  -  clear();
  -}
  -
  -void LabelStack::clear()
  -{
  -  StackElem *prev;
  -
  -  while (tos) {
  -    prev = tos->prev;
  -    delete tos;
  -    tos = prev;
  -  }
  -}
  -
   // ------------------------------ ContextImp -----------------------------------
   
   // ECMA 10.2
  @@ -425,7 +374,6 @@
     Lexer::curr()->doneParsing();
     ProgramNode *prog = progNode;
     progNode = 0;
  -//  sid = -1;
   
     if (parseError || lexError) {
       int eline = Lexer::curr()->lineNo();
  
  
  
  1.34      +20 -4     JavaScriptCore/kjs/internal.h
  
  Index: internal.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/internal.h,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- internal.h	14 Aug 2005 16:04:19 -0000	1.33
  +++ internal.h	14 Aug 2005 16:41:47 -0000	1.34
  @@ -139,9 +139,6 @@
       LabelStack(): tos(0L), iterationDepth(0), switchDepth(0) {}
       ~LabelStack();
   
  -    LabelStack(const LabelStack &other);
  -    LabelStack &operator=(const LabelStack &other);
  -
       /**
        * If id is not empty and is not in the stack already, puts it on top of
        * the stack and returns true, otherwise returns false
  @@ -165,13 +162,15 @@
       bool inSwitch() const { return (switchDepth > 0); }
       
     private:
  +    LabelStack(const LabelStack &other);
  +    LabelStack &operator=(const LabelStack &other);
  +
       struct StackElem {
         Identifier id;
         StackElem *prev;
       };
   
       StackElem *tos;
  -    void clear();
       int iterationDepth;
       int switchDepth;
     };
  @@ -408,6 +407,23 @@
     void printInfo(ExecState *exec, const char *s, ValueImp *, int lineno = -1);
   #endif
   
  +inline LabelStack::~LabelStack()
  +{
  +    StackElem *prev;
  +    for (StackElem *e = tos; e; e = prev) {
  +        prev = e->prev;
  +        delete e;
  +    }
  +}
  +
  +inline void LabelStack::pop()
  +{
  +    if (StackElem *e = tos) {
  +        tos = e->prev;
  +        delete e;
  +    }
  +}
  +
   } // namespace
   
   #endif //  INTERNAL_H
  
  
  



More information about the webkit-changes mailing list