Changeset 19901 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Feb 27, 2007, 4:26:22 PM (18 years ago)
Author:
ggaren
Message:

Reviewed by Darin Adler.


Follow-up to fixing http://bugs.webkit.org/show_bug.cgi?id=12659 | <rdar://problem/4954306>
JS objects not collected after closing window @ ebay.com/maps.google.com


Changed Interpreter cache of global constructors and prototypes from
ProtectedPtrs to bare, marked pointers. ProtectedPtrs are inefficient,
and they increase the risk of reference cycles. Also, Darin said something
about ProtectedPtrs giving him warts.


Also changed data members to precise types from generic JSObject*'s.


Layout tests and JS tests pass.

  • kjs/SavedBuiltins.h:
  • kjs/interpreter.cpp: (KJS::Interpreter::init): (KJS::Interpreter::~Interpreter): (KJS::Interpreter::initGlobalObject): Moved Identifier::init() call to constructor, for clarity. (KJS::Interpreter::mark):
  • kjs/interpreter.h:
Location:
trunk/JavaScriptCore/kjs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/SavedBuiltins.h

    r17437 r19901  
    4444    friend class Interpreter;
    4545private:
    46     ProtectedPtr<JSObject> m_Object;
    47     ProtectedPtr<JSObject> m_Function;
    48     ProtectedPtr<JSObject> m_Array;
    49     ProtectedPtr<JSObject> m_Boolean;
    50     ProtectedPtr<JSObject> m_String;
    51     ProtectedPtr<JSObject> m_Number;
    52     ProtectedPtr<JSObject> m_Date;
    53     ProtectedPtr<JSObject> m_RegExp;
    54     ProtectedPtr<JSObject> m_Error;
     46    ProtectedPtr<ObjectObjectImp> m_Object;
     47    ProtectedPtr<FunctionObjectImp> m_Function;
     48    ProtectedPtr<ArrayObjectImp> m_Array;
     49    ProtectedPtr<BooleanObjectImp> m_Boolean;
     50    ProtectedPtr<StringObjectImp> m_String;
     51    ProtectedPtr<NumberObjectImp> m_Number;
     52    ProtectedPtr<DateObjectImp> m_Date;
     53    ProtectedPtr<RegExpObjectImp> m_RegExp;
     54    ProtectedPtr<ErrorObjectImp> m_Error;
    5555   
    56     ProtectedPtr<JSObject> m_ObjectPrototype;
    57     ProtectedPtr<JSObject> m_FunctionPrototype;
    58     ProtectedPtr<JSObject> m_ArrayPrototype;
    59     ProtectedPtr<JSObject> m_BooleanPrototype;
    60     ProtectedPtr<JSObject> m_StringPrototype;
    61     ProtectedPtr<JSObject> m_NumberPrototype;
    62     ProtectedPtr<JSObject> m_DatePrototype;
    63     ProtectedPtr<JSObject> m_RegExpPrototype;
    64     ProtectedPtr<JSObject> m_ErrorPrototype;
     56    ProtectedPtr<ObjectPrototype> m_ObjectPrototype;
     57    ProtectedPtr<FunctionPrototype> m_FunctionPrototype;
     58    ProtectedPtr<ArrayPrototype> m_ArrayPrototype;
     59    ProtectedPtr<BooleanPrototype> m_BooleanPrototype;
     60    ProtectedPtr<StringPrototype> m_StringPrototype;
     61    ProtectedPtr<NumberPrototype> m_NumberPrototype;
     62    ProtectedPtr<DatePrototype> m_DatePrototype;
     63    ProtectedPtr<RegExpPrototype> m_RegExpPrototype;
     64    ProtectedPtr<ErrorPrototype> m_ErrorPrototype;
    6565   
    66     ProtectedPtr<JSObject> m_EvalError;
    67     ProtectedPtr<JSObject> m_RangeError;
    68     ProtectedPtr<JSObject> m_ReferenceError;
    69     ProtectedPtr<JSObject> m_SyntaxError;
    70     ProtectedPtr<JSObject> m_TypeError;
    71     ProtectedPtr<JSObject> m_UriError;
     66    ProtectedPtr<NativeErrorImp> m_EvalError;
     67    ProtectedPtr<NativeErrorImp> m_RangeError;
     68    ProtectedPtr<NativeErrorImp> m_ReferenceError;
     69    ProtectedPtr<NativeErrorImp> m_SyntaxError;
     70    ProtectedPtr<NativeErrorImp> m_TypeError;
     71    ProtectedPtr<NativeErrorImp> m_UriError;
    7272   
    73     ProtectedPtr<JSObject> m_EvalErrorPrototype;
    74     ProtectedPtr<JSObject> m_RangeErrorPrototype;
    75     ProtectedPtr<JSObject> m_ReferenceErrorPrototype;
    76     ProtectedPtr<JSObject> m_SyntaxErrorPrototype;
    77     ProtectedPtr<JSObject> m_TypeErrorPrototype;
    78     ProtectedPtr<JSObject> m_UriErrorPrototype;
     73    ProtectedPtr<NativeErrorPrototype> m_EvalErrorPrototype;
     74    ProtectedPtr<NativeErrorPrototype> m_RangeErrorPrototype;
     75    ProtectedPtr<NativeErrorPrototype> m_ReferenceErrorPrototype;
     76    ProtectedPtr<NativeErrorPrototype> m_SyntaxErrorPrototype;
     77    ProtectedPtr<NativeErrorPrototype> m_TypeErrorPrototype;
     78    ProtectedPtr<NativeErrorPrototype> m_UriErrorPrototype;
    7979};
    8080
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r19894 r19901  
    9797    JSLock lock;
    9898
     99    Identifier::init();
     100
    99101    m_refCount = 0;
    100102    m_timeoutTime = 0;
     
    109111    m_argumentsPropertyName = &argumentsPropertyName;
    110112    m_specialPrototypePropertyName = &specialPrototypePropertyName;
    111 
    112     interpreterMap().set(m_globalObject, this);
    113113
    114114    if (s_hook) {
     
    121121        s_hook = next = prev = this;
    122122    }
    123    
     123    interpreterMap().set(m_globalObject, this);
     124
    124125    initGlobalObject();
    125126}
     
    135136    prev->next = next;
    136137    s_hook = next;
    137     if (s_hook == this)
    138     {
     138    if (s_hook == this) {
    139139        // This was the last interpreter
    140140        s_hook = 0;
    141141    }
    142    
    143142    interpreterMap().remove(m_globalObject);
    144143}
     
    151150void Interpreter::initGlobalObject()
    152151{
    153     Identifier::init();
    154 
    155     FunctionPrototype *funcProto = new FunctionPrototype(&m_globalExec);
    156     m_FunctionPrototype = funcProto;
    157     ObjectPrototype *objProto = new ObjectPrototype(&m_globalExec, funcProto);
    158     m_ObjectPrototype = objProto;
    159     funcProto->setPrototype(m_ObjectPrototype);
    160    
    161     ArrayPrototype *arrayProto = new ArrayPrototype(&m_globalExec, objProto);
    162     m_ArrayPrototype = arrayProto;
    163     StringPrototype *stringProto = new StringPrototype(&m_globalExec, objProto);
    164     m_StringPrototype = stringProto;
    165     BooleanPrototype *booleanProto = new BooleanPrototype(&m_globalExec, objProto, funcProto);
    166     m_BooleanPrototype = booleanProto;
    167     NumberPrototype *numberProto = new NumberPrototype(&m_globalExec, objProto, funcProto);
    168     m_NumberPrototype = numberProto;
    169     DatePrototype *dateProto = new DatePrototype(&m_globalExec, objProto);
    170     m_DatePrototype = dateProto;
    171     RegExpPrototype *regexpProto = new RegExpPrototype(&m_globalExec, objProto, funcProto);
    172     m_RegExpPrototype = regexpProto;
    173     ErrorPrototype *errorProto = new ErrorPrototype(&m_globalExec, objProto, funcProto);
    174     m_ErrorPrototype = errorProto;
    175    
     152    // Clear before inititalizing, to avoid marking uninitialized (dangerous) or
     153    // stale (wasteful) pointers during initialization.
     154
     155    // Prototypes
     156    m_FunctionPrototype = 0;
     157    m_ObjectPrototype = 0;
     158
     159    m_ArrayPrototype = 0;
     160    m_StringPrototype = 0;
     161    m_BooleanPrototype = 0;
     162    m_NumberPrototype = 0;
     163    m_DatePrototype = 0;
     164    m_RegExpPrototype = 0;
     165    m_ErrorPrototype = 0;
     166   
     167    m_EvalErrorPrototype = 0;
     168    m_RangeErrorPrototype = 0;
     169    m_ReferenceErrorPrototype = 0;
     170    m_SyntaxErrorPrototype = 0;
     171    m_TypeErrorPrototype = 0;
     172    m_UriErrorPrototype = 0;
     173
     174    // Constructors
     175    m_Object = 0;
     176    m_Function = 0;
     177    m_Array = 0;
     178    m_String = 0;
     179    m_Boolean = 0;
     180    m_Number = 0;
     181    m_Date = 0;
     182    m_RegExp = 0;
     183    m_Error = 0;
     184   
     185    m_EvalError = 0;
     186    m_RangeError = 0;
     187    m_ReferenceError = 0;
     188    m_SyntaxError = 0;
     189    m_TypeError = 0;
     190    m_UriError = 0;
     191
     192    // Prototypes
     193    m_FunctionPrototype = new FunctionPrototype(&m_globalExec);
     194    m_ObjectPrototype = new ObjectPrototype(&m_globalExec, m_FunctionPrototype);
     195    m_FunctionPrototype->setPrototype(m_ObjectPrototype);
     196   
     197    m_ArrayPrototype = new ArrayPrototype(&m_globalExec, m_ObjectPrototype);
     198    m_StringPrototype = new StringPrototype(&m_globalExec, m_ObjectPrototype);
     199    m_BooleanPrototype = new BooleanPrototype(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype);
     200    m_NumberPrototype = new NumberPrototype(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype);
     201    m_DatePrototype = new DatePrototype(&m_globalExec, m_ObjectPrototype);
     202    m_RegExpPrototype = new RegExpPrototype(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype);;
     203    m_ErrorPrototype = new ErrorPrototype(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype);
     204   
     205    m_EvalErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, EvalError, "EvalError", "EvalError");
     206    m_RangeErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, RangeError, "RangeError", "RangeError");
     207    m_ReferenceErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, ReferenceError, "ReferenceError", "ReferenceError");
     208    m_SyntaxErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, SyntaxError, "SyntaxError", "SyntaxError");
     209    m_TypeErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, TypeError, "TypeError", "TypeError");
     210    m_UriErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, URIError, "URIError", "URIError");
     211
     212    // Constructors
     213    m_Object = new ObjectObjectImp(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype);
     214    m_Function = new FunctionObjectImp(&m_globalExec, m_FunctionPrototype);
     215    m_Array = new ArrayObjectImp(&m_globalExec, m_FunctionPrototype, m_ArrayPrototype);
     216    m_String = new StringObjectImp(&m_globalExec, m_FunctionPrototype, m_StringPrototype);
     217    m_Boolean = new BooleanObjectImp(&m_globalExec, m_FunctionPrototype, m_BooleanPrototype);
     218    m_Number = new NumberObjectImp(&m_globalExec, m_FunctionPrototype, m_NumberPrototype);
     219    m_Date = new DateObjectImp(&m_globalExec, m_FunctionPrototype, m_DatePrototype);
     220    m_RegExp = new RegExpObjectImp(&m_globalExec, m_FunctionPrototype, m_RegExpPrototype);
     221    m_Error = new ErrorObjectImp(&m_globalExec, m_FunctionPrototype, m_ErrorPrototype);
     222   
     223    m_EvalError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_EvalErrorPrototype);
     224    m_RangeError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_RangeErrorPrototype);
     225    m_ReferenceError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_ReferenceErrorPrototype);
     226    m_SyntaxError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_SyntaxErrorPrototype);
     227    m_TypeError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_TypeErrorPrototype);
     228    m_UriError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_UriErrorPrototype);
     229   
     230    m_FunctionPrototype->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum);
     231    m_ObjectPrototype->put(&m_globalExec, constructorPropertyName, m_Object, DontEnum | DontDelete | ReadOnly);
     232    m_FunctionPrototype->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum | DontDelete | ReadOnly);
     233    m_ArrayPrototype->put(&m_globalExec, constructorPropertyName, m_Array, DontEnum | DontDelete | ReadOnly);
     234    m_BooleanPrototype->put(&m_globalExec, constructorPropertyName, m_Boolean, DontEnum | DontDelete | ReadOnly);
     235    m_StringPrototype->put(&m_globalExec, constructorPropertyName, m_String, DontEnum | DontDelete | ReadOnly);
     236    m_NumberPrototype->put(&m_globalExec, constructorPropertyName, m_Number, DontEnum | DontDelete | ReadOnly);
     237    m_DatePrototype->put(&m_globalExec, constructorPropertyName, m_Date, DontEnum | DontDelete | ReadOnly);
     238    m_RegExpPrototype->put(&m_globalExec, constructorPropertyName, m_RegExp, DontEnum | DontDelete | ReadOnly);
     239    m_ErrorPrototype->put(&m_globalExec, constructorPropertyName, m_Error, DontEnum | DontDelete | ReadOnly);
     240    m_EvalErrorPrototype->put(&m_globalExec, constructorPropertyName, m_EvalError, DontEnum | DontDelete | ReadOnly);
     241    m_RangeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_RangeError, DontEnum | DontDelete | ReadOnly);
     242    m_ReferenceErrorPrototype->put(&m_globalExec, constructorPropertyName, m_ReferenceError, DontEnum | DontDelete | ReadOnly);
     243    m_SyntaxErrorPrototype->put(&m_globalExec, constructorPropertyName, m_SyntaxError, DontEnum | DontDelete | ReadOnly);
     244    m_TypeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_TypeError, DontEnum | DontDelete | ReadOnly);
     245    m_UriErrorPrototype->put(&m_globalExec, constructorPropertyName, m_UriError, DontEnum | DontDelete | ReadOnly);
     246
     247    // Set global object prototype
    176248    JSObject* o = m_globalObject;
    177249    while (o->prototype()->isObject())
    178250        o = static_cast<JSObject*>(o->prototype());
    179251    o->setPrototype(m_ObjectPrototype);
    180    
    181     // Constructors (Object, Array, etc.)
    182     m_Object = new ObjectObjectImp(&m_globalExec, objProto, funcProto);
    183     m_Function = new FunctionObjectImp(&m_globalExec, funcProto);
    184     m_Array = new ArrayObjectImp(&m_globalExec, funcProto, arrayProto);
    185     m_String = new StringObjectImp(&m_globalExec, funcProto, stringProto);
    186     m_Boolean = new BooleanObjectImp(&m_globalExec, funcProto, booleanProto);
    187     m_Number = new NumberObjectImp(&m_globalExec, funcProto, numberProto);
    188     m_Date = new DateObjectImp(&m_globalExec, funcProto, dateProto);
    189     m_RegExp = new RegExpObjectImp(&m_globalExec, funcProto, regexpProto);
    190     m_Error = new ErrorObjectImp(&m_globalExec, funcProto, errorProto);
    191    
    192     // Error object prototypes
    193     m_EvalErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, EvalError, "EvalError", "EvalError");
    194     m_RangeErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, RangeError, "RangeError", "RangeError");
    195     m_ReferenceErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, ReferenceError, "ReferenceError", "ReferenceError");
    196     m_SyntaxErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, SyntaxError, "SyntaxError", "SyntaxError");
    197     m_TypeErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, TypeError, "TypeError", "TypeError");
    198     m_UriErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, URIError, "URIError", "URIError");
    199    
    200     // Error objects
    201     m_EvalError = new NativeErrorImp(&m_globalExec, funcProto, m_EvalErrorPrototype);
    202     m_RangeError = new NativeErrorImp(&m_globalExec, funcProto, m_RangeErrorPrototype);
    203     m_ReferenceError = new NativeErrorImp(&m_globalExec, funcProto, m_ReferenceErrorPrototype);
    204     m_SyntaxError = new NativeErrorImp(&m_globalExec, funcProto, m_SyntaxErrorPrototype);
    205     m_TypeError = new NativeErrorImp(&m_globalExec, funcProto, m_TypeErrorPrototype);
    206     m_UriError = new NativeErrorImp(&m_globalExec, funcProto, m_UriErrorPrototype);
    207    
    208     // ECMA 15.3.4.1
    209     funcProto->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum);
    210    
     252
     253    // Set global constructors
     254    // FIXME: kjs_window.cpp checks Internal/DontEnum as a performance hack, to
     255    // see that these values can be put directly without a check for override
     256    // properties. Maybe we should call putDirect instead, for better encapsulation.
    211257    m_globalObject->put(&m_globalExec, "Object", m_Object, DontEnum);
    212258    m_globalObject->put(&m_globalExec, "Function", m_Function, DontEnum);
     
    218264    m_globalObject->put(&m_globalExec, "RegExp", m_RegExp, DontEnum);
    219265    m_globalObject->put(&m_globalExec, "Error", m_Error, DontEnum);
    220     // Using Internal for those to have something != 0
    221     // (see kjs_window). Maybe DontEnum would be ok too ?
    222266    m_globalObject->put(&m_globalExec, "EvalError",m_EvalError, Internal);
    223267    m_globalObject->put(&m_globalExec, "RangeError",m_RangeError, Internal);
     
    226270    m_globalObject->put(&m_globalExec, "TypeError",m_TypeError, Internal);
    227271    m_globalObject->put(&m_globalExec, "URIError",m_UriError, Internal);
    228    
    229     // Set the constructorPropertyName property of all builtin constructors
    230     objProto->put(&m_globalExec, constructorPropertyName, m_Object, DontEnum | DontDelete | ReadOnly);
    231     funcProto->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum | DontDelete | ReadOnly);
    232     arrayProto->put(&m_globalExec, constructorPropertyName, m_Array, DontEnum | DontDelete | ReadOnly);
    233     booleanProto->put(&m_globalExec, constructorPropertyName, m_Boolean, DontEnum | DontDelete | ReadOnly);
    234     stringProto->put(&m_globalExec, constructorPropertyName, m_String, DontEnum | DontDelete | ReadOnly);
    235     numberProto->put(&m_globalExec, constructorPropertyName, m_Number, DontEnum | DontDelete | ReadOnly);
    236     dateProto->put(&m_globalExec, constructorPropertyName, m_Date, DontEnum | DontDelete | ReadOnly);
    237     regexpProto->put(&m_globalExec, constructorPropertyName, m_RegExp, DontEnum | DontDelete | ReadOnly);
    238     errorProto->put(&m_globalExec, constructorPropertyName, m_Error, DontEnum | DontDelete | ReadOnly);
    239     m_EvalErrorPrototype->put(&m_globalExec, constructorPropertyName, m_EvalError, DontEnum | DontDelete | ReadOnly);
    240     m_RangeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_RangeError, DontEnum | DontDelete | ReadOnly);
    241     m_ReferenceErrorPrototype->put(&m_globalExec, constructorPropertyName, m_ReferenceError, DontEnum | DontDelete | ReadOnly);
    242     m_SyntaxErrorPrototype->put(&m_globalExec, constructorPropertyName, m_SyntaxError, DontEnum | DontDelete | ReadOnly);
    243     m_TypeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_TypeError, DontEnum | DontDelete | ReadOnly);
    244     m_UriErrorPrototype->put(&m_globalExec, constructorPropertyName, m_UriError, DontEnum | DontDelete | ReadOnly);
    245    
    246     // built-in values
    247     m_globalObject->put(&m_globalExec, "NaN",        jsNaN(), DontEnum|DontDelete);
    248     m_globalObject->put(&m_globalExec, "Infinity",   jsNumber(Inf), DontEnum|DontDelete);
    249     m_globalObject->put(&m_globalExec, "undefined",  jsUndefined(), DontEnum|DontDelete);
    250    
    251     // built-in functions
    252     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::Eval, 1, "eval"), DontEnum);
    253     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);
    254     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);
    255     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);
    256     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);
    257     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::Escape, 1, "escape"), DontEnum);
    258     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);
    259     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);
    260     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);
    261     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);
    262     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);
     272
     273    // Set global values
     274    m_globalObject->put(&m_globalExec, "Math", new MathObjectImp(&m_globalExec, m_ObjectPrototype), DontEnum);
     275    m_globalObject->put(&m_globalExec, "NaN", jsNaN(), DontEnum|DontDelete);
     276    m_globalObject->put(&m_globalExec, "Infinity", jsNumber(Inf), DontEnum|DontDelete);
     277    m_globalObject->put(&m_globalExec, "undefined", jsUndefined(), DontEnum|DontDelete);
     278   
     279    // Set global functions
     280    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum);
     281    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);
     282    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);
     283    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);
     284    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);
     285    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum);
     286    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);
     287    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);
     288    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);
     289    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);
     290    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);
    263291#ifndef NDEBUG
    264     m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);
     292    m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);
    265293#endif
    266    
    267     // built-in objects
    268     m_globalObject->put(&m_globalExec, "Math", new MathObjectImp(&m_globalExec, objProto), DontEnum);
    269294}
    270295
     
    517542    if (m_context)
    518543        m_context->mark();
     544
     545    if (m_globalExec.exception() && !m_globalExec.exception()->marked())
     546        m_globalExec.exception()->mark();
     547
    519548    if (m_globalObject && !m_globalObject->marked())
    520549        m_globalObject->mark();
    521     if (m_globalExec.exception() && !m_globalExec.exception()->marked())
    522         m_globalExec.exception()->mark();
     550
     551    if (m_Object && !m_Object->marked())
     552        m_Object->mark();
     553    if (m_Function && !m_Function->marked())
     554        m_Function->mark();
     555    if (m_Array && !m_Array->marked())
     556        m_Array->mark();
     557    if (m_Boolean && !m_Boolean->marked())
     558        m_Boolean->mark();
     559    if (m_String && !m_String->marked())
     560        m_String->mark();
     561    if (m_Number && !m_Number->marked())
     562        m_Number->mark();
     563    if (m_Date && !m_Date->marked())
     564        m_Date->mark();
     565    if (m_RegExp && !m_RegExp->marked())
     566        m_RegExp->mark();
     567    if (m_Error && !m_Error->marked())
     568        m_Error->mark();
     569   
     570    if (m_ObjectPrototype && !m_ObjectPrototype->marked())
     571        m_ObjectPrototype->mark();
     572    if (m_FunctionPrototype && !m_FunctionPrototype->marked())
     573        m_FunctionPrototype->mark();
     574    if (m_ArrayPrototype && !m_ArrayPrototype->marked())
     575        m_ArrayPrototype->mark();
     576    if (m_BooleanPrototype && !m_BooleanPrototype->marked())
     577        m_BooleanPrototype->mark();
     578    if (m_StringPrototype && !m_StringPrototype->marked())
     579        m_StringPrototype->mark();
     580    if (m_NumberPrototype && !m_NumberPrototype->marked())
     581        m_NumberPrototype->mark();
     582    if (m_DatePrototype && !m_DatePrototype->marked())
     583        m_DatePrototype->mark();
     584    if (m_RegExpPrototype && !m_RegExpPrototype->marked())
     585        m_RegExpPrototype->mark();
     586    if (m_ErrorPrototype && !m_ErrorPrototype->marked())
     587        m_ErrorPrototype->mark();
     588   
     589    if (m_EvalError && !m_EvalError->marked())
     590        m_EvalError->mark();
     591    if (m_RangeError && !m_RangeError->marked())
     592        m_RangeError->mark();
     593    if (m_ReferenceError && !m_ReferenceError->marked())
     594        m_ReferenceError->mark();
     595    if (m_SyntaxError && !m_SyntaxError->marked())
     596        m_SyntaxError->mark();
     597    if (m_TypeError && !m_TypeError->marked())
     598        m_TypeError->mark();
     599    if (m_UriError && !m_UriError->marked())
     600        m_UriError->mark();
     601   
     602    if (m_EvalErrorPrototype && !m_EvalErrorPrototype->marked())
     603        m_EvalErrorPrototype->mark();
     604    if (m_RangeErrorPrototype && !m_RangeErrorPrototype->marked())
     605        m_RangeErrorPrototype->mark();
     606    if (m_ReferenceErrorPrototype && !m_ReferenceErrorPrototype->marked())
     607        m_ReferenceErrorPrototype->mark();
     608    if (m_SyntaxErrorPrototype && !m_SyntaxErrorPrototype->marked())
     609        m_SyntaxErrorPrototype->mark();
     610    if (m_TypeErrorPrototype && !m_TypeErrorPrototype->marked())
     611        m_TypeErrorPrototype->mark();
     612    if (m_UriErrorPrototype && !m_UriErrorPrototype->marked())
     613        m_UriErrorPrototype->mark();
    523614}
    524615
  • trunk/JavaScriptCore/kjs/interpreter.h

    r19534 r19901  
    3232namespace KJS {
    3333
     34  class ArrayObjectImp;
     35  class ArrayPrototype;
     36  class BooleanObjectImp;
     37  class BooleanPrototype;
    3438  class Context;
     39  class DateObjectImp;
     40  class DatePrototype;
    3541  class Debugger;
     42  class ErrorObjectImp;
     43  class ErrorPrototype;
     44  class EvalError;
     45  class EvalErrorPrototype;
     46  class FunctionObjectImp;
     47  class FunctionPrototype;
     48  class NativeErrorImp;
     49  class NativeErrorPrototype;
     50  class NumberObjectImp;
     51  class NumberPrototype;
     52  class ObjectObjectImp;
     53  class ObjectPrototype;
     54  class RangeError;
     55  class RangeErrorPrototype;
     56  class ReferenceError;
     57  class ReferenceError;
     58  class ReferenceErrorPrototype;
     59  class RegExpObjectImp;
     60  class RegExpPrototype;
    3661  class RuntimeMethod;
    3762  class SavedBuiltins;
    3863  class ScopeChain;
     64  class StringObjectImp;
     65  class StringPrototype;
     66  class SyntaxErrorPrototype;
     67  class TypeError;
     68  class TypeErrorPrototype;
     69  class UriError;
     70  class UriErrorPrototype;
    3971 
    4072  /**
     
    71103
    72104    /**
     105     * Resets the global object's default properties and adds the default object
     106     * prototype to its prototype chain.
     107     */
     108    void initGlobalObject();
     109
     110    /**
    73111     * Returns the object that is used as the global object during all script
    74112     * execution performed by this interpreter
    75113     */
    76114    JSObject* globalObject() const;
    77     void initGlobalObject();
    78115
    79116    /**
     
    327364
    328365private:
     366    void init();
     367
     368    void resetTimeoutCheck();
    329369    bool checkTimeout();
    330     void init();
    331     void resetTimeoutCheck();
    332 
    333     /**
    334      * This constructor is not implemented, in order to prevent
    335      * copy-construction of Interpreter objects. You should always pass around
    336      * pointers to an interpreter instance instead.
    337      */
     370
     371    // Uncopyable
    338372    Interpreter(const Interpreter&);
    339    
    340     /**
    341      * This constructor is not implemented, in order to prevent assignment of
    342      * Interpreter objects. You should always pass around pointers to an
    343      * interpreter instance instead.
    344      */
    345373    Interpreter operator=(const Interpreter&);
    346374   
     
    348376   
    349377    ExecState m_globalExec;
    350     JSObject* m_globalObject;
    351378
    352379    const Identifier *m_argumentsPropertyName;
     
    370397    unsigned m_ticksUntilNextTimeoutCheck;
    371398
    372     ProtectedPtr<JSObject> m_Object;
    373     ProtectedPtr<JSObject> m_Function;
    374     ProtectedPtr<JSObject> m_Array;
    375     ProtectedPtr<JSObject> m_Boolean;
    376     ProtectedPtr<JSObject> m_String;
    377     ProtectedPtr<JSObject> m_Number;
    378     ProtectedPtr<JSObject> m_Date;
    379     ProtectedPtr<JSObject> m_RegExp;
    380     ProtectedPtr<JSObject> m_Error;
    381    
    382     ProtectedPtr<JSObject> m_ObjectPrototype;
    383     ProtectedPtr<JSObject> m_FunctionPrototype;
    384     ProtectedPtr<JSObject> m_ArrayPrototype;
    385     ProtectedPtr<JSObject> m_BooleanPrototype;
    386     ProtectedPtr<JSObject> m_StringPrototype;
    387     ProtectedPtr<JSObject> m_NumberPrototype;
    388     ProtectedPtr<JSObject> m_DatePrototype;
    389     ProtectedPtr<JSObject> m_RegExpPrototype;
    390     ProtectedPtr<JSObject> m_ErrorPrototype;
    391    
    392     ProtectedPtr<JSObject> m_EvalError;
    393     ProtectedPtr<JSObject> m_RangeError;
    394     ProtectedPtr<JSObject> m_ReferenceError;
    395     ProtectedPtr<JSObject> m_SyntaxError;
    396     ProtectedPtr<JSObject> m_TypeError;
    397     ProtectedPtr<JSObject> m_UriError;
    398    
    399     ProtectedPtr<JSObject> m_EvalErrorPrototype;
    400     ProtectedPtr<JSObject> m_RangeErrorPrototype;
    401     ProtectedPtr<JSObject> m_ReferenceErrorPrototype;
    402     ProtectedPtr<JSObject> m_SyntaxErrorPrototype;
    403     ProtectedPtr<JSObject> m_TypeErrorPrototype;
    404     ProtectedPtr<JSObject> m_UriErrorPrototype;
     399    JSObject* m_globalObject;
     400
     401    ObjectObjectImp* m_Object;
     402    FunctionObjectImp* m_Function;
     403    ArrayObjectImp* m_Array;
     404    BooleanObjectImp* m_Boolean;
     405    StringObjectImp* m_String;
     406    NumberObjectImp* m_Number;
     407    DateObjectImp* m_Date;
     408    RegExpObjectImp* m_RegExp;
     409    ErrorObjectImp* m_Error;
     410   
     411    ObjectPrototype* m_ObjectPrototype;
     412    FunctionPrototype* m_FunctionPrototype;
     413    ArrayPrototype* m_ArrayPrototype;
     414    BooleanPrototype* m_BooleanPrototype;
     415    StringPrototype* m_StringPrototype;
     416    NumberPrototype* m_NumberPrototype;
     417    DatePrototype* m_DatePrototype;
     418    RegExpPrototype* m_RegExpPrototype;
     419    ErrorPrototype* m_ErrorPrototype;
     420   
     421    NativeErrorImp* m_EvalError;
     422    NativeErrorImp* m_RangeError;
     423    NativeErrorImp* m_ReferenceError;
     424    NativeErrorImp* m_SyntaxError;
     425    NativeErrorImp* m_TypeError;
     426    NativeErrorImp* m_UriError;
     427   
     428    NativeErrorPrototype* m_EvalErrorPrototype;
     429    NativeErrorPrototype* m_RangeErrorPrototype;
     430    NativeErrorPrototype* m_ReferenceErrorPrototype;
     431    NativeErrorPrototype* m_SyntaxErrorPrototype;
     432    NativeErrorPrototype* m_TypeErrorPrototype;
     433    NativeErrorPrototype* m_UriErrorPrototype;
    405434  };
    406435
Note: See TracChangeset for help on using the changeset viewer.