webengine/osswebengine/JavaScriptCore/kjs/interpreter.cpp
changeset 13 10e98eab6f85
parent 0 dd21522fd290
equal deleted inserted replaced
8:7c90e6132015 13:10e98eab6f85
    78 static const int preferredScriptCheckTimeInterval = 1000;
    78 static const int preferredScriptCheckTimeInterval = 1000;
    79 
    79 
    80 Interpreter* Interpreter::s_hook = 0;
    80 Interpreter* Interpreter::s_hook = 0;
    81     
    81     
    82 typedef HashMap<JSObject*, Interpreter*> InterpreterMap;
    82 typedef HashMap<JSObject*, Interpreter*> InterpreterMap;
       
    83 static InterpreterMap* map = 0;
    83 static inline InterpreterMap &interpreterMap()
    84 static inline InterpreterMap &interpreterMap()
    84 {
    85 {
    85     static InterpreterMap* map = new InterpreterMap;
    86     if(!map )
       
    87      map = new InterpreterMap;
    86     return* map;
    88     return* map;
    87 }
    89 }
    88     
    90     
       
    91 struct cleanupInterpreterMap {
       
    92     ~cleanupInterpreterMap() {
       
    93     	if(map)
       
    94     		{
       
    95     		map->clear();
       
    96     		delete map;
       
    97     		map = NULL;
       
    98     		}
       
    99     }
       
   100 };
       
   101 static cleanupInterpreterMap deleteInterpreterMap;
       
   102 
    89 EXPORT
   103 EXPORT
    90 Interpreter::Interpreter(JSObject* globalObject)
   104 Interpreter::Interpreter(JSObject* globalObject)
    91     : m_globalExec(this, 0)
   105     : m_globalExec(this, 0)
    92     , m_globalObject(globalObject)
   106     , m_globalObject(globalObject)
    93 {
   107 {
   143     s_hook = next;
   157     s_hook = next;
   144     if (s_hook == this) {
   158     if (s_hook == this) {
   145         // This was the last interpreter
   159         // This was the last interpreter
   146         s_hook = 0;
   160         s_hook = 0;
   147     }
   161     }
       
   162 
   148     interpreterMap().remove(m_globalObject);
   163     interpreterMap().remove(m_globalObject);
       
   164 
       
   165     // It's likely that destroying the interpreter has created a lot of garbage. 
       
   166     Collector::collect(); 
   149 }
   167 }
   150 
   168 
   151 EXPORT
   169 EXPORT
   152 JSObject* Interpreter::globalObject() const
   170 JSObject* Interpreter::globalObject() const
   153 {
   171 {