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

Geoffrey ggaren at opensource.apple.com
Tue Nov 15 17:45:14 PST 2005


ggaren      05/11/15 17:45:14

  Modified:    .        ChangeLog
               kjs      collector.cpp internal.cpp internal.h value.cpp
                        value.h
  Log:
          Reviewed by mjs.
  
          - Fixed <rdar://problem/4342216> Installer crash in
            KJS::ValueImp::marked() when garbage collector runs inside call to
            ConstantValues::init()
  
          I took responsibility for initializing and marking ConstantValues away
          from InterpreterImp, since it's possible to reference such a value
          before any interpreter has been created and after the last interpreter
          has been destroyed.
  
          InterpreterImp::lock now initializes ConstantValues. It's a good
          place for the initialization because you have to call it before
          creating any objects. Since ::lock can be called more than once,
          I added a check in ConstantValues::init to ensure that it executes
          only once.
  
          Collector:collect is now responsible for marking ConstantValues.
  
          We no longer clear the ConstantValues since we can't guarantee that no
          one has a reference to them.
  
          FIXME: This is hackery. The long-term plan is to make ConstantValues
          use immediate values that require no initialization.
  
          * ChangeLog:
          * kjs/collector.cpp:
          (KJS::Collector::collect):
          * kjs/internal.cpp:
          (KJS::InterpreterImp::InterpreterImp):
          (KJS::InterpreterImp::lock):
          (KJS::InterpreterImp::clear):
          (KJS::InterpreterImp::mark):
          * kjs/internal.h:
          * kjs/value.cpp:
          (KJS::ConstantValues::initIfNeeded):
          * kjs/value.h:
  
  Revision  Changes    Path
  1.881     +40 -0     JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.880
  retrieving revision 1.881
  diff -u -r1.880 -r1.881
  --- ChangeLog	9 Nov 2005 06:34:52 -0000	1.880
  +++ ChangeLog	16 Nov 2005 01:45:09 -0000	1.881
  @@ -1,3 +1,43 @@
  +2005-11-15  Geoffrey Garen  <ggaren at apple.com>
  +
  +        Reviewed by mjs.
  +        
  +        - Fixed <rdar://problem/4342216> Installer crash in 
  +          KJS::ValueImp::marked() when garbage collector runs inside call to 
  +          ConstantValues::init()
  +          
  +        I took responsibility for initializing and marking ConstantValues away 
  +        from InterpreterImp, since it's possible to reference such a value 
  +        before any interpreter has been created and after the last interpreter 
  +        has been destroyed.
  +
  +        InterpreterImp::lock now initializes ConstantValues. It's a good
  +        place for the initialization because you have to call it before
  +        creating any objects. Since ::lock can be called more than once,
  +        I added a check in ConstantValues::init to ensure that it executes 
  +        only once.
  +
  +        Collector:collect is now responsible for marking ConstantValues.
  +
  +        We no longer clear the ConstantValues since we can't guarantee that no 
  +        one has a reference to them.
  +
  +        FIXME: This is hackery. The long-term plan is to make ConstantValues
  +        use immediate values that require no initialization.
  +
  +        * ChangeLog:
  +        * kjs/collector.cpp:
  +        (KJS::Collector::collect):
  +        * kjs/internal.cpp:
  +        (KJS::InterpreterImp::InterpreterImp):
  +        (KJS::InterpreterImp::lock):
  +        (KJS::InterpreterImp::clear):
  +        (KJS::InterpreterImp::mark):
  +        * kjs/internal.h:
  +        * kjs/value.cpp:
  +        (KJS::ConstantValues::initIfNeeded):
  +        * kjs/value.h:
  +
   2005-11-08  Geoffrey Garen  <ggaren at apple.com>
   
           Reviewed by Darin.
  
  
  
  1.50      +1 -0      JavaScriptCore/kjs/collector.cpp
  
  Index: collector.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/collector.cpp,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- collector.cpp	4 Oct 2005 01:43:58 -0000	1.49
  +++ collector.cpp	16 Nov 2005 01:45:11 -0000	1.50
  @@ -403,6 +403,7 @@
         scr = scr->next;
       } while (scr != InterpreterImp::s_hook);
     }
  +  ConstantValues::mark();
   
     // MARK: first mark all referenced objects recursively starting out from the set of root objects
   
  
  
  
  1.77      +6 -13     JavaScriptCore/kjs/internal.cpp
  
  Index: internal.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/internal.cpp,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- internal.cpp	4 Oct 2005 01:43:58 -0000	1.76
  +++ internal.cpp	16 Nov 2005 01:45:11 -0000	1.77
  @@ -434,16 +434,6 @@
   
   InterpreterImp* InterpreterImp::s_hook = 0L;
   
  -void InterpreterImp::globalInit()
  -{
  -    ConstantValues::init();
  -}
  -
  -void InterpreterImp::globalClear()
  -{
  -    ConstantValues::clear();
  -}
  -
   typedef HashMap<ObjectImp *, InterpreterImp *, PointerHash<ObjectImp *> > InterpreterMap;
   
   static inline InterpreterMap &interpreterMap()
  @@ -469,7 +459,6 @@
     } else {
       // This is the first interpreter
       s_hook = next = prev = this;
  -    globalInit();
     }
   
     interpreterMap().set(glob, this);
  @@ -487,6 +476,12 @@
   void InterpreterImp::lock()
   {
     lockInterpreter();
  +
  +  // FIXME: Hack-o-rama. To prevent construction of a global object with a null prototype (4342216),
  +  // we need to intialize our constants before the first object is constructed. InterpreterImp::lock()
  +  // is a good place to do this because you have to call it before doing any allocations. Once we change our 
  +  // implementation to use immediate values, we should remove this code.
  +  ConstantValues::initIfNeeded();
   }
   
   int InterpreterImp::lockCount()
  @@ -638,14 +633,12 @@
     {
       // This was the last interpreter
       s_hook = 0L;
  -    globalClear();
     }
     interpreterMap().remove(global);
   }
   
   void InterpreterImp::mark()
   {
  -  ConstantValues::mark();
     if (m_interpreter)
       m_interpreter->mark();
     if (_context)
  
  
  
  1.44      +0 -3      JavaScriptCore/kjs/internal.h
  
  Index: internal.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/internal.h,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- internal.h	6 Oct 2005 01:13:17 -0000	1.43
  +++ internal.h	16 Nov 2005 01:45:12 -0000	1.44
  @@ -246,9 +246,6 @@
     class InterpreterImp {
       friend class Collector;
     public:
  -    static void globalInit();
  -    static void globalClear();
  -
       InterpreterImp(Interpreter *interp, ObjectImp *glob);
       ~InterpreterImp();
   
  
  
  
  1.32      +4 -9      JavaScriptCore/kjs/value.cpp
  
  Index: value.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/value.cpp,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- value.cpp	6 Oct 2005 01:13:18 -0000	1.31
  +++ value.cpp	16 Nov 2005 01:45:12 -0000	1.32
  @@ -187,22 +187,17 @@
     return v ? v : new NumberImp(d);
   }
   
  -void ConstantValues::init()
  +void ConstantValues::initIfNeeded()
   {
  +    if (undefined)
  +        return;
  +    
       undefined = new UndefinedImp();
       null = new NullImp();
       jsTrue = new BooleanImp(true);
       jsFalse = new BooleanImp(false);
   }
   
  -void ConstantValues::clear()
  -{
  -    undefined = NULL;
  -    null = NULL;
  -    jsTrue = NULL;
  -    jsFalse = NULL;
  -}
  -
   void ConstantValues::mark()
   {
       if (AllocatedValueImp *v = undefined)
  
  
  
  1.37      +1 -2      JavaScriptCore/kjs/value.h
  
  Index: value.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/value.h,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- value.h	6 Oct 2005 01:13:18 -0000	1.36
  +++ value.h	16 Nov 2005 01:45:12 -0000	1.37
  @@ -196,8 +196,7 @@
       static AllocatedValueImp *jsFalse;
       static AllocatedValueImp *jsTrue;
   
  -    static void init();
  -    static void clear();
  +    static void initIfNeeded();
       static void mark();
   };
   
  
  
  



More information about the webkit-changes mailing list